Creating release candidate final for 3.5.1

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/tags/RELEASE_351@225673 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/final/.arcconfig b/final/.arcconfig
new file mode 100644
index 0000000..6d07e82
--- /dev/null
+++ b/final/.arcconfig
@@ -0,0 +1,4 @@
+{
+  "project_id" : "libcxx",
+  "conduit_uri" : "http://reviews.llvm.org/"
+}
diff --git a/final/CMakeLists.txt b/final/CMakeLists.txt
new file mode 100644
index 0000000..c20e5d1
--- /dev/null
+++ b/final/CMakeLists.txt
@@ -0,0 +1,282 @@
+# See www/CMake.html for instructions on how to build libcxx with CMake.
+
+#===============================================================================
+# Setup Project
+#===============================================================================
+
+project(libcxx CXX C)
+cmake_minimum_required(VERSION 2.8)
+
+set(PACKAGE_NAME libcxx)
+set(PACKAGE_VERSION trunk-svn)
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
+
+# Add path for custom modules
+set(CMAKE_MODULE_PATH
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
+  ${CMAKE_MODULE_PATH}
+  )
+
+# Require out of source build.
+include(MacroEnsureOutOfSourceBuild)
+MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
+ "${PROJECT_NAME} requires an out of source build. Please create a separate
+ build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
+ )
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  set(LIBCXX_BUILT_STANDALONE 1)
+endif()
+
+#===============================================================================
+# Setup CMake Options
+#===============================================================================
+
+# Define options.
+option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
+option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
+option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
+option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
+option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
+option(LIBCXX_ENABLE_CXX0X "Enable -std=c++0x and use of c++0x language features if the compiler supports it." ON)
+option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
+option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
+
+set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
+if (NOT DEFINED LIBCXX_CXX_ABI)
+  set(LIBCXX_CXX_ABI "none")
+endif()
+set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
+    "Specify C++ ABI library to use." FORCE)
+set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
+
+#===============================================================================
+# Configure System
+#===============================================================================
+
+# Get triples.
+include(GetTriple)
+get_host_triple(LIBCXX_HOST_TRIPLE
+  LIBCXX_HOST_ARCH
+  LIBCXX_HOST_VENDOR
+  LIBCXX_HOST_OS
+  )
+set(LIBCXX_HOST_TRIPLE ${LIBCXX_HOST_TRIPLE} CACHE STRING "Host triple.")
+get_target_triple(LIBCXX_TARGET_TRIPLE
+  LIBCXX_TARGET_ARCH
+  LIBCXX_TARGET_VENDOR
+  LIBCXX_TARGET_OS
+  )
+set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")
+
+#===============================================================================
+# Add an ABI library if appropriate
+#===============================================================================
+
+#
+# _setup_abi: Set up the build to use an ABI library
+#
+# Parameters:
+#   abidefines: A list of defines needed to compile libc++ with the ABI library
+#   abilibs   : A list of libraries to link against
+#   abifiles  : A list of files (which may be relative paths) to copy into the
+#               libc++ build tree for the build.  These files will also be
+#               installed alongside the libc++ headers.
+#   abidirs   : A list of relative paths to create under an include directory
+#               in the libc++ build directory.
+#
+macro(setup_abi_lib abipathvar abidefines abilibs abifiles abidirs)
+  list(APPEND LIBCXX_CXX_FEATURE_FLAGS ${abidefines})
+  set(${abipathvar} "${${abipathvar}}"
+    CACHE PATH
+    "Paths to C++ ABI header directories separated by ';'." FORCE
+    )
+  set(LIBCXX_CXX_ABI_LIBRARIES ${abilibs})
+  set(LIBCXX_ABILIB_FILES ${abifiles})
+
+  file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include")
+  foreach(_d ${abidirs})
+    file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/${_d}")
+  endforeach()
+
+  foreach(fpath ${LIBCXX_ABILIB_FILES})
+    set(found FALSE)
+    foreach(incpath ${${abipathvar}})
+      if (EXISTS "${incpath}/${fpath}")
+        set(found TRUE)
+        get_filename_component(dstdir ${fpath} PATH)
+        get_filename_component(ifile ${fpath} NAME)
+        file(COPY "${incpath}/${fpath}"
+          DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}"
+          )
+        list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}")
+      endif()
+    endforeach()
+    if (NOT found)
+      message(FATAL_ERROR "Failed to find ${fpath}")
+    endif()
+  endforeach()
+
+  add_custom_target(LIBCXX_CXX_ABI_DEPS DEPENDS ${abilib_headers})
+  include_directories("${CMAKE_BINARY_DIR}/include")
+
+  install(FILES ${abilib_headers}
+    DESTINATION include/c++/v1
+    PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+    )
+endmacro()
+
+if ("${LIBCXX_CXX_ABI}" STREQUAL "libstdc++" OR
+    "${LIBCXX_CXX_ABI}" STREQUAL "libsupc++")
+  set(_LIBSUPCXX_INCLUDE_FILES
+    cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h
+    bits/cxxabi_tweaks.h bits/cxxabi_forced.h
+    )
+  if ("${LIBCXX_CXX_ABI}" STREQUAL "libstdc++")
+    set(_LIBSUPCXX_DEFINES "-DLIBSTDCXX")
+    set(_LIBSUPCXX_LIBNAME stdc++)
+  else()
+    set(_LIBSUPCXX_DEFINES "")
+    set(_LIBSUPCXX_LIBNAME supc++)
+  endif()
+  setup_abi_lib("LIBCXX_LIBSUPCXX_INCLUDE_PATHS"
+    "-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}"
+    "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
+    )
+elseif ("${LIBCXX_CXX_ABI}" STREQUAL "libcxxabi")
+  setup_abi_lib("LIBCXX_LIBCXXABI_INCLUDE_PATHS" ""
+    "c++abi" "cxxabi.h" ""
+    )
+elseif ("${LIBCXX_CXX_ABI}" STREQUAL "libcxxrt")
+  setup_abi_lib("LIBCXX_LIBCXXRT_INCLUDE_PATHS" "-DLIBCXXRT"
+    "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
+    )
+elseif (NOT "${LIBCXX_CXX_ABI}" STREQUAL "none")
+  message(FATAL_ERROR
+    "Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are "
+    "supported for c++ abi."
+    )
+endif ()
+
+# Configure compiler.
+include(config-ix)
+
+#===============================================================================
+# Setup Compiler Flags
+#===============================================================================
+
+# Get required flags.
+# On all systems the system c++ standard library headers need to be excluded.
+if (MSVC)
+  # MSVC only has -X, which disables all default includes; including the crt.
+  # Thus, we do nothing and hope we don't accidentally include any of the C++
+  # headers.
+else()
+  if (LIBCXX_HAS_NOSTDINCXX_FLAG)
+    list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -nostdinc++)
+    string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  endif()
+  if (LIBCXX_ENABLE_CXX0X AND LIBCXX_HAS_STDCXX0X_FLAG)
+    list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -std=c++0x)
+  endif()
+endif()
+
+macro(append_if list condition var)
+  if (${condition})
+    list(APPEND ${list} ${var})
+  endif()
+endmacro()
+
+# Get warning flags
+if (NOT MSVC)
+  append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_WALL_FLAG -Wall)
+  list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -Werror=return-type)
+endif()
+
+append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_W_FLAG -W)
+append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter)
+append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
+append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_WNO_LONG_LONG_FLAG -Wno-long-long)
+if (LIBCXX_ENABLE_WERROR)
+  append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_WERROR_FLAG -Werror)
+  append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_WX_FLAG -WX)
+else()
+  append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_WNO_ERROR_FLAG -Wno-error)
+  append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_NO_WX_FLAG -WX-)
+endif()
+if (LIBCXX_ENABLE_PEDANTIC)
+  append_if(LIBCXX_CXX_WARNING_FLAGS LIBCXX_HAS_PEDANTIC_FLAG -pedantic)
+endif()
+
+# Get feature flags.
+# Exceptions
+if (LIBCXX_ENABLE_EXCEPTIONS)
+  # Catches C++ exceptions only and tells the compiler to assume that extern C
+  # functions never throw a C++ exception.
+  append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_EHSC_FLAG -EHsc)
+else()
+  list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_NO_EXCEPTIONS)
+  append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_EHS_FLAG -EHs-)
+  append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_EHA_FLAG -EHa-)
+  append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions)
+endif()
+# RTTI
+if (NOT LIBCXX_ENABLE_RTTI)
+  list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_NO_RTTI)
+  append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_GR_FLAG -GR-)
+  append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_FNO_RTTI_FLAG -fno-rtti)
+endif()
+# Assert
+string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
+if (LIBCXX_ENABLE_ASSERTIONS)
+  # MSVC doesn't like _DEBUG on release builds. See PR 4379.
+  if (NOT MSVC)
+    list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_DEBUG)
+  endif()
+  # On Release builds cmake automatically defines NDEBUG, so we
+  # explicitly undefine it:
+  if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
+    list(APPEND LIBCXX_CXX_FEATURE_FLAGS -UNDEBUG)
+  endif()
+else()
+  if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
+    list(APPEND LIBCXX_CXX_FEATURE_FLAGS -DNDEBUG)
+  endif()
+endif()
+# Static library
+if (NOT LIBCXX_ENABLE_SHARED)
+  list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_BUILD_STATIC)
+endif()
+
+# This is the _ONLY_ place where add_definitions is called.
+if (MSVC)
+  add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+endif()
+
+string(REPLACE ";" " " LIBCXX_CXX_REQUIRED_FLAGS "${LIBCXX_CXX_REQUIRED_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_REQUIRED_FLAGS}")
+
+string(REPLACE ";" " " LIBCXX_CXX_WARNING_FLAGS "${LIBCXX_CXX_WARNING_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_WARNING_FLAGS}")
+
+string(REPLACE ";" " " LIBCXX_CXX_FEATURE_FLAGS "${LIBCXX_CXX_FEATURE_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FEATURE_FLAGS}")
+
+#===============================================================================
+# Setup Source Code
+#===============================================================================
+
+include_directories(include)
+add_subdirectory(include)
+
+# Add source code. This also contains all of the logic for deciding linker flags
+# soname, etc...
+add_subdirectory(lib)
+
+#===============================================================================
+# Setup Tests
+#===============================================================================
+
+add_subdirectory(test)
diff --git a/final/CREDITS.TXT b/final/CREDITS.TXT
new file mode 100644
index 0000000..368b526
--- /dev/null
+++ b/final/CREDITS.TXT
@@ -0,0 +1,123 @@
+This file is a partial list of people who have contributed to the LLVM/libc++
+project.  If you have contributed a patch or made some other contribution to
+LLVM/libc++, please submit a patch to this file to add yourself, and it will be
+done!
+
+The list is sorted by surname and formatted to allow easy grepping and
+beautification by scripts.  The fields are: name (N), email (E), web-address
+(W), PGP key ID and fingerprint (P), description (D), and snail-mail address
+(S).
+
+N: Saleem Abdulrasool
+E: compnerd@compnerd.org
+D: Minor patches and Linux fixes.
+
+N: Dimitry Andric
+E: dimitry@andric.com
+D: Visibility fixes, minor FreeBSD portability patches.
+
+N: Holger Arnold
+E: holgerar@gmail.com
+D: Minor fix.
+
+N: Ruben Van Boxem
+E: vanboxem dot ruben at gmail dot com
+D: Initial Windows patches.
+
+N: David Chisnall
+E: theraven at theravensnest dot org
+D: FreeBSD and Solaris ports, libcxxrt support, some atomics work.
+
+N: Marshall Clow
+E: mclow.lists@gmail.com
+E: marshall@idio.com
+D: C++14 support, patches and bug fixes.
+
+N: Bill Fisher
+E: william.w.fisher@gmail.com
+D: Regex bug fixes.
+
+N: Matthew Dempsky
+E: matthew@dempsky.org
+D: Minor patches and bug fixes.
+
+N: Google Inc.
+D: Copyright owner and contributor of the CityHash algorithm
+
+N: Howard Hinnant
+E: hhinnant@apple.com
+D: Architect and primary author of libc++
+
+N: Hyeon-bin Jeong
+E: tuhertz@gmail.com
+D: Minor patches and bug fixes.
+
+N: Argyrios Kyrtzidis
+E: kyrtzidis@apple.com
+D: Bug fixes.
+
+N: Bruce Mitchener, Jr.
+E: bruce.mitchener@gmail.com
+D: Emscripten-related changes.
+
+N: Michel Morin
+E: mimomorin@gmail.com
+D: Minor patches to is_convertible.
+
+N: Andrew Morrow
+E: andrew.c.morrow@gmail.com
+D: Minor patches and Linux fixes.
+
+N: Arvid Picciani
+E: aep at exys dot org
+D: Minor patches and musl port.
+
+N: Bjorn Reese
+E: breese@users.sourceforge.net
+D: Initial regex prototype
+
+N: Nico Rieck
+E: nico.rieck@gmail.com
+D: Windows fixes
+
+N: Jonathan Sauer
+D: Minor patches, mostly related to constexpr
+
+N: Craig Silverstein
+E: csilvers@google.com
+D: Implemented Cityhash as the string hash function on 64-bit machines
+
+N: Richard Smith
+D: Minor patches.
+
+N: Joerg Sonnenberger
+E: joerg@NetBSD.org
+D: NetBSD port.
+
+N: Stephan Tolksdorf
+E: st@quanttec.com
+D: Minor <atomic> fix
+
+N: Michael van der Westhuizen
+E: r1mikey at gmail dot com
+
+N: Klaas de Vries
+E: klaas at klaasgaaf dot nl
+D: Minor bug fix.
+
+N: Zhang Xiongpang
+E: zhangxiongpang@gmail.com
+D: Minor patches and bug fixes.
+
+N: Xing Xue
+E: xingxue@ca.ibm.com
+D: AIX port
+
+N: Zhihao Yuan
+E: lichray@gmail.com
+D: Standard compatibility fixes.
+
+N: Jeffrey Yasskin
+E: jyasskin@gmail.com
+E: jyasskin@google.com
+D: Linux fixes.
diff --git a/final/LICENSE.TXT b/final/LICENSE.TXT
new file mode 100644
index 0000000..41ca5d1
--- /dev/null
+++ b/final/LICENSE.TXT
@@ -0,0 +1,76 @@
+==============================================================================
+libc++ License
+==============================================================================
+
+The libc++ library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license.  As a user of this code you may choose
+to use it under either license.  As a contributor, you agree to allow your code
+to be used under both.
+
+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
+
+All rights reserved.
+
+Developed by:
+
+    LLVM Team
+
+    University of Illinois at Urbana-Champaign
+
+    http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimers.
+
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimers in the
+      documentation and/or other materials provided with the distribution.
+
+    * Neither the names of the LLVM Team, University of Illinois at
+      Urbana-Champaign, nor the names of its contributors may be used to
+      endorse or promote products derived from this Software without specific
+      prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==============================================================================
+
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/final/Makefile b/final/Makefile
new file mode 100644
index 0000000..ab7b5b6
--- /dev/null
+++ b/final/Makefile
@@ -0,0 +1,56 @@
+##
+# libc++ Makefile
+##
+
+SRCDIRS = .
+DESTDIR = $(DSTROOT)
+
+OBJROOT=.
+SYMROOT=.
+export TRIPLE=-apple-
+
+ifeq (,$(RC_INDIGO))
+	INSTALL_PREFIX=""
+else
+	INSTALL_PREFIX="$(SDKROOT)"
+endif
+INSTALL_DIR=$(DSTROOT)/$(INSTALL_PREFIX)
+
+.PHONY: help installsrc clean installheaders install
+
+help::
+	@echo "Use make install DSTROOT=<destination>"
+
+installsrc:: $(SRCROOT)
+
+	ditto $(SRCDIRS)/include $(SRCROOT)/include
+	ditto $(SRCDIRS)/lib $(SRCROOT)/lib
+	ditto $(SRCDIRS)/src $(SRCROOT)/src
+	ditto $(SRCDIRS)/Makefile $(SRCROOT)/Makefile
+
+clean::
+
+# The installheaders target is used by clang's runtime/libcxx makefile.
+installheaders::
+	mkdir -p $(HEADER_DIR)/c++/v1/ext
+	(cd $(SRCDIRS)/include && \
+	  tar cf - --exclude=".*" --exclude=support \
+	           --exclude=CMakeLists.txt *) | \
+	  (cd $(HEADER_DIR)/c++/v1 && tar xf -)
+	chmod 755 $(HEADER_DIR)/c++/v1
+	chmod 644 $(HEADER_DIR)/c++/v1/*
+	chmod 755 $(HEADER_DIR)/c++/v1/ext
+	chmod 644 $(HEADER_DIR)/c++/v1/ext/*
+	chmod 755 $(HEADER_DIR)/c++/v1/experimental
+	chmod 644 $(HEADER_DIR)/c++/v1/experimental/*
+
+install::
+
+	cd lib && ./buildit
+	ditto lib/libc++.1.dylib $(SYMROOT)/usr/lib/libc++.1.dylib
+	cd lib && dsymutil -o $(SYMROOT)/libc++.1.dylib.dSYM \
+	  $(SYMROOT)/usr/lib/libc++.1.dylib
+	mkdir -p $(INSTALL_DIR)/usr/lib
+	strip -S -o $(INSTALL_DIR)/usr/lib/libc++.1.dylib \
+	  $(SYMROOT)/usr/lib/libc++.1.dylib
+	cd $(INSTALL_DIR)/usr/lib && ln -s libc++.1.dylib libc++.dylib
diff --git a/final/cmake/Modules/GetTriple.cmake b/final/cmake/Modules/GetTriple.cmake
new file mode 100644
index 0000000..c555931
--- /dev/null
+++ b/final/cmake/Modules/GetTriple.cmake
@@ -0,0 +1,53 @@
+# Define functions to get the host and target triple.
+
+function(get_host_triple out out_arch out_vendor out_os)
+  # Get the architecture.
+  set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
+  if (arch STREQUAL "x86")
+    set(arch "i686")
+  endif()
+  # Get the vendor.
+  if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
+    set(vendor "apple")
+  else()
+    set(vendor "pc")
+  endif()
+  # Get os.
+  if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
+    set(os "win32")
+  else()
+    string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} os)
+  endif()
+  set(triple "${arch}-${vendor}-${os}")
+  set(${out} ${triple} PARENT_SCOPE)
+  set(${out_arch} ${arch} PARENT_SCOPE)
+  set(${out_vendor} ${vendor} PARENT_SCOPE)
+  set(${out_os} ${os} PARENT_SCOPE)
+  message(STATUS "Host triple: ${triple}")
+endfunction()
+
+function(get_target_triple out out_arch out_vendor out_os)
+  # Get the architecture.
+  set(arch ${CMAKE_SYSTEM_PROCESSOR})
+  if (arch STREQUAL "x86")
+    set(arch "i686")
+  endif()
+  # Get the vendor.
+  if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+    set(vendor "apple")
+  else()
+    set(vendor "pc")
+  endif()
+  # Get os.
+  if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+    set(os "win32")
+  else()
+    string(TOLOWER ${CMAKE_SYSTEM_NAME} os)
+  endif()
+  set(triple "${arch}-${vendor}-${os}")
+  set(${out} ${triple} PARENT_SCOPE)
+  set(${out_arch} ${arch} PARENT_SCOPE)
+  set(${out_vendor} ${vendor} PARENT_SCOPE)
+  set(${out_os} ${os} PARENT_SCOPE)
+  message(STATUS "Target triple: ${triple}")
+endfunction()
diff --git a/final/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake b/final/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
new file mode 100644
index 0000000..a066936
--- /dev/null
+++ b/final/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
@@ -0,0 +1,18 @@
+# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+
+macro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage )
+
+string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource )
+if( _insource )
+ message( SEND_ERROR "${_errorMessage}" )
+ message( FATAL_ERROR
+ "In-source builds are not allowed.
+ CMake would overwrite the makefiles distributed with Compiler-RT.
+ Please create a directory and run cmake from there, passing the path
+ to this source directory as the last argument.
+ This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
+ Please delete them."
+ )
+endif( _insource )
+
+endmacro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD )
diff --git a/final/cmake/config-ix.cmake b/final/cmake/config-ix.cmake
new file mode 100644
index 0000000..e8adafd
--- /dev/null
+++ b/final/cmake/config-ix.cmake
@@ -0,0 +1,32 @@
+include(CheckLibraryExists)
+include(CheckCXXCompilerFlag)
+
+# Check compiler flags
+check_cxx_compiler_flag(-std=c++0x            LIBCXX_HAS_STDCXX0X_FLAG)
+check_cxx_compiler_flag(-fPIC                 LIBCXX_HAS_FPIC_FLAG)
+check_cxx_compiler_flag(-nodefaultlibs        LIBCXX_HAS_NODEFAULTLIBS_FLAG)
+check_cxx_compiler_flag(-nostdinc++           LIBCXX_HAS_NOSTDINCXX_FLAG)
+check_cxx_compiler_flag(-Wall                 LIBCXX_HAS_WALL_FLAG)
+check_cxx_compiler_flag(-W                    LIBCXX_HAS_W_FLAG)
+check_cxx_compiler_flag(-Wno-unused-parameter LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG)
+check_cxx_compiler_flag(-Wwrite-strings       LIBCXX_HAS_WWRITE_STRINGS_FLAG)
+check_cxx_compiler_flag(-Wno-long-long        LIBCXX_HAS_WNO_LONG_LONG_FLAG)
+check_cxx_compiler_flag(-pedantic             LIBCXX_HAS_PEDANTIC_FLAG)
+check_cxx_compiler_flag(-Werror               LIBCXX_HAS_WERROR_FLAG)
+check_cxx_compiler_flag(-Wno-error            LIBCXX_HAS_WNO_ERROR_FLAG)
+check_cxx_compiler_flag(-fno-exceptions       LIBCXX_HAS_FNO_EXCEPTIONS_FLAG)
+check_cxx_compiler_flag(-fno-rtti             LIBCXX_HAS_FNO_RTTI_FLAG)
+check_cxx_compiler_flag(/WX                   LIBCXX_HAS_WX_FLAG)
+check_cxx_compiler_flag(/WX-                  LIBCXX_HAS_NO_WX_FLAG)
+check_cxx_compiler_flag(/EHsc                 LIBCXX_HAS_EHSC_FLAG)
+check_cxx_compiler_flag(/EHs-                 LIBCXX_HAS_NO_EHS_FLAG)
+check_cxx_compiler_flag(/EHa-                 LIBCXX_HAS_NO_EHA_FLAG)
+check_cxx_compiler_flag(/GR-                  LIBCXX_HAS_NO_GR_FLAG)
+
+# Check libraries
+check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
+check_library_exists(c printf "" LIBCXX_HAS_C_LIB)
+check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
+check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
+
diff --git a/final/include/CMakeLists.txt b/final/include/CMakeLists.txt
new file mode 100644
index 0000000..bbf7ea4
--- /dev/null
+++ b/final/include/CMakeLists.txt
@@ -0,0 +1,13 @@
+if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
+  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
+endif()
+
+install(DIRECTORY .
+  DESTINATION include/c++/v1
+  FILES_MATCHING
+  PATTERN "*"
+  PATTERN "CMakeLists.txt" EXCLUDE
+  PATTERN ".svn" EXCLUDE
+  ${LIBCXX_SUPPORT_HEADER_PATTERN}
+  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+  )
diff --git a/final/include/__bit_reference b/final/include/__bit_reference
new file mode 100644
index 0000000..d9ebfbe
--- /dev/null
+++ b/final/include/__bit_reference
@@ -0,0 +1,1287 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___BIT_REFERENCE
+#define _LIBCPP___BIT_REFERENCE
+
+#include <__config>
+#include <algorithm>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> class __bit_iterator;
+template <class _Cp> class __bit_const_reference;
+
+template <class _Tp>
+struct __has_storage_type
+{
+    static const bool value = false;
+};
+
+template <class _Cp, bool = __has_storage_type<_Cp>::value>
+class __bit_reference
+{
+    typedef typename _Cp::__storage_type    __storage_type;
+    typedef typename _Cp::__storage_pointer __storage_pointer;
+
+    __storage_pointer __seg_;
+    __storage_type    __mask_;
+
+#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
+    friend typename _Cp::__self;
+#else
+    friend class _Cp::__self;
+#endif
+    friend class __bit_const_reference<_Cp>;
+    friend class __bit_iterator<_Cp, false>;
+public:
+    _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
+        {return static_cast<bool>(*__seg_ & __mask_);}
+    _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
+        {return !static_cast<bool>(*this);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bit_reference& operator=(bool __x) _NOEXCEPT
+    {
+        if (__x)
+            *__seg_ |= __mask_;
+        else
+            *__seg_ &= ~__mask_;
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
+        {return operator=(static_cast<bool>(__x));}
+
+    _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
+        {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__ctz(__mask_)));}
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
+        : __seg_(__s), __mask_(__m) {}
+};
+
+template <class _Cp>
+class __bit_reference<_Cp, false>
+{
+};
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
+{
+    bool __t = __x;
+    __x = __y;
+    __y = __t;
+}
+
+template <class _Cp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
+{
+    bool __t = __x;
+    __x = __y;
+    __y = __t;
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
+{
+    bool __t = __x;
+    __x = __y;
+    __y = __t;
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
+{
+    bool __t = __x;
+    __x = __y;
+    __y = __t;
+}
+
+template <class _Cp>
+class __bit_const_reference
+{
+    typedef typename _Cp::__storage_type          __storage_type;
+    typedef typename _Cp::__const_storage_pointer __storage_pointer;
+
+    __storage_pointer        __seg_;
+    __storage_type __mask_;
+
+#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
+    friend typename _Cp::__self;
+#else
+    friend class _Cp::__self;
+#endif
+    friend class __bit_iterator<_Cp, true>;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
+        : __seg_(__x.__seg_), __mask_(__x.__mask_) {}
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
+        {return static_cast<bool>(*__seg_ & __mask_);}
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
+        {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__ctz(__mask_)));}
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR
+    __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
+        : __seg_(__s), __mask_(__m) {}
+
+    __bit_const_reference& operator=(const __bit_const_reference& __x);
+};
+
+// find
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, _IsConst>
+__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _It;
+    typedef typename _It::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    // do first partial word
+    if (__first.__ctz_ != 0)
+    {
+        __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+        __storage_type __dn = _VSTD::min(__clz_f, __n);
+        __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+        __storage_type __b = *__first.__seg_ & __m;
+        if (__b)
+            return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+        if (__n == __dn)
+            return __first + __n;
+        __n -= __dn;
+        ++__first.__seg_;
+    }
+    // do middle whole words
+    for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+        if (*__first.__seg_)
+            return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(*__first.__seg_)));
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        __storage_type __b = *__first.__seg_ & __m;
+        if (__b)
+            return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+    }
+    return _It(__first.__seg_, static_cast<unsigned>(__n));
+}
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, _IsConst>
+__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _It;
+    typedef typename _It::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    // do first partial word
+    if (__first.__ctz_ != 0)
+    {
+        __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+        __storage_type __dn = _VSTD::min(__clz_f, __n);
+        __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+        __storage_type __b = ~*__first.__seg_ & __m;
+        if (__b)
+            return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+        if (__n == __dn)
+            return __first + __n;
+        __n -= __dn;
+        ++__first.__seg_;
+    }
+    // do middle whole words
+    for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+    {
+        __storage_type __b = ~*__first.__seg_;
+        if (__b)
+            return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+    }
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        __storage_type __b = ~*__first.__seg_ & __m;
+        if (__b)
+            return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+    }
+    return _It(__first.__seg_, static_cast<unsigned>(__n));
+}
+
+template <class _Cp, bool _IsConst, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, _IsConst>
+find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
+{
+    if (static_cast<bool>(__value_))
+        return __find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
+    return __find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
+}
+
+// count
+
+template <class _Cp, bool _IsConst>
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _It;
+    typedef typename _It::__storage_type __storage_type;
+    typedef typename _It::difference_type difference_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    difference_type __r = 0;
+    // do first partial word
+    if (__first.__ctz_ != 0)
+    {
+        __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+        __storage_type __dn = _VSTD::min(__clz_f, __n);
+        __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+        __r = _VSTD::__pop_count(*__first.__seg_ & __m);
+        __n -= __dn;
+        ++__first.__seg_;
+    }
+    // do middle whole words
+    for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+        __r += _VSTD::__pop_count(*__first.__seg_);
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        __r += _VSTD::__pop_count(*__first.__seg_ & __m);
+    }
+    return __r;
+}
+
+template <class _Cp, bool _IsConst>
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _It;
+    typedef typename _It::__storage_type __storage_type;
+    typedef typename _It::difference_type difference_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    difference_type __r = 0;
+    // do first partial word
+    if (__first.__ctz_ != 0)
+    {
+        __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+        __storage_type __dn = _VSTD::min(__clz_f, __n);
+        __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+        __r = _VSTD::__pop_count(~*__first.__seg_ & __m);
+        __n -= __dn;
+        ++__first.__seg_;
+    }
+    // do middle whole words
+    for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+        __r += _VSTD::__pop_count(~*__first.__seg_);
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        __r += _VSTD::__pop_count(~*__first.__seg_ & __m);
+    }
+    return __r;
+}
+
+template <class _Cp, bool _IsConst, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __bit_iterator<_Cp, _IsConst>::difference_type
+count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_)
+{
+    if (static_cast<bool>(__value_))
+        return __count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first));
+    return __count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first));
+}
+
+// fill_n
+
+template <class _Cp>
+void
+__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+{
+    typedef __bit_iterator<_Cp, false> _It;
+    typedef typename _It::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    // do first partial word
+    if (__first.__ctz_ != 0)
+    {
+        __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+        __storage_type __dn = _VSTD::min(__clz_f, __n);
+        __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+        *__first.__seg_ &= ~__m;
+        __n -= __dn;
+        ++__first.__seg_;
+    }
+    // do middle whole words
+    __storage_type __nw = __n / __bits_per_word;
+    _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type));
+    __n -= __nw * __bits_per_word;
+    // do last partial word
+    if (__n > 0)
+    {
+        __first.__seg_ += __nw;
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        *__first.__seg_ &= ~__m;
+    }
+}
+
+template <class _Cp>
+void
+__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
+{
+    typedef __bit_iterator<_Cp, false> _It;
+    typedef typename _It::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    // do first partial word
+    if (__first.__ctz_ != 0)
+    {
+        __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+        __storage_type __dn = _VSTD::min(__clz_f, __n);
+        __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+        *__first.__seg_ |= __m;
+        __n -= __dn;
+        ++__first.__seg_;
+    }
+    // do middle whole words
+    __storage_type __nw = __n / __bits_per_word;
+    _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type));
+    __n -= __nw * __bits_per_word;
+    // do last partial word
+    if (__n > 0)
+    {
+        __first.__seg_ += __nw;
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        *__first.__seg_ |= __m;
+    }
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_)
+{
+    if (__n > 0)
+    {
+        if (__value_)
+            __fill_n_true(__first, __n);
+        else
+            __fill_n_false(__first, __n);
+    }
+}
+
+// fill
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value_)
+{
+    _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value_);
+}
+
+// copy
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+                                                     __bit_iterator<_Cp, false> __result)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _In;
+    typedef  typename _In::difference_type difference_type;
+    typedef typename _In::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _In::__bits_per_word;
+    difference_type __n = __last - __first;
+    if (__n > 0)
+    {
+        // do first word
+        if (__first.__ctz_ != 0)
+        {
+            unsigned __clz = __bits_per_word - __first.__ctz_;
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n);
+            __n -= __dn;
+            __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
+            __storage_type __b = *__first.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b;
+            __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+            __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_)  % __bits_per_word);
+            ++__first.__seg_;
+            // __first.__ctz_ = 0;
+        }
+        // __first.__ctz_ == 0;
+        // do middle words
+        __storage_type __nw = __n / __bits_per_word;
+        _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
+                       _VSTD::__to_raw_pointer(__first.__seg_),
+                       __nw * sizeof(__storage_type));
+        __n -= __nw * __bits_per_word;
+        __result.__seg_ += __nw;
+        // do last word
+        if (__n > 0)
+        {
+            __first.__seg_ += __nw;
+            __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+            __storage_type __b = *__first.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b;
+            __result.__ctz_ = static_cast<unsigned>(__n);
+        }
+    }
+    return __result;
+}
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+                                                       __bit_iterator<_Cp, false> __result)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _In;
+    typedef  typename _In::difference_type difference_type;
+    typedef typename _In::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _In::__bits_per_word;
+    difference_type __n = __last - __first;
+    if (__n > 0)
+    {
+        // do first word
+        if (__first.__ctz_ != 0)
+        {
+            unsigned __clz_f = __bits_per_word - __first.__ctz_;
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n);
+            __n -= __dn;
+            __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+            __storage_type __b = *__first.__seg_ & __m;
+            unsigned __clz_r = __bits_per_word - __result.__ctz_;
+            __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r);
+            __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
+            *__result.__seg_ &= ~__m;
+            if (__result.__ctz_ > __first.__ctz_)
+                *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_);
+            else
+                *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_);
+            __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
+            __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_)  % __bits_per_word);
+            __dn -= __ddn;
+            if (__dn > 0)
+            {
+                __m = ~__storage_type(0) >> (__bits_per_word - __dn);
+                *__result.__seg_ &= ~__m;
+                *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn);
+                __result.__ctz_ = static_cast<unsigned>(__dn);
+            }
+            ++__first.__seg_;
+            // __first.__ctz_ = 0;
+        }
+        // __first.__ctz_ == 0;
+        // do middle words
+        unsigned __clz_r = __bits_per_word - __result.__ctz_;
+        __storage_type __m = ~__storage_type(0) << __result.__ctz_;
+        for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_)
+        {
+            __storage_type __b = *__first.__seg_;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b << __result.__ctz_;
+            ++__result.__seg_;
+            *__result.__seg_ &= __m;
+            *__result.__seg_ |= __b >> __clz_r;
+        }
+        // do last word
+        if (__n > 0)
+        {
+            __m = ~__storage_type(0) >> (__bits_per_word - __n);
+            __storage_type __b = *__first.__seg_ & __m;
+            __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__clz_r));
+            __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b << __result.__ctz_;
+            __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+            __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_)  % __bits_per_word);
+            __n -= __dn;
+            if (__n > 0)
+            {
+                __m = ~__storage_type(0) >> (__bits_per_word - __n);
+                *__result.__seg_ &= ~__m;
+                *__result.__seg_ |= __b >> __dn;
+                __result.__ctz_ = static_cast<unsigned>(__n);
+            }
+        }
+    }
+    return __result;
+}
+
+template <class _Cp, bool _IsConst>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, false>
+copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
+{
+    if (__first.__ctz_ == __result.__ctz_)
+        return __copy_aligned(__first, __last, __result);
+    return __copy_unaligned(__first, __last, __result);
+}
+
+// copy_backward
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+                                                     __bit_iterator<_Cp, false> __result)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _In;
+    typedef  typename _In::difference_type difference_type;
+    typedef typename _In::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _In::__bits_per_word;
+    difference_type __n = __last - __first;
+    if (__n > 0)
+    {
+        // do first word
+        if (__last.__ctz_ != 0)
+        {
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__last.__ctz_), __n);
+            __n -= __dn;
+            unsigned __clz = __bits_per_word - __last.__ctz_;
+            __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz);
+            __storage_type __b = *__last.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b;
+            __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) +
+                                                       __result.__ctz_)  % __bits_per_word);
+            // __last.__ctz_ = 0
+         }
+        // __last.__ctz_ == 0 || __n == 0
+        // __result.__ctz_ == 0 || __n == 0
+        // do middle words
+        __storage_type __nw = __n / __bits_per_word;
+        __result.__seg_ -= __nw;
+        __last.__seg_ -= __nw;
+        _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_),
+                       _VSTD::__to_raw_pointer(__last.__seg_),
+                       __nw * sizeof(__storage_type));
+        __n -= __nw * __bits_per_word;
+        // do last word
+        if (__n > 0)
+        {
+            __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n);
+            __storage_type __b = *--__last.__seg_ & __m;
+            *--__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b;
+            __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
+        }
+    }
+    return __result;
+}
+
+template <class _Cp, bool _IsConst>
+__bit_iterator<_Cp, false>
+__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
+                                                       __bit_iterator<_Cp, false> __result)
+{
+    typedef __bit_iterator<_Cp, _IsConst> _In;
+    typedef  typename _In::difference_type difference_type;
+    typedef typename _In::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _In::__bits_per_word;
+    difference_type __n = __last - __first;
+    if (__n > 0)
+    {
+        // do first word
+        if (__last.__ctz_ != 0)
+        {
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__last.__ctz_), __n);
+            __n -= __dn;
+            unsigned __clz_l = __bits_per_word - __last.__ctz_;
+            __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l);
+            __storage_type __b = *__last.__seg_ & __m;
+            unsigned __clz_r = __bits_per_word - __result.__ctz_;
+            __storage_type __ddn = _VSTD::min(__dn, static_cast<difference_type>(__result.__ctz_));
+            if (__ddn > 0)
+            {
+                __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r);
+                *__result.__seg_ &= ~__m;
+                if (__result.__ctz_ > __last.__ctz_)
+                    *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
+                else
+                    *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_);
+                __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) +
+                                                         __result.__ctz_)  % __bits_per_word);
+                __dn -= __ddn;
+            }
+            if (__dn > 0)
+            {
+                // __result.__ctz_ == 0
+                --__result.__seg_;
+                __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1));
+                __m = ~__storage_type(0) << __result.__ctz_;
+                *__result.__seg_ &= ~__m;
+                __last.__ctz_ -= __dn + __ddn;
+                *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
+            }
+            // __last.__ctz_ = 0
+         }
+        // __last.__ctz_ == 0 || __n == 0
+        // __result.__ctz_ != 0 || __n == 0
+        // do middle words
+        unsigned __clz_r = __bits_per_word - __result.__ctz_;
+        __storage_type __m = ~__storage_type(0) >> __clz_r;
+        for (; __n >= __bits_per_word; __n -= __bits_per_word)
+        {
+            __storage_type __b = *--__last.__seg_;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b >> __clz_r;
+            *--__result.__seg_ &= __m;
+            *__result.__seg_ |= __b << __result.__ctz_;
+        }
+        // do last word
+        if (__n > 0)
+        {
+            __m = ~__storage_type(0) << (__bits_per_word - __n);
+            __storage_type __b = *--__last.__seg_ & __m;
+            __clz_r = __bits_per_word - __result.__ctz_;
+            __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__result.__ctz_));
+            __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r);
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_);
+            __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) +
+                                                     __result.__ctz_)  % __bits_per_word);
+            __n -= __dn;
+            if (__n > 0)
+            {
+                // __result.__ctz_ == 0
+                --__result.__seg_;
+                __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
+                __m = ~__storage_type(0) << __result.__ctz_;
+                *__result.__seg_ &= ~__m;
+                *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn));
+            }
+        }
+    }
+    return __result;
+}
+
+template <class _Cp, bool _IsConst>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, false>
+copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
+{
+    if (__last.__ctz_ == __result.__ctz_)
+        return __copy_backward_aligned(__first, __last, __result);
+    return __copy_backward_unaligned(__first, __last, __result);
+}
+
+// move
+
+template <class _Cp, bool _IsConst>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<_Cp, false>
+move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
+{
+    return _VSTD::copy(__first, __last, __result);
+}
+
+// move_backward
+
+template <class _Cp, bool _IsConst>
+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);
+}
+
+// swap_ranges
+
+template <class __C1, class __C2>
+__bit_iterator<__C2, false>
+__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
+                      __bit_iterator<__C2, false> __result)
+{
+    typedef __bit_iterator<__C1, false> _I1;
+    typedef  typename _I1::difference_type difference_type;
+    typedef typename _I1::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _I1::__bits_per_word;
+    difference_type __n = __last - __first;
+    if (__n > 0)
+    {
+        // do first word
+        if (__first.__ctz_ != 0)
+        {
+            unsigned __clz = __bits_per_word - __first.__ctz_;
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n);
+            __n -= __dn;
+            __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
+            __storage_type __b1 = *__first.__seg_ & __m;
+            *__first.__seg_ &= ~__m;
+            __storage_type __b2 = *__result.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b1;
+            *__first.__seg_  |= __b2;
+            __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+            __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_)  % __bits_per_word);
+            ++__first.__seg_;
+            // __first.__ctz_ = 0;
+        }
+        // __first.__ctz_ == 0;
+        // do middle words
+        for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_)
+            swap(*__first.__seg_, *__result.__seg_);
+        // do last word
+        if (__n > 0)
+        {
+            __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+            __storage_type __b1 = *__first.__seg_ & __m;
+            *__first.__seg_ &= ~__m;
+            __storage_type __b2 = *__result.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b1;
+            *__first.__seg_  |= __b2;
+            __result.__ctz_ = static_cast<unsigned>(__n);
+        }
+    }
+    return __result;
+}
+
+template <class __C1, class __C2>
+__bit_iterator<__C2, false>
+__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last,
+                        __bit_iterator<__C2, false> __result)
+{
+    typedef __bit_iterator<__C1, false> _I1;
+    typedef  typename _I1::difference_type difference_type;
+    typedef typename _I1::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _I1::__bits_per_word;
+    difference_type __n = __last - __first;
+    if (__n > 0)
+    {
+        // do first word
+        if (__first.__ctz_ != 0)
+        {
+            unsigned __clz_f = __bits_per_word - __first.__ctz_;
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n);
+            __n -= __dn;
+            __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+            __storage_type __b1 = *__first.__seg_ & __m;
+            *__first.__seg_ &= ~__m;
+            unsigned __clz_r = __bits_per_word - __result.__ctz_;
+            __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r);
+            __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
+            __storage_type __b2 = *__result.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            if (__result.__ctz_ > __first.__ctz_)
+            {
+                unsigned __s = __result.__ctz_ - __first.__ctz_;
+                *__result.__seg_ |= __b1 << __s;
+                *__first.__seg_  |= __b2 >> __s;
+            }
+            else
+            {
+                unsigned __s = __first.__ctz_ - __result.__ctz_;
+                *__result.__seg_ |= __b1 >> __s;
+                *__first.__seg_  |= __b2 << __s;
+            }
+            __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
+            __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_)  % __bits_per_word);
+            __dn -= __ddn;
+            if (__dn > 0)
+            {
+                __m = ~__storage_type(0) >> (__bits_per_word - __dn);
+                __b2 = *__result.__seg_ & __m;
+                *__result.__seg_ &= ~__m;
+                unsigned __s = __first.__ctz_ + __ddn;
+                *__result.__seg_ |= __b1 >> __s;
+                *__first.__seg_  |= __b2 << __s;
+                __result.__ctz_ = static_cast<unsigned>(__dn);
+            }
+            ++__first.__seg_;
+            // __first.__ctz_ = 0;
+        }
+        // __first.__ctz_ == 0;
+        // do middle words
+        __storage_type __m = ~__storage_type(0) << __result.__ctz_;
+        unsigned __clz_r = __bits_per_word - __result.__ctz_;
+        for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_)
+        {
+            __storage_type __b1 = *__first.__seg_;
+            __storage_type __b2 = *__result.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b1 << __result.__ctz_;
+            *__first.__seg_  = __b2 >> __result.__ctz_;
+            ++__result.__seg_;
+            __b2 = *__result.__seg_ & ~__m;
+            *__result.__seg_ &= __m;
+            *__result.__seg_ |= __b1 >> __clz_r;
+            *__first.__seg_  |= __b2 << __clz_r;
+        }
+        // do last word
+        if (__n > 0)
+        {
+            __m = ~__storage_type(0) >> (__bits_per_word - __n);
+            __storage_type __b1 = *__first.__seg_ & __m;
+            *__first.__seg_ &= ~__m;
+            __storage_type __dn = _VSTD::min<__storage_type>(__n, __clz_r);
+            __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
+            __storage_type __b2 = *__result.__seg_ & __m;
+            *__result.__seg_ &= ~__m;
+            *__result.__seg_ |= __b1 << __result.__ctz_;
+            *__first.__seg_  |= __b2 >> __result.__ctz_;
+            __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
+            __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_)  % __bits_per_word);
+            __n -= __dn;
+            if (__n > 0)
+            {
+                __m = ~__storage_type(0) >> (__bits_per_word - __n);
+                __b2 = *__result.__seg_ & __m;
+                *__result.__seg_ &= ~__m;
+                *__result.__seg_ |= __b1 >> __dn;
+                *__first.__seg_  |= __b2 << __dn;
+                __result.__ctz_ = static_cast<unsigned>(__n);
+            }
+        }
+    }
+    return __result;
+}
+
+template <class __C1, class __C2>
+inline _LIBCPP_INLINE_VISIBILITY
+__bit_iterator<__C2, false>
+swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __last1,
+            __bit_iterator<__C2, false> __first2)
+{
+    if (__first1.__ctz_ == __first2.__ctz_)
+        return __swap_ranges_aligned(__first1, __last1, __first2);
+    return __swap_ranges_unaligned(__first1, __last1, __first2);
+}
+
+// rotate
+
+template <class _Cp>
+struct __bit_array
+{
+    typedef typename _Cp::difference_type difference_type;
+    typedef typename _Cp::__storage_type  __storage_type;
+    typedef typename _Cp::__storage_pointer __storage_pointer;
+    typedef typename _Cp::iterator        iterator;
+    static const unsigned __bits_per_word = _Cp::__bits_per_word;
+    static const unsigned _Np = 4;
+
+    difference_type __size_;
+    __storage_type __word_[_Np];
+
+    _LIBCPP_INLINE_VISIBILITY static difference_type capacity()
+        {return static_cast<difference_type>(_Np * __bits_per_word);}
+    _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {}
+    _LIBCPP_INLINE_VISIBILITY iterator begin()
+    {
+        return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
+    }
+    _LIBCPP_INLINE_VISIBILITY iterator end()
+    {
+        return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
+                                                  static_cast<unsigned>(__size_ % __bits_per_word));
+    }
+};
+
+template <class _Cp>
+__bit_iterator<_Cp, false>
+rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
+{
+    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;
+    while (__d1 != 0 && __d2 != 0)
+    {
+        if (__d1 <= __d2)
+        {
+            if (__d1 <= __bit_array<_Cp>::capacity())
+            {
+                __bit_array<_Cp> __b(__d1);
+                _VSTD::copy(__first, __middle, __b.begin());
+                _VSTD::copy(__b.begin(), __b.end(), _VSTD::copy(__middle, __last, __first));
+                break;
+            }
+            else
+            {
+                __bit_iterator<_Cp, false> __mp = _VSTD::swap_ranges(__first, __middle, __middle);
+                __first = __middle;
+                __middle = __mp;
+                __d2 -= __d1;
+            }
+        }
+        else
+        {
+            if (__d2 <= __bit_array<_Cp>::capacity())
+            {
+                __bit_array<_Cp> __b(__d2);
+                _VSTD::copy(__middle, __last, __b.begin());
+                _VSTD::copy_backward(__b.begin(), __b.end(), _VSTD::copy_backward(__first, __middle, __last));
+                break;
+            }
+            else
+            {
+                __bit_iterator<_Cp, false> __mp = __first + __d2;
+                _VSTD::swap_ranges(__first, __mp, __middle);
+                __first = __mp;
+                __d1 -= __d2;
+            }
+        }
+    }
+    return __r;
+}
+
+// equal
+
+template <class _Cp, bool _IC1, bool _IC2>
+bool
+__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
+                  __bit_iterator<_Cp, _IC2> __first2)
+{
+    typedef __bit_iterator<_Cp, _IC1> _It;
+    typedef  typename _It::difference_type difference_type;
+    typedef typename _It::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    difference_type __n = __last1 - __first1;
+    if (__n > 0)
+    {
+        // do first word
+        if (__first1.__ctz_ != 0)
+        {
+            unsigned __clz_f = __bits_per_word - __first1.__ctz_;
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n);
+            __n -= __dn;
+            __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+            __storage_type __b = *__first1.__seg_ & __m;
+            unsigned __clz_r = __bits_per_word - __first2.__ctz_;
+            __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r);
+            __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
+            if (__first2.__ctz_ > __first1.__ctz_)
+            {
+                if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_)))
+                    return false;
+            }
+            else
+            {
+                if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_)))
+                    return false;
+            }
+            __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word;
+            __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_)  % __bits_per_word);
+            __dn -= __ddn;
+            if (__dn > 0)
+            {
+                __m = ~__storage_type(0) >> (__bits_per_word - __dn);
+                if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn)))
+                    return false;
+                __first2.__ctz_ = static_cast<unsigned>(__dn);
+            }
+            ++__first1.__seg_;
+            // __first1.__ctz_ = 0;
+        }
+        // __first1.__ctz_ == 0;
+        // do middle words
+        unsigned __clz_r = __bits_per_word - __first2.__ctz_;
+        __storage_type __m = ~__storage_type(0) << __first2.__ctz_;
+        for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_)
+        {
+            __storage_type __b = *__first1.__seg_;
+            if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_))
+                return false;
+            ++__first2.__seg_;
+            if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r))
+                return false;
+        }
+        // do last word
+        if (__n > 0)
+        {
+            __m = ~__storage_type(0) >> (__bits_per_word - __n);
+            __storage_type __b = *__first1.__seg_ & __m;
+            __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__clz_r));
+            __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
+            if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_))
+                return false;
+            __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word;
+            __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_)  % __bits_per_word);
+            __n -= __dn;
+            if (__n > 0)
+            {
+                __m = ~__storage_type(0) >> (__bits_per_word - __n);
+                if ((*__first2.__seg_ & __m) != (__b >> __dn))
+                    return false;
+            }
+        }
+    }
+    return true;
+}
+
+template <class _Cp, bool _IC1, bool _IC2>
+bool
+__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
+                __bit_iterator<_Cp, _IC2> __first2)
+{
+    typedef __bit_iterator<_Cp, _IC1> _It;
+    typedef  typename _It::difference_type difference_type;
+    typedef typename _It::__storage_type __storage_type;
+    static const unsigned __bits_per_word = _It::__bits_per_word;
+    difference_type __n = __last1 - __first1;
+    if (__n > 0)
+    {
+        // do first word
+        if (__first1.__ctz_ != 0)
+        {
+            unsigned __clz = __bits_per_word - __first1.__ctz_;
+            difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n);
+            __n -= __dn;
+            __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
+            if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
+                return false;
+            ++__first2.__seg_;
+            ++__first1.__seg_;
+            // __first1.__ctz_ = 0;
+            // __first2.__ctz_ = 0;
+        }
+        // __first1.__ctz_ == 0;
+        // __first2.__ctz_ == 0;
+        // do middle words
+        for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_)
+            if (*__first2.__seg_ != *__first1.__seg_)
+                return false;
+        // do last word
+        if (__n > 0)
+        {
+            __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+            if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
+                return false;
+        }
+    }
+    return true;
+}
+
+template <class _Cp, bool _IC1, bool _IC2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
+{
+    if (__first1.__ctz_ == __first2.__ctz_)
+        return __equal_aligned(__first1, __last1, __first2);
+    return __equal_unaligned(__first1, __last1, __first2);
+}
+
+template <class _Cp, bool _IsConst,
+          typename _Cp::__storage_type>
+class __bit_iterator
+{
+public:
+    typedef typename _Cp::difference_type                                                          difference_type;
+    typedef bool                                                                                  value_type;
+    typedef __bit_iterator                                                                        pointer;
+    typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference;
+    typedef random_access_iterator_tag                                                            iterator_category;
+
+private:
+    typedef typename _Cp::__storage_type                                           __storage_type;
+    typedef typename conditional<_IsConst, typename _Cp::__const_storage_pointer,
+                                           typename _Cp::__storage_pointer>::type  __storage_pointer;
+    static const unsigned __bits_per_word = _Cp::__bits_per_word;
+
+    __storage_pointer __seg_;
+    unsigned          __ctz_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+    : __seg_(nullptr), __ctz_(0)
+#endif
+    {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
+        : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
+
+    _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
+        {return reference(__seg_, __storage_type(1) << __ctz_);}
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()
+    {
+        if (__ctz_ != __bits_per_word-1)
+            ++__ctz_;
+        else
+        {
+            __ctz_ = 0;
+            ++__seg_;
+        }
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)
+    {
+        __bit_iterator __tmp = *this;
+        ++(*this);
+        return __tmp;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()
+    {
+        if (__ctz_ != 0)
+            --__ctz_;
+        else
+        {
+            __ctz_ = __bits_per_word - 1;
+            --__seg_;
+        }
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)
+    {
+        __bit_iterator __tmp = *this;
+        --(*this);
+        return __tmp;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n)
+    {
+        if (__n >= 0)
+            __seg_ += (__n + __ctz_) / __bits_per_word;
+        else
+            __seg_ += static_cast<difference_type>(__n - __bits_per_word + __ctz_ + 1)
+                    / static_cast<difference_type>(__bits_per_word);
+        __n &= (__bits_per_word - 1);
+        __ctz_ = static_cast<unsigned>((__n + __ctz_)  % __bits_per_word);
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n)
+    {
+        return *this += -__n;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const
+    {
+        __bit_iterator __t(*this);
+        __t += __n;
+        return __t;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const
+    {
+        __bit_iterator __t(*this);
+        __t -= __n;
+        return __t;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
+        {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}
+
+    _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);}
+
+    _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
+        {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}
+
+    _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
+        {return !(__x == __y);}
+
+    _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
+        {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}
+
+    _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
+        {return __y < __x;}
+
+    _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
+        {return !(__y < __x);}
+
+    _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
+        {return !(__x < __y);}
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
+        : __seg_(__s), __ctz_(__ctz) {}
+
+#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
+    friend typename _Cp::__self;
+#else
+    friend class _Cp::__self;
+#endif
+    friend class __bit_reference<_Cp>;
+    friend class __bit_const_reference<_Cp>;
+    friend class __bit_iterator<_Cp, true>;
+    template <class _Dp> friend struct __bit_array;
+    template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+    template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
+                                                                                  __bit_iterator<_Dp, _IC> __last,
+                                                                                  __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
+                                                                                    __bit_iterator<_Dp, _IC> __last,
+                                                                                    __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
+                                                                        __bit_iterator<_Dp, _IC> __last,
+                                                                        __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
+                                                                                           __bit_iterator<_Dp, _IC> __last,
+                                                                                           __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
+                                                                                             __bit_iterator<_Dp, _IC> __last,
+                                                                                             __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
+                                                                                 __bit_iterator<_Dp, _IC> __last,
+                                                                                 __bit_iterator<_Dp, false> __result);
+    template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,
+                                                                                           __bit_iterator<__C1, false>,
+                                                                                           __bit_iterator<__C2, false>);
+    template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_unaligned(__bit_iterator<__C1, false>,
+                                                                                             __bit_iterator<__C1, false>,
+                                                                                             __bit_iterator<__C2, false>);
+    template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,
+                                                                                 __bit_iterator<__C1, false>,
+                                                                                 __bit_iterator<__C2, false>);
+    template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
+                                                                __bit_iterator<_Dp, false>,
+                                                                __bit_iterator<_Dp, false>);
+    template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
+                                                    __bit_iterator<_Dp, _IC1>,
+                                                    __bit_iterator<_Dp, _IC2>);
+    template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
+                                                      __bit_iterator<_Dp, _IC1>,
+                                                      __bit_iterator<_Dp, _IC2>);
+    template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,
+                                                                __bit_iterator<_Dp, _IC1>,
+                                                                __bit_iterator<_Dp, _IC2>);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,
+                                                                          typename _Dp::size_type);
+    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,
+                                                                           typename _Dp::size_type);
+    template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
+                   __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+    template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type
+                   __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___BIT_REFERENCE
diff --git a/final/include/__config b/final/include/__config
new file mode 100644
index 0000000..ce235af
--- /dev/null
+++ b/final/include/__config
@@ -0,0 +1,693 @@
+// -*- C++ -*-
+//===--------------------------- __config ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_CONFIG
+#define _LIBCPP_CONFIG
+
+#if !defined(_MSC_VER) || defined(__clang__)
+#pragma GCC system_header
+#endif
+
+#ifdef __GNUC__
+#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
+#endif
+
+#define _LIBCPP_VERSION 1101
+
+#define _LIBCPP_ABI_VERSION 1
+
+#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)
+
+#ifdef __LITTLE_ENDIAN__
+#if __LITTLE_ENDIAN__
+#define _LIBCPP_LITTLE_ENDIAN 1
+#define _LIBCPP_BIG_ENDIAN    0
+#endif  // __LITTLE_ENDIAN__
+#endif  // __LITTLE_ENDIAN__
+
+#ifdef __BIG_ENDIAN__
+#if __BIG_ENDIAN__
+#define _LIBCPP_LITTLE_ENDIAN 0
+#define _LIBCPP_BIG_ENDIAN    1
+#endif  // __BIG_ENDIAN__
+#endif  // __BIG_ENDIAN__
+
+#ifdef __FreeBSD__
+# include <sys/endian.h>
+#  if _BYTE_ORDER == _LITTLE_ENDIAN
+#   define _LIBCPP_LITTLE_ENDIAN 1
+#   define _LIBCPP_BIG_ENDIAN    0
+# else  // _BYTE_ORDER == _LITTLE_ENDIAN
+#   define _LIBCPP_LITTLE_ENDIAN 0
+#   define _LIBCPP_BIG_ENDIAN    1
+# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
+# ifndef __LONG_LONG_SUPPORTED
+#  define _LIBCPP_HAS_NO_LONG_LONG
+# endif  // __LONG_LONG_SUPPORTED
+#endif  // __FreeBSD__
+
+#ifdef __NetBSD__
+# include <sys/endian.h>
+#  if _BYTE_ORDER == _LITTLE_ENDIAN
+#   define _LIBCPP_LITTLE_ENDIAN 1
+#   define _LIBCPP_BIG_ENDIAN    0
+# else  // _BYTE_ORDER == _LITTLE_ENDIAN
+#   define _LIBCPP_LITTLE_ENDIAN 0
+#   define _LIBCPP_BIG_ENDIAN    1
+# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
+# define _LIBCPP_HAS_QUICK_EXIT
+#endif  // __NetBSD__
+
+#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)
+#    define _LIBCPP_HAS_IS_BASE_OF
+#  endif
+#  if defined(_MSC_VER) && !defined(__clang__)
+#    define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
+#    define _LIBCPP_TOSTRING2(x) #x
+#    define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
+#    define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
+#  endif
+#  // If mingw not explicitly detected, assume using MS C runtime only.
+#  ifndef __MINGW32__
+#    define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+#  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
+#   define _LIBCPP_LITTLE_ENDIAN 1
+#   define _LIBCPP_BIG_ENDIAN    0
+# else
+#   define _LIBCPP_LITTLE_ENDIAN 0
+#   define _LIBCPP_BIG_ENDIAN    1
+# endif
+#endif // __sun__
+
+#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
+# include <endian.h>
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  define _LIBCPP_LITTLE_ENDIAN 1
+#  define _LIBCPP_BIG_ENDIAN    0
+# elif __BYTE_ORDER == __BIG_ENDIAN
+#  define _LIBCPP_LITTLE_ENDIAN 0
+#  define _LIBCPP_BIG_ENDIAN    1
+# else  // __BYTE_ORDER == __BIG_ENDIAN
+#  error unable to determine endian
+# endif
+#endif  // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
+
+#ifdef _WIN32
+
+// only really useful for a DLL
+#ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
+# ifdef cxx_EXPORTS
+#  define _LIBCPP_HIDDEN
+#  define _LIBCPP_FUNC_VIS __declspec(dllexport)
+#  define _LIBCPP_TYPE_VIS __declspec(dllexport)
+# else
+#  define _LIBCPP_HIDDEN
+#  define _LIBCPP_FUNC_VIS __declspec(dllimport)
+#  define _LIBCPP_TYPE_VIS __declspec(dllimport)
+# endif
+#else
+# define _LIBCPP_HIDDEN
+# define _LIBCPP_FUNC_VIS
+# define _LIBCPP_TYPE_VIS
+#endif
+
+#define _LIBCPP_TYPE_VIS_ONLY
+#define _LIBCPP_FUNC_VIS_ONLY
+
+#ifndef _LIBCPP_INLINE_VISIBILITY
+# ifdef _LIBCPP_MSVC
+#  define _LIBCPP_INLINE_VISIBILITY __forceinline
+# else // MinGW GCC and Clang
+#  define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+# endif
+#endif
+
+#ifndef _LIBCPP_EXCEPTION_ABI
+#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
+#endif
+
+#ifndef _LIBCPP_ALWAYS_INLINE
+# ifdef _LIBCPP_MSVC
+#  define _LIBCPP_ALWAYS_INLINE __forceinline
+# endif
+#endif
+
+#endif // _WIN32
+
+#ifndef __has_attribute
+#define __has_attribute(__x) 0
+#endif
+
+#ifndef _LIBCPP_HIDDEN
+#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
+#endif
+
+#ifndef _LIBCPP_FUNC_VIS
+#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
+#endif
+
+#ifndef _LIBCPP_TYPE_VIS
+#  if __has_attribute(__type_visibility__)
+#    define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
+#  else
+#    define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
+#  endif
+#endif
+
+#ifndef _LIBCPP_TYPE_VIS_ONLY
+# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
+#endif
+
+#ifndef _LIBCPP_FUNC_VIS_ONLY
+# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
+#endif
+
+#ifndef _LIBCPP_INLINE_VISIBILITY
+#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
+#endif
+
+#ifndef _LIBCPP_EXCEPTION_ABI
+#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
+#endif
+
+#ifndef _LIBCPP_ALWAYS_INLINE
+#define _LIBCPP_ALWAYS_INLINE  __attribute__ ((__visibility__("hidden"), __always_inline__))
+#endif
+
+#if defined(__clang__)
+
+#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&        \
+    !defined(__arm__)
+#define _LIBCPP_ALTERNATE_STRING_LAYOUT
+#endif
+
+#if __has_feature(cxx_alignas)
+#  define _ALIGNAS_TYPE(x) alignas(x)
+#  define _ALIGNAS(x) alignas(x)
+#else
+#  define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
+#  define _ALIGNAS(x) __attribute__((__aligned__(x)))
+#endif
+
+#if !__has_feature(cxx_alias_templates)
+#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#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))
+#define _LIBCPP_NO_EXCEPTIONS
+#endif
+
+#if !(__has_feature(cxx_rtti))
+#define _LIBCPP_NO_RTTI
+#endif
+
+#if !(__has_feature(cxx_strong_enums))
+#define _LIBCPP_HAS_NO_STRONG_ENUMS
+#endif
+
+#if !(__has_feature(cxx_decltype))
+#define _LIBCPP_HAS_NO_DECLTYPE
+#endif
+
+#if __has_feature(cxx_attributes)
+#  define _LIBCPP_NORETURN [[noreturn]]
+#else
+#  define _LIBCPP_NORETURN __attribute__ ((noreturn))
+#endif
+
+#if !(__has_feature(cxx_defaulted_functions))
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#endif  // !(__has_feature(cxx_defaulted_functions))
+
+#if !(__has_feature(cxx_deleted_functions))
+#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#endif  // !(__has_feature(cxx_deleted_functions))
+
+#if !(__has_feature(cxx_lambdas))
+#define _LIBCPP_HAS_NO_LAMBDAS
+#endif
+
+#if !(__has_feature(cxx_nullptr))
+#define _LIBCPP_HAS_NO_NULLPTR
+#endif
+
+#if !(__has_feature(cxx_rvalue_references))
+#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+
+#if !(__has_feature(cxx_static_assert))
+#define _LIBCPP_HAS_NO_STATIC_ASSERT
+#endif
+
+#if !(__has_feature(cxx_auto_type))
+#define _LIBCPP_HAS_NO_AUTO_TYPE
+#endif
+
+#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
+#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#endif
+
+#if !(__has_feature(cxx_variadic_templates))
+#define _LIBCPP_HAS_NO_VARIADICS
+#endif
+
+#if !(__has_feature(cxx_trailing_return))
+#define _LIBCPP_HAS_NO_TRAILING_RETURN
+#endif
+
+#if !(__has_feature(cxx_generalized_initializers))
+#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#endif
+
+#if __has_feature(is_base_of)
+#  define _LIBCPP_HAS_IS_BASE_OF
+#endif
+
+// Objective-C++ features (opt-in)
+#if __has_feature(objc_arc)
+#define _LIBCPP_HAS_OBJC_ARC
+#endif
+
+#if __has_feature(objc_arc_weak)
+#define _LIBCPP_HAS_OBJC_ARC_WEAK
+#define _LIBCPP_HAS_NO_STRONG_ENUMS
+#endif
+
+#if !(__has_feature(cxx_constexpr))
+#define _LIBCPP_HAS_NO_CONSTEXPR
+#endif
+
+#if !(__has_feature(cxx_relaxed_constexpr))
+#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+#endif
+
+#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if defined(__FreeBSD__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_C11_FEATURES
+#elif defined(__ANDROID__)
+#define _LIBCPP_HAS_QUICK_EXIT
+#elif defined(__linux__)
+#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
+#endif
+#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
+#endif
+
+#if __has_feature(underlying_type)
+#  define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
+#endif
+
+#if __has_feature(is_literal)
+#  define _LIBCPP_IS_LITERAL(T) __is_literal(T)
+#endif
+
+// Inline namespaces are available in Clang regardless of C++ dialect.
+#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
+#define _LIBCPP_END_NAMESPACE_STD  } }
+#define _VSTD std::_LIBCPP_NAMESPACE
+
+namespace std {
+  inline namespace _LIBCPP_NAMESPACE {
+  }
+}
+
+#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
+#define _LIBCPP_HAS_NO_ASAN
+#endif
+
+#elif defined(__GNUC__)
+
+#define _ALIGNAS(x) __attribute__((__aligned__(x)))
+#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
+
+#define _LIBCPP_NORETURN __attribute__((noreturn))
+
+#if _GNUC_VER >= 407
+#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
+#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
+#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
+// Can only use constexpr in c++11 mode.
+#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
+#define _LIBCPP_HAS_NO_CONSTEXPR
+#endif
+
+// No version of GCC supports relaxed constexpr rules
+#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
+
+#define _NOEXCEPT throw()
+#define _NOEXCEPT_(x)
+#define _NOEXCEPT_OR_FALSE(x) false
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+
+#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#define _LIBCPP_HAS_NO_DECLTYPE
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define _LIBCPP_HAS_NO_NULLPTR
+#define _LIBCPP_HAS_NO_STATIC_ASSERT
+#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
+
+#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_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_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_NULLPTR
+#endif
+
+#if _GNUC_VER < 407
+#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#endif
+
+#endif  // __GXX_EXPERIMENTAL_CXX0X__
+
+#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
+#define _LIBCPP_END_NAMESPACE_STD  } }
+#define _VSTD std::_LIBCPP_NAMESPACE
+
+namespace std {
+namespace _LIBCPP_NAMESPACE {
+}
+using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
+}
+
+#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
+#define _LIBCPP_HAS_NO_ASAN
+#endif
+
+#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_UNICODE_CHARS
+#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#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  }
+#define _VSTD std
+
+#  define _LIBCPP_WEAK
+namespace std {
+}
+
+#define _LIBCPP_HAS_NO_ASAN
+
+#elif defined(__IBMCPP__)
+
+#define _ALIGNAS(x) __attribute__((__aligned__(x)))
+#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
+#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_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_NULLPTR
+#define _LIBCPP_HAS_NO_UNICODE_CHARS
+#define _LIBCPP_HAS_IS_BASE_OF
+
+#if defined(_AIX)
+#define __MULTILOCALE_API
+#endif
+
+#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
+#define _LIBCPP_END_NAMESPACE_STD  } }
+#define _VSTD std::_LIBCPP_NAMESPACE
+
+namespace std {
+  inline namespace _LIBCPP_NAMESPACE {
+  }
+}
+
+#define _LIBCPP_HAS_NO_ASAN
+
+#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__
+
+#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
+typedef unsigned short char16_t;
+typedef unsigned int   char32_t;
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+#ifndef __SIZEOF_INT128__
+#define _LIBCPP_HAS_NO_INT128
+#endif
+
+#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
+
+template <bool> struct __static_assert_test;
+template <> struct __static_assert_test<true> {};
+template <unsigned> struct __static_assert_check {};
+#define static_assert(__b, __m) \
+    typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
+    _LIBCPP_CONCAT(__t, __LINE__)
+
+#endif  // _LIBCPP_HAS_NO_STATIC_ASSERT
+
+#ifdef _LIBCPP_HAS_NO_DECLTYPE
+#define decltype(x) __typeof__(x)
+#endif
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#define _LIBCPP_CONSTEXPR
+#else
+#define _LIBCPP_CONSTEXPR constexpr
+#endif
+
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+#define _LIBCPP_DEFAULT {}
+#else
+#define _LIBCPP_DEFAULT = default;
+#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
+#   define _LIBCPP_EXPLICIT
+#endif
+
+#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete)
+#   define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
+#endif
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx
+#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
+    __lx __v_; \
+    _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \
+    _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
+    _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
+    };
+#else  // _LIBCPP_HAS_NO_STRONG_ENUMS
+#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x
+#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
+#endif  // _LIBCPP_HAS_NO_STRONG_ENUMS
+
+#ifdef _LIBCPP_DEBUG
+#   if _LIBCPP_DEBUG == 0
+#       define _LIBCPP_DEBUG_LEVEL 1
+#   elif _LIBCPP_DEBUG == 1
+#       define _LIBCPP_DEBUG_LEVEL 2
+#   else
+#       error Supported values for _LIBCPP_DEBUG are 0 and 1
+#   endif
+#   define _LIBCPP_EXTERN_TEMPLATE(...)
+#endif
+
+#ifndef _LIBCPP_EXTERN_TEMPLATE
+#define _LIBCPP_EXTERN_TEMPLATE(...)
+#endif
+
+#ifndef _LIBCPP_EXTERN_TEMPLATE2
+#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
+#endif
+
+#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
+#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
+#endif
+
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__)
+#define _LIBCPP_LOCALE__L_EXTENSIONS 1
+#endif
+
+#ifdef __FreeBSD__
+#define _DECLARE_C99_LDBL_MATH 1
+#endif
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
+#define _LIBCPP_HAS_DEFAULTRUNELOCALE
+#endif
+
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
+#define _LIBCPP_WCTYPE_IS_MASK
+#endif
+
+#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
+#  define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1
+#endif
+
+#ifndef _LIBCPP_STD_VER
+#  if  __cplusplus <= 201103L
+#    define _LIBCPP_STD_VER 11
+#  elif __cplusplus <= 201402L
+#    define _LIBCPP_STD_VER 14
+#  else
+#    define _LIBCPP_STD_VER 15  // current year, or date of c++17 ratification
+#  endif
+#endif  // _LIBCPP_STD_VER
+
+#if _LIBCPP_STD_VER > 11
+#define _LIBCPP_DEPRECATED [[deprecated]]
+#else
+#define _LIBCPP_DEPRECATED
+#endif
+
+#if _LIBCPP_STD_VER <= 11
+#define _LIBCPP_EXPLICIT_AFTER_CXX11
+#define _LIBCPP_DEPRECATED_AFTER_CXX11
+#else
+#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit
+#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]]
+#endif
+
+#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr
+#else
+#define _LIBCPP_CONSTEXPR_AFTER_CXX11
+#endif
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" void __sanitizer_annotate_contiguous_container(
+  const void *, const void *, const void *, const void *);
+#endif
+
+// Try to find out if RTTI is disabled.
+// 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__ >= 4 && \
+   (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2)) && !defined(__GXX_RTTI)
+#    define _LIBCPP_NO_RTTI
+#  elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI)
+#    define _LIBCPP_NO_RTTI
+#  endif
+#endif
+
+#ifndef _LIBCPP_WEAK
+#  define _LIBCPP_WEAK __attribute__((__weak__))
+#endif
+
+#endif  // _LIBCPP_CONFIG
diff --git a/final/include/__debug b/final/include/__debug
new file mode 100644
index 0000000..f1805ad
--- /dev/null
+++ b/final/include/__debug
@@ -0,0 +1,218 @@
+// -*- C++ -*-
+//===--------------------------- __debug ----------------------------------===//
+//
+//                     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_DEBUG_H
+#define _LIBCPP_DEBUG_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#if _LIBCPP_DEBUG_LEVEL >= 1
+
+#   include <cstdlib>
+#   include <cstdio>
+#   include <cstddef>
+#   ifndef _LIBCPP_ASSERT
+#      define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort()))
+#   endif
+
+#endif
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TYPE_VIS __c_node;
+
+struct _LIBCPP_TYPE_VIS __i_node
+{
+    void* __i_;
+    __i_node* __next_;
+    __c_node* __c_;
+
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+    __i_node(const __i_node&) = delete;
+    __i_node& operator=(const __i_node&) = delete;
+#else
+private:
+    __i_node(const __i_node&);
+    __i_node& operator=(const __i_node&);
+public:
+#endif
+    _LIBCPP_INLINE_VISIBILITY
+    __i_node(void* __i, __i_node* __next, __c_node* __c)
+        : __i_(__i), __next_(__next), __c_(__c) {}
+    ~__i_node();
+};
+
+struct _LIBCPP_TYPE_VIS __c_node
+{
+    void* __c_;
+    __c_node* __next_;
+    __i_node** beg_;
+    __i_node** end_;
+    __i_node** cap_;
+
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+    __c_node(const __c_node&) = delete;
+    __c_node& operator=(const __c_node&) = delete;
+#else
+private:
+    __c_node(const __c_node&);
+    __c_node& operator=(const __c_node&);
+public:
+#endif
+    _LIBCPP_INLINE_VISIBILITY
+    __c_node(void* __c, __c_node* __next)
+        : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}
+    virtual ~__c_node();
+
+    virtual bool __dereferenceable(const void*) const = 0;
+    virtual bool __decrementable(const void*) const = 0;
+    virtual bool __addable(const void*, ptrdiff_t) const = 0;
+    virtual bool __subscriptable(const void*, ptrdiff_t) const = 0;
+
+    void __add(__i_node* __i);
+    _LIBCPP_HIDDEN void __remove(__i_node* __i);
+};
+
+template <class _Cont>
+struct _C_node
+    : public __c_node
+{
+    _C_node(void* __c, __c_node* __n)
+        : __c_node(__c, __n) {}
+
+    virtual bool __dereferenceable(const void*) const;
+    virtual bool __decrementable(const void*) const;
+    virtual bool __addable(const void*, ptrdiff_t) const;
+    virtual bool __subscriptable(const void*, ptrdiff_t) const;
+};
+
+template <class _Cont>
+bool
+_C_node<_Cont>::__dereferenceable(const void* __i) const
+{
+    typedef typename _Cont::const_iterator iterator;
+    const iterator* __j = static_cast<const iterator*>(__i);
+    _Cont* _Cp = static_cast<_Cont*>(__c_);
+    return _Cp->__dereferenceable(__j);
+}
+
+template <class _Cont>
+bool
+_C_node<_Cont>::__decrementable(const void* __i) const
+{
+    typedef typename _Cont::const_iterator iterator;
+    const iterator* __j = static_cast<const iterator*>(__i);
+    _Cont* _Cp = static_cast<_Cont*>(__c_);
+    return _Cp->__decrementable(__j);
+}
+
+template <class _Cont>
+bool
+_C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const
+{
+    typedef typename _Cont::const_iterator iterator;
+    const iterator* __j = static_cast<const iterator*>(__i);
+    _Cont* _Cp = static_cast<_Cont*>(__c_);
+    return _Cp->__addable(__j, __n);
+}
+
+template <class _Cont>
+bool
+_C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const
+{
+    typedef typename _Cont::const_iterator iterator;
+    const iterator* __j = static_cast<const iterator*>(__i);
+    _Cont* _Cp = static_cast<_Cont*>(__c_);
+    return _Cp->__subscriptable(__j, __n);
+}
+
+class _LIBCPP_TYPE_VIS __libcpp_db
+{
+    __c_node** __cbeg_;
+    __c_node** __cend_;
+    size_t   __csz_;
+    __i_node** __ibeg_;
+    __i_node** __iend_;
+    size_t   __isz_;
+
+    __libcpp_db();
+public:
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+    __libcpp_db(const __libcpp_db&) = delete;
+    __libcpp_db& operator=(const __libcpp_db&) = delete;
+#else
+private:
+    __libcpp_db(const __libcpp_db&);
+    __libcpp_db& operator=(const __libcpp_db&);
+public:
+#endif
+    ~__libcpp_db();
+
+    class __db_c_iterator;
+    class __db_c_const_iterator;
+    class __db_i_iterator;
+    class __db_i_const_iterator;
+
+    __db_c_const_iterator __c_end() const;
+    __db_i_const_iterator __i_end() const;
+
+    template <class _Cont>
+    _LIBCPP_INLINE_VISIBILITY
+    void __insert_c(_Cont* __c)
+    {
+        __c_node* __n = __insert_c(static_cast<void*>(__c));
+        ::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_);
+    }
+
+    void __insert_i(void* __i);
+    __c_node* __insert_c(void* __c);
+    void __erase_c(void* __c);
+
+    void __insert_ic(void* __i, const void* __c);
+    void __iterator_copy(void* __i, const void* __i0);
+    void __erase_i(void* __i);
+
+    void* __find_c_from_i(void* __i) const;
+    void __invalidate_all(void* __c);
+    __c_node* __find_c_and_lock(void* __c) const;
+    __c_node* __find_c(void* __c) const;
+    void unlock() const;
+
+    void swap(void* __c1, void* __c2);
+
+
+    bool __dereferenceable(const void* __i) const;
+    bool __decrementable(const void* __i) const;
+    bool __addable(const void* __i, ptrdiff_t __n) const;
+    bool __subscriptable(const void* __i, ptrdiff_t __n) const;
+    bool __less_than_comparable(const void* __i, const void* __j) const;
+private:
+    _LIBCPP_HIDDEN
+    __i_node* __insert_iterator(void* __i);
+    _LIBCPP_HIDDEN
+    __i_node* __find_iterator(const void* __i) const;
+
+    friend _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
+};
+
+_LIBCPP_FUNC_VIS __libcpp_db* __get_db();
+_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
+
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif
+
+#endif  // _LIBCPP_DEBUG_H
+
diff --git a/final/include/__functional_03 b/final/include/__functional_03
new file mode 100644
index 0000000..d8a9f05
--- /dev/null
+++ b/final/include/__functional_03
@@ -0,0 +1,2135 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FUNCTIONAL_03
+#define _LIBCPP_FUNCTIONAL_03
+
+// manual variadic expansion for <functional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#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>
+{
+};
+
+template<class _Fp> class __base;
+
+template<class _Rp>
+class __base<_Rp()>
+{
+    __base(const __base&);
+    __base& operator=(const __base&);
+public:
+    __base() {}
+    virtual ~__base() {}
+    virtual __base* __clone() const = 0;
+    virtual void __clone(__base*) const = 0;
+    virtual void destroy() = 0;
+    virtual void destroy_deallocate() = 0;
+    virtual _Rp operator()() = 0;
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const = 0;
+    virtual const std::type_info& target_type() const = 0;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0>
+class __base<_Rp(_A0)>
+{
+    __base(const __base&);
+    __base& operator=(const __base&);
+public:
+    __base() {}
+    virtual ~__base() {}
+    virtual __base* __clone() const = 0;
+    virtual void __clone(__base*) const = 0;
+    virtual void destroy() = 0;
+    virtual void destroy_deallocate() = 0;
+    virtual _Rp operator()(_A0) = 0;
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const = 0;
+    virtual const std::type_info& target_type() const = 0;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0, class _A1>
+class __base<_Rp(_A0, _A1)>
+{
+    __base(const __base&);
+    __base& operator=(const __base&);
+public:
+    __base() {}
+    virtual ~__base() {}
+    virtual __base* __clone() const = 0;
+    virtual void __clone(__base*) const = 0;
+    virtual void destroy() = 0;
+    virtual void destroy_deallocate() = 0;
+    virtual _Rp operator()(_A0, _A1) = 0;
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const = 0;
+    virtual const std::type_info& target_type() const = 0;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0, class _A1, class _A2>
+class __base<_Rp(_A0, _A1, _A2)>
+{
+    __base(const __base&);
+    __base& operator=(const __base&);
+public:
+    __base() {}
+    virtual ~__base() {}
+    virtual __base* __clone() const = 0;
+    virtual void __clone(__base*) const = 0;
+    virtual void destroy() = 0;
+    virtual void destroy_deallocate() = 0;
+    virtual _Rp operator()(_A0, _A1, _A2) = 0;
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const = 0;
+    virtual const std::type_info& target_type() const = 0;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _FD, class _Alloc, class _FB> class __func;
+
+template<class _Fp, class _Alloc, class _Rp>
+class __func<_Fp, _Alloc, _Rp()>
+    : public  __base<_Rp()>
+{
+    __compressed_pair<_Fp, _Alloc> __f_;
+public:
+    explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+    explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+    virtual __base<_Rp()>* __clone() const;
+    virtual void __clone(__base<_Rp()>*) const;
+    virtual void destroy();
+    virtual void destroy_deallocate();
+    virtual _Rp operator()();
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const;
+    virtual const std::type_info& target_type() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Fp, class _Alloc, class _Rp>
+__base<_Rp()>*
+__func<_Fp, _Alloc, _Rp()>::__clone() const
+{
+    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    _Ap __a(__f_.second());
+    typedef __allocator_destructor<_Ap> _Dp;
+    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+    return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+void
+__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const
+{
+    ::new (__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+void
+__func<_Fp, _Alloc, _Rp()>::destroy()
+{
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+void
+__func<_Fp, _Alloc, _Rp()>::destroy_deallocate()
+{
+    typedef typename _Alloc::template rebind<__func>::other _Ap;
+    _Ap __a(__f_.second());
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+    __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+_Rp
+__func<_Fp, _Alloc, _Rp()>::operator()()
+{
+    return __invoke(__f_.first());
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp>
+const void*
+__func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const
+{
+    if (__ti == typeid(_Fp))
+        return &__f_.first();
+    return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp()>::target_type() const
+{
+    return typeid(_Fp);
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+class __func<_Fp, _Alloc, _Rp(_A0)>
+    : public  __base<_Rp(_A0)>
+{
+    __compressed_pair<_Fp, _Alloc> __f_;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+    _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
+        : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+    virtual __base<_Rp(_A0)>* __clone() const;
+    virtual void __clone(__base<_Rp(_A0)>*) const;
+    virtual void destroy();
+    virtual void destroy_deallocate();
+    virtual _Rp operator()(_A0);
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const;
+    virtual const std::type_info& target_type() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+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;
+    _Ap __a(__f_.second());
+    typedef __allocator_destructor<_Ap> _Dp;
+    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+    return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+void
+__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const
+{
+    ::new (__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+void
+__func<_Fp, _Alloc, _Rp(_A0)>::destroy()
+{
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+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;
+    _Ap __a(__f_.second());
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+    __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+_Rp
+__func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0)
+{
+    return __invoke(__f_.first(), __a0);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+const void*
+__func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const
+{
+    if (__ti == typeid(_Fp))
+        return &__f_.first();
+    return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_A0)>::target_type() const
+{
+    return typeid(_Fp);
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+class __func<_Fp, _Alloc, _Rp(_A0, _A1)>
+    : public  __base<_Rp(_A0, _A1)>
+{
+    __compressed_pair<_Fp, _Alloc> __f_;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+    _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
+        : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+    virtual __base<_Rp(_A0, _A1)>* __clone() const;
+    virtual void __clone(__base<_Rp(_A0, _A1)>*) const;
+    virtual void destroy();
+    virtual void destroy_deallocate();
+    virtual _Rp operator()(_A0, _A1);
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const;
+    virtual const std::type_info& target_type() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+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;
+    _Ap __a(__f_.second());
+    typedef __allocator_destructor<_Ap> _Dp;
+    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+    return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const
+{
+    ::new (__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy()
+{
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+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;
+    _Ap __a(__f_.second());
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+    __a.deallocate(this, 1);
+}
+
+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);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+const void*
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const
+{
+    if (__ti == typeid(_Fp))
+        return &__f_.first();
+    return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const
+{
+    return typeid(_Fp);
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>
+    : public  __base<_Rp(_A0, _A1, _A2)>
+{
+    __compressed_pair<_Fp, _Alloc> __f_;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {}
+    _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a)
+        : __f_(_VSTD::move(__f), _VSTD::move(__a)) {}
+    virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const;
+    virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const;
+    virtual void destroy();
+    virtual void destroy_deallocate();
+    virtual _Rp operator()(_A0, _A1, _A2);
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const;
+    virtual const std::type_info& target_type() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+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;
+    _Ap __a(__f_.second());
+    typedef __allocator_destructor<_Ap> _Dp;
+    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+    return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const
+{
+    ::new (__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+void
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy()
+{
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+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;
+    _Ap __a(__f_.second());
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+    __a.deallocate(this, 1);
+}
+
+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);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+const void*
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const
+{
+    if (__ti == typeid(_Fp))
+        return &__f_.first();
+    return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const
+{
+    return typeid(_Fp);
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+}  // __function
+
+template<class _Rp>
+class _LIBCPP_TYPE_VIS_ONLY function<_Rp()>
+{
+    typedef __function::__base<_Rp()> __base;
+    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;
+
+    // 20.7.16.2.1, construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+    _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+    function(const function&);
+    template<class _Fp>
+      function(_Fp,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+    template<class _Alloc>
+      function(allocator_arg_t, const _Alloc&, const function&);
+    template<class _Fp, class _Alloc>
+      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    function& operator=(const function&);
+    function& operator=(nullptr_t);
+    template<class _Fp>
+      typename enable_if
+      <
+        !is_integral<_Fp>::value,
+        function&
+      >::type
+      operator=(_Fp);
+
+    ~function();
+
+    // 20.7.16.2.2, function modifiers:
+    void swap(function&);
+    template<class _Fp, class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      void assign(_Fp __f, const _Alloc& __a)
+        {function(allocator_arg, __a, __f).swap(*this);}
+
+    // 20.7.16.2.3, function capacity:
+    _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
+
+private:
+    // deleted overloads close possible hole in the type system
+    template<class _R2>
+      bool operator==(const function<_R2()>&) const;// = delete;
+    template<class _R2>
+      bool operator!=(const function<_R2()>&) const;// = delete;
+public:
+    // 20.7.16.2.4, function invocation:
+    _Rp operator()() const;
+
+#ifndef _LIBCPP_NO_RTTI
+    // 20.7.16.2.5, function target access:
+    const std::type_info& target_type() const;
+    template <typename _Tp> _Tp* target();
+    template <typename _Tp> const _Tp* target() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp>
+function<_Rp()>::function(const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp>
+template<class _Alloc>
+function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp>
+template <class _Fp>
+function<_Rp()>::function(_Fp __f,
+                                     typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    if (__not_null(__f))
+    {
+        typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF;
+        if (sizeof(_FF) <= sizeof(__buf_))
+        {
+            __f_ = (__base*)&__buf_;
+            ::new (__f_) _FF(__f);
+        }
+        else
+        {
+            typedef allocator<_FF> _Ap;
+            _Ap __a;
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp>
+template <class _Fp, class _Alloc>
+function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+                                     typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    if (__not_null(__f))
+    {
+        typedef __function::__func<_Fp, _Alloc, _Rp()> _FF;
+        if (sizeof(_FF) <= sizeof(__buf_))
+        {
+            __f_ = (__base*)&__buf_;
+            ::new (__f_) _FF(__f);
+        }
+        else
+        {
+            typedef typename __alloc_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+                rebind_alloc<_FF>
+#else
+                rebind_alloc<_FF>::other
+#endif
+                                                         _Ap;
+            _Ap __a(__a0);
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, _Alloc(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp>
+function<_Rp()>&
+function<_Rp()>::operator=(const function& __f)
+{
+    function(__f).swap(*this);
+    return *this;
+}
+
+template<class _Rp>
+function<_Rp()>&
+function<_Rp()>::operator=(nullptr_t)
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+    __f_ = 0;
+}
+
+template<class _Rp>
+template <class _Fp>
+typename enable_if
+<
+    !is_integral<_Fp>::value,
+    function<_Rp()>&
+>::type
+function<_Rp()>::operator=(_Fp __f)
+{
+    function(_VSTD::move(__f)).swap(*this);
+    return *this;
+}
+
+template<class _Rp>
+function<_Rp()>::~function()
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+}
+
+template<class _Rp>
+void
+function<_Rp()>::swap(function& __f)
+{
+    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+    {
+        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+        __base* __t = (__base*)&__tempbuf;
+        __f_->__clone(__t);
+        __f_->destroy();
+        __f_ = 0;
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = 0;
+        __f_ = (__base*)&__buf_;
+        __t->__clone((__base*)&__f.__buf_);
+        __t->destroy();
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f_ == (__base*)&__buf_)
+    {
+        __f_->__clone((__base*)&__f.__buf_);
+        __f_->destroy();
+        __f_ = __f.__f_;
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = __f_;
+        __f_ = (__base*)&__buf_;
+    }
+    else
+        _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp>
+_Rp
+function<_Rp()>::operator()() const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__f_ == 0)
+        throw bad_function_call();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return (*__f_)();
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp>
+const std::type_info&
+function<_Rp()>::target_type() const
+{
+    if (__f_ == 0)
+        return typeid(void);
+    return __f_->target_type();
+}
+
+template<class _Rp>
+template <typename _Tp>
+_Tp*
+function<_Rp()>::target()
+{
+    if (__f_ == 0)
+        return (_Tp*)0;
+    return (_Tp*)__f_->target(typeid(_Tp));
+}
+
+template<class _Rp>
+template <typename _Tp>
+const _Tp*
+function<_Rp()>::target() const
+{
+    if (__f_ == 0)
+        return (const _Tp*)0;
+    return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0>
+class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)>
+    : public unary_function<_A0, _Rp>
+{
+    typedef __function::__base<_Rp(_A0)> __base;
+    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;
+
+    // 20.7.16.2.1, construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+    _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+    function(const function&);
+    template<class _Fp>
+      function(_Fp,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+    template<class _Alloc>
+      function(allocator_arg_t, const _Alloc&, const function&);
+    template<class _Fp, class _Alloc>
+      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    function& operator=(const function&);
+    function& operator=(nullptr_t);
+    template<class _Fp>
+      typename enable_if
+      <
+        !is_integral<_Fp>::value,
+        function&
+      >::type
+      operator=(_Fp);
+
+    ~function();
+
+    // 20.7.16.2.2, function modifiers:
+    void swap(function&);
+    template<class _Fp, class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      void assign(_Fp __f, const _Alloc& __a)
+        {function(allocator_arg, __a, __f).swap(*this);}
+
+    // 20.7.16.2.3, function capacity:
+    _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
+
+private:
+    // deleted overloads close possible hole in the type system
+    template<class _R2, class _B0>
+      bool operator==(const function<_R2(_B0)>&) const;// = delete;
+    template<class _R2, class _B0>
+      bool operator!=(const function<_R2(_B0)>&) const;// = delete;
+public:
+    // 20.7.16.2.4, function invocation:
+    _Rp operator()(_A0) const;
+
+#ifndef _LIBCPP_NO_RTTI
+    // 20.7.16.2.5, function target access:
+    const std::type_info& target_type() const;
+    template <typename _Tp> _Tp* target();
+    template <typename _Tp> const _Tp* target() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>::function(const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0>
+template<class _Alloc>
+function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0>
+template <class _Fp>
+function<_Rp(_A0)>::function(_Fp __f,
+                                     typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    if (__not_null(__f))
+    {
+        typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF;
+        if (sizeof(_FF) <= sizeof(__buf_))
+        {
+            __f_ = (__base*)&__buf_;
+            ::new (__f_) _FF(__f);
+        }
+        else
+        {
+            typedef allocator<_FF> _Ap;
+            _Ap __a;
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class _A0>
+template <class _Fp, class _Alloc>
+function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+                                     typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    if (__not_null(__f))
+    {
+        typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF;
+        if (sizeof(_FF) <= sizeof(__buf_))
+        {
+            __f_ = (__base*)&__buf_;
+            ::new (__f_) _FF(__f);
+        }
+        else
+        {
+            typedef typename __alloc_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+                rebind_alloc<_FF>
+#else
+                rebind_alloc<_FF>::other
+#endif
+                                                         _Ap;
+            _Ap __a(__a0);
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, _Alloc(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>&
+function<_Rp(_A0)>::operator=(const function& __f)
+{
+    function(__f).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>&
+function<_Rp(_A0)>::operator=(nullptr_t)
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+    __f_ = 0;
+}
+
+template<class _Rp, class _A0>
+template <class _Fp>
+typename enable_if
+<
+    !is_integral<_Fp>::value,
+    function<_Rp(_A0)>&
+>::type
+function<_Rp(_A0)>::operator=(_Fp __f)
+{
+    function(_VSTD::move(__f)).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class _A0>
+function<_Rp(_A0)>::~function()
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+}
+
+template<class _Rp, class _A0>
+void
+function<_Rp(_A0)>::swap(function& __f)
+{
+    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+    {
+        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+        __base* __t = (__base*)&__tempbuf;
+        __f_->__clone(__t);
+        __f_->destroy();
+        __f_ = 0;
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = 0;
+        __f_ = (__base*)&__buf_;
+        __t->__clone((__base*)&__f.__buf_);
+        __t->destroy();
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f_ == (__base*)&__buf_)
+    {
+        __f_->__clone((__base*)&__f.__buf_);
+        __f_->destroy();
+        __f_ = __f.__f_;
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = __f_;
+        __f_ = (__base*)&__buf_;
+    }
+    else
+        _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class _A0>
+_Rp
+function<_Rp(_A0)>::operator()(_A0 __a0) const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__f_ == 0)
+        throw bad_function_call();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return (*__f_)(__a0);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0>
+const std::type_info&
+function<_Rp(_A0)>::target_type() const
+{
+    if (__f_ == 0)
+        return typeid(void);
+    return __f_->target_type();
+}
+
+template<class _Rp, class _A0>
+template <typename _Tp>
+_Tp*
+function<_Rp(_A0)>::target()
+{
+    if (__f_ == 0)
+        return (_Tp*)0;
+    return (_Tp*)__f_->target(typeid(_Tp));
+}
+
+template<class _Rp, class _A0>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_A0)>::target() const
+{
+    if (__f_ == 0)
+        return (const _Tp*)0;
+    return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1>
+class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)>
+    : public binary_function<_A0, _A1, _Rp>
+{
+    typedef __function::__base<_Rp(_A0, _A1)> __base;
+    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;
+
+    // 20.7.16.2.1, construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+    _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+    function(const function&);
+    template<class _Fp>
+      function(_Fp,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+    template<class _Alloc>
+      function(allocator_arg_t, const _Alloc&, const function&);
+    template<class _Fp, class _Alloc>
+      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    function& operator=(const function&);
+    function& operator=(nullptr_t);
+    template<class _Fp>
+      typename enable_if
+      <
+        !is_integral<_Fp>::value,
+        function&
+      >::type
+      operator=(_Fp);
+
+    ~function();
+
+    // 20.7.16.2.2, function modifiers:
+    void swap(function&);
+    template<class _Fp, class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      void assign(_Fp __f, const _Alloc& __a)
+        {function(allocator_arg, __a, __f).swap(*this);}
+
+    // 20.7.16.2.3, function capacity:
+    operator bool() const {return __f_;}
+
+private:
+    // deleted overloads close possible hole in the type system
+    template<class _R2, class _B0, class _B1>
+      bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete;
+    template<class _R2, class _B0, class _B1>
+      bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete;
+public:
+    // 20.7.16.2.4, function invocation:
+    _Rp operator()(_A0, _A1) const;
+
+#ifndef _LIBCPP_NO_RTTI
+    // 20.7.16.2.5, function target access:
+    const std::type_info& target_type() const;
+    template <typename _Tp> _Tp* target();
+    template <typename _Tp> const _Tp* target() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>::function(const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1>
+template<class _Alloc>
+function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1>
+template <class _Fp>
+function<_Rp(_A0, _A1)>::function(_Fp __f,
+                                 typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    if (__not_null(__f))
+    {
+        typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF;
+        if (sizeof(_FF) <= sizeof(__buf_))
+        {
+            __f_ = (__base*)&__buf_;
+            ::new (__f_) _FF(__f);
+        }
+        else
+        {
+            typedef allocator<_FF> _Ap;
+            _Ap __a;
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class _A0, class _A1>
+template <class _Fp, class _Alloc>
+function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+                                 typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    if (__not_null(__f))
+    {
+        typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF;
+        if (sizeof(_FF) <= sizeof(__buf_))
+        {
+            __f_ = (__base*)&__buf_;
+            ::new (__f_) _FF(__f);
+        }
+        else
+        {
+            typedef typename __alloc_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+                rebind_alloc<_FF>
+#else
+                rebind_alloc<_FF>::other
+#endif
+                                                         _Ap;
+            _Ap __a(__a0);
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, _Alloc(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>&
+function<_Rp(_A0, _A1)>::operator=(const function& __f)
+{
+    function(__f).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>&
+function<_Rp(_A0, _A1)>::operator=(nullptr_t)
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+    __f_ = 0;
+}
+
+template<class _Rp, class _A0, class _A1>
+template <class _Fp>
+typename enable_if
+<
+    !is_integral<_Fp>::value,
+    function<_Rp(_A0, _A1)>&
+>::type
+function<_Rp(_A0, _A1)>::operator=(_Fp __f)
+{
+    function(_VSTD::move(__f)).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class _A0, class _A1>
+function<_Rp(_A0, _A1)>::~function()
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+}
+
+template<class _Rp, class _A0, class _A1>
+void
+function<_Rp(_A0, _A1)>::swap(function& __f)
+{
+    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+    {
+        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+        __base* __t = (__base*)&__tempbuf;
+        __f_->__clone(__t);
+        __f_->destroy();
+        __f_ = 0;
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = 0;
+        __f_ = (__base*)&__buf_;
+        __t->__clone((__base*)&__f.__buf_);
+        __t->destroy();
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f_ == (__base*)&__buf_)
+    {
+        __f_->__clone((__base*)&__f.__buf_);
+        __f_->destroy();
+        __f_ = __f.__f_;
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = __f_;
+        __f_ = (__base*)&__buf_;
+    }
+    else
+        _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class _A0, class _A1>
+_Rp
+function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__f_ == 0)
+        throw bad_function_call();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return (*__f_)(__a0, __a1);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1>
+const std::type_info&
+function<_Rp(_A0, _A1)>::target_type() const
+{
+    if (__f_ == 0)
+        return typeid(void);
+    return __f_->target_type();
+}
+
+template<class _Rp, class _A0, class _A1>
+template <typename _Tp>
+_Tp*
+function<_Rp(_A0, _A1)>::target()
+{
+    if (__f_ == 0)
+        return (_Tp*)0;
+    return (_Tp*)__f_->target(typeid(_Tp));
+}
+
+template<class _Rp, class _A0, class _A1>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_A0, _A1)>::target() const
+{
+    if (__f_ == 0)
+        return (const _Tp*)0;
+    return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1, class _A2>
+class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)>
+{
+    typedef __function::__base<_Rp(_A0, _A1, _A2)> __base;
+    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;
+
+    // 20.7.16.2.1, construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {}
+    _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {}
+    function(const function&);
+    template<class _Fp>
+      function(_Fp,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&) : __f_(0) {}
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {}
+    template<class _Alloc>
+      function(allocator_arg_t, const _Alloc&, const function&);
+    template<class _Fp, class _Alloc>
+      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+               typename enable_if<!is_integral<_Fp>::value>::type* = 0);
+
+    function& operator=(const function&);
+    function& operator=(nullptr_t);
+    template<class _Fp>
+      typename enable_if
+      <
+        !is_integral<_Fp>::value,
+        function&
+      >::type
+      operator=(_Fp);
+
+    ~function();
+
+    // 20.7.16.2.2, function modifiers:
+    void swap(function&);
+    template<class _Fp, class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      void assign(_Fp __f, const _Alloc& __a)
+        {function(allocator_arg, __a, __f).swap(*this);}
+
+    // 20.7.16.2.3, function capacity:
+    _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;}
+
+private:
+    // deleted overloads close possible hole in the type system
+    template<class _R2, class _B0, class _B1, class _B2>
+      bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete;
+    template<class _R2, class _B0, class _B1, class _B2>
+      bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete;
+public:
+    // 20.7.16.2.4, function invocation:
+    _Rp operator()(_A0, _A1, _A2) const;
+
+#ifndef _LIBCPP_NO_RTTI
+    // 20.7.16.2.5, function target access:
+    const std::type_info& target_type() const;
+    template <typename _Tp> _Tp* target();
+    template <typename _Tp> const _Tp* target() const;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>::function(const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template<class _Alloc>
+function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&,
+                                      const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <class _Fp>
+function<_Rp(_A0, _A1, _A2)>::function(_Fp __f,
+                                     typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    if (__not_null(__f))
+    {
+        typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF;
+        if (sizeof(_FF) <= sizeof(__buf_))
+        {
+            __f_ = (__base*)&__buf_;
+            ::new (__f_) _FF(__f);
+        }
+        else
+        {
+            typedef allocator<_FF> _Ap;
+            _Ap __a;
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <class _Fp, class _Alloc>
+function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+                                     typename enable_if<!is_integral<_Fp>::value>::type*)
+    : __f_(0)
+{
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    if (__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);
+        }
+        else
+        {
+            typedef typename __alloc_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+                rebind_alloc<_FF>
+#else
+                rebind_alloc<_FF>::other
+#endif
+                                                         _Ap;
+            _Ap __a(__a0);
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(__f, _Alloc(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>&
+function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f)
+{
+    function(__f).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>&
+function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+    __f_ = 0;
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <class _Fp>
+typename enable_if
+<
+    !is_integral<_Fp>::value,
+    function<_Rp(_A0, _A1, _A2)>&
+>::type
+function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f)
+{
+    function(_VSTD::move(__f)).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+function<_Rp(_A0, _A1, _A2)>::~function()
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+void
+function<_Rp(_A0, _A1, _A2)>::swap(function& __f)
+{
+    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+    {
+        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+        __base* __t = (__base*)&__tempbuf;
+        __f_->__clone(__t);
+        __f_->destroy();
+        __f_ = 0;
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = 0;
+        __f_ = (__base*)&__buf_;
+        __t->__clone((__base*)&__f.__buf_);
+        __t->destroy();
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f_ == (__base*)&__buf_)
+    {
+        __f_->__clone((__base*)&__f.__buf_);
+        __f_->destroy();
+        __f_ = __f.__f_;
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = __f_;
+        __f_ = (__base*)&__buf_;
+    }
+    else
+        _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+_Rp
+function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__f_ == 0)
+        throw bad_function_call();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return (*__f_)(__a0, __a1, __a2);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class _A0, class _A1, class _A2>
+const std::type_info&
+function<_Rp(_A0, _A1, _A2)>::target_type() const
+{
+    if (__f_ == 0)
+        return typeid(void);
+    return __f_->target_type();
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <typename _Tp>
+_Tp*
+function<_Rp(_A0, _A1, _A2)>::target()
+{
+    if (__f_ == 0)
+        return (_Tp*)0;
+    return (_Tp*)__f_->target(typeid(_Tp));
+}
+
+template<class _Rp, class _A0, class _A1, class _A2>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_A0, _A1, _A2)>::target() const
+{
+    if (__f_ == 0)
+        return (const _Tp*)0;
+    return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const function<_Fp>& __f, nullptr_t) {return !__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const function<_Fp>& __f) {return !__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;}
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+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/final/include/__functional_base b/final/include/__functional_base
new file mode 100644
index 0000000..6766793
--- /dev/null
+++ b/final/include/__functional_base
@@ -0,0 +1,615 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FUNCTIONAL_BASE
+#define _LIBCPP_FUNCTIONAL_BASE
+
+#include <__config>
+#include <type_traits>
+#include <typeinfo>
+#include <exception>
+#include <new>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Arg, class _Result>
+struct _LIBCPP_TYPE_VIS_ONLY unary_function
+{
+    typedef _Arg    argument_type;
+    typedef _Result result_type;
+};
+
+template <class _Arg1, class _Arg2, class _Result>
+struct _LIBCPP_TYPE_VIS_ONLY binary_function
+{
+    typedef _Arg1   first_argument_type;
+    typedef _Arg2   second_argument_type;
+    typedef _Result result_type;
+};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
+
+template <class _Tp>
+struct __has_result_type
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::result_type* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x < __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    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>
+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<_Tp>
+{
+};
+
+// 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>
+{
+};
+
+// 3 or more arguments
+
+template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
+struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
+struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
+struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
+{
+    typedef _Rp result_type;
+};
+
+// __invoke
+
+// bullets 1 and 2
+
+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)...))
+{
+    return ((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...);
+}
+
+// bullets 3 and 4
+
+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;
+}
+
+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;
+}
+
+// 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)...))
+{
+    return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
+}
+
+template <class _Tp, class ..._Args>
+struct __invoke_return
+{
+    typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) 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) _NOEXCEPT
+        : __f_(_VSTD::addressof(__f)) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
+#endif
+
+    // access
+    _LIBCPP_INLINE_VISIBILITY operator type&    () const _NOEXCEPT {return *__f_;}
+    _LIBCPP_INLINE_VISIBILITY          type& get() const _NOEXCEPT {return *__f_;}
+
+    // invoke
+    template <class... _ArgTypes>
+       _LIBCPP_INLINE_VISIBILITY
+       typename __invoke_of<type&, _ArgTypes...>::type
+          operator() (_ArgTypes&&... __args) const
+          {
+              return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
+          }
+};
+
+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) _NOEXCEPT
+{
+    return reference_wrapper<_Tp>(__t);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+reference_wrapper<_Tp>
+ref(reference_wrapper<_Tp> __t) _NOEXCEPT
+{
+    return ref(__t.get());
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+reference_wrapper<const _Tp>
+cref(const _Tp& __t) _NOEXCEPT
+{
+    return reference_wrapper<const _Tp>(__t);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+reference_wrapper<const _Tp>
+cref(reference_wrapper<_Tp> __t) _NOEXCEPT
+{
+    return cref(__t.get());
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+
+template <class _Tp> void ref(const _Tp&&) = delete;
+template <class _Tp> void cref(const _Tp&&) = delete;
+
+#else  // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+
+template <class _Tp> void ref(const _Tp&&);// = delete;
+template <class _Tp> void cref(const _Tp&&);// = delete;
+
+#endif  // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp1, class _Tp2 = void>
+struct __is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp1>(0)) == 1;
+};
+#endif
+
+// allocator_arg_t
+
+struct _LIBCPP_TYPE_VIS_ONLY allocator_arg_t { };
+
+#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY)
+extern const allocator_arg_t allocator_arg;
+#else
+constexpr allocator_arg_t allocator_arg = allocator_arg_t();
+#endif
+
+// uses_allocator
+
+template <class _Tp>
+struct __has_allocator_type
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::allocator_type* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value>
+struct __uses_allocator
+    : public integral_constant<bool,
+        is_convertible<_Alloc, typename _Tp::allocator_type>::value>
+{
+};
+
+template <class _Tp, class _Alloc>
+struct __uses_allocator<_Tp, _Alloc, false>
+    : public false_type
+{
+};
+
+template <class _Tp, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator
+    : public __uses_allocator<_Tp, _Alloc>
+{
+};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+// allocator construction
+
+template <class _Tp, class _Alloc, class ..._Args>
+struct __uses_alloc_ctor_imp
+{
+    static const bool __ua = uses_allocator<_Tp, _Alloc>::value;
+    static const bool __ic =
+        is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
+    static const int value = __ua ? 2 - __ic : 0;
+};
+
+template <class _Tp, class _Alloc, class ..._Args>
+struct __uses_alloc_ctor
+    : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
+    {};
+
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args )
+{
+    new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
+}
+
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+    new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
+}
+
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
+{
+    new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
+}
+
+template <class _Tp, class _Allocator, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args)
+{ 
+    __user_alloc_construct_impl( 
+             __uses_alloc_ctor<_Tp, _Allocator>(), 
+             __storage, __a, _VSTD::forward<_Args>(__args)...
+        );
+}
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_FUNCTIONAL_BASE
diff --git a/final/include/__functional_base_03 b/final/include/__functional_base_03
new file mode 100644
index 0000000..f297ee0
--- /dev/null
+++ b/final/include/__functional_base_03
@@ -0,0 +1,1087 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FUNCTIONAL_BASE_03
+#define _LIBCPP_FUNCTIONAL_BASE_03
+
+// 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>
+{
+};
+
+// 3 or more arguments
+
+template <class _Rp, class _A1, class _A2, class _A3>
+struct __weak_result_type<_Rp (_A1, _A2, _A3)>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _A1, class _A2, class _A3>
+struct __weak_result_type<_Rp (&)(_A1, _A2, _A3)>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _A1, class _A2, class _A3>
+struct __weak_result_type<_Rp (*)(_A1, _A2, _A3)>
+{
+    typedef _Rp result_type;
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2)>
+{
+    typedef _Rp result_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 _Rp, class _Cp, class _A1, class _A2>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) volatile>
+{
+    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>
+// {
+// };
+
+// 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>
+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)
+{
+    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)
+{
+    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);
+}
+
+// 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)
+{
+    return __t1.*__f;
+}
+
+template <class _Rp, class _Tp>
+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)
+{
+    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)
+{
+    return __f();
+}
+
+template <class _Fp, class _A0>
+inline _LIBCPP_INLINE_VISIBILITY
+decltype(declval<_Fp>()(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)
+{
+    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)
+{
+    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
+{
+    typedef typename __weak_result_type<_Fp>::result_type type;
+};
+
+template <class _Fp>
+struct __invoke_return<_Fp, false>
+{
+    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;
+};
+
+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;
+};
+
+template <class _Tp, class _A0, class _A1>
+struct __invoke_return1
+{
+    typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(),
+                                                    _VSTD::declval<_A1>())) 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;
+};
+
+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(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, 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 _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/final/include/__hash_table b/final/include/__hash_table
new file mode 100644
index 0000000..4c4feb0
--- /dev/null
+++ b/final/include/__hash_table
@@ -0,0 +1,2457 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP__HASH_TABLE
+#define _LIBCPP__HASH_TABLE
+
+#include <__config>
+#include <initializer_list>
+#include <memory>
+#include <iterator>
+#include <algorithm>
+#include <cmath>
+
+#include <__undef_min_max>
+
+#ifdef _LIBCPP_DEBUG
+#   include <__debug>
+#else
+#   define _LIBCPP_ASSERT(x, m) ((void)0)
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_FUNC_VIS
+size_t __next_prime(size_t __n);
+
+template <class _NodePtr>
+struct __hash_node_base
+{
+    typedef __hash_node_base __first_node;
+
+    _NodePtr    __next_;
+
+    _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {}
+};
+
+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
+             >
+{
+    typedef _Tp value_type;
+
+    size_t     __hash_;
+    value_type __value_;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__is_power2(size_t __bc)
+{
+    return __bc > 2 && !(__bc & (__bc - 1));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+__constrain_hash(size_t __h, size_t __bc)
+{
+    return !(__bc & (__bc - 1)) ? __h & (__bc - 1) : __h % __bc;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+__next_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 _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_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 _NodePtr>
+class _LIBCPP_TYPE_VIS_ONLY __hash_iterator
+{
+    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;
+
+    _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+    : __node_(nullptr)
+#endif
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_i(this);
+#endif
+    }
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_iterator(const __hash_iterator& __i)
+        : __node_(__i.__node_)
+    {
+        __get_db()->__iterator_copy(this, &__i);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__hash_iterator()
+    {
+        __get_db()->__erase_i(this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_iterator& operator=(const __hash_iterator& __i)
+    {
+        if (this != &__i)
+        {
+            __get_db()->__iterator_copy(this, &__i);
+            __node_ = __i.__node_;
+        }
+        return *this;
+    }
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+        reference operator*() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container iterator");
+#endif
+            return __node_->__value_;
+        }
+    _LIBCPP_INLINE_VISIBILITY
+        pointer operator->() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container iterator");
+#endif
+            return pointer_traits<pointer>::pointer_to(__node_->__value_);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_iterator& operator++()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to increment non-incrementable unordered container iterator");
+#endif
+        __node_ = __node_->__next_;
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_iterator operator++(int)
+    {
+        __hash_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __hash_iterator& __x, const __hash_iterator& __y)
+    {
+        return __x.__node_ == __y.__node_;
+    }
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __hash_iterator& __x, const __hash_iterator& __y)
+        {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_iterator(__node_pointer __node, const void* __c) _NOEXCEPT
+        : __node_(__node)
+        {
+            __get_db()->__insert_ic(this, __c);
+        }
+#else
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_iterator(__node_pointer __node) _NOEXCEPT
+        : __node_(__node)
+        {}
+#endif
+
+    template <class, class, class, class> friend class __hash_table;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
+};
+
+template <class _ConstNodePtr>
+class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator
+{
+    typedef _ConstNodePtr __node_pointer;
+
+    __node_pointer         __node_;
+
+    typedef typename remove_const<
+        typename pointer_traits<__node_pointer>::element_type
+                                 >::type __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;
+
+    _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+    : __node_(nullptr)
+#endif
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_i(this);
+#endif
+    }
+    _LIBCPP_INLINE_VISIBILITY 
+    __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
+        : __node_(__x.__node_)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__iterator_copy(this, &__x);
+#endif
+    }
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_iterator(const __hash_const_iterator& __i)
+        : __node_(__i.__node_)
+    {
+        __get_db()->__iterator_copy(this, &__i);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__hash_const_iterator()
+    {
+        __get_db()->__erase_i(this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_iterator& operator=(const __hash_const_iterator& __i)
+    {
+        if (this != &__i)
+        {
+            __get_db()->__iterator_copy(this, &__i);
+            __node_ = __i.__node_;
+        }
+        return *this;
+    }
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+        reference operator*() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container const_iterator");
+#endif
+            return __node_->__value_;
+        }
+    _LIBCPP_INLINE_VISIBILITY
+        pointer operator->() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container const_iterator");
+#endif
+            return pointer_traits<pointer>::pointer_to(__node_->__value_);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_iterator& operator++()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to increment non-incrementable unordered container const_iterator");
+#endif
+        __node_ = __node_->__next_;
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_iterator operator++(int)
+    {
+        __hash_const_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __hash_const_iterator& __x, const __hash_const_iterator& __y)
+    {
+        return __x.__node_ == __y.__node_;
+    }
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __hash_const_iterator& __x, const __hash_const_iterator& __y)
+        {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_iterator(__node_pointer __node, const void* __c) _NOEXCEPT
+        : __node_(__node)
+        {
+            __get_db()->__insert_ic(this, __c);
+        }
+#else
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_iterator(__node_pointer __node) _NOEXCEPT
+        : __node_(__node)
+        {}
+#endif
+
+    template <class, class, class, class> friend class __hash_table;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
+    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;
+
+    __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 value_type&                                         reference;
+    typedef typename __pointer_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+            rebind<value_type>
+#else
+            rebind<value_type>::other
+#endif
+                                                                pointer;
+
+    _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_i(this);
+#endif
+    }
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_local_iterator(const __hash_local_iterator& __i)
+        : __node_(__i.__node_),
+          __bucket_(__i.__bucket_),
+          __bucket_count_(__i.__bucket_count_)
+    {
+        __get_db()->__iterator_copy(this, &__i);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__hash_local_iterator()
+    {
+        __get_db()->__erase_i(this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_local_iterator& operator=(const __hash_local_iterator& __i)
+    {
+        if (this != &__i)
+        {
+            __get_db()->__iterator_copy(this, &__i);
+            __node_ = __i.__node_;
+            __bucket_ = __i.__bucket_;
+            __bucket_count_ = __i.__bucket_count_;
+        }
+        return *this;
+    }
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+        reference operator*() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container local_iterator");
+#endif
+            return __node_->__value_;
+        }
+    _LIBCPP_INLINE_VISIBILITY
+        pointer operator->() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container local_iterator");
+#endif
+            return pointer_traits<pointer>::pointer_to(__node_->__value_);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_local_iterator& operator++()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to increment non-incrementable unordered container local_iterator");
+#endif
+        __node_ = __node_->__next_;
+        if (__node_ != nullptr && __constrain_hash(__node_->__hash_, __bucket_count_) != __bucket_)
+            __node_ = nullptr;
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_local_iterator operator++(int)
+    {
+        __hash_local_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __hash_local_iterator& __x, const __hash_local_iterator& __y)
+    {
+        return __x.__node_ == __y.__node_;
+    }
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __hash_local_iterator& __x, const __hash_local_iterator& __y)
+        {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_local_iterator(__node_pointer __node, size_t __bucket,
+                          size_t __bucket_count, const void* __c) _NOEXCEPT
+        : __node_(__node),
+          __bucket_(__bucket),
+          __bucket_count_(__bucket_count)
+        {
+            __get_db()->__insert_ic(this, __c);
+            if (__node_ != nullptr)
+                __node_ = __node_->__next_;
+        }
+#else
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_local_iterator(__node_pointer __node, size_t __bucket,
+                          size_t __bucket_count) _NOEXCEPT
+        : __node_(__node),
+          __bucket_(__bucket),
+          __bucket_count_(__bucket_count)
+        {
+            if (__node_ != nullptr)
+                __node_ = __node_->__next_;
+        }
+#endif
+    template <class, class, class, class> friend class __hash_table;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator;
+};
+
+template <class _ConstNodePtr>
+class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator
+{
+    typedef _ConstNodePtr __node_pointer;
+
+    __node_pointer         __node_;
+    size_t                 __bucket_;
+    size_t                 __bucket_count_;
+
+    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 __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;
+
+    _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_i(this);
+#endif
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT
+        : __node_(__x.__node_),
+          __bucket_(__x.__bucket_),
+          __bucket_count_(__x.__bucket_count_)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__iterator_copy(this, &__x);
+#endif
+    }
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_local_iterator(const __hash_const_local_iterator& __i)
+        : __node_(__i.__node_),
+          __bucket_(__i.__bucket_),
+          __bucket_count_(__i.__bucket_count_)
+    {
+        __get_db()->__iterator_copy(this, &__i);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__hash_const_local_iterator()
+    {
+        __get_db()->__erase_i(this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i)
+    {
+        if (this != &__i)
+        {
+            __get_db()->__iterator_copy(this, &__i);
+            __node_ = __i.__node_;
+            __bucket_ = __i.__bucket_;
+            __bucket_count_ = __i.__bucket_count_;
+        }
+        return *this;
+    }
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+        reference operator*() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
+#endif
+            return __node_->__value_;
+        }
+    _LIBCPP_INLINE_VISIBILITY
+        pointer operator->() const
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                           "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
+#endif
+            return pointer_traits<pointer>::pointer_to(__node_->__value_);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_local_iterator& operator++()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to increment non-incrementable unordered container const_local_iterator");
+#endif
+        __node_ = __node_->__next_;
+        if (__node_ != nullptr && __constrain_hash(__node_->__hash_, __bucket_count_) != __bucket_)
+            __node_ = nullptr;
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_local_iterator operator++(int)
+    {
+        __hash_const_local_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y)
+    {
+        return __x.__node_ == __y.__node_;
+    }
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y)
+        {return !(__x == __y);}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_local_iterator(__node_pointer __node, size_t __bucket,
+                                size_t __bucket_count, const void* __c) _NOEXCEPT
+        : __node_(__node),
+          __bucket_(__bucket),
+          __bucket_count_(__bucket_count)
+        {
+            __get_db()->__insert_ic(this, __c);
+            if (__node_ != nullptr)
+                __node_ = __node_->__next_;
+        }
+#else
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_const_local_iterator(__node_pointer __node, size_t __bucket,
+                                size_t __bucket_count) _NOEXCEPT
+        : __node_(__node),
+          __bucket_(__bucket),
+          __bucket_count_(__bucket_count)
+        {
+            if (__node_ != nullptr)
+                __node_ = __node_->__next_;
+        }
+#endif
+    template <class, class, class, class> friend class __hash_table;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
+};
+
+template <class _Alloc>
+class __bucket_list_deallocator
+{
+    typedef _Alloc                                          allocator_type;
+    typedef allocator_traits<allocator_type>                __alloc_traits;
+    typedef typename __alloc_traits::size_type              size_type;
+
+    __compressed_pair<size_type, allocator_type> __data_;
+public:
+    typedef typename __alloc_traits::pointer pointer;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bucket_list_deallocator()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+        : __data_(0) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bucket_list_deallocator(const allocator_type& __a, size_type __size)
+        _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
+        : __data_(__size, __a) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bucket_list_deallocator(__bucket_list_deallocator&& __x)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+        : __data_(_VSTD::move(__x.__data_))
+    {
+        __x.size() = 0;
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type& size() _NOEXCEPT {return __data_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type  size() const _NOEXCEPT {return __data_.first();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type& __alloc() _NOEXCEPT {return __data_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const allocator_type& __alloc() const _NOEXCEPT {return __data_.second();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void operator()(pointer __p) _NOEXCEPT
+    {
+        __alloc_traits::deallocate(__alloc(), __p, size());
+    }
+};
+
+template <class _Alloc> class __hash_map_node_destructor;
+
+template <class _Alloc>
+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:
+
+    allocator_type& __na_;
+
+    __hash_node_destructor& operator=(const __hash_node_destructor&);
+
+public:
+    bool __value_constructed;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __hash_node_destructor(allocator_type& __na,
+                                    bool __constructed = false) _NOEXCEPT
+        : __na_(__na),
+          __value_constructed(__constructed)
+        {}
+
+    _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);
+    }
+
+    template <class> friend class __hash_map_node_destructor;
+};
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+class __hash_table
+{
+public:
+    typedef _Tp    value_type;
+    typedef _Hash  hasher;
+    typedef _Equal key_equal;
+    typedef _Alloc allocator_type;
+
+private:
+    typedef allocator_traits<allocator_type> __alloc_traits;
+public:
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+    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;
+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
+#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 __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;
+
+private:
+
+    typedef typename __node_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+            rebind_alloc<__node_pointer>
+#else
+            rebind_alloc<__node_pointer>::other
+#endif
+                                                            __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_;
+    // --- Member data end ---
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type& size() _NOEXCEPT {return __p2_.first();}
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    size_type  size() const _NOEXCEPT {return __p2_.first();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher& hash_function() _NOEXCEPT {return __p2_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const hasher& hash_function() const _NOEXCEPT {return __p2_.second();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    float& max_load_factor() _NOEXCEPT {return __p3_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+    float  max_load_factor() const _NOEXCEPT {return __p3_.first();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal& key_eq() _NOEXCEPT {return __p3_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const key_equal& key_eq() const _NOEXCEPT {return __p3_.second();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __node_allocator& __node_alloc() _NOEXCEPT {return __p1_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const __node_allocator& __node_alloc() const _NOEXCEPT
+        {return __p1_.second();}
+
+public:
+    typedef __hash_iterator<__node_pointer>                   iterator;
+    typedef __hash_const_iterator<__node_pointer>             const_iterator;
+    typedef __hash_local_iterator<__node_pointer>             local_iterator;
+    typedef __hash_const_local_iterator<__node_pointer>       const_local_iterator;
+
+    __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);
+    __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
+    __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);
+    __hash_table(__hash_table&& __u, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~__hash_table();
+
+    __hash_table& operator=(const __hash_table& __u);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __hash_table& operator=(__hash_table&& __u)
+        _NOEXCEPT_(
+            __node_traits::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<__node_allocator>::value &&
+            is_nothrow_move_assignable<hasher>::value &&
+            is_nothrow_move_assignable<key_equal>::value);
+#endif
+    template <class _InputIterator>
+        void __assign_unique(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        void __assign_multi(_InputIterator __first, _InputIterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT
+    {
+        return allocator_traits<__pointer_allocator>::max_size(
+            __bucket_list_.get_deleter().__alloc());
+    }
+
+    pair<iterator, bool> __node_insert_unique(__node_pointer __nd);
+    iterator             __node_insert_multi(__node_pointer __nd);
+    iterator             __node_insert_multi(const_iterator __p,
+                                             __node_pointer __nd);
+
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class... _Args>
+        pair<iterator, bool> __emplace_unique(_Args&&... __args);
+    template <class... _Args>
+        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)
+
+    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
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Pp>
+        iterator __insert_multi(_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
+
+    void clear() _NOEXCEPT;
+    void rehash(size_type __n);
+    _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
+        {rehash(static_cast<size_type>(ceil(__n / max_load_factor())));}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const _NOEXCEPT
+    {
+        return __bucket_list_.get_deleter().size();
+    }
+
+    iterator       begin() _NOEXCEPT;
+    iterator       end() _NOEXCEPT;
+    const_iterator begin() const _NOEXCEPT;
+    const_iterator end() const _NOEXCEPT;
+
+    template <class _Key>
+        _LIBCPP_INLINE_VISIBILITY
+        size_type bucket(const _Key& __k) const
+        {
+            _LIBCPP_ASSERT(bucket_count() > 0,
+                "unordered container::bucket(key) called when bucket_count() == 0");
+            return __constrain_hash(hash_function()(__k), bucket_count());
+        }
+
+    template <class _Key>
+        iterator       find(const _Key& __x);
+    template <class _Key>
+        const_iterator find(const _Key& __x) const;
+
+    typedef __hash_node_destructor<__node_allocator> _Dp;
+    typedef unique_ptr<__node, _Dp> __node_holder;
+
+    iterator erase(const_iterator __p);
+    iterator erase(const_iterator __first, const_iterator __last);
+    template <class _Key>
+        size_type __erase_unique(const _Key& __k);
+    template <class _Key>
+        size_type __erase_multi(const _Key& __k);
+    __node_holder remove(const_iterator __p) _NOEXCEPT;
+
+    template <class _Key>
+        size_type __count_unique(const _Key& __k) const;
+    template <class _Key>
+        size_type __count_multi(const _Key& __k) const;
+
+    template <class _Key>
+        pair<iterator, iterator>
+        __equal_range_unique(const _Key& __k);
+    template <class _Key>
+        pair<const_iterator, const_iterator>
+        __equal_range_unique(const _Key& __k) const;
+
+    template <class _Key>
+        pair<iterator, iterator>
+        __equal_range_multi(const _Key& __k);
+    template <class _Key>
+        pair<const_iterator, const_iterator>
+        __equal_range_multi(const _Key& __k) const;
+
+    void swap(__hash_table& __u)
+        _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);
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const _NOEXCEPT
+        {return __pointer_alloc_traits::max_size(__bucket_list_.get_deleter().__alloc());}
+    size_type bucket_size(size_type __n) const;
+    _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT
+    {
+        size_type __bc = bucket_count();
+        return __bc != 0 ? (float)size() / __bc : 0.f;
+    }
+    _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT
+    {
+        _LIBCPP_ASSERT(__mlf > 0,
+            "unordered container::max_load_factor(lf) called with lf <= 0");
+        max_load_factor() = _VSTD::max(__mlf, load_factor());
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator
+    begin(size_type __n)
+    {
+        _LIBCPP_ASSERT(__n < bucket_count(),
+            "unordered container::begin(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
+#else
+        return local_iterator(__bucket_list_[__n], __n, bucket_count());
+#endif
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator
+    end(size_type __n)
+    {
+        _LIBCPP_ASSERT(__n < bucket_count(),
+            "unordered container::end(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return local_iterator(nullptr, __n, bucket_count(), this);
+#else
+        return local_iterator(nullptr, __n, bucket_count());
+#endif
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator
+    cbegin(size_type __n) const
+    {
+        _LIBCPP_ASSERT(__n < bucket_count(),
+            "unordered container::cbegin(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this);
+#else
+        return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
+#endif
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator
+    cend(size_type __n) const
+    {
+        _LIBCPP_ASSERT(__n < bucket_count(),
+            "unordered container::cend(n) called with n >= bucket_count()");
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return const_local_iterator(nullptr, __n, bucket_count(), this);
+#else
+        return const_local_iterator(nullptr, __n, bucket_count());
+#endif
+    }
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const;
+    bool __decrementable(const const_iterator* __i) const;
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+private:
+    void __rehash(size_type __n);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    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);
+#endif
+    __node_holder __construct_node(const value_type& __v, size_t __hash);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __hash_table& __u)
+        {__copy_assign_alloc(__u, integral_constant<bool,
+             __node_traits::propagate_on_container_copy_assignment::value>());}
+    void __copy_assign_alloc(const __hash_table& __u, true_type);
+    _LIBCPP_INLINE_VISIBILITY
+        void __copy_assign_alloc(const __hash_table&, false_type) {}
+
+    void __move_assign(__hash_table& __u, false_type);
+    void __move_assign(__hash_table& __u, true_type)
+        _NOEXCEPT_(
+            is_nothrow_move_assignable<__node_allocator>::value &&
+            is_nothrow_move_assignable<hasher>::value &&
+            is_nothrow_move_assignable<key_equal>::value);
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__hash_table& __u)
+        _NOEXCEPT_(
+            !__node_traits::propagate_on_container_move_assignment::value ||
+            (is_nothrow_move_assignable<__pointer_allocator>::value &&
+             is_nothrow_move_assignable<__node_allocator>::value))
+        {__move_assign_alloc(__u, integral_constant<bool,
+             __node_traits::propagate_on_container_move_assignment::value>());}
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__hash_table& __u, true_type)
+        _NOEXCEPT_(
+            is_nothrow_move_assignable<__pointer_allocator>::value &&
+            is_nothrow_move_assignable<__node_allocator>::value)
+    {
+        __bucket_list_.get_deleter().__alloc() =
+                _VSTD::move(__u.__bucket_list_.get_deleter().__alloc());
+        __node_alloc() = _VSTD::move(__u.__node_alloc());
+    }
+    _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 {}
+
+    void __deallocate(__node_pointer __np) _NOEXCEPT;
+    __node_pointer __detach() _NOEXCEPT;
+
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
+};
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+__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<hasher>::value &&
+        is_nothrow_default_constructible<key_equal>::value)
+    : __p2_(0),
+      __p3_(1.0f)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
+                                                       const key_equal& __eql)
+    : __bucket_list_(nullptr, __bucket_list_deleter()),
+      __p1_(),
+      __p2_(0, __hf),
+      __p3_(1.0f, __eql)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf,
+                                                       const key_equal& __eql,
+                                                       const allocator_type& __a)
+    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+      __p1_(__node_allocator(__a)),
+      __p2_(0, __hf),
+      __p3_(1.0f, __eql)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a)
+    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+      __p1_(__node_allocator(__a)),
+      __p2_(0),
+      __p3_(1.0f)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u)
+    : __bucket_list_(nullptr,
+          __bucket_list_deleter(allocator_traits<__pointer_allocator>::
+              select_on_container_copy_construction(
+                  __u.__bucket_list_.get_deleter().__alloc()), 0)),
+      __p1_(allocator_traits<__node_allocator>::
+          select_on_container_copy_construction(__u.__node_alloc())),
+      __p2_(0, __u.hash_function()),
+      __p3_(__u.__p3_)
+{
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u,
+                                                       const allocator_type& __a)
+    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+      __p1_(__node_allocator(__a)),
+      __p2_(0, __u.hash_function()),
+      __p3_(__u.__p3_)
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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<hasher>::value &&
+            is_nothrow_move_constructible<key_equal>::value)
+    : __bucket_list_(_VSTD::move(__u.__bucket_list_)),
+      __p1_(_VSTD::move(__u.__p1_)),
+      __p2_(_VSTD::move(__u.__p2_)),
+      __p3_(_VSTD::move(__u.__p3_))
+{
+    if (size() > 0)
+    {
+        __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+        __u.__p1_.first().__next_ = nullptr;
+        __u.size() = 0;
+    }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u,
+                                                       const allocator_type& __a)
+    : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)),
+      __p1_(__node_allocator(__a)),
+      __p2_(0, _VSTD::move(__u.hash_function())),
+      __p3_(_VSTD::move(__u.__p3_))
+{
+    if (__a == allocator_type(__u.__node_alloc()))
+    {
+        __bucket_list_.reset(__u.__bucket_list_.release());
+        __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
+        __u.__bucket_list_.get_deleter().size() = 0;
+        if (__u.size() > 0)
+        {
+            __p1_.first().__next_ = __u.__p1_.first().__next_;
+            __u.__p1_.first().__next_ = nullptr;
+            __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
+                static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+            size() = __u.size();
+            __u.size() = 0;
+        }
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table()
+{
+    __deallocate(__p1_.first().__next_);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__erase_c(this);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc(
+        const __hash_table& __u, true_type)
+{
+    if (__node_alloc() != __u.__node_alloc())
+    {
+        clear();
+        __bucket_list_.reset();
+        __bucket_list_.get_deleter().size() = 0;
+    }
+    __bucket_list_.get_deleter().__alloc() = __u.__bucket_list_.get_deleter().__alloc();
+    __node_alloc() = __u.__node_alloc();
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>&
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u)
+{
+    if (this != &__u)
+    {
+        __copy_assign_alloc(__u);
+        hash_function() = __u.hash_function();
+        key_eq() = __u.key_eq();
+        max_load_factor() = __u.max_load_factor();
+        __assign_multi(__u.begin(), __u.end());
+    }
+    return *this;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate(__node_pointer __np)
+    _NOEXCEPT
+{
+    __node_allocator& __na = __node_alloc();
+    while (__np != nullptr)
+    {
+        __node_pointer __next = __np->__next_;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __c_node* __c = __get_db()->__find_c_and_lock(this);
+        for (__i_node** __p = __c->end_; __p != __c->beg_; )
+        {
+            --__p;
+            iterator* __i = static_cast<iterator*>((*__p)->__i_);
+            if (__i->__node_ == __np)
+            {
+                (*__p)->__c_ = nullptr;
+                if (--__c->end_ != __p)
+                    memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+            }
+        }
+        __get_db()->unlock();
+#endif
+        __node_traits::destroy(__na, _VSTD::addressof(__np->__value_));
+        __node_traits::deallocate(__na, __np, 1);
+        __np = __next;
+    }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_pointer
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT
+{
+    size_type __bc = bucket_count();
+    for (size_type __i = 0; __i < __bc; ++__i)
+        __bucket_list_[__i] = nullptr;
+    size() = 0;
+    __node_pointer __cache = __p1_.first().__next_;
+    __p1_.first().__next_ = nullptr;
+    return __cache;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
+        __hash_table& __u, true_type)
+    _NOEXCEPT_(
+        is_nothrow_move_assignable<__node_allocator>::value &&
+        is_nothrow_move_assignable<hasher>::value &&
+        is_nothrow_move_assignable<key_equal>::value)
+{
+    clear();
+    __bucket_list_.reset(__u.__bucket_list_.release());
+    __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size();
+    __u.__bucket_list_.get_deleter().size() = 0;
+    __move_assign_alloc(__u);
+    size() = __u.size();
+    hash_function() = _VSTD::move(__u.hash_function());
+    max_load_factor() = __u.max_load_factor();
+    key_eq() = _VSTD::move(__u.key_eq());
+    __p1_.first().__next_ = __u.__p1_.first().__next_;
+    if (size() > 0)
+    {
+        __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+        __u.__p1_.first().__next_ = nullptr;
+        __u.size() = 0;
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->swap(this, &__u);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(
+        __hash_table& __u, false_type)
+{
+    if (__node_alloc() == __u.__node_alloc())
+        __move_assign(__u, true_type());
+    else
+    {
+        hash_function() = _VSTD::move(__u.hash_function());
+        key_eq() = _VSTD::move(__u.key_eq());
+        max_load_factor() = __u.max_load_factor();
+        if (bucket_count() != 0)
+        {
+            __node_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            try
+            {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                const_iterator __i = __u.begin();
+                while (__cache != nullptr && __u.size() != 0)
+                {
+                    __cache->__value_ = _VSTD::move(__u.remove(__i++)->__value_);
+                    __node_pointer __next = __cache->__next_;
+                    __node_insert_multi(__cache);
+                    __cache = __next;
+                }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            }
+            catch (...)
+            {
+                __deallocate(__cache);
+                throw;
+            }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __deallocate(__cache);
+        }
+        const_iterator __i = __u.begin();
+        while (__u.size() != 0)
+        {
+            __node_holder __h =
+                    __construct_node(_VSTD::move(__u.remove(__i++)->__value_));
+            __node_insert_multi(__h.get());
+            __h.release();
+        }
+    }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+__hash_table<_Tp, _Hash, _Equal, _Alloc>&
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
+    _NOEXCEPT_(
+        __node_traits::propagate_on_container_move_assignment::value &&
+        is_nothrow_move_assignable<__node_allocator>::value &&
+        is_nothrow_move_assignable<hasher>::value &&
+        is_nothrow_move_assignable<key_equal>::value)
+{
+    __move_assign(__u, integral_constant<bool,
+                  __node_traits::propagate_on_container_move_assignment::value>());
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _InputIterator>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first,
+                                                          _InputIterator __last)
+{
+    if (bucket_count() != 0)
+    {
+        __node_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __cache != nullptr && __first != __last; ++__first)
+            {
+                __cache->__value_ = *__first;
+                __node_pointer __next = __cache->__next_;
+                __node_insert_unique(__cache);
+                __cache = __next;
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            __deallocate(__cache);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __deallocate(__cache);
+    }
+    for (; __first != __last; ++__first)
+        __insert_unique(*__first);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _InputIterator>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first,
+                                                         _InputIterator __last)
+{
+    if (bucket_count() != 0)
+    {
+        __node_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __cache != nullptr && __first != __last; ++__first)
+            {
+                __cache->__value_ = *__first;
+                __node_pointer __next = __cache->__next_;
+                __node_insert_multi(__cache);
+                __cache = __next;
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            __deallocate(__cache);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __deallocate(__cache);
+    }
+    for (; __first != __last; ++__first)
+        __insert_multi(*__first);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(__p1_.first().__next_, this);
+#else
+    return iterator(__p1_.first().__next_);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(nullptr, this);
+#else
+    return iterator(nullptr);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return const_iterator(__p1_.first().__next_, this);
+#else
+    return const_iterator(__p1_.first().__next_);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return const_iterator(nullptr, this);
+#else
+    return const_iterator(nullptr);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT
+{
+    if (size() > 0)
+    {
+        __deallocate(__p1_.first().__next_);
+        __p1_.first().__next_ = nullptr;
+        size_type __bc = bucket_count();
+        for (size_type __i = 0; __i < __bc; ++__i)
+            __bucket_list_[__i] = nullptr;
+        size() = 0;
+    }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __nd)
+{
+    __nd->__hash_ = hash_function()(__nd->__value_);
+    size_type __bc = bucket_count();
+    bool __inserted = false;
+    __node_pointer __ndptr;
+    size_t __chash;
+    if (__bc != 0)
+    {
+        __chash = __constrain_hash(__nd->__hash_, __bc);
+        __ndptr = __bucket_list_[__chash];
+        if (__ndptr != nullptr)
+        {
+            for (__ndptr = __ndptr->__next_; __ndptr != nullptr &&
+                                             __constrain_hash(__ndptr->__hash_, __bc) == __chash;
+                                                     __ndptr = __ndptr->__next_)
+            {
+                if (key_eq()(__ndptr->__value_, __nd->__value_))
+                    goto __done;
+            }
+        }
+    }
+    {
+        if (size()+1 > __bc * max_load_factor() || __bc == 0)
+        {
+            rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+                           size_type(ceil(float(size() + 1) / max_load_factor()))));
+            __bc = bucket_count();
+            __chash = __constrain_hash(__nd->__hash_, __bc);
+        }
+        // insert_after __bucket_list_[__chash], or __first_node if bucket is null
+        __node_pointer __pn = __bucket_list_[__chash];
+        if (__pn == nullptr)
+        {
+            __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+            __nd->__next_ = __pn->__next_;
+            __pn->__next_ = __nd;
+            // fix up __bucket_list_
+            __bucket_list_[__chash] = __pn;
+            if (__nd->__next_ != nullptr)
+                __bucket_list_[__constrain_hash(__nd->__next_->__hash_, __bc)] = __nd;
+        }
+        else
+        {
+            __nd->__next_ = __pn->__next_;
+            __pn->__next_ = __nd;
+        }
+        __ndptr = __nd;
+        // increment size
+        ++size();
+        __inserted = true;
+    }
+__done:
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return pair<iterator, bool>(iterator(__ndptr, this), __inserted);
+#else
+    return pair<iterator, bool>(iterator(__ndptr), __inserted);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __cp)
+{
+    __cp->__hash_ = hash_function()(__cp->__value_);
+    size_type __bc = bucket_count();
+    if (size()+1 > __bc * max_load_factor() || __bc == 0)
+    {
+        rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+                       size_type(ceil(float(size() + 1) / max_load_factor()))));
+        __bc = bucket_count();
+    }
+    size_t __chash = __constrain_hash(__cp->__hash_, __bc);
+    __node_pointer __pn = __bucket_list_[__chash];
+    if (__pn == nullptr)
+    {
+        __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+        __cp->__next_ = __pn->__next_;
+        __pn->__next_ = __cp;
+        // fix up __bucket_list_
+        __bucket_list_[__chash] = __pn;
+        if (__cp->__next_ != nullptr)
+            __bucket_list_[__constrain_hash(__cp->__next_->__hash_, __bc)] = __cp;
+    }
+    else
+    {
+        for (bool __found = false; __pn->__next_ != nullptr &&
+                                   __constrain_hash(__pn->__next_->__hash_, __bc) == __chash;
+                                                           __pn = __pn->__next_)
+        {
+            //      __found    key_eq()     action
+            //      false       false       loop
+            //      true        true        loop
+            //      false       true        set __found to true
+            //      true        false       break
+            if (__found != (__pn->__next_->__hash_ == __cp->__hash_ &&
+                            key_eq()(__pn->__next_->__value_, __cp->__value_)))
+            {
+                if (!__found)
+                    __found = true;
+                else
+                    break;
+            }
+        }
+        __cp->__next_ = __pn->__next_;
+        __pn->__next_ = __cp;
+        if (__cp->__next_ != nullptr)
+        {
+            size_t __nhash = __constrain_hash(__cp->__next_->__hash_, __bc);
+            if (__nhash != __chash)
+                __bucket_list_[__nhash] = __cp;
+        }
+    }
+    ++size();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(__cp, this);
+#else
+    return iterator(__cp);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
+        const_iterator __p, __node_pointer __cp)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
+        " referring to this unordered container");
+#endif
+    if (__p != end() && key_eq()(*__p, __cp->__value_))
+    {
+        __node_pointer __np = __p.__node_;
+        __cp->__hash_ = __np->__hash_;
+        size_type __bc = bucket_count();
+        if (size()+1 > __bc * max_load_factor() || __bc == 0)
+        {
+            rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+                           size_type(ceil(float(size() + 1) / max_load_factor()))));
+            __bc = bucket_count();
+        }
+        size_t __chash = __constrain_hash(__cp->__hash_, __bc);
+        __node_pointer __pp = __bucket_list_[__chash];
+        while (__pp->__next_ != __np)
+            __pp = __pp->__next_;
+        __cp->__next_ = __np;
+        __pp->__next_ = __cp;
+        ++size();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return iterator(__cp, this);
+#else
+        return iterator(__cp);
+#endif
+    }
+    return __node_insert_multi(__cp);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
+{
+    size_t __hash = hash_function()(__x);
+    size_type __bc = bucket_count();
+    bool __inserted = false;
+    __node_pointer __nd;
+    size_t __chash;
+    if (__bc != 0)
+    {
+        __chash = __constrain_hash(__hash, __bc);
+        __nd = __bucket_list_[__chash];
+        if (__nd != nullptr)
+        {
+            for (__nd = __nd->__next_; __nd != nullptr &&
+                                       __constrain_hash(__nd->__hash_, __bc) == __chash;
+                                                           __nd = __nd->__next_)
+            {
+                if (key_eq()(__nd->__value_, __x))
+                    goto __done;
+            }
+        }
+    }
+    {
+        __node_holder __h = __construct_node(__x, __hash);
+        if (size()+1 > __bc * max_load_factor() || __bc == 0)
+        {
+            rehash(_VSTD::max<size_type>(2 * __bc + !__is_power2(__bc),
+                           size_type(ceil(float(size() + 1) / max_load_factor()))));
+            __bc = bucket_count();
+            __chash = __constrain_hash(__hash, __bc);
+        }
+        // insert_after __bucket_list_[__chash], or __first_node if bucket is null
+        __node_pointer __pn = __bucket_list_[__chash];
+        if (__pn == nullptr)
+        {
+            __pn = static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+            __h->__next_ = __pn->__next_;
+            __pn->__next_ = __h.get();
+            // fix up __bucket_list_
+            __bucket_list_[__chash] = __pn;
+            if (__h->__next_ != nullptr)
+                __bucket_list_[__constrain_hash(__h->__next_->__hash_, __bc)] = __h.get();
+        }
+        else
+        {
+            __h->__next_ = __pn->__next_;
+            __pn->__next_ = __h.get();
+        }
+        __nd = __h.release();
+        // increment size
+        ++size();
+        __inserted = true;
+    }
+__done:
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return pair<iterator, bool>(iterator(__nd, this), __inserted);
+#else
+    return pair<iterator, bool>(iterator(__nd), __inserted);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+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)
+{
+    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+    pair<iterator, bool> __r = __node_insert_unique(__h.get());
+    if (__r.second)
+        __h.release();
+    return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class... _Args>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_multi(_Args&&... __args)
+{
+    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+    iterator __r = __node_insert_multi(__h.get());
+    __h.release();
+    return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class... _Args>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
+        const_iterator __p, _Args&&... __args)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "unordered container::emplace_hint(const_iterator, args...) called with an iterator not"
+        " referring to this unordered container");
+#endif
+    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+    iterator __r = __node_insert_multi(__p, __h.get());
+    __h.release();
+    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
+
+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)
+{
+    __node_holder __h = __construct_node(__x);
+    iterator __r = __node_insert_multi(__h.get());
+    __h.release();
+    return __r;
+}
+
+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)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "unordered container::insert(const_iterator, lvalue) called with an iterator not"
+        " referring to this unordered container");
+#endif
+    __node_holder __h = __construct_node(__x);
+    iterator __r = __node_insert_multi(__p, __h.get());
+    __h.release();
+    return __r;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
+{
+    if (__n == 1)
+        __n = 2;
+    else if (__n & (__n - 1))
+        __n = __next_prime(__n);
+    size_type __bc = bucket_count();
+    if (__n > __bc)
+        __rehash(__n);
+    else if (__n < __bc)
+    {
+        __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())))
+              );
+        if (__n < __bc)
+            __rehash(__n);
+    }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__invalidate_all(this);
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+    __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
+    __bucket_list_.reset(__nbc > 0 ?
+                      __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr);
+    __bucket_list_.get_deleter().size() = __nbc;
+    if (__nbc > 0)
+    {
+        for (size_type __i = 0; __i < __nbc; ++__i)
+            __bucket_list_[__i] = nullptr;
+        __node_pointer __pp(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first())));
+        __node_pointer __cp = __pp->__next_;
+        if (__cp != nullptr)
+        {
+            size_type __chash = __constrain_hash(__cp->__hash_, __nbc);
+            __bucket_list_[__chash] = __pp;
+            size_type __phash = __chash;
+            for (__pp = __cp, __cp = __cp->__next_; __cp != nullptr;
+                                                           __cp = __pp->__next_)
+            {
+                __chash = __constrain_hash(__cp->__hash_, __nbc);
+                if (__chash == __phash)
+                    __pp = __cp;
+                else
+                {
+                    if (__bucket_list_[__chash] == nullptr)
+                    {
+                        __bucket_list_[__chash] = __pp;
+                        __pp = __cp;
+                        __phash = __chash;
+                    }
+                    else
+                    {
+                        __node_pointer __np = __cp;
+                        for (; __np->__next_ != nullptr &&
+                               key_eq()(__cp->__value_, __np->__next_->__value_);
+                                                           __np = __np->__next_)
+                            ;
+                        __pp->__next_ = __np->__next_;
+                        __np->__next_ = __bucket_list_[__chash]->__next_;
+                        __bucket_list_[__chash]->__next_ = __cp;
+
+                    }
+                }
+            }
+        }
+    }
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k)
+{
+    size_t __hash = hash_function()(__k);
+    size_type __bc = bucket_count();
+    if (__bc != 0)
+    {
+        size_t __chash = __constrain_hash(__hash, __bc);
+        __node_pointer __nd = __bucket_list_[__chash];
+        if (__nd != nullptr)
+        {
+            for (__nd = __nd->__next_; __nd != nullptr &&
+                                       __constrain_hash(__nd->__hash_, __bc) == __chash;
+                                                           __nd = __nd->__next_)
+            {
+                if (key_eq()(__nd->__value_, __k))
+#if _LIBCPP_DEBUG_LEVEL >= 2
+                    return iterator(__nd, this);
+#else
+                    return iterator(__nd);
+#endif
+            }
+        }
+    }
+    return end();
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const
+{
+    size_t __hash = hash_function()(__k);
+    size_type __bc = bucket_count();
+    if (__bc != 0)
+    {
+        size_t __chash = __constrain_hash(__hash, __bc);
+        __node_const_pointer __nd = __bucket_list_[__chash];
+        if (__nd != nullptr)
+        {
+            for (__nd = __nd->__next_; __nd != nullptr &&
+                                           __constrain_hash(__nd->__hash_, __bc) == __chash;
+                                                           __nd = __nd->__next_)
+            {
+                if (key_eq()(__nd->__value_, __k))
+#if _LIBCPP_DEBUG_LEVEL >= 2
+                    return const_iterator(__nd, this);
+#else
+                    return const_iterator(__nd);
+#endif
+            }
+        }
+
+    }
+    return end();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+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)
+{
+    __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)...);
+    __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>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v,
+                                                           size_t __hash)
+{
+    __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));
+    __h.get_deleter().__value_constructed = true;
+    __h->__hash_ = __hash;
+    __h->__next_ = nullptr;
+    return __h;
+}
+
+#else  // _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)
+{
+    __node_allocator& __na = __node_alloc();
+    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
+    __node_traits::construct(__na, _VSTD::addressof(__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
+}
+
+#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)
+{
+    __node_allocator& __na = __node_alloc();
+    __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
+    __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v);
+    __h.get_deleter().__value_constructed = true;
+    __h->__hash_ = __hash;
+    __h->__next_ = nullptr;
+    return _VSTD::move(__h);  // explicitly moved for C++03
+}
+
+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)
+{
+    __node_pointer __np = __p.__node_;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "unordered container erase(iterator) called with an iterator not"
+        " referring to this container");
+    _LIBCPP_ASSERT(__p != end(),
+        "unordered container erase(iterator) called with a non-dereferenceable iterator");
+    iterator __r(__np, this);
+#else
+    iterator __r(__np);
+#endif
+    ++__r;
+    remove(__p);
+    return __r;
+}
+
+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 __first,
+                                                const_iterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
+        "unodered container::erase(iterator, iterator) called with an iterator not"
+        " referring to this unodered container");
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
+        "unodered container::erase(iterator, iterator) called with an iterator not"
+        " referring to this unodered container");
+#endif
+    for (const_iterator __p = __first; __first != __last; __p = __first)
+    {
+        ++__first;
+        erase(__p);
+    }
+    __node_pointer __np = __last.__node_;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator (__np, this);
+#else
+    return iterator (__np);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_unique(const _Key& __k)
+{
+    iterator __i = find(__k);
+    if (__i == end())
+        return 0;
+    erase(__i);
+    return 1;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_multi(const _Key& __k)
+{
+    size_type __r = 0;
+    iterator __i = find(__k);
+    if (__i != end())
+    {
+        iterator __e = end();
+        do
+        {
+            erase(__i++);
+            ++__r;
+        } while (__i != __e && key_eq()(*__i, __k));
+    }
+    return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT
+{
+    // current node
+    __node_pointer __cn = __p.__node_;
+    size_type __bc = bucket_count();
+    size_t __chash = __constrain_hash(__cn->__hash_, __bc);
+    // find previous node
+    __node_pointer __pn = __bucket_list_[__chash];
+    for (; __pn->__next_ != __cn; __pn = __pn->__next_)
+        ;
+    // Fix up __bucket_list_
+        // if __pn is not in same bucket (before begin is not in same bucket) &&
+        //    if __cn->__next_ is not in same bucket (nullptr is not in same bucket)
+    if (__pn == static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()))
+                            || __constrain_hash(__pn->__hash_, __bc) != __chash)
+    {
+        if (__cn->__next_ == nullptr || __constrain_hash(__cn->__next_->__hash_, __bc) != __chash)
+            __bucket_list_[__chash] = nullptr;
+    }
+        // if __cn->__next_ is not in same bucket (nullptr is in same bucket)
+    if (__cn->__next_ != nullptr)
+    {
+        size_t __nhash = __constrain_hash(__cn->__next_->__hash_, __bc);
+        if (__nhash != __chash)
+            __bucket_list_[__nhash] = __pn;
+    }
+    // remove __cn
+    __pn->__next_ = __cn->__next_;
+    __cn->__next_ = nullptr;
+    --size();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __c_node* __c = __get_db()->__find_c_and_lock(this);
+    for (__i_node** __p = __c->end_; __p != __c->beg_; )
+    {
+        --__p;
+        iterator* __i = static_cast<iterator*>((*__p)->__i_);
+        if (__i->__node_ == __cn)
+        {
+            (*__p)->__c_ = nullptr;
+            if (--__c->end_ != __p)
+                memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+        }
+    }
+    __get_db()->unlock();
+#endif
+    return __node_holder(__cn, _Dp(__node_alloc(), true));
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const
+{
+    return static_cast<size_type>(find(__k) != end());
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_multi(const _Key& __k) const
+{
+    size_type __r = 0;
+    const_iterator __i = find(__k);
+    if (__i != end())
+    {
+        const_iterator __e = end();
+        do
+        {
+            ++__i;
+            ++__r;
+        } while (__i != __e && key_eq()(*__i, __k));
+    }
+    return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator,
+     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique(
+        const _Key& __k)
+{
+    iterator __i = find(__k);
+    iterator __j = __i;
+    if (__i != end())
+        ++__j;
+    return pair<iterator, iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator,
+     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique(
+        const _Key& __k) const
+{
+    const_iterator __i = find(__k);
+    const_iterator __j = __i;
+    if (__i != end())
+        ++__j;
+    return pair<const_iterator, const_iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator,
+     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
+        const _Key& __k)
+{
+    iterator __i = find(__k);
+    iterator __j = __i;
+    if (__i != end())
+    {
+        iterator __e = end();
+        do
+        {
+            ++__j;
+        } while (__j != __e && key_eq()(*__j, __k));
+    }
+    return pair<iterator, iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+template <class _Key>
+pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator,
+     typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator>
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
+        const _Key& __k) const
+{
+    const_iterator __i = find(__k);
+    const_iterator __j = __i;
+    if (__i != end())
+    {
+        const_iterator __e = end();
+        do
+        {
+            ++__j;
+        } while (__j != __e && key_eq()(*__j, __k));
+    }
+    return pair<const_iterator, const_iterator>(__i, __j);
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+void
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
+    _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)
+{
+    {
+    __node_pointer_pointer __npp = __bucket_list_.release();
+    __bucket_list_.reset(__u.__bucket_list_.release());
+    __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(),
+             __u.__bucket_list_.get_deleter().__alloc());
+    __swap_alloc(__node_alloc(), __u.__node_alloc());
+    _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
+    __p2_.swap(__u.__p2_);
+    __p3_.swap(__u.__p3_);
+    if (size() > 0)
+        __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash_, bucket_count())] =
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__p1_.first()));
+    if (__u.size() > 0)
+        __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash_, __u.bucket_count())] =
+            static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::pointer_to(__u.__p1_.first()));
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->swap(this, &__u);
+#endif
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const
+{
+    _LIBCPP_ASSERT(__n < bucket_count(),
+        "unordered container::bucket_size(n) called with n >= bucket_count()");
+    __node_const_pointer __np = __bucket_list_[__n];
+    size_type __bc = bucket_count();
+    size_type __r = 0;
+    if (__np != nullptr)
+    {
+        for (__np = __np->__next_; __np != nullptr &&
+                                   __constrain_hash(__np->__hash_, __bc) == __n;
+                                                    __np = __np->__next_, ++__r)
+            ;
+    }
+    return __r;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x,
+     __hash_table<_Tp, _Hash, _Equal, _Alloc>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__dereferenceable(const const_iterator* __i) const
+{
+    return __i->__node_ != nullptr;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__decrementable(const const_iterator*) const
+{
+    return false;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const
+{
+    return false;
+}
+
+template <class _Tp, class _Hash, class _Equal, class _Alloc>
+bool
+__hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
+{
+    return false;
+}
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP__HASH_TABLE
diff --git a/final/include/__locale b/final/include/__locale
new file mode 100644
index 0000000..3daa1f1
--- /dev/null
+++ b/final/include/__locale
@@ -0,0 +1,1454 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___LOCALE
+#define _LIBCPP___LOCALE
+
+#include <__config>
+#include <string>
+#include <memory>
+#include <utility>
+#include <mutex>
+#include <cstdint>
+#include <cctype>
+#include <locale.h>
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+# include <support/win32/locale_win32.h>
+#elif defined(_AIX)
+# include <support/ibm/xlocale.h>
+#elif defined(__ANDROID__)
+// Android gained the locale aware functions in L (API level 21)
+# include <android/api-level.h>
+# if __ANDROID_API__ <= 20
+#  include <support/android/locale_bionic.h>
+# endif
+#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
+    || defined(__sun__)   || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
+# include <xlocale.h>
+#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS locale;
+
+template <class _Facet>
+_LIBCPP_INLINE_VISIBILITY
+bool
+has_facet(const locale&) _NOEXCEPT;
+
+template <class _Facet>
+_LIBCPP_INLINE_VISIBILITY
+const _Facet&
+use_facet(const locale&);
+
+class _LIBCPP_TYPE_VIS locale
+{
+public:
+    // types:
+    class _LIBCPP_TYPE_VIS facet;
+    class _LIBCPP_TYPE_VIS id;
+
+    typedef int category;
+    static const category // values assigned here are for exposition only
+        none     = 0,
+        collate  = LC_COLLATE_MASK,
+        ctype    = LC_CTYPE_MASK,
+        monetary = LC_MONETARY_MASK,
+        numeric  = LC_NUMERIC_MASK,
+        time     = LC_TIME_MASK,
+        messages = LC_MESSAGES_MASK,
+        all = collate | ctype | monetary | numeric | time | messages;
+
+    // construct/copy/destroy:
+    locale()  _NOEXCEPT;
+    locale(const locale&)  _NOEXCEPT;
+    explicit locale(const char*);
+    explicit locale(const string&);
+    locale(const locale&, const char*, category);
+    locale(const locale&, const string&, category);
+    template <class _Facet>
+        _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*);
+    locale(const locale&, const locale&, category);
+
+    ~locale();
+
+    const locale& operator=(const locale&)  _NOEXCEPT;
+
+    template <class _Facet> locale combine(const locale&) const;
+
+    // locale operations:
+    string name() const;
+    bool operator==(const locale&) const;
+    bool operator!=(const locale& __y) const {return !(*this == __y);}
+    template <class _CharT, class _Traits, class _Allocator>
+      bool operator()(const basic_string<_CharT, _Traits, _Allocator>&,
+                      const basic_string<_CharT, _Traits, _Allocator>&) const;
+
+    // global locale objects:
+    static locale global(const locale&);
+    static const locale& classic();
+
+private:
+    class __imp;
+    __imp* __locale_;
+
+    void __install_ctor(const locale&, facet*, long);
+    static locale& __global();
+    bool has_facet(id&) const;
+    const facet* use_facet(id&) const;
+
+    template <class _Facet> friend bool has_facet(const locale&)  _NOEXCEPT;
+    template <class _Facet> friend const _Facet& use_facet(const locale&);
+};
+
+class _LIBCPP_TYPE_VIS locale::facet
+    : public __shared_count
+{
+protected:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit facet(size_t __refs = 0)
+        : __shared_count(static_cast<long>(__refs)-1) {}
+
+    virtual ~facet();
+
+//    facet(const facet&) = delete;     // effectively done in __shared_count
+//    void operator=(const facet&) = delete;
+private:
+    virtual void __on_zero_shared() _NOEXCEPT;
+};
+
+class _LIBCPP_TYPE_VIS locale::id
+{
+    once_flag      __flag_;
+    int32_t        __id_;
+
+    static int32_t __next_id;
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {}
+private:
+    void __init();
+    void operator=(const id&); // = delete;
+    id(const id&); // = delete;
+public:  // only needed for tests
+    long __get();
+
+    friend class locale;
+    friend class locale::__imp;
+};
+
+template <class _Facet>
+inline _LIBCPP_INLINE_VISIBILITY
+locale::locale(const locale& __other, _Facet* __f)
+{
+    __install_ctor(__other, __f, __f ? __f->id.__get() : 0);
+}
+
+template <class _Facet>
+locale
+locale::combine(const locale& __other) const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (!_VSTD::has_facet<_Facet>(__other))
+        throw runtime_error("locale::combine: locale missing facet");
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
+}
+
+template <class _Facet>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+has_facet(const locale& __l)  _NOEXCEPT
+{
+    return __l.has_facet(_Facet::id);
+}
+
+template <class _Facet>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Facet&
+use_facet(const locale& __l)
+{
+    return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));
+}
+
+// template <class _CharT> class collate;
+
+template <class _CharT>
+class _LIBCPP_TYPE_VIS_ONLY collate
+    : public locale::facet
+{
+public:
+    typedef _CharT char_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit collate(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    int compare(const char_type* __lo1, const char_type* __hi1,
+                const char_type* __lo2, const char_type* __hi2) const
+    {
+        return do_compare(__lo1, __hi1, __lo2, __hi2);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    string_type transform(const char_type* __lo, const char_type* __hi) const
+    {
+        return do_transform(__lo, __hi);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    long hash(const char_type* __lo, const char_type* __hi) const
+    {
+        return do_hash(__lo, __hi);
+    }
+
+    static locale::id id;
+
+protected:
+    ~collate();
+    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
+                           const char_type* __lo2, const char_type* __hi2) const;
+    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const
+        {return string_type(__lo, __hi);}
+    virtual long do_hash(const char_type* __lo, const char_type* __hi) const;
+};
+
+template <class _CharT> locale::id collate<_CharT>::id;
+
+template <class _CharT>
+collate<_CharT>::~collate()
+{
+}
+
+template <class _CharT>
+int
+collate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1,
+                            const char_type* __lo2, const char_type* __hi2) const
+{
+    for (; __lo2 != __hi2; ++__lo1, ++__lo2)
+    {
+        if (__lo1 == __hi1 || *__lo1 < *__lo2)
+            return -1;
+        if (*__lo2 < *__lo1)
+            return 1;
+    }
+    return __lo1 != __hi1;
+}
+
+template <class _CharT>
+long
+collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
+{
+    size_t __h = 0;
+    const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8;
+    const size_t __mask = size_t(0xF) << (__sr + 4);
+    for(const char_type* __p = __lo; __p != __hi; ++__p)
+    {
+        __h = (__h << 4) + static_cast<size_t>(*__p);
+        size_t __g = __h & __mask;
+        __h ^= __g | (__g >> __sr);
+    }
+    return static_cast<long>(__h);
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<wchar_t>)
+
+// template <class CharT> class collate_byname;
+
+template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY collate_byname;
+
+template <>
+class _LIBCPP_TYPE_VIS collate_byname<char>
+    : public collate<char>
+{
+    locale_t __l;
+public:
+    typedef char char_type;
+    typedef basic_string<char_type> string_type;
+
+    explicit collate_byname(const char* __n, size_t __refs = 0);
+    explicit collate_byname(const string& __n, size_t __refs = 0);
+
+protected:
+    ~collate_byname();
+    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
+                           const char_type* __lo2, const char_type* __hi2) const;
+    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
+};
+
+template <>
+class _LIBCPP_TYPE_VIS collate_byname<wchar_t>
+    : public collate<wchar_t>
+{
+    locale_t __l;
+public:
+    typedef wchar_t char_type;
+    typedef basic_string<char_type> string_type;
+
+    explicit collate_byname(const char* __n, size_t __refs = 0);
+    explicit collate_byname(const string& __n, size_t __refs = 0);
+
+protected:
+    ~collate_byname();
+
+    virtual int do_compare(const char_type* __lo1, const char_type* __hi1,
+                           const char_type* __lo2, const char_type* __hi2) const;
+    virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const;
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+bool
+locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
+                   const basic_string<_CharT, _Traits, _Allocator>& __y) const
+{
+    return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare(
+                                       __x.data(), __x.data() + __x.size(),
+                                       __y.data(), __y.data() + __y.size()) < 0;
+}
+
+// template <class charT> class ctype
+
+class _LIBCPP_TYPE_VIS ctype_base
+{
+public:
+#ifdef __GLIBC__
+    typedef unsigned short mask;
+    static const mask space  = _ISspace;
+    static const mask print  = _ISprint;
+    static const mask cntrl  = _IScntrl;
+    static const mask upper  = _ISupper;
+    static const mask lower  = _ISlower;
+    static const mask alpha  = _ISalpha;
+    static const mask digit  = _ISdigit;
+    static const mask punct  = _ISpunct;
+    static const mask xdigit = _ISxdigit;
+    static const mask blank  = _ISblank;
+#elif defined(_WIN32)
+    typedef unsigned short mask;
+    static const mask space  = _SPACE;
+    static const mask print  = _BLANK|_PUNCT|_ALPHA|_DIGIT;
+    static const mask cntrl  = _CONTROL;
+    static const mask upper  = _UPPER;
+    static const mask lower  = _LOWER;
+    static const mask alpha  = _ALPHA;
+    static const mask digit  = _DIGIT;
+    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__
+    typedef __uint32_t mask;
+#elif defined(__FreeBSD__)
+    typedef unsigned long mask;
+#elif defined(__EMSCRIPTEN__) ||  defined(__NetBSD__)
+    typedef unsigned short mask;
+#elif defined(__ANDROID__)
+    typedef char mask;
+#endif
+    static const mask space  = _CTYPE_S;
+    static const mask print  = _CTYPE_R;
+    static const mask cntrl  = _CTYPE_C;
+    static const mask upper  = _CTYPE_U;
+    static const mask lower  = _CTYPE_L;
+    static const mask alpha  = _CTYPE_A;
+    static const mask digit  = _CTYPE_D;
+    static const mask punct  = _CTYPE_P;
+    static const mask xdigit = _CTYPE_X;
+# if defined(__NetBSD__)
+    static const mask blank  = _CTYPE_BL;
+# else
+    static const mask blank  = _CTYPE_B;
+# endif
+#elif defined(__sun__) || defined(_AIX)
+    typedef unsigned int mask;
+    static const mask space  = _ISSPACE;
+    static const mask print  = _ISPRINT;
+    static const mask cntrl  = _ISCNTRL;
+    static const mask upper  = _ISUPPER;
+    static const mask lower  = _ISLOWER;
+    static const mask alpha  = _ISALPHA;
+    static const mask digit  = _ISDIGIT;
+    static const mask punct  = _ISPUNCT;
+    static const mask xdigit = _ISXDIGIT;
+    static const mask blank  = _ISBLANK;
+#else  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__ || __EMSCRIPTEN__ || __sun__
+    typedef unsigned long mask;
+    static const mask space  = 1<<0;
+    static const mask print  = 1<<1;
+    static const mask cntrl  = 1<<2;
+    static const mask upper  = 1<<3;
+    static const mask lower  = 1<<4;
+    static const mask alpha  = 1<<5;
+    static const mask digit  = 1<<6;
+    static const mask punct  = 1<<7;
+    static const mask xdigit = 1<<8;
+    static const mask blank  = 1<<9;
+#endif  // __GLIBC__ || _WIN32 || __APPLE__ || __FreeBSD__
+    static const mask alnum  = alpha | digit;
+    static const mask graph  = alnum | punct;
+
+    _LIBCPP_ALWAYS_INLINE ctype_base() {}
+};
+
+template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype;
+
+template <>
+class _LIBCPP_TYPE_VIS ctype<wchar_t>
+    : public locale::facet,
+      public ctype_base
+{
+public:
+    typedef wchar_t char_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit ctype(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    bool is(mask __m, char_type __c) const
+    {
+        return do_is(__m, __c);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
+    {
+        return do_is(__low, __high, __vec);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const
+    {
+        return do_scan_is(__m, __low, __high);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
+    {
+        return do_scan_not(__m, __low, __high);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char_type toupper(char_type __c) const
+    {
+        return do_toupper(__c);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* toupper(char_type* __low, const char_type* __high) const
+    {
+        return do_toupper(__low, __high);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char_type tolower(char_type __c) const
+    {
+        return do_tolower(__c);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* tolower(char_type* __low, const char_type* __high) const
+    {
+        return do_tolower(__low, __high);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char_type widen(char __c) const
+    {
+        return do_widen(__c);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char* widen(const char* __low, const char* __high, char_type* __to) const
+    {
+        return do_widen(__low, __high, __to);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char narrow(char_type __c, char __dfault) const
+    {
+        return do_narrow(__c, __dfault);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
+    {
+        return do_narrow(__low, __high, __dfault, __to);
+    }
+
+    static locale::id id;
+
+protected:
+    ~ctype();
+    virtual bool do_is(mask __m, char_type __c) const;
+    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
+    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
+    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
+    virtual char_type do_toupper(char_type) const;
+    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+    virtual char_type do_tolower(char_type) const;
+    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+    virtual char_type do_widen(char) const;
+    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
+    virtual char do_narrow(char_type, char __dfault) const;
+    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
+};
+
+template <>
+class _LIBCPP_TYPE_VIS ctype<char>
+    : public locale::facet, public ctype_base
+{
+    const mask* __tab_;
+    bool        __del_;
+public:
+    typedef char char_type;
+
+    explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0);
+
+    _LIBCPP_ALWAYS_INLINE
+    bool is(mask __m, char_type __c) const
+    {
+        return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false;
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const
+    {
+        for (; __low != __high; ++__low, ++__vec)
+            *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0;
+        return __low;
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const
+    {
+        for (; __low != __high; ++__low)
+            if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
+                break;
+        return __low;
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const
+    {
+        for (; __low != __high; ++__low)
+            if (!(isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)))
+                break;
+        return __low;
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char_type toupper(char_type __c) const
+    {
+        return do_toupper(__c);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* toupper(char_type* __low, const char_type* __high) const
+    {
+        return do_toupper(__low, __high);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char_type tolower(char_type __c) const
+    {
+        return do_tolower(__c);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char_type* tolower(char_type* __low, const char_type* __high) const
+    {
+        return do_tolower(__low, __high);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char_type widen(char __c) const
+    {
+        return do_widen(__c);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char* widen(const char* __low, const char* __high, char_type* __to) const
+    {
+        return do_widen(__low, __high, __to);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    char narrow(char_type __c, char __dfault) const
+    {
+        return do_narrow(__c, __dfault);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const
+    {
+        return do_narrow(__low, __high, __dfault, __to);
+    }
+
+    static locale::id id;
+
+#ifdef _CACHED_RUNES
+    static const size_t table_size = _CACHED_RUNES;
+#else
+    static const size_t table_size = 256;  // FIXME: Don't hardcode this.
+#endif
+    _LIBCPP_ALWAYS_INLINE const mask* table() const  _NOEXCEPT {return __tab_;}
+    static const mask* classic_table()  _NOEXCEPT;
+#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+    static const int* __classic_upper_table() _NOEXCEPT;
+    static const int* __classic_lower_table() _NOEXCEPT;
+#endif
+#if defined(__NetBSD__)
+    static const short* __classic_upper_table() _NOEXCEPT;
+    static const short* __classic_lower_table() _NOEXCEPT;
+#endif
+
+protected:
+    ~ctype();
+    virtual char_type do_toupper(char_type __c) const;
+    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+    virtual char_type do_tolower(char_type __c) const;
+    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+    virtual char_type do_widen(char __c) const;
+    virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const;
+    virtual char do_narrow(char_type __c, char __dfault) const;
+    virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const;
+};
+
+// template <class CharT> class ctype_byname;
+
+template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype_byname;
+
+template <>
+class _LIBCPP_TYPE_VIS ctype_byname<char>
+    : public ctype<char>
+{
+    locale_t __l;
+
+public:
+    explicit ctype_byname(const char*, size_t = 0);
+    explicit ctype_byname(const string&, size_t = 0);
+
+protected:
+    ~ctype_byname();
+    virtual char_type do_toupper(char_type) const;
+    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+    virtual char_type do_tolower(char_type) const;
+    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+};
+
+template <>
+class _LIBCPP_TYPE_VIS ctype_byname<wchar_t>
+    : public ctype<wchar_t>
+{
+    locale_t __l;
+
+public:
+    explicit ctype_byname(const char*, size_t = 0);
+    explicit ctype_byname(const string&, size_t = 0);
+
+protected:
+    ~ctype_byname();
+    virtual bool do_is(mask __m, char_type __c) const;
+    virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const;
+    virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const;
+    virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const;
+    virtual char_type do_toupper(char_type) const;
+    virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const;
+    virtual char_type do_tolower(char_type) const;
+    virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const;
+    virtual char_type do_widen(char) const;
+    virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const;
+    virtual char do_narrow(char_type, char __dfault) const;
+    virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
+};
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isspace(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isprint(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+iscntrl(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isupper(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+islower(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isalpha(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isdigit(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ispunct(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isxdigit(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isalnum(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+isgraph(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+toupper(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).toupper(__c);
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+tolower(_CharT __c, const locale& __loc)
+{
+    return use_facet<ctype<_CharT> >(__loc).tolower(__c);
+}
+
+// codecvt_base
+
+class _LIBCPP_TYPE_VIS codecvt_base
+{
+public:
+    _LIBCPP_ALWAYS_INLINE codecvt_base() {}
+    enum result {ok, partial, error, noconv};
+};
+
+// template <class internT, class externT, class stateT> class codecvt;
+
+template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TYPE_VIS_ONLY codecvt;
+
+// template <> class codecvt<char, char, mbstate_t>
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char, char, mbstate_t>
+    : public locale::facet,
+      public codecvt_base
+{
+public:
+    typedef char      intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    result out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_unshift(__st, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+    {
+        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int encoding() const  _NOEXCEPT
+    {
+        return do_encoding();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    bool always_noconv() const  _NOEXCEPT
+    {
+        return do_always_noconv();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+    {
+        return do_length(__st, __frm, __end, __mx);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int max_length() const  _NOEXCEPT
+    {
+        return do_max_length();
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt(const char*, size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    ~codecvt();
+
+    virtual result do_out(state_type& __st,
+                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result do_in(state_type& __st,
+                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result do_unshift(state_type& __st,
+                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const  _NOEXCEPT;
+    virtual bool do_always_noconv() const  _NOEXCEPT;
+    virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+    virtual int do_max_length() const  _NOEXCEPT;
+};
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t>
+    : public locale::facet,
+      public codecvt_base
+{
+    locale_t __l;
+public:
+    typedef wchar_t   intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    explicit codecvt(size_t __refs = 0);
+
+    _LIBCPP_ALWAYS_INLINE
+    result out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_unshift(__st, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+    {
+        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int encoding() const  _NOEXCEPT
+    {
+        return do_encoding();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    bool always_noconv() const  _NOEXCEPT
+    {
+        return do_always_noconv();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+    {
+        return do_length(__st, __frm, __end, __mx);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int max_length() const  _NOEXCEPT
+    {
+        return do_max_length();
+    }
+
+    static locale::id id;
+
+protected:
+    explicit codecvt(const char*, size_t __refs = 0);
+
+    ~codecvt();
+
+    virtual result do_out(state_type& __st,
+                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result do_in(state_type& __st,
+                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result do_unshift(state_type& __st,
+                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const  _NOEXCEPT;
+    virtual bool do_always_noconv() const  _NOEXCEPT;
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+    virtual int do_max_length() const  _NOEXCEPT;
+};
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char16_t, char, mbstate_t>
+    : public locale::facet,
+      public codecvt_base
+{
+public:
+    typedef char16_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    result out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_unshift(__st, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+    {
+        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int encoding() const  _NOEXCEPT
+    {
+        return do_encoding();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    bool always_noconv() const  _NOEXCEPT
+    {
+        return do_always_noconv();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+    {
+        return do_length(__st, __frm, __end, __mx);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int max_length() const  _NOEXCEPT
+    {
+        return do_max_length();
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt(const char*, size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    ~codecvt();
+
+    virtual result do_out(state_type& __st,
+                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result do_in(state_type& __st,
+                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result do_unshift(state_type& __st,
+                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const  _NOEXCEPT;
+    virtual bool do_always_noconv() const  _NOEXCEPT;
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+    virtual int do_max_length() const  _NOEXCEPT;
+};
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+template <>
+class _LIBCPP_TYPE_VIS codecvt<char32_t, char, mbstate_t>
+    : public locale::facet,
+      public codecvt_base
+{
+public:
+    typedef char32_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    result out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const
+    {
+        return do_unshift(__st, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    result in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const
+    {
+        return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int encoding() const  _NOEXCEPT
+    {
+        return do_encoding();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    bool always_noconv() const  _NOEXCEPT
+    {
+        return do_always_noconv();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const
+    {
+        return do_length(__st, __frm, __end, __mx);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int max_length() const  _NOEXCEPT
+    {
+        return do_max_length();
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt(const char*, size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    ~codecvt();
+
+    virtual result do_out(state_type& __st,
+                          const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+                          extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result do_in(state_type& __st,
+                         const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+                         intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result do_unshift(state_type& __st,
+                              extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const  _NOEXCEPT;
+    virtual bool do_always_noconv() const  _NOEXCEPT;
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
+    virtual int do_max_length() const  _NOEXCEPT;
+};
+
+// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
+
+template <class _InternT, class _ExternT, class _StateT>
+class _LIBCPP_TYPE_VIS_ONLY codecvt_byname
+    : public codecvt<_InternT, _ExternT, _StateT>
+{
+public:
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt_byname(const char* __nm, size_t __refs = 0)
+        : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt_byname(const string& __nm, size_t __refs = 0)
+        : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {}
+protected:
+    ~codecvt_byname();
+};
+
+template <class _InternT, class _ExternT, class _StateT>
+codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
+{
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
+
+_LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
+
+template <size_t _Np>
+struct __narrow_to_utf8
+{
+    template <class _OutputIterator, class _CharT>
+    _OutputIterator
+    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const;
+};
+
+template <>
+struct __narrow_to_utf8<8>
+{
+    template <class _OutputIterator, class _CharT>
+    _LIBCPP_ALWAYS_INLINE
+    _OutputIterator
+    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
+    {
+        for (; __wb < __we; ++__wb, ++__s)
+            *__s = *__wb;
+        return __s;
+    }
+};
+
+template <>
+struct __narrow_to_utf8<16>
+    : public codecvt<char16_t, char, mbstate_t>
+{
+    _LIBCPP_ALWAYS_INLINE
+    __narrow_to_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
+
+    ~__narrow_to_utf8();
+
+    template <class _OutputIterator, class _CharT>
+    _LIBCPP_ALWAYS_INLINE
+    _OutputIterator
+    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
+    {
+        result __r = ok;
+        mbstate_t __mb;
+        while (__wb < __we && __r != error)
+        {
+            const int __sz = 32;
+            char __buf[__sz];
+            char* __bn;
+            const char16_t* __wn = (const char16_t*)__wb;
+            __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn,
+                         __buf, __buf+__sz, __bn);
+            if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
+                __throw_runtime_error("locale not supported");
+            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
+                *__s = *__p;
+            __wb = (const _CharT*)__wn;
+        }
+        return __s;
+    }
+};
+
+template <>
+struct __narrow_to_utf8<32>
+    : public codecvt<char32_t, char, mbstate_t>
+{
+    _LIBCPP_ALWAYS_INLINE
+    __narrow_to_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
+
+    ~__narrow_to_utf8();
+
+    template <class _OutputIterator, class _CharT>
+    _LIBCPP_ALWAYS_INLINE
+    _OutputIterator
+    operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const
+    {
+        result __r = ok;
+        mbstate_t __mb;
+        while (__wb < __we && __r != error)
+        {
+            const int __sz = 32;
+            char __buf[__sz];
+            char* __bn;
+            const char32_t* __wn = (const char32_t*)__wb;
+            __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn,
+                         __buf, __buf+__sz, __bn);
+            if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
+                __throw_runtime_error("locale not supported");
+            for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
+                *__s = *__p;
+            __wb = (const _CharT*)__wn;
+        }
+        return __s;
+    }
+};
+
+template <size_t _Np>
+struct __widen_from_utf8
+{
+    template <class _OutputIterator>
+    _OutputIterator
+    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const;
+};
+
+template <>
+struct __widen_from_utf8<8>
+{
+    template <class _OutputIterator>
+    _LIBCPP_ALWAYS_INLINE
+    _OutputIterator
+    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
+    {
+        for (; __nb < __ne; ++__nb, ++__s)
+            *__s = *__nb;
+        return __s;
+    }
+};
+
+template <>
+struct __widen_from_utf8<16>
+    : public codecvt<char16_t, char, mbstate_t>
+{
+    _LIBCPP_ALWAYS_INLINE
+    __widen_from_utf8() : codecvt<char16_t, char, mbstate_t>(1) {}
+
+    ~__widen_from_utf8();
+
+    template <class _OutputIterator>
+    _LIBCPP_ALWAYS_INLINE
+    _OutputIterator
+    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
+    {
+        result __r = ok;
+        mbstate_t __mb;
+        while (__nb < __ne && __r != error)
+        {
+            const int __sz = 32;
+            char16_t __buf[__sz];
+            char16_t* __bn;
+            const char* __nn = __nb;
+            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
+                        __buf, __buf+__sz, __bn);
+            if (__r == codecvt_base::error || __nn == __nb)
+                __throw_runtime_error("locale not supported");
+            for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
+                *__s = (wchar_t)*__p;
+            __nb = __nn;
+        }
+        return __s;
+    }
+};
+
+template <>
+struct __widen_from_utf8<32>
+    : public codecvt<char32_t, char, mbstate_t>
+{
+    _LIBCPP_ALWAYS_INLINE
+    __widen_from_utf8() : codecvt<char32_t, char, mbstate_t>(1) {}
+
+    ~__widen_from_utf8();
+
+    template <class _OutputIterator>
+    _LIBCPP_ALWAYS_INLINE
+    _OutputIterator
+    operator()(_OutputIterator __s, const char* __nb, const char* __ne) const
+    {
+        result __r = ok;
+        mbstate_t __mb;
+        while (__nb < __ne && __r != error)
+        {
+            const int __sz = 32;
+            char32_t __buf[__sz];
+            char32_t* __bn;
+            const char* __nn = __nb;
+            __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn,
+                        __buf, __buf+__sz, __bn);
+            if (__r == codecvt_base::error || __nn == __nb)
+                __throw_runtime_error("locale not supported");
+            for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
+                *__s = (wchar_t)*__p;
+            __nb = __nn;
+        }
+        return __s;
+    }
+};
+
+// template <class charT> class numpunct
+
+template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct;
+
+template <>
+class _LIBCPP_TYPE_VIS numpunct<char>
+    : public locale::facet
+{
+public:
+    typedef char char_type;
+    typedef basic_string<char_type> string_type;
+
+    explicit numpunct(size_t __refs = 0);
+
+    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
+    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
+    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
+    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
+    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
+
+    static locale::id id;
+
+protected:
+    ~numpunct();
+    virtual char_type do_decimal_point() const;
+    virtual char_type do_thousands_sep() const;
+    virtual string do_grouping() const;
+    virtual string_type do_truename() const;
+    virtual string_type do_falsename() const;
+
+    char_type __decimal_point_;
+    char_type __thousands_sep_;
+    string __grouping_;
+};
+
+template <>
+class _LIBCPP_TYPE_VIS numpunct<wchar_t>
+    : public locale::facet
+{
+public:
+    typedef wchar_t char_type;
+    typedef basic_string<char_type> string_type;
+
+    explicit numpunct(size_t __refs = 0);
+
+    _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();}
+    _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();}
+    _LIBCPP_ALWAYS_INLINE string grouping() const         {return do_grouping();}
+    _LIBCPP_ALWAYS_INLINE string_type truename() const    {return do_truename();}
+    _LIBCPP_ALWAYS_INLINE string_type falsename() const   {return do_falsename();}
+
+    static locale::id id;
+
+protected:
+    ~numpunct();
+    virtual char_type do_decimal_point() const;
+    virtual char_type do_thousands_sep() const;
+    virtual string do_grouping() const;
+    virtual string_type do_truename() const;
+    virtual string_type do_falsename() const;
+
+    char_type __decimal_point_;
+    char_type __thousands_sep_;
+    string __grouping_;
+};
+
+// template <class charT> class numpunct_byname
+
+template <class charT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname;
+
+template <>
+class _LIBCPP_TYPE_VIS numpunct_byname<char>
+: public numpunct<char>
+{
+public:
+    typedef char char_type;
+    typedef basic_string<char_type> string_type;
+
+    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
+    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
+
+protected:
+    ~numpunct_byname();
+
+private:
+    void __init(const char*);
+};
+
+template <>
+class _LIBCPP_TYPE_VIS numpunct_byname<wchar_t>
+: public numpunct<wchar_t>
+{
+public:
+    typedef wchar_t char_type;
+    typedef basic_string<char_type> string_type;
+
+    explicit numpunct_byname(const char* __nm, size_t __refs = 0);
+    explicit numpunct_byname(const string& __nm, size_t __refs = 0);
+
+protected:
+    ~numpunct_byname();
+
+private:
+    void __init(const char*);
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___LOCALE
diff --git a/final/include/__mutex_base b/final/include/__mutex_base
new file mode 100644
index 0000000..293fead
--- /dev/null
+++ b/final/include/__mutex_base
@@ -0,0 +1,401 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___MUTEX_BASE
+#define _LIBCPP___MUTEX_BASE
+
+#include <__config>
+#include <chrono>
+#include <system_error>
+#include <pthread.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS mutex
+{
+    pthread_mutex_t __m_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+     constexpr mutex() _NOEXCEPT : __m_(PTHREAD_MUTEX_INITIALIZER) {}
+#else
+     mutex() _NOEXCEPT {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
+#endif
+     ~mutex();
+
+private:
+    mutex(const mutex&);// = delete;
+    mutex& operator=(const mutex&);// = delete;
+
+public:
+    void lock();
+    bool try_lock() _NOEXCEPT;
+    void unlock() _NOEXCEPT;
+
+    typedef pthread_mutex_t* native_handle_type;
+    _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
+};
+
+struct _LIBCPP_TYPE_VIS defer_lock_t {};
+struct _LIBCPP_TYPE_VIS try_to_lock_t {};
+struct _LIBCPP_TYPE_VIS adopt_lock_t {};
+
+#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MUTEX)
+
+extern const defer_lock_t  defer_lock;
+extern const try_to_lock_t try_to_lock;
+extern const adopt_lock_t  adopt_lock;
+
+#else
+
+constexpr defer_lock_t  defer_lock  = defer_lock_t();
+constexpr try_to_lock_t try_to_lock = try_to_lock_t();
+constexpr adopt_lock_t  adopt_lock  = adopt_lock_t();
+
+#endif
+
+template <class _Mutex>
+class _LIBCPP_TYPE_VIS_ONLY lock_guard
+{
+public:
+    typedef _Mutex mutex_type;
+
+private:
+    mutex_type& __m_;
+public:
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit lock_guard(mutex_type& __m)
+        : __m_(__m) {__m_.lock();}
+    _LIBCPP_INLINE_VISIBILITY
+    lock_guard(mutex_type& __m, adopt_lock_t)
+        : __m_(__m) {}
+    _LIBCPP_INLINE_VISIBILITY
+    ~lock_guard() {__m_.unlock();}
+
+private:
+    lock_guard(lock_guard const&);// = delete;
+    lock_guard& operator=(lock_guard const&);// = delete;
+};
+
+template <class _Mutex>
+class _LIBCPP_TYPE_VIS_ONLY unique_lock
+{
+public:
+    typedef _Mutex mutex_type;
+
+private:
+    mutex_type* __m_;
+    bool __owns_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit unique_lock(mutex_type& __m)
+        : __m_(&__m), __owns_(true) {__m_->lock();}
+    _LIBCPP_INLINE_VISIBILITY
+    unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
+        : __m_(&__m), __owns_(false) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unique_lock(mutex_type& __m, try_to_lock_t)
+        : __m_(&__m), __owns_(__m.try_lock()) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unique_lock(mutex_type& __m, adopt_lock_t)
+        : __m_(&__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)) {}
+    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)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    ~unique_lock()
+    {
+        if (__owns_)
+            __m_->unlock();
+    }
+
+private:
+    unique_lock(unique_lock const&); // = delete;
+    unique_lock& operator=(unique_lock const&); // = delete;
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    unique_lock(unique_lock&& __u) _NOEXCEPT
+        : __m_(__u.__m_), __owns_(__u.__owns_)
+        {__u.__m_ = nullptr; __u.__owns_ = false;}
+    _LIBCPP_INLINE_VISIBILITY
+    unique_lock& operator=(unique_lock&& __u) _NOEXCEPT
+        {
+            if (__owns_)
+                __m_->unlock();
+            __m_ = __u.__m_;
+            __owns_ = __u.__owns_;
+            __u.__m_ = nullptr;
+            __u.__owns_ = false;
+            return *this;
+        }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    void lock();
+    bool try_lock();
+
+    template <class _Rep, class _Period>
+        bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
+    template <class _Clock, class _Duration>
+        bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
+
+    void unlock();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(unique_lock& __u) _NOEXCEPT
+    {
+        _VSTD::swap(__m_, __u.__m_);
+        _VSTD::swap(__owns_, __u.__owns_);
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    mutex_type* release() _NOEXCEPT
+    {
+        mutex_type* __m = __m_;
+        __m_ = nullptr;
+        __owns_ = false;
+        return __m;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool owns_lock() const _NOEXCEPT {return __owns_;}
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_EXPLICIT
+        operator bool () const _NOEXCEPT {return __owns_;}
+    _LIBCPP_INLINE_VISIBILITY
+    mutex_type* mutex() const _NOEXCEPT {return __m_;}
+};
+
+template <class _Mutex>
+void
+unique_lock<_Mutex>::lock()
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "unique_lock::lock: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "unique_lock::lock: already locked");
+    __m_->lock();
+    __owns_ = true;
+}
+
+template <class _Mutex>
+bool
+unique_lock<_Mutex>::try_lock()
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
+    __owns_ = __m_->try_lock();
+    return __owns_;
+}
+
+template <class _Mutex>
+template <class _Rep, class _Period>
+bool
+unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked");
+    __owns_ = __m_->try_lock_for(__d);
+    return __owns_;
+}
+
+template <class _Mutex>
+template <class _Clock, class _Duration>
+bool
+unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked");
+    __owns_ = __m_->try_lock_until(__t);
+    return __owns_;
+}
+
+template <class _Mutex>
+void
+unique_lock<_Mutex>::unlock()
+{
+    if (!__owns_)
+        __throw_system_error(EPERM, "unique_lock::unlock: not locked");
+    __m_->unlock();
+    __owns_ = false;
+}
+
+template <class _Mutex>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT
+    {__x.swap(__y);}
+
+//enum class cv_status
+_LIBCPP_DECLARE_STRONG_ENUM(cv_status)
+{
+    no_timeout,
+    timeout
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
+
+class _LIBCPP_TYPE_VIS condition_variable
+{
+    pthread_cond_t __cv_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    constexpr condition_variable() : __cv_(PTHREAD_COND_INITIALIZER) {}
+#else
+    condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
+#endif
+    ~condition_variable();
+
+private:
+    condition_variable(const condition_variable&); // = delete;
+    condition_variable& operator=(const condition_variable&); // = delete;
+
+public:
+    void notify_one() _NOEXCEPT;
+    void notify_all() _NOEXCEPT;
+
+    void wait(unique_lock<mutex>& __lk) _NOEXCEPT;
+    template <class _Predicate>
+        void wait(unique_lock<mutex>& __lk, _Predicate __pred);
+
+    template <class _Clock, class _Duration>
+        cv_status
+        wait_until(unique_lock<mutex>& __lk,
+                   const chrono::time_point<_Clock, _Duration>& __t);
+
+    template <class _Clock, class _Duration, class _Predicate>
+        bool
+        wait_until(unique_lock<mutex>& __lk,
+                   const chrono::time_point<_Clock, _Duration>& __t,
+                   _Predicate __pred);
+
+    template <class _Rep, class _Period>
+        cv_status
+        wait_for(unique_lock<mutex>& __lk,
+                 const chrono::duration<_Rep, _Period>& __d);
+
+    template <class _Rep, class _Period, class _Predicate>
+        bool
+        wait_for(unique_lock<mutex>& __lk,
+                 const chrono::duration<_Rep, _Period>& __d,
+                 _Predicate __pred);
+
+    typedef pthread_cond_t* native_handle_type;
+    _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;}
+
+private:
+    void __do_timed_wait(unique_lock<mutex>& __lk,
+       chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
+};
+
+template <class _To, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    chrono::__is_duration<_To>::value,
+    _To
+>::type
+__ceil(chrono::duration<_Rep, _Period> __d)
+{
+    using namespace chrono;
+    _To __r = duration_cast<_To>(__d);
+    if (__r < __d)
+        ++__r;
+    return __r;
+}
+
+template <class _Predicate>
+void
+condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred)
+{
+    while (!__pred())
+        wait(__lk);
+}
+
+template <class _Clock, class _Duration>
+cv_status
+condition_variable::wait_until(unique_lock<mutex>& __lk,
+                               const chrono::time_point<_Clock, _Duration>& __t)
+{
+    using namespace chrono;
+    wait_for(__lk, __t - _Clock::now());
+    return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout;
+}
+
+template <class _Clock, class _Duration, class _Predicate>
+bool
+condition_variable::wait_until(unique_lock<mutex>& __lk,
+                   const chrono::time_point<_Clock, _Duration>& __t,
+                   _Predicate __pred)
+{
+    while (!__pred())
+    {
+        if (wait_until(__lk, __t) == cv_status::timeout)
+            return __pred();
+    }
+    return true;
+}
+
+template <class _Rep, class _Period>
+cv_status
+condition_variable::wait_for(unique_lock<mutex>& __lk,
+                             const chrono::duration<_Rep, _Period>& __d)
+{
+    using namespace chrono;
+    if (__d <= __d.zero())
+        return cv_status::timeout;
+    typedef time_point<system_clock, duration<long double, nano> > __sys_tpf;
+    typedef time_point<system_clock, nanoseconds> __sys_tpi;
+    __sys_tpf _Max = __sys_tpi::max();
+    system_clock::time_point __s_now = system_clock::now();
+    steady_clock::time_point __c_now = steady_clock::now();
+    if (_Max - __d > __s_now)
+        __do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d));
+    else
+        __do_timed_wait(__lk, __sys_tpi::max());
+    return steady_clock::now() - __c_now < __d ? cv_status::no_timeout :
+                                                 cv_status::timeout;
+}
+
+template <class _Rep, class _Period, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+condition_variable::wait_for(unique_lock<mutex>& __lk,
+                             const chrono::duration<_Rep, _Period>& __d,
+                             _Predicate __pred)
+{
+    return wait_until(__lk, chrono::steady_clock::now() + __d,
+                      _VSTD::move(__pred));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___MUTEX_BASE
diff --git a/final/include/__refstring b/final/include/__refstring
new file mode 100644
index 0000000..6866bf1
--- /dev/null
+++ b/final/include/__refstring
@@ -0,0 +1,139 @@
+//===------------------------ __refstring ---------------------------------===//
+//
+//                     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___REFSTRING
+#define _LIBCPP___REFSTRING
+
+#include <__config>
+#include <cstddef>
+#include <cstring>
+#if __APPLE__
+#include <dlfcn.h>
+#include <mach-o/dyld.h>
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_HIDDEN __libcpp_refstring
+{
+private:
+    const char* str_;
+
+    typedef int count_t;
+
+    struct _Rep_base
+    {
+        std::size_t len;
+        std::size_t cap;
+        count_t     count;
+    };
+
+    static
+    _Rep_base*
+    rep_from_data(const char *data_) _NOEXCEPT
+    {
+        char *data = const_cast<char *>(data_);
+        return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
+    }
+    static
+    char *
+    data_from_rep(_Rep_base *rep) _NOEXCEPT
+    {
+        char *data = reinterpret_cast<char *>(rep);
+        return data + sizeof(*rep);
+    }
+
+#if __APPLE__
+    static
+    const char*
+    compute_gcc_empty_string_storage() _NOEXCEPT
+    {
+        void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
+        if (handle == nullptr)
+            return nullptr;
+        void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
+        if (sym == nullptr)
+            return nullptr;
+        return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
+    }
+
+    static
+    const char*
+    get_gcc_empty_string_storage() _NOEXCEPT
+    {
+        static const char* p = compute_gcc_empty_string_storage();
+        return p;
+    }
+
+    bool
+    uses_refcount() const
+    {
+        return str_ != get_gcc_empty_string_storage();
+    }
+#else
+    bool
+    uses_refcount() const
+    {
+        return true;
+    }
+#endif
+
+public:
+    explicit __libcpp_refstring(const char* msg) {
+        std::size_t len = strlen(msg);
+        _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1));
+        rep->len = len;
+        rep->cap = len;
+        rep->count = 0;
+        char *data = data_from_rep(rep);
+        std::memcpy(data, msg, len + 1);
+        str_ = data;
+    }
+
+    __libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT : str_(s.str_)
+    {
+        if (uses_refcount())
+            __sync_add_and_fetch(&rep_from_data(str_)->count, 1);
+    }
+
+    __libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT
+    {
+        bool adjust_old_count = uses_refcount();
+        struct _Rep_base *old_rep = rep_from_data(str_);
+        str_ = s.str_;
+        if (uses_refcount())
+            __sync_add_and_fetch(&rep_from_data(str_)->count, 1);
+        if (adjust_old_count)
+        {
+            if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
+            {
+                ::operator delete(old_rep);
+            }
+        }
+        return *this;
+    }
+
+    ~__libcpp_refstring()
+    {
+        if (uses_refcount())
+        {
+            _Rep_base* rep = rep_from_data(str_);
+            if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0)
+            {
+                ::operator delete(rep);
+            }
+        }
+    }
+
+    const char* c_str() const _NOEXCEPT {return str_;}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif //_LIBCPP___REFSTRING
diff --git a/final/include/__split_buffer b/final/include/__split_buffer
new file mode 100644
index 0000000..1d529cb
--- /dev/null
+++ b/final/include/__split_buffer
@@ -0,0 +1,654 @@
+// -*- C++ -*-
+#ifndef _LIBCPP_SPLIT_BUFFER
+#define _LIBCPP_SPLIT_BUFFER
+
+#include <__config>
+#include <type_traits>
+#include <algorithm>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <bool>
+class __split_buffer_common
+{
+protected:
+    void __throw_length_error() const;
+    void __throw_out_of_range() const;
+};
+
+template <class _Tp, class _Allocator = allocator<_Tp> >
+struct __split_buffer
+    : private __split_buffer_common<true>
+{
+private:
+    __split_buffer(const __split_buffer&);
+    __split_buffer& operator=(const __split_buffer&);
+public:
+    typedef _Tp                                             value_type;
+    typedef _Allocator                                      allocator_type;
+    typedef typename remove_reference<allocator_type>::type __alloc_rr;
+    typedef allocator_traits<__alloc_rr>                    __alloc_traits;
+    typedef value_type&                                     reference;
+    typedef const value_type&                               const_reference;
+    typedef typename __alloc_traits::size_type              size_type;
+    typedef typename __alloc_traits::difference_type        difference_type;
+    typedef typename __alloc_traits::pointer                pointer;
+    typedef typename __alloc_traits::const_pointer          const_pointer;
+    typedef pointer                                         iterator;
+    typedef const_pointer                                   const_iterator;
+
+    pointer                                         __first_;
+    pointer                                         __begin_;
+    pointer                                         __end_;
+    __compressed_pair<pointer, allocator_type> __end_cap_;
+
+    typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
+    typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
+
+    _LIBCPP_INLINE_VISIBILITY __alloc_rr&           __alloc() _NOEXCEPT         {return __end_cap_.second();}
+    _LIBCPP_INLINE_VISIBILITY const __alloc_rr&     __alloc() const _NOEXCEPT   {return __end_cap_.second();}
+    _LIBCPP_INLINE_VISIBILITY pointer&              __end_cap() _NOEXCEPT       {return __end_cap_.first();}
+    _LIBCPP_INLINE_VISIBILITY const pointer&        __end_cap() const _NOEXCEPT {return __end_cap_.first();}
+
+    __split_buffer()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+    explicit __split_buffer(__alloc_rr& __a);
+    explicit __split_buffer(const __alloc_rr& __a);
+    __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
+    ~__split_buffer();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __split_buffer(__split_buffer&& __c)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+    __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
+    __split_buffer& operator=(__split_buffer&& __c)
+        _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
+                is_nothrow_move_assignable<allocator_type>::value) ||
+               !__alloc_traits::propagate_on_container_move_assignment::value);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY       iterator begin() _NOEXCEPT       {return __begin_;}
+    _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
+    _LIBCPP_INLINE_VISIBILITY       iterator end() _NOEXCEPT         {return __end_;}
+    _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT   {return __end_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT
+        {__destruct_at_end(__begin_);}
+    _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
+    _LIBCPP_INLINE_VISIBILITY bool empty()     const {return __end_ == __begin_;}
+    _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
+    _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
+    _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
+
+    _LIBCPP_INLINE_VISIBILITY       reference front()       {return *__begin_;}
+    _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
+    _LIBCPP_INLINE_VISIBILITY       reference back()        {return *(__end_ - 1);}
+    _LIBCPP_INLINE_VISIBILITY const_reference back() const  {return *(__end_ - 1);}
+
+    void reserve(size_type __n);
+    void shrink_to_fit() _NOEXCEPT;
+    void push_front(const_reference __x);
+    _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+    void push_front(value_type&& __x);
+    void push_back(value_type&& __x);
+#if !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class... _Args>
+        void emplace_back(_Args&&... __args);
+#endif  // !defined(_LIBCPP_HAS_NO_VARIADICS)
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
+    _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
+
+    void __construct_at_end(size_type __n);
+    void __construct_at_end(size_type __n, const_reference __x);
+    template <class _InputIter>
+        typename enable_if
+        <
+            __is_input_iterator<_InputIter>::value &&
+           !__is_forward_iterator<_InputIter>::value,
+            void
+        >::type
+        __construct_at_end(_InputIter __first, _InputIter __last);
+    template <class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            void
+        >::type
+        __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
+        {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
+        void __destruct_at_begin(pointer __new_begin, false_type);
+        void __destruct_at_begin(pointer __new_begin, true_type);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __destruct_at_end(pointer __new_last) _NOEXCEPT
+        {__destruct_at_end(__new_last, false_type());}
+    _LIBCPP_INLINE_VISIBILITY
+        void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+        void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
+
+    void swap(__split_buffer& __x)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
+                   __is_nothrow_swappable<__alloc_rr>::value);
+
+    bool __invariants() const;
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__split_buffer& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+        {
+            __alloc() = _VSTD::move(__c.__alloc());
+        }
+
+    _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>
+bool
+__split_buffer<_Tp, _Allocator>::__invariants() const
+{
+    if (__first_ == nullptr)
+    {
+        if (__begin_ != nullptr)
+            return false;
+        if (__end_ != nullptr)
+            return false;
+        if (__end_cap() != nullptr)
+            return false;
+    }
+    else
+    {
+        if (__begin_ < __first_)
+            return false;
+        if (__end_ < __begin_)
+            return false;
+        if (__end_cap() < __end_)
+            return false;
+    }
+    return true;
+}
+
+//  Default constructs __n objects starting at __end_
+//  throws if construction throws
+//  Precondition:  __n > 0
+//  Precondition:  size() + __n <= capacity()
+//  Postcondition:  size() == size() + __n
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
+{
+    __alloc_rr& __a = this->__alloc();
+    do
+    {
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
+        ++this->__end_;
+        --__n;
+    } while (__n > 0);
+}
+
+//  Copy constructs __n objects starting at __end_ from __x
+//  throws if construction throws
+//  Precondition:  __n > 0
+//  Precondition:  size() + __n <= capacity()
+//  Postcondition:  size() == old size() + __n
+//  Postcondition:  [i] == __x for all i in [size() - __n, __n)
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
+{
+    __alloc_rr& __a = this->__alloc();
+    do
+    {
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x);
+        ++this->__end_;
+        --__n;
+    } while (__n > 0);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+typename enable_if
+<
+     __is_input_iterator<_InputIter>::value &&
+    !__is_forward_iterator<_InputIter>::value,
+    void
+>::type
+__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
+{
+    __alloc_rr& __a = this->__alloc();
+    for (; __first != __last; ++__first)
+    {
+        if (__end_ == __end_cap())
+        {
+            size_type __old_cap = __end_cap() - __first_;
+            size_type __new_cap = _VSTD::max<size_type>(2 * __old_cap, 8);
+            __split_buffer __buf(__new_cap, 0, __a);
+            for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_)
+                __alloc_traits::construct(__buf.__alloc(),
+                        _VSTD::__to_raw_pointer(__buf.__end_), _VSTD::move(*__p));
+            swap(__buf);
+        }
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
+        ++this->__end_;
+    }
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    void
+>::type
+__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+{
+    __alloc_rr& __a = this->__alloc();
+    for (; __first != __last; ++__first)
+    {
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
+        ++this->__end_;
+    }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
+{
+    while (__begin_ != __new_begin)
+        __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++));
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
+{
+    __begin_ = __new_begin;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
+{
+    while (__new_last != __end_)
+        __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_));
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
+{
+    __end_ = __new_last;
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
+    : __end_cap_(nullptr, __a)
+{
+    __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
+    __begin_ = __end_ = __first_ + __start;
+    __end_cap() = __first_ + __cap;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+__split_buffer<_Tp, _Allocator>::__split_buffer()
+    _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+    : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr)
+{
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+__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
+__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
+    : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
+{
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::~__split_buffer()
+{
+    clear();
+    if (__first_)
+        __alloc_traits::deallocate(__alloc(), __first_, capacity());
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
+    _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+    : __first_(_VSTD::move(__c.__first_)),
+      __begin_(_VSTD::move(__c.__begin_)),
+      __end_(_VSTD::move(__c.__end_)),
+      __end_cap_(_VSTD::move(__c.__end_cap_))
+{
+    __c.__first_ = nullptr;
+    __c.__begin_ = nullptr;
+    __c.__end_ = nullptr;
+    __c.__end_cap() = nullptr;
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
+    : __end_cap_(__a)
+{
+    if (__a == __c.__alloc())
+    {
+        __first_ = __c.__first_;
+        __begin_ = __c.__begin_;
+        __end_ = __c.__end_;
+        __end_cap() = __c.__end_cap();
+        __c.__first_ = nullptr;
+        __c.__begin_ = nullptr;
+        __c.__end_ = nullptr;
+        __c.__end_cap() = nullptr;
+    }
+    else
+    {
+        size_type __cap = __c.size();
+        __first_ = __alloc_traits::allocate(__alloc(), __cap);
+        __begin_ = __end_ = __first_;
+        __end_cap() = __first_ + __cap;
+        typedef move_iterator<iterator> _Ip;
+        __construct_at_end(_Ip(__c.begin()), _Ip(__c.end()));
+    }
+}
+
+template <class _Tp, class _Allocator>
+__split_buffer<_Tp, _Allocator>&
+__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
+    _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
+                is_nothrow_move_assignable<allocator_type>::value) ||
+               !__alloc_traits::propagate_on_container_move_assignment::value)
+{
+    clear();
+    shrink_to_fit();
+    __first_ = __c.__first_;
+    __begin_ = __c.__begin_;
+    __end_ = __c.__end_;
+    __end_cap() = __c.__end_cap();
+    __move_assign_alloc(__c,
+        integral_constant<bool,
+                          __alloc_traits::propagate_on_container_move_assignment::value>());
+    __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
+                   __is_nothrow_swappable<__alloc_rr>::value)
+{
+    _VSTD::swap(__first_, __x.__first_);
+    _VSTD::swap(__begin_, __x.__begin_);
+    _VSTD::swap(__end_, __x.__end_);
+    _VSTD::swap(__end_cap(), __x.__end_cap());
+    __swap_alloc(__alloc(), __x.__alloc());
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
+{
+    if (__n < capacity())
+    {
+        __split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc());
+        __t.__construct_at_end(move_iterator<pointer>(__begin_),
+                               move_iterator<pointer>(__end_));
+        _VSTD::swap(__first_, __t.__first_);
+        _VSTD::swap(__begin_, __t.__begin_);
+        _VSTD::swap(__end_, __t.__end_);
+        _VSTD::swap(__end_cap(), __t.__end_cap());
+    }
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+    if (capacity() > size())
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc());
+            __t.__construct_at_end(move_iterator<pointer>(__begin_),
+                                   move_iterator<pointer>(__end_));
+            __t.__end_ = __t.__begin_ + (__end_ - __begin_);
+            _VSTD::swap(__first_, __t.__first_);
+            _VSTD::swap(__begin_, __t.__begin_);
+            _VSTD::swap(__end_, __t.__end_);
+            _VSTD::swap(__end_cap(), __t.__end_cap());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
+{
+    if (__begin_ == __first_)
+    {
+        if (__end_ < __end_cap())
+        {
+            difference_type __d = __end_cap() - __end_;
+            __d = (__d + 1) / 2;
+            __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
+            __end_ += __d;
+        }
+        else
+        {
+            size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+            __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
+            __t.__construct_at_end(move_iterator<pointer>(__begin_),
+                                   move_iterator<pointer>(__end_));
+            _VSTD::swap(__first_, __t.__first_);
+            _VSTD::swap(__begin_, __t.__begin_);
+            _VSTD::swap(__end_, __t.__end_);
+            _VSTD::swap(__end_cap(), __t.__end_cap());
+        }
+    }
+    __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), __x);
+    --__begin_;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
+{
+    if (__begin_ == __first_)
+    {
+        if (__end_ < __end_cap())
+        {
+            difference_type __d = __end_cap() - __end_;
+            __d = (__d + 1) / 2;
+            __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d);
+            __end_ += __d;
+        }
+        else
+        {
+            size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+            __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc());
+            __t.__construct_at_end(move_iterator<pointer>(__begin_),
+                                   move_iterator<pointer>(__end_));
+            _VSTD::swap(__first_, __t.__first_);
+            _VSTD::swap(__begin_, __t.__begin_);
+            _VSTD::swap(__end_, __t.__end_);
+            _VSTD::swap(__end_cap(), __t.__end_cap());
+        }
+    }
+    __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1),
+            _VSTD::move(__x));
+    --__begin_;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
+{
+    if (__end_ == __end_cap())
+    {
+        if (__begin_ > __first_)
+        {
+            difference_type __d = __begin_ - __first_;
+            __d = (__d + 1) / 2;
+            __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
+            __begin_ -= __d;
+        }
+        else
+        {
+            size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+            __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
+            __t.__construct_at_end(move_iterator<pointer>(__begin_),
+                                   move_iterator<pointer>(__end_));
+            _VSTD::swap(__first_, __t.__first_);
+            _VSTD::swap(__begin_, __t.__begin_);
+            _VSTD::swap(__end_, __t.__end_);
+            _VSTD::swap(__end_cap(), __t.__end_cap());
+        }
+    }
+    __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), __x);
+    ++__end_;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+void
+__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
+{
+    if (__end_ == __end_cap())
+    {
+        if (__begin_ > __first_)
+        {
+            difference_type __d = __begin_ - __first_;
+            __d = (__d + 1) / 2;
+            __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
+            __begin_ -= __d;
+        }
+        else
+        {
+            size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+            __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
+            __t.__construct_at_end(move_iterator<pointer>(__begin_),
+                                   move_iterator<pointer>(__end_));
+            _VSTD::swap(__first_, __t.__first_);
+            _VSTD::swap(__begin_, __t.__begin_);
+            _VSTD::swap(__end_, __t.__end_);
+            _VSTD::swap(__end_cap(), __t.__end_cap());
+        }
+    }
+    __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_),
+            _VSTD::move(__x));
+    ++__end_;
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+void
+__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
+{
+    if (__end_ == __end_cap())
+    {
+        if (__begin_ > __first_)
+        {
+            difference_type __d = __begin_ - __first_;
+            __d = (__d + 1) / 2;
+            __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d);
+            __begin_ -= __d;
+        }
+        else
+        {
+            size_type __c = max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1);
+            __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
+            __t.__construct_at_end(move_iterator<pointer>(__begin_),
+                                   move_iterator<pointer>(__end_));
+            _VSTD::swap(__first_, __t.__first_);
+            _VSTD::swap(__begin_, __t.__begin_);
+            _VSTD::swap(__end_, __t.__end_);
+            _VSTD::swap(__end_cap(), __t.__end_cap());
+        }
+    }
+    __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_),
+                              _VSTD::forward<_Args>(__args)...);
+    ++__end_;
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)
+        _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_SPLIT_BUFFER
diff --git a/final/include/__sso_allocator b/final/include/__sso_allocator
new file mode 100644
index 0000000..645f2ba
--- /dev/null
+++ b/final/include/__sso_allocator
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___SSO_ALLOCATOR
+#define _LIBCPP___SSO_ALLOCATOR
+
+#include <__config>
+#include <type_traits>
+#include <new>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, size_t _Np> class _LIBCPP_HIDDEN __sso_allocator;
+
+template <size_t _Np>
+class _LIBCPP_HIDDEN __sso_allocator<void, _Np>
+{
+public:
+    typedef const void*       const_pointer;
+    typedef void              value_type;
+};
+
+template <class _Tp, size_t _Np>
+class _LIBCPP_HIDDEN __sso_allocator
+{
+    typename aligned_storage<sizeof(_Tp) * _Np>::type buf_;
+    bool __allocated_;
+public:
+    typedef size_t            size_type;
+    typedef _Tp*              pointer;
+    typedef _Tp               value_type;
+
+    _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
+    _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
+    template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
+         : __allocated_(false) {}
+private:
+    __sso_allocator& operator=(const __sso_allocator&);
+public:
+    _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = 0)
+    {
+        if (!__allocated_ && __n <= _Np)
+        {
+            __allocated_ = true;
+            return (pointer)&buf_;
+        }
+        return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
+    }
+    _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type)
+    {
+        if (__p == (pointer)&buf_)
+            __allocated_ = false;
+        else
+            _VSTD::__deallocate(__p);
+    }
+    _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___SSO_ALLOCATOR
diff --git a/final/include/__std_stream b/final/include/__std_stream
new file mode 100644
index 0000000..5403ada
--- /dev/null
+++ b/final/include/__std_stream
@@ -0,0 +1,359 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___STD_STREAM
+#define _LIBCPP___STD_STREAM
+
+#include <__config>
+#include <ostream>
+#include <istream>
+#include <__locale>
+#include <cstdio>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static const int __limit = 8;
+
+// __stdinbuf
+
+template <class _CharT>
+class _LIBCPP_HIDDEN __stdinbuf
+    : public basic_streambuf<_CharT, char_traits<_CharT> >
+{
+public:
+    typedef _CharT                           char_type;
+    typedef char_traits<char_type>           traits_type;
+    typedef typename traits_type::int_type   int_type;
+    typedef typename traits_type::pos_type   pos_type;
+    typedef typename traits_type::off_type   off_type;
+    typedef typename traits_type::state_type state_type;
+
+    __stdinbuf(FILE* __fp, state_type* __st);
+
+protected:
+    virtual int_type underflow();
+    virtual int_type uflow();
+    virtual int_type pbackfail(int_type __c = traits_type::eof());
+    virtual void imbue(const locale& __loc);
+
+private:
+
+    FILE* __file_;
+    const codecvt<char_type, char, state_type>* __cv_;
+    state_type* __st_;
+    int __encoding_;
+    int_type __last_consumed_;
+    bool __last_consumed_is_next_;
+    bool __always_noconv_;
+
+    __stdinbuf(const __stdinbuf&);
+    __stdinbuf& operator=(const __stdinbuf&);
+
+    int_type __getchar(bool __consume);
+};
+
+template <class _CharT>
+__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
+    : __file_(__fp),
+      __st_(__st),
+      __last_consumed_(traits_type::eof()),
+      __last_consumed_is_next_(false)
+{
+    imbue(this->getloc());
+}
+
+template <class _CharT>
+void
+__stdinbuf<_CharT>::imbue(const locale& __loc)
+{
+    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+    __encoding_ = __cv_->encoding();
+    __always_noconv_ = __cv_->always_noconv();
+    if (__encoding_ > __limit)
+        __throw_runtime_error("unsupported locale for standard input");
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::underflow()
+{
+    return __getchar(false);
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::uflow()
+{
+    return __getchar(true);
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::__getchar(bool __consume)
+{
+    if (__last_consumed_is_next_)
+    {
+        int_type __result = __last_consumed_;
+        if (__consume)
+        {
+            __last_consumed_ = traits_type::eof();
+            __last_consumed_is_next_ = false;
+        }
+        return __result;
+    }
+    char __extbuf[__limit];
+    int __nread = _VSTD::max(1, __encoding_);
+    for (int __i = 0; __i < __nread; ++__i)
+    {
+        int __c = getc(__file_);
+        if (__c == EOF)
+            return traits_type::eof();
+        __extbuf[__i] = static_cast<char>(__c);
+    }
+    char_type __1buf;
+    if (__always_noconv_)
+        __1buf = static_cast<char_type>(__extbuf[0]);
+    else
+    {
+        const char* __enxt;
+        char_type* __inxt;
+        codecvt_base::result __r;
+        do
+        {
+            state_type __sv_st = *__st_;
+            __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
+                                   &__1buf, &__1buf + 1, __inxt);
+            switch (__r)
+            {
+            case _VSTD::codecvt_base::ok:
+                break;
+            case codecvt_base::partial:
+                *__st_ = __sv_st;
+                if (__nread == sizeof(__extbuf))
+                    return traits_type::eof();
+                {
+                    int __c = getc(__file_);
+                    if (__c == EOF)
+                        return traits_type::eof();
+                    __extbuf[__nread] = static_cast<char>(__c);
+                }
+                ++__nread;
+                break;
+            case codecvt_base::error:
+                return traits_type::eof();
+            case _VSTD::codecvt_base::noconv:
+                __1buf = static_cast<char_type>(__extbuf[0]);
+                break;
+            }
+        } while (__r == _VSTD::codecvt_base::partial);
+    }
+    if (!__consume)
+    {
+        for (int __i = __nread; __i > 0;)
+        {
+            if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
+                return traits_type::eof();
+        }
+    }
+    else
+        __last_consumed_ = traits_type::to_int_type(__1buf);
+    return traits_type::to_int_type(__1buf);
+}
+
+template <class _CharT>
+typename __stdinbuf<_CharT>::int_type
+__stdinbuf<_CharT>::pbackfail(int_type __c)
+{
+    if (traits_type::eq_int_type(__c, traits_type::eof()))
+    {
+        if (!__last_consumed_is_next_)
+        {
+            __c = __last_consumed_;
+            __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
+                                                                 traits_type::eof());
+        }
+        return __c;
+    }
+    if (__last_consumed_is_next_)
+    {
+        char __extbuf[__limit];
+        char* __enxt;
+        const char_type __ci = traits_type::to_char_type(__last_consumed_);
+        const char_type* __inxt;
+        switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
+                                  __extbuf, __extbuf + sizeof(__extbuf), __enxt))
+        {
+        case _VSTD::codecvt_base::ok:
+            break;
+        case _VSTD::codecvt_base::noconv:
+            __extbuf[0] = static_cast<char>(__last_consumed_);
+            __enxt = __extbuf + 1;
+            break;
+        case codecvt_base::partial:
+        case codecvt_base::error:
+            return traits_type::eof();
+        }
+        while (__enxt > __extbuf)
+            if (ungetc(*--__enxt, __file_) == EOF)
+                return traits_type::eof();
+    }
+    __last_consumed_ = __c;
+    __last_consumed_is_next_ = true;
+    return __c;
+}
+
+// __stdoutbuf
+
+template <class _CharT>
+class _LIBCPP_HIDDEN __stdoutbuf
+    : public basic_streambuf<_CharT, char_traits<_CharT> >
+{
+public:
+    typedef _CharT                           char_type;
+    typedef char_traits<char_type>           traits_type;
+    typedef typename traits_type::int_type   int_type;
+    typedef typename traits_type::pos_type   pos_type;
+    typedef typename traits_type::off_type   off_type;
+    typedef typename traits_type::state_type state_type;
+
+    __stdoutbuf(FILE* __fp, state_type* __st);
+
+protected:
+    virtual int_type overflow (int_type __c = traits_type::eof());
+    virtual streamsize xsputn(const char_type* __s, streamsize __n);
+    virtual int sync();
+    virtual void imbue(const locale& __loc);
+
+private:
+    FILE* __file_;
+    const codecvt<char_type, char, state_type>* __cv_;
+    state_type* __st_;
+    bool __always_noconv_;
+
+    __stdoutbuf(const __stdoutbuf&);
+    __stdoutbuf& operator=(const __stdoutbuf&);
+};
+
+template <class _CharT>
+__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
+    : __file_(__fp),
+      __cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
+      __st_(__st),
+      __always_noconv_(__cv_->always_noconv())
+{
+}
+
+template <class _CharT>
+typename __stdoutbuf<_CharT>::int_type
+__stdoutbuf<_CharT>::overflow(int_type __c)
+{
+    char __extbuf[__limit];
+    char_type __1buf;
+    if (!traits_type::eq_int_type(__c, traits_type::eof()))
+    {
+        __1buf = traits_type::to_char_type(__c);
+        if (__always_noconv_)
+        {
+            if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
+                return traits_type::eof();
+        }
+        else
+        {
+            char* __extbe = __extbuf;
+            codecvt_base::result __r;
+            char_type* pbase = &__1buf;
+            char_type* pptr = pbase + 1;
+            char_type* epptr = pptr;
+            do
+            {
+                const char_type* __e;
+                __r = __cv_->out(*__st_, pbase, pptr, __e,
+                                        __extbuf,
+                                        __extbuf + sizeof(__extbuf),
+                                        __extbe);
+                if (__e == pbase)
+                    return traits_type::eof();
+                if (__r == codecvt_base::noconv)
+                {
+                    if (fwrite(pbase, 1, 1, __file_) != 1)
+                        return traits_type::eof();
+                }
+                else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
+                {
+                    size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
+                    if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
+                        return traits_type::eof();
+                    if (__r == codecvt_base::partial)
+                    {
+                        pbase = (char_type*)__e;
+                    }
+                }
+                else
+                    return traits_type::eof();
+            } while (__r == codecvt_base::partial);
+        }
+    }
+    return traits_type::not_eof(__c);
+}
+
+template <class _CharT>
+streamsize
+__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n)
+{
+    if (__always_noconv_)
+        return fwrite(__s, sizeof(char_type), __n, __file_);
+    streamsize __i = 0;
+    for (; __i < __n; ++__i, ++__s)
+        if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
+            break;
+    return __i;
+}
+
+template <class _CharT>
+int
+__stdoutbuf<_CharT>::sync()
+{
+    char __extbuf[__limit];
+    codecvt_base::result __r;
+    do
+    {
+        char* __extbe;
+        __r = __cv_->unshift(*__st_, __extbuf,
+                                    __extbuf + sizeof(__extbuf),
+                                    __extbe);
+        size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
+        if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
+            return -1;
+    } while (__r == codecvt_base::partial);
+    if (__r == codecvt_base::error)
+        return -1;
+    if (fflush(__file_))
+        return -1;
+    return 0;
+}
+
+template <class _CharT>
+void
+__stdoutbuf<_CharT>::imbue(const locale& __loc)
+{
+    sync();
+    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+    __always_noconv_ = __cv_->always_noconv();
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___STD_STREAM
diff --git a/final/include/__tree b/final/include/__tree
new file mode 100644
index 0000000..8e5447a
--- /dev/null
+++ b/final/include/__tree
@@ -0,0 +1,2309 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TREE
+#define _LIBCPP___TREE
+
+#include <__config>
+#include <iterator>
+#include <memory>
+#include <stdexcept>
+#include <algorithm>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Compare, class _Allocator> class __tree;
+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;
+
+/*
+
+_NodePtr algorithms
+
+The algorithms taking _NodePtr are red black tree algorithms.  Those
+algorithms taking a parameter named __root should assume that __root
+points to a proper red black tree (unless otherwise specified).
+
+Each algorithm herein assumes that __root->__parent_ points to a non-null
+structure which has a member __left_ which points back to __root.  No other
+member is read or written to at __root->__parent_.
+
+__root->__parent_ will be referred to below (in comments only) as end_node.
+end_node->__left_ is an externably accessible lvalue for __root, and can be
+changed by node insertion and removal (without explicit reference to end_node).
+
+All nodes (with the exception of end_node), even the node referred to as
+__root, have a non-null __parent_ field.
+
+*/
+
+// Returns:  true if __x is a left child of its parent, else false
+// Precondition:  __x != nullptr.
+template <class _NodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__tree_is_left_child(_NodePtr __x) _NOEXCEPT
+{
+    return __x == __x->__parent_->__left_;
+}
+
+// Determintes if the subtree rooted at __x is a proper red black subtree.  If
+//    __x is a proper subtree, returns the black height (null counts as 1).  If
+//    __x is an improper subtree, returns 0.
+template <class _NodePtr>
+unsigned
+__tree_sub_invariant(_NodePtr __x)
+{
+    if (__x == nullptr)
+        return 1;
+    // parent consistency checked by caller
+    // check __x->__left_ consistency
+    if (__x->__left_ != nullptr && __x->__left_->__parent_ != __x)
+        return 0;
+    // check __x->__right_ consistency
+    if (__x->__right_ != nullptr && __x->__right_->__parent_ != __x)
+        return 0;
+    // check __x->__left_ != __x->__right_ unless both are nullptr
+    if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr)
+        return 0;
+    // If this is red, neither child can be red
+    if (!__x->__is_black_)
+    {
+        if (__x->__left_ && !__x->__left_->__is_black_)
+            return 0;
+        if (__x->__right_ && !__x->__right_->__is_black_)
+            return 0;
+    }
+    unsigned __h = __tree_sub_invariant(__x->__left_);
+    if (__h == 0)
+        return 0;  // invalid left subtree
+    if (__h != __tree_sub_invariant(__x->__right_))
+        return 0;  // invalid or different height right subtree
+    return __h + __x->__is_black_;  // return black height of this node
+}
+
+// Determintes if the red black tree rooted at __root is a proper red black tree.
+//    __root == nullptr is a proper tree.  Returns true is __root is a proper
+//    red black tree, else returns false.
+template <class _NodePtr>
+bool
+__tree_invariant(_NodePtr __root)
+{
+    if (__root == nullptr)
+        return true;
+    // check __x->__parent_ consistency
+    if (__root->__parent_ == nullptr)
+        return false;
+    if (!__tree_is_left_child(__root))
+        return false;
+    // root must be black
+    if (!__root->__is_black_)
+        return false;
+    // do normal node checks
+    return __tree_sub_invariant(__root) != 0;
+}
+
+// Returns:  pointer to the left-most node under __x.
+// Precondition:  __x != nullptr.
+template <class _NodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+_NodePtr
+__tree_min(_NodePtr __x) _NOEXCEPT
+{
+    while (__x->__left_ != nullptr)
+        __x = __x->__left_;
+    return __x;
+}
+
+// Returns:  pointer to the right-most node under __x.
+// Precondition:  __x != nullptr.
+template <class _NodePtr>
+inline _LIBCPP_INLINE_VISIBILITY
+_NodePtr
+__tree_max(_NodePtr __x) _NOEXCEPT
+{
+    while (__x->__right_ != nullptr)
+        __x = __x->__right_;
+    return __x;
+}
+
+// Returns:  pointer to the next in-order node after __x.
+// Precondition:  __x != nullptr.
+template <class _NodePtr>
+_NodePtr
+__tree_next(_NodePtr __x) _NOEXCEPT
+{
+    if (__x->__right_ != nullptr)
+        return __tree_min(__x->__right_);
+    while (!__tree_is_left_child(__x))
+        __x = __x->__parent_;
+    return __x->__parent_;
+}
+
+// Returns:  pointer to the previous in-order node before __x.
+// Precondition:  __x != nullptr.
+template <class _NodePtr>
+_NodePtr
+__tree_prev(_NodePtr __x) _NOEXCEPT
+{
+    if (__x->__left_ != nullptr)
+        return __tree_max(__x->__left_);
+    while (__tree_is_left_child(__x))
+        __x = __x->__parent_;
+    return __x->__parent_;
+}
+
+// Returns:  pointer to a node which has no children
+// Precondition:  __x != nullptr.
+template <class _NodePtr>
+_NodePtr
+__tree_leaf(_NodePtr __x) _NOEXCEPT
+{
+    while (true)
+    {
+        if (__x->__left_ != nullptr)
+        {
+            __x = __x->__left_;
+            continue;
+        }
+        if (__x->__right_ != nullptr)
+        {
+            __x = __x->__right_;
+            continue;
+        }
+        break;
+    }
+    return __x;
+}
+
+// Effects:  Makes __x->__right_ the subtree root with __x as its left child
+//           while preserving in-order order.
+// Precondition:  __x->__right_ != nullptr
+template <class _NodePtr>
+void
+__tree_left_rotate(_NodePtr __x) _NOEXCEPT
+{
+    _NodePtr __y = __x->__right_;
+    __x->__right_ = __y->__left_;
+    if (__x->__right_ != nullptr)
+        __x->__right_->__parent_ = __x;
+    __y->__parent_ = __x->__parent_;
+    if (__tree_is_left_child(__x))
+        __x->__parent_->__left_ = __y;
+    else
+        __x->__parent_->__right_ = __y;
+    __y->__left_ = __x;
+    __x->__parent_ = __y;
+}
+
+// Effects:  Makes __x->__left_ the subtree root with __x as its right child
+//           while preserving in-order order.
+// Precondition:  __x->__left_ != nullptr
+template <class _NodePtr>
+void
+__tree_right_rotate(_NodePtr __x) _NOEXCEPT
+{
+    _NodePtr __y = __x->__left_;
+    __x->__left_ = __y->__right_;
+    if (__x->__left_ != nullptr)
+        __x->__left_->__parent_ = __x;
+    __y->__parent_ = __x->__parent_;
+    if (__tree_is_left_child(__x))
+        __x->__parent_->__left_ = __y;
+    else
+        __x->__parent_->__right_ = __y;
+    __y->__right_ = __x;
+    __x->__parent_ = __y;
+}
+
+// Effects:  Rebalances __root after attaching __x to a leaf.
+// Precondition:  __root != nulptr && __x != nullptr.
+//                __x has no children.
+//                __x == __root or == a direct or indirect child of __root.
+//                If __x were to be unlinked from __root (setting __root to
+//                  nullptr if __root == __x), __tree_invariant(__root) == true.
+// Postcondition: __tree_invariant(end_node->__left_) == true.  end_node->__left_
+//                may be different than the value passed in as __root.
+template <class _NodePtr>
+void
+__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT
+{
+    __x->__is_black_ = __x == __root;
+    while (__x != __root && !__x->__parent_->__is_black_)
+    {
+        // __x->__parent_ != __root because __x->__parent_->__is_black == false
+        if (__tree_is_left_child(__x->__parent_))
+        {
+            _NodePtr __y = __x->__parent_->__parent_->__right_;
+            if (__y != nullptr && !__y->__is_black_)
+            {
+                __x = __x->__parent_;
+                __x->__is_black_ = true;
+                __x = __x->__parent_;
+                __x->__is_black_ = __x == __root;
+                __y->__is_black_ = true;
+            }
+            else
+            {
+                if (!__tree_is_left_child(__x))
+                {
+                    __x = __x->__parent_;
+                    __tree_left_rotate(__x);
+                }
+                __x = __x->__parent_;
+                __x->__is_black_ = true;
+                __x = __x->__parent_;
+                __x->__is_black_ = false;
+                __tree_right_rotate(__x);
+                break;
+            }
+        }
+        else
+        {
+            _NodePtr __y = __x->__parent_->__parent_->__left_;
+            if (__y != nullptr && !__y->__is_black_)
+            {
+                __x = __x->__parent_;
+                __x->__is_black_ = true;
+                __x = __x->__parent_;
+                __x->__is_black_ = __x == __root;
+                __y->__is_black_ = true;
+            }
+            else
+            {
+                if (__tree_is_left_child(__x))
+                {
+                    __x = __x->__parent_;
+                    __tree_right_rotate(__x);
+                }
+                __x = __x->__parent_;
+                __x->__is_black_ = true;
+                __x = __x->__parent_;
+                __x->__is_black_ = false;
+                __tree_left_rotate(__x);
+                break;
+            }
+        }
+    }
+}
+
+// Precondition:  __root != nullptr && __z != nullptr.
+//                __tree_invariant(__root) == true.
+//                __z == __root or == a direct or indirect child of __root.
+// Effects:  unlinks __z from the tree rooted at __root, rebalancing as needed.
+// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_
+//                nor any of its children refer to __z.  end_node->__left_
+//                may be different than the value passed in as __root.
+template <class _NodePtr>
+void
+__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT
+{
+    // __z will be removed from the tree.  Client still needs to destruct/deallocate it
+    // __y is either __z, or if __z has two children, __tree_next(__z).
+    // __y will have at most one child.
+    // __y will be the initial hole in the tree (make the hole at a leaf)
+    _NodePtr __y = (__z->__left_ == nullptr || __z->__right_ == nullptr) ?
+                    __z : __tree_next(__z);
+    // __x is __y's possibly null single child
+    _NodePtr __x = __y->__left_ != nullptr ? __y->__left_ : __y->__right_;
+    // __w is __x's possibly null uncle (will become __x's sibling)
+    _NodePtr __w = nullptr;
+    // link __x to __y's parent, and find __w
+    if (__x != nullptr)
+        __x->__parent_ = __y->__parent_;
+    if (__tree_is_left_child(__y))
+    {
+        __y->__parent_->__left_ = __x;
+        if (__y != __root)
+            __w = __y->__parent_->__right_;
+        else
+            __root = __x;  // __w == nullptr
+    }
+    else
+    {
+        __y->__parent_->__right_ = __x;
+        // __y can't be root if it is a right child
+        __w = __y->__parent_->__left_;
+    }
+    bool __removed_black = __y->__is_black_;
+    // If we didn't remove __z, do so now by splicing in __y for __z,
+    //    but copy __z's color.  This does not impact __x or __w.
+    if (__y != __z)
+    {
+        // __z->__left_ != nulptr but __z->__right_ might == __x == nullptr
+        __y->__parent_ = __z->__parent_;
+        if (__tree_is_left_child(__z))
+            __y->__parent_->__left_ = __y;
+        else
+            __y->__parent_->__right_ = __y;
+        __y->__left_ = __z->__left_;
+        __y->__left_->__parent_ = __y;
+        __y->__right_ = __z->__right_;
+        if (__y->__right_ != nullptr)
+            __y->__right_->__parent_ = __y;
+        __y->__is_black_ = __z->__is_black_;
+        if (__root == __z)
+            __root = __y;
+    }
+    // There is no need to rebalance if we removed a red, or if we removed
+    //     the last node.
+    if (__removed_black && __root != nullptr)
+    {
+        // Rebalance:
+        // __x has an implicit black color (transferred from the removed __y)
+        //    associated with it, no matter what its color is.
+        // If __x is __root (in which case it can't be null), it is supposed
+        //    to be black anyway, and if it is doubly black, then the double
+        //    can just be ignored.
+        // If __x is red (in which case it can't be null), then it can absorb
+        //    the implicit black just by setting its color to black.
+        // Since __y was black and only had one child (which __x points to), __x
+        //   is either red with no children, else null, otherwise __y would have
+        //   different black heights under left and right pointers.
+        // if (__x == __root || __x != nullptr && !__x->__is_black_)
+        if (__x != nullptr)
+            __x->__is_black_ = true;
+        else
+        {
+            //  Else __x isn't root, and is "doubly black", even though it may
+            //     be null.  __w can not be null here, else the parent would
+            //     see a black height >= 2 on the __x side and a black height
+            //     of 1 on the __w side (__w must be a non-null black or a red
+            //     with a non-null black child).
+            while (true)
+            {
+                if (!__tree_is_left_child(__w))  // if x is left child
+                {
+                    if (!__w->__is_black_)
+                    {
+                        __w->__is_black_ = true;
+                        __w->__parent_->__is_black_ = false;
+                        __tree_left_rotate(__w->__parent_);
+                        // __x is still valid
+                        // reset __root only if necessary
+                        if (__root == __w->__left_)
+                            __root = __w;
+                        // reset sibling, and it still can't be null
+                        __w = __w->__left_->__right_;
+                    }
+                    // __w->__is_black_ is now true, __w may have null children
+                    if ((__w->__left_  == nullptr || __w->__left_->__is_black_) &&
+                        (__w->__right_ == nullptr || __w->__right_->__is_black_))
+                    {
+                        __w->__is_black_ = false;
+                        __x = __w->__parent_;
+                        // __x can no longer be null
+                        if (__x == __root || !__x->__is_black_)
+                        {
+                            __x->__is_black_ = true;
+                            break;
+                        }
+                        // reset sibling, and it still can't be null
+                        __w = __tree_is_left_child(__x) ?
+                                    __x->__parent_->__right_ :
+                                    __x->__parent_->__left_;
+                        // continue;
+                    }
+                    else  // __w has a red child
+                    {
+                        if (__w->__right_ == nullptr || __w->__right_->__is_black_)
+                        {
+                            // __w left child is non-null and red
+                            __w->__left_->__is_black_ = true;
+                            __w->__is_black_ = false;
+                            __tree_right_rotate(__w);
+                            // __w is known not to be root, so root hasn't changed
+                            // reset sibling, and it still can't be null
+                            __w = __w->__parent_;
+                        }
+                        // __w has a right red child, left child may be null
+                        __w->__is_black_ = __w->__parent_->__is_black_;
+                        __w->__parent_->__is_black_ = true;
+                        __w->__right_->__is_black_ = true;
+                        __tree_left_rotate(__w->__parent_);
+                        break;
+                    }
+                }
+                else
+                {
+                    if (!__w->__is_black_)
+                    {
+                        __w->__is_black_ = true;
+                        __w->__parent_->__is_black_ = false;
+                        __tree_right_rotate(__w->__parent_);
+                        // __x is still valid
+                        // reset __root only if necessary
+                        if (__root == __w->__right_)
+                            __root = __w;
+                        // reset sibling, and it still can't be null
+                        __w = __w->__right_->__left_;
+                    }
+                    // __w->__is_black_ is now true, __w may have null children
+                    if ((__w->__left_  == nullptr || __w->__left_->__is_black_) &&
+                        (__w->__right_ == nullptr || __w->__right_->__is_black_))
+                    {
+                        __w->__is_black_ = false;
+                        __x = __w->__parent_;
+                        // __x can no longer be null
+                        if (!__x->__is_black_ || __x == __root)
+                        {
+                            __x->__is_black_ = true;
+                            break;
+                        }
+                        // reset sibling, and it still can't be null
+                        __w = __tree_is_left_child(__x) ?
+                                    __x->__parent_->__right_ :
+                                    __x->__parent_->__left_;
+                        // continue;
+                    }
+                    else  // __w has a red child
+                    {
+                        if (__w->__left_ == nullptr || __w->__left_->__is_black_)
+                        {
+                            // __w right child is non-null and red
+                            __w->__right_->__is_black_ = true;
+                            __w->__is_black_ = false;
+                            __tree_left_rotate(__w);
+                            // __w is known not to be root, so root hasn't changed
+                            // reset sibling, and it still can't be null
+                            __w = __w->__parent_;
+                        }
+                        // __w has a left red child, right child may be null
+                        __w->__is_black_ = __w->__parent_->__is_black_;
+                        __w->__parent_->__is_black_ = true;
+                        __w->__left_->__is_black_ = true;
+                        __tree_right_rotate(__w->__parent_);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+}
+
+template <class _Allocator> class __map_node_destructor;
+
+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;
+private:
+
+    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) _NOEXCEPT
+        : __na_(__na),
+          __value_constructed(false)
+        {}
+
+    _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);
+    }
+
+    template <class> friend class __map_node_destructor;
+};
+
+// node
+
+template <class _Pointer>
+class __tree_end_node
+{
+public:
+    typedef _Pointer pointer;
+    pointer __left_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __tree_end_node() _NOEXCEPT : __left_() {}
+};
+
+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
+             >
+{
+    __tree_node_base(const __tree_node_base&);
+    __tree_node_base& operator=(const __tree_node_base&);
+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;
+
+    pointer __right_;
+    pointer __parent_;
+    bool __is_black_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __tree_node_base() _NOEXCEPT
+        : __right_(), __parent_(), __is_black_(false) {}
+};
+
+template <class _Tp, class _VoidPtr>
+class __tree_node
+    : public __tree_node_base<_VoidPtr>
+{
+public:
+    typedef __tree_node_base<_VoidPtr> base;
+    typedef _Tp value_type;
+
+    value_type __value_;
+
+#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)
+};
+
+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;
+
+    __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;
+
+    _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+    : __ptr_(nullptr)
+#endif
+    {}
+
+    _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
+    _LIBCPP_INLINE_VISIBILITY pointer operator->() const
+        {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;}
+    _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;}
+    _LIBCPP_INLINE_VISIBILITY
+    __tree_iterator operator--(int)
+        {__tree_iterator __t(*this); --(*this); return __t;}
+
+    friend _LIBCPP_INLINE_VISIBILITY 
+        bool operator==(const __tree_iterator& __x, const __tree_iterator& __y)
+        {return __x.__ptr_ == __y.__ptr_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y)
+        {return !(__x == __y);}
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+    template <class, class, class> friend class __tree;
+    template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_iterator;
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
+    template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY set;
+    template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multiset;
+};
+
+template <class _Tp, class _ConstNodePtr, 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;
+
+    __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;
+
+    _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+    : __ptr_(nullptr)
+#endif
+    {}
+
+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;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT
+        : __ptr_(__p.__ptr_) {}
+
+    _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;}
+    _LIBCPP_INLINE_VISIBILITY pointer operator->() const
+        {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;}
+    _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;}
+    _LIBCPP_INLINE_VISIBILITY
+    __tree_const_iterator operator--(int)
+        {__tree_const_iterator __t(*this); --(*this); return __t;}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y)
+        {return __x.__ptr_ == __y.__ptr_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y)
+        {return !(__x == __y);}
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT
+        : __ptr_(__p) {}
+    template <class, class, class> friend class __tree;
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
+    template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY set;
+    template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multiset;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
+};
+
+template <class _Tp, class _Compare, class _Allocator>
+class __tree
+{
+public:
+    typedef _Tp                                      value_type;
+    typedef _Compare                                 value_compare;
+    typedef _Allocator                               allocator_type;
+    typedef allocator_traits<allocator_type>         __alloc_traits;
+    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;
+
+    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;
+
+    __node_pointer                                          __begin_node_;
+    __compressed_pair<__end_node_t, __node_allocator>  __pair1_;
+    __compressed_pair<size_type, value_compare>        __pair3_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __node_pointer __end_node() _NOEXCEPT
+    {
+        return static_cast<__node_pointer>
+               (
+                   pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())
+               );
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __node_const_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()))
+               );
+    }
+    _LIBCPP_INLINE_VISIBILITY
+          __node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();}
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    const __node_allocator& __node_alloc() const _NOEXCEPT
+        {return __pair1_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+          __node_pointer& __begin_node() _NOEXCEPT {return __begin_node_;}
+    _LIBCPP_INLINE_VISIBILITY
+    const __node_pointer& __begin_node() const _NOEXCEPT {return __begin_node_;}
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type __alloc() const _NOEXCEPT
+        {return allocator_type(__node_alloc());}
+private:
+    _LIBCPP_INLINE_VISIBILITY
+          size_type& size() _NOEXCEPT {return __pair3_.first();}
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    const size_type& size() const _NOEXCEPT {return __pair3_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+          value_compare& value_comp() _NOEXCEPT {return __pair3_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    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_);}
+
+    typedef __tree_iterator<value_type, __node_pointer, difference_type>             iterator;
+    typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator;
+
+    explicit __tree(const value_compare& __comp)
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<__node_allocator>::value &&
+            is_nothrow_copy_constructible<value_compare>::value);
+    explicit __tree(const allocator_type& __a);
+    __tree(const value_compare& __comp, const allocator_type& __a);
+    __tree(const __tree& __t);
+    __tree& operator=(const __tree& __t);
+    template <class _InputIterator>
+        void __assign_unique(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        void __assign_multi(_InputIterator __first, _InputIterator __last);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __tree(__tree&& __t)
+        _NOEXCEPT_(
+            is_nothrow_move_constructible<__node_allocator>::value &&
+            is_nothrow_move_constructible<value_compare>::value);
+    __tree(__tree&& __t, const allocator_type& __a);
+    __tree& operator=(__tree&& __t)
+        _NOEXCEPT_(
+            __node_traits::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<value_compare>::value &&
+            is_nothrow_move_assignable<__node_allocator>::value);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    ~__tree();
+
+    _LIBCPP_INLINE_VISIBILITY
+          iterator begin()  _NOEXCEPT {return       iterator(__begin_node());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return const_iterator(__begin_node());}
+    _LIBCPP_INLINE_VISIBILITY
+          iterator end() _NOEXCEPT {return       iterator(__end_node());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT {return const_iterator(__end_node());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT
+        {return __node_traits::max_size(__node_alloc());}
+
+    void clear() _NOEXCEPT;
+
+    void swap(__tree& __t)
+        _NOEXCEPT_(
+            __is_nothrow_swappable<value_compare>::value &&
+            (!__node_traits::propagate_on_container_swap::value ||
+             __is_nothrow_swappable<__node_allocator>::value));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args>
+        pair<iterator, bool>
+        __emplace_unique(_Args&&... __args);
+    template <class... _Args>
+        iterator
+        __emplace_multi(_Args&&... __args);
+
+    template <class... _Args>
+        iterator
+        __emplace_hint_unique(const_iterator __p, _Args&&... __args);
+    template <class... _Args>
+        iterator
+        __emplace_hint_multi(const_iterator __p, _Args&&... __args);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    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);
+    template <class _Vp>
+        iterator __insert_multi(const_iterator __p, _Vp&& __v);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    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);
+
+    pair<iterator, bool> __node_insert_unique(__node_pointer __nd);
+    iterator             __node_insert_unique(const_iterator __p,
+                                              __node_pointer __nd);
+
+    iterator __node_insert_multi(__node_pointer __nd);
+    iterator __node_insert_multi(const_iterator __p, __node_pointer __nd);
+
+    iterator erase(const_iterator __p);
+    iterator erase(const_iterator __f, const_iterator __l);
+    template <class _Key>
+        size_type __erase_unique(const _Key& __k);
+    template <class _Key>
+        size_type __erase_multi(const _Key& __k);
+
+    void __insert_node_at(__node_base_pointer __parent,
+                          __node_base_pointer& __child,
+                          __node_base_pointer __new_node);
+
+    template <class _Key>
+        iterator find(const _Key& __v);
+    template <class _Key>
+        const_iterator find(const _Key& __v) const;
+
+    template <class _Key>
+        size_type __count_unique(const _Key& __k) const;
+    template <class _Key>
+        size_type __count_multi(const _Key& __k) const;
+
+    template <class _Key>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator lower_bound(const _Key& __v)
+            {return __lower_bound(__v, __root(), __end_node());}
+    template <class _Key>
+        iterator __lower_bound(const _Key& __v,
+                               __node_pointer __root,
+                               __node_pointer __result);
+    template <class _Key>
+        _LIBCPP_INLINE_VISIBILITY
+        const_iterator lower_bound(const _Key& __v) const
+            {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;
+    template <class _Key>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator upper_bound(const _Key& __v)
+            {return __upper_bound(__v, __root(), __end_node());}
+    template <class _Key>
+        iterator __upper_bound(const _Key& __v,
+                               __node_pointer __root,
+                               __node_pointer __result);
+    template <class _Key>
+        _LIBCPP_INLINE_VISIBILITY
+        const_iterator upper_bound(const _Key& __v) const
+            {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;
+    template <class _Key>
+        pair<iterator, iterator>
+        __equal_range_unique(const _Key& __k);
+    template <class _Key>
+        pair<const_iterator, const_iterator>
+        __equal_range_unique(const _Key& __k) const;
+
+    template <class _Key>
+        pair<iterator, iterator>
+        __equal_range_multi(const _Key& __k);
+    template <class _Key>
+        pair<const_iterator, const_iterator>
+        __equal_range_multi(const _Key& __k) const;
+
+    typedef __tree_node_destructor<__node_allocator> _Dp;
+    typedef unique_ptr<__node, _Dp> __node_holder;
+
+    __node_holder remove(const_iterator __p) _NOEXCEPT;
+private:
+    typename __node_base::pointer&
+        __find_leaf_low(typename __node_base::pointer& __parent, const value_type& __v);
+    typename __node_base::pointer&
+        __find_leaf_high(typename __node_base::pointer& __parent, const value_type& __v);
+    typename __node_base::pointer&
+        __find_leaf(const_iterator __hint,
+                    typename __node_base::pointer& __parent, const value_type& __v);
+    template <class _Key>
+        typename __node_base::pointer&
+        __find_equal(typename __node_base::pointer& __parent, const _Key& __v);
+    template <class _Key>
+        typename __node_base::pointer&
+        __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)
+    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);
+#endif
+
+    void destroy(__node_pointer __nd) _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __tree& __t)
+        {__copy_assign_alloc(__t, integral_constant<bool,
+             __node_traits::propagate_on_container_copy_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __tree& __t, true_type)
+        {__node_alloc() = __t.__node_alloc();}
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __tree& __t, false_type) {}
+
+    void __move_assign(__tree& __t, false_type);
+    void __move_assign(__tree& __t, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
+                   is_nothrow_move_assignable<__node_allocator>::value);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__tree& __t)
+        _NOEXCEPT_(
+            !__node_traits::propagate_on_container_move_assignment::value ||
+            is_nothrow_move_assignable<__node_allocator>::value)
+        {__move_assign_alloc(__t, integral_constant<bool,
+             __node_traits::propagate_on_container_move_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__tree& __t, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
+        {__node_alloc() = _VSTD::move(__t.__node_alloc());}
+    _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);
+
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
+};
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp)
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<__node_allocator>::value &&
+            is_nothrow_copy_constructible<value_compare>::value)
+    : __pair3_(0, __comp)
+{
+    __begin_node() = __end_node();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
+    : __pair1_(__node_allocator(__a)),
+      __begin_node_(__node_pointer()),
+      __pair3_(0)
+{
+    __begin_node() = __end_node();
+}
+
+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()),
+      __pair3_(0, __comp)
+{
+    __begin_node() = __end_node();
+}
+
+// Precondition:  size() != 0
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
+__tree<_Tp, _Compare, _Allocator>::__detach()
+{
+    __node_pointer __cache = __begin_node();
+    __begin_node() = __end_node();
+    __end_node()->__left_->__parent_ = nullptr;
+    __end_node()->__left_ = nullptr;
+    size() = 0;
+    // __cache->__left_ == nullptr
+    if (__cache->__right_ != nullptr)
+        __cache = static_cast<__node_pointer>(__cache->__right_);
+    // __cache->__left_ == nullptr
+    // __cache->__right_ == nullptr
+    return __cache;
+}
+
+// Precondition:  __cache != nullptr
+//    __cache->left_ == nullptr
+//    __cache->right_ == nullptr
+//    This is no longer a red-black tree
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
+__tree<_Tp, _Compare, _Allocator>::__detach(__node_pointer __cache)
+{
+    if (__cache->__parent_ == nullptr)
+        return nullptr;
+    if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache)))
+    {
+        __cache->__parent_->__left_ = nullptr;
+        __cache = static_cast<__node_pointer>(__cache->__parent_);
+        if (__cache->__right_ == nullptr)
+            return __cache;
+        return static_cast<__node_pointer>(__tree_leaf(__cache->__right_));
+    }
+    // __cache is right child
+    __cache->__parent_->__right_ = nullptr;
+    __cache = static_cast<__node_pointer>(__cache->__parent_);
+    if (__cache->__left_ == nullptr)
+        return __cache;
+    return static_cast<__node_pointer>(__tree_leaf(__cache->__left_));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>&
+__tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t)
+{
+    if (this != &__t)
+    {
+        value_comp() = __t.value_comp();
+        __copy_assign_alloc(__t);
+        __assign_multi(__t.begin(), __t.end());
+    }
+    return *this;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _InputIterator>
+void
+__tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _InputIterator __last)
+{
+    if (size() != 0)
+    {
+        __node_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __cache != nullptr && __first != __last; ++__first)
+            {
+                __cache->__value_ = *__first;
+                __node_pointer __next = __detach(__cache);
+                __node_insert_unique(__cache);
+                __cache = __next;
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (__cache->__parent_ != nullptr)
+                __cache = static_cast<__node_pointer>(__cache->__parent_);
+            destroy(__cache);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        if (__cache != nullptr)
+        {
+            while (__cache->__parent_ != nullptr)
+                __cache = static_cast<__node_pointer>(__cache->__parent_);
+            destroy(__cache);
+        }
+    }
+    for (; __first != __last; ++__first)
+        __insert_unique(*__first);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _InputIterator>
+void
+__tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last)
+{
+    if (size() != 0)
+    {
+        __node_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __cache != nullptr && __first != __last; ++__first)
+            {
+                __cache->__value_ = *__first;
+                __node_pointer __next = __detach(__cache);
+                __node_insert_multi(__cache);
+                __cache = __next;
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (__cache->__parent_ != nullptr)
+                __cache = static_cast<__node_pointer>(__cache->__parent_);
+            destroy(__cache);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        if (__cache != nullptr)
+        {
+            while (__cache->__parent_ != nullptr)
+                __cache = static_cast<__node_pointer>(__cache->__parent_);
+            destroy(__cache);
+        }
+    }
+    for (; __first != __last; ++__first)
+        __insert_multi(*__first);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
+    : __begin_node_(__node_pointer()),
+      __pair1_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),
+      __pair3_(0, __t.value_comp())
+{
+    __begin_node() = __end_node();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t)
+    _NOEXCEPT_(
+        is_nothrow_move_constructible<__node_allocator>::value &&
+        is_nothrow_move_constructible<value_compare>::value)
+    : __begin_node_(_VSTD::move(__t.__begin_node_)),
+      __pair1_(_VSTD::move(__t.__pair1_)),
+      __pair3_(_VSTD::move(__t.__pair3_))
+{
+    if (size() == 0)
+        __begin_node() = __end_node();
+    else
+    {
+        __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
+        __t.__begin_node() = __t.__end_node();
+        __t.__end_node()->__left_ = nullptr;
+        __t.size() = 0;
+    }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
+    : __pair1_(__node_allocator(__a)),
+      __pair3_(0, _VSTD::move(__t.value_comp()))
+{
+    if (__a == __t.__alloc())
+    {
+        if (__t.size() == 0)
+            __begin_node() = __end_node();
+        else
+        {
+            __begin_node() = __t.__begin_node();
+            __end_node()->__left_ = __t.__end_node()->__left_;
+            __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
+            size() = __t.size();
+            __t.__begin_node() = __t.__end_node();
+            __t.__end_node()->__left_ = nullptr;
+            __t.size() = 0;
+        }
+    }
+    else
+    {
+        __begin_node() = __end_node();
+    }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
+    _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
+               is_nothrow_move_assignable<__node_allocator>::value)
+{
+    destroy(static_cast<__node_pointer>(__end_node()->__left_));
+    __begin_node_ = __t.__begin_node_;
+    __pair1_.first() = __t.__pair1_.first();
+    __move_assign_alloc(__t);
+    __pair3_ = _VSTD::move(__t.__pair3_);
+    if (size() == 0)
+        __begin_node() = __end_node();
+    else
+    {
+        __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
+        __t.__begin_node() = __t.__end_node();
+        __t.__end_node()->__left_ = nullptr;
+        __t.size() = 0;
+    }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type)
+{
+    if (__node_alloc() == __t.__node_alloc())
+        __move_assign(__t, true_type());
+    else
+    {
+        value_comp() = _VSTD::move(__t.value_comp());
+        const_iterator __e = end();
+        if (size() != 0)
+        {
+            __node_pointer __cache = __detach();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            try
+            {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                while (__cache != nullptr && __t.size() != 0)
+                {
+                    __cache->__value_ = _VSTD::move(__t.remove(__t.begin())->__value_);
+                    __node_pointer __next = __detach(__cache);
+                    __node_insert_multi(__cache);
+                    __cache = __next;
+                }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            }
+            catch (...)
+            {
+                while (__cache->__parent_ != nullptr)
+                    __cache = static_cast<__node_pointer>(__cache->__parent_);
+                destroy(__cache);
+                throw;
+            }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            if (__cache != nullptr)
+            {
+                while (__cache->__parent_ != nullptr)
+                    __cache = static_cast<__node_pointer>(__cache->__parent_);
+                destroy(__cache);
+            }
+        }
+        while (__t.size() != 0)
+            __insert_multi(__e, _VSTD::move(__t.remove(__t.begin())->__value_));
+    }
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>&
+__tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)
+    _NOEXCEPT_(
+        __node_traits::propagate_on_container_move_assignment::value &&
+        is_nothrow_move_assignable<value_compare>::value &&
+        is_nothrow_move_assignable<__node_allocator>::value)
+        
+{
+    __move_assign(__t, integral_constant<bool,
+                  __node_traits::propagate_on_container_move_assignment::value>());
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Compare, class _Allocator>
+__tree<_Tp, _Compare, _Allocator>::~__tree()
+{
+    destroy(__root());
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT
+{
+    if (__nd != nullptr)
+    {
+        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::deallocate(__na, __nd, 1);
+    }
+}
+
+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))
+{
+    using _VSTD::swap;
+    swap(__begin_node_, __t.__begin_node_);
+    swap(__pair1_.first(), __t.__pair1_.first());
+    __swap_alloc(__node_alloc(), __t.__node_alloc());
+    __pair3_.swap(__t.__pair3_);
+    if (size() == 0)
+        __begin_node() = __end_node();
+    else
+        __end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__end_node());
+    if (__t.size() == 0)
+        __t.__begin_node() = __t.__end_node();
+    else
+        __t.__end_node()->__left_->__parent_ = static_cast<__node_base_pointer>(__t.__end_node());
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT
+{
+    destroy(__root());
+    size() = 0;
+    __begin_node() = __end_node();
+    __end_node()->__left_ = nullptr;
+}
+
+// Find lower_bound place to insert
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+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)
+{
+    __node_pointer __nd = __root();
+    if (__nd != nullptr)
+    {
+        while (true)
+        {
+            if (value_comp()(__nd->__value_, __v))
+            {
+                if (__nd->__right_ != nullptr)
+                    __nd = static_cast<__node_pointer>(__nd->__right_);
+                else
+                {
+                    __parent = static_cast<__node_base_pointer>(__nd);
+                    return __parent->__right_;
+                }
+            }
+            else
+            {
+                if (__nd->__left_ != nullptr)
+                    __nd = static_cast<__node_pointer>(__nd->__left_);
+                else
+                {
+                    __parent = static_cast<__node_base_pointer>(__nd);
+                    return __parent->__left_;
+                }
+            }
+        }
+    }
+    __parent = static_cast<__node_base_pointer>(__end_node());
+    return __parent->__left_;
+}
+
+// Find upper_bound place to insert
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+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)
+{
+    __node_pointer __nd = __root();
+    if (__nd != nullptr)
+    {
+        while (true)
+        {
+            if (value_comp()(__v, __nd->__value_))
+            {
+                if (__nd->__left_ != nullptr)
+                    __nd = static_cast<__node_pointer>(__nd->__left_);
+                else
+                {
+                    __parent = static_cast<__node_base_pointer>(__nd);
+                    return __parent->__left_;
+                }
+            }
+            else
+            {
+                if (__nd->__right_ != nullptr)
+                    __nd = static_cast<__node_pointer>(__nd->__right_);
+                else
+                {
+                    __parent = static_cast<__node_base_pointer>(__nd);
+                    return __parent->__right_;
+                }
+            }
+        }
+    }
+    __parent = static_cast<__node_base_pointer>(__end_node());
+    return __parent->__left_;
+}
+
+// Find leaf place to insert closest to __hint
+// First check prior to __hint.
+// Next check after __hint.
+// Next do O(log N) search.
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+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)
+{
+    if (__hint == end() || !value_comp()(*__hint, __v))  // check before
+    {
+        // __v <= *__hint
+        const_iterator __prior = __hint;
+        if (__prior == begin() || !value_comp()(__v, *--__prior))
+        {
+            // *prev(__hint) <= __v <= *__hint
+            if (__hint.__ptr_->__left_ == nullptr)
+            {
+                __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
+                return __parent->__left_;
+            }
+            else
+            {
+                __parent = static_cast<__node_base_pointer>(__prior.__ptr_);
+                return __parent->__right_;
+            }
+        }
+        // __v < *prev(__hint)
+        return __find_leaf_high(__parent, __v);
+    }
+    // else __v > *__hint
+    return __find_leaf_low(__parent, __v);
+}
+
+// Find place to insert if __v doesn't exist
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+// If __v exists, set parent to node of __v and return reference to node of __v
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_equal(typename __node_base::pointer& __parent,
+                                                const _Key& __v)
+{
+    __node_pointer __nd = __root();
+    if (__nd != nullptr)
+    {
+        while (true)
+        {
+            if (value_comp()(__v, __nd->__value_))
+            {
+                if (__nd->__left_ != nullptr)
+                    __nd = static_cast<__node_pointer>(__nd->__left_);
+                else
+                {
+                    __parent = static_cast<__node_base_pointer>(__nd);
+                    return __parent->__left_;
+                }
+            }
+            else if (value_comp()(__nd->__value_, __v))
+            {
+                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>(__end_node());
+    return __parent->__left_;
+}
+
+// Find place to insert if __v doesn't exist
+// First check prior to __hint.
+// Next check after __hint.
+// Next do O(log N) search.
+// Set __parent to parent of null leaf
+// Return reference to null leaf
+// If __v exists, set parent to node of __v and return reference to node of __v
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::__node_base::pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint,
+                                                typename __node_base::pointer& __parent,
+                                                const _Key& __v)
+{
+    if (__hint == end() || value_comp()(__v, *__hint))  // check before
+    {
+        // __v < *__hint
+        const_iterator __prior = __hint;
+        if (__prior == begin() || value_comp()(*--__prior, __v))
+        {
+            // *prev(__hint) < __v < *__hint
+            if (__hint.__ptr_->__left_ == nullptr)
+            {
+                __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
+                return __parent->__left_;
+            }
+            else
+            {
+                __parent = static_cast<__node_base_pointer>(__prior.__ptr_);
+                return __parent->__right_;
+            }
+        }
+        // __v <= *prev(__hint)
+        return __find_equal(__parent, __v);
+    }
+    else if (value_comp()(*__hint, __v))  // check after
+    {
+        // *__hint < __v
+        const_iterator __next = _VSTD::next(__hint);
+        if (__next == end() || value_comp()(__v, *__next))
+        {
+            // *__hint < __v < *_VSTD::next(__hint)
+            if (__hint.__ptr_->__right_ == nullptr)
+            {
+                __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
+                return __parent->__right_;
+            }
+            else
+            {
+                __parent = static_cast<__node_base_pointer>(__next.__ptr_);
+                return __parent->__left_;
+            }
+        }
+        // *next(__hint) <= __v
+        return __find_equal(__parent, __v);
+    }
+    // else __v == *__hint
+    __parent = static_cast<__node_base_pointer>(__hint.__ptr_);
+    return __parent;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+void
+__tree<_Tp, _Compare, _Allocator>::__insert_node_at(__node_base_pointer __parent,
+                                                    __node_base_pointer& __child,
+                                                    __node_base_pointer __new_node)
+{
+    __new_node->__left_   = nullptr;
+    __new_node->__right_  = nullptr;
+    __new_node->__parent_ = __parent;
+    __child = __new_node;
+    if (__begin_node()->__left_ != nullptr)
+        __begin_node() = static_cast<__node_pointer>(__begin_node()->__left_);
+    __tree_balance_after_insert(__end_node()->__left_, __child);
+    ++size();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+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)
+{
+    __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)...);
+    __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)
+{
+    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_equal(__parent, __h->__value_);
+    __node_pointer __r = static_cast<__node_pointer>(__child);
+    bool __inserted = false;
+    if (__child == nullptr)
+    {
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+        __r = __h.release();
+        __inserted = true;
+    }
+    return pair<iterator, bool>(iterator(__r), __inserted);
+}
+
+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)
+{
+    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_equal(__p, __parent, __h->__value_);
+    __node_pointer __r = static_cast<__node_pointer>(__child);
+    if (__child == nullptr)
+    {
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+        __r = __h.release();
+    }
+    return iterator(__r);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class... _Args>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__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_);
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+    return iterator(static_cast<__node_pointer>(__h.release()));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class... _Args>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p,
+                                                        _Args&&... __args)
+{
+    __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...);
+    __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(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
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_holder
+__tree<_Tp, _Compare, _Allocator>::__construct_node(const 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);
+    __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);
+}
+
+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);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__insert_multi(const value_type& __v)
+{
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_leaf_high(__parent, __v);
+    __node_holder __h = __construct_node(__v);
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+    return iterator(__h.release());
+}
+
+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)
+{
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_leaf(__p, __parent, __v);
+    __node_holder __h = __construct_node(__v);
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+    return iterator(__h.release());
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd)
+{
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_equal(__parent, __nd->__value_);
+    __node_pointer __r = static_cast<__node_pointer>(__child);
+    bool __inserted = false;
+    if (__child == nullptr)
+    {
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+        __r = __nd;
+        __inserted = true;
+    }
+    return pair<iterator, bool>(iterator(__r), __inserted);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(const_iterator __p,
+                                                        __node_pointer __nd)
+{
+    __node_base_pointer __parent;
+    __node_base_pointer& __child = __find_equal(__p, __parent, __nd->__value_);
+    __node_pointer __r = static_cast<__node_pointer>(__child);
+    if (__child == nullptr)
+    {
+        __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+        __r = __nd;
+    }
+    return iterator(__r);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+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_);
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+    return iterator(__nd);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__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_);
+    __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+    return iterator(__nd);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p)
+{
+    __node_pointer __np = __p.__ptr_;
+    iterator __r(__np);
+    ++__r;
+    if (__begin_node() == __np)
+        __begin_node() = __r.__ptr_;
+    --size();
+    __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::deallocate(__na, __np, 1);
+    return __r;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l)
+{
+    while (__f != __l)
+        __f = erase(__f);
+    return iterator(__l.__ptr_);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::size_type
+__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k)
+{
+    iterator __i = find(__k);
+    if (__i == end())
+        return 0;
+    erase(__i);
+    return 1;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::size_type
+__tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k)
+{
+    pair<iterator, iterator> __p = __equal_range_multi(__k);
+    size_type __r = 0;
+    for (; __p.first != __p.second; ++__r)
+        __p.first = erase(__p.first);
+    return __r;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v)
+{
+    iterator __p = __lower_bound(__v, __root(), __end_node());
+    if (__p != end() && !value_comp()(__v, *__p))
+        return __p;
+    return end();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::const_iterator
+__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const
+{
+    const_iterator __p = __lower_bound(__v, __root(), __end_node());
+    if (__p != end() && !value_comp()(__v, *__p))
+        return __p;
+    return end();
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+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();
+    while (__rt != nullptr)
+    {
+        if (value_comp()(__k, __rt->__value_))
+        {
+            __result = __rt;
+            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+        }
+        else if (value_comp()(__rt->__value_, __k))
+            __rt = static_cast<__node_const_pointer>(__rt->__right_);
+        else
+            return 1;
+    }
+    return 0;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+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();
+    while (__rt != nullptr)
+    {
+        if (value_comp()(__k, __rt->__value_))
+        {
+            __result = __rt;
+            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+        }
+        else if (value_comp()(__rt->__value_, __k))
+            __rt = static_cast<__node_const_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)
+            );
+    }
+    return 0;
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v,
+                                                 __node_pointer __root,
+                                                 __node_pointer __result)
+{
+    while (__root != nullptr)
+    {
+        if (!value_comp()(__root->__value_, __v))
+        {
+            __result = __root;
+            __root = static_cast<__node_pointer>(__root->__left_);
+        }
+        else
+            __root = static_cast<__node_pointer>(__root->__right_);
+    }
+    return iterator(__result);
+}
+
+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
+{
+    while (__root != nullptr)
+    {
+        if (!value_comp()(__root->__value_, __v))
+        {
+            __result = __root;
+            __root = static_cast<__node_const_pointer>(__root->__left_);
+        }
+        else
+            __root = static_cast<__node_const_pointer>(__root->__right_);
+    }
+    return const_iterator(__result);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v,
+                                                 __node_pointer __root,
+                                                 __node_pointer __result)
+{
+    while (__root != nullptr)
+    {
+        if (value_comp()(__v, __root->__value_))
+        {
+            __result = __root;
+            __root = static_cast<__node_pointer>(__root->__left_);
+        }
+        else
+            __root = static_cast<__node_pointer>(__root->__right_);
+    }
+    return iterator(__result);
+}
+
+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
+{
+    while (__root != nullptr)
+    {
+        if (value_comp()(__v, __root->__value_))
+        {
+            __result = __root;
+            __root = static_cast<__node_const_pointer>(__root->__left_);
+        }
+        else
+            __root = static_cast<__node_const_pointer>(__root->__right_);
+    }
+    return const_iterator(__result);
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator,
+     typename __tree<_Tp, _Compare, _Allocator>::iterator>
+__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k)
+{
+    typedef pair<iterator, iterator> _Pp;
+    __node_pointer __result = __end_node();
+    __node_pointer __rt = __root();
+    while (__rt != nullptr)
+    {
+        if (value_comp()(__k, __rt->__value_))
+        {
+            __result = __rt;
+            __rt = static_cast<__node_pointer>(__rt->__left_);
+        }
+        else if (value_comp()(__rt->__value_, __k))
+            __rt = static_cast<__node_pointer>(__rt->__right_);
+        else
+            return _Pp(iterator(__rt),
+                      iterator(
+                          __rt->__right_ != nullptr ?
+                              static_cast<__node_pointer>(__tree_min(__rt->__right_))
+                            : __result));
+    }
+    return _Pp(iterator(__result), iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
+     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();
+    while (__rt != nullptr)
+    {
+        if (value_comp()(__k, __rt->__value_))
+        {
+            __result = __rt;
+            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+        }
+        else if (value_comp()(__rt->__value_, __k))
+            __rt = static_cast<__node_const_pointer>(__rt->__right_);
+        else
+            return _Pp(const_iterator(__rt),
+                      const_iterator(
+                          __rt->__right_ != nullptr ?
+                              static_cast<__node_const_pointer>(__tree_min(__rt->__right_))
+                            : __result));
+    }
+    return _Pp(const_iterator(__result), const_iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator,
+     typename __tree<_Tp, _Compare, _Allocator>::iterator>
+__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k)
+{
+    typedef pair<iterator, iterator> _Pp;
+    __node_pointer __result = __end_node();
+    __node_pointer __rt = __root();
+    while (__rt != nullptr)
+    {
+        if (value_comp()(__k, __rt->__value_))
+        {
+            __result = __rt;
+            __rt = static_cast<__node_pointer>(__rt->__left_);
+        }
+        else if (value_comp()(__rt->__value_, __k))
+            __rt = static_cast<__node_pointer>(__rt->__right_);
+        else
+            return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), __rt),
+                      __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
+    }
+    return _Pp(iterator(__result), iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+template <class _Key>
+pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
+     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();
+    while (__rt != nullptr)
+    {
+        if (value_comp()(__k, __rt->__value_))
+        {
+            __result = __rt;
+            __rt = static_cast<__node_const_pointer>(__rt->__left_);
+        }
+        else if (value_comp()(__rt->__value_, __k))
+            __rt = static_cast<__node_const_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(const_iterator(__result), const_iterator(__result));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+typename __tree<_Tp, _Compare, _Allocator>::__node_holder
+__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT
+{
+    __node_pointer __np = __p.__ptr_;
+    if (__begin_node() == __np)
+    {
+        if (__np->__right_ != nullptr)
+            __begin_node() = static_cast<__node_pointer>(__np->__right_);
+        else
+            __begin_node() = static_cast<__node_pointer>(__np->__parent_);
+    }
+    --size();
+    __tree_remove(__end_node()->__left_,
+                  static_cast<__node_base_pointer>(__np));
+    return __node_holder(__np, _Dp(__node_alloc()));
+}
+
+template <class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__tree<_Tp, _Compare, _Allocator>& __x,
+     __tree<_Tp, _Compare, _Allocator>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___TREE
diff --git a/final/include/__tuple b/final/include/__tuple
new file mode 100644
index 0000000..de35cb8
--- /dev/null
+++ b/final/include/__tuple
@@ -0,0 +1,305 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TUPLE
+#define _LIBCPP___TUPLE
+
+#include <__config>
+#include <cstddef>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#ifdef _LIBCPP_HAS_NO_VARIADICS
+
+#include <__tuple_03>
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_size<const _Tp>
+    : public tuple_size<_Tp> {};
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_size<volatile _Tp>
+    : public tuple_size<_Tp> {};
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_size<const volatile _Tp>
+    : public tuple_size<_Tp> {};
+
+template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element;
+
+template <size_t _Ip, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const _Tp>
+{
+public:
+    typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+template <size_t _Ip, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, volatile _Tp>
+{
+public:
+    typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
+};
+
+template <size_t _Ip, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const volatile _Tp>
+{
+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> {};
+
+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
+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;
+
+template <size_t _Ip, class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(tuple<_Tp...>&&) _NOEXCEPT;
+
+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;
+
+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 _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;
+
+template <size_t _Ip, class _Tp, size_t _Size>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&&
+get(array<_Tp, _Size>&&) _NOEXCEPT;
+
+// __make_tuple_indices
+
+template <size_t...> struct __tuple_indices {};
+
+template <size_t _Sp, class _IntTuple, size_t _Ep>
+struct __make_indices_imp;
+
+template <size_t _Sp, size_t ..._Indices, size_t _Ep>
+struct __make_indices_imp<_Sp, __tuple_indices<_Indices...>, _Ep>
+{
+    typedef typename __make_indices_imp<_Sp+1, __tuple_indices<_Indices..., _Sp>, _Ep>::type type;
+};
+
+template <size_t _Ep, size_t ..._Indices>
+struct __make_indices_imp<_Ep, __tuple_indices<_Indices...>, _Ep>
+{
+    typedef __tuple_indices<_Indices...> type;
+};
+
+template <size_t _Ep, size_t _Sp = 0>
+struct __make_tuple_indices
+{
+    static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
+    typedef typename __make_indices_imp<_Sp, __tuple_indices<>, _Ep>::type type;
+};
+
+// __tuple_types
+
+template <class ..._Tp> struct __tuple_types {};
+
+template <size_t _Ip>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<> >
+{
+public:
+    static_assert(_Ip == 0, "tuple_element index out of range");
+    static_assert(_Ip != 0, "tuple_element index out of range");
+};
+
+template <class _Hp, class ..._Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, __tuple_types<_Hp, _Tp...> >
+{
+public:
+    typedef _Hp type;
+};
+
+template <size_t _Ip, class _Hp, class ..._Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<_Hp, _Tp...> >
+{
+public:
+    typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...> >::type type;
+};
+
+template <class ..._Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_size<__tuple_types<_Tp...> >
+    : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
+
+// __make_tuple_types
+
+// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
+// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
+// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>.  If _Tuple is a
+// lvalue_reference type, then __tuple_types<_Types&...> is the result.
+
+template <class _TupleTypes, class _Tp, size_t _Sp, size_t _Ep>
+struct __make_tuple_types_imp;
+
+template <class ..._Types, class _Tp, size_t _Sp, size_t _Ep>
+struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Sp, _Ep>
+{
+    typedef typename remove_reference<_Tp>::type _Tpr;
+    typedef typename __make_tuple_types_imp<__tuple_types<_Types...,
+                                            typename conditional<is_lvalue_reference<_Tp>::value,
+                                                typename tuple_element<_Sp, _Tpr>::type&,
+                                                typename tuple_element<_Sp, _Tpr>::type>::type>,
+                                            _Tp, _Sp+1, _Ep>::type type;
+};
+
+template <class ..._Types, class _Tp, size_t _Ep>
+struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Ep, _Ep>
+{
+    typedef __tuple_types<_Types...> type;
+};
+
+template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value, size_t _Sp = 0>
+struct __make_tuple_types
+{
+    static_assert(_Sp <= _Ep, "__make_tuple_types input error");
+    typedef typename __make_tuple_types_imp<__tuple_types<>, _Tp, _Sp, _Ep>::type type;
+};
+
+// __tuple_convertible
+
+template <bool, class _Tp, class _Up>
+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...> >
+    : public integral_constant<bool,
+                               is_convertible<_Tp0, _Up0>::value &&
+                               __tuple_convertible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
+
+template <>
+struct __tuple_convertible_imp<true, __tuple_types<>, __tuple_types<> >
+    : public true_type {};
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+                                bool = __tuple_like<_Up>::value>
+struct __tuple_convertible
+    : public false_type {};
+
+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>
+{};
+
+// __tuple_constructible
+
+template <bool, class _Tp, class _Up>
+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...> >
+    : public integral_constant<bool,
+                               is_constructible<_Up0, _Tp0>::value &&
+                               __tuple_constructible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
+
+template <>
+struct __tuple_constructible_imp<true, __tuple_types<>, __tuple_types<> >
+    : public true_type {};
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+                                bool = __tuple_like<_Up>::value>
+struct __tuple_constructible
+    : public false_type {};
+
+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>
+{};
+
+// __tuple_assignable
+
+template <bool, class _Tp, class _Up>
+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...> >
+    : public integral_constant<bool,
+                               is_assignable<_Up0&, _Tp0>::value &&
+                               __tuple_assignable_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
+
+template <>
+struct __tuple_assignable_imp<true, __tuple_types<>, __tuple_types<> >
+    : public true_type {};
+
+template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
+                                bool = __tuple_like<_Up>::value>
+struct __tuple_assignable
+    : public false_type {};
+
+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>
+{};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+#endif  // _LIBCPP___TUPLE
diff --git a/final/include/__tuple_03 b/final/include/__tuple_03
new file mode 100644
index 0000000..b91c2cd
--- /dev/null
+++ b/final/include/__tuple_03
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___TUPLE_03
+#define _LIBCPP___TUPLE_03
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
+template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP___TUPLE_03
diff --git a/final/include/__undef_min_max b/final/include/__undef_min_max
new file mode 100644
index 0000000..5df9412
--- /dev/null
+++ b/final/include/__undef_min_max
@@ -0,0 +1,29 @@
+// -*- 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 min
+#if defined(_MSC_VER) && ! defined(__clang__)
+_LIBCPP_WARNING("macro min is incompatible with C++.  Try #define NOMINMAX "
+                "before any Windows header. #undefing min")
+#else
+#warning: macro min is incompatible with C++.  #undefing min
+#endif
+#undef min
+#endif
+
+#ifdef max
+#if defined(_MSC_VER) && ! defined(__clang__)
+_LIBCPP_WARNING("macro max is incompatible with C++.  Try #define NOMINMAX "
+                "before any Windows header. #undefing max")
+#else
+#warning: macro max is incompatible with C++.  #undefing max
+#endif
+#undef max
+#endif
diff --git a/final/include/algorithm b/final/include/algorithm
new file mode 100644
index 0000000..3b74a6b
--- /dev/null
+++ b/final/include/algorithm
@@ -0,0 +1,5749 @@
+// -*- 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_ALGORITHM
+#define _LIBCPP_ALGORITHM
+
+/*
+    algorithm synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+template <class InputIterator, class Predicate>
+    bool
+    all_of(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator, class Predicate>
+    bool
+    any_of(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator, class Predicate>
+    bool
+    none_of(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator, class Function>
+    Function
+    for_each(InputIterator first, InputIterator last, Function f);
+
+template <class InputIterator, class T>
+    InputIterator
+    find(InputIterator first, InputIterator last, const T& value);
+
+template <class InputIterator, class Predicate>
+    InputIterator
+    find_if(InputIterator first, InputIterator last, Predicate pred);
+
+template<class InputIterator, class Predicate>
+    InputIterator
+    find_if_not(InputIterator first, InputIterator last, Predicate pred);
+
+template <class ForwardIterator1, class ForwardIterator2>
+    ForwardIterator1
+    find_end(ForwardIterator1 first1, ForwardIterator1 last1,
+             ForwardIterator2 first2, ForwardIterator2 last2);
+
+template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+    ForwardIterator1
+    find_end(ForwardIterator1 first1, ForwardIterator1 last1,
+             ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
+
+template <class ForwardIterator1, class ForwardIterator2>
+    ForwardIterator1
+    find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
+                  ForwardIterator2 first2, ForwardIterator2 last2);
+
+template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+    ForwardIterator1
+    find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
+                  ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
+
+template <class ForwardIterator>
+    ForwardIterator
+    adjacent_find(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class BinaryPredicate>
+    ForwardIterator
+    adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
+
+template <class InputIterator, class T>
+    typename iterator_traits<InputIterator>::difference_type
+    count(InputIterator first, InputIterator last, const T& value);
+
+template <class InputIterator, class Predicate>
+    typename iterator_traits<InputIterator>::difference_type
+    count_if(InputIterator first, InputIterator last, Predicate pred);
+
+template <class InputIterator1, class InputIterator2>
+    pair<InputIterator1, InputIterator2>
+    mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
+
+template <class InputIterator1, class InputIterator2>
+    pair<InputIterator1, InputIterator2>
+    mismatch(InputIterator1 first1, InputIterator1 last1, 
+             InputIterator2 first2, InputIterator2 last2); // **C++14**
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+    pair<InputIterator1, InputIterator2>
+    mismatch(InputIterator1 first1, InputIterator1 last1,
+             InputIterator2 first2, BinaryPredicate pred);
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+    pair<InputIterator1, InputIterator2>
+    mismatch(InputIterator1 first1, InputIterator1 last1,
+             InputIterator2 first2, InputIterator2 last2,
+             BinaryPredicate pred); // **C++14**
+
+template <class InputIterator1, class InputIterator2>
+    bool
+    equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
+
+template <class InputIterator1, class InputIterator2>
+    bool
+    equal(InputIterator1 first1, InputIterator1 last1, 
+          InputIterator2 first2, InputIterator2 last2); // **C++14**
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+    bool
+    equal(InputIterator1 first1, InputIterator1 last1,
+          InputIterator2 first2, BinaryPredicate pred);
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+    bool
+    equal(InputIterator1 first1, InputIterator1 last1,
+          InputIterator2 first2, InputIterator2 last2,
+          BinaryPredicate pred); // **C++14**
+
+template<class ForwardIterator1, class ForwardIterator2>
+    bool
+    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+                   ForwardIterator2 first2);
+
+template<class ForwardIterator1, class ForwardIterator2>
+    bool
+    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+                   ForwardIterator2 first2, ForwardIterator2 last2); // **C++14**
+
+template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+    bool
+    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+                   ForwardIterator2 first2, BinaryPredicate pred);
+
+template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+    bool
+    is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+                   ForwardIterator2 first2, ForwardIterator2 last2,
+                   BinaryPredicate pred);  // **C++14**
+
+template <class ForwardIterator1, class ForwardIterator2>
+    ForwardIterator1
+    search(ForwardIterator1 first1, ForwardIterator1 last1,
+           ForwardIterator2 first2, ForwardIterator2 last2);
+
+template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+    ForwardIterator1
+    search(ForwardIterator1 first1, ForwardIterator1 last1,
+           ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
+
+template <class ForwardIterator, class Size, class T>
+    ForwardIterator
+    search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
+
+template <class ForwardIterator, class Size, class T, class BinaryPredicate>
+    ForwardIterator
+    search_n(ForwardIterator first, ForwardIterator last,
+             Size count, const T& value, BinaryPredicate pred);
+
+template <class InputIterator, class OutputIterator>
+    OutputIterator
+    copy(InputIterator first, InputIterator last, OutputIterator result);
+
+template<class InputIterator, class OutputIterator, class Predicate>
+    OutputIterator
+    copy_if(InputIterator first, InputIterator last,
+            OutputIterator result, Predicate pred);
+
+template<class InputIterator, class Size, class OutputIterator>
+    OutputIterator
+    copy_n(InputIterator first, Size n, OutputIterator result);
+
+template <class BidirectionalIterator1, class BidirectionalIterator2>
+    BidirectionalIterator2
+    copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
+                  BidirectionalIterator2 result);
+
+template <class ForwardIterator1, class ForwardIterator2>
+    ForwardIterator2
+    swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
+
+template <class ForwardIterator1, class ForwardIterator2>
+    void
+    iter_swap(ForwardIterator1 a, ForwardIterator2 b);
+
+template <class InputIterator, class OutputIterator, class UnaryOperation>
+    OutputIterator
+    transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
+    OutputIterator
+    transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
+              OutputIterator result, BinaryOperation binary_op);
+
+template <class ForwardIterator, class T>
+    void
+    replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
+
+template <class ForwardIterator, class Predicate, class T>
+    void
+    replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
+
+template <class InputIterator, class OutputIterator, class T>
+    OutputIterator
+    replace_copy(InputIterator first, InputIterator last, OutputIterator result,
+                 const T& old_value, const T& new_value);
+
+template <class InputIterator, class OutputIterator, class Predicate, class T>
+    OutputIterator
+    replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
+
+template <class ForwardIterator, class T>
+    void
+    fill(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class OutputIterator, class Size, class T>
+    OutputIterator
+    fill_n(OutputIterator first, Size n, const T& value);
+
+template <class ForwardIterator, class Generator>
+    void
+    generate(ForwardIterator first, ForwardIterator last, Generator gen);
+
+template <class OutputIterator, class Size, class Generator>
+    OutputIterator
+    generate_n(OutputIterator first, Size n, Generator gen);
+
+template <class ForwardIterator, class T>
+    ForwardIterator
+    remove(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class Predicate>
+    ForwardIterator
+    remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template <class InputIterator, class OutputIterator, class T>
+    OutputIterator
+    remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
+
+template <class InputIterator, class OutputIterator, class Predicate>
+    OutputIterator
+    remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
+
+template <class ForwardIterator>
+    ForwardIterator
+    unique(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class BinaryPredicate>
+    ForwardIterator
+    unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
+
+template <class InputIterator, class OutputIterator>
+    OutputIterator
+    unique_copy(InputIterator first, InputIterator last, OutputIterator result);
+
+template <class InputIterator, class OutputIterator, class BinaryPredicate>
+    OutputIterator
+    unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
+
+template <class BidirectionalIterator>
+    void
+    reverse(BidirectionalIterator first, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class OutputIterator>
+    OutputIterator
+    reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
+
+template <class ForwardIterator>
+    ForwardIterator
+    rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
+
+template <class ForwardIterator, class OutputIterator>
+    OutputIterator
+    rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
+
+template <class RandomAccessIterator>
+    void
+    random_shuffle(RandomAccessIterator first, RandomAccessIterator last); // deprecated in C++14
+
+template <class RandomAccessIterator, class RandomNumberGenerator>
+    void
+    random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+                   RandomNumberGenerator& rand);  // deprecated in C++14
+
+template<class RandomAccessIterator, class UniformRandomNumberGenerator>
+    void shuffle(RandomAccessIterator first, RandomAccessIterator last,
+                 UniformRandomNumberGenerator&& g);
+
+template <class InputIterator, class Predicate>
+    bool
+    is_partitioned(InputIterator first, InputIterator last, Predicate pred);
+
+template <class ForwardIterator, class Predicate>
+    ForwardIterator
+    partition(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template <class InputIterator, class OutputIterator1,
+          class OutputIterator2, class Predicate>
+    pair<OutputIterator1, OutputIterator2>
+    partition_copy(InputIterator first, InputIterator last,
+                   OutputIterator1 out_true, OutputIterator2 out_false,
+                   Predicate pred);
+
+template <class ForwardIterator, class Predicate>
+    ForwardIterator
+    stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template<class ForwardIterator, class Predicate>
+    ForwardIterator
+    partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+template <class ForwardIterator>
+    bool
+    is_sorted(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+    bool
+    is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template<class ForwardIterator>
+    ForwardIterator
+    is_sorted_until(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+    ForwardIterator
+    is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    sort(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    stable_sort(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
+
+template <class InputIterator, class RandomAccessIterator>
+    RandomAccessIterator
+    partial_sort_copy(InputIterator first, InputIterator last,
+                      RandomAccessIterator result_first, RandomAccessIterator result_last);
+
+template <class InputIterator, class RandomAccessIterator, class Compare>
+    RandomAccessIterator
+    partial_sort_copy(InputIterator first, InputIterator last,
+                      RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
+
+template <class ForwardIterator, class T>
+    ForwardIterator
+    lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+    ForwardIterator
+    lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class ForwardIterator, class T>
+    ForwardIterator
+    upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+    ForwardIterator
+    upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class ForwardIterator, class T>
+    pair<ForwardIterator, ForwardIterator>
+    equal_range(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+    pair<ForwardIterator, ForwardIterator>
+    equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class ForwardIterator, class T>
+    bool
+    binary_search(ForwardIterator first, ForwardIterator last, const T& value);
+
+template <class ForwardIterator, class T, class Compare>
+    bool
+    binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+    OutputIterator
+    merge(InputIterator1 first1, InputIterator1 last1,
+          InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+    OutputIterator
+    merge(InputIterator1 first1, InputIterator1 last1,
+          InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class BidirectionalIterator>
+    void
+    inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class Compare>
+    void
+    inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
+
+template <class InputIterator1, class InputIterator2>
+    bool
+    includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
+
+template <class InputIterator1, class InputIterator2, class Compare>
+    bool
+    includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+    OutputIterator
+    set_union(InputIterator1 first1, InputIterator1 last1,
+              InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+    OutputIterator
+    set_union(InputIterator1 first1, InputIterator1 last1,
+              InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+    OutputIterator
+    set_intersection(InputIterator1 first1, InputIterator1 last1,
+                     InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+    OutputIterator
+    set_intersection(InputIterator1 first1, InputIterator1 last1,
+                     InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+    OutputIterator
+    set_difference(InputIterator1 first1, InputIterator1 last1,
+                   InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+    OutputIterator
+    set_difference(InputIterator1 first1, InputIterator1 last1,
+                   InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator>
+    OutputIterator
+    set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
+                             InputIterator2 first2, InputIterator2 last2, OutputIterator result);
+
+template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
+    OutputIterator
+    set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
+                             InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    push_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    pop_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    make_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    void
+    sort_heap(RandomAccessIterator first, RandomAccessIterator last);
+
+template <class RandomAccessIterator, class Compare>
+    void
+    sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    bool
+    is_heap(RandomAccessIterator first, RandomAccessiterator last);
+
+template <class RandomAccessIterator, class Compare>
+    bool
+    is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
+
+template <class RandomAccessIterator>
+    RandomAccessIterator
+    is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
+
+template <class RandomAccessIterator, class Compare>
+    RandomAccessIterator
+    is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
+
+template <class ForwardIterator>
+    ForwardIterator
+    min_element(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+    ForwardIterator
+    min_element(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template <class T>
+    const T&
+    min(const T& a, const T& b);  // constexpr in C++14
+
+template <class T, class Compare>
+    const T&
+    min(const T& a, const T& b, Compare comp);  // constexpr in C++14
+
+template<class T>
+    T
+    min(initializer_list<T> t);  // constexpr in C++14
+
+template<class T, class Compare>
+    T
+    min(initializer_list<T> t, Compare comp);  // constexpr in C++14
+
+template <class ForwardIterator>
+    ForwardIterator
+    max_element(ForwardIterator first, ForwardIterator last);
+
+template <class ForwardIterator, class Compare>
+    ForwardIterator
+    max_element(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template <class T>
+    const T&
+    max(const T& a, const T& b); // constexpr in C++14
+
+template <class T, class Compare>
+    const T&
+    max(const T& a, const T& b, Compare comp);  // constexpr in C++14
+
+template<class T>
+    T
+    max(initializer_list<T> t);  // constexpr in C++14
+
+template<class T, class Compare>
+    T
+    max(initializer_list<T> t, Compare comp);  // constexpr in C++14
+
+template<class ForwardIterator>
+    pair<ForwardIterator, ForwardIterator>
+    minmax_element(ForwardIterator first, ForwardIterator last);
+
+template<class ForwardIterator, class Compare>
+    pair<ForwardIterator, ForwardIterator>
+    minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
+
+template<class T>
+    pair<const T&, const T&>
+    minmax(const T& a, const T& b);  // constexpr in C++14
+
+template<class T, class Compare>
+    pair<const T&, const T&>
+    minmax(const T& a, const T& b, Compare comp);  // constexpr in C++14
+
+template<class T>
+    pair<T, T>
+    minmax(initializer_list<T> t);  // constexpr in C++14
+
+template<class T, class Compare>
+    pair<T, T>
+    minmax(initializer_list<T> t, Compare comp);  // constexpr in C++14
+
+template <class InputIterator1, class InputIterator2>
+    bool
+    lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
+
+template <class InputIterator1, class InputIterator2, class Compare>
+    bool
+    lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
+                            InputIterator2 first2, InputIterator2 last2, Compare comp);
+
+template <class BidirectionalIterator>
+    bool
+    next_permutation(BidirectionalIterator first, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class Compare>
+    bool
+    next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
+
+template <class BidirectionalIterator>
+    bool
+    prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
+
+template <class BidirectionalIterator, class Compare>
+    bool
+    prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <initializer_list>
+#include <type_traits>
+#include <cstring>
+#include <utility>
+#include <memory>
+#include <iterator>
+#include <cstddef>
+
+#if defined(__IBMCPP__)
+#include "support/ibm/support.h"
+#endif
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#include "support/win32/support.h"
+#endif
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// I'd like to replace these with _VSTD::equal_to<void>, but can't because:
+//   * That only works with C++14 and later, and
+//   * We haven't included <functional> here.
+template <class _T1, class _T2 = _T1>
+struct __equal_to
+{
+    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;}
+    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;}
+    _LIBCPP_INLINE_VISIBILITY bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;}
+};
+
+template <class _T1>
+struct __equal_to<_T1, _T1>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+};
+
+template <class _T1>
+struct __equal_to<const _T1, _T1>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+};
+
+template <class _T1>
+struct __equal_to<_T1, const _T1>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
+};
+
+template <class _T1, class _T2 = _T1>
+struct __less
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 
+    bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;}
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;}
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;}
+};
+
+template <class _T1>
+struct __less<_T1, _T1>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+};
+
+template <class _T1>
+struct __less<const _T1, _T1>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+};
+
+template <class _T1>
+struct __less<_T1, const _T1>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
+};
+
+template <class _Predicate>
+class __negate
+{
+private:
+    _Predicate __p_;
+public:
+    _LIBCPP_INLINE_VISIBILITY __negate() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __negate(_Predicate __p) : __p_(__p) {}
+
+    template <class _T1>
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _T1& __x) {return !__p_(__x);}
+
+    template <class _T1, class _T2>
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _T1& __x, const _T2& __y) {return !__p_(__x, __y);}
+};
+
+#ifdef _LIBCPP_DEBUG
+
+template <class _Compare>
+struct __debug_less
+{
+    _Compare __comp_;
+    __debug_less(_Compare& __c) : __comp_(__c) {}
+    template <class _Tp, class _Up>
+    bool operator()(const _Tp& __x, const _Up& __y)
+    {
+        bool __r = __comp_(__x, __y);
+        if (__r)
+            _LIBCPP_ASSERT(!__comp_(__y, __x), "Comparator does not induce a strict weak ordering");
+        return __r;
+    }
+};
+
+#endif  // _LIBCPP_DEBUG
+
+// Precondition:  __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned
+__ctz(unsigned __x)
+{
+    return static_cast<unsigned>(__builtin_ctz(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__ctz(unsigned long __x)
+{
+    return static_cast<unsigned long>(__builtin_ctzl(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__ctz(unsigned long long __x)
+{
+    return static_cast<unsigned long long>(__builtin_ctzll(__x));
+}
+
+// Precondition:  __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned
+__clz(unsigned __x)
+{
+    return static_cast<unsigned>(__builtin_clz(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__clz(unsigned long __x)
+{
+    return static_cast<unsigned long>(__builtin_clzl (__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__clz(unsigned long long __x)
+{
+    return static_cast<unsigned long long>(__builtin_clzll(__x));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned           __x) {return __builtin_popcount  (__x);}
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned      long __x) {return __builtin_popcountl (__x);}
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {return __builtin_popcountll(__x);}
+
+// all_of
+
+template <class _InputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+        if (!__pred(*__first))
+            return false;
+    return true;
+}
+
+// any_of
+
+template <class _InputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+        if (__pred(*__first))
+            return true;
+    return false;
+}
+
+// none_of
+
+template <class _InputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+        if (__pred(*__first))
+            return false;
+    return true;
+}
+
+// for_each
+
+template <class _InputIterator, class _Function>
+inline _LIBCPP_INLINE_VISIBILITY
+_Function
+for_each(_InputIterator __first, _InputIterator __last, _Function __f)
+{
+    for (; __first != __last; ++__first)
+        __f(*__first);
+    return _VSTD::move(__f);  // explicitly moved for (emulated) C++03
+}
+
+// find
+
+template <class _InputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_InputIterator
+find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
+{
+    for (; __first != __last; ++__first)
+        if (*__first == __value_)
+            break;
+    return __first;
+}
+
+// find_if
+
+template <class _InputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_InputIterator
+find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+        if (__pred(*__first))
+            break;
+    return __first;
+}
+
+// find_if_not
+
+template<class _InputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_InputIterator
+find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+        if (!__pred(*__first))
+            break;
+    return __first;
+}
+
+// find_end
+
+template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
+_ForwardIterator1
+__find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+           _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
+           forward_iterator_tag, forward_iterator_tag)
+{
+    // modeled after search algorithm
+    _ForwardIterator1 __r = __last1;  // __last1 is the "default" answer
+    if (__first2 == __last2)
+        return __r;
+    while (true)
+    {
+        while (true)
+        {
+            if (__first1 == __last1)         // if source exhausted return last correct answer
+                return __r;                  //    (or __last1 if never found)
+            if (__pred(*__first1, *__first2))
+                break;
+            ++__first1;
+        }
+        // *__first1 matches *__first2, now match elements after here
+        _ForwardIterator1 __m1 = __first1;
+        _ForwardIterator2 __m2 = __first2;
+        while (true)
+        {
+            if (++__m2 == __last2)
+            {                         // Pattern exhaused, record answer and search for another one
+                __r = __first1;
+                ++__first1;
+                break;
+            }
+            if (++__m1 == __last1)     // Source exhausted, return last answer
+                return __r;
+            if (!__pred(*__m1, *__m2))  // mismatch, restart with a new __first
+            {
+                ++__first1;
+                break;
+            }  // else there is a match, check next elements
+        }
+    }
+}
+
+template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2>
+_BidirectionalIterator1
+__find_end(_BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1,
+           _BidirectionalIterator2 __first2, _BidirectionalIterator2 __last2, _BinaryPredicate __pred,
+           bidirectional_iterator_tag, bidirectional_iterator_tag)
+{
+    // modeled after search algorithm (in reverse)
+    if (__first2 == __last2)
+        return __last1;  // Everything matches an empty sequence
+    _BidirectionalIterator1 __l1 = __last1;
+    _BidirectionalIterator2 __l2 = __last2;
+    --__l2;
+    while (true)
+    {
+        // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks
+        while (true)
+        {
+            if (__first1 == __l1)  // return __last1 if no element matches *__first2
+                return __last1;
+            if (__pred(*--__l1, *__l2))
+                break;
+        }
+        // *__l1 matches *__l2, now match elements before here
+        _BidirectionalIterator1 __m1 = __l1;
+        _BidirectionalIterator2 __m2 = __l2;
+        while (true)
+        {
+            if (__m2 == __first2)  // If pattern exhausted, __m1 is the answer (works for 1 element pattern)
+                return __m1;
+            if (__m1 == __first1)  // Otherwise if source exhaused, pattern not found
+                return __last1;
+            if (!__pred(*--__m1, *--__m2))  // if there is a mismatch, restart with a new __l1
+            {
+                break;
+            }  // else there is a match, check next elements
+        }
+    }
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
+__find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
+           _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
+           random_access_iterator_tag, random_access_iterator_tag)
+{
+    // Take advantage of knowing source and pattern lengths.  Stop short when source is smaller than pattern
+    typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2;
+    if (__len2 == 0)
+        return __last1;
+    typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1;
+    if (__len1 < __len2)
+        return __last1;
+    const _RandomAccessIterator1 __s = __first1 + (__len2 - 1);  // End of pattern match can't go before here
+    _RandomAccessIterator1 __l1 = __last1;
+    _RandomAccessIterator2 __l2 = __last2;
+    --__l2;
+    while (true)
+    {
+        while (true)
+        {
+            if (__s == __l1)
+                return __last1;
+            if (__pred(*--__l1, *__l2))
+                break;
+        }
+        _RandomAccessIterator1 __m1 = __l1;
+        _RandomAccessIterator2 __m2 = __l2;
+        while (true)
+        {
+            if (__m2 == __first2)
+                return __m1;
+                                 // no need to check range on __m1 because __s guarantees we have enough source
+            if (!__pred(*--__m1, *--__m2))
+            {
+                break;
+            }
+        }
+    }
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator1
+find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+         _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
+{
+    return _VSTD::__find_end<typename add_lvalue_reference<_BinaryPredicate>::type>
+                         (__first1, __last1, __first2, __last2, __pred,
+                          typename iterator_traits<_ForwardIterator1>::iterator_category(),
+                          typename iterator_traits<_ForwardIterator2>::iterator_category());
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator1
+find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+         _ForwardIterator2 __first2, _ForwardIterator2 __last2)
+{
+    typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+    typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+    return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+
+// find_first_of
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1
+__find_first_of_ce(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+              _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
+{
+    for (; __first1 != __last1; ++__first1)
+        for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
+            if (__pred(*__first1, *__j))
+                return __first1;
+    return __last1;
+}
+
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator1
+find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+              _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
+{
+    return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator1
+find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+              _ForwardIterator2 __first2, _ForwardIterator2 __last2)
+{
+    typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+    typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+    return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+
+// adjacent_find
+
+template <class _ForwardIterator, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __i = __first;
+        while (++__i != __last)
+        {
+            if (__pred(*__first, *__i))
+                return __first;
+            __first = __i;
+        }
+    }
+    return __last;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
+{
+    typedef typename iterator_traits<_ForwardIterator>::value_type __v;
+    return _VSTD::adjacent_find(__first, __last, __equal_to<__v>());
+}
+
+// count
+
+template <class _InputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename iterator_traits<_InputIterator>::difference_type
+count(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
+{
+    typename iterator_traits<_InputIterator>::difference_type __r(0);
+    for (; __first != __last; ++__first)
+        if (*__first == __value_)
+            ++__r;
+    return __r;
+}
+
+// count_if
+
+template <class _InputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+typename iterator_traits<_InputIterator>::difference_type
+count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+    typename iterator_traits<_InputIterator>::difference_type __r(0);
+    for (; __first != __last; ++__first)
+        if (__pred(*__first))
+            ++__r;
+    return __r;
+}
+
+// mismatch
+
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_InputIterator1, _InputIterator2>
+mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
+         _InputIterator2 __first2, _BinaryPredicate __pred)
+{
+    for (; __first1 != __last1; ++__first1, ++__first2)
+        if (!__pred(*__first1, *__first2))
+            break;
+    return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
+}
+
+template <class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_InputIterator1, _InputIterator2>
+mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
+{
+    typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+    typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+    return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_InputIterator1, _InputIterator2>
+mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
+         _InputIterator2 __first2, _InputIterator2 __last2,
+         _BinaryPredicate __pred)
+{
+    for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
+        if (!__pred(*__first1, *__first2))
+            break;
+    return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
+}
+
+template <class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_InputIterator1, _InputIterator2>
+mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
+         _InputIterator2 __first2, _InputIterator2 __last2)
+{
+    typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+    typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+    return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+#endif
+
+// equal
+
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred)
+{
+    for (; __first1 != __last1; ++__first1, ++__first2)
+        if (!__pred(*__first1, *__first2))
+            return false;
+    return true;
+}
+
+template <class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
+{
+    typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+    typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+    return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__equal(_InputIterator1 __first1, _InputIterator1 __last1, 
+        _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
+        input_iterator_tag, input_iterator_tag )
+{
+    for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
+        if (!__pred(*__first1, *__first2))
+            return false;
+    return __first1 == __last1 && __first2 == __last2;
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, 
+        _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, 
+      random_access_iterator_tag, random_access_iterator_tag )
+{
+    if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
+        return false;
+    return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2,
+                        typename add_lvalue_reference<_BinaryPredicate>::type>
+                       (__first1, __last1, __first2, __pred );
+}
+
+template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, 
+      _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred )
+{
+    return _VSTD::__equal<typename add_lvalue_reference<_BinaryPredicate>::type>
+       (__first1, __last1, __first2, __last2, __pred, 
+        typename iterator_traits<_InputIterator1>::iterator_category(),
+        typename iterator_traits<_InputIterator2>::iterator_category());
+}
+
+template <class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+equal(_InputIterator1 __first1, _InputIterator1 __last1, 
+      _InputIterator2 __first2, _InputIterator2 __last2)
+{
+    typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+    typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+    return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(),
+        typename iterator_traits<_InputIterator1>::iterator_category(),
+        typename iterator_traits<_InputIterator2>::iterator_category());
+}
+#endif
+
+// is_permutation
+
+template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+bool
+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)
+        if (!__pred(*__first1, *__first2))
+            goto __not_done;
+    return true;
+__not_done:
+    // __first1 != __last1 && *__first1 != *__first2
+    typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
+    _D1 __l1 = _VSTD::distance(__first1, __last1);
+    if (__l1 == _D1(1))
+        return false;
+    _ForwardIterator2 __last2 = _VSTD::next(__first2, __l1);
+    // For each element in [f1, l1) see if there are the same number of
+    //    equal elements in [f2, l2)
+    for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i)
+    {
+        // Have we already counted the number of *__i in [f1, l1)?
+        for (_ForwardIterator1 __j = __first1; __j != __i; ++__j)
+            if (__pred(*__j, *__i))
+                goto __next_iter;
+        {
+            // Count number of *__i in [f2, l2)
+            _D1 __c2 = 0;
+            for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
+                if (__pred(*__i, *__j))
+                    ++__c2;
+            if (__c2 == 0)
+                return false;
+            // Count number of *__i in [__i, l1) (we can start with 1)
+            _D1 __c1 = 1;
+            for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
+                if (__pred(*__i, *__j))
+                    ++__c1;
+            if (__c1 != __c2)
+                return false;
+        }
+__next_iter:;
+    }
+    return true;
+}
+
+template<class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+               _ForwardIterator2 __first2)
+{
+    typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+    typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+    return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>());
+}
+
+#if _LIBCPP_STD_VER > 11
+template<class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
+bool
+__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+                 _ForwardIterator2 __first2, _ForwardIterator2 __last2, 
+                 _BinaryPredicate __pred,
+                 forward_iterator_tag, forward_iterator_tag )
+{
+    // shorten sequences as much as possible by lopping of any equal parts
+    for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
+        if (!__pred(*__first1, *__first2))
+            goto __not_done;
+    return __first1 == __last1 && __first2 == __last2;
+__not_done:
+    // __first1 != __last1 && __first2 != __last2 && *__first1 != *__first2
+    typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1;
+    _D1 __l1 = _VSTD::distance(__first1, __last1);
+
+    typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2;
+    _D2 __l2 = _VSTD::distance(__first2, __last2);
+    if (__l1 != __l2)
+        return false;
+
+    // For each element in [f1, l1) see if there are the same number of
+    //    equal elements in [f2, l2)
+    for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i)
+    {
+        // Have we already counted the number of *__i in [f1, l1)?
+        for (_ForwardIterator1 __j = __first1; __j != __i; ++__j)
+            if (__pred(*__j, *__i))
+                goto __next_iter;
+        {
+            // Count number of *__i in [f2, l2)
+            _D1 __c2 = 0;
+            for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j)
+                if (__pred(*__i, *__j))
+                    ++__c2;
+            if (__c2 == 0)
+                return false;
+            // Count number of *__i in [__i, l1) (we can start with 1)
+            _D1 __c1 = 1;
+            for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j)
+                if (__pred(*__i, *__j))
+                    ++__c1;
+            if (__c1 != __c2)
+                return false;
+        }
+__next_iter:;
+    }
+    return true;
+}
+
+template<class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+bool
+__is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
+               _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2, 
+               _BinaryPredicate __pred,
+               random_access_iterator_tag, random_access_iterator_tag )
+{
+    if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
+        return false;
+    return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2,
+                                 typename add_lvalue_reference<_BinaryPredicate>::type>
+                                (__first1, __last1, __first2, __pred );
+}
+
+template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+               _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+               _BinaryPredicate __pred )
+{
+    return _VSTD::__is_permutation<typename add_lvalue_reference<_BinaryPredicate>::type>
+       (__first1, __last1, __first2, __last2, __pred,
+        typename iterator_traits<_ForwardIterator1>::iterator_category(),
+        typename iterator_traits<_ForwardIterator2>::iterator_category());
+}
+
+template<class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+               _ForwardIterator2 __first2, _ForwardIterator2 __last2)
+{
+    typedef typename iterator_traits<_ForwardIterator1>::value_type __v1;
+    typedef typename iterator_traits<_ForwardIterator2>::value_type __v2;
+    return _VSTD::__is_permutation(__first1, __last1, __first2, __last2,
+        __equal_to<__v1, __v2>(),
+        typename iterator_traits<_ForwardIterator1>::iterator_category(),
+        typename iterator_traits<_ForwardIterator2>::iterator_category());
+}
+#endif
+
+// search
+
+template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
+_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
+    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;
+            if (__pred(*__first1, *__first2))
+                break;
+            ++__first1;
+        }
+        // *__first1 matches *__first2, now match elements after here
+        _ForwardIterator1 __m1 = __first1;
+        _ForwardIterator2 __m2 = __first2;
+        while (true)
+        {
+            if (++__m2 == __last2)  // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
+                return __first1;
+            if (++__m1 == __last1)  // Otherwise if source exhaused, pattern not found
+                return __last1;
+            if (!__pred(*__m1, *__m2))  // if there is a mismatch, restart with a new __first1
+            {
+                ++__first1;
+                break;
+            }  // else there is a match, check next elements
+        }
+    }
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1
+__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
+           _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;
+    // Take advantage of knowing source and pattern lengths.  Stop short when source is smaller than pattern
+    _D2 __len2 = __last2 - __first2;
+    if (__len2 == 0)
+        return __first1;
+    _D1 __len1 = __last1 - __first1;
+    if (__len1 < __len2)
+        return __last1;
+    const _RandomAccessIterator1 __s = __last1 - (__len2 - 1);  // Start of pattern match can't go beyond here
+    while (true)
+    {
+#if !_LIBCPP_UNROLL_LOOPS
+        while (true)
+        {
+            if (__first1 == __s)
+                return __last1;
+            if (__pred(*__first1, *__first2))
+                break;
+            ++__first1;
+        }
+#else  // !_LIBCPP_UNROLL_LOOPS
+        for (_D1 __loop_unroll = (__s - __first1) / 4; __loop_unroll > 0; --__loop_unroll)
+        {
+            if (__pred(*__first1, *__first2))
+                goto __phase2;
+            if (__pred(*++__first1, *__first2))
+                goto __phase2;
+            if (__pred(*++__first1, *__first2))
+                goto __phase2;
+            if (__pred(*++__first1, *__first2))
+                goto __phase2;
+            ++__first1;
+        }
+        switch (__s - __first1)
+        {
+        case 3:
+            if (__pred(*__first1, *__first2))
+                break;
+            ++__first1;
+        case 2:
+            if (__pred(*__first1, *__first2))
+                break;
+            ++__first1;
+        case 1:
+            if (__pred(*__first1, *__first2))
+                break;
+        case 0:
+            return __last1;
+        }
+    __phase2:
+#endif  // !_LIBCPP_UNROLL_LOOPS
+        _RandomAccessIterator1 __m1 = __first1;
+        _RandomAccessIterator2 __m2 = __first2;
+#if !_LIBCPP_UNROLL_LOOPS
+         while (true)
+         {
+             if (++__m2 == __last2)
+                 return __first1;
+             ++__m1;          // no need to check range on __m1 because __s guarantees we have enough source
+             if (!__pred(*__m1, *__m2))
+             {
+                 ++__first1;
+                 break;
+             }
+         }
+#else  // !_LIBCPP_UNROLL_LOOPS
+        ++__m2;
+        ++__m1;
+        for (_D2 __loop_unroll = (__last2 - __m2) / 4; __loop_unroll > 0; --__loop_unroll)
+        {
+            if (!__pred(*__m1, *__m2))
+                goto __continue;
+            if (!__pred(*++__m1, *++__m2))
+                goto __continue;
+            if (!__pred(*++__m1, *++__m2))
+                goto __continue;
+            if (!__pred(*++__m1, *++__m2))
+                goto __continue;
+            ++__m1;
+            ++__m2;
+        }
+        switch (__last2 - __m2)
+        {
+        case 3:
+            if (!__pred(*__m1, *__m2))
+                break;
+            ++__m1;
+            ++__m2;
+        case 2:
+            if (!__pred(*__m1, *__m2))
+                break;
+            ++__m1;
+            ++__m2;
+        case 1:
+            if (!__pred(*__m1, *__m2))
+                break;
+        case 0:
+            return __first1;
+        }
+    __continue:
+        ++__first1;
+#endif  // !_LIBCPP_UNROLL_LOOPS
+    }
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator1
+search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+       _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
+{
+    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());
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+_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;
+    return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
+}
+
+// search_n
+
+template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp>
+_ForwardIterator
+__search_n(_ForwardIterator __first, _ForwardIterator __last,
+           _Size __count, const _Tp& __value_, _BinaryPredicate __pred, forward_iterator_tag)
+{
+    if (__count <= 0)
+        return __first;
+    while (true)
+    {
+        // Find first element in sequence that matchs __value_, with a mininum of loop checks
+        while (true)
+        {
+            if (__first == __last)  // return __last if no element matches __value_
+                return __last;
+            if (__pred(*__first, __value_))
+                break;
+            ++__first;
+        }
+        // *__first matches __value_, now match elements after here
+        _ForwardIterator __m = __first;
+        _Size __c(0);
+        while (true)
+        {
+            if (++__c == __count)  // If pattern exhausted, __first is the answer (works for 1 element pattern)
+                return __first;
+            if (++__m == __last)  // Otherwise if source exhaused, pattern not found
+                return __last;
+            if (!__pred(*__m, __value_))  // if there is a mismatch, restart with a new __first
+            {
+                __first = __m;
+                ++__first;
+                break;
+            }  // else there is a match, check next elements
+        }
+    }
+}
+
+template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp>
+_RandomAccessIterator
+__search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
+           _Size __count, const _Tp& __value_, _BinaryPredicate __pred, random_access_iterator_tag)
+{
+    if (__count <= 0)
+        return __first;
+    _Size __len = static_cast<_Size>(__last - __first);
+    if (__len < __count)
+        return __last;
+    const _RandomAccessIterator __s = __last - (__count - 1);  // Start of pattern match can't go beyond here
+    while (true)
+    {
+        // Find first element in sequence that matchs __value_, with a mininum of loop checks
+        while (true)
+        {
+            if (__first >= __s)  // return __last if no element matches __value_
+                return __last;
+            if (__pred(*__first, __value_))
+                break;
+            ++__first;
+        }
+        // *__first matches __value_, now match elements after here
+        _RandomAccessIterator __m = __first;
+        _Size __c(0);
+        while (true)
+        {
+            if (++__c == __count)  // If pattern exhausted, __first is the answer (works for 1 element pattern)
+                return __first;
+             ++__m;          // no need to check range on __m because __s guarantees we have enough source
+            if (!__pred(*__m, __value_))  // if there is a mismatch, restart with a new __first
+            {
+                __first = __m;
+                ++__first;
+                break;
+            }  // else there is a match, check next elements
+        }
+    }
+}
+
+template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+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());
+}
+
+template <class _ForwardIterator, class _Size, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_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>());
+}
+
+// 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
+__unwrap_iter(_Iter __i)
+{
+    return __i;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_trivially_copy_assignable<_Tp>::value,
+    _Tp*
+>::type
+__unwrap_iter(move_iterator<_Tp*> __i)
+{
+    return __i.base();
+}
+
+#if _LIBCPP_DEBUG_LEVEL < 2
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_trivially_copy_assignable<_Tp>::value,
+    _Tp*
+>::type
+__unwrap_iter(__wrap_iter<_Tp*> __i)
+{
+    return __i.base();
+}
+
+#endif  // _LIBCPP_DEBUG_LEVEL < 2
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    for (; __first != __last; ++__first, ++__result)
+        *__result = *__first;
+    return __result;
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_same<typename remove_const<_Tp>::type, _Up>::value &&
+    is_trivially_copy_assignable<_Up>::value,
+    _Up*
+>::type
+__copy(_Tp* __first, _Tp* __last, _Up* __result)
+{
+    const size_t __n = static_cast<size_t>(__last - __first);
+    _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    return __result + __n;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    return _VSTD::__copy(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+}
+
+// copy_backward
+
+template <class _BidirectionalIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
+{
+    while (__first != __last)
+        *--__result = *--__last;
+    return __result;
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_same<typename remove_const<_Tp>::type, _Up>::value &&
+    is_trivially_copy_assignable<_Up>::value,
+    _Up*
+>::type
+__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));
+    return __result;
+}
+
+template <class _BidirectionalIterator1, class _BidirectionalIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+_BidirectionalIterator2
+copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
+              _BidirectionalIterator2 __result)
+{
+    return _VSTD::__copy_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+}
+
+// copy_if
+
+template<class _InputIterator, class _OutputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+copy_if(_InputIterator __first, _InputIterator __last,
+        _OutputIterator __result, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+    {
+        if (__pred(*__first))
+        {
+            *__result = *__first;
+            ++__result;
+        }
+    }
+    return __result;
+}
+
+// copy_n
+
+template<class _InputIterator, class _Size, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_input_iterator<_InputIterator>::value &&
+   !__is_random_access_iterator<_InputIterator>::value,
+    _OutputIterator
+>::type
+copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
+{
+    if (__n > 0)
+    {
+        *__result = *__first;
+        ++__result;
+        for (--__n; __n > 0; --__n)
+        {
+            ++__first;
+            *__result = *__first;
+            ++__result;
+        }
+    }
+    return __result;
+}
+
+template<class _InputIterator, class _Size, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_random_access_iterator<_InputIterator>::value,
+    _OutputIterator
+>::type
+copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
+{
+    return _VSTD::copy(__first, __first + __n, __result);
+}
+
+// move
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    for (; __first != __last; ++__first, ++__result)
+        *__result = _VSTD::move(*__first);
+    return __result;
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_same<typename remove_const<_Tp>::type, _Up>::value &&
+    is_trivially_copy_assignable<_Up>::value,
+    _Up*
+>::type
+__move(_Tp* __first, _Tp* __last, _Up* __result)
+{
+    const size_t __n = static_cast<size_t>(__last - __first);
+    _VSTD::memmove(__result, __first, __n * sizeof(_Up));
+    return __result + __n;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+move(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    return _VSTD::__move(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+}
+
+// move_backward
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    while (__first != __last)
+        *--__result = _VSTD::move(*--__last);
+    return __result;
+}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_same<typename remove_const<_Tp>::type, _Up>::value &&
+    is_trivially_copy_assignable<_Up>::value,
+    _Up*
+>::type
+__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));
+    return __result;
+}
+
+template <class _BidirectionalIterator1, class _BidirectionalIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+_BidirectionalIterator2
+move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
+              _BidirectionalIterator2 __result)
+{
+    return _VSTD::__move_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result));
+}
+
+// iter_swap
+
+// moved to <type_traits> for better swap / noexcept support
+
+// transform
+
+template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
+{
+    for (; __first != __last; ++__first, ++__result)
+        *__result = __op(*__first);
+    return __result;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
+          _OutputIterator __result, _BinaryOperation __binary_op)
+{
+    for (; __first1 != __last1; ++__first1, ++__first2, ++__result)
+        *__result = __binary_op(*__first1, *__first2);
+    return __result;
+}
+
+// replace
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
+{
+    for (; __first != __last; ++__first)
+        if (*__first == __old_value)
+            *__first = __new_value;
+}
+
+// replace_if
+
+template <class _ForwardIterator, class _Predicate, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
+{
+    for (; __first != __last; ++__first)
+        if (__pred(*__first))
+            *__first = __new_value;
+}
+
+// replace_copy
+
+template <class _InputIterator, class _OutputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+             const _Tp& __old_value, const _Tp& __new_value)
+{
+    for (; __first != __last; ++__first, ++__result)
+        if (*__first == __old_value)
+            *__result = __new_value;
+        else
+            *__result = *__first;
+    return __result;
+}
+
+// replace_copy_if
+
+template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+                _Predicate __pred, const _Tp& __new_value)
+{
+    for (; __first != __last; ++__first, ++__result)
+        if (__pred(*__first))
+            *__result = __new_value;
+        else
+            *__result = *__first;
+    return __result;
+}
+
+// fill_n
+
+template <class _OutputIterator, class _Size, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
+{
+    for (; __n > 0; ++__first, --__n)
+        *__first = __value_;
+    return __first;
+}
+
+template <class _Tp, class _Size, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && sizeof(_Tp) == 1 &&
+    !is_same<_Tp, bool>::value &&
+    is_integral<_Up>::value && sizeof(_Up) == 1,
+    _Tp*
+>::type
+__fill_n(_Tp* __first, _Size __n,_Up __value_)
+{
+    if (__n > 0)
+        _VSTD::memset(__first, (unsigned char)__value_, (size_t)(__n));
+    return __first + __n;
+}
+
+template <class _OutputIterator, class _Size, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_)
+{
+   return _VSTD::__fill_n(__first, __n, __value_);
+}
+
+// fill
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag)
+{
+    for (; __first != __last; ++__first)
+        *__first = __value_;
+}
+
+template <class _RandomAccessIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag)
+{
+    _VSTD::fill_n(__first, __last - __first, __value_);
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+    _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+// generate
+
+template <class _ForwardIterator, class _Generator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
+{
+    for (; __first != __last; ++__first)
+        *__first = __gen();
+}
+
+// generate_n
+
+template <class _OutputIterator, class _Size, class _Generator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
+{
+    for (; __n > 0; ++__first, --__n)
+        *__first = __gen();
+    return __first;
+}
+
+// remove
+
+template <class _ForwardIterator, class _Tp>
+_ForwardIterator
+remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+    __first = _VSTD::find(__first, __last, __value_);
+    if (__first != __last)
+    {
+        _ForwardIterator __i = __first;
+        while (++__i != __last)
+        {
+            if (!(*__i == __value_))
+            {
+                *__first = _VSTD::move(*__i);
+                ++__first;
+            }
+        }
+    }
+    return __first;
+}
+
+// remove_if
+
+template <class _ForwardIterator, class _Predicate>
+_ForwardIterator
+remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+    __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type>
+                           (__first, __last, __pred);
+    if (__first != __last)
+    {
+        _ForwardIterator __i = __first;
+        while (++__i != __last)
+        {
+            if (!__pred(*__i))
+            {
+                *__first = _VSTD::move(*__i);
+                ++__first;
+            }
+        }
+    }
+    return __first;
+}
+
+// remove_copy
+
+template <class _InputIterator, class _OutputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_)
+{
+    for (; __first != __last; ++__first)
+    {
+        if (!(*__first == __value_))
+        {
+            *__result = *__first;
+            ++__result;
+        }
+    }
+    return __result;
+}
+
+// remove_copy_if
+
+template <class _InputIterator, class _OutputIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+    {
+        if (!__pred(*__first))
+        {
+            *__result = *__first;
+            ++__result;
+        }
+    }
+    return __result;
+}
+
+// unique
+
+template <class _ForwardIterator, class _BinaryPredicate>
+_ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
+{
+    __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type>
+                                 (__first, __last, __pred);
+    if (__first != __last)
+    {
+        // ...  a  a  ?  ...
+        //      f     i
+        _ForwardIterator __i = __first;
+        for (++__i; ++__i != __last;)
+            if (!__pred(*__first, *__i))
+                *++__first = _VSTD::move(*__i);
+        ++__first;
+    }
+    return __first;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+unique(_ForwardIterator __first, _ForwardIterator __last)
+{
+    typedef typename iterator_traits<_ForwardIterator>::value_type __v;
+    return _VSTD::unique(__first, __last, __equal_to<__v>());
+}
+
+// unique_copy
+
+template <class _BinaryPredicate, class _InputIterator, class _OutputIterator>
+_OutputIterator
+__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
+              input_iterator_tag, output_iterator_tag)
+{
+    if (__first != __last)
+    {
+        typename iterator_traits<_InputIterator>::value_type __t(*__first);
+        *__result = __t;
+        ++__result;
+        while (++__first != __last)
+        {
+            if (!__pred(__t, *__first))
+            {
+                __t = *__first;
+                *__result = __t;
+                ++__result;
+            }
+        }
+    }
+    return __result;
+}
+
+template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator>
+_OutputIterator
+__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred,
+              forward_iterator_tag, output_iterator_tag)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __i = __first;
+        *__result = *__i;
+        ++__result;
+        while (++__first != __last)
+        {
+            if (!__pred(*__i, *__first))
+            {
+                *__result = *__first;
+                ++__result;
+                __i = __first;
+            }
+        }
+    }
+    return __result;
+}
+
+template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator>
+_ForwardIterator
+__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred,
+              input_iterator_tag, forward_iterator_tag)
+{
+    if (__first != __last)
+    {
+        *__result = *__first;
+        while (++__first != __last)
+            if (!__pred(*__result, *__first))
+                *++__result = *__first;
+        ++__result;
+    }
+    return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred)
+{
+    return _VSTD::__unique_copy<typename add_lvalue_reference<_BinaryPredicate>::type>
+                              (__first, __last, __result, __pred,
+                               typename iterator_traits<_InputIterator>::iterator_category(),
+                               typename iterator_traits<_OutputIterator>::iterator_category());
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    typedef typename iterator_traits<_InputIterator>::value_type __v;
+    return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>());
+}
+
+// reverse
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
+{
+    while (__first != __last)
+    {
+        if (__first == --__last)
+            break;
+        swap(*__first, *__last);
+        ++__first;
+    }
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
+{
+    if (__first != __last)
+        for (; __first < --__last; ++__first)
+            swap(*__first, *__last);
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+    _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category());
+}
+
+// reverse_copy
+
+template <class _BidirectionalIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
+{
+    for (; __first != __last; ++__result)
+        *__result = *--__last;
+    return __result;
+}
+
+// rotate
+
+template <class _ForwardIterator>
+_ForwardIterator
+__rotate_left(_ForwardIterator __first, _ForwardIterator __last)
+{
+    typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+    value_type __tmp = _VSTD::move(*__first);
+    _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first);
+    *__lm1 = _VSTD::move(__tmp);
+    return __lm1;
+}
+
+template <class _BidirectionalIterator>
+_BidirectionalIterator
+__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+    typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+    _BidirectionalIterator __lm1 = _VSTD::prev(__last);
+    value_type __tmp = _VSTD::move(*__lm1);
+    _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last);
+    *__first = _VSTD::move(__tmp);
+    return __fp1;
+}
+
+template <class _ForwardIterator>
+_ForwardIterator
+__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
+{
+    _ForwardIterator __i = __middle;
+    while (true)
+    {
+        swap(*__first, *__i);
+        ++__first;
+        if (++__i == __last)
+            break;
+        if (__first == __middle)
+            __middle = __i;
+    }
+    _ForwardIterator __r = __first;
+    if (__first != __middle)
+    {
+        __i = __middle;
+        while (true)
+        {
+            swap(*__first, *__i);
+            ++__first;
+            if (++__i == __last)
+            {
+                if (__first == __middle)
+                    break;
+                __i = __middle;
+            }
+            else if (__first == __middle)
+                __middle = __i;
+        }
+    }
+    return __r;
+}
+
+template<typename _Integral>
+inline _LIBCPP_INLINE_VISIBILITY
+_Integral
+__gcd(_Integral __x, _Integral __y)
+{
+    do
+    {
+        _Integral __t = __x % __y;
+        __x = __y;
+        __y = __t;
+    } while (__y);
+    return __x;
+}
+
+template<typename _RandomAccessIterator>
+_RandomAccessIterator
+__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+
+    const difference_type __m1 = __middle - __first;
+    const difference_type __m2 = __last - __middle;
+    if (__m1 == __m2)
+    {
+        _VSTD::swap_ranges(__first, __middle, __middle);
+        return __middle;
+    }
+    const difference_type __g = _VSTD::__gcd(__m1, __m2);
+    for (_RandomAccessIterator __p = __first + __g; __p != __first;)
+    {
+        value_type __t(_VSTD::move(*--__p));
+        _RandomAccessIterator __p1 = __p;
+        _RandomAccessIterator __p2 = __p1 + __m1;
+        do
+        {
+            *__p1 = _VSTD::move(*__p2);
+            __p1 = __p2;
+            const difference_type __d = __last - __p2;
+            if (__m1 < __d)
+                __p2 += __m1;
+            else
+                __p2 = __first + (__m1 - __d);
+        } while (__p2 != __p);
+        *__p1 = _VSTD::move(__t);
+    }
+    return __first + __m2;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
+         _VSTD::forward_iterator_tag)
+{
+    typedef typename _VSTD::iterator_traits<_ForwardIterator>::value_type value_type;
+    if (_VSTD::is_trivially_move_assignable<value_type>::value)
+    {
+        if (_VSTD::next(__first) == __middle)
+            return _VSTD::__rotate_left(__first, __last);
+    }
+    return _VSTD::__rotate_forward(__first, __middle, __last);
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_BidirectionalIterator
+__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+         _VSTD::bidirectional_iterator_tag)
+{
+    typedef typename _VSTD::iterator_traits<_BidirectionalIterator>::value_type value_type;
+    if (_VSTD::is_trivially_move_assignable<value_type>::value)
+    {
+        if (_VSTD::next(__first) == __middle)
+            return _VSTD::__rotate_left(__first, __last);
+        if (_VSTD::next(__middle) == __last)
+            return _VSTD::__rotate_right(__first, __last);
+    }
+    return _VSTD::__rotate_forward(__first, __middle, __last);
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_RandomAccessIterator
+__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+         _VSTD::random_access_iterator_tag)
+{
+    typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::value_type value_type;
+    if (_VSTD::is_trivially_move_assignable<value_type>::value)
+    {
+        if (_VSTD::next(__first) == __middle)
+            return _VSTD::__rotate_left(__first, __last);
+        if (_VSTD::next(__middle) == __last)
+            return _VSTD::__rotate_right(__first, __last);
+        return _VSTD::__rotate_gcd(__first, __middle, __last);
+    }
+    return _VSTD::__rotate_forward(__first, __middle, __last);
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
+{
+    if (__first == __middle)
+        return __last;
+    if (__middle == __last)
+        return __first;
+    return _VSTD::__rotate(__first, __middle, __last,
+                           typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+// rotate_copy
+
+template <class _ForwardIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
+{
+    return _VSTD::copy(__first, __middle, _VSTD::copy(__middle, __last, __result));
+}
+
+// min_element
+
+template <class _ForwardIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_ForwardIterator
+__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __i = __first;
+        while (++__i != __last)
+            if (__comp(*__i, *__first))
+                __first = __i;
+    }
+    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
+_ForwardIterator
+min_element(_ForwardIterator __first, _ForwardIterator __last)
+{
+    return __min_element(__first, __last,
+              __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+// min
+
+template <class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+min(const _Tp& __a, const _Tp& __b, _Compare __comp)
+{
+    return __comp(__b, __a) ? __b : __a;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+min(const _Tp& __a, const _Tp& __b)
+{
+    return _VSTD::min(__a, __b, __less<_Tp>());
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+min(initializer_list<_Tp> __t, _Compare __comp)
+{
+    return *__min_element(__t.begin(), __t.end(), __comp);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+min(initializer_list<_Tp> __t)
+{
+    return *__min_element(__t.begin(), __t.end(), __less<_Tp>());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+// max_element
+
+template <class _ForwardIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_ForwardIterator
+__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __i = __first;
+        while (++__i != __last)
+            if (__comp(*__first, *__i))
+                __first = __i;
+    }
+    return __first;
+}
+
+
+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
+_ForwardIterator
+max_element(_ForwardIterator __first, _ForwardIterator __last)
+{
+    return __max_element(__first, __last,
+              __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+// max
+
+template <class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+max(const _Tp& __a, const _Tp& __b, _Compare __comp)
+{
+    return __comp(__a, __b) ? __b : __a;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Tp&
+max(const _Tp& __a, const _Tp& __b)
+{
+    return _VSTD::max(__a, __b, __less<_Tp>());
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+max(initializer_list<_Tp> __t, _Compare __comp)
+{
+    return *__max_element(__t.begin(), __t.end(), __comp);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+max(initializer_list<_Tp> __t)
+{
+    return *__max_element(__t.begin(), __t.end(), __less<_Tp>());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+// minmax_element
+
+template <class _ForwardIterator, class _Compare>
+std::pair<_ForwardIterator, _ForwardIterator>
+minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+  std::pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
+  if (__first != __last)
+  {
+      if (++__first != __last)
+      {
+          if (__comp(*__first, *__result.first))
+              __result.first = __first;
+          else
+              __result.second = __first;
+          while (++__first != __last)
+          {
+              _ForwardIterator __i = __first;
+              if (++__first == __last)
+              {
+                  if (__comp(*__i, *__result.first))
+                      __result.first = __i;
+                  else if (!__comp(*__i, *__result.second))
+                      __result.second = __i;
+                  break;
+              }
+              else
+              {
+                  if (__comp(*__first, *__i))
+                  {
+                      if (__comp(*__first, *__result.first))
+                          __result.first = __first;
+                      if (!__comp(*__i, *__result.second))
+                          __result.second = __i;
+                  }
+                  else
+                  {
+                      if (__comp(*__i, *__result.first))
+                          __result.first = __i;
+                      if (!__comp(*__first, *__result.second))
+                          __result.second = __first;
+                  }
+              }
+          }
+      }
+  }
+  return __result;
+}
+
+template <class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+std::pair<_ForwardIterator, _ForwardIterator>
+minmax_element(_ForwardIterator __first, _ForwardIterator __last)
+{
+    return _VSTD::minmax_element(__first, __last,
+              __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+// minmax
+
+template<class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<const _Tp&, const _Tp&>
+minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
+{
+    return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) :
+                              pair<const _Tp&, const _Tp&>(__a, __b);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<const _Tp&, const _Tp&>
+minmax(const _Tp& __a, const _Tp& __b)
+{
+    return _VSTD::minmax(__a, __b, __less<_Tp>());
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Tp, _Tp>
+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 );
+
+    ++__first;
+    if (__t.size() % 2 == 0)
+    {
+        if (__comp(*__first,  __result.first))
+            __result.first  = *__first;
+        else
+            __result.second = *__first;
+        ++__first;
+    }
+    
+    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;
+            }
+        else {
+            if (__comp(*__first, __result.first)) __result.first  = *__first;
+            if (__comp(__result.second, __prev))  __result.second = __prev;
+            }
+                
+        __first++;
+    }
+    return __result;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Tp, _Tp>
+minmax(initializer_list<_Tp> __t)
+{
+    return _VSTD::minmax(__t, __less<_Tp>());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+// random_shuffle
+
+// __independent_bits_engine
+
+template <unsigned long long _Xp, size_t _Rp>
+struct __log2_imp
+{
+    static const size_t value = _Xp & ((unsigned long long)(1) << _Rp) ? _Rp
+                                           : __log2_imp<_Xp, _Rp - 1>::value;
+};
+
+template <unsigned long long _Xp>
+struct __log2_imp<_Xp, 0>
+{
+    static const size_t value = 0;
+};
+
+template <size_t _Rp>
+struct __log2_imp<0, _Rp>
+{
+    static const size_t value = _Rp + 1;
+};
+
+template <class _UI, _UI _Xp>
+struct __log2
+{
+    static const size_t value = __log2_imp<_Xp,
+                                         sizeof(_UI) * __CHAR_BIT__ - 1>::value;
+};
+
+template<class _Engine, class _UIntType>
+class __independent_bits_engine
+{
+public:
+    // types
+    typedef _UIntType result_type;
+
+private:
+    typedef typename _Engine::result_type _Engine_result_type;
+    typedef typename conditional
+        <
+            sizeof(_Engine_result_type) <= sizeof(result_type),
+                result_type,
+                _Engine_result_type
+        >::type _Working_result_type;
+
+    _Engine& __e_;
+    size_t __w_;
+    size_t __w0_;
+    size_t __n_;
+    size_t __n0_;
+    _Working_result_type __y0_;
+    _Working_result_type __y1_;
+    _Engine_result_type __mask0_;
+    _Engine_result_type __mask1_;
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
+                                          + _Working_result_type(1);
+#else
+    static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()
+                                                      + _Working_result_type(1);
+#endif
+    static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value;
+    static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits;
+    static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits;
+
+public:
+    // constructors and seeding functions
+    __independent_bits_engine(_Engine& __e, size_t __w);
+
+    // generating functions
+    result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
+
+private:
+    result_type __eval(false_type);
+    result_type __eval(true_type);
+};
+
+template<class _Engine, class _UIntType>
+__independent_bits_engine<_Engine, _UIntType>
+    ::__independent_bits_engine(_Engine& __e, size_t __w)
+        : __e_(__e),
+          __w_(__w)
+{
+    __n_ = __w_ / __m + (__w_ % __m != 0);
+    __w0_ = __w_ / __n_;
+    if (_Rp == 0)
+        __y0_ = _Rp;
+    else if (__w0_ < _WDt)
+        __y0_ = (_Rp >> __w0_) << __w0_;
+    else
+        __y0_ = 0;
+    if (_Rp - __y0_ > __y0_ / __n_)
+    {
+        ++__n_;
+        __w0_ = __w_ / __n_;
+        if (__w0_ < _WDt)
+            __y0_ = (_Rp >> __w0_) << __w0_;
+        else
+            __y0_ = 0;
+    }
+    __n0_ = __n_ - __w_ % __n_;
+    if (__w0_ < _WDt - 1)
+        __y1_ = (_Rp >> (__w0_ + 1)) << (__w0_ + 1);
+    else
+        __y1_ = 0;
+    __mask0_ = __w0_ > 0 ? _Engine_result_type(~0) >> (_EDt - __w0_) :
+                          _Engine_result_type(0);
+    __mask1_ = __w0_ < _EDt - 1 ?
+                               _Engine_result_type(~0) >> (_EDt - (__w0_ + 1)) :
+                               _Engine_result_type(~0);
+}
+
+template<class _Engine, class _UIntType>
+inline
+_UIntType
+__independent_bits_engine<_Engine, _UIntType>::__eval(false_type)
+{
+    return static_cast<result_type>(__e_() & __mask0_);
+}
+
+template<class _Engine, class _UIntType>
+_UIntType
+__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
+{
+    result_type _Sp = 0;
+    for (size_t __k = 0; __k < __n0_; ++__k)
+    {
+        _Engine_result_type __u;
+        do
+        {
+            __u = __e_() - _Engine::min();
+        } while (__u >= __y0_);
+        if (__w0_ < _WDt)
+            _Sp <<= __w0_;
+        else
+            _Sp = 0;
+        _Sp += __u & __mask0_;
+    }
+    for (size_t __k = __n0_; __k < __n_; ++__k)
+    {
+        _Engine_result_type __u;
+        do
+        {
+            __u = __e_() - _Engine::min();
+        } while (__u >= __y1_);
+        if (__w0_ < _WDt - 1)
+            _Sp <<= __w0_ + 1;
+        else
+            _Sp = 0;
+        _Sp += __u & __mask1_;
+    }
+    return _Sp;
+}
+
+// uniform_int_distribution
+
+template<class _IntType = int>
+class uniform_int_distribution
+{
+public:
+    // types
+    typedef _IntType result_type;
+
+    class param_type
+    {
+        result_type __a_;
+        result_type __b_;
+    public:
+        typedef uniform_int_distribution distribution_type;
+
+        explicit param_type(result_type __a = 0,
+                            result_type __b = numeric_limits<result_type>::max())
+            : __a_(__a), __b_(__b) {}
+
+        result_type a() const {return __a_;}
+        result_type b() const {return __b_;}
+
+        friend bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+        friend bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    explicit uniform_int_distribution(result_type __a = 0,
+                                      result_type __b = numeric_limits<result_type>::max())
+        : __p_(param_type(__a, __b)) {}
+    explicit uniform_int_distribution(const param_type& __p) : __p_(__p) {}
+    void reset() {}
+
+    // generating functions
+    template<class _URNG> result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    result_type a() const {return __p_.a();}
+    result_type b() const {return __p_.b();}
+
+    param_type param() const {return __p_;}
+    void param(const param_type& __p) {__p_ = __p;}
+
+    result_type min() const {return a();}
+    result_type max() const {return b();}
+
+    friend bool operator==(const uniform_int_distribution& __x,
+                           const uniform_int_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend bool operator!=(const uniform_int_distribution& __x,
+                           const uniform_int_distribution& __y)
+            {return !(__x == __y);}
+};
+
+template<class _IntType>
+template<class _URNG>
+typename uniform_int_distribution<_IntType>::result_type
+uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
+{
+    typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t),
+                                            uint32_t, uint64_t>::type _UIntType;
+    const _UIntType _Rp = __p.b() - __p.a() + _UIntType(1);
+    if (_Rp == 1)
+        return __p.a();
+    const size_t _Dt = numeric_limits<_UIntType>::digits;
+    typedef __independent_bits_engine<_URNG, _UIntType> _Eng;
+    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)
+        ++__w;
+    _Eng __e(__g, __w);
+    _UIntType __u;
+    do
+    {
+        __u = __e();
+    } while (__u >= _Rp);
+    return static_cast<result_type>(__u + __p.a());
+}
+
+class _LIBCPP_TYPE_VIS __rs_default;
+
+_LIBCPP_FUNC_VIS __rs_default __rs_get();
+
+class _LIBCPP_TYPE_VIS __rs_default
+{
+    static unsigned __c_;
+
+    __rs_default();
+public:
+    typedef uint_fast32_t result_type;
+
+    static const result_type _Min = 0;
+    static const result_type _Max = 0xFFFFFFFF;
+
+    __rs_default(const __rs_default&);
+    ~__rs_default();
+
+    result_type operator()();
+
+    static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
+    static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
+
+    friend _LIBCPP_FUNC_VIS __rs_default __rs_get();
+};
+
+_LIBCPP_FUNC_VIS __rs_default __rs_get();
+
+template <class _RandomAccessIterator>
+void
+random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    typedef uniform_int_distribution<ptrdiff_t> _Dp;
+    typedef typename _Dp::param_type _Pp;
+    difference_type __d = __last - __first;
+    if (__d > 1)
+    {
+        _Dp __uid;
+        __rs_default __g = __rs_get();
+        for (--__last, --__d; __first < __last; ++__first, --__d)
+        {
+            difference_type __i = __uid(__g, _Pp(0, __d));
+            if (__i != difference_type(0))
+                swap(*__first, *(__first + __i));
+        }
+    }
+}
+
+template <class _RandomAccessIterator, class _RandomNumberGenerator>
+void
+random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+               _RandomNumberGenerator&& __rand)
+#else
+               _RandomNumberGenerator& __rand)
+#endif
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    difference_type __d = __last - __first;
+    if (__d > 1)
+    {
+        for (--__last; __first < __last; ++__first, --__d)
+        {
+            difference_type __i = __rand(__d);
+            swap(*__first, *(__first + __i));
+        }
+    }
+}
+
+template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
+    void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+                 _UniformRandomNumberGenerator&& __g)
+#else
+                 _UniformRandomNumberGenerator& __g)
+#endif
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    typedef uniform_int_distribution<ptrdiff_t> _Dp;
+    typedef typename _Dp::param_type _Pp;
+    difference_type __d = __last - __first;
+    if (__d > 1)
+    {
+        _Dp __uid;
+        for (--__last, --__d; __first < __last; ++__first, --__d)
+        {
+            difference_type __i = __uid(__g, _Pp(0, __d));
+            if (__i != difference_type(0))
+                swap(*__first, *(__first + __i));
+        }
+    }
+}
+
+template <class _InputIterator, class _Predicate>
+bool
+is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+        if (!__pred(*__first))
+            break;
+    for (; __first != __last; ++__first)
+        if (__pred(*__first))
+            return false;
+    return true;
+}
+
+// partition
+
+template <class _Predicate, class _ForwardIterator>
+_ForwardIterator
+__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag)
+{
+    while (true)
+    {
+        if (__first == __last)
+            return __first;
+        if (!__pred(*__first))
+            break;
+        ++__first;
+    }
+    for (_ForwardIterator __p = __first; ++__p != __last;)
+    {
+        if (__pred(*__p))
+        {
+            swap(*__first, *__p);
+            ++__first;
+        }
+    }
+    return __first;
+}
+
+template <class _Predicate, class _BidirectionalIterator>
+_BidirectionalIterator
+__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+            bidirectional_iterator_tag)
+{
+    while (true)
+    {
+        while (true)
+        {
+            if (__first == __last)
+                return __first;
+            if (!__pred(*__first))
+                break;
+            ++__first;
+        }
+        do
+        {
+            if (__first == --__last)
+                return __first;
+        } while (!__pred(*__last));
+        swap(*__first, *__last);
+        ++__first;
+    }
+}
+
+template <class _ForwardIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+    return _VSTD::__partition<typename add_lvalue_reference<_Predicate>::type>
+                            (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+// partition_copy
+
+template <class _InputIterator, class _OutputIterator1,
+          class _OutputIterator2, class _Predicate>
+pair<_OutputIterator1, _OutputIterator2>
+partition_copy(_InputIterator __first, _InputIterator __last,
+               _OutputIterator1 __out_true, _OutputIterator2 __out_false,
+               _Predicate __pred)
+{
+    for (; __first != __last; ++__first)
+    {
+        if (__pred(*__first))
+        {
+            *__out_true = *__first;
+            ++__out_true;
+        }
+        else
+        {
+            *__out_false = *__first;
+            ++__out_false;
+        }
+    }
+    return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false);
+}
+
+// partition_point
+
+template<class _ForwardIterator, class _Predicate>
+_ForwardIterator
+partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+    typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+    difference_type __len = _VSTD::distance(__first, __last);
+    while (__len != 0)
+    {
+        difference_type __l2 = __len / 2;
+        _ForwardIterator __m = __first;
+        _VSTD::advance(__m, __l2);
+        if (__pred(*__m))
+        {
+            __first = ++__m;
+            __len -= __l2 + 1;
+        }
+        else
+            __len = __l2;
+    }
+    return __first;
+}
+
+// stable_partition
+
+template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
+_ForwardIterator
+__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
+                   _Distance __len, _Pair __p, forward_iterator_tag __fit)
+{
+    // *__first is known to be false
+    // __len >= 1
+    if (__len == 1)
+        return __first;
+    if (__len == 2)
+    {
+        _ForwardIterator __m = __first;
+        if (__pred(*++__m))
+        {
+            swap(*__first, *__m);
+            return __m;
+        }
+        return __first;
+    }
+    if (__len <= __p.second)
+    {   // The buffer is big enough to use
+        typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+        __destruct_n __d(0);
+        unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
+        // Move the falses into the temporary buffer, and the trues to the front of the line
+        // Update __first to always point to the end of the trues
+        value_type* __t = __p.first;
+        ::new(__t) value_type(_VSTD::move(*__first));
+        __d.__incr((value_type*)0);
+        ++__t;
+        _ForwardIterator __i = __first;
+        while (++__i != __last)
+        {
+            if (__pred(*__i))
+            {
+                *__first = _VSTD::move(*__i);
+                ++__first;
+            }
+            else
+            {
+                ::new(__t) value_type(_VSTD::move(*__i));
+                __d.__incr((value_type*)0);
+                ++__t;
+            }
+        }
+        // All trues now at start of range, all falses in buffer
+        // Move falses back into range, but don't mess up __first which points to first false
+        __i = __first;
+        for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, ++__i)
+            *__i = _VSTD::move(*__t2);
+        // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
+        return __first;
+    }
+    // Else not enough buffer, do in place
+    // __len >= 3
+    _ForwardIterator __m = __first;
+    _Distance __len2 = __len / 2;  // __len2 >= 2
+    _VSTD::advance(__m, __len2);
+    // recurse on [__first, __m), *__first know to be false
+    // F?????????????????
+    // f       m         l
+    typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
+    _ForwardIterator __first_false = __stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit);
+    // TTTFFFFF??????????
+    // f  ff   m         l
+    // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
+    _ForwardIterator __m1 = __m;
+    _ForwardIterator __second_false = __last;
+    _Distance __len_half = __len - __len2;
+    while (__pred(*__m1))
+    {
+        if (++__m1 == __last)
+            goto __second_half_done;
+        --__len_half;
+    }
+    // TTTFFFFFTTTF??????
+    // f  ff   m  m1     l
+    __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit);
+__second_half_done:
+    // TTTFFFFFTTTTTFFFFF
+    // f  ff   m    sf   l
+    return _VSTD::rotate(__first_false, __m, __second_false);
+    // TTTTTTTTFFFFFFFFFF
+    //         |
+}
+
+struct __return_temporary_buffer
+{
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);}
+};
+
+template <class _Predicate, class _ForwardIterator>
+_ForwardIterator
+__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred,
+                   forward_iterator_tag)
+{
+    const unsigned __alloc_limit = 3;  // might want to make this a function of trivial assignment
+    // Either prove all true and return __first or point to first false
+    while (true)
+    {
+        if (__first == __last)
+            return __first;
+        if (!__pred(*__first))
+            break;
+        ++__first;
+    }
+    // We now have a reduced range [__first, __last)
+    // *__first is known to be false
+    typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+    typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+    difference_type __len = _VSTD::distance(__first, __last);
+    pair<value_type*, ptrdiff_t> __p(0, 0);
+    unique_ptr<value_type, __return_temporary_buffer> __h;
+    if (__len >= __alloc_limit)
+    {
+        __p = _VSTD::get_temporary_buffer<value_type>(__len);
+        __h.reset(__p.first);
+    }
+    return __stable_partition<typename add_lvalue_reference<_Predicate>::type>
+                             (__first, __last, __pred, __len, __p, forward_iterator_tag());
+}
+
+template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
+_BidirectionalIterator
+__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+                   _Distance __len, _Pair __p, bidirectional_iterator_tag __bit)
+{
+    // *__first is known to be false
+    // *__last is known to be true
+    // __len >= 2
+    if (__len == 2)
+    {
+        swap(*__first, *__last);
+        return __last;
+    }
+    if (__len == 3)
+    {
+        _BidirectionalIterator __m = __first;
+        if (__pred(*++__m))
+        {
+            swap(*__first, *__m);
+            swap(*__m, *__last);
+            return __last;
+        }
+        swap(*__m, *__last);
+        swap(*__first, *__m);
+        return __m;
+    }
+    if (__len <= __p.second)
+    {   // The buffer is big enough to use
+        typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+        __destruct_n __d(0);
+        unique_ptr<value_type, __destruct_n&> __h(__p.first, __d);
+        // Move the falses into the temporary buffer, and the trues to the front of the line
+        // Update __first to always point to the end of the trues
+        value_type* __t = __p.first;
+        ::new(__t) value_type(_VSTD::move(*__first));
+        __d.__incr((value_type*)0);
+        ++__t;
+        _BidirectionalIterator __i = __first;
+        while (++__i != __last)
+        {
+            if (__pred(*__i))
+            {
+                *__first = _VSTD::move(*__i);
+                ++__first;
+            }
+            else
+            {
+                ::new(__t) value_type(_VSTD::move(*__i));
+                __d.__incr((value_type*)0);
+                ++__t;
+            }
+        }
+        // move *__last, known to be true
+        *__first = _VSTD::move(*__i);
+        __i = ++__first;
+        // All trues now at start of range, all falses in buffer
+        // Move falses back into range, but don't mess up __first which points to first false
+        for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, ++__i)
+            *__i = _VSTD::move(*__t2);
+        // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer
+        return __first;
+    }
+    // Else not enough buffer, do in place
+    // __len >= 4
+    _BidirectionalIterator __m = __first;
+    _Distance __len2 = __len / 2;  // __len2 >= 2
+    _VSTD::advance(__m, __len2);
+    // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false
+    // F????????????????T
+    // f       m        l
+    _BidirectionalIterator __m1 = __m;
+    _BidirectionalIterator __first_false = __first;
+    _Distance __len_half = __len2;
+    while (!__pred(*--__m1))
+    {
+        if (__m1 == __first)
+            goto __first_half_done;
+        --__len_half;
+    }
+    // F???TFFF?????????T
+    // f   m1  m        l
+    typedef typename add_lvalue_reference<_Predicate>::type _PredRef;
+    __first_false = __stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit);
+__first_half_done:
+    // TTTFFFFF?????????T
+    // f  ff   m        l
+    // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true
+    __m1 = __m;
+    _BidirectionalIterator __second_false = __last;
+    ++__second_false;
+    __len_half = __len - __len2;
+    while (__pred(*__m1))
+    {
+        if (++__m1 == __last)
+            goto __second_half_done;
+        --__len_half;
+    }
+    // TTTFFFFFTTTF?????T
+    // f  ff   m  m1    l
+    __second_false = __stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit);
+__second_half_done:
+    // TTTFFFFFTTTTTFFFFF
+    // f  ff   m    sf  l
+    return _VSTD::rotate(__first_false, __m, __second_false);
+    // TTTTTTTTFFFFFFFFFF
+    //         |
+}
+
+template <class _Predicate, class _BidirectionalIterator>
+_BidirectionalIterator
+__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred,
+                   bidirectional_iterator_tag)
+{
+    typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
+    typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+    const difference_type __alloc_limit = 4;  // might want to make this a function of trivial assignment
+    // Either prove all true and return __first or point to first false
+    while (true)
+    {
+        if (__first == __last)
+            return __first;
+        if (!__pred(*__first))
+            break;
+        ++__first;
+    }
+    // __first points to first false, everything prior to __first is already set.
+    // Either prove [__first, __last) is all false and return __first, or point __last to last true
+    do
+    {
+        if (__first == --__last)
+            return __first;
+    } while (!__pred(*__last));
+    // We now have a reduced range [__first, __last]
+    // *__first is known to be false
+    // *__last is known to be true
+    // __len >= 2
+    difference_type __len = _VSTD::distance(__first, __last) + 1;
+    pair<value_type*, ptrdiff_t> __p(0, 0);
+    unique_ptr<value_type, __return_temporary_buffer> __h;
+    if (__len >= __alloc_limit)
+    {
+        __p = _VSTD::get_temporary_buffer<value_type>(__len);
+        __h.reset(__p.first);
+    }
+    return __stable_partition<typename add_lvalue_reference<_Predicate>::type>
+                             (__first, __last, __pred, __len, __p, bidirectional_iterator_tag());
+}
+
+template <class _ForwardIterator, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
+{
+    return __stable_partition<typename add_lvalue_reference<_Predicate>::type>
+                             (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category());
+}
+
+// is_sorted_until
+
+template <class _ForwardIterator, class _Compare>
+_ForwardIterator
+is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __i = __first;
+        while (++__i != __last)
+        {
+            if (__comp(*__i, *__first))
+                return __i;
+            __first = __i;
+        }
+    }
+    return __last;
+}
+
+template<class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
+{
+    return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+// is_sorted
+
+template <class _ForwardIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+    return _VSTD::is_sorted_until(__first, __last, __comp) == __last;
+}
+
+template<class _ForwardIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+is_sorted(_ForwardIterator __first, _ForwardIterator __last)
+{
+    return _VSTD::is_sorted(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+// sort
+
+// stable, 2-3 compares, 0-2 swaps
+
+template <class _Compare, class _ForwardIterator>
+unsigned
+__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c)
+{
+    unsigned __r = 0;
+    if (!__c(*__y, *__x))          // if x <= y
+    {
+        if (!__c(*__z, *__y))      // if y <= z
+            return __r;            // x <= y && y <= z
+                                   // x <= y && y > z
+        swap(*__y, *__z);          // x <= z && y < z
+        __r = 1;
+        if (__c(*__y, *__x))       // if x > y
+        {
+            swap(*__x, *__y);      // x < y && y <= z
+            __r = 2;
+        }
+        return __r;                // x <= y && y < z
+    }
+    if (__c(*__z, *__y))           // x > y, if y > z
+    {
+        swap(*__x, *__z);          // x < y && y < z
+        __r = 1;
+        return __r;
+    }
+    swap(*__x, *__y);              // x > y && y <= z
+    __r = 1;                       // x < y && x <= z
+    if (__c(*__z, *__y))           // if y > z
+    {
+        swap(*__y, *__z);          // x <= y && y < z
+        __r = 2;
+    }
+    return __r;
+}                                  // x <= y && y <= z
+
+// stable, 3-6 compares, 0-5 swaps
+
+template <class _Compare, class _ForwardIterator>
+unsigned
+__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
+            _ForwardIterator __x4, _Compare __c)
+{
+    unsigned __r = __sort3<_Compare>(__x1, __x2, __x3, __c);
+    if (__c(*__x4, *__x3))
+    {
+        swap(*__x3, *__x4);
+        ++__r;
+        if (__c(*__x3, *__x2))
+        {
+            swap(*__x2, *__x3);
+            ++__r;
+            if (__c(*__x2, *__x1))
+            {
+                swap(*__x1, *__x2);
+                ++__r;
+            }
+        }
+    }
+    return __r;
+}
+
+// stable, 4-10 compares, 0-9 swaps
+
+template <class _Compare, class _ForwardIterator>
+unsigned
+__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3,
+            _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c)
+{
+    unsigned __r = __sort4<_Compare>(__x1, __x2, __x3, __x4, __c);
+    if (__c(*__x5, *__x4))
+    {
+        swap(*__x4, *__x5);
+        ++__r;
+        if (__c(*__x4, *__x3))
+        {
+            swap(*__x3, *__x4);
+            ++__r;
+            if (__c(*__x3, *__x2))
+            {
+                swap(*__x2, *__x3);
+                ++__r;
+                if (__c(*__x2, *__x1))
+                {
+                    swap(*__x1, *__x2);
+                    ++__r;
+                }
+            }
+        }
+    }
+    return __r;
+}
+
+// Assumes size > 0
+template <class _Compare, class _BirdirectionalIterator>
+void
+__selection_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp)
+{
+    _BirdirectionalIterator __lm1 = __last;
+    for (--__lm1; __first != __lm1; ++__first)
+    {
+        _BirdirectionalIterator __i = _VSTD::min_element<_BirdirectionalIterator,
+                                                        typename add_lvalue_reference<_Compare>::type>
+                                                       (__first, __last, __comp);
+        if (__i != __first)
+            swap(*__first, *__i);
+    }
+}
+
+template <class _Compare, class _BirdirectionalIterator>
+void
+__insertion_sort(_BirdirectionalIterator __first, _BirdirectionalIterator __last, _Compare __comp)
+{
+    typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type;
+    if (__first != __last)
+    {
+        _BirdirectionalIterator __i = __first;
+        for (++__i; __i != __last; ++__i)
+        {
+            _BirdirectionalIterator __j = __i;
+            value_type __t(_VSTD::move(*__j));
+            for (_BirdirectionalIterator __k = __i; __k != __first && __comp(__t,  *--__k); --__j)
+                *__j = _VSTD::move(*__k);
+            *__j = _VSTD::move(__t);
+        }
+    }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+    _RandomAccessIterator __j = __first+2;
+    __sort3<_Compare>(__first, __first+1, __j, __comp);
+    for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
+    {
+        if (__comp(*__i, *__j))
+        {
+            value_type __t(_VSTD::move(*__i));
+            _RandomAccessIterator __k = __j;
+            __j = __i;
+            do
+            {
+                *__j = _VSTD::move(*__k);
+                __j = __k;
+            } while (__j != __first && __comp(__t, *--__k));
+            *__j = _VSTD::move(__t);
+        }
+        __j = __i;
+    }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+bool
+__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    switch (__last - __first)
+    {
+    case 0:
+    case 1:
+        return true;
+    case 2:
+        if (__comp(*--__last, *__first))
+            swap(*__first, *__last);
+        return true;
+    case 3:
+        _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
+        return true;
+    case 4:
+        _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
+        return true;
+    case 5:
+        _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
+        return true;
+    }
+    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+    _RandomAccessIterator __j = __first+2;
+    __sort3<_Compare>(__first, __first+1, __j, __comp);
+    const unsigned __limit = 8;
+    unsigned __count = 0;
+    for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
+    {
+        if (__comp(*__i, *__j))
+        {
+            value_type __t(_VSTD::move(*__i));
+            _RandomAccessIterator __k = __j;
+            __j = __i;
+            do
+            {
+                *__j = _VSTD::move(*__k);
+                __j = __k;
+            } while (__j != __first && __comp(__t, *--__k));
+            *__j = _VSTD::move(__t);
+            if (++__count == __limit)
+                return ++__i == __last;
+        }
+        __j = __i;
+    }
+    return true;
+}
+
+template <class _Compare, class _BirdirectionalIterator>
+void
+__insertion_sort_move(_BirdirectionalIterator __first1, _BirdirectionalIterator __last1,
+                      typename iterator_traits<_BirdirectionalIterator>::value_type* __first2, _Compare __comp)
+{
+    typedef typename iterator_traits<_BirdirectionalIterator>::value_type value_type;
+    if (__first1 != __last1)
+    {
+        __destruct_n __d(0);
+        unique_ptr<value_type, __destruct_n&> __h(__first2, __d);
+        value_type* __last2 = __first2;
+        ::new(__last2) value_type(_VSTD::move(*__first1));
+        __d.__incr((value_type*)0);
+        for (++__last2; ++__first1 != __last1; ++__last2)
+        {
+            value_type* __j2 = __last2;
+            value_type* __i2 = __j2;
+            if (__comp(*__first1, *--__i2))
+            {
+                ::new(__j2) value_type(_VSTD::move(*__i2));
+                __d.__incr((value_type*)0);
+                for (--__j2; __i2 != __first2 && __comp(*__first1,  *--__i2); --__j2)
+                    *__j2 = _VSTD::move(*__i2);
+                *__j2 = _VSTD::move(*__first1);
+            }
+            else
+            {
+                ::new(__j2) value_type(_VSTD::move(*__first1));
+                __d.__incr((value_type*)0);
+            }
+        }
+        __h.release();
+    }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    // _Compare is known to be a reference type
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+    const difference_type __limit = is_trivially_copy_constructible<value_type>::value &&
+                                    is_trivially_copy_assignable<value_type>::value ? 30 : 6;
+    while (true)
+    {
+    __restart:
+        difference_type __len = __last - __first;
+        switch (__len)
+        {
+        case 0:
+        case 1:
+            return;
+        case 2:
+            if (__comp(*--__last, *__first))
+                swap(*__first, *__last);
+            return;
+        case 3:
+            _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
+            return;
+        case 4:
+            _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
+            return;
+        case 5:
+            _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
+            return;
+        }
+        if (__len <= __limit)
+        {
+            _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
+            return;
+        }
+        // __len > 5
+        _RandomAccessIterator __m = __first;
+        _RandomAccessIterator __lm1 = __last;
+        --__lm1;
+        unsigned __n_swaps;
+        {
+        difference_type __delta;
+        if (__len >= 1000)
+        {
+            __delta = __len/2;
+            __m += __delta;
+            __delta /= 2;
+            __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp);
+        }
+        else
+        {
+            __delta = __len/2;
+            __m += __delta;
+            __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp);
+        }
+        }
+        // *__m is median
+        // partition [__first, __m) < *__m and *__m <= [__m, __last)
+        // (this inhibits tossing elements equivalent to __m around unnecessarily)
+        _RandomAccessIterator __i = __first;
+        _RandomAccessIterator __j = __lm1;
+        // j points beyond range to be tested, *__m is known to be <= *__lm1
+        // The search going up is known to be guarded but the search coming down isn't.
+        // Prime the downward search with a guard.
+        if (!__comp(*__i, *__m))  // if *__first == *__m
+        {
+            // *__first == *__m, *__first doesn't go in first part
+            // manually guard downward moving __j against __i
+            while (true)
+            {
+                if (__i == --__j)
+                {
+                    // *__first == *__m, *__m <= all other elements
+                    // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
+                    ++__i;  // __first + 1
+                    __j = __last;
+                    if (!__comp(*__first, *--__j))  // we need a guard if *__first == *(__last-1)
+                    {
+                        while (true)
+                        {
+                            if (__i == __j)
+                                return;  // [__first, __last) all equivalent elements
+                            if (__comp(*__first, *__i))
+                            {
+                                swap(*__i, *__j);
+                                ++__n_swaps;
+                                ++__i;
+                                break;
+                            }
+                            ++__i;
+                        }
+                    }
+                    // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
+                    if (__i == __j)
+                        return;
+                    while (true)
+                    {
+                        while (!__comp(*__first, *__i))
+                            ++__i;
+                        while (__comp(*__first, *--__j))
+                            ;
+                        if (__i >= __j)
+                            break;
+                        swap(*__i, *__j);
+                        ++__n_swaps;
+                        ++__i;
+                    }
+                    // [__first, __i) == *__first and *__first < [__i, __last)
+                    // The first part is sorted, sort the secod part
+                    // _VSTD::__sort<_Compare>(__i, __last, __comp);
+                    __first = __i;
+                    goto __restart;
+                }
+                if (__comp(*__j, *__m))
+                {
+                    swap(*__i, *__j);
+                    ++__n_swaps;
+                    break;  // found guard for downward moving __j, now use unguarded partition
+                }
+            }
+        }
+        // It is known that *__i < *__m
+        ++__i;
+        // j points beyond range to be tested, *__m is known to be <= *__lm1
+        // if not yet partitioned...
+        if (__i < __j)
+        {
+            // known that *(__i - 1) < *__m
+            // known that __i <= __m
+            while (true)
+            {
+                // __m still guards upward moving __i
+                while (__comp(*__i, *__m))
+                    ++__i;
+                // It is now known that a guard exists for downward moving __j
+                while (!__comp(*--__j, *__m))
+                    ;
+                if (__i > __j)
+                    break;
+                swap(*__i, *__j);
+                ++__n_swaps;
+                // It is known that __m != __j
+                // If __m just moved, follow it
+                if (__m == __i)
+                    __m = __j;
+                ++__i;
+            }
+        }
+        // [__first, __i) < *__m and *__m <= [__i, __last)
+        if (__i != __m && __comp(*__m, *__i))
+        {
+            swap(*__i, *__m);
+            ++__n_swaps;
+        }
+        // [__first, __i) < *__i and *__i <= [__i+1, __last)
+        // If we were given a perfect partition, see if insertion sort is quick...
+        if (__n_swaps == 0)
+        {
+            bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp);
+            if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp))
+            {
+                if (__fs)
+                    return;
+                __last = __i;
+                continue;
+            }
+            else
+            {
+                if (__fs)
+                {
+                    __first = ++__i;
+                    continue;
+                }
+            }
+        }
+        // sort smaller range with recursive call and larger with tail recursion elimination
+        if (__i - __first < __last - __i)
+        {
+            _VSTD::__sort<_Compare>(__first, __i, __comp);
+            // _VSTD::__sort<_Compare>(__i+1, __last, __comp);
+            __first = ++__i;
+        }
+        else
+        {
+            _VSTD::__sort<_Compare>(__i+1, __last, __comp);
+            // _VSTD::__sort<_Compare>(__first, __i, __comp);
+            __last = __i;
+        }
+    }
+}
+
+// This forwarder keeps the top call and the recursive calls using the same instantiation, forcing a reference _Compare
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __sort<_Comp_ref>(__first, __last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __sort<_Comp_ref>(__first, __last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sort(_Tp** __first, _Tp** __last)
+{
+    _VSTD::sort((size_t*)__first, (size_t*)__last, __less<size_t>());
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last)
+{
+    _VSTD::sort(__first.base(), __last.base());
+}
+
+template <class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last, _Compare __comp)
+{
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    _VSTD::sort<_Tp*, _Comp_ref>(__first.base(), __last.base(), __comp);
+}
+
+#ifdef _LIBCPP_MSVC
+#pragma warning( push )
+#pragma warning( disable: 4231)
+#endif // _LIBCPP_MSVC
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&))
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&))
+#ifdef _LIBCPP_MSVC
+#pragma warning( pop )
+#endif  // _LIBCPP_MSVC
+
+// lower_bound
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+_ForwardIterator
+__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+    typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+    difference_type __len = _VSTD::distance(__first, __last);
+    while (__len != 0)
+    {
+        difference_type __l2 = __len / 2;
+        _ForwardIterator __m = __first;
+        _VSTD::advance(__m, __l2);
+        if (__comp(*__m, __value_))
+        {
+            __first = ++__m;
+            __len -= __l2 + 1;
+        }
+        else
+            __len = __l2;
+    }
+    return __first;
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __lower_bound<_Comp_ref>(__first, __last, __value_, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+    return _VSTD::lower_bound(__first, __last, __value_,
+                             __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+}
+
+// upper_bound
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+_ForwardIterator
+__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+    typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+    difference_type __len = _VSTD::distance(__first, __last);
+    while (__len != 0)
+    {
+        difference_type __l2 = __len / 2;
+        _ForwardIterator __m = __first;
+        _VSTD::advance(__m, __l2);
+        if (__comp(__value_, *__m))
+            __len = __l2;
+        else
+        {
+            __first = ++__m;
+            __len -= __l2 + 1;
+        }
+    }
+    return __first;
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __upper_bound<_Comp_ref>(__first, __last, __value_, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_ForwardIterator
+upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+    return _VSTD::upper_bound(__first, __last, __value_,
+                             __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>());
+}
+
+// equal_range
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+pair<_ForwardIterator, _ForwardIterator>
+__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+    typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
+    difference_type __len = _VSTD::distance(__first, __last);
+    while (__len != 0)
+    {
+        difference_type __l2 = __len / 2;
+        _ForwardIterator __m = __first;
+        _VSTD::advance(__m, __l2);
+        if (__comp(*__m, __value_))
+        {
+            __first = ++__m;
+            __len -= __l2 + 1;
+        }
+        else if (__comp(__value_, *__m))
+        {
+            __last = __m;
+            __len = __l2;
+        }
+        else
+        {
+            _ForwardIterator __mp1 = __m;
+            return pair<_ForwardIterator, _ForwardIterator>
+                   (
+                      __lower_bound<_Compare>(__first, __m, __value_, __comp),
+                      __upper_bound<_Compare>(++__mp1, __last, __value_, __comp)
+                   );
+        }
+    }
+    return pair<_ForwardIterator, _ForwardIterator>(__first, __first);
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_ForwardIterator, _ForwardIterator>
+equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __equal_range<_Comp_ref>(__first, __last, __value_, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __equal_range<_Comp_ref>(__first, __last, __value_, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_ForwardIterator, _ForwardIterator>
+equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+    return _VSTD::equal_range(__first, __last, __value_,
+                             __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+}
+
+// binary_search
+
+template <class _Compare, class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+    __first = __lower_bound<_Compare>(__first, __last, __value_, __comp);
+    return __first != __last && !__comp(__value_, *__first);
+}
+
+template <class _ForwardIterator, class _Tp, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __binary_search<_Comp_ref>(__first, __last, __value_, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __binary_search<_Comp_ref>(__first, __last, __value_, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
+{
+    return _VSTD::binary_search(__first, __last, __value_,
+                             __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>());
+}
+
+// merge
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_OutputIterator
+__merge(_InputIterator1 __first1, _InputIterator1 __last1,
+        _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+    for (; __first1 != __last1; ++__result)
+    {
+        if (__first2 == __last2)
+            return _VSTD::copy(__first1, __last1, __result);
+        if (__comp(*__first2, *__first1))
+        {
+            *__result = *__first2;
+            ++__first2;
+        }
+        else
+        {
+            *__result = *__first1;
+            ++__first1;
+        }
+    }
+    return _VSTD::copy(__first2, __last2, __result);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+merge(_InputIterator1 __first1, _InputIterator1 __last1,
+      _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+merge(_InputIterator1 __first1, _InputIterator1 __last1,
+      _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+    typedef typename iterator_traits<_InputIterator1>::value_type __v1;
+    typedef typename iterator_traits<_InputIterator2>::value_type __v2;
+    return merge(__first1, __last1, __first2, __last2, __result, __less<__v1, __v2>());
+}
+
+// inplace_merge
+
+template <class _Compare, class _BidirectionalIterator>
+void
+__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+                _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+                                 typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
+                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)
+            ::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);
+    }
+    else
+    {
+        value_type* __p = __buff;
+        for (_BidirectionalIterator __i = __middle; __i != __last; __d.__incr((value_type*)0), ++__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));
+    }
+}
+
+template <class _Compare, class _BidirectionalIterator>
+void
+__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+                _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1,
+                                 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;
+        // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
+        for (; true; ++__first, --__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
+        //     all elements in:
+        //         [__first, __m1)  <= [__middle, __m2)
+        //         [__middle, __m2) <  [__m1, __middle)
+        //         [__m1, __middle) <= [__m2, __last)
+        //     and __m1 or __m2 is in the middle of its range
+        _BidirectionalIterator __m1;  // "median" of [__first, __middle)
+        _BidirectionalIterator __m2;  // "median" of [__middle, __last)
+        difference_type __len11;      // distance(__first, __m1)
+        difference_type __len21;      // distance(__middle, __m2)
+        // binary search smaller range
+        if (__len1 < __len2)
+        {   // __len >= 1, __len2 >= 2
+            __len21 = __len2 / 2;
+            __m2 = __middle;
+            _VSTD::advance(__m2, __len21);
+            __m1 = __upper_bound<_Compare>(__first, __middle, *__m2, __comp);
+            __len11 = _VSTD::distance(__first, __m1);
+        }
+        else
+        {
+            if (__len1 == 1)
+            {   // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1
+                // It is known *__first > *__middle
+                swap(*__first, *__middle);
+                return;
+            }
+            // __len1 >= 2, __len2 >= 1
+            __len11 = __len1 / 2;
+            __m1 = __first;
+            _VSTD::advance(__m1, __len11);
+            __m2 = __lower_bound<_Compare>(__middle, __last, *__m1, __comp);
+            __len21 = _VSTD::distance(__middle, __m2);
+        }
+        difference_type __len12 = __len1 - __len11;  // distance(__m1, __middle)
+        difference_type __len22 = __len2 - __len21;  // distance(__m2, __last)
+        // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last)
+        // swap middle two partitions
+        __middle = _VSTD::rotate(__m1, __middle, __m2);
+        // __len12 and __len21 now have swapped meanings
+        // merge smaller range with recurisve call and larger with tail recursion elimination
+        if (__len11 + __len21 < __len12 + __len22)
+        {
+            __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
+//          __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
+            __first = __middle;
+            __middle = __m2;
+            __len1 = __len12;
+            __len2 = __len22;
+        }
+        else
+        {
+            __inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size);
+//          __inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size);
+            __last = __middle;
+            __middle = __m1;
+            __len1 = __len11;
+            __len2 = __len21;
+        }
+    }
+}
+
+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
+inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
+              _Compare __comp)
+{
+    typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
+    typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
+    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);
+    }
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __c, __len1, __len2,
+                                            __buf.first, __buf.second);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
+                                            __buf.first, __buf.second);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last)
+{
+    _VSTD::inplace_merge(__first, __middle, __last,
+                        __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
+}
+
+// stable_sort
+
+template <class _Compare, class _InputIterator1, class _InputIterator2>
+void
+__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1,
+        _InputIterator2 __first2, _InputIterator2 __last2,
+        typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp)
+{
+    typedef typename iterator_traits<_InputIterator1>::value_type value_type;
+    __destruct_n __d(0);
+    unique_ptr<value_type, __destruct_n&> __h(__result, __d);
+    for (; true; ++__result)
+    {
+        if (__first1 == __last1)
+        {
+            for (; __first2 != __last2; ++__first2, ++__result, __d.__incr((value_type*)0))
+                ::new (__result) value_type(_VSTD::move(*__first2));
+            __h.release();
+            return;
+        }
+        if (__first2 == __last2)
+        {
+            for (; __first1 != __last1; ++__first1, ++__result, __d.__incr((value_type*)0))
+                ::new (__result) value_type(_VSTD::move(*__first1));
+            __h.release();
+            return;
+        }
+        if (__comp(*__first2, *__first1))
+        {
+            ::new (__result) value_type(_VSTD::move(*__first2));
+            __d.__incr((value_type*)0);
+            ++__first2;
+        }
+        else
+        {
+            ::new (__result) value_type(_VSTD::move(*__first1));
+            __d.__incr((value_type*)0);
+            ++__first1;
+        }
+    }
+}
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+void
+__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1,
+        _InputIterator2 __first2, _InputIterator2 __last2,
+        _OutputIterator __result, _Compare __comp)
+{
+    for (; __first1 != __last1; ++__result)
+    {
+        if (__first2 == __last2)
+        {
+            for (; __first1 != __last1; ++__first1, ++__result)
+                *__result = _VSTD::move(*__first1);
+            return;
+        }
+        if (__comp(*__first2, *__first1))
+        {
+            *__result = _VSTD::move(*__first2);
+            ++__first2;
+        }
+        else
+        {
+            *__result = _VSTD::move(*__first1);
+            ++__first1;
+        }
+    }
+    for (; __first2 != __last2; ++__first2, ++__result)
+        *__result = _VSTD::move(*__first2);
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+              typename iterator_traits<_RandomAccessIterator>::difference_type __len,
+              typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size);
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp,
+                   typename iterator_traits<_RandomAccessIterator>::difference_type __len,
+                   typename iterator_traits<_RandomAccessIterator>::value_type* __first2)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+    switch (__len)
+    {
+    case 0:
+        return;
+    case 1:
+        ::new(__first2) value_type(_VSTD::move(*__first1));
+        return;
+    case 2:
+       __destruct_n __d(0);
+        unique_ptr<value_type, __destruct_n&> __h2(__first2, __d);
+         if (__comp(*--__last1, *__first1))
+        {
+            ::new(__first2) value_type(_VSTD::move(*__last1));
+            __d.__incr((value_type*)0);
+            ++__first2;
+            ::new(__first2) value_type(_VSTD::move(*__first1));
+        }
+        else
+        {
+            ::new(__first2) value_type(_VSTD::move(*__first1));
+            __d.__incr((value_type*)0);
+            ++__first2;
+            ::new(__first2) value_type(_VSTD::move(*__last1));
+        }
+        __h2.release();
+        return;
+    }
+    if (__len <= 8)
+    {
+        __insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp);
+        return;
+    }
+    typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
+    _RandomAccessIterator __m = __first1 + __l2;
+    __stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2);
+    __stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2);
+    __merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp);
+}
+
+template <class _Tp>
+struct __stable_sort_switch
+{
+    static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value;
+};
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+              typename iterator_traits<_RandomAccessIterator>::difference_type __len,
+              typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    switch (__len)
+    {
+    case 0:
+    case 1:
+        return;
+    case 2:
+        if (__comp(*--__last, *__first))
+            swap(*__first, *__last);
+        return;
+    }
+    if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value))
+    {
+        __insertion_sort<_Compare>(__first, __last, __comp);
+        return;
+    }
+    typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2;
+    _RandomAccessIterator __m = __first + __l2;
+    if (__len <= __buff_size)
+    {
+        __destruct_n __d(0);
+        unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
+        __stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff);
+        __d.__set(__l2, (value_type*)0);
+        __stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2);
+        __d.__set(__len, (value_type*)0);
+        __merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
+//         __merge<_Compare>(move_iterator<value_type*>(__buff),
+//                           move_iterator<value_type*>(__buff + __l2),
+//                           move_iterator<_RandomAccessIterator>(__buff + __l2),
+//                           move_iterator<_RandomAccessIterator>(__buff + __len),
+//                           __first, __comp);
+        return;
+    }
+    __stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size);
+    __stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size);
+    __inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size);
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    difference_type __len = __last - __first;
+    pair<value_type*, ptrdiff_t> __buf(0, 0);
+    unique_ptr<value_type, __return_temporary_buffer> __h;
+    if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value))
+    {
+        __buf = _VSTD::get_temporary_buffer<value_type>(__len);
+        __h.reset(__buf.first);
+    }
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __stable_sort<_Comp_ref>(__first, __last, __c, __len, __buf.first, __buf.second);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    _VSTD::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// is_heap_until
+
+template <class _RandomAccessIterator, class _Compare>
+_RandomAccessIterator
+is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    difference_type __len = __last - __first;
+    difference_type __p = 0;
+    difference_type __c = 1;
+    _RandomAccessIterator __pp = __first;
+    while (__c < __len)
+    {
+        _RandomAccessIterator __cp = __first + __c;
+        if (__comp(*__pp, *__cp))
+            return __cp;
+        ++__c;
+        ++__cp;
+        if (__c == __len)
+            return __last;
+        if (__comp(*__pp, *__cp))
+            return __cp;
+        ++__p;
+        ++__pp;
+        __c = 2 * __p + 1;
+    }
+    return __last;
+}
+
+template<class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_RandomAccessIterator
+is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    return _VSTD::is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// is_heap
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    return _VSTD::is_heap_until(__first, __last, __comp) == __last;
+}
+
+template<class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    return _VSTD::is_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// push_heap
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__push_heap_front(_RandomAccessIterator __first, _RandomAccessIterator, _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)
+    {
+        difference_type __p = 0;
+        _RandomAccessIterator __pp = __first;
+        difference_type __c = 2;
+        _RandomAccessIterator __cp = __first + __c;
+        if (__c == __len || __comp(*__cp, *(__cp - 1)))
+        {
+            --__c;
+            --__cp;
+        }
+        if (__comp(*__pp, *__cp))
+        {
+            value_type __t(_VSTD::move(*__pp));
+            do
+            {
+                *__pp = _VSTD::move(*__cp);
+                __pp = __cp;
+                __p = __c;
+                __c = (__p + 1) * 2;
+                if (__c > __len)
+                    break;
+                __cp = __first + __c;
+                if (__c == __len || __comp(*__cp, *(__cp - 1)))
+                {
+                    --__c;
+                    --__cp;
+                }
+            } while (__comp(__t, *__cp));
+            *__pp = _VSTD::move(__t);
+        }
+    }
+}
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__push_heap_back(_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)
+    {
+        __len = (__len - 2) / 2;
+        _RandomAccessIterator __ptr = __first + __len;
+        if (__comp(*__ptr, *--__last))
+        {
+            value_type __t(_VSTD::move(*__last));
+            do
+            {
+                *__last = _VSTD::move(*__ptr);
+                __last = __ptr;
+                if (__len == 0)
+                    break;
+                __len = (__len - 1) / 2;
+                __ptr = __first + __len;
+            } while (__comp(*__ptr, __t));
+            *__last = _VSTD::move(__t);
+        }
+    }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __push_heap_back<_Comp_ref>(__first, __last, __c, __last - __first);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    _VSTD::push_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// pop_heap
+
+template <class _Compare, class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
+           typename iterator_traits<_RandomAccessIterator>::difference_type __len)
+{
+    if (__len > 1)
+    {
+        swap(*__first, *--__last);
+        __push_heap_front<_Compare>(__first, __last, __comp, __len-1);
+    }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __pop_heap<_Comp_ref>(__first, __last, __c, __last - __first);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    _VSTD::pop_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// make_heap
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    difference_type __n = __last - __first;
+    if (__n > 1)
+    {
+        __last = __first;
+        ++__last;
+        for (difference_type __i = 1; __i < __n;)
+            __push_heap_back<_Compare>(__first, ++__last, __comp, ++__i);
+    }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __make_heap<_Comp_ref>(__first, __last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __make_heap<_Comp_ref>(__first, __last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    _VSTD::make_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// sort_heap
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    for (difference_type __n = __last - __first; __n > 1; --__last, --__n)
+        __pop_heap<_Compare>(__first, __last, __comp, __n);
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __sort_heap<_Comp_ref>(__first, __last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __sort_heap<_Comp_ref>(__first, __last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    _VSTD::sort_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// partial_sort
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+             _Compare __comp)
+{
+    __make_heap<_Compare>(__first, __middle, __comp);
+    typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first;
+    for (_RandomAccessIterator __i = __middle; __i != __last; ++__i)
+    {
+        if (__comp(*__i, *__first))
+        {
+            swap(*__i, *__first);
+            __push_heap_front<_Compare>(__first, __middle, __comp, __len);
+        }
+    }
+    __sort_heap<_Compare>(__first, __middle, __comp);
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
+             _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __partial_sort<_Comp_ref>(__first, __middle, __last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
+{
+    _VSTD::partial_sort(__first, __middle, __last,
+                       __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// partial_sort_copy
+
+template <class _Compare, class _InputIterator, class _RandomAccessIterator>
+_RandomAccessIterator
+__partial_sort_copy(_InputIterator __first, _InputIterator __last,
+                    _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
+{
+    _RandomAccessIterator __r = __result_first;
+    if (__r != __result_last)
+    {
+        typename iterator_traits<_RandomAccessIterator>::difference_type __len = 0;
+        for (; __first != __last && __r != __result_last; ++__first, ++__r, ++__len)
+            *__r = *__first;
+        __make_heap<_Compare>(__result_first, __r, __comp);
+        for (; __first != __last; ++__first)
+            if (__comp(*__first, *__result_first))
+            {
+                *__result_first = *__first;
+                __push_heap_front<_Compare>(__result_first, __r, __comp, __len);
+            }
+        __sort_heap<_Compare>(__result_first, __r, __comp);
+    }
+    return __r;
+}
+
+template <class _InputIterator, class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_RandomAccessIterator
+partial_sort_copy(_InputIterator __first, _InputIterator __last,
+                  _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator, class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_RandomAccessIterator
+partial_sort_copy(_InputIterator __first, _InputIterator __last,
+                  _RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
+{
+    return _VSTD::partial_sort_copy(__first, __last, __result_first, __result_last,
+                                   __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// nth_element
+
+template <class _Compare, class _RandomAccessIterator>
+void
+__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
+{
+    // _Compare is known to be a reference type
+    typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
+    const difference_type __limit = 7;
+    while (true)
+    {
+    __restart:
+        if (__nth == __last)
+            return;
+        difference_type __len = __last - __first;
+        switch (__len)
+        {
+        case 0:
+        case 1:
+            return;
+        case 2:
+            if (__comp(*--__last, *__first))
+                swap(*__first, *__last);
+            return;
+        case 3:
+            {
+            _RandomAccessIterator __m = __first;
+            _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp);
+            return;
+            }
+        }
+        if (__len <= __limit)
+        {
+            __selection_sort<_Compare>(__first, __last, __comp);
+            return;
+        }
+        // __len > __limit >= 3
+        _RandomAccessIterator __m = __first + __len/2;
+        _RandomAccessIterator __lm1 = __last;
+        unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp);
+        // *__m is median
+        // partition [__first, __m) < *__m and *__m <= [__m, __last)
+        // (this inhibits tossing elements equivalent to __m around unnecessarily)
+        _RandomAccessIterator __i = __first;
+        _RandomAccessIterator __j = __lm1;
+        // j points beyond range to be tested, *__lm1 is known to be <= *__m
+        // The search going up is known to be guarded but the search coming down isn't.
+        // Prime the downward search with a guard.
+        if (!__comp(*__i, *__m))  // if *__first == *__m
+        {
+            // *__first == *__m, *__first doesn't go in first part
+            // manually guard downward moving __j against __i
+            while (true)
+            {
+                if (__i == --__j)
+                {
+                    // *__first == *__m, *__m <= all other elements
+                    // Parition instead into [__first, __i) == *__first and *__first < [__i, __last)
+                    ++__i;  // __first + 1
+                    __j = __last;
+                    if (!__comp(*__first, *--__j))  // we need a guard if *__first == *(__last-1)
+                    {
+                        while (true)
+                        {
+                            if (__i == __j)
+                                return;  // [__first, __last) all equivalent elements
+                            if (__comp(*__first, *__i))
+                            {
+                                swap(*__i, *__j);
+                                ++__n_swaps;
+                                ++__i;
+                                break;
+                            }
+                            ++__i;
+                        }
+                    }
+                    // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1
+                    if (__i == __j)
+                        return;
+                    while (true)
+                    {
+                        while (!__comp(*__first, *__i))
+                            ++__i;
+                        while (__comp(*__first, *--__j))
+                            ;
+                        if (__i >= __j)
+                            break;
+                        swap(*__i, *__j);
+                        ++__n_swaps;
+                        ++__i;
+                    }
+                    // [__first, __i) == *__first and *__first < [__i, __last)
+                    // The first part is sorted,
+                    if (__nth < __i)
+                        return;
+                    // __nth_element the secod part
+                    // __nth_element<_Compare>(__i, __nth, __last, __comp);
+                    __first = __i;
+                    goto __restart;
+                }
+                if (__comp(*__j, *__m))
+                {
+                    swap(*__i, *__j);
+                    ++__n_swaps;
+                    break;  // found guard for downward moving __j, now use unguarded partition
+                }
+            }
+        }
+        ++__i;
+        // j points beyond range to be tested, *__lm1 is known to be <= *__m
+        // if not yet partitioned...
+        if (__i < __j)
+        {
+            // known that *(__i - 1) < *__m
+            while (true)
+            {
+                // __m still guards upward moving __i
+                while (__comp(*__i, *__m))
+                    ++__i;
+                // It is now known that a guard exists for downward moving __j
+                while (!__comp(*--__j, *__m))
+                    ;
+                if (__i >= __j)
+                    break;
+                swap(*__i, *__j);
+                ++__n_swaps;
+                // It is known that __m != __j
+                // If __m just moved, follow it
+                if (__m == __i)
+                    __m = __j;
+                ++__i;
+            }
+        }
+        // [__first, __i) < *__m and *__m <= [__i, __last)
+        if (__i != __m && __comp(*__m, *__i))
+        {
+            swap(*__i, *__m);
+            ++__n_swaps;
+        }
+        // [__first, __i) < *__i and *__i <= [__i+1, __last)
+        if (__nth == __i)
+            return;
+        if (__n_swaps == 0)
+        {
+            // We were given a perfectly partitioned sequence.  Coincidence?
+            if (__nth < __i)
+            {
+                // Check for [__first, __i) already sorted
+                __j = __m = __first;
+                while (++__j != __i)
+                {
+                    if (__comp(*__j, *__m))
+                        // not yet sorted, so sort
+                        goto not_sorted;
+                    __m = __j;
+                }
+                // [__first, __i) sorted
+                return;
+            }
+            else
+            {
+                // Check for [__i, __last) already sorted
+                __j = __m = __i;
+                while (++__j != __last)
+                {
+                    if (__comp(*__j, *__m))
+                        // not yet sorted, so sort
+                        goto not_sorted;
+                    __m = __j;
+                }
+                // [__i, __last) sorted
+                return;
+            }
+        }
+not_sorted:
+        // __nth_element on range containing __nth
+        if (__nth < __i)
+        {
+            // __nth_element<_Compare>(__first, __nth, __i, __comp);
+            __last = __i;
+        }
+        else
+        {
+            // __nth_element<_Compare>(__i+1, __nth, __last, __comp);
+            __first = ++__i;
+        }
+    }
+}
+
+template <class _RandomAccessIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    __nth_element<_Comp_ref>(__first, __nth, __last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    __nth_element<_Comp_ref>(__first, __nth, __last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _RandomAccessIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last)
+{
+    _VSTD::nth_element(__first, __nth, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+}
+
+// includes
+
+template <class _Compare, class _InputIterator1, class _InputIterator2>
+bool
+__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
+           _Compare __comp)
+{
+    for (; __first2 != __last2; ++__first1)
+    {
+        if (__first1 == __last1 || __comp(*__first2, *__first1))
+            return false;
+        if (!__comp(*__first1, *__first2))
+            ++__first2;
+    }
+    return true;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
+         _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
+{
+    return _VSTD::includes(__first1, __last1, __first2, __last2,
+                          __less<typename iterator_traits<_InputIterator1>::value_type,
+                                 typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+// set_union
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_OutputIterator
+__set_union(_InputIterator1 __first1, _InputIterator1 __last1,
+            _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+    for (; __first1 != __last1; ++__result)
+    {
+        if (__first2 == __last2)
+            return _VSTD::copy(__first1, __last1, __result);
+        if (__comp(*__first2, *__first1))
+        {
+            *__result = *__first2;
+            ++__first2;
+        }
+        else
+        {
+            *__result = *__first1;
+            if (!__comp(*__first1, *__first2))
+                ++__first2;
+            ++__first1;
+        }
+    }
+    return _VSTD::copy(__first2, __last2, __result);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_union(_InputIterator1 __first1, _InputIterator1 __last1,
+          _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_union(_InputIterator1 __first1, _InputIterator1 __last1,
+          _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+    return _VSTD::set_union(__first1, __last1, __first2, __last2, __result,
+                          __less<typename iterator_traits<_InputIterator1>::value_type,
+                                 typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+// set_intersection
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_OutputIterator
+__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
+                   _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+    while (__first1 != __last1 && __first2 != __last2)
+    {
+        if (__comp(*__first1, *__first2))
+            ++__first1;
+        else
+        {
+            if (!__comp(*__first2, *__first1))
+            {
+                *__result = *__first1;
+                ++__result;
+                ++__first1;
+            }
+            ++__first2;
+        }
+    }
+    return __result;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
+                 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
+                 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+    return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result,
+                                  __less<typename iterator_traits<_InputIterator1>::value_type,
+                                         typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+// set_difference
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_OutputIterator
+__set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+                 _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+    while (__first1 != __last1)
+    {
+        if (__first2 == __last2)
+            return _VSTD::copy(__first1, __last1, __result);
+        if (__comp(*__first1, *__first2))
+        {
+            *__result = *__first1;
+            ++__result;
+            ++__first1;
+        }
+        else
+        {
+            if (!__comp(*__first2, *__first1))
+                ++__first1;
+            ++__first2;
+        }
+    }
+    return __result;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+               _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+               _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+    return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result,
+                                __less<typename iterator_traits<_InputIterator1>::value_type,
+                                       typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+// set_symmetric_difference
+
+template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
+_OutputIterator
+__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+                           _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+    while (__first1 != __last1)
+    {
+        if (__first2 == __last2)
+            return _VSTD::copy(__first1, __last1, __result);
+        if (__comp(*__first1, *__first2))
+        {
+            *__result = *__first1;
+            ++__result;
+            ++__first1;
+        }
+        else
+        {
+            if (__comp(*__first2, *__first1))
+            {
+                *__result = *__first2;
+                ++__result;
+            }
+            else
+                ++__first1;
+            ++__first2;
+        }
+    }
+    return _VSTD::copy(__first2, __last2, __result);
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+                         _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
+                         _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
+{
+    return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result,
+                                          __less<typename iterator_traits<_InputIterator1>::value_type,
+                                                 typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+// lexicographical_compare
+
+template <class _Compare, class _InputIterator1, class _InputIterator2>
+bool
+__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
+                          _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
+{
+    for (; __first2 != __last2; ++__first1, ++__first2)
+    {
+        if (__first1 == __last1 || __comp(*__first1, *__first2))
+            return true;
+        if (__comp(*__first2, *__first1))
+            return false;
+    }
+    return false;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
+                        _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _InputIterator1, class _InputIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
+                        _InputIterator2 __first2, _InputIterator2 __last2)
+{
+    return _VSTD::lexicographical_compare(__first1, __last1, __first2, __last2,
+                                         __less<typename iterator_traits<_InputIterator1>::value_type,
+                                                typename iterator_traits<_InputIterator2>::value_type>());
+}
+
+// next_permutation
+
+template <class _Compare, class _BidirectionalIterator>
+bool
+__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+    _BidirectionalIterator __i = __last;
+    if (__first == __last || __first == --__i)
+        return false;
+    while (true)
+    {
+        _BidirectionalIterator __ip1 = __i;
+        if (__comp(*--__i, *__ip1))
+        {
+            _BidirectionalIterator __j = __last;
+            while (!__comp(*__i, *--__j))
+                ;
+            swap(*__i, *__j);
+            _VSTD::reverse(__ip1, __last);
+            return true;
+        }
+        if (__i == __first)
+        {
+            _VSTD::reverse(__first, __last);
+            return false;
+        }
+    }
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __next_permutation<_Comp_ref>(__first, __last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __next_permutation<_Comp_ref>(__first, __last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+    return _VSTD::next_permutation(__first, __last,
+                                  __less<typename iterator_traits<_BidirectionalIterator>::value_type>());
+}
+
+// prev_permutation
+
+template <class _Compare, class _BidirectionalIterator>
+bool
+__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+    _BidirectionalIterator __i = __last;
+    if (__first == __last || __first == --__i)
+        return false;
+    while (true)
+    {
+        _BidirectionalIterator __ip1 = __i;
+        if (__comp(*__ip1, *--__i))
+        {
+            _BidirectionalIterator __j = __last;
+            while (!__comp(*--__j, *__i))
+                ;
+            swap(*__i, *__j);
+            _VSTD::reverse(__ip1, __last);
+            return true;
+        }
+        if (__i == __first)
+        {
+            _VSTD::reverse(__first, __last);
+            return false;
+        }
+    }
+}
+
+template <class _BidirectionalIterator, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
+{
+#ifdef _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
+    __debug_less<_Compare> __c(__comp);
+    return __prev_permutation<_Comp_ref>(__first, __last, __c);
+#else  // _LIBCPP_DEBUG
+    typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+    return __prev_permutation<_Comp_ref>(__first, __last, __comp);
+#endif  // _LIBCPP_DEBUG
+}
+
+template <class _BidirectionalIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
+{
+    return _VSTD::prev_permutation(__first, __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/final/include/array b/final/include/array
new file mode 100644
index 0000000..d37075d
--- /dev/null
+++ b/final/include/array
@@ -0,0 +1,342 @@
+// -*- C++ -*-
+//===---------------------------- array -----------------------------------===//
+//
+//                     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_ARRAY
+#define _LIBCPP_ARRAY
+
+/*
+    array synopsis
+
+namespace std
+{
+template <class T, size_t N >
+struct array
+{
+    // types:
+    typedef T & reference;
+    typedef const T & const_reference;
+    typedef implementation defined iterator;
+    typedef implementation defined const_iterator;
+    typedef size_t size_type;
+    typedef ptrdiff_t difference_type;
+    typedef T value_type;
+    typedef T* pointer;
+    typedef const T* const_pointer;
+    typedef std::reverse_iterator<iterator> reverse_iterator;
+    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+    // No explicit construct/copy/destroy for aggregate type
+    void fill(const T& u);
+    void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
+
+    // iterators:
+    iterator begin() noexcept;
+    const_iterator begin() const noexcept;
+    iterator end() noexcept;
+    const_iterator end() const noexcept;
+
+    reverse_iterator rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+    reverse_iterator rend() noexcept;
+    const_reverse_iterator rend() const noexcept;
+
+    const_iterator cbegin() const noexcept;
+    const_iterator cend() const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend() const noexcept;
+
+    // capacity:
+    constexpr size_type size() const noexcept;
+    constexpr size_type max_size() const noexcept;
+    constexpr bool empty() const noexcept;
+
+    // element access:
+    reference operator[](size_type n);
+    const_reference operator[](size_type n) const; // constexpr in C++14
+    const_reference at(size_type n) const; // constexpr in C++14
+    reference at(size_type n);
+
+    reference front();
+    const_reference front() const; // constexpr in C++14
+    reference back();
+    const_reference back() const; // constexpr in C++14
+
+    T* data() noexcept;
+    const T* data() const noexcept;
+};
+
+template <class T, size_t N>
+  bool operator==(const array<T,N>& x, const array<T,N>& y);
+template <class T, size_t N>
+  bool operator!=(const array<T,N>& x, const array<T,N>& y);
+template <class T, size_t N>
+  bool operator<(const array<T,N>& x, const array<T,N>& y);
+template <class T, size_t N>
+  bool operator>(const array<T,N>& x, const array<T,N>& y);
+template <class T, size_t N>
+  bool operator<=(const array<T,N>& x, const array<T,N>& y);
+template <class T, size_t N>
+  bool operator>=(const array<T,N>& x, const array<T,N>& y);
+
+template <class T, size_t N >
+  void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y)));
+
+template <class T> class tuple_size;
+template <int 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
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__tuple>
+#include <type_traits>
+#include <utility>
+#include <iterator>
+#include <algorithm>
+#include <stdexcept>
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+    #include <cassert>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, size_t _Size>
+struct _LIBCPP_TYPE_VIS_ONLY array
+{
+    // types:
+    typedef array __self;
+    typedef _Tp                                   value_type;
+    typedef value_type&                           reference;
+    typedef const value_type&                     const_reference;
+    typedef value_type*                           iterator;
+    typedef const value_type*                     const_iterator;
+    typedef value_type*                           pointer;
+    typedef const value_type*                     const_pointer;
+    typedef size_t                                size_type;
+    typedef ptrdiff_t                             difference_type;
+    typedef std::reverse_iterator<iterator>       reverse_iterator;
+    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+    value_type __elems_[_Size > 0 ? _Size : 1];
+
+    // No explicit construct/copy/destroy for aggregate type
+    _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
+        {_VSTD::fill_n(__elems_, _Size, __u);}
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
+        {_VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
+
+    // iterators:
+    _LIBCPP_INLINE_VISIBILITY
+    iterator begin() _NOEXCEPT {return iterator(__elems_);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+    // capacity:
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
+
+    // element access:
+    _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n)             {return __elems_[__n];}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference operator[](size_type __n) const {return __elems_[__n];}
+    reference at(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
+
+    _LIBCPP_INLINE_VISIBILITY reference front()             {return __elems_[0];}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
+    _LIBCPP_INLINE_VISIBILITY reference back()              {return __elems_[_Size > 0 ? _Size-1 : 0];}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const  {return __elems_[_Size > 0 ? _Size-1 : 0];}
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type* data() _NOEXCEPT {return __elems_;}
+    _LIBCPP_INLINE_VISIBILITY
+    const value_type* data() const _NOEXCEPT {return __elems_;}
+};
+
+template <class _Tp, size_t _Size>
+typename array<_Tp, _Size>::reference
+array<_Tp, _Size>::at(size_type __n)
+{
+    if (__n >= _Size)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("array::at");
+#else
+        assert(!"array::at out_of_range");
+#endif
+    return __elems_[__n];
+}
+
+template <class _Tp, size_t _Size>
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+typename array<_Tp, _Size>::const_reference
+array<_Tp, _Size>::at(size_type __n) const
+{
+    if (__n >= _Size)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("array::at");
+#else
+        assert(!"array::at out_of_range");
+#endif
+    return __elems_[__n];
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+    return _VSTD::equal(__x.__elems_, __x.__elems_ + _Size, __y.__elems_);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.__elems_, __x.__elems_ + _Size, __y.__elems_, __y.__elems_ + _Size);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_swappable<_Tp>::value,
+    void
+>::type
+swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
+                                  _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
+{
+    __x.swap(__y);
+}
+
+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> >
+{
+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&
+get(array<_Tp, _Size>& __a) _NOEXCEPT
+{
+    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
+    return __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 __a.__elems_[_Ip];
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <size_t _Ip, class _Tp, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&&
+get(array<_Tp, _Size>&& __a) _NOEXCEPT
+{
+    static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
+    return _VSTD::move(__a.__elems_[_Ip]);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_ARRAY
diff --git a/final/include/atomic b/final/include/atomic
new file mode 100644
index 0000000..f6ab1cb
--- /dev/null
+++ b/final/include/atomic
@@ -0,0 +1,1531 @@
+// -*- C++ -*-
+//===--------------------------- atomic -----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_ATOMIC
+#define _LIBCPP_ATOMIC
+
+/*
+    atomic synopsis
+
+namespace std
+{
+
+// order and consistency
+
+typedef enum memory_order
+{
+    memory_order_relaxed,
+    memory_order_consume,  // load-consume
+    memory_order_acquire,  // load-acquire
+    memory_order_release,  // store-release
+    memory_order_acq_rel,  // store-release load-acquire
+    memory_order_seq_cst   // store-release load-acquire
+} memory_order;
+
+template <class T> T kill_dependency(T y) noexcept;
+
+// lock-free property
+
+#define ATOMIC_BOOL_LOCK_FREE unspecified
+#define ATOMIC_CHAR_LOCK_FREE unspecified
+#define ATOMIC_CHAR16_T_LOCK_FREE unspecified
+#define ATOMIC_CHAR32_T_LOCK_FREE unspecified
+#define ATOMIC_WCHAR_T_LOCK_FREE unspecified
+#define ATOMIC_SHORT_LOCK_FREE unspecified
+#define ATOMIC_INT_LOCK_FREE unspecified
+#define ATOMIC_LONG_LOCK_FREE unspecified
+#define ATOMIC_LLONG_LOCK_FREE unspecified
+#define ATOMIC_POINTER_LOCK_FREE unspecified
+
+// flag type and operations
+
+typedef struct atomic_flag
+{
+    bool test_and_set(memory_order m = memory_order_seq_cst) volatile noexcept;
+    bool test_and_set(memory_order m = memory_order_seq_cst) noexcept;
+    void clear(memory_order m = memory_order_seq_cst) volatile noexcept;
+    void clear(memory_order m = memory_order_seq_cst) noexcept;
+    atomic_flag()  noexcept = default;
+    atomic_flag(const atomic_flag&) = delete;
+    atomic_flag& operator=(const atomic_flag&) = delete;
+    atomic_flag& operator=(const atomic_flag&) volatile = delete;
+} atomic_flag;
+
+bool
+    atomic_flag_test_and_set(volatile atomic_flag* obj) noexcept;
+
+bool
+    atomic_flag_test_and_set(atomic_flag* obj) noexcept;
+
+bool
+    atomic_flag_test_and_set_explicit(volatile atomic_flag* obj,
+                                      memory_order m) noexcept;
+
+bool
+    atomic_flag_test_and_set_explicit(atomic_flag* obj, memory_order m) noexcept;
+
+void
+    atomic_flag_clear(volatile atomic_flag* obj) noexcept;
+
+void
+    atomic_flag_clear(atomic_flag* obj) noexcept;
+
+void
+    atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept;
+
+void
+    atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept;
+
+#define ATOMIC_FLAG_INIT see below
+#define ATOMIC_VAR_INIT(value) see below
+
+template <class T>
+struct atomic
+{
+    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;
+    void store(T desr, memory_order m = memory_order_seq_cst) noexcept;
+    T load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+    T load(memory_order m = memory_order_seq_cst) const noexcept;
+    operator T() const volatile noexcept;
+    operator T() const noexcept;
+    T exchange(T desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+    T exchange(T desr, memory_order m = memory_order_seq_cst) noexcept;
+    bool compare_exchange_weak(T& expc, T desr,
+                               memory_order s, memory_order f) volatile noexcept;
+    bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f) noexcept;
+    bool compare_exchange_strong(T& expc, T desr,
+                                 memory_order s, memory_order f) volatile noexcept;
+    bool compare_exchange_strong(T& expc, T desr,
+                                 memory_order s, memory_order f) noexcept;
+    bool compare_exchange_weak(T& expc, T desr,
+                               memory_order m = memory_order_seq_cst) volatile noexcept;
+    bool compare_exchange_weak(T& expc, T desr,
+                               memory_order m = memory_order_seq_cst) noexcept;
+    bool compare_exchange_strong(T& expc, T desr,
+                                memory_order m = memory_order_seq_cst) volatile noexcept;
+    bool compare_exchange_strong(T& expc, T desr,
+                                 memory_order m = memory_order_seq_cst) noexcept;
+
+    atomic() noexcept = default;
+    constexpr atomic(T desr) noexcept;
+    atomic(const atomic&) = delete;
+    atomic& operator=(const atomic&) = delete;
+    atomic& operator=(const atomic&) volatile = delete;
+    T operator=(T) volatile noexcept;
+    T operator=(T) noexcept;
+};
+
+template <>
+struct atomic<integral>
+{
+    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;
+    void store(integral desr, memory_order m = memory_order_seq_cst) noexcept;
+    integral load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+    integral load(memory_order m = memory_order_seq_cst) const noexcept;
+    operator integral() const volatile noexcept;
+    operator integral() const noexcept;
+    integral exchange(integral desr,
+                      memory_order m = memory_order_seq_cst) volatile noexcept;
+    integral exchange(integral desr, memory_order m = memory_order_seq_cst) noexcept;
+    bool compare_exchange_weak(integral& expc, integral desr,
+                               memory_order s, memory_order f) volatile noexcept;
+    bool compare_exchange_weak(integral& expc, integral desr,
+                               memory_order s, memory_order f) noexcept;
+    bool compare_exchange_strong(integral& expc, integral desr,
+                                 memory_order s, memory_order f) volatile noexcept;
+    bool compare_exchange_strong(integral& expc, integral desr,
+                                 memory_order s, memory_order f) noexcept;
+    bool compare_exchange_weak(integral& expc, integral desr,
+                               memory_order m = memory_order_seq_cst) volatile noexcept;
+    bool compare_exchange_weak(integral& expc, integral desr,
+                               memory_order m = memory_order_seq_cst) noexcept;
+    bool compare_exchange_strong(integral& expc, integral desr,
+                                memory_order m = memory_order_seq_cst) volatile noexcept;
+    bool compare_exchange_strong(integral& expc, integral desr,
+                                 memory_order m = memory_order_seq_cst) noexcept;
+
+    integral
+        fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+    integral fetch_add(integral op, memory_order m = memory_order_seq_cst) noexcept;
+    integral
+        fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+    integral fetch_sub(integral op, memory_order m = memory_order_seq_cst) noexcept;
+    integral
+        fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+    integral fetch_and(integral op, memory_order m = memory_order_seq_cst) noexcept;
+    integral
+        fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+    integral fetch_or(integral op, memory_order m = memory_order_seq_cst) noexcept;
+    integral
+        fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile noexcept;
+    integral fetch_xor(integral op, memory_order m = memory_order_seq_cst) noexcept;
+
+    atomic() noexcept = default;
+    constexpr atomic(integral desr) noexcept;
+    atomic(const atomic&) = delete;
+    atomic& operator=(const atomic&) = delete;
+    atomic& operator=(const atomic&) volatile = delete;
+    integral operator=(integral desr) volatile noexcept;
+    integral operator=(integral desr) noexcept;
+
+    integral operator++(int) volatile noexcept;
+    integral operator++(int) noexcept;
+    integral operator--(int) volatile noexcept;
+    integral operator--(int) noexcept;
+    integral operator++() volatile noexcept;
+    integral operator++() noexcept;
+    integral operator--() volatile noexcept;
+    integral operator--() noexcept;
+    integral operator+=(integral op) volatile noexcept;
+    integral operator+=(integral op) noexcept;
+    integral operator-=(integral op) volatile noexcept;
+    integral operator-=(integral op) noexcept;
+    integral operator&=(integral op) volatile noexcept;
+    integral operator&=(integral op) noexcept;
+    integral operator|=(integral op) volatile noexcept;
+    integral operator|=(integral op) noexcept;
+    integral operator^=(integral op) volatile noexcept;
+    integral operator^=(integral op) noexcept;
+};
+
+template <class T>
+struct atomic<T*>
+{
+    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;
+    void store(T* desr, memory_order m = memory_order_seq_cst) noexcept;
+    T* load(memory_order m = memory_order_seq_cst) const volatile noexcept;
+    T* load(memory_order m = memory_order_seq_cst) const noexcept;
+    operator T*() const volatile noexcept;
+    operator T*() const noexcept;
+    T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile noexcept;
+    T* exchange(T* desr, memory_order m = memory_order_seq_cst) noexcept;
+    bool compare_exchange_weak(T*& expc, T* desr,
+                               memory_order s, memory_order f) volatile noexcept;
+    bool compare_exchange_weak(T*& expc, T* desr,
+                               memory_order s, memory_order f) noexcept;
+    bool compare_exchange_strong(T*& expc, T* desr,
+                                 memory_order s, memory_order f) volatile noexcept;
+    bool compare_exchange_strong(T*& expc, T* desr,
+                                 memory_order s, memory_order f) noexcept;
+    bool compare_exchange_weak(T*& expc, T* desr,
+                               memory_order m = memory_order_seq_cst) volatile noexcept;
+    bool compare_exchange_weak(T*& expc, T* desr,
+                               memory_order m = memory_order_seq_cst) noexcept;
+    bool compare_exchange_strong(T*& expc, T* desr,
+                                memory_order m = memory_order_seq_cst) volatile noexcept;
+    bool compare_exchange_strong(T*& expc, T* desr,
+                                 memory_order m = memory_order_seq_cst) noexcept;
+    T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
+    T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
+    T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile noexcept;
+    T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) noexcept;
+
+    atomic() noexcept = default;
+    constexpr atomic(T* desr) noexcept;
+    atomic(const atomic&) = delete;
+    atomic& operator=(const atomic&) = delete;
+    atomic& operator=(const atomic&) volatile = delete;
+
+    T* operator=(T*) volatile noexcept;
+    T* operator=(T*) noexcept;
+    T* operator++(int) volatile noexcept;
+    T* operator++(int) noexcept;
+    T* operator--(int) volatile noexcept;
+    T* operator--(int) noexcept;
+    T* operator++() volatile noexcept;
+    T* operator++() noexcept;
+    T* operator--() volatile noexcept;
+    T* operator--() noexcept;
+    T* operator+=(ptrdiff_t op) volatile noexcept;
+    T* operator+=(ptrdiff_t op) noexcept;
+    T* operator-=(ptrdiff_t op) volatile noexcept;
+    T* operator-=(ptrdiff_t op) noexcept;
+};
+
+
+template <class T>
+    bool
+    atomic_is_lock_free(const volatile atomic<T>* obj) noexcept;
+
+template <class T>
+    bool
+    atomic_is_lock_free(const atomic<T>* obj) noexcept;
+
+template <class T>
+    void
+    atomic_init(volatile atomic<T>* obj, T desr) noexcept;
+
+template <class T>
+    void
+    atomic_init(atomic<T>* obj, T desr) noexcept;
+
+template <class T>
+    void
+    atomic_store(volatile atomic<T>* obj, T desr) noexcept;
+
+template <class T>
+    void
+    atomic_store(atomic<T>* obj, T desr) noexcept;
+
+template <class T>
+    void
+    atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
+
+template <class T>
+    void
+    atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
+
+template <class T>
+    T
+    atomic_load(const volatile atomic<T>* obj) noexcept;
+
+template <class T>
+    T
+    atomic_load(const atomic<T>* obj) noexcept;
+
+template <class T>
+    T
+    atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept;
+
+template <class T>
+    T
+    atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept;
+
+template <class T>
+    T
+    atomic_exchange(volatile atomic<T>* obj, T desr) noexcept;
+
+template <class T>
+    T
+    atomic_exchange(atomic<T>* obj, T desr) noexcept;
+
+template <class T>
+    T
+    atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept;
+
+template <class T>
+    T
+    atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
+                                          T desr,
+                                          memory_order s, memory_order f) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
+                                          memory_order s, memory_order f) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj,
+                                            T* expc, T desr,
+                                            memory_order s, memory_order f) noexcept;
+
+template <class T>
+    bool
+    atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc,
+                                            T desr,
+                                            memory_order s, memory_order f) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op,
+                             memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op,
+                             memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept;
+
+template <class Integral>
+    Integral
+    atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+template <class Integral>
+    Integral
+    atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op,
+                              memory_order m) noexcept;
+
+template <class T>
+    T*
+    atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
+
+template <class T>
+    T*
+    atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept;
+
+template <class T>
+    T*
+    atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
+                              memory_order m) noexcept;
+template <class T>
+    T*
+    atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
+
+template <class T>
+    T*
+    atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept;
+
+template <class T>
+    T*
+    atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept;
+
+template <class T>
+    T*
+    atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
+                              memory_order m) noexcept;
+template <class T>
+    T*
+    atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept;
+
+// Atomics for standard typedef types
+
+typedef atomic<bool>               atomic_bool;
+typedef atomic<char>               atomic_char;
+typedef atomic<signed char>        atomic_schar;
+typedef atomic<unsigned char>      atomic_uchar;
+typedef atomic<short>              atomic_short;
+typedef atomic<unsigned short>     atomic_ushort;
+typedef atomic<int>                atomic_int;
+typedef atomic<unsigned int>       atomic_uint;
+typedef atomic<long>               atomic_long;
+typedef atomic<unsigned long>      atomic_ulong;
+typedef atomic<long long>          atomic_llong;
+typedef atomic<unsigned long long> atomic_ullong;
+typedef atomic<char16_t>           atomic_char16_t;
+typedef atomic<char32_t>           atomic_char32_t;
+typedef atomic<wchar_t>            atomic_wchar_t;
+
+typedef atomic<int_least8_t>   atomic_int_least8_t;
+typedef atomic<uint_least8_t>  atomic_uint_least8_t;
+typedef atomic<int_least16_t>  atomic_int_least16_t;
+typedef atomic<uint_least16_t> atomic_uint_least16_t;
+typedef atomic<int_least32_t>  atomic_int_least32_t;
+typedef atomic<uint_least32_t> atomic_uint_least32_t;
+typedef atomic<int_least64_t>  atomic_int_least64_t;
+typedef atomic<uint_least64_t> atomic_uint_least64_t;
+
+typedef atomic<int_fast8_t>   atomic_int_fast8_t;
+typedef atomic<uint_fast8_t>  atomic_uint_fast8_t;
+typedef atomic<int_fast16_t>  atomic_int_fast16_t;
+typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+typedef atomic<int_fast32_t>  atomic_int_fast32_t;
+typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+typedef atomic<int_fast64_t>  atomic_int_fast64_t;
+typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+
+typedef atomic<intptr_t>  atomic_intptr_t;
+typedef atomic<uintptr_t> atomic_uintptr_t;
+typedef atomic<size_t>    atomic_size_t;
+typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+typedef atomic<intmax_t>  atomic_intmax_t;
+typedef atomic<uintmax_t> atomic_uintmax_t;
+
+// fences
+
+void atomic_thread_fence(memory_order m) noexcept;
+void atomic_signal_fence(memory_order m) noexcept;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <cstddef>
+#include <cstdint>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !__has_feature(cxx_atomic)
+#error <atomic> is not implemented
+#else
+
+typedef enum memory_order
+{
+    memory_order_relaxed, memory_order_consume, memory_order_acquire,
+    memory_order_release, memory_order_acq_rel, memory_order_seq_cst
+} memory_order;
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+kill_dependency(_Tp __y) _NOEXCEPT
+{
+    return __y;
+}
+
+// general atomic<T>
+
+template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
+struct __atomic_base  // false
+{
+    mutable _Atomic(_Tp) __a_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool is_lock_free() const volatile _NOEXCEPT
+        {return __c11_atomic_is_lock_free(sizeof(_Tp));}
+    _LIBCPP_INLINE_VISIBILITY
+    bool is_lock_free() const _NOEXCEPT
+        {return __c11_atomic_is_lock_free(sizeof(_Tp));}
+    _LIBCPP_INLINE_VISIBILITY
+    void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {__c11_atomic_store(&__a_, __d, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {__c11_atomic_store(&__a_, __d, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
+        {return __c11_atomic_load(&__a_, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
+        {return __c11_atomic_load(&__a_, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    operator _Tp() const volatile _NOEXCEPT {return load();}
+    _LIBCPP_INLINE_VISIBILITY
+    operator _Tp() const _NOEXCEPT          {return load();}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_exchange(&__a_, __d, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_exchange(&__a_, __d, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_weak(_Tp& __e, _Tp __d,
+                               memory_order __s, memory_order __f) volatile _NOEXCEPT
+        {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_weak(_Tp& __e, _Tp __d,
+                               memory_order __s, memory_order __f) _NOEXCEPT
+        {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_strong(_Tp& __e, _Tp __d,
+                                 memory_order __s, memory_order __f) volatile _NOEXCEPT
+        {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_strong(_Tp& __e, _Tp __d,
+                                 memory_order __s, memory_order __f) _NOEXCEPT
+        {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_weak(_Tp& __e, _Tp __d,
+                              memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_weak(_Tp& __e, _Tp __d,
+                               memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_strong(_Tp& __e, _Tp __d,
+                              memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool compare_exchange_strong(_Tp& __e, _Tp __d,
+                                 memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
+
+    _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+    __atomic_base() _NOEXCEPT = default;
+#else
+    __atomic_base() _NOEXCEPT : __a_() {}
+#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+    __atomic_base(const __atomic_base&) = delete;
+    __atomic_base& operator=(const __atomic_base&) = delete;
+    __atomic_base& operator=(const __atomic_base&) volatile = delete;
+#else  // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+private:
+    __atomic_base(const __atomic_base&);
+    __atomic_base& operator=(const __atomic_base&);
+    __atomic_base& operator=(const __atomic_base&) volatile;
+#endif  // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+};
+
+// atomic<Integral>
+
+template <class _Tp>
+struct __atomic_base<_Tp, true>
+    : public __atomic_base<_Tp, false>
+{
+    typedef __atomic_base<_Tp, false> __base;
+    _LIBCPP_INLINE_VISIBILITY
+    __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator++(int) volatile _NOEXCEPT      {return fetch_add(_Tp(1));}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator++(int) _NOEXCEPT               {return fetch_add(_Tp(1));}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator--(int) volatile _NOEXCEPT      {return fetch_sub(_Tp(1));}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator--(int) _NOEXCEPT               {return fetch_sub(_Tp(1));}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator++() volatile _NOEXCEPT         {return fetch_add(_Tp(1)) + _Tp(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator++() _NOEXCEPT                  {return fetch_add(_Tp(1)) + _Tp(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator--() volatile _NOEXCEPT         {return fetch_sub(_Tp(1)) - _Tp(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator--() _NOEXCEPT                  {return fetch_sub(_Tp(1)) - _Tp(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator+=(_Tp __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator+=(_Tp __op) _NOEXCEPT          {return fetch_add(__op) + __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator-=(_Tp __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator-=(_Tp __op) _NOEXCEPT          {return fetch_sub(__op) - __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator&=(_Tp __op) volatile _NOEXCEPT {return fetch_and(__op) & __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator&=(_Tp __op) _NOEXCEPT          {return fetch_and(__op) & __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator|=(_Tp __op) volatile _NOEXCEPT {return fetch_or(__op) | __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator|=(_Tp __op) _NOEXCEPT          {return fetch_or(__op) | __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator^=(_Tp __op) volatile _NOEXCEPT {return fetch_xor(__op) ^ __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator^=(_Tp __op) _NOEXCEPT          {return fetch_xor(__op) ^ __op;}
+};
+
+// atomic<T>
+
+template <class _Tp>
+struct atomic
+    : public __atomic_base<_Tp>
+{
+    typedef __atomic_base<_Tp> __base;
+    _LIBCPP_INLINE_VISIBILITY
+    atomic() _NOEXCEPT _LIBCPP_DEFAULT
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator=(_Tp __d) volatile _NOEXCEPT
+        {__base::store(__d); return __d;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator=(_Tp __d) _NOEXCEPT
+        {__base::store(__d); return __d;}
+};
+
+// atomic<T*>
+
+template <class _Tp>
+struct atomic<_Tp*>
+    : public __atomic_base<_Tp*>
+{
+    typedef __atomic_base<_Tp*> __base;
+    _LIBCPP_INLINE_VISIBILITY
+    atomic() _NOEXCEPT _LIBCPP_DEFAULT
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator=(_Tp* __d) volatile _NOEXCEPT
+        {__base::store(__d); return __d;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator=(_Tp* __d) _NOEXCEPT
+        {__base::store(__d); return __d;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
+                                                                        volatile _NOEXCEPT
+        {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
+                                                                        volatile _NOEXCEPT
+        {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator++(int) volatile _NOEXCEPT            {return fetch_add(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator++(int) _NOEXCEPT                     {return fetch_add(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator--(int) volatile _NOEXCEPT            {return fetch_sub(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator--(int) _NOEXCEPT                     {return fetch_sub(1);}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator++() volatile _NOEXCEPT               {return fetch_add(1) + 1;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator++() _NOEXCEPT                        {return fetch_add(1) + 1;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator--() volatile _NOEXCEPT               {return fetch_sub(1) - 1;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator--() _NOEXCEPT                        {return fetch_sub(1) - 1;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator+=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_add(__op) + __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator+=(ptrdiff_t __op) _NOEXCEPT          {return fetch_add(__op) + __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;}
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT          {return fetch_sub(__op) - __op;}
+};
+
+// atomic_is_lock_free
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
+{
+    return __o->is_lock_free();
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
+{
+    return __o->is_lock_free();
+}
+
+// atomic_init
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+{
+    __c11_atomic_init(&__o->__a_, __d);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+{
+    __c11_atomic_init(&__o->__a_, __d);
+}
+
+// atomic_store
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+{
+    __o->store(__d);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+{
+    __o->store(__d);
+}
+
+// atomic_store_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+{
+    __o->store(__d, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+{
+    __o->store(__d, __m);
+}
+
+// atomic_load
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
+{
+    return __o->load();
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
+{
+    return __o->load();
+}
+
+// atomic_load_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
+{
+    return __o->load(__m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
+{
+    return __o->load(__m);
+}
+
+// atomic_exchange
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+{
+    return __o->exchange(__d);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
+{
+    return __o->exchange(__d);
+}
+
+// atomic_exchange_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+{
+    return __o->exchange(__d, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
+{
+    return __o->exchange(__d, __m);
+}
+
+// atomic_compare_exchange_weak
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+{
+    return __o->compare_exchange_weak(*__e, __d);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+{
+    return __o->compare_exchange_weak(*__e, __d);
+}
+
+// atomic_compare_exchange_strong
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+{
+    return __o->compare_exchange_strong(*__e, __d);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
+{
+    return __o->compare_exchange_strong(*__e, __d);
+}
+
+// atomic_compare_exchange_weak_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
+                                      _Tp __d,
+                                      memory_order __s, memory_order __f) _NOEXCEPT
+{
+    return __o->compare_exchange_weak(*__e, __d, __s, __f);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
+                                      memory_order __s, memory_order __f) _NOEXCEPT
+{
+    return __o->compare_exchange_weak(*__e, __d, __s, __f);
+}
+
+// atomic_compare_exchange_strong_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
+                                        _Tp* __e, _Tp __d,
+                                        memory_order __s, memory_order __f) _NOEXCEPT
+{
+    return __o->compare_exchange_strong(*__e, __d, __s, __f);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
+                                        _Tp __d,
+                                        memory_order __s, memory_order __f) _NOEXCEPT
+{
+    return __o->compare_exchange_strong(*__e, __d, __s, __f);
+}
+
+// atomic_fetch_add
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_add(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_add(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+{
+    return __o->fetch_add(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+{
+    return __o->fetch_add(__op);
+}
+
+// atomic_fetch_add_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_add(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_add(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
+                          memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_add(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_add(__op, __m);
+}
+
+// atomic_fetch_sub
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_sub(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_sub(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+{
+    return __o->fetch_sub(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
+{
+    return __o->fetch_sub(__op);
+}
+
+// atomic_fetch_sub_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_sub(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_sub(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
+                          memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_sub(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_sub(__op, __m);
+}
+
+// atomic_fetch_and
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_and(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_and(__op);
+}
+
+// atomic_fetch_and_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_and(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_and(__op, __m);
+}
+
+// atomic_fetch_or
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_or(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_or(__op);
+}
+
+// atomic_fetch_or_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_or(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_or(__op, __m);
+}
+
+// atomic_fetch_xor
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_xor(__op);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
+{
+    return __o->fetch_xor(__op);
+}
+
+// atomic_fetch_xor_explicit
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_xor(__op, __m);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
+    _Tp
+>::type
+atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
+{
+    return __o->fetch_xor(__op, __m);
+}
+
+// flag type and operations
+
+typedef struct atomic_flag
+{
+    _Atomic(bool) __a_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {return __c11_atomic_exchange(&__a_, true, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {return __c11_atomic_exchange(&__a_, true, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
+        {__c11_atomic_store(&__a_, false, __m);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
+        {__c11_atomic_store(&__a_, false, __m);}
+
+    _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+    atomic_flag() _NOEXCEPT = default;
+#else
+    atomic_flag() _NOEXCEPT : __a_() {}
+#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
+
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+    atomic_flag(const atomic_flag&) = delete;
+    atomic_flag& operator=(const atomic_flag&) = delete;
+    atomic_flag& operator=(const atomic_flag&) volatile = delete;
+#else  // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+private:
+    atomic_flag(const atomic_flag&);
+    atomic_flag& operator=(const atomic_flag&);
+    atomic_flag& operator=(const atomic_flag&) volatile;
+#endif  // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+} atomic_flag;
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set(volatile atomic_flag* __o) _NOEXCEPT
+{
+    return __o->test_and_set();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set(atomic_flag* __o) _NOEXCEPT
+{
+    return __o->test_and_set();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+    return __o->test_and_set(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_flag_test_and_set_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+    return __o->test_and_set(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear(volatile atomic_flag* __o) _NOEXCEPT
+{
+    __o->clear();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear(atomic_flag* __o) _NOEXCEPT
+{
+    __o->clear();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear_explicit(volatile atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+    __o->clear(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_flag_clear_explicit(atomic_flag* __o, memory_order __m) _NOEXCEPT
+{
+    __o->clear(__m);
+}
+
+// fences
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_thread_fence(memory_order __m) _NOEXCEPT
+{
+    __c11_atomic_thread_fence(__m);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_signal_fence(memory_order __m) _NOEXCEPT
+{
+    __c11_atomic_signal_fence(__m);
+}
+
+// Atomics for standard typedef types
+
+typedef atomic<bool>               atomic_bool;
+typedef atomic<char>               atomic_char;
+typedef atomic<signed char>        atomic_schar;
+typedef atomic<unsigned char>      atomic_uchar;
+typedef atomic<short>              atomic_short;
+typedef atomic<unsigned short>     atomic_ushort;
+typedef atomic<int>                atomic_int;
+typedef atomic<unsigned int>       atomic_uint;
+typedef atomic<long>               atomic_long;
+typedef atomic<unsigned long>      atomic_ulong;
+typedef atomic<long long>          atomic_llong;
+typedef atomic<unsigned long long> atomic_ullong;
+typedef atomic<char16_t>           atomic_char16_t;
+typedef atomic<char32_t>           atomic_char32_t;
+typedef atomic<wchar_t>            atomic_wchar_t;
+
+typedef atomic<int_least8_t>   atomic_int_least8_t;
+typedef atomic<uint_least8_t>  atomic_uint_least8_t;
+typedef atomic<int_least16_t>  atomic_int_least16_t;
+typedef atomic<uint_least16_t> atomic_uint_least16_t;
+typedef atomic<int_least32_t>  atomic_int_least32_t;
+typedef atomic<uint_least32_t> atomic_uint_least32_t;
+typedef atomic<int_least64_t>  atomic_int_least64_t;
+typedef atomic<uint_least64_t> atomic_uint_least64_t;
+
+typedef atomic<int_fast8_t>   atomic_int_fast8_t;
+typedef atomic<uint_fast8_t>  atomic_uint_fast8_t;
+typedef atomic<int_fast16_t>  atomic_int_fast16_t;
+typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+typedef atomic<int_fast32_t>  atomic_int_fast32_t;
+typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+typedef atomic<int_fast64_t>  atomic_int_fast64_t;
+typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+
+typedef atomic<intptr_t>  atomic_intptr_t;
+typedef atomic<uintptr_t> atomic_uintptr_t;
+typedef atomic<size_t>    atomic_size_t;
+typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+typedef atomic<intmax_t>  atomic_intmax_t;
+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_ATOMIC
diff --git a/final/include/bitset b/final/include/bitset
new file mode 100644
index 0000000..8c278cc
--- /dev/null
+++ b/final/include/bitset
@@ -0,0 +1,1081 @@
+// -*- C++ -*-
+//===---------------------------- bitset ----------------------------------===//
+//
+//                     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_BITSET
+#define _LIBCPP_BITSET
+
+/*
+    bitset synopsis
+
+namespace std
+{
+
+namespace std {
+
+template <size_t N>
+class bitset
+{
+public:
+    // bit reference:
+    class reference
+    {
+        friend class bitset;
+        reference() noexcept;
+    public:
+        ~reference() noexcept;
+        reference& operator=(bool x) noexcept;           // for b[i] = x;
+        reference& operator=(const reference&) noexcept; // for b[i] = b[j];
+        bool operator~() const noexcept;                 // flips the bit
+        operator bool() const noexcept;                  // for x = b[i];
+        reference& flip() noexcept;                      // for b[i].flip();
+    };
+
+    // 23.3.5.1 constructors:
+    constexpr bitset() noexcept;
+    constexpr bitset(unsigned long long val) noexcept;
+    template <class charT>
+        explicit bitset(const charT* str,
+                        typename basic_string<charT>::size_type n = basic_string<charT>::npos,
+                        charT zero = charT('0'), charT one = charT('1'));
+    template<class charT, class traits, class Allocator>
+        explicit bitset(const basic_string<charT,traits,Allocator>& str,
+                        typename basic_string<charT,traits,Allocator>::size_type pos = 0,
+                        typename basic_string<charT,traits,Allocator>::size_type n =
+                                 basic_string<charT,traits,Allocator>::npos,
+                        charT zero = charT('0'), charT one = charT('1'));
+
+    // 23.3.5.2 bitset operations:
+    bitset& operator&=(const bitset& rhs) noexcept;
+    bitset& operator|=(const bitset& rhs) noexcept;
+    bitset& operator^=(const bitset& rhs) noexcept;
+    bitset& operator<<=(size_t pos) noexcept;
+    bitset& operator>>=(size_t pos) noexcept;
+    bitset& set() noexcept;
+    bitset& set(size_t pos, bool val = true);
+    bitset& reset() noexcept;
+    bitset& reset(size_t pos);
+    bitset operator~() const noexcept;
+    bitset& flip() noexcept;
+    bitset& flip(size_t pos);
+
+    // element access:
+    constexpr bool operator[](size_t pos) const; // for b[i];
+    reference operator[](size_t pos);            // for b[i];
+    unsigned long to_ulong() const;
+    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>
+        basic_string<charT, traits, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
+    template <class charT>
+        basic_string<charT, char_traits<charT>, allocator<charT> > to_string(charT zero = charT('0'), charT one = charT('1')) const;
+    basic_string<char, char_traits<char>, allocator<char> > to_string(char zero = '0', char one = '1') const;
+    size_t count() const noexcept;
+    constexpr size_t size() const noexcept;
+    bool operator==(const bitset& rhs) const noexcept;
+    bool operator!=(const bitset& rhs) const noexcept;
+    bool test(size_t pos) const;
+    bool all() const noexcept;
+    bool any() const noexcept;
+    bool none() const noexcept;
+    bitset operator<<(size_t pos) const noexcept;
+    bitset operator>>(size_t pos) const noexcept;
+};
+
+// 23.3.5.3 bitset operators:
+template <size_t N>
+bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept;
+
+template <size_t N>
+bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept;
+
+template <size_t N>
+bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept;
+
+template <class charT, class traits, size_t N>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
+
+template <class charT, class traits, size_t N>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
+
+template <size_t N> struct hash<std::bitset<N>>;
+
+}  // std
+
+*/
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include <__config>
+#include <__bit_reference>
+#include <cstddef>
+#include <climits>
+#include <string>
+#include <stdexcept>
+#include <iosfwd>
+#include <__functional_base>
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+    #include <cassert>
+#endif
+
+#include <__undef_min_max>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <size_t _N_words, size_t _Size>
+class __bitset;
+
+template <size_t _N_words, size_t _Size>
+struct __has_storage_type<__bitset<_N_words, _Size> >
+{
+    static const bool value = true;
+};
+
+template <size_t _N_words, size_t _Size>
+class __bitset
+{
+public:
+    typedef ptrdiff_t              difference_type;
+    typedef size_t                 size_type;
+    typedef size_type              __storage_type;
+protected:
+    typedef __bitset __self;
+    typedef       __storage_type*  __storage_pointer;
+    typedef const __storage_type*  __const_storage_pointer;
+    static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+    friend class __bit_reference<__bitset>;
+    friend class __bit_const_reference<__bitset>;
+    friend class __bit_iterator<__bitset, false>;
+    friend class __bit_iterator<__bitset, true>;
+    friend struct __bit_array<__bitset>;
+
+    __storage_type __first_[_N_words];
+
+    typedef __bit_reference<__bitset>                  reference;
+    typedef __bit_const_reference<__bitset>            const_reference;
+    typedef __bit_iterator<__bitset, false>            iterator;
+    typedef __bit_iterator<__bitset, true>             const_iterator;
+
+    _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+    explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
+        {return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
+        {return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+    _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT
+        {return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+    _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
+        {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+
+    void operator&=(const __bitset& __v) _NOEXCEPT;
+    void operator|=(const __bitset& __v) _NOEXCEPT;
+    void operator^=(const __bitset& __v) _NOEXCEPT;
+
+    void flip() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const
+        {return to_ulong(integral_constant<bool, _Size < sizeof(unsigned long) * CHAR_BIT>());}
+    _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const
+        {return to_ullong(integral_constant<bool, _Size < sizeof(unsigned long long) * CHAR_BIT>());}
+
+    bool all() const _NOEXCEPT;
+    bool any() const _NOEXCEPT;
+    size_t __hash_code() const _NOEXCEPT;
+private:
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    void __init(unsigned long long __v, false_type) _NOEXCEPT;
+    void __init(unsigned long long __v, true_type) _NOEXCEPT;
+#endif  // _LIBCPP_HAS_NO_CONSTEXPR
+    unsigned long to_ulong(false_type) const;
+    unsigned long to_ulong(true_type) const;
+    unsigned long long to_ullong(false_type) const;
+    unsigned long long to_ullong(true_type) const;
+    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
+_LIBCPP_CONSTEXPR
+__bitset<_N_words, _Size>::__bitset() _NOEXCEPT
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    : __first_{0}
+#endif
+{
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    _VSTD::fill_n(__first_, _N_words, __storage_type(0));
+#endif
+}
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+
+template <size_t _N_words, size_t _Size>
+void
+__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT
+{
+    __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];
+    for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word)
+        __t[__i] = static_cast<__storage_type>(__v);
+    _VSTD::copy(__t, __t + sizeof(__t)/sizeof(__t[0]), __first_);
+    _VSTD::fill(__first_ + sizeof(__t)/sizeof(__t[0]), __first_ + sizeof(__first_)/sizeof(__first_[0]),
+               __storage_type(0));
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT
+{
+    __first_[0] = __v;
+    _VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0));
+}
+
+#endif  // _LIBCPP_HAS_NO_CONSTEXPR
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+__bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+#if __SIZEOF_SIZE_T__ == 8
+    : __first_{__v}
+#elif __SIZEOF_SIZE_T__ == 4
+    : __first_{__v, __v >> __bits_per_word}
+#else
+#error This constructor has not been ported to this platform
+#endif
+#endif
+{
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());
+#endif
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
+{
+    for (size_type __i = 0; __i < _N_words; ++__i)
+        __first_[__i] &= __v.__first_[__i];
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
+{
+    for (size_type __i = 0; __i < _N_words; ++__i)
+        __first_[__i] |= __v.__first_[__i];
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
+{
+    for (size_type __i = 0; __i < _N_words; ++__i)
+        __first_[__i] ^= __v.__first_[__i];
+}
+
+template <size_t _N_words, size_t _Size>
+void
+__bitset<_N_words, _Size>::flip() _NOEXCEPT
+{
+    // do middle whole words
+    size_type __n = _Size;
+    __storage_pointer __p = __first_;
+    for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+        *__p = ~*__p;
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        __storage_type __b = *__p & __m;
+        *__p &= ~__m;
+        *__p |= ~__b & __m;
+    }
+}
+
+template <size_t _N_words, size_t _Size>
+unsigned long
+__bitset<_N_words, _Size>::to_ulong(false_type) const
+{
+    const_iterator __e = __make_iter(_Size);
+    const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
+    if (__i != __e)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw overflow_error("bitset to_ulong overflow error");
+#else
+        assert(!"bitset to_ulong overflow error");
+#endif
+    return __first_[0];
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__bitset<_N_words, _Size>::to_ulong(true_type) const
+{
+    return __first_[0];
+}
+
+template <size_t _N_words, size_t _Size>
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(false_type) const
+{
+    const_iterator __e = __make_iter(_Size);
+    const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
+    if (__i != __e)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw overflow_error("bitset to_ullong overflow error");
+#else
+        assert(!"bitset to_ullong overflow error");
+#endif
+    return to_ullong(true_type());
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(true_type) const
+{
+    return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const
+{
+    return __first_[0];
+}
+
+template <size_t _N_words, size_t _Size>
+unsigned long long
+__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const
+{
+    unsigned long long __r = __first_[0];
+    for (std::size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
+        __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
+    return __r;
+}
+
+template <size_t _N_words, size_t _Size>
+bool
+__bitset<_N_words, _Size>::all() const _NOEXCEPT
+{
+    // do middle whole words
+    size_type __n = _Size;
+    __const_storage_pointer __p = __first_;
+    for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+        if (~*__p)
+            return false;
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        if (~*__p & __m)
+            return false;
+    }
+    return true;
+}
+
+template <size_t _N_words, size_t _Size>
+bool
+__bitset<_N_words, _Size>::any() const _NOEXCEPT
+{
+    // do middle whole words
+    size_type __n = _Size;
+    __const_storage_pointer __p = __first_;
+    for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+        if (*__p)
+            return true;
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        if (*__p & __m)
+            return true;
+    }
+    return false;
+}
+
+template <size_t _N_words, size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+__bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT
+{
+    size_t __h = 0;
+    for (size_type __i = 0; __i < _N_words; ++__i)
+        __h ^= __first_[__i];
+    return __h;
+}
+
+template <size_t _Size>
+class __bitset<1, _Size>
+{
+public:
+    typedef ptrdiff_t              difference_type;
+    typedef size_t                 size_type;
+    typedef size_type              __storage_type;
+protected:
+    typedef __bitset __self;
+    typedef       __storage_type*  __storage_pointer;
+    typedef const __storage_type*  __const_storage_pointer;
+    static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+    friend class __bit_reference<__bitset>;
+    friend class __bit_const_reference<__bitset>;
+    friend class __bit_iterator<__bitset, false>;
+    friend class __bit_iterator<__bitset, true>;
+    friend struct __bit_array<__bitset>;
+
+    __storage_type __first_;
+
+    typedef __bit_reference<__bitset>                  reference;
+    typedef __bit_const_reference<__bitset>            const_reference;
+    typedef __bit_iterator<__bitset, false>            iterator;
+    typedef __bit_iterator<__bitset, true>             const_iterator;
+
+    _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+    explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT
+        {return reference(&__first_, __storage_type(1) << __pos);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT
+        {return const_reference(&__first_, __storage_type(1) << __pos);}
+    _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t __pos) _NOEXCEPT
+        {return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+    _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT
+        {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);}
+
+    void operator&=(const __bitset& __v) _NOEXCEPT;
+    void operator|=(const __bitset& __v) _NOEXCEPT;
+    void operator^=(const __bitset& __v) _NOEXCEPT;
+
+    void flip() _NOEXCEPT;
+
+    unsigned long to_ulong() const;
+    unsigned long long to_ullong() const;
+
+    bool all() const _NOEXCEPT;
+    bool any() const _NOEXCEPT;
+
+    size_t __hash_code() const _NOEXCEPT;
+};
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+__bitset<1, _Size>::__bitset() _NOEXCEPT
+    : __first_(0)
+{
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+__bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
+    : __first_(static_cast<__storage_type>(__v))
+{
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT
+{
+    __first_ &= __v.__first_;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT
+{
+    __first_ |= __v.__first_;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT
+{
+    __first_ ^= __v.__first_;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__bitset<1, _Size>::flip() _NOEXCEPT
+{
+    __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
+    __first_ = ~__first_;
+    __first_ &= __m;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+__bitset<1, _Size>::to_ulong() const
+{
+    return __first_;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+__bitset<1, _Size>::to_ullong() const
+{
+    return __first_;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__bitset<1, _Size>::all() const _NOEXCEPT
+{
+    __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
+    return !(~__first_ & __m);
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+__bitset<1, _Size>::any() const _NOEXCEPT
+{
+    __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);
+    return __first_ & __m;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+__bitset<1, _Size>::__hash_code() const _NOEXCEPT
+{
+    return __first_;
+}
+
+template <>
+class __bitset<0, 0>
+{
+public:
+    typedef ptrdiff_t              difference_type;
+    typedef size_t                 size_type;
+    typedef size_type              __storage_type;
+protected:
+    typedef __bitset __self;
+    typedef       __storage_type*  __storage_pointer;
+    typedef const __storage_type*  __const_storage_pointer;
+    static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+    friend class __bit_reference<__bitset>;
+    friend class __bit_const_reference<__bitset>;
+    friend class __bit_iterator<__bitset, false>;
+    friend class __bit_iterator<__bitset, true>;
+    friend struct __bit_array<__bitset>;
+
+    typedef __bit_reference<__bitset>                  reference;
+    typedef __bit_const_reference<__bitset>            const_reference;
+    typedef __bit_iterator<__bitset, false>            iterator;
+    typedef __bit_iterator<__bitset, true>             const_iterator;
+
+    _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT;
+    explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT
+        {return reference(0, 1);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT
+        {return const_reference(0, 1);}
+    _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_t) _NOEXCEPT
+        {return iterator(0, 0);}
+    _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t) const _NOEXCEPT
+        {return const_iterator(0, 0);}
+
+    _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset&) _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset&) _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset&) _NOEXCEPT {}
+
+    _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {}
+
+    _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const {return 0;}
+
+    _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT {return true;}
+    _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT {return false;}
+
+    _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;}
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+__bitset<0, 0>::__bitset() _NOEXCEPT
+{
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_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>
+class _LIBCPP_TYPE_VIS_ONLY bitset
+    : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size>
+{
+public:
+    static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
+    typedef __bitset<__n_words, _Size> base;
+
+public:
+    typedef typename base::reference       reference;
+    typedef typename base::const_reference const_reference;
+
+    // 23.3.5.1 constructors:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+        bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
+    template<class _CharT>
+        explicit bitset(const _CharT* __str,
+                        typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
+                        _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
+    template<class _CharT, class _Traits, class _Allocator>
+        explicit bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
+                        typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos = 0,
+                        typename basic_string<_CharT,_Traits,_Allocator>::size_type __n =
+                                (basic_string<_CharT,_Traits,_Allocator>::npos),
+                        _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
+
+    // 23.3.5.2 bitset operations:
+    bitset& operator&=(const bitset& __rhs) _NOEXCEPT;
+    bitset& operator|=(const bitset& __rhs) _NOEXCEPT;
+    bitset& operator^=(const bitset& __rhs) _NOEXCEPT;
+    bitset& operator<<=(size_t __pos) _NOEXCEPT;
+    bitset& operator>>=(size_t __pos) _NOEXCEPT;
+    bitset& set() _NOEXCEPT;
+    bitset& set(size_t __pos, bool __val = true);
+    bitset& reset() _NOEXCEPT;
+    bitset& reset(size_t __pos);
+    bitset  operator~() const _NOEXCEPT;
+    bitset& flip() _NOEXCEPT;
+    bitset& flip(size_t __pos);
+
+    // element access:
+    _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);}
+    unsigned long to_ulong() const;
+    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>
+        basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
+                                                                    _CharT __one = _CharT('1')) const;
+    template <class _CharT>
+        basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'),
+                                                                                _CharT __one = _CharT('1')) const;
+    basic_string<char, char_traits<char>, allocator<char> > to_string(char __zero = '0',
+                                                                      char __one = '1') const;
+    size_t count() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;}
+    bool operator==(const bitset& __rhs) const _NOEXCEPT;
+    bool operator!=(const bitset& __rhs) const _NOEXCEPT;
+    bool test(size_t __pos) const;
+    bool all() const _NOEXCEPT;
+    bool any() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();}
+    bitset operator<<(size_t __pos) const _NOEXCEPT;
+    bitset operator>>(size_t __pos) const _NOEXCEPT;
+
+private:
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t __hash_code() const _NOEXCEPT {return base::__hash_code();}
+
+    friend struct hash<bitset>;
+};
+
+template <size_t _Size>
+template<class _CharT>
+bitset<_Size>::bitset(const _CharT* __str,
+                      typename basic_string<_CharT>::size_type __n,
+                      _CharT __zero, _CharT __one)
+{
+    size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str));
+    for (size_t __i = 0; __i < __rlen; ++__i)
+        if (__str[__i] != __zero && __str[__i] != __one)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw invalid_argument("bitset string ctor has invalid argument");
+#else
+            assert(!"bitset string ctor has invalid argument");
+#endif
+    size_t _Mp = _VSTD::min(__rlen, _Size);
+    size_t __i = 0;
+    for (; __i < _Mp; ++__i)
+    {
+        _CharT __c = __str[_Mp - 1 - __i];
+        if (__c == __zero)
+            (*this)[__i] = false;
+        else
+            (*this)[__i] = true;
+    }
+    _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
+}
+
+template <size_t _Size>
+template<class _CharT, class _Traits, class _Allocator>
+bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
+       typename basic_string<_CharT,_Traits,_Allocator>::size_type __pos,
+       typename basic_string<_CharT,_Traits,_Allocator>::size_type __n,
+       _CharT __zero, _CharT __one)
+{
+    if (__pos > __str.size())
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("bitset string pos out of range");
+#else
+        assert(!"bitset string pos out of range");
+#endif
+    size_t __rlen = _VSTD::min(__n, __str.size() - __pos);
+    for (size_t __i = __pos; __i < __pos + __rlen; ++__i)
+        if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw invalid_argument("bitset string ctor has invalid argument");
+#else
+            assert(!"bitset string ctor has invalid argument");
+#endif
+    size_t _Mp = _VSTD::min(__rlen, _Size);
+    size_t __i = 0;
+    for (; __i < _Mp; ++__i)
+    {
+        _CharT __c = __str[__pos + _Mp - 1 - __i];
+        if (_Traits::eq(__c, __zero))
+            (*this)[__i] = false;
+        else
+            (*this)[__i] = true;
+    }
+    _VSTD::fill(base::__make_iter(__i), base::__make_iter(_Size), false);
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>&
+bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT
+{
+    base::operator&=(__rhs);
+    return *this;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>&
+bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT
+{
+    base::operator|=(__rhs);
+    return *this;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>&
+bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT
+{
+    base::operator^=(__rhs);
+    return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT
+{
+    __pos = _VSTD::min(__pos, _Size);
+    _VSTD::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size));
+    _VSTD::fill_n(base::__make_iter(0), __pos, false);
+    return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT
+{
+    __pos = _VSTD::min(__pos, _Size);
+    _VSTD::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0));
+    _VSTD::fill_n(base::__make_iter(_Size - __pos), __pos, false);
+    return *this;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>&
+bitset<_Size>::set() _NOEXCEPT
+{
+    _VSTD::fill_n(base::__make_iter(0), _Size, true);
+    return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::set(size_t __pos, bool __val)
+{
+    if (__pos >= _Size)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("bitset set argument out of range");
+#else
+        assert(!"bitset set argument out of range");
+#endif
+    (*this)[__pos] = __val;
+    return *this;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>&
+bitset<_Size>::reset() _NOEXCEPT
+{
+    _VSTD::fill_n(base::__make_iter(0), _Size, false);
+    return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::reset(size_t __pos)
+{
+    if (__pos >= _Size)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("bitset reset argument out of range");
+#else
+        assert(!"bitset reset argument out of range");
+#endif
+    (*this)[__pos] = false;
+    return *this;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+bitset<_Size>::operator~() const _NOEXCEPT
+{
+    bitset __x(*this);
+    __x.flip();
+    return __x;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>&
+bitset<_Size>::flip() _NOEXCEPT
+{
+    base::flip();
+    return *this;
+}
+
+template <size_t _Size>
+bitset<_Size>&
+bitset<_Size>::flip(size_t __pos)
+{
+    if (__pos >= _Size)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("bitset flip argument out of range");
+#else
+        assert(!"bitset flip argument out of range");
+#endif
+    reference r = base::__make_ref(__pos);
+    r = ~r;
+    return *this;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long
+bitset<_Size>::to_ulong() const
+{
+    return base::to_ulong();
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long
+bitset<_Size>::to_ullong() const
+{
+    return base::to_ullong();
+}
+
+template <size_t _Size>
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
+{
+    basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);
+    for (size_t __i = 0; __i < _Size; ++__i)
+    {
+        if ((*this)[__i])
+            __r[_Size - 1 - __i] = __one;
+    }
+    return __r;
+}
+
+template <size_t _Size>
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, allocator<_CharT> >
+bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
+{
+    return to_string<_CharT, _Traits, allocator<_CharT> >(__zero, __one);
+}
+
+template <size_t _Size>
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> >
+bitset<_Size>::to_string(_CharT __zero, _CharT __one) const
+{
+    return to_string<_CharT, char_traits<_CharT>, allocator<_CharT> >(__zero, __one);
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<char, char_traits<char>, allocator<char> >
+bitset<_Size>::to_string(char __zero, char __one) const
+{
+    return to_string<char, char_traits<char>, allocator<char> >(__zero, __one);
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+bitset<_Size>::count() const _NOEXCEPT
+{
+    return static_cast<size_t>(_VSTD::count(base::__make_iter(0), base::__make_iter(_Size), true));
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT
+{
+    return _VSTD::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0));
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT
+{
+    return !(*this == __rhs);
+}
+
+template <size_t _Size>
+bool
+bitset<_Size>::test(size_t __pos) const
+{
+    if (__pos >= _Size)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("bitset test argument out of range");
+#else
+        assert(!"bitset test argument out of range");
+#endif
+    return (*this)[__pos];
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+bitset<_Size>::all() const _NOEXCEPT
+{
+    return base::all();
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+bitset<_Size>::any() const _NOEXCEPT
+{
+    return base::any();
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT
+{
+    bitset __r = *this;
+    __r <<= __pos;
+    return __r;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT
+{
+    bitset __r = *this;
+    __r >>= __pos;
+    return __r;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+operator&(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
+{
+    bitset<_Size> __r = __x;
+    __r &= __y;
+    return __r;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
+{
+    bitset<_Size> __r = __x;
+    __r |= __y;
+    return __r;
+}
+
+template <size_t _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+bitset<_Size>
+operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
+{
+    bitset<_Size> __r = __x;
+    __r ^= __y;
+    return __r;
+}
+
+template <size_t _Size>
+struct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> >
+    : public unary_function<bitset<_Size>, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT
+        {return __bs.__hash_code();}
+};
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x);
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_BITSET
diff --git a/final/include/cassert b/final/include/cassert
new file mode 100644
index 0000000..3775990
--- /dev/null
+++ b/final/include/cassert
@@ -0,0 +1,25 @@
+// -*- C++ -*-
+//===-------------------------- cassert -----------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+/*
+    cassert synopsis
+
+Macros:
+
+    assert
+
+*/
+
+#include <__config>
+#include <assert.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
diff --git a/final/include/ccomplex b/final/include/ccomplex
new file mode 100644
index 0000000..6ed1164
--- /dev/null
+++ b/final/include/ccomplex
@@ -0,0 +1,29 @@
+// -*- C++ -*-
+//===--------------------------- ccomplex ---------------------------------===//
+//
+//                     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_CCOMPLEX
+#define _LIBCPP_CCOMPLEX
+
+/*
+    ccomplex synopsis
+
+#include <complex>
+
+*/
+
+#include <complex>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+// hh 080623 Created
+
+#endif  // _LIBCPP_CCOMPLEX
diff --git a/final/include/cctype b/final/include/cctype
new file mode 100644
index 0000000..b647903
--- /dev/null
+++ b/final/include/cctype
@@ -0,0 +1,164 @@
+// -*- C++ -*-
+//===---------------------------- cctype ----------------------------------===//
+//
+//                     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_CCTYPE
+#define _LIBCPP_CCTYPE
+
+/*
+    cctype synopsis
+
+namespace std
+{
+
+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);
+
+}  // std
+*/
+
+#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
+#endif
+
+_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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+
+#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
+using ::toupper;
+#endif  // toupper
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CCTYPE
diff --git a/final/include/cerrno b/final/include/cerrno
new file mode 100644
index 0000000..9804e4e
--- /dev/null
+++ b/final/include/cerrno
@@ -0,0 +1,393 @@
+// -*- C++ -*-
+//===-------------------------- cerrno ------------------------------------===//
+//
+//                     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_CERRNO
+#define _LIBCPP_CERRNO
+
+/*
+    cerrno synopsis
+
+Macros:
+
+    EDOM
+    EILSEQ  // C99
+    ERANGE
+    errno
+
+*/
+
+#include <__config>
+#include <errno.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#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/final/include/cfenv b/final/include/cfenv
new file mode 100644
index 0000000..dd7db37
--- /dev/null
+++ b/final/include/cfenv
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+//===---------------------------- cctype ----------------------------------===//
+//
+//                     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_CFENV
+#define _LIBCPP_CFENV
+
+/*
+    cfenv synopsis
+
+This entire header is C99 / C++0X
+
+Macros:
+
+    FE_DIVBYZERO
+    FE_INEXACT
+    FE_INVALID
+    FE_OVERFLOW
+    FE_UNDERFLOW
+    FE_ALL_EXCEPT
+    FE_DOWNWARD
+    FE_TONEAREST
+    FE_TOWARDZERO
+    FE_UPWARD
+    FE_DFL_ENV
+
+namespace std
+{
+
+Types:
+
+    fenv_t
+    fexcept_t
+
+int feclearexcept(int excepts);
+int fegetexceptflag(fexcept_t* flagp, int excepts);
+int feraiseexcept(int excepts);
+int fesetexceptflag(const fexcept_t* flagp, int excepts);
+int fetestexcept(int excepts);
+int fegetround();
+int fesetround(int round);
+int fegetenv(fenv_t* envp);
+int feholdexcept(fenv_t* envp);
+int fesetenv(const fenv_t* envp);
+int feupdateenv(const fenv_t* envp);
+
+}  // std
+*/
+
+#include <__config>
+#include <fenv.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::fenv_t;
+using ::fexcept_t;
+
+using ::feclearexcept;
+using ::fegetexceptflag;
+using ::feraiseexcept;
+using ::fesetexceptflag;
+using ::fetestexcept;
+using ::fegetround;
+using ::fesetround;
+using ::fegetenv;
+using ::feholdexcept;
+using ::fesetenv;
+using ::feupdateenv;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CFENV
diff --git a/final/include/cfloat b/final/include/cfloat
new file mode 100644
index 0000000..5fa5655
--- /dev/null
+++ b/final/include/cfloat
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+//===--------------------------- cfloat -----------------------------------===//
+//
+//                     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_CFLOAT
+#define _LIBCPP_CFLOAT
+
+/*
+    cfloat 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>
+#include <float.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#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/final/include/chrono b/final/include/chrono
new file mode 100644
index 0000000..2c65eee
--- /dev/null
+++ b/final/include/chrono
@@ -0,0 +1,1027 @@
+// -*- C++ -*-
+//===---------------------------- chrono ----------------------------------===//
+//
+//                     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_CHRONO
+#define _LIBCPP_CHRONO
+
+/*
+    chrono synopsis
+
+namespace std
+{
+namespace chrono
+{
+
+template <class ToDuration, class Rep, class Period>
+constexpr
+ToDuration
+duration_cast(const duration<Rep, Period>& fd);
+
+template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
+
+template <class Rep>
+struct duration_values
+{
+public:
+    static constexpr Rep zero();
+    static constexpr Rep max();
+    static constexpr Rep min();
+};
+
+// duration
+
+template <class Rep, class Period = ratio<1>>
+class duration
+{
+    static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
+    static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
+    static_assert(Period::num > 0, "duration period must be positive");
+public:
+    typedef Rep rep;
+    typedef Period period;
+
+    constexpr duration() = default;
+    template <class Rep2>
+        constexpr explicit duration(const Rep2& r,
+            typename enable_if
+            <
+               is_convertible<Rep2, rep>::value &&
+               (treat_as_floating_point<rep>::value ||
+               !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
+            >::type* = 0);
+
+    // conversions
+    template <class Rep2, class Period2>
+        constexpr duration(const duration<Rep2, Period2>& d,
+            typename enable_if
+            <
+                treat_as_floating_point<rep>::value ||
+                ratio_divide<Period2, period>::type::den == 1
+            >::type* = 0);
+
+    // observer
+
+    constexpr rep count() const;
+
+    // arithmetic
+
+    constexpr duration  operator+() const;
+    constexpr duration  operator-() const;
+    duration& operator++();
+    duration  operator++(int);
+    duration& operator--();
+    duration  operator--(int);
+
+    duration& operator+=(const duration& d);
+    duration& operator-=(const duration& d);
+
+    duration& operator*=(const rep& rhs);
+    duration& operator/=(const rep& rhs);
+
+    // special values
+
+    static constexpr duration zero();
+    static constexpr duration min();
+    static constexpr duration max();
+};
+
+typedef duration<long long,         nano> nanoseconds;
+typedef duration<long long,        micro> microseconds;
+typedef duration<long long,        milli> milliseconds;
+typedef duration<long long              > seconds;
+typedef duration<     long, ratio<  60> > minutes;
+typedef duration<     long, ratio<3600> > hours;
+
+template <class Clock, class Duration = typename Clock::duration>
+class time_point
+{
+public:
+    typedef Clock                     clock;
+    typedef Duration                  duration;
+    typedef typename duration::rep    rep;
+    typedef typename duration::period period;
+private:
+    duration d_;  // exposition only
+
+public:
+    time_point();  // has value "epoch" // constexpr in C++14
+    explicit time_point(const duration& d);  // same as time_point() + d // constexpr in C++14
+
+    // conversions
+    template <class Duration2>
+       time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
+
+    // observer
+
+    duration time_since_epoch() const; // constexpr in C++14
+
+    // arithmetic
+
+    time_point& operator+=(const duration& d);
+    time_point& operator-=(const duration& d);
+
+    // special values
+
+    static constexpr time_point min();
+    static constexpr time_point max();
+};
+
+} // chrono
+
+// common_type traits
+template <class Rep1, class Period1, class Rep2, class Period2>
+  struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
+
+template <class Clock, class Duration1, class Duration2>
+  struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
+
+namespace chrono {
+
+// duration arithmetic
+template <class Rep1, class Period1, class Rep2, class Period2>
+  constexpr
+  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+  operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+  constexpr
+  typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+  operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period, class Rep2>
+  constexpr
+  duration<typename common_type<Rep1, Rep2>::type, Period>
+  operator*(const duration<Rep1, Period>& d, const Rep2& s);
+template <class Rep1, class Period, class Rep2>
+  constexpr
+  duration<typename common_type<Rep1, Rep2>::type, Period>
+  operator*(const Rep1& s, const duration<Rep2, Period>& d);
+template <class Rep1, class Period, class Rep2>
+  constexpr
+  duration<typename common_type<Rep1, Rep2>::type, Period>
+  operator/(const duration<Rep1, Period>& d, const Rep2& s);
+template <class Rep1, class Period1, class Rep2, class Period2>
+  constexpr
+  typename common_type<Rep1, Rep2>::type
+  operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// duration comparisons
+template <class Rep1, class Period1, class Rep2, class Period2>
+   constexpr
+   bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+   constexpr
+   bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+   constexpr
+   bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+   constexpr
+   bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+   constexpr
+   bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Rep2, class Period2>
+   constexpr
+   bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// duration_cast
+template <class ToDuration, class Rep, class Period>
+  ToDuration duration_cast(const duration<Rep, Period>& d);
+
+// 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>
+  operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Rep1, class Period1, class Clock, class Duration2>
+  time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
+  operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Rep2, class Period2>
+  time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+  operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+  typename common_type<Duration1, Duration2>::type
+  operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_point comparisons (all constexpr in C++14)
+template <class Clock, class Duration1, class Duration2>
+   bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+   bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+   bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+   bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+   bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+template <class Clock, class Duration1, class Duration2>
+   bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_point_cast (constexpr in C++14)
+
+template <class ToDuration, class Clock, class Duration>
+  time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
+
+// Clocks
+
+class system_clock
+{
+public:
+    typedef microseconds                     duration;
+    typedef duration::rep                    rep;
+    typedef duration::period                 period;
+    typedef chrono::time_point<system_clock> time_point;
+    static const bool is_steady =            false; // constexpr in C++14
+
+    static time_point now() noexcept;
+    static time_t     to_time_t  (const time_point& __t) noexcept;
+    static time_point from_time_t(time_t __t) noexcept;
+};
+
+class steady_clock
+{
+public:
+    typedef nanoseconds                                   duration;
+    typedef duration::rep                                 rep;
+    typedef duration::period                              period;
+    typedef chrono::time_point<steady_clock, duration>    time_point;
+    static const bool is_steady =                         true; // constexpr in C++14
+
+    static time_point now() noexcept;
+};
+
+typedef steady_clock high_resolution_clock;
+
+}  // chrono
+
+constexpr chrono::hours                                 operator "" h(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , ratio<3600,1>> operator "" h(long double); // C++14
+constexpr chrono::minutes                               operator "" min(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , ratio<60,1>>   operator "" min(long double); // C++14
+constexpr chrono::seconds                               operator "" s(unsigned long long); // C++14
+constexpr chrono::duration<unspecified >                operator "" s(long double); // C++14
+constexpr chrono::milliseconds                          operator "" ms(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , milli>         operator "" ms(long double); // C++14
+constexpr chrono::microseconds                          operator "" us(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , micro>         operator "" us(long double); // C++14
+constexpr chrono::nanoseconds                           operator "" ns(unsigned long long); // C++14
+constexpr chrono::duration<unspecified , nano>          operator "" ns(long double); // C++14
+
+}  // std
+*/
+
+#include <__config>
+#include <ctime>
+#include <type_traits>
+#include <ratio>
+#include <limits>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TYPE_VIS_ONLY duration;
+
+template <class _Tp>
+struct __is_duration : false_type {};
+
+template <class _Rep, class _Period>
+struct __is_duration<duration<_Rep, _Period> > : true_type  {};
+
+template <class _Rep, class _Period>
+struct __is_duration<const duration<_Rep, _Period> > : true_type  {};
+
+template <class _Rep, class _Period>
+struct __is_duration<volatile duration<_Rep, _Period> > : true_type  {};
+
+template <class _Rep, class _Period>
+struct __is_duration<const volatile duration<_Rep, _Period> > : true_type  {};
+
+} // chrono
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::duration<_Rep1, _Period1>,
+                                         chrono::duration<_Rep2, _Period2> >
+{
+    typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
+                             typename __ratio_gcd<_Period1, _Period2>::type> type;
+};
+
+namespace chrono {
+
+// duration_cast
+
+template <class _FromDuration, class _ToDuration,
+          class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
+          bool = _Period::num == 1,
+          bool = _Period::den == 1>
+struct __duration_cast;
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    _ToDuration operator()(const _FromDuration& __fd) const
+    {
+        return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
+    }
+};
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    _ToDuration operator()(const _FromDuration& __fd) const
+    {
+        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
+        return _ToDuration(static_cast<typename _ToDuration::rep>(
+                           static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
+    }
+};
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    _ToDuration operator()(const _FromDuration& __fd) const
+    {
+        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
+        return _ToDuration(static_cast<typename _ToDuration::rep>(
+                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
+    }
+};
+
+template <class _FromDuration, class _ToDuration, class _Period>
+struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    _ToDuration operator()(const _FromDuration& __fd) const
+    {
+        typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
+        return _ToDuration(static_cast<typename _ToDuration::rep>(
+                           static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)
+                                                          / static_cast<_Ct>(_Period::den)));
+    }
+};
+
+template <class _ToDuration, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+    __is_duration<_ToDuration>::value,
+    _ToDuration
+>::type
+duration_cast(const duration<_Rep, _Period>& __fd)
+{
+    return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
+}
+
+template <class _Rep>
+struct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {};
+
+template <class _Rep>
+struct _LIBCPP_TYPE_VIS_ONLY duration_values
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max()  {return numeric_limits<_Rep>::max();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min()  {return numeric_limits<_Rep>::lowest();}
+};
+
+// duration
+
+template <class _Rep, class _Period>
+class _LIBCPP_TYPE_VIS_ONLY duration
+{
+    static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
+    static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
+    static_assert(_Period::num > 0, "duration period must be positive");
+
+    template <class _R1, class _R2>
+    struct __no_overflow
+    {
+    private:
+        static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+        static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+        static const intmax_t __n1 = _R1::num / __gcd_n1_n2;
+        static const intmax_t __d1 = _R1::den / __gcd_d1_d2;
+        static const intmax_t __n2 = _R2::num / __gcd_n1_n2;
+        static const intmax_t __d2 = _R2::den / __gcd_d1_d2;
+        static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1);
+
+        template <intmax_t _Xp, intmax_t _Yp, bool __overflow>
+        struct __mul    // __overflow == false
+        {
+            static const intmax_t value = _Xp * _Yp;
+        };
+
+        template <intmax_t _Xp, intmax_t _Yp>
+        struct __mul<_Xp, _Yp, true>
+        {
+            static const intmax_t value = 1;
+        };
+
+    public:
+        static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1);
+        typedef ratio<__mul<__n1, __d2, !value>::value,
+                      __mul<__n2, __d1, !value>::value> type;
+    };
+    
+public:
+    typedef _Rep rep;
+    typedef _Period period;
+private:
+    rep __rep_;
+public:
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+        duration() = default;
+#else
+        duration() {}
+#endif
+
+    template <class _Rep2>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+        explicit duration(const _Rep2& __r,
+            typename enable_if
+            <
+               is_convertible<_Rep2, rep>::value &&
+               (treat_as_floating_point<rep>::value ||
+               !treat_as_floating_point<_Rep2>::value)
+            >::type* = 0)
+                : __rep_(__r) {}
+
+    // conversions
+    template <class _Rep2, class _Period2>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+        duration(const duration<_Rep2, _Period2>& __d,
+            typename enable_if
+            <
+                __no_overflow<_Period2, period>::value && (
+                treat_as_floating_point<rep>::value ||
+                (__no_overflow<_Period2, period>::type::den == 1 &&
+                 !treat_as_floating_point<_Rep2>::value))
+            >::type* = 0)
+                : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {}
+
+    // observer
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;}
+
+    // arithmetic
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator+() const {return *this;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration  operator-() const {return duration(-__rep_);}
+    _LIBCPP_INLINE_VISIBILITY duration& operator++()      {++__rep_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY duration  operator++(int)   {return duration(__rep_++);}
+    _LIBCPP_INLINE_VISIBILITY duration& operator--()      {--__rep_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY duration  operator--(int)   {return duration(__rep_--);}
+
+    _LIBCPP_INLINE_VISIBILITY duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
+    _LIBCPP_INLINE_VISIBILITY duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
+
+    _LIBCPP_INLINE_VISIBILITY duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
+    _LIBCPP_INLINE_VISIBILITY duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
+    _LIBCPP_INLINE_VISIBILITY duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
+    _LIBCPP_INLINE_VISIBILITY duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
+
+    // special values
+
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() {return duration(duration_values<rep>::zero());}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min()  {return duration(duration_values<rep>::min());}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max()  {return duration(duration_values<rep>::max());}
+};
+
+typedef duration<long long,         nano> nanoseconds;
+typedef duration<long long,        micro> microseconds;
+typedef duration<long long,        milli> milliseconds;
+typedef duration<long long              > seconds;
+typedef duration<     long, ratio<  60> > minutes;
+typedef duration<     long, ratio<3600> > hours;
+
+// Duration ==
+
+template <class _LhsDuration, class _RhsDuration>
+struct __duration_eq
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
+        {
+            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
+            return _Ct(__lhs).count() == _Ct(__rhs).count();
+        }
+};
+
+template <class _LhsDuration>
+struct __duration_eq<_LhsDuration, _LhsDuration>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
+        {return __lhs.count() == __rhs.count();}
+};
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
+}
+
+// Duration !=
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    return !(__lhs == __rhs);
+}
+
+// Duration <
+
+template <class _LhsDuration, class _RhsDuration>
+struct __duration_lt
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const
+        {
+            typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
+            return _Ct(__lhs).count() < _Ct(__rhs).count();
+        }
+};
+
+template <class _LhsDuration>
+struct __duration_lt<_LhsDuration, _LhsDuration>
+{
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const
+        {return __lhs.count() < __rhs.count();}
+};
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
+}
+
+// Duration >
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    return __rhs < __lhs;
+}
+
+// Duration <=
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    return !(__rhs < __lhs);
+}
+
+// Duration >=
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+bool
+operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    return !(__lhs < __rhs);
+}
+
+// Duration +
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
+operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+    return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
+}
+
+// Duration -
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
+operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+    return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
+}
+
+// Duration *
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+    is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
+    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
+operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+{
+    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+    typedef duration<_Cr, _Period> _Cd;
+    return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s));
+}
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename enable_if
+<
+    is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
+    duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
+operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
+{
+    return __d * __s;
+}
+
+// Duration /
+
+template <class _Duration, class _Rep, bool = __is_duration<_Rep>::value>
+struct __duration_divide_result
+{
+};
+
+template <class _Duration, class _Rep2,
+    bool = is_convertible<_Rep2,
+                          typename common_type<typename _Duration::rep, _Rep2>::type>::value>
+struct __duration_divide_imp
+{
+};
+
+template <class _Rep1, class _Period, class _Rep2>
+struct __duration_divide_imp<duration<_Rep1, _Period>, _Rep2, true>
+{
+    typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> type;
+};
+
+template <class _Rep1, class _Period, class _Rep2>
+struct __duration_divide_result<duration<_Rep1, _Period>, _Rep2, false>
+    : __duration_divide_imp<duration<_Rep1, _Period>, _Rep2>
+{
+};
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
+operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+{
+    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+    typedef duration<_Cr, _Period> _Cd;
+    return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s));
+}
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<_Rep1, _Rep2>::type
+operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
+    return _Ct(__lhs).count() / _Ct(__rhs).count();
+}
+
+// Duration %
+
+template <class _Rep1, class _Period, class _Rep2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
+operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+{
+    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+    typedef duration<_Cr, _Period> _Cd;
+    return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s));
+}
+
+template <class _Rep1, class _Period1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
+operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    typedef typename common_type<_Rep1, _Rep2>::type _Cr;
+    typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
+    return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
+}
+
+//////////////////////////////////////////////////////////
+///////////////////// time_point /////////////////////////
+//////////////////////////////////////////////////////////
+
+template <class _Clock, class _Duration = typename _Clock::duration>
+class _LIBCPP_TYPE_VIS_ONLY time_point
+{
+    static_assert(__is_duration<_Duration>::value,
+                  "Second template parameter of time_point must be a std::chrono::duration");
+public:
+    typedef _Clock                    clock;
+    typedef _Duration                 duration;
+    typedef typename duration::rep    rep;
+    typedef typename duration::period period;
+private:
+    duration __d_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {}
+
+    // conversions
+    template <class _Duration2>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    time_point(const time_point<clock, _Duration2>& t,
+        typename enable_if
+        <
+            is_convertible<_Duration2, duration>::value
+        >::type* = 0)
+            : __d_(t.time_since_epoch()) {}
+
+    // observer
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;}
+
+    // arithmetic
+
+    _LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d; return *this;}
+    _LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;}
+
+    // special values
+
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() {return time_point(duration::min());}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() {return time_point(duration::max());}
+};
+
+} // chrono
+
+template <class _Clock, class _Duration1, class _Duration2>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::time_point<_Clock, _Duration1>,
+                                         chrono::time_point<_Clock, _Duration2> >
+{
+    typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
+};
+
+namespace chrono {
+
+template <class _ToDuration, class _Clock, class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+time_point<_Clock, _ToDuration>
+time_point_cast(const time_point<_Clock, _Duration>& __t)
+{
+    return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
+}
+
+// time_point ==
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return __lhs.time_since_epoch() == __rhs.time_since_epoch();
+}
+
+// time_point !=
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return !(__lhs == __rhs);
+}
+
+// time_point <
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return __lhs.time_since_epoch() < __rhs.time_since_epoch();
+}
+
+// time_point >
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return __rhs < __lhs;
+}
+
+// time_point <=
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return !(__rhs < __lhs);
+}
+
+// time_point >=
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return !(__lhs < __rhs);
+}
+
+// time_point operator+(time_point x, duration y);
+
+template <class _Clock, class _Duration1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
+operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
+    return _Tr (__lhs.time_since_epoch() + __rhs);
+}
+
+// time_point operator+(duration x, time_point y);
+
+template <class _Rep1, class _Period1, class _Clock, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
+operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return __rhs + __lhs;
+}
+
+// time_point operator-(time_point x, duration y);
+
+template <class _Clock, class _Duration1, class _Rep2, class _Period2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
+operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
+{
+    return __lhs + (-__rhs);
+}
+
+// duration operator-(time_point x, time_point y);
+
+template <class _Clock, class _Duration1, class _Duration2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename common_type<_Duration1, _Duration2>::type
+operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
+{
+    return __lhs.time_since_epoch() - __rhs.time_since_epoch();
+}
+
+//////////////////////////////////////////////////////////
+/////////////////////// clocks ///////////////////////////
+//////////////////////////////////////////////////////////
+
+class _LIBCPP_TYPE_VIS system_clock
+{
+public:
+    typedef microseconds                     duration;
+    typedef duration::rep                    rep;
+    typedef duration::period                 period;
+    typedef chrono::time_point<system_clock> time_point;
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
+
+    static time_point now() _NOEXCEPT;
+    static time_t     to_time_t  (const time_point& __t) _NOEXCEPT;
+    static time_point from_time_t(time_t __t) _NOEXCEPT;
+};
+
+class _LIBCPP_TYPE_VIS steady_clock
+{
+public:
+    typedef nanoseconds                                   duration;
+    typedef duration::rep                                 rep;
+    typedef duration::period                              period;
+    typedef chrono::time_point<steady_clock, duration>    time_point;
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true;
+
+    static time_point now() _NOEXCEPT;
+};
+
+typedef steady_clock high_resolution_clock;
+
+} // chrono
+
+#if _LIBCPP_STD_VER > 11
+// Suffixes for duration literals [time.duration.literals]
+inline namespace literals
+{ 
+  inline namespace chrono_literals
+  {
+
+    constexpr chrono::hours operator"" h(unsigned long long __h)
+    {
+        return chrono::hours(static_cast<chrono::hours::rep>(__h));
+    }
+
+    constexpr chrono::duration<long double, ratio<3600,1>> operator"" h(long double __h)
+    {
+        return chrono::duration<long double, ratio<3600,1>>(__h);
+    }
+
+
+    constexpr chrono::minutes operator"" min(unsigned long long __m)
+    {
+        return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
+    }
+
+    constexpr chrono::duration<long double, ratio<60,1>> operator"" min(long double __m)
+    {
+        return chrono::duration<long double, ratio<60,1>> (__m);
+    }
+
+
+    constexpr chrono::seconds operator"" s(unsigned long long __s)
+    {
+        return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
+    }
+
+    constexpr chrono::duration<long double> operator"" s(long double __s)
+    {
+        return chrono::duration<long double> (__s);
+    }
+
+
+    constexpr chrono::milliseconds operator"" ms(unsigned long long __ms)
+    {
+        return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
+    }
+
+    constexpr chrono::duration<long double, milli> operator"" ms(long double __ms)
+    {
+        return chrono::duration<long double, milli>(__ms);
+    }
+
+
+    constexpr chrono::microseconds operator"" us(unsigned long long __us)
+    {
+        return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
+    }
+
+    constexpr chrono::duration<long double, micro> operator"" us(long double __us)
+    {
+        return chrono::duration<long double, micro> (__us);
+    }
+    
+
+    constexpr chrono::nanoseconds operator"" ns(unsigned long long __ns)
+    {
+        return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
+    }
+
+    constexpr chrono::duration<long double, nano> operator"" ns(long double __ns)
+    {
+        return chrono::duration<long double, nano> (__ns);
+    }
+
+}}
+
+namespace chrono { // hoist the literals into namespace std::chrono
+   using namespace literals::chrono_literals;
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CHRONO
diff --git a/final/include/cinttypes b/final/include/cinttypes
new file mode 100644
index 0000000..786692b
--- /dev/null
+++ b/final/include/cinttypes
@@ -0,0 +1,259 @@
+// -*- C++ -*-
+//===--------------------------- cinttypes --------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_CINTTYPES
+#define _LIBCPP_CINTTYPES
+
+/*
+    cinttypes synopsis
+
+This entire header is C99 / C++0X
+
+#include <cstdint>  // <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
+
+namespace std
+{
+
+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);
+
+}  // std
+*/
+
+#include <__config>
+#include <cstdint>
+#include <inttypes.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using::imaxdiv_t;
+
+using::imaxabs;
+using::imaxdiv;
+using::strtoimax;
+using::strtoumax;
+using::wcstoimax;
+using::wcstoumax;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CINTTYPES
diff --git a/final/include/ciso646 b/final/include/ciso646
new file mode 100644
index 0000000..b2efc72
--- /dev/null
+++ b/final/include/ciso646
@@ -0,0 +1,25 @@
+// -*- C++ -*-
+//===--------------------------- ciso646 ----------------------------------===//
+//
+//                     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_CISO646
+#define _LIBCPP_CISO646
+
+/*
+    ciso646 synopsis
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#endif  // _LIBCPP_CISO646
diff --git a/final/include/climits b/final/include/climits
new file mode 100644
index 0000000..81ffecd
--- /dev/null
+++ b/final/include/climits
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//===--------------------------- climits ----------------------------------===//
+//
+//                     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_CLIMITS
+#define _LIBCPP_CLIMITS
+
+/*
+    climits synopsis
+
+Macros:
+
+    CHAR_BIT
+    SCHAR_MIN
+    SCHAR_MAX
+    UCHAR_MAX
+    CHAR_MIN
+    CHAR_MAX
+    MB_LEN_MAX
+    SHRT_MIN
+    SHRT_MAX
+    USHRT_MAX
+    INT_MIN
+    INT_MAX
+    UINT_MAX
+    LONG_MIN
+    LONG_MAX
+    ULONG_MAX
+    LLONG_MIN   // C99
+    LLONG_MAX   // C99
+    ULLONG_MAX  // C99
+
+*/
+
+#include <__config>
+#include <limits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#endif  // _LIBCPP_CLIMITS
diff --git a/final/include/clocale b/final/include/clocale
new file mode 100644
index 0000000..f8b8f0d
--- /dev/null
+++ b/final/include/clocale
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+//===--------------------------- clocale ----------------------------------===//
+//
+//                     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_CLOCALE
+#define _LIBCPP_CLOCALE
+
+/*
+    clocale synopsis
+
+Macros:
+
+    LC_ALL
+    LC_COLLATE
+    LC_CTYPE
+    LC_MONETARY
+    LC_NUMERIC
+    LC_TIME
+    NULL
+
+namespace std
+{
+
+struct lconv;
+char* setlocale(int category, const char* locale);
+lconv* localeconv();
+
+}  // std
+
+*/
+
+#include <__config>
+#include <locale.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::lconv;
+using ::setlocale;
+using ::localeconv;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CLOCALE
diff --git a/final/include/cmath b/final/include/cmath
new file mode 100644
index 0000000..964c672
--- /dev/null
+++ b/final/include/cmath
@@ -0,0 +1,1685 @@
+// -*- C++ -*-
+//===---------------------------- cmath -----------------------------------===//
+//
+//                     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_CMATH
+#define _LIBCPP_CMATH
+
+/*
+    cmath 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
+
+namespace std
+{
+
+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);
+
+}  // std
+
+*/
+
+#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 __x) _NOEXCEPT
+{
+    return signbit(__x);
+}
+
+#undef signbit
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+signbit(_A1 __x) _NOEXCEPT
+{
+    return __libcpp_signbit((typename std::__promote<_A1>::type)__x);
+}
+
+#endif  // signbit
+
+// fpclassify
+
+#ifdef fpclassify
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+int
+__libcpp_fpclassify(_A1 __x) _NOEXCEPT
+{
+    return fpclassify(__x);
+}
+
+#undef fpclassify
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
+fpclassify(_A1 __x) _NOEXCEPT
+{
+    return __libcpp_fpclassify((typename std::__promote<_A1>::type)__x);
+}
+
+#endif  // fpclassify
+
+// isfinite
+
+#ifdef isfinite
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isfinite(_A1 __x) _NOEXCEPT
+{
+    return isfinite(__x);
+}
+
+#undef isfinite
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isfinite(_A1 __x) _NOEXCEPT
+{
+    return __libcpp_isfinite((typename std::__promote<_A1>::type)__x);
+}
+
+#endif  // isfinite
+
+// isinf
+
+#ifdef isinf
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isinf(_A1 __x) _NOEXCEPT
+{
+    return isinf(__x);
+}
+
+#undef isinf
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isinf(_A1 __x) _NOEXCEPT
+{
+    return __libcpp_isinf((typename std::__promote<_A1>::type)__x);
+}
+
+#endif  // isinf
+
+// isnan
+
+#ifdef isnan
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isnan(_A1 __x) _NOEXCEPT
+{
+    return isnan(__x);
+}
+
+#undef isnan
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isnan(_A1 __x) _NOEXCEPT
+{
+    return __libcpp_isnan((typename std::__promote<_A1>::type)__x);
+}
+
+#endif  // isnan
+
+// isnormal
+
+#ifdef isnormal
+
+template <class _A1>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isnormal(_A1 __x) _NOEXCEPT
+{
+    return isnormal(__x);
+}
+
+#undef isnormal
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
+isnormal(_A1 __x) _NOEXCEPT
+{
+    return __libcpp_isnormal((typename std::__promote<_A1>::type)__x);
+}
+
+#endif  // isnormal
+
+// isgreater
+
+#ifdef isgreater
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isgreater(_A1 __x, _A2 __y) _NOEXCEPT
+{
+    return isgreater(__x, __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 __x, _A2 __y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isgreater((type)__x, (type)__y);
+}
+
+#endif  // isgreater
+
+// isgreaterequal
+
+#ifdef isgreaterequal
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT
+{
+    return isgreaterequal(__x, __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 __x, _A2 __y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isgreaterequal((type)__x, (type)__y);
+}
+
+#endif  // isgreaterequal
+
+// isless
+
+#ifdef isless
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isless(_A1 __x, _A2 __y) _NOEXCEPT
+{
+    return isless(__x, __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 __x, _A2 __y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isless((type)__x, (type)__y);
+}
+
+#endif  // isless
+
+// islessequal
+
+#ifdef islessequal
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_islessequal(_A1 __x, _A2 __y) _NOEXCEPT
+{
+    return islessequal(__x, __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 __x, _A2 __y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_islessequal((type)__x, (type)__y);
+}
+
+#endif  // islessequal
+
+// islessgreater
+
+#ifdef islessgreater
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_islessgreater(_A1 __x, _A2 __y) _NOEXCEPT
+{
+    return islessgreater(__x, __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 __x, _A2 __y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_islessgreater((type)__x, (type)__y);
+}
+
+#endif  // islessgreater
+
+// isunordered
+
+#ifdef isunordered
+
+template <class _A1, class _A2>
+_LIBCPP_ALWAYS_INLINE
+bool
+__libcpp_isunordered(_A1 __x, _A2 __y) _NOEXCEPT
+{
+    return isunordered(__x, __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 __x, _A2 __y) _NOEXCEPT
+{
+    typedef typename std::__promote<_A1, _A2>::type type;
+    return __libcpp_isunordered((type)__x, (type)__y);
+}
+
+#endif  // isunordered
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::signbit;
+using ::fpclassify;
+using ::isfinite;
+using ::isinf;
+using ::isnan;
+using ::isnormal;
+using ::isgreater;
+using ::isgreaterequal;
+using ::isless;
+using ::islessequal;
+using ::islessgreater;
+using ::isunordered;
+using ::isunordered;
+
+using ::float_t;
+using ::double_t;
+
+// abs
+
+#if !defined(_AIX)
+inline _LIBCPP_INLINE_VISIBILITY
+float
+abs(float __x) _NOEXCEPT {return fabsf(__x);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+double
+abs(double __x) _NOEXCEPT {return fabs(__x);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long double
+abs(long double __x) _NOEXCEPT {return fabsl(__x);}
+#endif // !defined(_AIX)
+
+#ifndef __sun__
+
+// acos
+
+using ::acos;
+using ::acosf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       acos(float __x) _NOEXCEPT       {return acosf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) _NOEXCEPT {return acosl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+acos(_A1 __x) _NOEXCEPT {return acos((double)__x);}
+
+// asin
+
+using ::asin;
+using ::asinf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       asin(float __x) _NOEXCEPT       {return asinf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) _NOEXCEPT {return asinl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+asin(_A1 __x) _NOEXCEPT {return asin((double)__x);}
+
+// atan
+
+using ::atan;
+using ::atanf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       atan(float __x) _NOEXCEPT       {return atanf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) _NOEXCEPT {return atanl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+atan(_A1 __x) _NOEXCEPT {return atan((double)__x);}
+
+// atan2
+
+using ::atan2;
+using ::atan2f;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       atan2(float __y, float __x) _NOEXCEPT             {return atan2f(__y, __x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) _NOEXCEPT {return atan2l(__y, __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 __y, _A2 __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)__y, (__result_type)__x);
+}
+
+// ceil
+
+using ::ceil;
+using ::ceilf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       ceil(float __x) _NOEXCEPT       {return ceilf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) _NOEXCEPT {return ceill(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+ceil(_A1 __x) _NOEXCEPT {return ceil((double)__x);}
+
+// cos
+
+using ::cos;
+using ::cosf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       cos(float __x) _NOEXCEPT       {return cosf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) _NOEXCEPT {return cosl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+cos(_A1 __x) _NOEXCEPT {return cos((double)__x);}
+
+// cosh
+
+using ::cosh;
+using ::coshf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       cosh(float __x) _NOEXCEPT       {return coshf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) _NOEXCEPT {return coshl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+cosh(_A1 __x) _NOEXCEPT {return cosh((double)__x);}
+
+#endif // __sun__
+// exp
+
+using ::exp;
+using ::expf;
+
+#ifndef __sun__
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       exp(float __x) _NOEXCEPT       {return expf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) _NOEXCEPT {return expl(__x);}
+#endif
+
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+exp(_A1 __x) _NOEXCEPT {return exp((double)__x);}
+
+// fabs
+
+using ::fabs;
+using ::fabsf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       fabs(float __x) _NOEXCEPT       {return fabsf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) _NOEXCEPT {return fabsl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+fabs(_A1 __x) _NOEXCEPT {return fabs((double)__x);}
+
+// floor
+
+using ::floor;
+using ::floorf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       floor(float __x) _NOEXCEPT       {return floorf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) _NOEXCEPT {return floorl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+floor(_A1 __x) _NOEXCEPT {return floor((double)__x);}
+
+// fmod
+
+#endif //__sun__
+using ::fmod;
+using ::fmodf;
+#ifndef __sun__
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       fmod(float __x, float __y) _NOEXCEPT             {return fmodf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) _NOEXCEPT {return fmodl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+
+// frexp
+
+using ::frexp;
+using ::frexpf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       frexp(float __x, int* __e) _NOEXCEPT       {return frexpf(__x, __e);}
+inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) _NOEXCEPT {return frexpl(__x, __e);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+frexp(_A1 __x, int* __e) _NOEXCEPT {return frexp((double)__x, __e);}
+
+// ldexp
+
+using ::ldexp;
+using ::ldexpf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       ldexp(float __x, int __e) _NOEXCEPT       {return ldexpf(__x, __e);}
+inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) _NOEXCEPT {return ldexpl(__x, __e);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+ldexp(_A1 __x, int __e) _NOEXCEPT {return ldexp((double)__x, __e);}
+
+// log
+
+#endif // __sun__
+using ::log;
+using ::logf;
+#ifndef __sun__
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       log(float __x) _NOEXCEPT       {return logf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) _NOEXCEPT {return logl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+log(_A1 __x) _NOEXCEPT {return log((double)__x);}
+
+
+// log10
+
+using ::log10;
+using ::log10f;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       log10(float __x) _NOEXCEPT       {return log10f(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) _NOEXCEPT {return log10l(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+log10(_A1 __x) _NOEXCEPT {return log10((double)__x);}
+
+// modf
+
+using ::modf;
+using ::modff;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       modf(float __x, float* __y) _NOEXCEPT             {return modff(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) _NOEXCEPT {return modfl(__x, __y);}
+#endif
+
+// pow
+
+#endif // __sun__ 
+using ::pow;
+using ::powf;
+
+#ifndef __sun__
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       pow(float __x, float __y) _NOEXCEPT             {return powf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) _NOEXCEPT {return powl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+// sin
+
+using ::sin;
+using ::sinf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       sin(float __x) _NOEXCEPT       {return sinf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) _NOEXCEPT {return sinl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+sin(_A1 __x) _NOEXCEPT {return sin((double)__x);}
+
+// sinh
+
+using ::sinh;
+using ::sinhf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       sinh(float __x) _NOEXCEPT       {return sinhf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) _NOEXCEPT {return sinhl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+sinh(_A1 __x) _NOEXCEPT {return sinh((double)__x);}
+
+// sqrt
+
+#endif // __sun__
+using ::sqrt;
+using ::sqrtf;
+
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       sqrt(float __x) _NOEXCEPT       {return sqrtf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) _NOEXCEPT {return sqrtl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+sqrt(_A1 __x) _NOEXCEPT {return sqrt((double)__x);}
+
+// tan
+
+using ::tan;
+using ::tanf;
+#ifndef __sun__
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       tan(float __x) _NOEXCEPT       {return tanf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) _NOEXCEPT {return tanl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+tan(_A1 __x) _NOEXCEPT {return tan((double)__x);}
+
+// tanh
+
+using ::tanh;
+using ::tanhf;
+
+#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX))
+inline _LIBCPP_INLINE_VISIBILITY float       tanh(float __x) _NOEXCEPT       {return tanhf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) _NOEXCEPT {return tanhl(__x);}
+#endif
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+tanh(_A1 __x) _NOEXCEPT {return tanh((double)__x);}
+
+// acosh
+
+#ifndef _LIBCPP_MSVCRT
+using ::acosh;
+using ::acoshf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       acosh(float __x) _NOEXCEPT       {return acoshf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) _NOEXCEPT {return acoshl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+acosh(_A1 __x) _NOEXCEPT {return acosh((double)__x);}
+#endif
+
+// asinh
+
+#ifndef _LIBCPP_MSVCRT
+using ::asinh;
+using ::asinhf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       asinh(float __x) _NOEXCEPT       {return asinhf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) _NOEXCEPT {return asinhl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+asinh(_A1 __x) _NOEXCEPT {return asinh((double)__x);}
+#endif
+
+// atanh
+
+#ifndef _LIBCPP_MSVCRT
+using ::atanh;
+using ::atanhf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       atanh(float __x) _NOEXCEPT       {return atanhf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) _NOEXCEPT {return atanhl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+atanh(_A1 __x) _NOEXCEPT {return atanh((double)__x);}
+#endif
+
+// cbrt
+
+#ifndef _LIBCPP_MSVCRT
+using ::cbrt;
+using ::cbrtf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       cbrt(float __x) _NOEXCEPT       {return cbrtf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) _NOEXCEPT {return cbrtl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+cbrt(_A1 __x) _NOEXCEPT {return cbrt((double)__x);}
+#endif
+
+// copysign
+
+using ::copysign;
+using ::copysignf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       copysign(float __x, float __y) _NOEXCEPT             {return copysignf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) _NOEXCEPT {return copysignl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+#ifndef _LIBCPP_MSVCRT
+
+// erf
+
+using ::erf;
+using ::erff;
+
+inline _LIBCPP_INLINE_VISIBILITY float       erf(float __x) _NOEXCEPT       {return erff(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) _NOEXCEPT {return erfl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+erf(_A1 __x) _NOEXCEPT {return erf((double)__x);}
+
+// erfc
+
+using ::erfc;
+using ::erfcf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       erfc(float __x) _NOEXCEPT       {return erfcf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) _NOEXCEPT {return erfcl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+erfc(_A1 __x) _NOEXCEPT {return erfc((double)__x);}
+
+// exp2
+
+using ::exp2;
+using ::exp2f;
+
+inline _LIBCPP_INLINE_VISIBILITY float       exp2(float __x) _NOEXCEPT       {return exp2f(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) _NOEXCEPT {return exp2l(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+exp2(_A1 __x) _NOEXCEPT {return exp2((double)__x);}
+
+// expm1
+
+using ::expm1;
+using ::expm1f;
+
+inline _LIBCPP_INLINE_VISIBILITY float       expm1(float __x) _NOEXCEPT       {return expm1f(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) _NOEXCEPT {return expm1l(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+expm1(_A1 __x) _NOEXCEPT {return expm1((double)__x);}
+
+// fdim
+
+using ::fdim;
+using ::fdimf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       fdim(float __x, float __y) _NOEXCEPT             {return fdimf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) _NOEXCEPT {return fdiml(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+// fma
+
+using ::fmaf;
+using ::fma;
+
+inline _LIBCPP_INLINE_VISIBILITY float       fma(float __x, float __y, float __z) _NOEXCEPT                   {return fmaf(__x, __y, __z);}
+inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) _NOEXCEPT {return fmal(__x, __y, __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 __x, _A2 __y, _A3 __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)__x, (__result_type)__y, (__result_type)__z);
+}
+
+// fmax
+
+using ::fmax;
+using ::fmaxf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       fmax(float __x, float __y) _NOEXCEPT             {return fmaxf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) _NOEXCEPT {return fmaxl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+// fmin
+
+using ::fmin;
+using ::fminf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       fmin(float __x, float __y) _NOEXCEPT             {return fminf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) _NOEXCEPT {return fminl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+// hypot
+
+using ::hypot;
+using ::hypotf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       hypot(float __x, float __y) _NOEXCEPT             {return hypotf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) _NOEXCEPT {return hypotl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+// ilogb
+
+using ::ilogb;
+using ::ilogbf;
+
+inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) _NOEXCEPT       {return ilogbf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) _NOEXCEPT {return ilogbl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, int>::type
+ilogb(_A1 __x) _NOEXCEPT {return ilogb((double)__x);}
+
+// lgamma
+
+using ::lgamma;
+using ::lgammaf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       lgamma(float __x) _NOEXCEPT       {return lgammaf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) _NOEXCEPT {return lgammal(__x);}
+
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+lgamma(_A1 __x) _NOEXCEPT {return lgamma((double)__x);}
+
+
+// llrint
+
+using ::llrint;
+using ::llrintf;
+
+inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) _NOEXCEPT       {return llrintf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) _NOEXCEPT {return llrintl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, long long>::type
+llrint(_A1 __x) _NOEXCEPT {return llrint((double)__x);}
+
+// llround
+
+using ::llround;
+using ::llroundf;
+
+inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) _NOEXCEPT       {return llroundf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) _NOEXCEPT {return llroundl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, long long>::type
+llround(_A1 __x) _NOEXCEPT {return llround((double)__x);}
+
+// log1p
+
+using ::log1p;
+using ::log1pf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       log1p(float __x) _NOEXCEPT       {return log1pf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) _NOEXCEPT {return log1pl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+log1p(_A1 __x) _NOEXCEPT {return log1p((double)__x);}
+
+// log2
+
+using ::log2;
+using ::log2f;
+
+inline _LIBCPP_INLINE_VISIBILITY float       log2(float __x) _NOEXCEPT       {return log2f(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) _NOEXCEPT {return log2l(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+log2(_A1 __x) _NOEXCEPT {return log2((double)__x);}
+
+// logb
+
+using ::logb;
+using ::logbf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       logb(float __x) _NOEXCEPT       {return logbf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) _NOEXCEPT {return logbl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+logb(_A1 __x) _NOEXCEPT {return logb((double)__x);}
+
+// lrint
+
+using ::lrint;
+using ::lrintf;
+
+inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) _NOEXCEPT       {return lrintf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) _NOEXCEPT {return lrintl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, long>::type
+lrint(_A1 __x) _NOEXCEPT {return lrint((double)__x);}
+
+// lround
+
+using ::lround;
+using ::lroundf;
+
+inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) _NOEXCEPT       {return lroundf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) _NOEXCEPT {return lroundl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, long>::type
+lround(_A1 __x) _NOEXCEPT {return lround((double)__x);}
+
+#endif // _LIBCPP_MSVCRT
+#endif // __sun__
+
+// nan
+
+#ifndef _LIBCPP_MSVCRT
+using ::nan;
+using ::nanf;
+#endif // _LIBCPP_MSVCRT
+
+#ifndef __sun__
+#ifndef _LIBCPP_MSVCRT
+
+// nearbyint
+
+using ::nearbyint;
+using ::nearbyintf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       nearbyint(float __x) _NOEXCEPT       {return nearbyintf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) _NOEXCEPT {return nearbyintl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+nearbyint(_A1 __x) _NOEXCEPT {return nearbyint((double)__x);}
+
+// nextafter
+
+using ::nextafter;
+using ::nextafterf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       nextafter(float __x, float __y) _NOEXCEPT             {return nextafterf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) _NOEXCEPT {return nextafterl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+// nexttoward
+
+using ::nexttoward;
+using ::nexttowardf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       nexttoward(float __x, long double __y) _NOEXCEPT       {return nexttowardf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) _NOEXCEPT {return nexttowardl(__x, __y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+nexttoward(_A1 __x, long double __y) _NOEXCEPT {return nexttoward((double)__x, __y);}
+
+// remainder
+
+using ::remainder;
+using ::remainderf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       remainder(float __x, float __y) _NOEXCEPT             {return remainderf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) _NOEXCEPT {return remainderl(__x, __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 __x, _A2 __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)__x, (__result_type)__y);
+}
+
+// remquo
+
+using ::remquo;
+using ::remquof;
+
+inline _LIBCPP_INLINE_VISIBILITY float       remquo(float __x, float __y, int* __z) _NOEXCEPT             {return remquof(__x, __y, __z);}
+inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return remquol(__x, __y, __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 __x, _A2 __y, int* __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)__x, (__result_type)__y, __z);
+}
+
+// rint
+
+using ::rint;
+using ::rintf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       rint(float __x) _NOEXCEPT       {return rintf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) _NOEXCEPT {return rintl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+rint(_A1 __x) _NOEXCEPT {return rint((double)__x);}
+
+// round
+
+using ::round;
+using ::roundf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       round(float __x) _NOEXCEPT       {return roundf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) _NOEXCEPT {return roundl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+round(_A1 __x) _NOEXCEPT {return round((double)__x);}
+
+// scalbln
+
+using ::scalbln;
+using ::scalblnf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       scalbln(float __x, long __y) _NOEXCEPT       {return scalblnf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) _NOEXCEPT {return scalblnl(__x, __y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+scalbln(_A1 __x, long __y) _NOEXCEPT {return scalbln((double)__x, __y);}
+
+// scalbn
+
+using ::scalbn;
+using ::scalbnf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       scalbn(float __x, int __y) _NOEXCEPT       {return scalbnf(__x, __y);}
+inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) _NOEXCEPT {return scalbnl(__x, __y);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+scalbn(_A1 __x, int __y) _NOEXCEPT {return scalbn((double)__x, __y);}
+
+// tgamma
+
+using ::tgamma;
+using ::tgammaf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       tgamma(float __x) _NOEXCEPT       {return tgammaf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) _NOEXCEPT {return tgammal(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+tgamma(_A1 __x) _NOEXCEPT {return tgamma((double)__x);}
+
+// trunc
+
+using ::trunc;
+using ::truncf;
+
+inline _LIBCPP_INLINE_VISIBILITY float       trunc(float __x) _NOEXCEPT       {return truncf(__x);}
+inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) _NOEXCEPT {return truncl(__x);}
+
+template <class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_integral<_A1>::value, double>::type
+trunc(_A1 __x) _NOEXCEPT {return trunc((double)__x);}
+
+#endif // !_LIBCPP_MSVCRT
+
+using ::acosl;
+using ::asinl;
+using ::atanl;
+using ::atan2l;
+using ::ceill;
+using ::cosl;
+using ::coshl;
+using ::expl;
+using ::fabsl;
+using ::floorl;
+using ::fmodl;
+using ::frexpl;
+using ::ldexpl;
+using ::logl;
+using ::log10l;
+using ::modfl;
+using ::powl;
+using ::sinl;
+using ::sinhl;
+using ::sqrtl;
+using ::tanl;
+#ifndef _LIBCPP_MSVCRT
+using ::tanhl;
+using ::acoshl;
+using ::asinhl;
+using ::atanhl;
+using ::cbrtl;
+#endif  // !_LIBCPP_MSVCRT
+using ::copysignl;
+#ifndef _LIBCPP_MSVCRT
+using ::erfl;
+using ::erfcl;
+using ::exp2l;
+using ::expm1l;
+using ::fdiml;
+using ::fmal;
+using ::fmaxl;
+using ::fminl;
+using ::hypotl;
+using ::ilogbl;
+using ::lgammal;
+using ::llrintl;
+using ::llroundl;
+using ::log1pl;
+using ::log2l;
+using ::logbl;
+using ::lrintl;
+using ::lroundl;
+using ::nanl;
+using ::nearbyintl;
+using ::nextafterl;
+using ::nexttowardl;
+using ::remainderl;
+using ::remquol;
+using ::rintl;
+using ::roundl;
+using ::scalblnl;
+using ::scalbnl;
+using ::tgammal;
+using ::truncl;
+#endif // !_LIBCPP_MSVCRT
+
+#else 
+using ::lgamma;
+using ::lgammaf;
+#endif // __sun__
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CMATH
diff --git a/final/include/codecvt b/final/include/codecvt
new file mode 100644
index 0000000..6eff107
--- /dev/null
+++ b/final/include/codecvt
@@ -0,0 +1,550 @@
+// -*- C++ -*-
+//===-------------------------- codecvt -----------------------------------===//
+//
+//                     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_CODECVT
+#define _LIBCPP_CODECVT
+
+/*
+    codecvt synopsis
+
+namespace std
+{
+
+enum codecvt_mode
+{
+    consume_header = 4,
+    generate_header = 2,
+    little_endian = 1
+};
+
+template <class Elem, unsigned long Maxcode = 0x10ffff,
+          codecvt_mode Mode = (codecvt_mode)0>
+class codecvt_utf8
+    : public codecvt<Elem, char, mbstate_t>
+{
+    explicit codecvt_utf8(size_t refs = 0);
+    ~codecvt_utf8();
+};
+
+template <class Elem, unsigned long Maxcode = 0x10ffff,
+          codecvt_mode Mode = (codecvt_mode)0>
+class codecvt_utf16
+    : public codecvt<Elem, char, mbstate_t>
+{
+    explicit codecvt_utf16(size_t refs = 0);
+    ~codecvt_utf16();
+};
+
+template <class Elem, unsigned long Maxcode = 0x10ffff,
+          codecvt_mode Mode = (codecvt_mode)0>
+class codecvt_utf8_utf16
+    : public codecvt<Elem, char, mbstate_t>
+{
+    explicit codecvt_utf8_utf16(size_t refs = 0);
+    ~codecvt_utf8_utf16();
+};
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__locale>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum codecvt_mode
+{
+    consume_header = 4,
+    generate_header = 2,
+    little_endian = 1
+};
+
+// codecvt_utf8
+
+template <class _Elem> class __codecvt_utf8;
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t>
+    : public codecvt<wchar_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef wchar_t   intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t>
+    : public codecvt<char16_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char16_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t>
+    : public codecvt<char32_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char32_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <class _Elem, unsigned long _Maxcode = 0x10ffff,
+          codecvt_mode _Mode = (codecvt_mode)0>
+class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8
+    : public __codecvt_utf8<_Elem>
+{
+public:
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt_utf8(size_t __refs = 0)
+        : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    ~codecvt_utf8() {}
+};
+
+// codecvt_utf16
+
+template <class _Elem, bool _LittleEndian> class __codecvt_utf16;
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false>
+    : public codecvt<wchar_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef wchar_t   intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true>
+    : public codecvt<wchar_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef wchar_t   intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false>
+    : public codecvt<char16_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char16_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true>
+    : public codecvt<char16_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char16_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false>
+    : public codecvt<char32_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char32_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true>
+    : public codecvt<char32_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char32_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <class _Elem, unsigned long _Maxcode = 0x10ffff,
+          codecvt_mode _Mode = (codecvt_mode)0>
+class _LIBCPP_TYPE_VIS_ONLY codecvt_utf16
+    : public __codecvt_utf16<_Elem, _Mode & little_endian>
+{
+public:
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt_utf16(size_t __refs = 0)
+        : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    ~codecvt_utf16() {}
+};
+
+// codecvt_utf8_utf16
+
+template <class _Elem> class __codecvt_utf8_utf16;
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t>
+    : public codecvt<wchar_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef wchar_t   intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t>
+    : public codecvt<char32_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char32_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <>
+class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t>
+    : public codecvt<char16_t, char, mbstate_t>
+{
+    unsigned long _Maxcode_;
+    codecvt_mode _Mode_;
+public:
+    typedef char16_t  intern_type;
+    typedef char      extern_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode,
+                            codecvt_mode _Mode)
+        : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode),
+          _Mode_(_Mode) {}
+protected:
+    virtual result
+        do_out(state_type& __st,
+               const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt,
+               extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual result
+        do_in(state_type& __st,
+              const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt,
+              intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const;
+    virtual result
+        do_unshift(state_type& __st,
+                   extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const;
+    virtual int do_encoding() const throw();
+    virtual bool do_always_noconv() const throw();
+    virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
+                          size_t __mx) const;
+    virtual int do_max_length() const throw();
+};
+
+template <class _Elem, unsigned long _Maxcode = 0x10ffff,
+          codecvt_mode _Mode = (codecvt_mode)0>
+class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8_utf16
+    : public __codecvt_utf8_utf16<_Elem>
+{
+public:
+    _LIBCPP_ALWAYS_INLINE
+    explicit codecvt_utf8_utf16(size_t __refs = 0)
+        : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    ~codecvt_utf8_utf16() {}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CODECVT
diff --git a/final/include/complex b/final/include/complex
new file mode 100644
index 0000000..2943da1
--- /dev/null
+++ b/final/include/complex
@@ -0,0 +1,1567 @@
+// -*- C++ -*-
+//===--------------------------- complex ----------------------------------===//
+//
+//                     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_COMPLEX
+#define _LIBCPP_COMPLEX
+
+/*
+    complex synopsis
+
+namespace std
+{
+
+template<class T>
+class complex
+{
+public:
+    typedef T value_type;
+
+    complex(const T& re = T(), const T& im = T()); // constexpr in C++14
+    complex(const complex&);  // constexpr in C++14
+    template<class X> complex(const complex<X>&);  // constexpr in C++14
+
+    T real() const; // constexpr in C++14
+    T imag() const; // constexpr in C++14
+
+    void real(T);
+    void imag(T);
+
+    complex<T>& operator= (const T&);
+    complex<T>& operator+=(const T&);
+    complex<T>& operator-=(const T&);
+    complex<T>& operator*=(const T&);
+    complex<T>& operator/=(const T&);
+
+    complex& operator=(const complex&);
+    template<class X> complex<T>& operator= (const complex<X>&);
+    template<class X> complex<T>& operator+=(const complex<X>&);
+    template<class X> complex<T>& operator-=(const complex<X>&);
+    template<class X> complex<T>& operator*=(const complex<X>&);
+    template<class X> complex<T>& operator/=(const complex<X>&);
+};
+
+template<>
+class complex<float>
+{
+public:
+    typedef float value_type;
+
+    constexpr complex(float re = 0.0f, float im = 0.0f);
+    explicit constexpr complex(const complex<double>&);
+    explicit constexpr complex(const complex<long double>&);
+
+    constexpr float real() const;
+    void real(float);
+    constexpr float imag() const;
+    void imag(float);
+
+    complex<float>& operator= (float);
+    complex<float>& operator+=(float);
+    complex<float>& operator-=(float);
+    complex<float>& operator*=(float);
+    complex<float>& operator/=(float);
+
+    complex<float>& operator=(const complex<float>&);
+    template<class X> complex<float>& operator= (const complex<X>&);
+    template<class X> complex<float>& operator+=(const complex<X>&);
+    template<class X> complex<float>& operator-=(const complex<X>&);
+    template<class X> complex<float>& operator*=(const complex<X>&);
+    template<class X> complex<float>& operator/=(const complex<X>&);
+};
+
+template<>
+class complex<double>
+{
+public:
+    typedef double value_type;
+
+    constexpr complex(double re = 0.0, double im = 0.0);
+    constexpr complex(const complex<float>&);
+    explicit constexpr complex(const complex<long double>&);
+
+    constexpr double real() const;
+    void real(double);
+    constexpr double imag() const;
+    void imag(double);
+
+    complex<double>& operator= (double);
+    complex<double>& operator+=(double);
+    complex<double>& operator-=(double);
+    complex<double>& operator*=(double);
+    complex<double>& operator/=(double);
+    complex<double>& operator=(const complex<double>&);
+
+    template<class X> complex<double>& operator= (const complex<X>&);
+    template<class X> complex<double>& operator+=(const complex<X>&);
+    template<class X> complex<double>& operator-=(const complex<X>&);
+    template<class X> complex<double>& operator*=(const complex<X>&);
+    template<class X> complex<double>& operator/=(const complex<X>&);
+};
+
+template<>
+class complex<long double>
+{
+public:
+    typedef long double value_type;
+
+    constexpr complex(long double re = 0.0L, long double im = 0.0L);
+    constexpr complex(const complex<float>&);
+    constexpr complex(const complex<double>&);
+
+    constexpr long double real() const;
+    void real(long double);
+    constexpr long double imag() const;
+    void imag(long double);
+
+    complex<long double>& operator=(const complex<long double>&);
+    complex<long double>& operator= (long double);
+    complex<long double>& operator+=(long double);
+    complex<long double>& operator-=(long double);
+    complex<long double>& operator*=(long double);
+    complex<long double>& operator/=(long double);
+
+    template<class X> complex<long double>& operator= (const complex<X>&);
+    template<class X> complex<long double>& operator+=(const complex<X>&);
+    template<class X> complex<long double>& operator-=(const complex<X>&);
+    template<class X> complex<long double>& operator*=(const complex<X>&);
+    template<class X> complex<long double>& operator/=(const complex<X>&);
+};
+
+// 26.3.6 operators:
+template<class T> complex<T> operator+(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator+(const complex<T>&, const T&);
+template<class T> complex<T> operator+(const T&, const complex<T>&);
+template<class T> complex<T> operator-(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator-(const complex<T>&, const T&);
+template<class T> complex<T> operator-(const T&, const complex<T>&);
+template<class T> complex<T> operator*(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator*(const complex<T>&, const T&);
+template<class T> complex<T> operator*(const T&, const complex<T>&);
+template<class T> complex<T> operator/(const complex<T>&, const complex<T>&);
+template<class T> complex<T> operator/(const complex<T>&, const T&);
+template<class T> complex<T> operator/(const T&, const complex<T>&);
+template<class T> complex<T> operator+(const complex<T>&);
+template<class T> complex<T> operator-(const complex<T>&);
+template<class T> bool operator==(const complex<T>&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator==(const complex<T>&, const T&); // constexpr in C++14
+template<class T> bool operator==(const T&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator!=(const complex<T>&, const complex<T>&); // constexpr in C++14
+template<class T> bool operator!=(const complex<T>&, const T&); // constexpr in C++14
+template<class T> bool operator!=(const T&, const complex<T>&); // constexpr in C++14
+
+template<class T, class charT, class traits>
+  basic_istream<charT, traits>&
+  operator>>(basic_istream<charT, traits>&, complex<T>&);
+template<class T, class charT, class traits>
+  basic_ostream<charT, traits>&
+  operator<<(basic_ostream<charT, traits>&, const complex<T>&);
+
+// 26.3.7 values:
+
+template<class T>              T real(const complex<T>&); // constexpr in C++14
+                     long double real(long double);       // constexpr in C++14
+                          double real(double);            // constexpr in C++14
+template<Integral T>      double real(T);                 // constexpr in C++14
+                          float  real(float);             // constexpr in C++14
+
+template<class T>              T imag(const complex<T>&); // constexpr in C++14
+                     long double imag(long double);       // constexpr in C++14
+                          double imag(double);            // constexpr in C++14
+template<Integral T>      double imag(T);                 // constexpr in C++14
+                          float  imag(float);             // constexpr in C++14
+
+template<class T> T abs(const complex<T>&);
+
+template<class T>              T arg(const complex<T>&);
+                     long double arg(long double);
+                          double arg(double);
+template<Integral T>      double arg(T);
+                          float  arg(float);
+
+template<class T>              T norm(const complex<T>&);
+                     long double norm(long double);
+                          double norm(double);
+template<Integral T>      double norm(T);
+                          float  norm(float);
+
+template<class T>      complex<T>           conj(const complex<T>&);
+                       complex<long double> conj(long double);
+                       complex<double>      conj(double);
+template<Integral T>   complex<double>      conj(T);
+                       complex<float>       conj(float);
+
+template<class T>    complex<T>           proj(const complex<T>&);
+                     complex<long double> proj(long double);
+                     complex<double>      proj(double);
+template<Integral T> complex<double>      proj(T);
+                     complex<float>       proj(float);
+
+template<class T> complex<T> polar(const T&, const T& = 0);
+
+// 26.3.8 transcendentals:
+template<class T> complex<T> acos(const complex<T>&);
+template<class T> complex<T> asin(const complex<T>&);
+template<class T> complex<T> atan(const complex<T>&);
+template<class T> complex<T> acosh(const complex<T>&);
+template<class T> complex<T> asinh(const complex<T>&);
+template<class T> complex<T> atanh(const complex<T>&);
+template<class T> complex<T> cos (const complex<T>&);
+template<class T> complex<T> cosh (const complex<T>&);
+template<class T> complex<T> exp (const complex<T>&);
+template<class T> complex<T> log (const complex<T>&);
+template<class T> complex<T> log10(const complex<T>&);
+
+template<class T> complex<T> pow(const complex<T>&, const T&);
+template<class T> complex<T> pow(const complex<T>&, const complex<T>&);
+template<class T> complex<T> pow(const T&, const complex<T>&);
+
+template<class T> complex<T> sin (const complex<T>&);
+template<class T> complex<T> sinh (const complex<T>&);
+template<class T> complex<T> sqrt (const complex<T>&);
+template<class T> complex<T> tan (const complex<T>&);
+template<class T> complex<T> tanh (const complex<T>&);
+
+template<class T, class charT, class traits>
+  basic_istream<charT, traits>&
+  operator>>(basic_istream<charT, traits>& is, complex<T>& x);
+
+template<class T, class charT, class traits>
+  basic_ostream<charT, traits>&
+  operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <type_traits>
+#include <stdexcept>
+#include <cmath>
+#include <sstream>
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+    #include <cassert>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY complex;
+
+template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
+template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
+
+template<class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY complex
+{
+public:
+    typedef _Tp value_type;
+private:
+    value_type __re_;
+    value_type __im_;
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    complex(const value_type& __re = value_type(), const value_type& __im = value_type())
+        : __re_(__re), __im_(__im) {}
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    complex(const complex<_Xp>& __c)
+        : __re_(__c.real()), __im_(__c.imag()) {}
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type real() const {return __re_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 value_type imag() const {return __im_;}
+
+    _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+    _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+    _LIBCPP_INLINE_VISIBILITY complex& operator= (const value_type& __re)
+        {__re_ = __re; __im_ = value_type(); return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator+=(const value_type& __re) {__re_ += __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator-=(const value_type& __re) {__re_ -= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator*=(const value_type& __re) {__re_ *= __re; __im_ *= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator/=(const value_type& __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+        {
+            __re_ = __c.real();
+            __im_ = __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+        {
+            __re_ += __c.real();
+            __im_ += __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+        {
+            __re_ -= __c.real();
+            __im_ -= __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+        {
+            *this = *this * complex(__c.real(), __c.imag());
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+        {
+            *this = *this / complex(__c.real(), __c.imag());
+            return *this;
+        }
+};
+
+template<> class _LIBCPP_TYPE_VIS_ONLY complex<double>;
+template<> class _LIBCPP_TYPE_VIS_ONLY complex<long double>;
+
+template<>
+class _LIBCPP_TYPE_VIS_ONLY complex<float>
+{
+    float __re_;
+    float __im_;
+public:
+    typedef float value_type;
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f)
+        : __re_(__re), __im_(__im) {}
+    explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
+    explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float real() const {return __re_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR float imag() const {return __im_;}
+
+    _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+    _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+    _LIBCPP_INLINE_VISIBILITY complex& operator= (float __re)
+        {__re_ = __re; __im_ = value_type(); return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator+=(float __re) {__re_ += __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator-=(float __re) {__re_ -= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator*=(float __re) {__re_ *= __re; __im_ *= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator/=(float __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+        {
+            __re_ = __c.real();
+            __im_ = __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+        {
+            __re_ += __c.real();
+            __im_ += __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+        {
+            __re_ -= __c.real();
+            __im_ -= __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+        {
+            *this = *this * complex(__c.real(), __c.imag());
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+        {
+            *this = *this / complex(__c.real(), __c.imag());
+            return *this;
+        }
+};
+
+template<>
+class _LIBCPP_TYPE_VIS_ONLY complex<double>
+{
+    double __re_;
+    double __im_;
+public:
+    typedef double value_type;
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0)
+        : __re_(__re), __im_(__im) {}
+    _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+    explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double real() const {return __re_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR double imag() const {return __im_;}
+
+    _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+    _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+    _LIBCPP_INLINE_VISIBILITY complex& operator= (double __re)
+        {__re_ = __re; __im_ = value_type(); return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator+=(double __re) {__re_ += __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator-=(double __re) {__re_ -= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator*=(double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator/=(double __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+        {
+            __re_ = __c.real();
+            __im_ = __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+        {
+            __re_ += __c.real();
+            __im_ += __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+        {
+            __re_ -= __c.real();
+            __im_ -= __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+        {
+            *this = *this * complex(__c.real(), __c.imag());
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+        {
+            *this = *this / complex(__c.real(), __c.imag());
+            return *this;
+        }
+};
+
+template<>
+class _LIBCPP_TYPE_VIS_ONLY complex<long double>
+{
+    long double __re_;
+    long double __im_;
+public:
+    typedef long double value_type;
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
+        : __re_(__re), __im_(__im) {}
+    _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
+    _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double real() const {return __re_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR long double imag() const {return __im_;}
+
+    _LIBCPP_INLINE_VISIBILITY void real(value_type __re) {__re_ = __re;}
+    _LIBCPP_INLINE_VISIBILITY void imag(value_type __im) {__im_ = __im;}
+
+    _LIBCPP_INLINE_VISIBILITY complex& operator= (long double __re)
+        {__re_ = __re; __im_ = value_type(); return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator+=(long double __re) {__re_ += __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator-=(long double __re) {__re_ -= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator*=(long double __re) {__re_ *= __re; __im_ *= __re; return *this;}
+    _LIBCPP_INLINE_VISIBILITY complex& operator/=(long double __re) {__re_ /= __re; __im_ /= __re; return *this;}
+
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator= (const complex<_Xp>& __c)
+        {
+            __re_ = __c.real();
+            __im_ = __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator+=(const complex<_Xp>& __c)
+        {
+            __re_ += __c.real();
+            __im_ += __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator-=(const complex<_Xp>& __c)
+        {
+            __re_ -= __c.real();
+            __im_ -= __c.imag();
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator*=(const complex<_Xp>& __c)
+        {
+            *this = *this * complex(__c.real(), __c.imag());
+            return *this;
+        }
+    template<class _Xp> _LIBCPP_INLINE_VISIBILITY complex& operator/=(const complex<_Xp>& __c)
+        {
+            *this = *this / complex(__c.real(), __c.imag());
+            return *this;
+        }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+complex<float>::complex(const complex<double>& __c)
+    : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+complex<float>::complex(const complex<long double>& __c)
+    : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+complex<double>::complex(const complex<float>& __c)
+    : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+complex<double>::complex(const complex<long double>& __c)
+    : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+complex<long double>::complex(const complex<float>& __c)
+    : __re_(__c.real()), __im_(__c.imag()) {}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+complex<long double>::complex(const complex<double>& __c)
+    : __re_(__c.real()), __im_(__c.imag()) {}
+
+// 26.3.6 operators:
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+    complex<_Tp> __t(__x);
+    __t += __y;
+    return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const complex<_Tp>& __x, const _Tp& __y)
+{
+    complex<_Tp> __t(__x);
+    __t += __y;
+    return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const _Tp& __x, const complex<_Tp>& __y)
+{
+    complex<_Tp> __t(__y);
+    __t += __x;
+    return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+    complex<_Tp> __t(__x);
+    __t -= __y;
+    return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const complex<_Tp>& __x, const _Tp& __y)
+{
+    complex<_Tp> __t(__x);
+    __t -= __y;
+    return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const _Tp& __x, const complex<_Tp>& __y)
+{
+    complex<_Tp> __t(-__y);
+    __t += __x;
+    return __t;
+}
+
+template<class _Tp>
+complex<_Tp>
+operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
+{
+    _Tp __a = __z.real();
+    _Tp __b = __z.imag();
+    _Tp __c = __w.real();
+    _Tp __d = __w.imag();
+    _Tp __ac = __a * __c;
+    _Tp __bd = __b * __d;
+    _Tp __ad = __a * __d;
+    _Tp __bc = __b * __c;
+    _Tp __x = __ac - __bd;
+    _Tp __y = __ad + __bc;
+    if (isnan(__x) && isnan(__y))
+    {
+        bool __recalc = false;
+        if (isinf(__a) || isinf(__b))
+        {
+            __a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a);
+            __b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b);
+            if (isnan(__c))
+                __c = copysign(_Tp(0), __c);
+            if (isnan(__d))
+                __d = copysign(_Tp(0), __d);
+            __recalc = true;
+        }
+        if (isinf(__c) || isinf(__d))
+        {
+            __c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c);
+            __d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d);
+            if (isnan(__a))
+                __a = copysign(_Tp(0), __a);
+            if (isnan(__b))
+                __b = copysign(_Tp(0), __b);
+            __recalc = true;
+        }
+        if (!__recalc && (isinf(__ac) || isinf(__bd) ||
+                          isinf(__ad) || isinf(__bc)))
+        {
+            if (isnan(__a))
+                __a = copysign(_Tp(0), __a);
+            if (isnan(__b))
+                __b = copysign(_Tp(0), __b);
+            if (isnan(__c))
+                __c = copysign(_Tp(0), __c);
+            if (isnan(__d))
+                __d = copysign(_Tp(0), __d);
+            __recalc = true;
+        }
+        if (__recalc)
+        {
+            __x = _Tp(INFINITY) * (__a * __c - __b * __d);
+            __y = _Tp(INFINITY) * (__a * __d + __b * __c);
+        }
+    }
+    return complex<_Tp>(__x, __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator*(const complex<_Tp>& __x, const _Tp& __y)
+{
+    complex<_Tp> __t(__x);
+    __t *= __y;
+    return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator*(const _Tp& __x, const complex<_Tp>& __y)
+{
+    complex<_Tp> __t(__y);
+    __t *= __x;
+    return __t;
+}
+
+template<class _Tp>
+complex<_Tp>
+operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
+{
+    int __ilogbw = 0;
+    _Tp __a = __z.real();
+    _Tp __b = __z.imag();
+    _Tp __c = __w.real();
+    _Tp __d = __w.imag();
+    _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
+    if (isfinite(__logbw))
+    {
+        __ilogbw = static_cast<int>(__logbw);
+        __c = scalbn(__c, -__ilogbw);
+        __d = scalbn(__d, -__ilogbw);
+    }
+    _Tp __denom = __c * __c + __d * __d;
+    _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
+    _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
+    if (isnan(__x) && isnan(__y))
+    {
+        if ((__denom == _Tp(0)) && (!isnan(__a) || !isnan(__b)))
+        {
+            __x = copysign(_Tp(INFINITY), __c) * __a;
+            __y = copysign(_Tp(INFINITY), __c) * __b;
+        }
+        else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d))
+        {
+            __a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a);
+            __b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b);
+            __x = _Tp(INFINITY) * (__a * __c + __b * __d);
+            __y = _Tp(INFINITY) * (__b * __c - __a * __d);
+        }
+        else if (isinf(__logbw) && __logbw > _Tp(0) && isfinite(__a) && isfinite(__b))
+        {
+            __c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c);
+            __d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d);
+            __x = _Tp(0) * (__a * __c + __b * __d);
+            __y = _Tp(0) * (__b * __c - __a * __d);
+        }
+    }
+    return complex<_Tp>(__x, __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator/(const complex<_Tp>& __x, const _Tp& __y)
+{
+    return complex<_Tp>(__x.real() / __y, __x.imag() / __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator/(const _Tp& __x, const complex<_Tp>& __y)
+{
+    complex<_Tp> __t(__x);
+    __t /= __y;
+    return __t;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator+(const complex<_Tp>& __x)
+{
+    return __x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+operator-(const complex<_Tp>& __x)
+{
+    return complex<_Tp>(-__x.real(), -__x.imag());
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+    return __x.real() == __y.real() && __x.imag() == __y.imag();
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const complex<_Tp>& __x, const _Tp& __y)
+{
+    return __x.real() == __y && __x.imag() == 0;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const _Tp& __x, const complex<_Tp>& __y)
+{
+    return __x == __y.real() && 0 == __y.imag();
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+    return !(__x == __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const complex<_Tp>& __x, const _Tp& __y)
+{
+    return !(__x == __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const _Tp& __x, const complex<_Tp>& __y)
+{
+    return !(__x == __y);
+}
+
+// 26.3.7 values:
+
+// real
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+real(const complex<_Tp>& __c)
+{
+    return __c.real();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+long double
+real(long double __re)
+{
+    return __re;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+double
+real(double __re)
+{
+    return __re;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename enable_if
+<
+    is_integral<_Tp>::value,
+    double
+>::type
+real(_Tp  __re)
+{
+    return __re;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+float
+real(float  __re)
+{
+    return __re;
+}
+
+// imag
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp
+imag(const complex<_Tp>& __c)
+{
+    return __c.imag();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+long double
+imag(long double __re)
+{
+    return 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+double
+imag(double __re)
+{
+    return 0;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename enable_if
+<
+    is_integral<_Tp>::value,
+    double
+>::type
+imag(_Tp  __re)
+{
+    return 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+float
+imag(float  __re)
+{
+    return 0;
+}
+
+// abs
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+abs(const complex<_Tp>& __c)
+{
+    return hypot(__c.real(), __c.imag());
+}
+
+// arg
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+arg(const complex<_Tp>& __c)
+{
+    return atan2(__c.imag(), __c.real());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long double
+arg(long double __re)
+{
+    return atan2l(0.L, __re);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+double
+arg(double __re)
+{
+    return atan2(0., __re);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value,
+    double
+>::type
+arg(_Tp __re)
+{
+    return atan2(0., __re);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+float
+arg(float __re)
+{
+    return atan2f(0.F, __re);
+}
+
+// norm
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+norm(const complex<_Tp>& __c)
+{
+    if (isinf(__c.real()))
+        return abs(__c.real());
+    if (isinf(__c.imag()))
+        return abs(__c.imag());
+    return __c.real() * __c.real() + __c.imag() * __c.imag();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+long double
+norm(long double __re)
+{
+    return __re * __re;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+double
+norm(double __re)
+{
+    return __re * __re;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value,
+    double
+>::type
+norm(_Tp __re)
+{
+    return (double)__re * __re;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+float
+norm(float __re)
+{
+    return __re * __re;
+}
+
+// conj
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+conj(const complex<_Tp>& __c)
+{
+    return complex<_Tp>(__c.real(), -__c.imag());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+complex<long double>
+conj(long double __re)
+{
+    return complex<long double>(__re);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+complex<double>
+conj(double __re)
+{
+    return complex<double>(__re);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value,
+    complex<double>
+>::type
+conj(_Tp __re)
+{
+    return complex<double>(__re);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+complex<float>
+conj(float __re)
+{
+    return complex<float>(__re);
+}
+
+// proj
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+proj(const complex<_Tp>& __c)
+{
+    std::complex<_Tp> __r = __c;
+    if (isinf(__c.real()) || isinf(__c.imag()))
+        __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
+    return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+complex<long double>
+proj(long double __re)
+{
+    if (isinf(__re))
+        __re = abs(__re);
+    return complex<long double>(__re);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+complex<double>
+proj(double __re)
+{
+    if (isinf(__re))
+        __re = abs(__re);
+    return complex<double>(__re);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_integral<_Tp>::value,
+    complex<double>
+>::type
+proj(_Tp __re)
+{
+    return complex<double>(__re);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+complex<float>
+proj(float __re)
+{
+    if (isinf(__re))
+        __re = abs(__re);
+    return complex<float>(__re);
+}
+
+// polar
+
+template<class _Tp>
+complex<_Tp>
+polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
+{
+    if (isnan(__rho) || signbit(__rho))
+        return complex<_Tp>(_Tp(NAN), _Tp(NAN));
+    if (isnan(__theta))
+    {
+        if (isinf(__rho))
+            return complex<_Tp>(__rho, __theta);
+        return complex<_Tp>(__theta, __theta);
+    }
+    if (isinf(__theta))
+    {
+        if (isinf(__rho))
+            return complex<_Tp>(__rho, _Tp(NAN));
+        return complex<_Tp>(_Tp(NAN), _Tp(NAN));
+    }
+    _Tp __x = __rho * cos(__theta);
+    if (isnan(__x))
+        __x = 0;
+    _Tp __y = __rho * sin(__theta);
+    if (isnan(__y))
+        __y = 0;
+    return complex<_Tp>(__x, __y);
+}
+
+// log
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+log(const complex<_Tp>& __x)
+{
+    return complex<_Tp>(log(abs(__x)), arg(__x));
+}
+
+// log10
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+log10(const complex<_Tp>& __x)
+{
+    return log(__x) / log(_Tp(10));
+}
+
+// sqrt
+
+template<class _Tp>
+complex<_Tp>
+sqrt(const complex<_Tp>& __x)
+{
+    if (isinf(__x.imag()))
+        return complex<_Tp>(_Tp(INFINITY), __x.imag());
+    if (isinf(__x.real()))
+    {
+        if (__x.real() > _Tp(0))
+            return complex<_Tp>(__x.real(), isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
+        return complex<_Tp>(isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
+    }
+    return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
+}
+
+// exp
+
+template<class _Tp>
+complex<_Tp>
+exp(const complex<_Tp>& __x)
+{
+    _Tp __i = __x.imag();
+    if (isinf(__x.real()))
+    {
+        if (__x.real() < _Tp(0))
+        {
+            if (!isfinite(__i))
+                __i = _Tp(1);
+        }
+        else if (__i == 0 || !isfinite(__i))
+        {
+            if (isinf(__i))
+                __i = _Tp(NAN);
+            return complex<_Tp>(__x.real(), __i);
+        }
+    }
+    else if (isnan(__x.real()) && __x.imag() == 0)
+        return __x;
+    _Tp __e = exp(__x.real());
+    return complex<_Tp>(__e * cos(__i), __e * sin(__i));
+}
+
+// pow
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+{
+    return exp(__y * log(__x));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<typename __promote<_Tp, _Up>::type>
+pow(const complex<_Tp>& __x, const complex<_Up>& __y)
+{
+    typedef complex<typename __promote<_Tp, _Up>::type> result_type;
+    return _VSTD::pow(result_type(__x), result_type(__y));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_arithmetic<_Up>::value,
+    complex<typename __promote<_Tp, _Up>::type>
+>::type
+pow(const complex<_Tp>& __x, const _Up& __y)
+{
+    typedef complex<typename __promote<_Tp, _Up>::type> result_type;
+    return _VSTD::pow(result_type(__x), result_type(__y));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_arithmetic<_Tp>::value,
+    complex<typename __promote<_Tp, _Up>::type>
+>::type
+pow(const _Tp& __x, const complex<_Up>& __y)
+{
+    typedef complex<typename __promote<_Tp, _Up>::type> result_type;
+    return _VSTD::pow(result_type(__x), result_type(__y));
+}
+
+// asinh
+
+template<class _Tp>
+complex<_Tp>
+asinh(const complex<_Tp>& __x)
+{
+    const _Tp __pi(atan2(+0., -0.));
+    if (isinf(__x.real()))
+    {
+        if (isnan(__x.imag()))
+            return __x;
+        if (isinf(__x.imag()))
+            return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
+        return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
+    }
+    if (isnan(__x.real()))
+    {
+        if (isinf(__x.imag()))
+            return complex<_Tp>(__x.imag(), __x.real());
+        if (__x.imag() == 0)
+            return __x;
+        return complex<_Tp>(__x.real(), __x.real());
+    }
+    if (isinf(__x.imag()))
+        return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+    complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
+    return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
+}
+
+// acosh
+
+template<class _Tp>
+complex<_Tp>
+acosh(const complex<_Tp>& __x)
+{
+    const _Tp __pi(atan2(+0., -0.));
+    if (isinf(__x.real()))
+    {
+        if (isnan(__x.imag()))
+            return complex<_Tp>(abs(__x.real()), __x.imag());
+        if (isinf(__x.imag()))
+        {
+            if (__x.real() > 0)
+                return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
+            else
+                return complex<_Tp>(-__x.real(), copysign(__pi * _Tp(0.75), __x.imag()));
+        }
+        if (__x.real() < 0)
+            return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
+        return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
+    }
+    if (isnan(__x.real()))
+    {
+        if (isinf(__x.imag()))
+            return complex<_Tp>(abs(__x.imag()), __x.real());
+        return complex<_Tp>(__x.real(), __x.real());
+    }
+    if (isinf(__x.imag()))
+        return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
+    complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
+    return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
+}
+
+// atanh
+
+template<class _Tp>
+complex<_Tp>
+atanh(const complex<_Tp>& __x)
+{
+    const _Tp __pi(atan2(+0., -0.));
+    if (isinf(__x.imag()))
+    {
+        return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+    }
+    if (isnan(__x.imag()))
+    {
+        if (isinf(__x.real()) || __x.real() == 0)
+            return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
+        return complex<_Tp>(__x.imag(), __x.imag());
+    }
+    if (isnan(__x.real()))
+    {
+        return complex<_Tp>(__x.real(), __x.real());
+    }
+    if (isinf(__x.real()))
+    {
+        return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
+    }
+    if (abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0))
+    {
+        return complex<_Tp>(copysign(_Tp(INFINITY), __x.real()), copysign(_Tp(0), __x.imag()));
+    }
+    complex<_Tp> __z = log((_Tp(1) + __x) / (_Tp(1) - __x)) / _Tp(2);
+    return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
+}
+
+// sinh
+
+template<class _Tp>
+complex<_Tp>
+sinh(const complex<_Tp>& __x)
+{
+    if (isinf(__x.real()) && !isfinite(__x.imag()))
+        return complex<_Tp>(__x.real(), _Tp(NAN));
+    if (__x.real() == 0 && !isfinite(__x.imag()))
+        return complex<_Tp>(__x.real(), _Tp(NAN));
+    if (__x.imag() == 0 && !isfinite(__x.real()))
+        return __x;
+    return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
+}
+
+// cosh
+
+template<class _Tp>
+complex<_Tp>
+cosh(const complex<_Tp>& __x)
+{
+    if (isinf(__x.real()) && !isfinite(__x.imag()))
+        return complex<_Tp>(abs(__x.real()), _Tp(NAN));
+    if (__x.real() == 0 && !isfinite(__x.imag()))
+        return complex<_Tp>(_Tp(NAN), __x.real());
+    if (__x.real() == 0 && __x.imag() == 0)
+        return complex<_Tp>(_Tp(1), __x.imag());
+    if (__x.imag() == 0 && !isfinite(__x.real()))
+        return complex<_Tp>(abs(__x.real()), __x.imag());
+    return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
+}
+
+// tanh
+
+template<class _Tp>
+complex<_Tp>
+tanh(const complex<_Tp>& __x)
+{
+    if (isinf(__x.real()))
+    {
+        if (!isfinite(__x.imag()))
+            return complex<_Tp>(_Tp(1), _Tp(0));
+        return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
+    }
+    if (isnan(__x.real()) && __x.imag() == 0)
+        return __x;
+    _Tp __2r(_Tp(2) * __x.real());
+    _Tp __2i(_Tp(2) * __x.imag());
+    _Tp __d(cosh(__2r) + cos(__2i));
+    _Tp __2rsh(sinh(__2r));
+    if (isinf(__2rsh) && isinf(__d))
+        return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
+                            __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
+    return  complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
+}
+
+// asin
+
+template<class _Tp>
+complex<_Tp>
+asin(const complex<_Tp>& __x)
+{
+    complex<_Tp> __z = asinh(complex<_Tp>(-__x.imag(), __x.real()));
+    return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+// acos
+
+template<class _Tp>
+complex<_Tp>
+acos(const complex<_Tp>& __x)
+{
+    const _Tp __pi(atan2(+0., -0.));
+    if (isinf(__x.real()))
+    {
+        if (isnan(__x.imag()))
+            return complex<_Tp>(__x.imag(), __x.real());
+        if (isinf(__x.imag()))
+        {
+            if (__x.real() < _Tp(0))
+                return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
+            return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag());
+        }
+        if (__x.real() < _Tp(0))
+            return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
+        return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
+    }
+    if (isnan(__x.real()))
+    {
+        if (isinf(__x.imag()))
+            return complex<_Tp>(__x.real(), -__x.imag());
+        return complex<_Tp>(__x.real(), __x.real());
+    }
+    if (isinf(__x.imag()))
+        return complex<_Tp>(__pi/_Tp(2), -__x.imag());
+    if (__x.real() == 0)
+        return complex<_Tp>(__pi/_Tp(2), -__x.imag());
+    complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
+    if (signbit(__x.imag()))
+        return complex<_Tp>(abs(__z.imag()), abs(__z.real()));
+    return complex<_Tp>(abs(__z.imag()), -abs(__z.real()));
+}
+
+// atan
+
+template<class _Tp>
+complex<_Tp>
+atan(const complex<_Tp>& __x)
+{
+    complex<_Tp> __z = atanh(complex<_Tp>(-__x.imag(), __x.real()));
+    return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+// sin
+
+template<class _Tp>
+complex<_Tp>
+sin(const complex<_Tp>& __x)
+{
+    complex<_Tp> __z = sinh(complex<_Tp>(-__x.imag(), __x.real()));
+    return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+// cos
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+complex<_Tp>
+cos(const complex<_Tp>& __x)
+{
+    return cosh(complex<_Tp>(-__x.imag(), __x.real()));
+}
+
+// tan
+
+template<class _Tp>
+complex<_Tp>
+tan(const complex<_Tp>& __x)
+{
+    complex<_Tp> __z = tanh(complex<_Tp>(-__x.imag(), __x.real()));
+    return complex<_Tp>(__z.imag(), -__z.real());
+}
+
+template<class _Tp, class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
+{
+    if (__is.good())
+    {
+        ws(__is);
+        if (__is.peek() == _CharT('('))
+        {
+            __is.get();
+            _Tp __r;
+            __is >> __r;
+            if (!__is.fail())
+            {
+                ws(__is);
+                _CharT __c = __is.peek();
+                if (__c == _CharT(','))
+                {
+                    __is.get();
+                    _Tp __i;
+                    __is >> __i;
+                    if (!__is.fail())
+                    {
+                        ws(__is);
+                        __c = __is.peek();
+                        if (__c == _CharT(')'))
+                        {
+                            __is.get();
+                            __x = complex<_Tp>(__r, __i);
+                        }
+                        else
+                            __is.setstate(ios_base::failbit);
+                    }
+                    else
+                        __is.setstate(ios_base::failbit);
+                }
+                else if (__c == _CharT(')'))
+                {
+                    __is.get();
+                    __x = complex<_Tp>(__r, _Tp(0));
+                }
+                else
+                    __is.setstate(ios_base::failbit);
+            }
+            else
+                __is.setstate(ios_base::failbit);
+        }
+        else
+        {
+            _Tp __r;
+            __is >> __r;
+            if (!__is.fail())
+                __x = complex<_Tp>(__r, _Tp(0));
+            else
+                __is.setstate(ios_base::failbit);
+        }
+    }
+    else
+        __is.setstate(ios_base::failbit);
+    return __is;
+}
+
+template<class _Tp, class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
+{
+    basic_ostringstream<_CharT, _Traits> __s;
+    __s.flags(__os.flags());
+    __s.imbue(__os.getloc());
+    __s.precision(__os.precision());
+    __s << '(' << __x.real() << ',' << __x.imag() << ')';
+    return __os << __s.str();
+}
+
+#if _LIBCPP_STD_VER > 11 
+// Literal suffix for complex number literals [complex.literals]
+inline namespace literals
+{ 
+  inline namespace complex_literals
+  {
+    constexpr complex<long double> operator""il(long double __im)
+    {
+        return { 0.0l, __im };
+    }
+
+    constexpr complex<long double> operator""il(unsigned long long __im)
+    {
+        return { 0.0l, static_cast<long double>(__im) };
+    }
+
+
+    constexpr complex<double> operator""i(long double __im)
+    {
+        return { 0.0, static_cast<double>(__im) };
+    }
+
+    constexpr complex<double> operator""i(unsigned long long __im)
+    {
+        return { 0.0, static_cast<double>(__im) };
+    }
+
+
+    constexpr complex<float> operator""if(long double __im)
+    {
+        return { 0.0f, static_cast<float>(__im) };
+    }
+
+    constexpr complex<float> operator""if(unsigned long long __im)
+    {
+        return { 0.0f, static_cast<float>(__im) };
+    }
+  }
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_COMPLEX
diff --git a/final/include/complex.h b/final/include/complex.h
new file mode 100644
index 0000000..7003d31
--- /dev/null
+++ b/final/include/complex.h
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//===--------------------------- complex.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_COMPLEX_H
+#define _LIBCPP_COMPLEX_H
+
+/*
+    complex.h synopsis
+
+#include <ccomplex>
+
+*/
+
+#ifdef __cplusplus
+
+#include <ccomplex>
+
+#else  // __cplusplus
+
+#include_next <complex.h>
+
+#endif  // __cplusplus
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#endif  // _LIBCPP_COMPLEX_H
diff --git a/final/include/condition_variable b/final/include/condition_variable
new file mode 100644
index 0000000..dc67266
--- /dev/null
+++ b/final/include/condition_variable
@@ -0,0 +1,256 @@
+// -*- C++ -*-
+//===---------------------- condition_variable ----------------------------===//
+//
+//                     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_CONDITION_VARIABLE
+#define _LIBCPP_CONDITION_VARIABLE
+
+/*
+    condition_variable synopsis
+
+namespace std
+{
+
+enum class cv_status { no_timeout, timeout };
+
+class condition_variable
+{
+public:
+    condition_variable();
+    ~condition_variable();
+
+    condition_variable(const condition_variable&) = delete;
+    condition_variable& operator=(const condition_variable&) = delete;
+
+    void notify_one() noexcept;
+    void notify_all() noexcept;
+
+    void wait(unique_lock<mutex>& lock);
+    template <class Predicate>
+        void wait(unique_lock<mutex>& lock, Predicate pred);
+
+    template <class Clock, class Duration>
+        cv_status
+        wait_until(unique_lock<mutex>& lock,
+                   const chrono::time_point<Clock, Duration>& abs_time);
+
+    template <class Clock, class Duration, class Predicate>
+        bool
+        wait_until(unique_lock<mutex>& lock,
+                   const chrono::time_point<Clock, Duration>& abs_time,
+                   Predicate pred);
+
+    template <class Rep, class Period>
+        cv_status
+        wait_for(unique_lock<mutex>& lock,
+                 const chrono::duration<Rep, Period>& rel_time);
+
+    template <class Rep, class Period, class Predicate>
+        bool
+        wait_for(unique_lock<mutex>& lock,
+                 const chrono::duration<Rep, Period>& rel_time,
+                 Predicate pred);
+
+    typedef pthread_cond_t* native_handle_type;
+    native_handle_type native_handle();
+};
+
+void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+
+class condition_variable_any
+{
+public:
+    condition_variable_any();
+    ~condition_variable_any();
+
+    condition_variable_any(const condition_variable_any&) = delete;
+    condition_variable_any& operator=(const condition_variable_any&) = delete;
+
+    void notify_one() noexcept;
+    void notify_all() noexcept;
+
+    template <class Lock>
+        void wait(Lock& lock);
+    template <class Lock, class Predicate>
+        void wait(Lock& lock, Predicate pred);
+
+    template <class Lock, class Clock, class Duration>
+        cv_status
+        wait_until(Lock& lock,
+                   const chrono::time_point<Clock, Duration>& abs_time);
+
+    template <class Lock, class Clock, class Duration, class Predicate>
+        bool
+        wait_until(Lock& lock,
+                   const chrono::time_point<Clock, Duration>& abs_time,
+                   Predicate pred);
+
+    template <class Lock, class Rep, class Period>
+        cv_status
+        wait_for(Lock& lock,
+                 const chrono::duration<Rep, Period>& rel_time);
+
+    template <class Lock, class Rep, class Period, class Predicate>
+        bool
+        wait_for(Lock& lock,
+                 const chrono::duration<Rep, Period>& rel_time,
+                 Predicate pred);
+};
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__mutex_base>
+#include <memory>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS condition_variable_any
+{
+    condition_variable __cv_;
+    shared_ptr<mutex>  __mut_;
+public:
+    condition_variable_any();
+
+    void notify_one() _NOEXCEPT;
+    void notify_all() _NOEXCEPT;
+
+    template <class _Lock>
+        void wait(_Lock& __lock);
+    template <class _Lock, class _Predicate>
+        void wait(_Lock& __lock, _Predicate __pred);
+
+    template <class _Lock, class _Clock, class _Duration>
+        cv_status
+        wait_until(_Lock& __lock,
+                   const chrono::time_point<_Clock, _Duration>& __t);
+
+    template <class _Lock, class _Clock, class _Duration, class _Predicate>
+        bool
+        wait_until(_Lock& __lock,
+                   const chrono::time_point<_Clock, _Duration>& __t,
+                   _Predicate __pred);
+
+    template <class _Lock, class _Rep, class _Period>
+        cv_status
+        wait_for(_Lock& __lock,
+                 const chrono::duration<_Rep, _Period>& __d);
+
+    template <class _Lock, class _Rep, class _Period, class _Predicate>
+        bool
+        wait_for(_Lock& __lock,
+                 const chrono::duration<_Rep, _Period>& __d,
+                 _Predicate __pred);
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+condition_variable_any::condition_variable_any()
+    : __mut_(make_shared<mutex>()) {}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+condition_variable_any::notify_one() _NOEXCEPT
+{
+    {lock_guard<mutex> __lx(*__mut_);}
+    __cv_.notify_one();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+condition_variable_any::notify_all() _NOEXCEPT
+{
+    {lock_guard<mutex> __lx(*__mut_);}
+    __cv_.notify_all();
+}
+
+struct __lock_external
+{
+    template <class _Lock>
+    void operator()(_Lock* __m) {__m->lock();}
+};
+
+template <class _Lock>
+void
+condition_variable_any::wait(_Lock& __lock)
+{
+    shared_ptr<mutex> __mut = __mut_;
+    unique_lock<mutex> __lk(*__mut);
+    __lock.unlock();
+    unique_ptr<_Lock, __lock_external> __lxx(&__lock);
+    lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
+    __cv_.wait(__lk);
+}  // __mut_.unlock(), __lock.lock()
+
+template <class _Lock, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+condition_variable_any::wait(_Lock& __lock, _Predicate __pred)
+{
+    while (!__pred())
+        wait(__lock);
+}
+
+template <class _Lock, class _Clock, class _Duration>
+cv_status
+condition_variable_any::wait_until(_Lock& __lock,
+                                   const chrono::time_point<_Clock, _Duration>& __t)
+{
+    shared_ptr<mutex> __mut = __mut_;
+    unique_lock<mutex> __lk(*__mut);
+    __lock.unlock();
+    unique_ptr<_Lock, __lock_external> __lxx(&__lock);
+    lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock);
+    return __cv_.wait_until(__lk, __t);
+}  // __mut_.unlock(), __lock.lock()
+
+template <class _Lock, class _Clock, class _Duration, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+condition_variable_any::wait_until(_Lock& __lock,
+                                   const chrono::time_point<_Clock, _Duration>& __t,
+                                   _Predicate __pred)
+{
+    while (!__pred())
+        if (wait_until(__lock, __t) == cv_status::timeout)
+            return __pred();
+    return true;
+}
+
+template <class _Lock, class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY
+cv_status
+condition_variable_any::wait_for(_Lock& __lock,
+                                 const chrono::duration<_Rep, _Period>& __d)
+{
+    return wait_until(__lock, chrono::steady_clock::now() + __d);
+}
+
+template <class _Lock, class _Rep, class _Period, class _Predicate>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+condition_variable_any::wait_for(_Lock& __lock,
+                                 const chrono::duration<_Rep, _Period>& __d,
+                                 _Predicate __pred)
+{
+    return wait_until(__lock, chrono::steady_clock::now() + __d,
+                      _VSTD::move(__pred));
+}
+
+_LIBCPP_FUNC_VIS
+void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CONDITION_VARIABLE
diff --git a/final/include/csetjmp b/final/include/csetjmp
new file mode 100644
index 0000000..d0b2c07
--- /dev/null
+++ b/final/include/csetjmp
@@ -0,0 +1,52 @@
+// -*- C++ -*-
+//===--------------------------- csetjmp ----------------------------------===//
+//
+//                     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_CSETJMP
+#define _LIBCPP_CSETJMP
+
+/*
+    csetjmp synopsis
+
+Macros:
+
+    setjmp
+
+namespace std
+{
+
+Types:
+
+    jmp_buf
+
+void longjmp(jmp_buf env, int val);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <setjmp.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#ifndef setjmp
+#define setjmp(env) setjmp(env)
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::jmp_buf;
+using ::longjmp;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CSETJMP
diff --git a/final/include/csignal b/final/include/csignal
new file mode 100644
index 0000000..9728266
--- /dev/null
+++ b/final/include/csignal
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+//===--------------------------- csignal ----------------------------------===//
+//
+//                     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_CSIGNAL
+#define _LIBCPP_CSIGNAL
+
+/*
+    csignal synopsis
+
+Macros:
+
+    SIG_DFL
+    SIG_ERR
+    SIG_IGN
+    SIGABRT
+    SIGFPE
+    SIGILL
+    SIGINT
+    SIGSEGV
+    SIGTERM
+
+namespace std
+{
+
+Types:
+
+    sig_atomic_t
+
+void (*signal(int sig, void (*func)(int)))(int);
+int raise(int sig);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <signal.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::sig_atomic_t;
+using ::signal;
+using ::raise;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CSIGNAL
diff --git a/final/include/cstdarg b/final/include/cstdarg
new file mode 100644
index 0000000..c8b6999
--- /dev/null
+++ b/final/include/cstdarg
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//===--------------------------- cstdarg ----------------------------------===//
+//
+//                     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_CSTDARG
+#define _LIBCPP_CSTDARG
+
+/*
+    cstdarg synopsis
+
+Macros:
+
+    type va_arg(va_list ap, type);
+    void va_copy(va_list dest, va_list src);  // C99
+    void va_end(va_list ap);
+    void va_start(va_list ap, parmN);
+
+namespace std
+{
+
+Types:
+
+    va_list
+
+}  // std
+
+*/
+
+#include <__config>
+#include <stdarg.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::va_list;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CSTDARG
diff --git a/final/include/cstdbool b/final/include/cstdbool
new file mode 100644
index 0000000..2c764a6
--- /dev/null
+++ b/final/include/cstdbool
@@ -0,0 +1,32 @@
+// -*- C++ -*-
+//===--------------------------- cstdbool ---------------------------------===//
+//
+//                     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_CSTDBOOL
+#define _LIBCPP_CSTDBOOL
+
+/*
+    cstdbool synopsis
+
+Macros:
+
+    __bool_true_false_are_defined
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#undef __bool_true_false_are_defined
+#define __bool_true_false_are_defined 1
+
+#endif  // _LIBCPP_CSTDBOOL
diff --git a/final/include/cstddef b/final/include/cstddef
new file mode 100644
index 0000000..c3ca64a
--- /dev/null
+++ b/final/include/cstddef
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+//===--------------------------- cstddef ----------------------------------===//
+//
+//                     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_CSTDDEF
+#define _LIBCPP_CSTDDEF
+
+/*
+    cstddef synopsis
+
+Macros:
+
+    offsetof(type,member-designator)
+    NULL
+
+namespace std
+{
+
+Types:
+
+    ptrdiff_t
+    size_t
+    max_align_t
+    nullptr_t
+
+}  // std
+
+*/
+
+#include <__config>
+
+#include <stddef.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::ptrdiff_t;
+using ::size_t;
+
+#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T)
+// Re-use the compiler's <stddef.h> max_align_t where possible.
+using ::max_align_t;
+#else
+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/final/include/cstdint b/final/include/cstdint
new file mode 100644
index 0000000..7a187d3
--- /dev/null
+++ b/final/include/cstdint
@@ -0,0 +1,191 @@
+// -*- C++ -*-
+//===--------------------------- cstdint ----------------------------------===//
+//
+//                     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_CSTDINT
+#define _LIBCPP_CSTDINT
+
+/*
+    cstdint synopsis
+
+Macros:
+
+    INT8_MIN
+    INT16_MIN
+    INT32_MIN
+    INT64_MIN
+
+    INT8_MAX
+    INT16_MAX
+    INT32_MAX
+    INT64_MAX
+
+    UINT8_MAX
+    UINT16_MAX
+    UINT32_MAX
+    UINT64_MAX
+
+    INT_LEAST8_MIN
+    INT_LEAST16_MIN
+    INT_LEAST32_MIN
+    INT_LEAST64_MIN
+
+    INT_LEAST8_MAX
+    INT_LEAST16_MAX
+    INT_LEAST32_MAX
+    INT_LEAST64_MAX
+
+    UINT_LEAST8_MAX
+    UINT_LEAST16_MAX
+    UINT_LEAST32_MAX
+    UINT_LEAST64_MAX
+
+    INT_FAST8_MIN
+    INT_FAST16_MIN
+    INT_FAST32_MIN
+    INT_FAST64_MIN
+
+    INT_FAST8_MAX
+    INT_FAST16_MAX
+    INT_FAST32_MAX
+    INT_FAST64_MAX
+
+    UINT_FAST8_MAX
+    UINT_FAST16_MAX
+    UINT_FAST32_MAX
+    UINT_FAST64_MAX
+
+    INTPTR_MIN
+    INTPTR_MAX
+    UINTPTR_MAX
+
+    INTMAX_MIN
+    INTMAX_MAX
+
+    UINTMAX_MAX
+
+    PTRDIFF_MIN
+    PTRDIFF_MAX
+
+    SIG_ATOMIC_MIN
+    SIG_ATOMIC_MAX
+
+    SIZE_MAX
+
+    WCHAR_MIN
+    WCHAR_MAX
+
+    WINT_MIN
+    WINT_MAX
+
+    INT8_C(value)
+    INT16_C(value)
+    INT32_C(value)
+    INT64_C(value)
+
+    UINT8_C(value)
+    UINT16_C(value)
+    UINT32_C(value)
+    UINT64_C(value)
+
+    INTMAX_C(value)
+    UINTMAX_C(value)
+
+namespace std
+{
+
+Types:
+
+    int8_t
+    int16_t
+    int32_t
+    int64_t
+
+    uint8_t
+    uint16_t
+    uint32_t
+    uint64_t
+
+    int_least8_t
+    int_least16_t
+    int_least32_t
+    int_least64_t
+
+    uint_least8_t
+    uint_least16_t
+    uint_least32_t
+    uint_least64_t
+
+    int_fast8_t
+    int_fast16_t
+    int_fast32_t
+    int_fast64_t
+
+    uint_fast8_t
+    uint_fast16_t
+    uint_fast32_t
+    uint_fast64_t
+
+    intptr_t
+    uintptr_t
+
+    intmax_t
+    uintmax_t
+
+}  // std
+*/
+
+#include <__config>
+#include <stdint.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using::int8_t;
+using::int16_t;
+using::int32_t;
+using::int64_t;
+
+using::uint8_t;
+using::uint16_t;
+using::uint32_t;
+using::uint64_t;
+
+using::int_least8_t;
+using::int_least16_t;
+using::int_least32_t;
+using::int_least64_t;
+
+using::uint_least8_t;
+using::uint_least16_t;
+using::uint_least32_t;
+using::uint_least64_t;
+
+using::int_fast8_t;
+using::int_fast16_t;
+using::int_fast32_t;
+using::int_fast64_t;
+
+using::uint_fast8_t;
+using::uint_fast16_t;
+using::uint_fast32_t;
+using::uint_fast64_t;
+
+using::intptr_t;
+using::uintptr_t;
+
+using::intmax_t;
+using::uintmax_t;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CSTDINT
diff --git a/final/include/cstdio b/final/include/cstdio
new file mode 100644
index 0000000..ce3af4d
--- /dev/null
+++ b/final/include/cstdio
@@ -0,0 +1,182 @@
+// -*- C++ -*-
+//===---------------------------- cstdio ----------------------------------===//
+//
+//                     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_CSTDIO
+#define _LIBCPP_CSTDIO
+
+/*
+    cstdio 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
+
+namespace std
+{
+
+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);
+
+}  // std
+*/
+
+#include <__config>
+#include <stdio.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#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;
+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;
+using ::fgetpos;
+using ::fseek;
+using ::fsetpos;
+using ::ftell;
+using ::rewind;
+using ::clearerr;
+using ::feof;
+using ::ferror;
+using ::perror;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CSTDIO
diff --git a/final/include/cstdlib b/final/include/cstdlib
new file mode 100644
index 0000000..152b891
--- /dev/null
+++ b/final/include/cstdlib
@@ -0,0 +1,172 @@
+// -*- C++ -*-
+//===--------------------------- cstdlib ----------------------------------===//
+//
+//                     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_CSTDLIB
+#define _LIBCPP_CSTDLIB
+
+/*
+    cstdlib synopsis
+
+Macros:
+
+    EXIT_FAILURE
+    EXIT_SUCCESS
+    MB_CUR_MAX
+    NULL
+    RAND_MAX
+
+namespace std
+{
+
+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
+
+}  // std
+
+*/
+
+#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
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::size_t;
+using ::div_t;
+using ::ldiv_t;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::lldiv_t;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::atof;
+using ::atoi;
+using ::atol;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::atoll;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::strtod;
+using ::strtof;
+using ::strtold;
+using ::strtol;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::strtoll;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::strtoul;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::strtoull;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::rand;
+using ::srand;
+using ::calloc;
+using ::free;
+using ::malloc;
+using ::realloc;
+using ::abort;
+using ::atexit;
+using ::exit;
+using ::_Exit;
+using ::getenv;
+using ::system;
+using ::bsearch;
+using ::qsort;
+using ::abs;
+using ::labs;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::llabs;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::div;
+using ::ldiv;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::lldiv;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::mblen;
+using ::mbtowc;
+using ::wctomb;
+using ::mbstowcs;
+using ::wcstombs;
+#ifdef _LIBCPP_HAS_QUICK_EXIT
+using ::at_quick_exit;
+using ::quick_exit;
+#endif
+#ifdef _LIBCPP_HAS_C11_FEATURES
+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/final/include/cstring b/final/include/cstring
new file mode 100644
index 0000000..21c9155
--- /dev/null
+++ b/final/include/cstring
@@ -0,0 +1,112 @@
+// -*- C++ -*-
+//===--------------------------- cstring ----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_CSTRING
+#define _LIBCPP_CSTRING
+
+/*
+    cstring synopsis
+
+Macros:
+
+    NULL
+
+namespace std
+{
+
+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);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <string.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::size_t;
+using ::memcpy;
+using ::memmove;
+using ::strcpy;
+using ::strncpy;
+using ::strcat;
+using ::strncat;
+using ::memcmp;
+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
+
+using ::strtok;
+using ::memset;
+using ::strerror;
+using ::strlen;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CSTRING
diff --git a/final/include/ctgmath b/final/include/ctgmath
new file mode 100644
index 0000000..535eb7d
--- /dev/null
+++ b/final/include/ctgmath
@@ -0,0 +1,29 @@
+// -*- C++ -*-
+//===-------------------------- ctgmath -----------------------------------===//
+//
+//                     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_CTGMATH
+#define _LIBCPP_CTGMATH
+
+/*
+    ctgmath synopsis
+
+#include <ccomplex>
+#include <cmath>
+
+*/
+
+#include <ccomplex>
+#include <cmath>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#endif  // _LIBCPP_CTGMATH
diff --git a/final/include/ctime b/final/include/ctime
new file mode 100644
index 0000000..fc4eb26
--- /dev/null
+++ b/final/include/ctime
@@ -0,0 +1,72 @@
+// -*- C++ -*-
+//===---------------------------- ctime -----------------------------------===//
+//
+//                     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_CTIME
+#define _LIBCPP_CTIME
+
+/*
+    ctime synopsis
+
+Macros:
+
+    NULL
+    CLOCKS_PER_SEC
+
+namespace std
+{
+
+Types:
+
+    clock_t
+    size_t
+    time_t
+    tm
+
+clock_t clock();
+double difftime(time_t time1, time_t time0);
+time_t mktime(tm* timeptr);
+time_t time(time_t* timer);
+char* asctime(const tm* timeptr);
+char* ctime(const time_t* timer);
+tm*    gmtime(const time_t* timer);
+tm* localtime(const time_t* timer);
+size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
+                const tm* restrict timeptr);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <time.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::clock_t;
+using ::size_t;
+using ::time_t;
+using ::tm;
+using ::clock;
+using ::difftime;
+using ::mktime;
+using ::time;
+using ::asctime;
+using ::ctime;
+using ::gmtime;
+using ::localtime;
+using ::strftime;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CTIME
diff --git a/final/include/cwchar b/final/include/cwchar
new file mode 100644
index 0000000..9f51587
--- /dev/null
+++ b/final/include/cwchar
@@ -0,0 +1,217 @@
+// -*- C++ -*-
+//===--------------------------- cwchar -----------------------------------===//
+//
+//                     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_CWCHAR
+#define _LIBCPP_CWCHAR
+
+/*
+    cwchar synopsis
+
+Macros:
+
+    NULL
+    WCHAR_MAX
+    WCHAR_MIN
+    WEOF
+
+namespace std
+{
+
+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);
+
+}  // std
+
+*/
+
+#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
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+using ::mbstate_t;
+using ::size_t;
+using ::tm;
+using ::wint_t;
+using ::FILE;
+using ::fwprintf;
+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
+using ::wcstof;
+using ::wcstold;
+#endif // _LIBCPP_MSVCRT
+using ::wcstol;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::wcstoll;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::wcstoul;
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+using ::wcstoull;
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+using ::wcscpy;
+using ::wcsncpy;
+using ::wcscat;
+using ::wcsncat;
+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;
+using ::wcstok;
+using ::wmemcmp;
+using ::wmemcpy;
+using ::wmemmove;
+using ::wmemset;
+using ::wcsftime;
+using ::btowc;
+using ::wctob;
+using ::mbsinit;
+using ::mbrlen;
+using ::mbrtowc;
+using ::wcrtomb;
+using ::mbsrtowcs;
+using ::wcsrtombs;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_CWCHAR
diff --git a/final/include/cwctype b/final/include/cwctype
new file mode 100644
index 0000000..4f89b52
--- /dev/null
+++ b/final/include/cwctype
@@ -0,0 +1,213 @@
+// -*- C++ -*-
+//===--------------------------- cwctype ----------------------------------===//
+//
+//                     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_CWCTYPE
+#define _LIBCPP_CWCTYPE
+
+/*
+    cwctype synopsis
+
+Macros:
+
+    WEOF
+
+namespace std
+{
+
+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);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <cctype>
+#include <wctype.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_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
+
+#endif  // _LIBCPP_CWCTYPE
diff --git a/final/include/deque b/final/include/deque
new file mode 100644
index 0000000..9b256b7
--- /dev/null
+++ b/final/include/deque
@@ -0,0 +1,2873 @@
+// -*- C++ -*-
+//===---------------------------- deque -----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_DEQUE
+#define _LIBCPP_DEQUE
+
+/*
+    deque synopsis
+
+namespace std
+{
+
+template <class T, class Allocator = allocator<T> >
+class deque
+{
+public:
+    // types:
+    typedef T value_type;
+    typedef Allocator allocator_type;
+
+    typedef typename allocator_type::reference       reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef implementation-defined                   iterator;
+    typedef implementation-defined                   const_iterator;
+    typedef typename allocator_type::size_type       size_type;
+    typedef typename allocator_type::difference_type difference_type;
+
+    typedef typename allocator_type::pointer         pointer;
+    typedef typename allocator_type::const_pointer   const_pointer;
+    typedef std::reverse_iterator<iterator>          reverse_iterator;
+    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+
+    // construct/copy/destroy:
+    deque() noexcept(is_nothrow_default_constructible<allocator_type>::value);
+    explicit deque(const allocator_type& a);
+    explicit deque(size_type n);
+    explicit deque(size_type n, const allocator_type& a); // C++14
+    deque(size_type n, const value_type& v);
+    deque(size_type n, const value_type& v, const allocator_type& a);
+    template <class InputIterator>
+        deque(InputIterator f, InputIterator l);
+    template <class InputIterator>
+        deque(InputIterator f, InputIterator l, const allocator_type& a);
+    deque(const deque& c);
+    deque(deque&& c)
+        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+    deque(initializer_list<value_type> il, const Allocator& a = allocator_type());
+    deque(const deque& c, const allocator_type& a);
+    deque(deque&& c, const allocator_type& a);
+    ~deque();
+
+    deque& operator=(const deque& c);
+    deque& operator=(deque&& c)
+        noexcept(
+             allocator_type::propagate_on_container_move_assignment::value &&
+             is_nothrow_move_assignable<allocator_type>::value);
+    deque& operator=(initializer_list<value_type> il);
+
+    template <class InputIterator>
+        void assign(InputIterator f, InputIterator l);
+    void assign(size_type n, const value_type& v);
+    void assign(initializer_list<value_type> il);
+
+    allocator_type get_allocator() const noexcept;
+
+    // iterators:
+
+    iterator       begin() noexcept;
+    const_iterator begin() const noexcept;
+    iterator       end() noexcept;
+    const_iterator end() const noexcept;
+
+    reverse_iterator       rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+    reverse_iterator       rend() noexcept;
+    const_reverse_iterator rend() const noexcept;
+
+    const_iterator         cbegin() const noexcept;
+    const_iterator         cend() const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend() const noexcept;
+
+    // capacity:
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+    void resize(size_type n);
+    void resize(size_type n, const value_type& v);
+    void shrink_to_fit();
+    bool empty() const noexcept;
+
+    // element access:
+    reference operator[](size_type i);
+    const_reference operator[](size_type i) const;
+    reference at(size_type i);
+    const_reference at(size_type i) const;
+    reference front();
+    const_reference front() const;
+    reference back();
+    const_reference back() const;
+
+    // modifiers:
+    void push_front(const value_type& v);
+    void push_front(value_type&& v);
+    void push_back(const value_type& v);
+    void push_back(value_type&& v);
+    template <class... Args> void emplace_front(Args&&... args);
+    template <class... Args> void emplace_back(Args&&... args);
+    template <class... Args> iterator emplace(const_iterator p, Args&&... args);
+    iterator insert(const_iterator p, const value_type& v);
+    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, 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);
+    void clear() noexcept;
+};
+
+template <class T, class Allocator>
+    bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+    bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+    bool operator!=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+    bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+    bool operator>=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+template <class T, class Allocator>
+    bool operator<=(const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+
+// specialized algorithms:
+template <class T, class Allocator>
+    void swap(deque<T,Allocator>& x, deque<T,Allocator>& y)
+         noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include <__config>
+#include <__split_buffer>
+#include <type_traits>
+#include <initializer_list>
+#include <iterator>
+#include <algorithm>
+#include <stdexcept>
+
+#include <__undef_min_max>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Allocator> class __deque_base;
+
+template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
+          class _DiffType, _DiffType _BlockSize>
+class _LIBCPP_TYPE_VIS_ONLY __deque_iterator;
+
+template <class _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(_RAIter __f,
+     _RAIter __l,
+     __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+     typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+     __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+     _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(__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 _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_backward(_RAIter __f,
+              _RAIter __l,
+              __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+              typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+              __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+              _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_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 _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(_RAIter __f,
+     _RAIter __l,
+     __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+     typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+     __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+     _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(__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 _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move_backward(_RAIter __f,
+              _RAIter __l,
+              __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+              typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+              __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+              _OutputIterator __r);
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+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 _Pointer, class _Reference, class _MapPointer,
+          class _DiffType, _DiffType _BlockSize>
+class _LIBCPP_TYPE_VIS_ONLY __deque_iterator
+{
+    typedef _MapPointer __map_iterator;
+public:
+    typedef _Pointer  pointer;
+    typedef _DiffType difference_type;
+private:
+    __map_iterator __m_iter_;
+    pointer        __ptr_;
+
+    static const difference_type __block_size = _BlockSize;
+public:
+    typedef _ValueType                  value_type;
+    typedef random_access_iterator_tag  iterator_category;
+    typedef _Reference                  reference;
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+     : __m_iter_(nullptr), __ptr_(nullptr)
+#endif
+     {}
+
+    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,
+                typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT
+        : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {}
+
+    _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *__ptr_;}
+    _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return __ptr_;}
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator++()
+    {
+        if (++__ptr_ - *__m_iter_ == __block_size)
+        {
+            ++__m_iter_;
+            __ptr_ = *__m_iter_;
+        }
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator operator++(int)
+    {
+        __deque_iterator __tmp = *this;
+        ++(*this);
+        return __tmp;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator--()
+    {
+        if (__ptr_ == *__m_iter_)
+        {
+            --__m_iter_;
+            __ptr_ = *__m_iter_ + __block_size;
+        }
+        --__ptr_;
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator operator--(int)
+    {
+        __deque_iterator __tmp = *this;
+        --(*this);
+        return __tmp;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator+=(difference_type __n)
+    {
+        if (__n != 0)
+        {
+            __n += __ptr_ - *__m_iter_;
+            if (__n > 0)
+            {
+                __m_iter_ += __n / __block_size;
+                __ptr_ = *__m_iter_ + __n % __block_size;
+            }
+            else // (__n < 0)
+            {
+                difference_type __z = __block_size - 1 - __n;
+                __m_iter_ -= __z / __block_size;
+                __ptr_ = *__m_iter_ + (__block_size - 1 - __z % __block_size);
+            }
+        }
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator& operator-=(difference_type __n)
+    {
+        return *this += -__n;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator operator+(difference_type __n) const
+    {
+        __deque_iterator __t(*this);
+        __t += __n;
+        return __t;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator operator-(difference_type __n) const
+    {
+        __deque_iterator __t(*this);
+        __t -= __n;
+        return __t;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    friend __deque_iterator operator+(difference_type __n, const __deque_iterator& __it)
+        {return __it + __n;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    friend difference_type operator-(const __deque_iterator& __x, const __deque_iterator& __y)
+    {
+        if (__x != __y)
+            return (__x.__m_iter_ - __y.__m_iter_) * __block_size
+                 + (__x.__ptr_ - *__x.__m_iter_)
+                 - (__y.__ptr_ - *__y.__m_iter_);
+        return 0;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const
+        {return *(*this + __n);}
+
+    _LIBCPP_INLINE_VISIBILITY friend
+        bool operator==(const __deque_iterator& __x, const __deque_iterator& __y)
+        {return __x.__ptr_ == __y.__ptr_;}
+
+    _LIBCPP_INLINE_VISIBILITY friend
+        bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y)
+        {return !(__x == __y);}
+
+    _LIBCPP_INLINE_VISIBILITY friend
+        bool operator<(const __deque_iterator& __x, const __deque_iterator& __y)
+        {return __x.__m_iter_ < __y.__m_iter_ ||
+               (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);}
+
+    _LIBCPP_INLINE_VISIBILITY friend
+        bool operator>(const __deque_iterator& __x, const __deque_iterator& __y)
+        {return __y < __x;}
+
+    _LIBCPP_INLINE_VISIBILITY friend
+        bool operator<=(const __deque_iterator& __x, const __deque_iterator& __y)
+        {return !(__y < __x);}
+
+    _LIBCPP_INLINE_VISIBILITY friend
+        bool operator>=(const __deque_iterator& __x, const __deque_iterator& __y)
+        {return !(__x < __y);}
+
+private:
+    _LIBCPP_INLINE_VISIBILITY __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
+        : __m_iter_(__m), __ptr_(__p) {}
+
+    template <class _Tp, class _Ap> friend class __deque_base;
+    template <class _Tp, class _Ap> friend class _LIBCPP_TYPE_VIS_ONLY deque;
+    template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>
+        friend class _LIBCPP_TYPE_VIS_ONLY __deque_iterator;
+
+    template <class _RAIter,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    copy(_RAIter __f,
+         _RAIter __l,
+         __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+         typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _OutputIterator>
+    friend
+    _OutputIterator
+    copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+         __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+         _OutputIterator __r);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    copy(__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 _RAIter,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    copy_backward(_RAIter __f,
+                  _RAIter __l,
+                  __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+                  typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _OutputIterator>
+    friend
+    _OutputIterator
+    copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+                  __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+                  _OutputIterator __r);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    copy_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 _RAIter,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    move(_RAIter __f,
+         _RAIter __l,
+         __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+         typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _OutputIterator>
+    friend
+    _OutputIterator
+    move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+         __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+         _OutputIterator __r);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    move(__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 _RAIter,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    move_backward(_RAIter __f,
+                  _RAIter __l,
+                  __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+                  typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _OutputIterator>
+    friend
+    _OutputIterator
+    move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+                  __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+                  _OutputIterator __r);
+
+    template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+              class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+    friend
+    __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+    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);
+};
+
+// copy
+
+template <class _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(_RAIter __f,
+     _RAIter __l,
+     __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+     typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+{
+    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;
+    while (__f != __l)
+    {
+        pointer __rb = __r.__ptr_;
+        pointer __re = *__r.__m_iter_ + _B2;
+        difference_type __bs = __re - __rb;
+        difference_type __n = __l - __f;
+        _RAIter __m = __l;
+        if (__n > __bs)
+        {
+            __n = __bs;
+            __m = __f + __n;
+        }
+        _VSTD::copy(__f, __m, __rb);
+        __f = __m;
+        __r += __n;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+     __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+     _OutputIterator __r)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        pointer __fb = __f.__ptr_;
+        pointer __fe = *__f.__m_iter_ + _B1;
+        difference_type __bs = __fe - __fb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __fe = __fb + __bs;
+        }
+        __r = _VSTD::copy(__fb, __fe, __r);
+        __n -= __bs;
+        __f += __bs;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy(__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)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        pointer __fb = __f.__ptr_;
+        pointer __fe = *__f.__m_iter_ + _B1;
+        difference_type __bs = __fe - __fb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __fe = __fb + __bs;
+        }
+        __r = _VSTD::copy(__fb, __fe, __r);
+        __n -= __bs;
+        __f += __bs;
+    }
+    return __r;
+}
+
+// copy_backward
+
+template <class _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_backward(_RAIter __f,
+              _RAIter __l,
+              __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+              typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+{
+    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;
+    while (__f != __l)
+    {
+        __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r);
+        pointer __rb = *__rp.__m_iter_;
+        pointer __re = __rp.__ptr_ + 1;
+        difference_type __bs = __re - __rb;
+        difference_type __n = __l - __f;
+        _RAIter __m = __f;
+        if (__n > __bs)
+        {
+            __n = __bs;
+            __m = __l - __n;
+        }
+        _VSTD::copy_backward(__m, __l, __re);
+        __l = __m;
+        __r -= __n;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+copy_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+              __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+              _OutputIterator __r)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        --__l;
+        pointer __lb = *__l.__m_iter_;
+        pointer __le = __l.__ptr_ + 1;
+        difference_type __bs = __le - __lb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __lb = __le - __bs;
+        }
+        __r = _VSTD::copy_backward(__lb, __le, __r);
+        __n -= __bs;
+        __l -= __bs - 1;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+copy_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)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        --__l;
+        pointer __lb = *__l.__m_iter_;
+        pointer __le = __l.__ptr_ + 1;
+        difference_type __bs = __le - __lb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __lb = __le - __bs;
+        }
+        __r = _VSTD::copy_backward(__lb, __le, __r);
+        __n -= __bs;
+        __l -= __bs - 1;
+    }
+    return __r;
+}
+
+// move
+
+template <class _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(_RAIter __f,
+     _RAIter __l,
+     __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+     typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+{
+    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;
+    while (__f != __l)
+    {
+        pointer __rb = __r.__ptr_;
+        pointer __re = *__r.__m_iter_ + _B2;
+        difference_type __bs = __re - __rb;
+        difference_type __n = __l - __f;
+        _RAIter __m = __l;
+        if (__n > __bs)
+        {
+            __n = __bs;
+            __m = __f + __n;
+        }
+        _VSTD::move(__f, __m, __rb);
+        __f = __m;
+        __r += __n;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+     __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+     _OutputIterator __r)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        pointer __fb = __f.__ptr_;
+        pointer __fe = *__f.__m_iter_ + _B1;
+        difference_type __bs = __fe - __fb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __fe = __fb + __bs;
+        }
+        __r = _VSTD::move(__fb, __fe, __r);
+        __n -= __bs;
+        __f += __bs;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move(__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)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        pointer __fb = __f.__ptr_;
+        pointer __fe = *__f.__m_iter_ + _B1;
+        difference_type __bs = __fe - __fb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __fe = __fb + __bs;
+        }
+        __r = _VSTD::move(__fb, __fe, __r);
+        __n -= __bs;
+        __f += __bs;
+    }
+    return __r;
+}
+
+// move_backward
+
+template <class _RAIter,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+move_backward(_RAIter __f,
+              _RAIter __l,
+              __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r,
+              typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+{
+    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;
+    while (__f != __l)
+    {
+        __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __rp = _VSTD::prev(__r);
+        pointer __rb = *__rp.__m_iter_;
+        pointer __re = __rp.__ptr_ + 1;
+        difference_type __bs = __re - __rb;
+        difference_type __n = __l - __f;
+        _RAIter __m = __f;
+        if (__n > __bs)
+        {
+            __n = __bs;
+            __m = __l - __n;
+        }
+        _VSTD::move_backward(__m, __l, __re);
+        __l = __m;
+        __r -= __n;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _OutputIterator>
+_OutputIterator
+move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f,
+              __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l,
+              _OutputIterator __r)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        --__l;
+        pointer __lb = *__l.__m_iter_;
+        pointer __le = __l.__ptr_ + 1;
+        difference_type __bs = __le - __lb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __lb = __le - __bs;
+        }
+        __r = _VSTD::move_backward(__lb, __le, __r);
+        __n -= __bs;
+        __l -= __bs - 1;
+    }
+    return __r;
+}
+
+template <class _V1, class _P1, class _R1, class _M1, class _D1, _D1 _B1,
+          class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
+__deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>
+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)
+{
+    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;
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        --__l;
+        pointer __lb = *__l.__m_iter_;
+        pointer __le = __l.__ptr_ + 1;
+        difference_type __bs = __le - __lb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __lb = __le - __bs;
+        }
+        __r = _VSTD::move_backward(__lb, __le, __r);
+        __n -= __bs;
+        __l -= __bs - 1;
+    }
+    return __r;
+}
+
+template <bool>
+class __deque_base_common
+{
+protected:
+    void __throw_length_error() const;
+    void __throw_out_of_range() const;
+};
+
+template <bool __b>
+void
+__deque_base_common<__b>::__throw_length_error() const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw length_error("deque");
+#endif
+}
+
+template <bool __b>
+void
+__deque_base_common<__b>::__throw_out_of_range() const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw out_of_range("deque");
+#endif
+}
+
+template <class _Tp, class _Allocator>
+class __deque_base
+    : protected __deque_base_common<true>
+{
+    __deque_base(const __deque_base& __c);
+    __deque_base& operator=(const __deque_base& __c);
+protected:
+    typedef _Tp                                      value_type;
+    typedef _Allocator                               allocator_type;
+    typedef allocator_traits<allocator_type>         __alloc_traits;
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+    typedef typename __alloc_traits::size_type       size_type;
+    typedef typename __alloc_traits::difference_type difference_type;
+    typedef typename __alloc_traits::pointer         pointer;
+    typedef typename __alloc_traits::const_pointer   const_pointer;
+
+    static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16;
+
+    typedef typename __alloc_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+                rebind_alloc<pointer>
+#else
+                rebind_alloc<pointer>::other
+#endif
+                                                         __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 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;
+    typedef __deque_iterator<value_type, const_pointer, const_reference, __map_const_pointer,
+                             difference_type, __block_size>    const_iterator;
+
+    __map __map_;
+    size_type __start_;
+    __compressed_pair<size_type, allocator_type> __size_;
+
+    iterator       begin() _NOEXCEPT;
+    const_iterator begin() const _NOEXCEPT;
+    iterator       end() _NOEXCEPT;
+    const_iterator end() const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY size_type&            size()          {return __size_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+    const size_type& size() const _NOEXCEPT {return __size_.first();}
+    _LIBCPP_INLINE_VISIBILITY allocator_type&       __alloc()       {return __size_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const allocator_type& __alloc() const _NOEXCEPT {return __size_.second();}
+
+    __deque_base()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+    explicit __deque_base(const allocator_type& __a);
+public:
+    ~__deque_base();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    __deque_base(__deque_base&& __c)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+    __deque_base(__deque_base&& __c, const allocator_type& __a);
+
+#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);
+protected:
+    void clear() _NOEXCEPT;
+
+    bool __invariants() const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign(__deque_base& __c)
+        _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
+                   is_nothrow_move_assignable<allocator_type>::value)
+    {
+        __map_ = _VSTD::move(__c.__map_);
+        __start_ = __c.__start_;
+        size() = __c.size();
+        __move_assign_alloc(__c);
+        __c.__start_ = __c.size() = 0;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__deque_base& __c)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value ||
+                   is_nothrow_move_assignable<allocator_type>::value)
+        {__move_assign_alloc(__c, integral_constant<bool,
+                      __alloc_traits::propagate_on_container_move_assignment::value>());}
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__deque_base& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+        {
+            __alloc() = _VSTD::move(__c.__alloc());
+        }
+
+    _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>
+bool
+__deque_base<_Tp, _Allocator>::__invariants() const
+{
+    if (!__map_.__invariants())
+        return false;
+    if (__map_.size() >= size_type(-1) / __block_size)
+        return false;
+    for (typename __map::const_iterator __i = __map_.begin(), __e = __map_.end();
+         __i != __e; ++__i)
+        if (*__i == nullptr)
+            return false;
+    if (__map_.size() != 0)
+    {
+        if (size() >= __map_.size() * __block_size)
+            return false;
+        if (__start_ >= __map_.size() * __block_size - size())
+            return false;
+    }
+    else
+    {
+        if (size() != 0)
+            return false;
+        if (__start_ != 0)
+            return false;
+    }
+    return true;
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::iterator
+__deque_base<_Tp, _Allocator>::begin() _NOEXCEPT
+{
+    __map_pointer __mp = __map_.begin() + __start_ / __block_size;
+    return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::const_iterator
+__deque_base<_Tp, _Allocator>::begin() const _NOEXCEPT
+{
+    __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size);
+    return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::iterator
+__deque_base<_Tp, _Allocator>::end() _NOEXCEPT
+{
+    size_type __p = size() + __start_;
+    __map_pointer __mp = __map_.begin() + __p / __block_size;
+    return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+typename __deque_base<_Tp, _Allocator>::const_iterator
+__deque_base<_Tp, _Allocator>::end() const _NOEXCEPT
+{
+    size_type __p = size() + __start_;
+    __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size);
+    return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+__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
+__deque_base<_Tp, _Allocator>::__deque_base(const allocator_type& __a)
+    : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {}
+
+template <class _Tp, class _Allocator>
+__deque_base<_Tp, _Allocator>::~__deque_base()
+{
+    clear();
+    typename __map::iterator __i = __map_.begin();
+    typename __map::iterator __e = __map_.end();
+    for (; __i != __e; ++__i)
+        __alloc_traits::deallocate(__alloc(), *__i, __block_size);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c)
+    _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+    : __map_(_VSTD::move(__c.__map_)),
+      __start_(_VSTD::move(__c.__start_)),
+      __size_(_VSTD::move(__c.__size_))
+{
+    __c.__start_ = 0;
+    __c.size() = 0;
+}
+
+template <class _Tp, class _Allocator>
+__deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_type& __a)
+    : __map_(_VSTD::move(__c.__map_), __pointer_allocator(__a)),
+      __start_(_VSTD::move(__c.__start_)),
+      __size_(_VSTD::move(__c.size()), __a)
+{
+    if (__a == __c.__alloc())
+    {
+        __c.__start_ = 0;
+        __c.size() = 0;
+    }
+    else
+    {
+        __map_.clear();
+        __start_ = 0;
+        size() = 0;
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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)
+{
+    __map_.swap(__c.__map_);
+    _VSTD::swap(__start_, __c.__start_);
+    _VSTD::swap(size(), __c.size());
+    __swap_alloc(__alloc(), __c.__alloc());
+}
+
+template <class _Tp, class _Allocator>
+void
+__deque_base<_Tp, _Allocator>::clear() _NOEXCEPT
+{
+    allocator_type& __a = __alloc();
+    for (iterator __i = begin(), __e = end(); __i != __e; ++__i)
+        __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
+    size() = 0;
+    while (__map_.size() > 2)
+    {
+        __alloc_traits::deallocate(__a, __map_.front(), __block_size);
+        __map_.pop_front();
+    }
+    switch (__map_.size())
+    {
+    case 1:
+        __start_ = __block_size / 2;
+        break;
+    case 2:
+        __start_ = __block_size;
+        break;
+    }
+}
+
+template <class _Tp, class _Allocator = allocator<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY deque
+    : private __deque_base<_Tp, _Allocator>
+{
+public:
+    // types:
+
+    typedef _Tp value_type;
+    typedef _Allocator allocator_type;
+
+    typedef __deque_base<value_type, allocator_type> __base;
+
+    typedef typename __base::__alloc_traits        __alloc_traits;
+    typedef typename __base::reference             reference;
+    typedef typename __base::const_reference       const_reference;
+    typedef typename __base::iterator              iterator;
+    typedef typename __base::const_iterator        const_iterator;
+    typedef typename __base::size_type             size_type;
+    typedef typename __base::difference_type       difference_type;
+
+    typedef typename __base::pointer               pointer;
+    typedef typename __base::const_pointer         const_pointer;
+    typedef _VSTD::reverse_iterator<iterator>       reverse_iterator;
+    typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+    // construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY
+    deque()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+        {}
+    _LIBCPP_INLINE_VISIBILITY explicit deque(const allocator_type& __a) : __base(__a) {}
+    explicit deque(size_type __n);
+#if _LIBCPP_STD_VER > 11
+    explicit deque(size_type __n, const _Allocator& __a);
+#endif
+    deque(size_type __n, const value_type& __v);
+    deque(size_type __n, const value_type& __v, const allocator_type& __a);
+    template <class _InputIter>
+        deque(_InputIter __f, _InputIter __l,
+              typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0);
+    template <class _InputIter>
+        deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
+              typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0);
+    deque(const deque& __c);
+    deque(const deque& __c, const allocator_type& __a);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    deque(initializer_list<value_type> __il);
+    deque(initializer_list<value_type> __il, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    deque& operator=(const deque& __c);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    deque& operator=(initializer_list<value_type> __il) {assign(__il); return *this;}
+#endif   // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value);
+    deque(deque&& __c, const allocator_type& __a);
+    deque& operator=(deque&& __c)
+        _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
+                   is_nothrow_move_assignable<allocator_type>::value);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    template <class _InputIter>
+        void assign(_InputIter __f, _InputIter __l,
+                    typename enable_if<__is_input_iterator<_InputIter>::value &&
+                                      !__is_random_access_iterator<_InputIter>::value>::type* = 0);
+    template <class _RAIter>
+        void assign(_RAIter __f, _RAIter __l,
+                    typename enable_if<__is_random_access_iterator<_RAIter>::value>::type* = 0);
+    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) {assign(__il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    allocator_type get_allocator() const _NOEXCEPT;
+
+    // iterators:
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin() _NOEXCEPT       {return __base::begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return __base::begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end() _NOEXCEPT         {return __base::end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()   const _NOEXCEPT {return __base::end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator       rbegin() _NOEXCEPT
+        {return       reverse_iterator(__base::end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT
+        {return const_reverse_iterator(__base::end());}
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator       rend() _NOEXCEPT
+        {return       reverse_iterator(__base::begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend()   const _NOEXCEPT
+        {return const_reverse_iterator(__base::begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator         cbegin()  const _NOEXCEPT
+        {return __base::begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator         cend()    const _NOEXCEPT
+        {return __base::end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT
+        {return const_reverse_iterator(__base::end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend()   const _NOEXCEPT
+        {return const_reverse_iterator(__base::begin());}
+
+    // capacity:
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT {return __base::size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT
+        {return __alloc_traits::max_size(__base::__alloc());}
+    void resize(size_type __n);
+    void resize(size_type __n, const value_type& __v);
+    void shrink_to_fit() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT {return __base::size() == 0;}
+
+    // element access:
+    reference operator[](size_type __i);
+    const_reference operator[](size_type __i) const;
+    reference at(size_type __i);
+    const_reference at(size_type __i) const;
+    reference front();
+    const_reference front() const;
+    reference back();
+    const_reference back() const;
+
+    // 23.2.2.3 modifiers:
+    void push_front(const value_type& __v);
+    void push_back(const value_type& __v);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args> void emplace_front(_Args&&... __args);
+    template <class... _Args> void emplace_back(_Args&&... __args);
+    template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+    void push_front(value_type&& __v);
+    void push_back(value_type&& __v);
+    iterator insert(const_iterator __p, value_type&& __v);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    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,
+                         typename enable_if<__is_input_iterator<_InputIter>::value
+                                         &&!__is_bidirectional_iterator<_InputIter>::value>::type* = 0);
+    template <class _BiIter>
+        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
+    iterator insert(const_iterator __p, initializer_list<value_type> __il)
+        {return insert(__p, __il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    void pop_front();
+    void pop_back();
+    iterator erase(const_iterator __p);
+    iterator erase(const_iterator __f, const_iterator __l);
+
+    void swap(deque& __c)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<allocator_type>::value);
+    void clear() _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool __invariants() const {return __base::__invariants();}
+private:
+    typedef typename __base::__map_const_pointer __map_const_pointer;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static size_type __recommend_blocks(size_type __n)
+    {
+        return __n / __base::__block_size + (__n % __base::__block_size != 0);
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    size_type __capacity() const
+    {
+        return __base::__map_.size() == 0 ? 0 : __base::__map_.size() * __base::__block_size - 1;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    size_type __front_spare() const
+    {
+        return __base::__start_;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    size_type __back_spare() const
+    {
+        return __capacity() - (__base::__start_ + __base::size());
+    }
+
+    template <class _InpIter>
+        void __append(_InpIter __f, _InpIter __l,
+                 typename enable_if<__is_input_iterator<_InpIter>::value &&
+                                   !__is_forward_iterator<_InpIter>::value>::type* = 0);
+    template <class _ForIter>
+        void __append(_ForIter __f, _ForIter __l,
+                      typename enable_if<__is_forward_iterator<_ForIter>::value>::type* = 0);
+    void __append(size_type __n);
+    void __append(size_type __n, const value_type& __v);
+    void __erase_to_end(const_iterator __f);
+    void __add_front_capacity();
+    void __add_front_capacity(size_type __n);
+    void __add_back_capacity();
+    void __add_back_capacity(size_type __n);
+    iterator __move_and_check(iterator __f, iterator __l, iterator __r,
+                              const_pointer& __vt);
+    iterator __move_backward_and_check(iterator __f, iterator __l, iterator __r,
+                                       const_pointer& __vt);
+    void __move_construct_and_check(iterator __f, iterator __l,
+                                    iterator __r, const_pointer& __vt);
+    void __move_construct_backward_and_check(iterator __f, iterator __l,
+                                             iterator __r, const_pointer& __vt);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const deque& __c)
+        {__copy_assign_alloc(__c, integral_constant<bool,
+                      __alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const deque& __c, true_type)
+        {
+            if (__base::__alloc() != __c.__alloc())
+            {
+                clear();
+                shrink_to_fit();
+            }
+            __base::__alloc() = __c.__alloc();
+            __base::__map_.__alloc() = __c.__map_.__alloc();
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const deque&, false_type)
+        {}
+
+    void __move_assign(deque& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+    void __move_assign(deque& __c, false_type);
+};
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n)
+{
+    if (__n > 0)
+        __append(__n);
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
+    : __base(__a)
+{
+    if (__n > 0)
+        __append(__n);
+}
+#endif
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v)
+{
+    if (__n > 0)
+        __append(__n, __v);
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v, const allocator_type& __a)
+    : __base(__a)
+{
+    if (__n > 0)
+        __append(__n, __v);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l,
+              typename enable_if<__is_input_iterator<_InputIter>::value>::type*)
+{
+    __append(__f, __l);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a,
+              typename enable_if<__is_input_iterator<_InputIter>::value>::type*)
+    : __base(__a)
+{
+    __append(__f, __l);
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(const deque& __c)
+    : __base(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))
+{
+    __append(__c.begin(), __c.end());
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(const deque& __c, const allocator_type& __a)
+    : __base(__a)
+{
+    __append(__c.begin(), __c.end());
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il)
+{
+    __append(__il.begin(), __il.end());
+}
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a)
+    : __base(__a)
+{
+    __append(__il.begin(), __il.end());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Allocator>
+deque<_Tp, _Allocator>&
+deque<_Tp, _Allocator>::operator=(const deque& __c)
+{
+    if (this != &__c)
+    {
+        __copy_assign_alloc(__c);
+        assign(__c.begin(), __c.end());
+    }
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+deque<_Tp, _Allocator>::deque(deque&& __c)
+    _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+    : __base(_VSTD::move(__c))
+{
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a)
+    : __base(_VSTD::move(__c), __a)
+{
+    if (__a != __c.__alloc())
+    {
+        typedef move_iterator<iterator> _Ip;
+        assign(_Ip(__c.begin()), _Ip(__c.end()));
+    }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+deque<_Tp, _Allocator>&
+deque<_Tp, _Allocator>::operator=(deque&& __c)
+        _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value &&
+                   is_nothrow_move_assignable<allocator_type>::value)
+{
+    __move_assign(__c, integral_constant<bool,
+          __alloc_traits::propagate_on_container_move_assignment::value>());
+    return *this;
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type)
+{
+    if (__base::__alloc() != __c.__alloc())
+    {
+        typedef move_iterator<iterator> _Ip;
+        assign(_Ip(__c.begin()), _Ip(__c.end()));
+    }
+    else
+        __move_assign(__c, true_type());
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
+    _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+    clear();
+    shrink_to_fit();
+    __base::__move_assign(__c);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+template <class _InputIter>
+void
+deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l,
+                               typename enable_if<__is_input_iterator<_InputIter>::value &&
+                                                 !__is_random_access_iterator<_InputIter>::value>::type*)
+{
+    iterator __i = __base::begin();
+    iterator __e = __base::end();
+    for (; __f != __l && __i != __e; ++__f, ++__i)
+        *__i = *__f;
+    if (__f != __l)
+        __append(__f, __l);
+    else
+        __erase_to_end(__i);
+}
+
+template <class _Tp, class _Allocator>
+template <class _RAIter>
+void
+deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l,
+                               typename enable_if<__is_random_access_iterator<_RAIter>::value>::type*)
+{
+    if (static_cast<size_type>(__l - __f) > __base::size())
+    {
+        _RAIter __m = __f + __base::size();
+        _VSTD::copy(__f, __m, __base::begin());
+        __append(__m, __l);
+    }
+    else
+        __erase_to_end(_VSTD::copy(__f, __l, __base::begin()));
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v)
+{
+    if (__n > __base::size())
+    {
+        _VSTD::fill_n(__base::begin(), __base::size(), __v);
+        __n -= __base::size();
+        __append(__n, __v);
+    }
+    else
+        __erase_to_end(_VSTD::fill_n(__base::begin(), __n, __v));
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+_Allocator
+deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT
+{
+    return __base::__alloc();
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::resize(size_type __n)
+{
+    if (__n > __base::size())
+        __append(__n - __base::size());
+    else if (__n < __base::size())
+        __erase_to_end(__base::begin() + __n);
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::resize(size_type __n, const value_type& __v)
+{
+    if (__n > __base::size())
+        __append(__n - __base::size(), __v);
+    else if (__n < __base::size())
+        __erase_to_end(__base::begin() + __n);
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+    allocator_type& __a = __base::__alloc();
+    if (empty())
+    {
+        while (__base::__map_.size() > 0)
+        {
+            __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
+            __base::__map_.pop_back();
+        }
+        __base::__start_ = 0;
+    }
+    else
+    {
+        if (__front_spare() >= __base::__block_size)
+        {
+            __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size);
+            __base::__map_.pop_front();
+            __base::__start_ -= __base::__block_size;
+        }
+        if (__back_spare() >= __base::__block_size)
+        {
+            __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
+            __base::__map_.pop_back();
+        }
+    }
+    __base::__map_.shrink_to_fit();
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::operator[](size_type __i)
+{
+    size_type __p = __base::__start_ + __i;
+    return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::operator[](size_type __i) const
+{
+    size_type __p = __base::__start_ + __i;
+    return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::at(size_type __i)
+{
+    if (__i >= __base::size())
+        __base::__throw_out_of_range();
+    size_type __p = __base::__start_ + __i;
+    return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::at(size_type __i) const
+{
+    if (__i >= __base::size())
+        __base::__throw_out_of_range();
+    size_type __p = __base::__start_ + __i;
+    return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::front()
+{
+    return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
+                                      + __base::__start_ % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::front() const
+{
+    return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
+                                      + __base::__start_ % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::reference
+deque<_Tp, _Allocator>::back()
+{
+    size_type __p = __base::size() + __base::__start_ - 1;
+    return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename deque<_Tp, _Allocator>::const_reference
+deque<_Tp, _Allocator>::back() const
+{
+    size_type __p = __base::size() + __base::__start_ - 1;
+    return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_back(const value_type& __v)
+{
+    allocator_type& __a = __base::__alloc();
+    if (__back_spare() == 0)
+        __add_back_capacity();
+    // __back_spare() >= 1
+    __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
+    ++__base::size();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_back(value_type&& __v)
+{
+    allocator_type& __a = __base::__alloc();
+    if (__back_spare() == 0)
+        __add_back_capacity();
+    // __back_spare() >= 1
+    __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
+    ++__base::size();
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+void
+deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)
+{
+    allocator_type& __a = __base::__alloc();
+    if (__back_spare() == 0)
+        __add_back_capacity();
+    // __back_spare() >= 1
+    __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...);
+    ++__base::size();
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_front(const value_type& __v)
+{
+    allocator_type& __a = __base::__alloc();
+    if (__front_spare() == 0)
+        __add_front_capacity();
+    // __front_spare() >= 1
+    __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
+    --__base::__start_;
+    ++__base::size();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::push_front(value_type&& __v)
+{
+    allocator_type& __a = __base::__alloc();
+    if (__front_spare() == 0)
+        __add_front_capacity();
+    // __front_spare() >= 1
+    __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));
+    --__base::__start_;
+    ++__base::size();
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+void
+deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
+{
+    allocator_type& __a = __base::__alloc();
+    if (__front_spare() == 0)
+        __add_front_capacity();
+    // __front_spare() >= 1
+    __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
+    --__base::__start_;
+    ++__base::size();
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v)
+{
+    size_type __pos = __p - __base::begin();
+    size_type __to_end = __base::size() - __pos;
+    allocator_type& __a = __base::__alloc();
+    if (__pos < __to_end)
+    {   // insert by shifting things backward
+        if (__front_spare() == 0)
+            __add_front_capacity();
+        // __front_spare() >= 1
+        if (__pos == 0)
+        {
+            __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), __v);
+            --__base::__start_;
+            ++__base::size();
+        }
+        else
+        {
+            const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+            iterator __b = __base::begin();
+            iterator __bm1 = _VSTD::prev(__b);
+            if (__vt == pointer_traits<const_pointer>::pointer_to(*__b))
+                __vt = pointer_traits<const_pointer>::pointer_to(*__bm1);
+            __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
+            --__base::__start_;
+            ++__base::size();
+            if (__pos > 1)
+                __b = __move_and_check(_VSTD::next(__b), __b + __pos, __b, __vt);
+            *__b = *__vt;
+        }
+    }
+    else
+    {   // insert by shifting things forward
+        if (__back_spare() == 0)
+            __add_back_capacity();
+        // __back_capacity >= 1
+        size_type __de = __base::size() - __pos;
+        if (__de == 0)
+        {
+            __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), __v);
+            ++__base::size();
+        }
+        else
+        {
+            const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+            iterator __e = __base::end();
+            iterator __em1 = _VSTD::prev(__e);
+            if (__vt == pointer_traits<const_pointer>::pointer_to(*__em1))
+                __vt = pointer_traits<const_pointer>::pointer_to(*__e);
+            __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
+            ++__base::size();
+            if (__de > 1)
+                __e = __move_backward_and_check(__e - __de, __em1, __e, __vt);
+            *--__e = *__vt;
+        }
+    }
+    return __base::begin() + __pos;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, value_type&& __v)
+{
+    size_type __pos = __p - __base::begin();
+    size_type __to_end = __base::size() - __pos;
+    allocator_type& __a = __base::__alloc();
+    if (__pos < __to_end)
+    {   // insert by shifting things backward
+        if (__front_spare() == 0)
+            __add_front_capacity();
+        // __front_spare() >= 1
+        if (__pos == 0)
+        {
+            __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::move(__v));
+            --__base::__start_;
+            ++__base::size();
+        }
+        else
+        {
+            iterator __b = __base::begin();
+            iterator __bm1 = _VSTD::prev(__b);
+            __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
+            --__base::__start_;
+            ++__base::size();
+            if (__pos > 1)
+                __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
+            *__b = _VSTD::move(__v);
+        }
+    }
+    else
+    {   // insert by shifting things forward
+        if (__back_spare() == 0)
+            __add_back_capacity();
+        // __back_capacity >= 1
+        size_type __de = __base::size() - __pos;
+        if (__de == 0)
+        {
+            __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::move(__v));
+            ++__base::size();
+        }
+        else
+        {
+            iterator __e = __base::end();
+            iterator __em1 = _VSTD::prev(__e);
+            __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
+            ++__base::size();
+            if (__de > 1)
+                __e = _VSTD::move_backward(__e - __de, __em1, __e);
+            *--__e = _VSTD::move(__v);
+        }
+    }
+    return __base::begin() + __pos;
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
+{
+    size_type __pos = __p - __base::begin();
+    size_type __to_end = __base::size() - __pos;
+    allocator_type& __a = __base::__alloc();
+    if (__pos < __to_end)
+    {   // insert by shifting things backward
+        if (__front_spare() == 0)
+            __add_front_capacity();
+        // __front_spare() >= 1
+        if (__pos == 0)
+        {
+            __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
+            --__base::__start_;
+            ++__base::size();
+        }
+        else
+        {
+            value_type __tmp(_VSTD::forward<_Args>(__args)...);
+            iterator __b = __base::begin();
+            iterator __bm1 = _VSTD::prev(__b);
+            __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
+            --__base::__start_;
+            ++__base::size();
+            if (__pos > 1)
+                __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
+            *__b = _VSTD::move(__tmp);
+        }
+    }
+    else
+    {   // insert by shifting things forward
+        if (__back_spare() == 0)
+            __add_back_capacity();
+        // __back_capacity >= 1
+        size_type __de = __base::size() - __pos;
+        if (__de == 0)
+        {
+            __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...);
+            ++__base::size();
+        }
+        else
+        {
+            value_type __tmp(_VSTD::forward<_Args>(__args)...);
+            iterator __e = __base::end();
+            iterator __em1 = _VSTD::prev(__e);
+            __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
+            ++__base::size();
+            if (__de > 1)
+                __e = _VSTD::move_backward(__e - __de, __em1, __e);
+            *--__e = _VSTD::move(__tmp);
+        }
+    }
+    return __base::begin() + __pos;
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_type& __v)
+{
+    size_type __pos = __p - __base::begin();
+    size_type __to_end = __base::size() - __pos;
+    allocator_type& __a = __base::__alloc();
+    if (__pos < __to_end)
+    {   // insert by shifting things backward
+        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)
+        {
+            for (size_type __m = __n - __pos; __m; --__m, --__base::__start_, ++__base::size())
+                __alloc_traits::construct(__a, _VSTD::addressof(*--__i), __v);
+            __n = __pos;
+        }
+        if (__n > 0)
+        {
+            const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+            iterator __obn = __old_begin + __n;
+            __move_construct_backward_and_check(__old_begin, __obn, __i, __vt);
+            if (__n < __pos)
+                __old_begin = __move_and_check(__obn, __old_begin + __pos, __old_begin, __vt);
+            _VSTD::fill_n(__old_begin, __n, *__vt);
+        }
+    }
+    else
+    {   // insert by shifting things forward
+        size_type __back_capacity = __back_spare();
+        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;
+        if (__n > __de)
+        {
+            for (size_type __m = __n - __de; __m; --__m, ++__i, ++__base::size())
+                __alloc_traits::construct(__a, _VSTD::addressof(*__i), __v);
+            __n = __de;
+        }
+        if (__n > 0)
+        {
+            const_pointer __vt = pointer_traits<const_pointer>::pointer_to(__v);
+            iterator __oen = __old_end - __n;
+            __move_construct_and_check(__oen, __old_end, __i, __vt);
+            if (__n < __de)
+                __old_end = __move_backward_and_check(__old_end - __de, __oen, __old_end, __vt);
+            _VSTD::fill_n(__old_end - __n, __n, *__vt);
+        }
+    }
+    return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+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*)
+{
+    __split_buffer<value_type, allocator_type&> __buf(__base::__alloc());
+    __buf.__construct_at_end(__f, __l);
+    typedef typename __split_buffer<value_type, allocator_type&>::iterator __bi;
+    return insert(__p, move_iterator<__bi>(__buf.begin()), move_iterator<__bi>(__buf.end()));
+}
+
+template <class _Tp, class _Allocator>
+template <class _BiIter>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
+                               typename enable_if<__is_bidirectional_iterator<_BiIter>::value>::type*)
+{
+    size_type __n = _VSTD::distance(__f, __l);
+    size_type __pos = __p - __base::begin();
+    size_type __to_end = __base::size() - __pos;
+    allocator_type& __a = __base::__alloc();
+    if (__pos < __to_end)
+    {   // insert by shifting things backward
+        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;
+        if (__n > __pos)
+        {
+            __m = __pos < __n / 2 ? _VSTD::prev(__l, __pos) : _VSTD::next(__f, __n - __pos);
+            for (_BiIter __j = __m; __j != __f; --__base::__start_, ++__base::size())
+                __alloc_traits::construct(__a, _VSTD::addressof(*--__i), *--__j);
+            __n = __pos;
+        }
+        if (__n > 0)
+        {
+            iterator __obn = __old_begin + __n;
+            for (iterator __j = __obn; __j != __old_begin;)
+            {
+                __alloc_traits::construct(__a, _VSTD::addressof(*--__i), _VSTD::move(*--__j));
+                --__base::__start_;
+                ++__base::size();
+            }
+            if (__n < __pos)
+                __old_begin = _VSTD::move(__obn, __old_begin + __pos, __old_begin);
+            _VSTD::copy(__m, __l, __old_begin);
+        }
+    }
+    else
+    {   // insert by shifting things forward
+        size_type __back_capacity = __back_spare();
+        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;
+        size_type __de = __base::size() - __pos;
+        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())
+                __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__j);
+            __n = __de;
+        }
+        if (__n > 0)
+        {
+            iterator __oen = __old_end - __n;
+            for (iterator __j = __oen; __j != __old_end; ++__i, ++__j, ++__base::size())
+                __alloc_traits::construct(__a, _VSTD::addressof(*__i), _VSTD::move(*__j));
+            if (__n < __de)
+                __old_end = _VSTD::move_backward(__old_end - __de, __oen, __old_end);
+            _VSTD::copy_backward(__f, __m, __old_end);
+        }
+    }
+    return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+template <class _InpIter>
+void
+deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
+                                 typename enable_if<__is_input_iterator<_InpIter>::value &&
+                                                   !__is_forward_iterator<_InpIter>::value>::type*)
+{
+    for (; __f != __l; ++__f)
+        push_back(*__f);
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForIter>
+void
+deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l,
+                                 typename enable_if<__is_forward_iterator<_ForIter>::value>::type*)
+{
+    size_type __n = _VSTD::distance(__f, __l);
+    allocator_type& __a = __base::__alloc();
+    size_type __back_capacity = __back_spare();
+    if (__n > __back_capacity)
+        __add_back_capacity(__n - __back_capacity);
+    // __n <= __back_capacity
+    for (iterator __i = __base::end(); __f != __l; ++__i, ++__f, ++__base::size())
+        __alloc_traits::construct(__a, _VSTD::addressof(*__i), *__f);
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__append(size_type __n)
+{
+    allocator_type& __a = __base::__alloc();
+    size_type __back_capacity = __back_spare();
+    if (__n > __back_capacity)
+        __add_back_capacity(__n - __back_capacity);
+    // __n <= __back_capacity
+    for (iterator __i = __base::end(); __n; --__n, ++__i, ++__base::size())
+        __alloc_traits::construct(__a, _VSTD::addressof(*__i));
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__append(size_type __n, const value_type& __v)
+{
+    allocator_type& __a = __base::__alloc();
+    size_type __back_capacity = __back_spare();
+    if (__n > __back_capacity)
+        __add_back_capacity(__n - __back_capacity);
+    // __n <= __back_capacity
+    for (iterator __i = __base::end(); __n; --__n, ++__i, ++__base::size())
+        __alloc_traits::construct(__a, _VSTD::addressof(*__i), __v);
+}
+
+// Create front capacity for one block of elements.
+// Strong guarantee.  Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_front_capacity()
+{
+    allocator_type& __a = __base::__alloc();
+    if (__back_spare() >= __base::__block_size)
+    {
+        __base::__start_ += __base::__block_size;
+        pointer __pt = __base::__map_.back();
+        __base::__map_.pop_back();
+        __base::__map_.push_front(__pt);
+    }
+    // Else if __base::__map_.size() < __base::__map_.capacity() then we need to allocate 1 buffer
+    else if (__base::__map_.size() < __base::__map_.capacity())
+    {   // we can put the new buffer into the map, but don't shift things around
+        // until all buffers are allocated.  If we throw, we don't need to fix
+        // anything up (any added buffers are undetectible)
+        if (__base::__map_.__front_spare() > 0)
+            __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+        else
+        {
+            __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+            // Done allocating, reorder capacity
+            pointer __pt = __base::__map_.back();
+            __base::__map_.pop_back();
+            __base::__map_.push_front(__pt);
+        }
+        __base::__start_ = __base::__map_.size() == 1 ?
+                               __base::__block_size / 2 :
+                               __base::__start_ + __base::__block_size;
+    }
+    // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
+    else
+    {
+        __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
+        for (typename __base::__map_pointer __i = __base::__map_.begin();
+                __i != __base::__map_.end(); ++__i)
+            __buf.push_back(*__i);
+        _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+        _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+        _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+        _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+        __base::__start_ = __base::__map_.size() == 1 ?
+                               __base::__block_size / 2 :
+                               __base::__start_ + __base::__block_size;
+    }
+}
+
+// Create front capacity for __n elements.
+// Strong guarantee.  Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_front_capacity(size_type __n)
+{
+    allocator_type& __a = __base::__alloc();
+    size_type __nb = __recommend_blocks(__n + __base::__map_.empty());
+    // Number of unused blocks at back:
+    size_type __back_capacity = __back_spare() / __base::__block_size;
+    __back_capacity = _VSTD::min(__back_capacity, __nb);  // don't take more than you need
+    __nb -= __back_capacity;  // number of blocks need to allocate
+    // If __nb == 0, then we have sufficient capacity.
+    if (__nb == 0)
+    {
+        __base::__start_ += __base::__block_size * __back_capacity;
+        for (; __back_capacity > 0; --__back_capacity)
+        {
+            pointer __pt = __base::__map_.back();
+            __base::__map_.pop_back();
+            __base::__map_.push_front(__pt);
+        }
+    }
+    // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
+    else if (__nb <= __base::__map_.capacity() - __base::__map_.size())
+    {   // we can put the new buffers into the map, but don't shift things around
+        // until all buffers are allocated.  If we throw, we don't need to fix
+        // anything up (any added buffers are undetectible)
+        for (; __nb > 0; --__nb, __base::__start_ += __base::__block_size - (__base::__map_.size() == 1))
+        {
+            if (__base::__map_.__front_spare() == 0)
+                break;
+            __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+        }
+        for (; __nb > 0; --__nb, ++__back_capacity)
+            __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+        // Done allocating, reorder capacity
+        __base::__start_ += __back_capacity * __base::__block_size;
+        for (; __back_capacity > 0; --__back_capacity)
+        {
+            pointer __pt = __base::__map_.back();
+            __base::__map_.pop_back();
+            __base::__map_.push_front(__pt);
+        }
+    }
+    // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
+    else
+    {
+        size_type __ds = (__nb + __back_capacity) * __base::__block_size - __base::__map_.empty();
+        __split_buffer<pointer, typename __base::__pointer_allocator&>
+            __buf(max<size_type>(2* __base::__map_.capacity(),
+                                 __nb + __base::__map_.size()),
+                  0, __base::__map_.__alloc());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __nb > 0; --__nb)
+                __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            for (typename __base::__map_pointer __i = __buf.begin();
+                    __i != __buf.end(); ++__i)
+                __alloc_traits::deallocate(__a, *__i, __base::__block_size);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        for (; __back_capacity > 0; --__back_capacity)
+        {
+            __buf.push_back(__base::__map_.back());
+            __base::__map_.pop_back();
+        }
+        for (typename __base::__map_pointer __i = __base::__map_.begin();
+                __i != __base::__map_.end(); ++__i)
+            __buf.push_back(*__i);
+        _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+        _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+        _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+        _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+        __base::__start_ += __ds;
+    }
+}
+
+// Create back capacity for one block of elements.
+// Strong guarantee.  Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_back_capacity()
+{
+    allocator_type& __a = __base::__alloc();
+    if (__front_spare() >= __base::__block_size)
+    {
+        __base::__start_ -= __base::__block_size;
+        pointer __pt = __base::__map_.front();
+        __base::__map_.pop_front();
+        __base::__map_.push_back(__pt);
+    }
+    // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
+    else if (__base::__map_.size() < __base::__map_.capacity())
+    {   // we can put the new buffer into the map, but don't shift things around
+        // until it is allocated.  If we throw, we don't need to fix
+        // anything up (any added buffers are undetectible)
+        if (__base::__map_.__back_spare() != 0)
+            __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+        else
+        {
+            __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+            // Done allocating, reorder capacity
+            pointer __pt = __base::__map_.front();
+            __base::__map_.pop_front();
+            __base::__map_.push_back(__pt);
+        }
+    }
+    // Else need to allocate 1 buffer, *and* we need to reallocate __map_.
+    else
+    {
+        __split_buffer<pointer, typename __base::__pointer_allocator&>
+            __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
+        for (typename __base::__map_pointer __i = __base::__map_.end();
+                __i != __base::__map_.begin();)
+            __buf.push_front(*--__i);
+        _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+        _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+        _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+        _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+    }
+}
+
+// Create back capacity for __n elements.
+// Strong guarantee.  Either do it or don't touch anything.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__add_back_capacity(size_type __n)
+{
+    allocator_type& __a = __base::__alloc();
+    size_type __nb = __recommend_blocks(__n + __base::__map_.empty());
+    // Number of unused blocks at front:
+    size_type __front_capacity = __front_spare() / __base::__block_size;
+    __front_capacity = _VSTD::min(__front_capacity, __nb);  // don't take more than you need
+    __nb -= __front_capacity;  // number of blocks need to allocate
+    // If __nb == 0, then we have sufficient capacity.
+    if (__nb == 0)
+    {
+        __base::__start_ -= __base::__block_size * __front_capacity;
+        for (; __front_capacity > 0; --__front_capacity)
+        {
+            pointer __pt = __base::__map_.front();
+            __base::__map_.pop_front();
+            __base::__map_.push_back(__pt);
+        }
+    }
+    // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers
+    else if (__nb <= __base::__map_.capacity() - __base::__map_.size())
+    {   // we can put the new buffers into the map, but don't shift things around
+        // until all buffers are allocated.  If we throw, we don't need to fix
+        // anything up (any added buffers are undetectible)
+        for (; __nb > 0; --__nb)
+        {
+            if (__base::__map_.__back_spare() == 0)
+                break;
+            __base::__map_.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+        }
+        for (; __nb > 0; --__nb, ++__front_capacity, __base::__start_ +=
+                                 __base::__block_size - (__base::__map_.size() == 1))
+            __base::__map_.push_front(__alloc_traits::allocate(__a, __base::__block_size));
+        // Done allocating, reorder capacity
+        __base::__start_ -= __base::__block_size * __front_capacity;
+        for (; __front_capacity > 0; --__front_capacity)
+        {
+            pointer __pt = __base::__map_.front();
+            __base::__map_.pop_front();
+            __base::__map_.push_back(__pt);
+        }
+    }
+    // Else need to allocate __nb buffers, *and* we need to reallocate __map_.
+    else
+    {
+        size_type __ds = __front_capacity * __base::__block_size;
+        __split_buffer<pointer, typename __base::__pointer_allocator&>
+            __buf(max<size_type>(2* __base::__map_.capacity(),
+                                 __nb + __base::__map_.size()),
+                  __base::__map_.size() - __front_capacity,
+                  __base::__map_.__alloc());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __nb > 0; --__nb)
+                __buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            for (typename __base::__map_pointer __i = __buf.begin();
+                    __i != __buf.end(); ++__i)
+                __alloc_traits::deallocate(__a, *__i, __base::__block_size);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        for (; __front_capacity > 0; --__front_capacity)
+        {
+            __buf.push_back(__base::__map_.front());
+            __base::__map_.pop_front();
+        }
+        for (typename __base::__map_pointer __i = __base::__map_.end();
+                __i != __base::__map_.begin();)
+            __buf.push_front(*--__i);
+        _VSTD::swap(__base::__map_.__first_, __buf.__first_);
+        _VSTD::swap(__base::__map_.__begin_, __buf.__begin_);
+        _VSTD::swap(__base::__map_.__end_, __buf.__end_);
+        _VSTD::swap(__base::__map_.__end_cap(), __buf.__end_cap());
+        __base::__start_ -= __ds;
+    }
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::pop_front()
+{
+    allocator_type& __a = __base::__alloc();
+    __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
+                                                    __base::__start_ / __base::__block_size) +
+                                                    __base::__start_ % __base::__block_size));
+    --__base::size();
+    if (++__base::__start_ >= 2 * __base::__block_size)
+    {
+        __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size);
+        __base::__map_.pop_front();
+        __base::__start_ -= __base::__block_size;
+    }
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::pop_back()
+{
+    allocator_type& __a = __base::__alloc();
+    size_type __p = __base::size() + __base::__start_ - 1;
+    __alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
+                                                    __p / __base::__block_size) +
+                                                    __p % __base::__block_size));
+    --__base::size();
+    if (__back_spare() >= 2 * __base::__block_size)
+    {
+        __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
+        __base::__map_.pop_back();
+    }
+}
+
+// move assign [__f, __l) to [__r, __r + (__l-__f)).
+// If __vt points into [__f, __l), then subtract (__f - __r) from __vt.
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __r,
+                                         const_pointer& __vt)
+{
+    // as if
+    //   for (; __f != __l; ++__f, ++__r)
+    //       *__r = _VSTD::move(*__f);
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        pointer __fb = __f.__ptr_;
+        pointer __fe = *__f.__m_iter_ + __base::__block_size;
+        difference_type __bs = __fe - __fb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __fe = __fb + __bs;
+        }
+        if (__fb <= __vt && __vt < __fe)
+            __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) -= __f - __r).__ptr_;
+        __r = _VSTD::move(__fb, __fe, __r);
+        __n -= __bs;
+        __f += __bs;
+    }
+    return __r;
+}
+
+// move assign [__f, __l) to [__r - (__l-__f), __r) backwards.
+// If __vt points into [__f, __l), then add (__r - __l) to __vt.
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::__move_backward_and_check(iterator __f, iterator __l, iterator __r,
+                                                  const_pointer& __vt)
+{
+    // as if
+    //   while (__f != __l)
+    //       *--__r = _VSTD::move(*--__l);
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        --__l;
+        pointer __lb = *__l.__m_iter_;
+        pointer __le = __l.__ptr_ + 1;
+        difference_type __bs = __le - __lb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __lb = __le - __bs;
+        }
+        if (__lb <= __vt && __vt < __le)
+            __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) += __r - __l - 1).__ptr_;
+        __r = _VSTD::move_backward(__lb, __le, __r);
+        __n -= __bs;
+        __l -= __bs - 1;
+    }
+    return __r;
+}
+
+// move construct [__f, __l) to [__r, __r + (__l-__f)).
+// If __vt points into [__f, __l), then add (__r - __f) to __vt.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator __l,
+                                                   iterator __r, const_pointer& __vt)
+{
+    allocator_type& __a = __base::__alloc();
+    // as if
+    //   for (; __f != __l; ++__r, ++__f, ++__base::size())
+    //       __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__f));
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        pointer __fb = __f.__ptr_;
+        pointer __fe = *__f.__m_iter_ + __base::__block_size;
+        difference_type __bs = __fe - __fb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __fe = __fb + __bs;
+        }
+        if (__fb <= __vt && __vt < __fe)
+            __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_;
+        for (; __fb != __fe; ++__fb, ++__r, ++__base::size())
+            __alloc_traits::construct(__a, _VSTD::addressof(*__r), _VSTD::move(*__fb));
+        __n -= __bs;
+        __f += __bs;
+    }
+}
+
+// move construct [__f, __l) to [__r - (__l-__f), __r) backwards.
+// If __vt points into [__f, __l), then subtract (__l - __r) from __vt.
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__move_construct_backward_and_check(iterator __f, iterator __l,
+                                                            iterator __r, const_pointer& __vt)
+{
+    allocator_type& __a = __base::__alloc();
+    // as if
+    //   for (iterator __j = __l; __j != __f;)
+    //   {
+    //       __alloc_traitsconstruct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__j));
+    //       --__base::__start_;
+    //       ++__base::size();
+    //   }
+    difference_type __n = __l - __f;
+    while (__n > 0)
+    {
+        --__l;
+        pointer __lb = *__l.__m_iter_;
+        pointer __le = __l.__ptr_ + 1;
+        difference_type __bs = __le - __lb;
+        if (__bs > __n)
+        {
+            __bs = __n;
+            __lb = __le - __bs;
+        }
+        if (__lb <= __vt && __vt < __le)
+            __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) -= __l - __r + 1).__ptr_;
+        while (__le != __lb)
+        {
+            __alloc_traits::construct(__a, _VSTD::addressof(*--__r), _VSTD::move(*--__le));
+            --__base::__start_;
+            ++__base::size();
+        }
+        __n -= __bs;
+        __l -= __bs - 1;
+    }
+}
+
+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)
+    {   // erase from front
+        _VSTD::move_backward(__b, __p, _VSTD::next(__p));
+        __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
+        --__base::size();
+        ++__base::__start_;
+        if (__front_spare() >= 2 * __base::__block_size)
+        {
+            __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size);
+            __base::__map_.pop_front();
+            __base::__start_ -= __base::__block_size;
+        }
+    }
+    else
+    {   // erase from back
+        iterator __i = _VSTD::move(_VSTD::next(__p), __base::end(), __p);
+        __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
+        --__base::size();
+        if (__back_spare() >= 2 * __base::__block_size)
+        {
+            __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
+            __base::__map_.pop_back();
+        }
+    }
+    return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+typename deque<_Tp, _Allocator>::iterator
+deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
+{
+    difference_type __n = __l - __f;
+    iterator __b = __base::begin();
+    difference_type __pos = __f - __b;
+    iterator __p = __b + __pos;
+    if (__n > 0)
+    {
+        allocator_type& __a = __base::__alloc();
+        if (__pos < (__base::size() - __n) / 2)
+        {   // erase from front
+            iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
+            for (; __b != __i; ++__b)
+                __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
+            __base::size() -= __n;
+            __base::__start_ += __n;
+            while (__front_spare() >= 2 * __base::__block_size)
+            {
+                __alloc_traits::deallocate(__a, __base::__map_.front(), __base::__block_size);
+                __base::__map_.pop_front();
+                __base::__start_ -= __base::__block_size;
+            }
+        }
+        else
+        {   // erase from back
+            iterator __i = _VSTD::move(__p + __n, __base::end(), __p);
+            for (iterator __e = __base::end(); __i != __e; ++__i)
+                __alloc_traits::destroy(__a, _VSTD::addressof(*__i));
+            __base::size() -= __n;
+            while (__back_spare() >= 2 * __base::__block_size)
+            {
+                __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
+                __base::__map_.pop_back();
+            }
+        }
+    }
+    return __base::begin() + __pos;
+}
+
+template <class _Tp, class _Allocator>
+void
+deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f)
+{
+    iterator __e = __base::end();
+    difference_type __n = __e - __f;
+    if (__n > 0)
+    {
+        allocator_type& __a = __base::__alloc();
+        iterator __b = __base::begin();
+        difference_type __pos = __f - __b;
+        for (iterator __p = __b + __pos; __p != __e; ++__p)
+            __alloc_traits::destroy(__a, _VSTD::addressof(*__p));
+        __base::size() -= __n;
+        while (__back_spare() >= 2 * __base::__block_size)
+        {
+            __alloc_traits::deallocate(__a, __base::__map_.back(), __base::__block_size);
+            __base::__map_.pop_back();
+        }
+    }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+deque<_Tp, _Allocator>::swap(deque& __c)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<allocator_type>::value)
+{
+    __base::swap(__c);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+deque<_Tp, _Allocator>::clear() _NOEXCEPT
+{
+    __base::clear();
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+    const typename deque<_Tp, _Allocator>::size_type __sz = __x.size();
+    return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_DEQUE
diff --git a/final/include/exception b/final/include/exception
new file mode 100644
index 0000000..cad802e
--- /dev/null
+++ b/final/include/exception
@@ -0,0 +1,250 @@
+// -*- C++ -*-
+//===-------------------------- exception ---------------------------------===//
+//
+//                     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_EXCEPTION
+#define _LIBCPP_EXCEPTION
+
+/*
+    exception synopsis
+
+namespace std
+{
+
+class exception
+{
+public:
+    exception() noexcept;
+    exception(const exception&) noexcept;
+    exception& operator=(const exception&) noexcept;
+    virtual ~exception() noexcept;
+    virtual const char* what() const noexcept;
+};
+
+class bad_exception
+    : public exception
+{
+public:
+    bad_exception() noexcept;
+    bad_exception(const bad_exception&) noexcept;
+    bad_exception& operator=(const bad_exception&) noexcept;
+    virtual ~bad_exception() noexcept;
+    virtual const char* what() const noexcept;
+};
+
+typedef void (*unexpected_handler)();
+unexpected_handler set_unexpected(unexpected_handler  f ) noexcept;
+unexpected_handler get_unexpected() noexcept;
+[[noreturn]] void unexpected();
+
+typedef void (*terminate_handler)();
+terminate_handler set_terminate(terminate_handler  f ) noexcept;
+terminate_handler get_terminate() noexcept;
+[[noreturn]] void terminate() noexcept;
+
+bool uncaught_exception() noexcept;
+
+typedef unspecified exception_ptr;
+
+exception_ptr current_exception() noexcept;
+void rethrow_exception [[noreturn]] (exception_ptr p);
+template<class E> exception_ptr make_exception_ptr(E e) noexcept;
+
+class nested_exception
+{
+public:
+    nested_exception() noexcept;
+    nested_exception(const nested_exception&) noexcept = default;
+    nested_exception& operator=(const nested_exception&) noexcept = default;
+    virtual ~nested_exception() = default;
+
+    // access functions
+    [[noreturn]] void rethrow_nested() const;
+    exception_ptr nested_ptr() const noexcept;
+};
+
+template <class T> [[noreturn]] void throw_with_nested(T&& t);
+template <class E> void rethrow_if_nested(const E& e);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <cstddef>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+namespace std  // purposefully not using versioning namespace
+{
+
+class _LIBCPP_EXCEPTION_ABI exception
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
+    virtual ~exception() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_exception
+    : public exception
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
+    virtual ~bad_exception() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+typedef void (*unexpected_handler)();
+_LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT;
+_LIBCPP_FUNC_VIS unexpected_handler get_unexpected() _NOEXCEPT;
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void unexpected();
+
+typedef void (*terminate_handler)();
+_LIBCPP_FUNC_VIS terminate_handler set_terminate(terminate_handler) _NOEXCEPT;
+_LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT;
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT;
+
+_LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT;
+
+class _LIBCPP_TYPE_VIS exception_ptr;
+
+_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
+
+class _LIBCPP_TYPE_VIS exception_ptr
+{
+    void* __ptr_;
+public:
+    _LIBCPP_INLINE_VISIBILITY exception_ptr() _NOEXCEPT : __ptr_() {}
+    _LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
+    exception_ptr(const exception_ptr&) _NOEXCEPT;
+    exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
+    ~exception_ptr() _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_EXPLICIT
+        operator bool() const _NOEXCEPT {return __ptr_ != nullptr;}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
+        {return __x.__ptr_ == __y.__ptr_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT
+        {return !(__x == __y);}
+
+    friend _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT;
+    friend _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr);
+};
+
+template<class _Ep>
+exception_ptr
+make_exception_ptr(_Ep __e) _NOEXCEPT
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+        throw __e;
+    }
+    catch (...)
+    {
+        return current_exception();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+// nested_exception
+
+class _LIBCPP_EXCEPTION_ABI nested_exception
+{
+    exception_ptr __ptr_;
+public:
+    nested_exception() _NOEXCEPT;
+//     nested_exception(const nested_exception&) noexcept = default;
+//     nested_exception& operator=(const nested_exception&) noexcept = default;
+    virtual ~nested_exception() _NOEXCEPT;
+
+    // access functions
+    _LIBCPP_NORETURN void rethrow_nested() const;
+    _LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const _NOEXCEPT {return __ptr_;}
+};
+
+template <class _Tp>
+struct __nested
+    : public _Tp,
+      public nested_exception
+{
+    _LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {}
+};
+
+template <class _Tp>
+_LIBCPP_NORETURN
+void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+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
+                                    >::type* = 0)
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+throw_with_nested (_Tp& __t, typename enable_if<
+                  is_class<_Tp>::value && !is_base_of<nested_exception, _Tp>::value
+                                    >::type* = 0)
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw __nested<typename remove_reference<_Tp>::type>(_VSTD::forward<_Tp>(__t));
+#endif
+}
+
+template <class _Tp>
+_LIBCPP_NORETURN
+void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+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
+                                    >::type* = 0)
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+throw_with_nested (_Tp& __t, typename enable_if<
+                  !is_class<_Tp>::value || is_base_of<nested_exception, _Tp>::value
+                                    >::type* = 0)
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw _VSTD::forward<_Tp>(__t);
+#endif
+}
+
+template <class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+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);
+    if (__nep)
+        __nep->rethrow_nested();
+}
+
+template <class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+rethrow_if_nested(const _Ep&, typename enable_if<
+                                   !is_polymorphic<_Ep>::value
+                                                   >::type* = 0)
+{
+}
+
+}  // std
+
+#endif  // _LIBCPP_EXCEPTION
diff --git a/final/include/experimental/__config b/final/include/experimental/__config
new file mode 100644
index 0000000..684a3b4
--- /dev/null
+++ b/final/include/experimental/__config
@@ -0,0 +1,24 @@
+// -*- C++ -*-
+//===--------------------------- __config ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_CONFIG
+#define _LIBCPP_EXPERIMENTAL_CONFIG
+
+#include <__config>
+
+#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {
+#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL  } }
+#define _VSTD_EXPERIMENTAL std::experimental
+
+#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
+#define _LIBCPP_END_NAMESPACE_LFTS  } } }
+#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
+
+#endif
diff --git a/final/include/experimental/dynarray b/final/include/experimental/dynarray
new file mode 100644
index 0000000..d2a4298
--- /dev/null
+++ b/final/include/experimental/dynarray
@@ -0,0 +1,314 @@
+// -*- C++ -*-
+//===-------------------------- dynarray ----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_DYNARRAY
+#define _LIBCPP_DYNARRAY
+
+#include <__config>
+#if _LIBCPP_STD_VER > 11
+
+/*
+    dynarray synopsis
+
+namespace std { namespace experimental {
+
+template< typename T >
+class dynarray
+{
+    // types:
+    typedef       T                               value_type;
+    typedef       T&                              reference;
+    typedef const T&                              const_reference;
+    typedef       T*                              pointer;
+    typedef const T*                              const_pointer;
+    typedef       implementation-defined          iterator;
+    typedef       implementation-defined          const_iterator;
+    typedef reverse_iterator<iterator>            reverse_iterator;
+    typedef reverse_iterator<const_iterator>      const_reverse_iterator;
+    typedef size_t                                size_type;
+    typedef ptrdiff_t                             difference_type;
+
+public:
+    // construct/copy/destroy:
+    explicit dynarray(size_type c);
+    template <typename Alloc>
+      dynarray(size_type c, const Alloc& alloc);
+    dynarray(size_type c, const T& v);
+    template <typename Alloc>
+      dynarray(size_type c, const T& v, const Alloc& alloc);
+    dynarray(const dynarray& d);
+    template <typename Alloc>
+      dynarray(const dynarray& d, const Alloc& alloc);
+    dynarray(initializer_list<T>);
+    template <typename Alloc>
+      dynarray(initializer_list<T>, const Alloc& alloc);
+
+    dynarray& operator=(const dynarray&) = delete;
+    ~dynarray();
+
+    // iterators:
+    iterator       begin()        noexcept;
+    const_iterator begin()  const noexcept;
+    const_iterator cbegin() const noexcept;
+    iterator       end()          noexcept;
+    const_iterator end()    const noexcept;
+    const_iterator cend()   const noexcept;
+
+    reverse_iterator       rbegin()        noexcept;
+    const_reverse_iterator rbegin()  const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    reverse_iterator       rend()          noexcept;
+    const_reverse_iterator rend()    const noexcept;
+    const_reverse_iterator crend()   const noexcept;
+
+    // capacity:
+    size_type size()     const noexcept;
+    size_type max_size() const noexcept;
+    bool      empty()    const noexcept;
+
+    // element access:
+    reference       operator[](size_type n);
+    const_reference operator[](size_type n) const;
+
+    reference       front();
+    const_reference front() const;
+    reference       back();
+    const_reference back()  const;
+
+    const_reference at(size_type n) const;
+    reference       at(size_type n);
+
+    // data access:
+    T*       data()       noexcept;
+    const T* data() const noexcept;
+
+    // mutating member functions:
+    void fill(const T& v);
+};
+
+}}  // std::experimental
+
+*/
+
+#include <__functional_base>
+#include <iterator>
+#include <stdexcept>
+#include <initializer_list>
+#include <new>
+#include <algorithm>
+
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+    #include <cassert>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+namespace std { namespace experimental { inline namespace __array_extensions_v1 {
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY dynarray
+{
+public:
+    // types:
+    typedef dynarray __self;
+    typedef _Tp                                   value_type;
+    typedef value_type&                           reference;
+    typedef const value_type&                     const_reference;
+    typedef value_type*                           iterator;
+    typedef const value_type*                     const_iterator;
+    typedef value_type*                           pointer;
+    typedef const value_type*                     const_pointer;
+    typedef size_t                                size_type;
+    typedef ptrdiff_t                             difference_type;
+    typedef std::reverse_iterator<iterator>       reverse_iterator;
+    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+private:
+    size_t                  __size_;
+    value_type *            __base_;
+    _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {}
+    
+    static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
+    {
+        if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
+        {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw bad_array_length();
+#else
+            assert(!"dynarray::allocation");
+#endif
+        }
+        return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
+    }
+
+    static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept
+    {
+        _VSTD::__deallocate (static_cast<void *> (__ptr));
+    }
+
+public:
+
+    explicit dynarray(size_type __c);
+    dynarray(size_type __c, const value_type& __v);
+    dynarray(const dynarray& __d);
+    dynarray(initializer_list<value_type>);
+
+//  We're not implementing these right now.
+//  Waiting for the resolution of LWG issue #2235
+//     template <typename _Alloc>
+//       dynarray(size_type __c, const _Alloc& __alloc);
+//     template <typename _Alloc>
+//       dynarray(size_type __c, const value_type& __v, const _Alloc& __alloc);
+//     template <typename _Alloc>
+//       dynarray(const dynarray& __d, const _Alloc& __alloc);
+//     template <typename _Alloc>
+//       dynarray(initializer_list<value_type>, const _Alloc& __alloc);
+
+    dynarray& operator=(const dynarray&) = delete;
+    ~dynarray();
+
+    // iterators:
+    inline _LIBCPP_INLINE_VISIBILITY iterator       begin()        noexcept { return iterator(data()); }
+    inline _LIBCPP_INLINE_VISIBILITY const_iterator begin()  const noexcept { return const_iterator(data()); }
+    inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); }
+    inline _LIBCPP_INLINE_VISIBILITY iterator       end()          noexcept { return iterator(data() + __size_); }
+    inline _LIBCPP_INLINE_VISIBILITY const_iterator end()    const noexcept { return const_iterator(data() + __size_); }
+    inline _LIBCPP_INLINE_VISIBILITY const_iterator cend()   const noexcept { return const_iterator(data() + __size_); }
+
+    inline _LIBCPP_INLINE_VISIBILITY reverse_iterator       rbegin()        noexcept { return reverse_iterator(end()); }
+    inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin()  const noexcept { return const_reverse_iterator(end()); }
+    inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
+    inline _LIBCPP_INLINE_VISIBILITY reverse_iterator       rend()          noexcept { return reverse_iterator(begin()); }
+    inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend()    const noexcept { return const_reverse_iterator(begin()); }
+    inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend()   const noexcept { return const_reverse_iterator(begin()); }
+
+    // capacity:
+    inline _LIBCPP_INLINE_VISIBILITY size_type size()     const noexcept { return __size_; }
+    inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; }
+    inline _LIBCPP_INLINE_VISIBILITY bool      empty()    const noexcept { return __size_ == 0; }
+
+    // element access:
+    inline _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __n)       { return data()[__n]; }
+    inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; }
+
+    inline _LIBCPP_INLINE_VISIBILITY reference       front()       { return data()[0]; }
+    inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; }
+    inline _LIBCPP_INLINE_VISIBILITY reference       back()        { return data()[__size_-1]; }
+    inline _LIBCPP_INLINE_VISIBILITY const_reference back()  const { return data()[__size_-1]; }
+
+    inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const;
+    inline _LIBCPP_INLINE_VISIBILITY reference       at(size_type __n);
+
+    // data access:
+    inline _LIBCPP_INLINE_VISIBILITY _Tp*       data()       noexcept { return __base_; }
+    inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; }
+
+    // mutating member functions:
+    inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); }
+};
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(size_type __c) : dynarray ()
+{
+    __base_ = __allocate (__c);
+    value_type *__data = data ();
+    for ( __size_ = 0; __size_ < __c; ++__size_, ++__data )
+        ::new (__data) value_type;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray ()
+{
+    __base_ = __allocate (__c);
+    value_type *__data = data ();
+    for ( __size_ = 0; __size_ < __c; ++__size_, ++__data )
+        ::new (__data) value_type (__v);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray ()
+{
+    size_t sz = __il.size();
+    __base_ = __allocate (sz);
+    value_type *__data = data ();
+    auto src = __il.begin();
+    for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src )
+        ::new (__data) value_type (*src);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray ()
+{
+    size_t sz = __d.size();
+    __base_ = __allocate (sz);
+    value_type *__data = data ();
+    auto src = __d.begin();
+    for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src )
+        ::new (__data) value_type (*src);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::~dynarray()
+{ 
+    value_type *__data = data () + __size_;
+    for ( size_t i = 0; i < __size_; ++i )
+        (--__data)->value_type::~value_type();
+    __deallocate ( __base_ );
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename dynarray<_Tp>::reference
+dynarray<_Tp>::at(size_type __n)
+{
+    if (__n >= __size_)
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("dynarray::at");
+#else
+        assert(!"dynarray::at out_of_range");
+#endif
+    }
+    return data()[__n];
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename dynarray<_Tp>::const_reference
+dynarray<_Tp>::at(size_type __n) const
+{
+    if (__n >= __size_)
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw out_of_range("dynarray::at");
+#else
+        assert(!"dynarray::at out_of_range");
+#endif
+    }
+    return data()[__n];
+}
+
+}}}
+
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Tp, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {};
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // if _LIBCPP_STD_VER > 11 
+#endif  // _LIBCPP_DYNARRAY
diff --git a/final/include/experimental/optional b/final/include/experimental/optional
new file mode 100644
index 0000000..3848da8
--- /dev/null
+++ b/final/include/experimental/optional
@@ -0,0 +1,699 @@
+// -*- C++ -*-
+//===-------------------------- optional ----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_OPTIONAL
+#define _LIBCPP_OPTIONAL
+
+/*
+    optional synopsis
+
+// C++1y
+
+#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
+
+*/
+
+#include <__config>
+#include <functional>
+#include <stdexcept>
+
+namespace std { namespace experimental {
+
+class _LIBCPP_EXCEPTION_ABI bad_optional_access
+    : public 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
+    virtual ~bad_optional_access() _NOEXCEPT;
+};
+
+}}  // std::experimental
+
+#if _LIBCPP_STD_VER > 11
+
+#include <initializer_list>
+#include <type_traits>
+#include <new>
+#include <__functional_base>
+
+#include <__undef_min_max>
+
+#ifdef _LIBCPP_DEBUG
+#   include <__debug>
+#else
+#   define _LIBCPP_ASSERT(x, m) ((void)0)
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+namespace std { namespace experimental { inline namespace __library_fundamentals_v1 {
+
+struct in_place_t {};
+constexpr in_place_t in_place{};
+
+struct nullopt_t
+{
+    explicit constexpr nullopt_t(int) noexcept {}
+};
+
+constexpr nullopt_t nullopt{0};
+
+template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
+class __optional_storage
+{
+protected:
+    typedef _Tp value_type;
+    union
+    {
+        char __null_state_;
+        value_type __val_;
+    };
+    bool __engaged_ = false;
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__optional_storage()
+    {
+        if (__engaged_)
+            __val_.~value_type();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr __optional_storage() noexcept
+        :  __null_state_('\0') {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __optional_storage(const __optional_storage& __x)
+        :  __engaged_(__x.__engaged_)
+        {
+            if (__engaged_)
+                ::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __optional_storage(__optional_storage&& __x)
+                      noexcept(is_nothrow_move_constructible<value_type>::value)
+        :  __engaged_(__x.__engaged_)
+        {
+            if (__engaged_)
+                ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr __optional_storage(const value_type& __v)
+        :  __val_(__v),
+           __engaged_(true) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr __optional_storage(value_type&& __v)
+        :  __val_(_VSTD::move(__v)),
+           __engaged_(true) {}
+
+    template <class... _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    explicit __optional_storage(in_place_t, _Args&&... __args)
+       :  __val_(_VSTD::forward<_Args>(__args)...),
+           __engaged_(true) {}
+};
+
+template <class _Tp>
+class __optional_storage<_Tp, true>
+{
+protected:
+    typedef _Tp value_type;
+    union
+    {
+        char __null_state_;
+        value_type __val_;
+    };
+    bool __engaged_ = false;
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr __optional_storage() noexcept
+        :  __null_state_('\0') {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __optional_storage(const __optional_storage& __x)
+        :  __engaged_(__x.__engaged_)
+        {
+            if (__engaged_)
+                ::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __optional_storage(__optional_storage&& __x)
+                      noexcept(is_nothrow_move_constructible<value_type>::value)
+        :  __engaged_(__x.__engaged_)
+        {
+            if (__engaged_)
+                ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr __optional_storage(const value_type& __v)
+        :  __val_(__v),
+           __engaged_(true) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr __optional_storage(value_type&& __v)
+        :  __val_(_VSTD::move(__v)),
+           __engaged_(true) {}
+
+    template <class... _Args>
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    explicit __optional_storage(in_place_t, _Args&&... __args)
+       :  __val_(_VSTD::forward<_Args>(__args)...),
+           __engaged_(true) {}
+};
+
+template <class _Tp>
+class optional
+    : private __optional_storage<_Tp>
+{
+    typedef __optional_storage<_Tp> __base;
+public:
+    typedef _Tp value_type;
+
+    static_assert(!is_reference<value_type>::value,
+              "Instantiation of optional with a reference type is ill-formed.");
+    static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value,
+              "Instantiation of optional with a in_place_t type is ill-formed.");
+    static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value,
+              "Instantiation of optional with a nullopt_t type is ill-formed.");
+    static_assert(is_object<value_type>::value,
+        "Instantiation of optional with a non-object type is undefined behavior.");
+    static_assert(is_nothrow_destructible<value_type>::value,
+        "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior.");
+
+    _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
+    _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
+    _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
+    _LIBCPP_INLINE_VISIBILITY ~optional() = default;
+    _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
+    _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v)
+        : __base(__v) {}
+    _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v)
+        : __base(_VSTD::move(__v)) {}
+
+    template <class... _Args,
+              class = typename enable_if
+                      <
+                           is_constructible<value_type, _Args...>::value
+                      >::type
+             >
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    explicit optional(in_place_t, _Args&&... __args)
+        : __base(in_place, _VSTD::forward<_Args>(__args)...) {}
+
+    template <class _Up, class... _Args,
+              class = typename enable_if
+                      <
+                           is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
+                      >::type
+             >
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
+        : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    optional& operator=(nullopt_t) noexcept
+    {
+        if (this->__engaged_)
+        {
+            this->__val_.~value_type();
+            this->__engaged_ = false;
+        }
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    optional&
+    operator=(const optional& __opt)
+    {
+        if (this->__engaged_ == __opt.__engaged_)
+        {
+            if (this->__engaged_)
+                this->__val_ = __opt.__val_;
+        }
+        else
+        {
+            if (this->__engaged_)
+                this->__val_.~value_type();
+            else
+                ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
+            this->__engaged_ = __opt.__engaged_;
+        }
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    optional&
+    operator=(optional&& __opt)
+        noexcept(is_nothrow_move_assignable<value_type>::value &&
+                 is_nothrow_move_constructible<value_type>::value)
+    {
+        if (this->__engaged_ == __opt.__engaged_)
+        {
+            if (this->__engaged_)
+                this->__val_ = _VSTD::move(__opt.__val_);
+        }
+        else
+        {
+            if (this->__engaged_)
+                this->__val_.~value_type();
+            else
+                ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_));
+            this->__engaged_ = __opt.__engaged_;
+        }
+        return *this;
+    }
+
+    template <class _Up,
+              class = typename enable_if
+                      <
+                          is_same<typename remove_reference<_Up>::type, value_type>::value &&
+                          is_constructible<value_type, _Up>::value &&
+                          is_assignable<value_type&, _Up>::value
+                      >::type
+             >
+    _LIBCPP_INLINE_VISIBILITY
+    optional&
+    operator=(_Up&& __v)
+    {
+        if (this->__engaged_)
+            this->__val_ = _VSTD::forward<_Up>(__v);
+        else
+        {
+            ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v));
+            this->__engaged_ = true;
+        }
+        return *this;
+    }
+
+    template <class... _Args,
+              class = typename enable_if
+                      <
+                          is_constructible<value_type, _Args...>::value
+                      >::type
+             >
+    _LIBCPP_INLINE_VISIBILITY
+    void
+    emplace(_Args&&... __args)
+    {
+        *this = nullopt;
+        ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...);
+        this->__engaged_ = true;
+    }
+
+    template <class _Up, class... _Args,
+              class = typename enable_if
+                      <
+                          is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
+                      >::type
+             >
+    _LIBCPP_INLINE_VISIBILITY
+    void
+    emplace(initializer_list<_Up> __il, _Args&&... __args)
+    {
+        *this = nullopt;
+        ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...);
+        this->__engaged_ = true;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void
+    swap(optional& __opt)
+        noexcept(is_nothrow_move_constructible<value_type>::value &&
+                 __is_nothrow_swappable<value_type>::value)
+    {
+        using _VSTD::swap;
+        if (this->__engaged_ == __opt.__engaged_)
+        {
+            if (this->__engaged_)
+                swap(this->__val_, __opt.__val_);
+        }
+        else
+        {
+            if (this->__engaged_)
+            {
+                ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_));
+                this->__val_.~value_type();
+            }
+            else
+            {
+                ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_));
+                __opt.__val_.~value_type();
+            }
+            swap(this->__engaged_, __opt.__engaged_);
+        }
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    value_type const*
+    operator->() const
+    {
+        _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
+        return __operator_arrow(__has_operator_addressof<value_type>{});
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type*
+    operator->()
+    {
+        _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
+        return _VSTD::addressof(this->__val_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    const value_type&
+    operator*() const
+    {
+        _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
+        return this->__val_;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type&
+    operator*()
+    {
+        _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
+        return this->__val_;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr explicit operator bool() const noexcept {return this->__engaged_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr value_type const& value() const
+    {
+        if (!this->__engaged_)
+            throw bad_optional_access("optional<T>::value: not engaged");
+        return this->__val_;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type& value()
+    {
+        if (!this->__engaged_)
+            throw bad_optional_access("optional<T>::value: not engaged");
+        return this->__val_;
+    }
+
+    template <class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr value_type value_or(_Up&& __v) const&
+    {
+        static_assert(is_copy_constructible<value_type>::value,
+                      "optional<T>::value_or: T must be copy constructible");
+        static_assert(is_convertible<_Up, value_type>::value,
+                      "optional<T>::value_or: U must be convertible to T");
+        return this->__engaged_ ? this->__val_ :
+                                  static_cast<value_type>(_VSTD::forward<_Up>(__v));
+    }
+
+    template <class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+    value_type value_or(_Up&& __v) &&
+    {
+        static_assert(is_move_constructible<value_type>::value,
+                      "optional<T>::value_or: T must be move constructible");
+        static_assert(is_convertible<_Up, value_type>::value,
+                      "optional<T>::value_or: U must be convertible to T");
+        return this->__engaged_ ? _VSTD::move(this->__val_) :
+                                  static_cast<value_type>(_VSTD::forward<_Up>(__v));
+    }
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    value_type const*
+    __operator_arrow(true_type) const
+    {
+        return _VSTD::addressof(this->__val_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    value_type const*
+    __operator_arrow(false_type) const
+    {
+        return &this->__val_;
+    }
+};
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+    if (static_cast<bool>(__x) != static_cast<bool>(__y))
+        return false;
+    if (!static_cast<bool>(__x))
+        return true;
+    return *__x == *__y;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
+{
+    if (!static_cast<bool>(__y))
+        return false;
+    if (!static_cast<bool>(__x))
+        return true;
+    return less<_Tp>{}(*__x, *__y);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const optional<_Tp>& __x, nullopt_t) noexcept
+{
+    return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+    return !static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const optional<_Tp>&, nullopt_t) noexcept
+{
+    return false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(nullopt_t, const optional<_Tp>& __x) noexcept
+{
+    return static_cast<bool>(__x);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const optional<_Tp>& __x, const _Tp& __v)
+{
+    return static_cast<bool>(__x) ? *__x == __v : false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator==(const _Tp& __v, const optional<_Tp>& __x)
+{
+    return static_cast<bool>(__x) ? *__x == __v : false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const optional<_Tp>& __x, const _Tp& __v)
+{
+    return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+bool
+operator<(const _Tp& __v, const optional<_Tp>& __x)
+{
+    return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr
+optional<typename decay<_Tp>::type>
+make_optional(_Tp&& __v)
+{
+    return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
+}
+
+}}}  // namespace std::experimental::__library_fundamentals_v1
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::optional<_Tp> >
+{
+    typedef std::experimental::optional<_Tp> argument_type;
+    typedef size_t        result_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator()(const argument_type& __opt) const _NOEXCEPT
+    {
+        return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0;
+    }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_STD_VER > 11
+
+#endif  // _LIBCPP_ARRAY
diff --git a/final/include/experimental/string_view b/final/include/experimental/string_view
new file mode 100644
index 0000000..c38548b
--- /dev/null
+++ b/final/include/experimental/string_view
@@ -0,0 +1,814 @@
+// -*- C++ -*-
+//===------------------------ string_view ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_LFTS_STRING_VIEW
+#define _LIBCPP_LFTS_STRING_VIEW
+
+/*
+string_view synopsis
+
+namespace std {
+ namespace experimental {
+  inline namespace library_fundamentals_v1 {
+
+    // 7.2, Class template basic_string_view
+    template<class charT, class traits = char_traits<charT>>
+        class basic_string_view;
+
+    // 7.9, basic_string_view non-member comparison functions
+    template<class charT, class traits>
+    constexpr bool operator==(basic_string_view<charT, traits> x,
+                              basic_string_view<charT, traits> y) noexcept;
+    template<class charT, class traits>
+    constexpr bool operator!=(basic_string_view<charT, traits> x,
+                              basic_string_view<charT, traits> y) noexcept;
+    template<class charT, class traits>
+    constexpr bool operator< (basic_string_view<charT, traits> x,
+                                 basic_string_view<charT, traits> y) noexcept;
+    template<class charT, class traits>
+    constexpr bool operator> (basic_string_view<charT, traits> x,
+                              basic_string_view<charT, traits> y) noexcept;
+    template<class charT, class traits>
+    constexpr bool operator<=(basic_string_view<charT, traits> x,
+                                 basic_string_view<charT, traits> y) noexcept;
+    template<class charT, class traits>
+    constexpr bool operator>=(basic_string_view<charT, traits> x,
+                              basic_string_view<charT, traits> y) noexcept;
+    // see below, sufficient additional overloads of comparison functions
+
+    // 7.10, Inserters and extractors
+    template<class charT, class traits>
+      basic_ostream<charT, traits>&
+        operator<<(basic_ostream<charT, traits>& os,
+                   basic_string_view<charT, traits> str);
+
+    // basic_string_view typedef names
+    typedef basic_string_view<char> string_view;
+    typedef basic_string_view<char16_t> u16string_view;
+    typedef basic_string_view<char32_t> u32string_view;
+    typedef basic_string_view<wchar_t> wstring_view;
+
+    template<class charT, class traits = char_traits<charT>>
+    class basic_string_view {
+      public:
+      // types
+      typedef traits traits_type;
+      typedef charT value_type;
+      typedef charT* pointer;
+      typedef const charT* const_pointer;
+      typedef charT& reference;
+      typedef const charT& const_reference;
+      typedef implementation-defined const_iterator;
+      typedef const_iterator iterator;
+      typedef reverse_iterator<const_iterator> const_reverse_iterator;
+      typedef const_reverse_iterator reverse_iterator;
+      typedef size_t size_type;
+      typedef ptrdiff_t difference_type;
+      static constexpr size_type npos = size_type(-1);
+
+      // 7.3, basic_string_view constructors and assignment operators
+      constexpr basic_string_view() noexcept;
+      constexpr basic_string_view(const basic_string_view&) noexcept = default;
+      basic_string_view& operator=(const basic_string_view&) noexcept = default;
+      template<class Allocator>
+      basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept;
+      constexpr basic_string_view(const charT* str);
+      constexpr basic_string_view(const charT* str, size_type len);
+
+      // 7.4, basic_string_view iterator support
+      constexpr const_iterator begin() const noexcept;
+      constexpr const_iterator end() const noexcept;
+      constexpr const_iterator cbegin() const noexcept;
+      constexpr const_iterator cend() const noexcept;
+      const_reverse_iterator rbegin() const noexcept;
+      const_reverse_iterator rend() const noexcept;
+      const_reverse_iterator crbegin() const noexcept;
+      const_reverse_iterator crend() const noexcept;
+
+      // 7.5, basic_string_view capacity
+      constexpr size_type size() const noexcept;
+      constexpr size_type length() const noexcept;
+      constexpr size_type max_size() const noexcept;
+      constexpr bool empty() const noexcept;
+
+      // 7.6, basic_string_view element access
+      constexpr const_reference operator[](size_type pos) const;
+      constexpr const_reference at(size_type pos) const;
+      constexpr const_reference front() const;
+      constexpr const_reference back() const;
+      constexpr const_pointer data() const noexcept;
+
+      // 7.7, basic_string_view modifiers
+      constexpr void clear() noexcept;
+      constexpr void remove_prefix(size_type n);
+      constexpr void remove_suffix(size_type n);
+      constexpr void swap(basic_string_view& s) noexcept;
+
+      // 7.8, basic_string_view string operations
+      template<class Allocator>
+      explicit operator basic_string<charT, traits, Allocator>() const;
+      template<class Allocator = allocator<charT>>
+      basic_string<charT, traits, Allocator> to_string(
+        const Allocator& a = Allocator()) const;
+
+      size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+      constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
+      constexpr int compare(basic_string_view s) const noexcept;
+      constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
+      constexpr int compare(size_type pos1, size_type n1,
+                            basic_string_view s, size_type pos2, size_type n2) const;
+      constexpr int compare(const charT* s) const;
+      constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
+      constexpr int compare(size_type pos1, size_type n1,
+                            const charT* s, size_type n2) const;
+      constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
+      constexpr size_type find(charT c, size_type pos = 0) const noexcept;
+      constexpr size_type find(const charT* s, size_type pos, size_type n) const;
+      constexpr size_type find(const charT* s, size_type pos = 0) const;
+      constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
+      constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
+      constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
+      constexpr size_type rfind(const charT* s, size_type pos = npos) const;
+      constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
+      constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
+      constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
+      constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
+      constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
+      constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
+      constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
+      constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
+      constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
+      constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
+      constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
+      constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+      constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
+      constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
+      constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
+      constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+
+     private:
+      const_pointer data_;  // exposition only
+      size_type     size_;  // exposition only
+    };
+
+  }  // namespace fundamentals_v1
+ }  // namespace experimental
+
+  // 7.11, Hash support
+  template <class T> struct hash;
+  template <> struct hash<experimental::string_view>;
+  template <> struct hash<experimental::u16string_view>;
+  template <> struct hash<experimental::u32string_view>;
+  template <> struct hash<experimental::wstring_view>;
+
+}  // namespace std
+
+
+*/
+
+#include <experimental/__config>
+
+#include <string>
+#include <algorithm>
+#include <iterator>
+#include <ostream>
+#include <iomanip>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+    
+    template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_string_view {
+    public:
+        // types
+        typedef _Traits                                    traits_type;
+        typedef _CharT                                     value_type;
+        typedef const _CharT*                              pointer;
+        typedef const _CharT*                              const_pointer;
+        typedef const _CharT&                              reference;
+        typedef const _CharT&                              const_reference;
+        typedef const_pointer                              const_iterator; // See [string.view.iterators]
+        typedef const_iterator                             iterator;
+        typedef _VSTD::reverse_iterator<const_iterator>    const_reverse_iterator;
+        typedef const_reverse_iterator                     reverse_iterator;
+        typedef size_t                                     size_type;
+        typedef ptrdiff_t                                  difference_type;
+        static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
+
+        // [string.view.cons], construct/copy
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
+
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        basic_string_view(const basic_string_view&) _NOEXCEPT = default;
+        
+        _LIBCPP_INLINE_VISIBILITY
+        basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
+
+        template<class _Allocator>
+        _LIBCPP_INLINE_VISIBILITY
+        basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT
+            : __data (__str.data()), __size(__str.size()) {}
+
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        basic_string_view(const _CharT* __s, size_type __len)
+            : __data(__s), __size(__len)
+        {
+//             _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): recieved nullptr");
+        }
+            
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        basic_string_view(const _CharT* __s)
+            : __data(__s), __size(_Traits::length(__s)) {}
+
+        // [string.view.iterators], iterators
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_iterator begin()  const _NOEXCEPT { return cbegin(); }
+        
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_iterator end()    const _NOEXCEPT { return cend(); }
+        
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_iterator cbegin() const _NOEXCEPT { return __data; }
+        
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_iterator cend()   const _NOEXCEPT { return __data + __size; }
+
+        _LIBCPP_INLINE_VISIBILITY
+        const_reverse_iterator rbegin()   const _NOEXCEPT { return const_reverse_iterator(cend()); }
+        
+        _LIBCPP_INLINE_VISIBILITY
+        const_reverse_iterator rend()     const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
+        
+        _LIBCPP_INLINE_VISIBILITY
+        const_reverse_iterator crbegin()  const _NOEXCEPT { return const_reverse_iterator(cend()); }
+        
+        _LIBCPP_INLINE_VISIBILITY
+        const_reverse_iterator crend()    const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
+
+        // [string.view.capacity], capacity
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        size_type size()     const _NOEXCEPT { return __size; }
+        
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        size_type length()   const _NOEXCEPT { return __size; }
+        
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits<size_type>::max(); }
+        
+        _LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY
+        empty()         const _NOEXCEPT { return __size == 0; }
+
+        // [string.view.access], element access
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_reference operator[](size_type __pos) const { return __data[__pos]; }
+        
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_reference at(size_type __pos) const
+        {
+            return __pos >= size()
+                ? throw out_of_range("string_view::at")
+                : __data[__pos];
+//             if (__pos >= size())
+//                 throw out_of_range("string_view::at");
+//             return __data[__pos]; 
+        }
+
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_reference front() const
+        {
+            return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
+        }
+        
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_reference back() const
+        {
+            return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
+        }
+
+        _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
+        const_pointer data() const _NOEXCEPT { return __data; }
+
+        // [string.view.modifiers], modifiers:
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        void clear() _NOEXCEPT
+        {
+            __data = nullptr;
+            __size = 0;
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        void remove_prefix(size_type __n) _NOEXCEPT
+        {
+            if (__n > __size)
+                __n = __size;
+            __data += __n;
+            __size -= __n;
+        }
+            
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        void remove_suffix(size_type __n) _NOEXCEPT
+        {
+            if (__n > __size)
+                __n = __size;
+            __size -= __n;
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        void swap(basic_string_view& __other) _NOEXCEPT
+        {
+            const value_type *__p = __data;
+            __data = __other.__data;
+            __other.__data = __p;
+            
+            size_type __sz = __size;
+            __size = __other.__size;
+            __other.__size = __sz;
+//             _VSTD::swap( __data, __other.__data );
+//             _VSTD::swap( __size, __other.__size );
+        }
+                    
+        // [string.view.ops], string operations:
+        template<class _Allocator>
+        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
+        { return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
+        
+        template<class _Allocator = allocator<_CharT> >
+        _LIBCPP_INLINE_VISIBILITY
+        basic_string<_CharT, _Traits, _Allocator> to_string( const _Allocator& __a = _Allocator())
+        { return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); }
+
+        size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
+        {
+            if ( __pos > size())
+                throw out_of_range("string_view::copy");
+            size_type __rlen = _VSTD::min( __n, size() - __pos );
+            _VSTD::copy_n(begin() + __pos, __rlen, __s );
+            return __rlen;
+        }
+        
+        _LIBCPP_CONSTEXPR
+        basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
+        {
+//             if (__pos > size())
+//                 throw out_of_range("string_view::substr");
+//             size_type __rlen = _VSTD::min( __n, size() - __pos );
+//             return basic_string_view(data() + __pos, __rlen);
+			return __pos > size()
+			       ? throw out_of_range("string_view::substr")
+			       : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
+        {
+            size_type __rlen = _VSTD::min( size(), __sv.size());
+            int __retval = _Traits::compare(data(), __sv.data(), __rlen);
+            if ( __retval == 0 ) // first __rlen chars matched
+                __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
+            return __retval;
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
+        {
+            return substr(__pos1, __n1).compare(__sv);
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        int compare(                       size_type __pos1, size_type __n1, 
+                    basic_string_view _sv, size_type __pos2, size_type __n2) const
+        {
+            return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        int compare(const _CharT* __s) const
+        {
+            return compare(basic_string_view(__s));
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
+        {
+            return substr(__pos1, __n1).compare(basic_string_view(__s));
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
+        {
+            return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
+        }
+
+        // find
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
+        {
+            _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr");
+            return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+                (data(), size(), __s.data(), __pos, __s.size());
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
+        {
+            return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+                (data(), size(), __c, __pos);
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find(const _CharT* __s, size_type __pos, size_type __n) const
+        {
+            _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): recieved nullptr");
+            return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, __n);
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find(const _CharT* __s, size_type __pos = 0) const
+        {
+            _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): recieved nullptr");
+            return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, traits_type::length(__s));
+        }
+
+        // rfind
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
+        {
+            _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): recieved nullptr");
+            return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+                (data(), size(), __s.data(), __pos, __s.size());
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
+        {
+            return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+                (data(), size(), __c, __pos);
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
+        {
+            _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): recieved nullptr");
+            return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, __n);
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type rfind(const _CharT* __s, size_type __pos=npos) const
+        {
+            _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): recieved nullptr");
+            return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, traits_type::length(__s));
+        }
+
+        // find_first_of
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
+        {
+            _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): recieved nullptr");
+            return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s.data(), __pos, __s.size());
+        }
+    
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
+        { return find(__c, __pos); }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
+        {
+            _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): recieved nullptr");
+            return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, __n);
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_of(const _CharT* __s, size_type __pos=0) const
+        {
+            _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): recieved nullptr");
+            return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, traits_type::length(__s));
+        }
+
+        // find_last_of
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
+        {
+            _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): recieved nullptr");
+            return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s.data(), __pos, __s.size());
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
+        { return rfind(__c, __pos); }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
+        {
+            _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): recieved nullptr");
+            return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, __n);
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
+        {
+            _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): recieved nullptr");
+            return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, traits_type::length(__s));
+        }
+
+        // find_first_not_of
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
+        {
+            _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): recieved nullptr");
+            return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s.data(), __pos, __s.size());
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
+        {
+            return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __c, __pos);
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+        {
+            _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): recieved nullptr");
+            return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, __n);
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
+        {
+            _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): recieved nullptr");
+            return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, traits_type::length(__s));
+        }
+        
+        // find_last_not_of
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
+        {
+            _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): recieved nullptr");
+            return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s.data(), __pos, __s.size());
+        }       
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
+        {
+            return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __c, __pos);
+        }
+        
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+        {
+            _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): recieved nullptr");
+            return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, __n);
+        }
+
+        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+        size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
+        {
+            _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): recieved nullptr");
+            return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+                (data(), size(), __s, __pos, traits_type::length(__s));
+        }
+
+    private:   
+        const   value_type* __data;
+        size_type           __size;
+    };
+
+
+    // [string.view.comparison]
+    // operator ==
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator==(basic_string_view<_CharT, _Traits> __lhs,
+                    basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        if ( __lhs.size() != __rhs.size()) return false;
+        return __lhs.compare(__rhs) == 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator==(basic_string_view<_CharT, _Traits> __lhs,
+                    typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+    {
+        if ( __lhs.size() != __rhs.size()) return false;
+        return __lhs.compare(__rhs) == 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 
+                    basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        if ( __lhs.size() != __rhs.size()) return false;
+        return __lhs.compare(__rhs) == 0;
+    }
+
+
+    // operator !=
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        if ( __lhs.size() != __rhs.size())
+            return true;
+        return __lhs.compare(__rhs) != 0;
+    }
+  
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
+                    typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+    {
+        if ( __lhs.size() != __rhs.size())
+            return true;
+        return __lhs.compare(__rhs) != 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 
+                    basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        if ( __lhs.size() != __rhs.size())
+            return true;
+        return __lhs.compare(__rhs) != 0;
+    }
+
+
+    // operator <
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) < 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator<(basic_string_view<_CharT, _Traits> __lhs,
+                    typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) < 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 
+                    basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) < 0;
+    }
+
+
+    // operator >
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) > 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator>(basic_string_view<_CharT, _Traits> __lhs,
+                    typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) > 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 
+                    basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) > 0;
+    }
+
+
+    // operator <=
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) <= 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
+                    typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) <= 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 
+                    basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) <= 0;
+    }
+
+
+    // operator >=
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) >= 0;
+    }
+
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
+                    typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) >= 0;
+    }
+
+    template<class _CharT, class _Traits>
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs, 
+                    basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
+    {
+        return __lhs.compare(__rhs) >= 0;
+    }
+
+
+    // [string.view.io]
+    template<class _CharT, class _Traits>
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv)
+    {
+        return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
+    }
+
+  typedef basic_string_view<char>     string_view;
+  typedef basic_string_view<char16_t> u16string_view;
+  typedef basic_string_view<char32_t> u32string_view;
+  typedef basic_string_view<wchar_t>  wstring_view;
+
+_LIBCPP_END_NAMESPACE_LFTS
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// [string.view.hash]
+// Shamelessly stolen from <string>
+template<class _CharT, class _Traits>
+struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> >
+    : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
+{
+    size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;
+};
+
+template<class _CharT, class _Traits>
+size_t
+hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
+        const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT
+{
+    return __do_string_hash(__val.data(), __val.data() + __val.size());
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _CharT, class _Traits>
+__quoted_output_proxy<_CharT, const _CharT *, _Traits>
+quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
+             _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+    return __quoted_output_proxy<_CharT, const _CharT *, _Traits> 
+         ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_LFTS_STRING_VIEW
diff --git a/final/include/experimental/utility b/final/include/experimental/utility
new file mode 100644
index 0000000..12a7d05
--- /dev/null
+++ b/final/include/experimental/utility
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//===-------------------------- utility ----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXPERIMENTAL_UTILITY
+#define _LIBCPP_EXPERIMENTAL_UTILITY
+
+/*
+    experimental/utility synopsis
+
+// C++1y
+
+#include <utility>
+
+namespace std {
+namespace experimental {
+inline namespace fundamentals_v1 {
+
+  3.1.2, erased-type placeholder
+  struct erased_type { };
+
+} // namespace fundamentals_v1
+} // namespace experimental
+} // namespace std
+
+ */
+
+# include <experimental/__config>
+
+#if _LIBCPP_STD_VER > 11
+
+# include <utility>
+
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+  struct _LIBCPP_TYPE_VIS_ONLY erased_type { };
+
+_LIBCPP_END_NAMESPACE_LFTS
+
+#endif /* _LIBCPP_STD_VER > 11 */
+
+#endif /* _LIBCPP_EXPERIMENTAL_UTILITY */
diff --git a/final/include/ext/__hash b/final/include/ext/__hash
new file mode 100644
index 0000000..5675d54
--- /dev/null
+++ b/final/include/ext/__hash
@@ -0,0 +1,135 @@
+// -*- C++ -*-
+//===------------------------- hash_set ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_EXT_HASH
+#define _LIBCPP_EXT_HASH
+
+#pragma GCC system_header
+
+#include <string>
+#include <cstring>
+
+namespace __gnu_cxx {
+using namespace std;
+
+template <typename _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash { };
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*>
+    : public unary_function<const char*, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const char *__c) const _NOEXCEPT
+    {
+        return __do_string_hash(__c, __c + strlen(__c));
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *>
+    : public unary_function<char*, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(char *__c) const _NOEXCEPT
+    {
+        return __do_string_hash<const char *>(__c, __c + strlen(__c));
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char>
+    : public unary_function<char, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(char __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
+    : public unary_function<signed char, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(signed char __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
+    : public unary_function<unsigned char, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned char __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<short>
+    : public unary_function<short, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(short __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
+    : public unary_function<unsigned short, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned short __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<int>
+    : public unary_function<int, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(int __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
+    : public unary_function<unsigned int, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned int __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<long>
+    : public unary_function<long, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(long __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
+    : public unary_function<unsigned long, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned long __c) const _NOEXCEPT
+    {
+        return __c;
+    }
+};
+}
+
+#endif  // _LIBCPP_EXT_HASH
diff --git a/final/include/ext/hash_map b/final/include/ext/hash_map
new file mode 100644
index 0000000..36cd595
--- /dev/null
+++ b/final/include/ext/hash_map
@@ -0,0 +1,1007 @@
+// -*- C++ -*-
+//===-------------------------- hash_map ----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_HASH_MAP
+#define _LIBCPP_HASH_MAP
+
+/*
+
+    hash_map synopsis
+
+namespace __gnu_cxx
+{
+
+template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+          class Alloc = allocator<pair<const Key, T>>>
+class hash_map
+{
+public:
+    // types
+    typedef Key                                                        key_type;
+    typedef T                                                          mapped_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef pair<const key_type, mapped_type>                          value_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+
+    explicit hash_map(size_type n = 193, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        hash_map(InputIterator f, InputIterator l,
+                      size_type n = 193, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    hash_map(const hash_map&);
+    ~hash_map();
+    hash_map& operator=(const hash_map&);
+
+    allocator_type get_allocator() const;
+
+    bool      empty() const;
+    size_type size() const;
+    size_type max_size() const;
+
+    iterator       begin();
+    iterator       end();
+    const_iterator begin()  const;
+    const_iterator end()    const;
+
+    pair<iterator, bool> insert(const value_type& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+
+    void erase(const_iterator position);
+    size_type erase(const key_type& k);
+    void erase(const_iterator first, const_iterator last);
+    void clear();
+
+    void swap(hash_map&);
+
+    hasher hash_funct() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    mapped_type& operator[](const key_type& k);
+
+    size_type bucket_count() const;
+    size_type max_bucket_count() const;
+
+    size_type elems_in_bucket(size_type n) const;
+
+    void resize(size_type n);
+};
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    void swap(hash_map<Key, T, Hash, Pred, Alloc>& x,
+              hash_map<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const hash_map<Key, T, Hash, Pred, Alloc>& x,
+               const hash_map<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const hash_map<Key, T, Hash, Pred, Alloc>& x,
+               const hash_map<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+          class Alloc = allocator<pair<const Key, T>>>
+class hash_multimap
+{
+public:
+    // types
+    typedef Key                                                        key_type;
+    typedef T                                                          mapped_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef pair<const key_type, mapped_type>                          value_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+
+    explicit hash_multimap(size_type n = 193, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        hash_multimap(InputIterator f, InputIterator l,
+                      size_type n = 193, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    explicit hash_multimap(const allocator_type&);
+    hash_multimap(const hash_multimap&);
+    ~hash_multimap();
+    hash_multimap& operator=(const hash_multimap&);
+
+    allocator_type get_allocator() const;
+
+    bool      empty() const;
+    size_type size() const;
+    size_type max_size() const;
+
+    iterator       begin();
+    iterator       end();
+    const_iterator begin()  const;
+    const_iterator end()    const;
+
+    iterator insert(const value_type& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+
+    void erase(const_iterator position);
+    size_type erase(const key_type& k);
+    void erase(const_iterator first, const_iterator last);
+    void clear();
+
+    void swap(hash_multimap&);
+
+    hasher hash_funct() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    size_type bucket_count() const;
+    size_type max_bucket_count() const;
+
+    size_type elems_in_bucket(size_type n) const;
+
+    void resize(size_type n);
+};
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    void swap(hash_multimap<Key, T, Hash, Pred, Alloc>& x,
+              hash_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
+               const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
+               const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+}  // __gnu_cxx
+
+*/
+
+#include <__config>
+#include <__hash_table>
+#include <functional>
+#include <stdexcept>
+#include <ext/__hash>
+
+#if __DEPRECATED
+#if defined(_MSC_VER) && ! defined(__clang__)
+    _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated.  Migrate to <unordered_map>")
+#else
+#   warning Use of the header <ext/hash_map> is deprecated.  Migrate to <unordered_map>
+#endif
+#endif
+
+#pragma GCC system_header
+
+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
+        >
+class __hash_map_hasher
+    : private _Hash
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : _Hash() {}
+    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : _Hash(__h) {}
+    _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const _Tp& __x) const
+        {return static_cast<const _Hash&>(*this)(__x.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const typename _Tp::first_type& __x) const
+        {return static_cast<const _Hash&>(*this)(__x);}
+};
+
+template <class _Tp, class _Hash>
+class __hash_map_hasher<_Tp, _Hash, false>
+{
+    _Hash __hash_;
+public:
+    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher() : __hash_() {}
+    _LIBCPP_INLINE_VISIBILITY __hash_map_hasher(const _Hash& __h) : __hash_(__h) {}
+    _LIBCPP_INLINE_VISIBILITY const _Hash& hash_function() const {return __hash_;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const _Tp& __x) const
+        {return __hash_(__x.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const typename _Tp::first_type& __x) const
+        {return __hash_(__x);}
+};
+
+template <class _Tp, class _Pred, bool = is_empty<_Pred>::value
+#if __has_feature(is_final)
+                                         && !__is_final(_Pred)
+#endif
+         >
+class __hash_map_equal
+    : private _Pred
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : _Pred() {}
+    _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : _Pred(__p) {}
+    _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
+        {return static_cast<const _Pred&>(*this)(__x, __y.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
+        {return static_cast<const _Pred&>(*this)(__x.first, __y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const typename _Tp::first_type& __x,
+                    const typename _Tp::first_type& __y) const
+        {return static_cast<const _Pred&>(*this)(__x, __y);}
+};
+
+template <class _Tp, class _Pred>
+class __hash_map_equal<_Tp, _Pred, false>
+{
+    _Pred __pred_;
+public:
+    _LIBCPP_INLINE_VISIBILITY __hash_map_equal() : __pred_() {}
+    _LIBCPP_INLINE_VISIBILITY __hash_map_equal(const _Pred& __p) : __pred_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY const _Pred& key_eq() const {return __pred_;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __pred_(__x.first, __y.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
+        {return __pred_(__x, __y.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
+        {return __pred_(__x.first, __y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const typename _Tp::first_type& __x,
+                    const typename _Tp::first_type& __y) const
+        {return __pred_(__x, __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;
+private:
+    typedef typename value_type::first_type     first_type;
+    typedef typename value_type::second_type    second_type;
+
+    allocator_type& __na_;
+
+    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
+
+public:
+    bool __first_constructed;
+    bool __second_constructed;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __hash_map_node_destructor(allocator_type& __na)
+        : __na_(__na),
+          __first_constructed(false),
+          __second_constructed(false)
+        {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
+        : __na_(__x.__na_),
+          __first_constructed(__x.__value_constructed),
+          __second_constructed(__x.__value_constructed)
+        {
+            __x.__value_constructed = false;
+        }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
+        : __na_(__x.__na_),
+          __first_constructed(__x.__value_constructed),
+          __second_constructed(__x.__value_constructed)
+        {
+            const_cast<bool&>(__x.__value_constructed) = false;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    void operator()(pointer __p)
+    {
+        if (__second_constructed)
+            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.second));
+        if (__first_constructed)
+            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.first));
+        if (__p)
+            __alloc_traits::deallocate(__na_, __p, 1);
+    }
+};
+
+template <class _HashIterator>
+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:
+    typedef forward_iterator_tag                                 iterator_category;
+    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;
+
+    _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
+
+    _LIBCPP_INLINE_VISIBILITY __hash_map_iterator(_HashIterator __i) : __i_(__i) {}
+
+    _LIBCPP_INLINE_VISIBILITY reference operator*() const {return *operator->();}
+    _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return (pointer)__i_.operator->();}
+
+    _LIBCPP_INLINE_VISIBILITY __hash_map_iterator& operator++() {++__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_iterator operator++(int)
+    {
+        __hash_map_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY 
+    bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
+        {return __x.__i_ == __y.__i_;}
+    friend _LIBCPP_INLINE_VISIBILITY 
+    bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
+        {return __x.__i_ != __y.__i_;}
+
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
+};
+
+template <class _HashIterator>
+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:
+    typedef forward_iterator_tag                                 iterator_category;
+    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;
+
+    _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator(_HashIterator __i) : __i_(__i) {}
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator(
+            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
+                : __i_(__i.__i_) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return *operator->();}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return (pointer)__i_.operator->();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator& operator++() {++__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator operator++(int)
+    {
+        __hash_map_const_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
+        {return __x.__i_ == __y.__i_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
+        {return __x.__i_ != __y.__i_;}
+
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
+};
+
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
+          class _Alloc = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TYPE_VIS_ONLY hash_map
+{
+public:
+    // types
+    typedef _Key                                           key_type;
+    typedef _Tp                                            mapped_type;
+    typedef _Tp                                            data_type;
+    typedef _Hash                                          hasher;
+    typedef _Pred                                          key_equal;
+    typedef _Alloc                                         allocator_type;
+    typedef pair<const key_type, mapped_type>              value_type;
+    typedef value_type&                                    reference;
+    typedef const value_type&                              const_reference;
+
+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 __hash_table<__value_type, __hasher,
+                         __key_equal,  __allocator_type>   __table;
+
+    __table __table_;
+
+    typedef typename __table::__node_pointer               __node_pointer;
+    typedef typename __table::__node_const_pointer         __node_const_pointer;
+    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;
+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 __hash_map_iterator<typename __table::iterator>       iterator;
+    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY hash_map() {__table_.rehash(193);}
+    explicit hash_map(size_type __n, const hasher& __hf = hasher(),
+                           const key_equal& __eql = key_equal());
+    hash_map(size_type __n, const hasher& __hf,
+                  const key_equal& __eql,
+                  const allocator_type& __a);
+    template <class _InputIterator>
+        hash_map(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        hash_map(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        hash_map(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf,
+                      const key_equal& __eql,
+                      const allocator_type& __a);
+    hash_map(const hash_map& __u);
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin()        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end()          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const {return __table_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> insert(const value_type& __x)
+        {return __table_.__insert_unique(__x);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
+    template <class _InputIterator>
+        void insert(_InputIterator __first, _InputIterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __p) {__table_.erase(__p.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __first, const_iterator __last)
+        {__table_.erase(__first.__i_, __last.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(hash_map& __u) {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_funct() const
+        {return __table_.hash_function().hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const
+        {return __table_.key_eq().key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_unique(__k);}
+
+    mapped_type& operator[](const key_type& __k);
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type elems_in_bucket(size_type __n) const
+        {return __table_.bucket_size(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void resize(size_type __n) {__table_.rehash(__n);}
+
+private:
+    __node_holder __construct_node(const key_type& __k);
+};
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
+        size_type __n, const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
+        size_type __n, const hasher& __hf, const key_equal& __eql,
+        const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
+        _InputIterator __first, _InputIterator __last)
+{
+    __table_.rehash(193);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
+        const hash_map& __u)
+    : __table_(__u.__table_)
+{
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const 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_.first), __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
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                       _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_unique(*__first);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
+{
+    iterator __i = find(__k);
+    if (__i != end())
+        return __i->second;
+    __node_holder __h = __construct_node(__k);
+    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
+    __h.release();
+    return __r.first->second;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+     hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
+            __i != __ex; ++__i)
+    {
+        const_iterator __j = __y.find(__i->first);
+        if (__j == __ey || !(*__i == *__j))
+            return false;
+    }
+    return true;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
+          class _Alloc = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TYPE_VIS_ONLY hash_multimap
+{
+public:
+    // types
+    typedef _Key                                           key_type;
+    typedef _Tp                                            mapped_type;
+    typedef _Tp                                            data_type;
+    typedef _Hash                                          hasher;
+    typedef _Pred                                          key_equal;
+    typedef _Alloc                                         allocator_type;
+    typedef pair<const key_type, mapped_type>              value_type;
+    typedef value_type&                                    reference;
+    typedef const value_type&                              const_reference;
+
+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 __hash_table<__value_type, __hasher,
+                         __key_equal,  __allocator_type>   __table;
+
+    __table __table_;
+
+    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;
+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 __hash_map_iterator<typename __table::iterator>       iterator;
+    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    hash_multimap() {__table_.rehash(193);}
+    explicit hash_multimap(size_type __n, const hasher& __hf = hasher(),
+                                const key_equal& __eql = key_equal());
+    hash_multimap(size_type __n, const hasher& __hf,
+                                const key_equal& __eql,
+                                const allocator_type& __a);
+    template <class _InputIterator>
+        hash_multimap(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        hash_multimap(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        hash_multimap(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf,
+                      const key_equal& __eql,
+                      const allocator_type& __a);
+    hash_multimap(const hash_multimap& __u);
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin()        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end()          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const {return __table_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
+    template <class _InputIterator>
+        void insert(_InputIterator __first, _InputIterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __p) {__table_.erase(__p.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __first, const_iterator __last)
+        {__table_.erase(__first.__i_, __last.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(hash_multimap& __u) {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_funct() const
+        {return __table_.hash_function().hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const
+        {return __table_.key_eq().key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_multi(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type elems_in_bucket(size_type __n) const
+        {return __table_.bucket_size(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void resize(size_type __n) {__table_.rehash(__n);}
+};
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
+        size_type __n, const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
+        size_type __n, const hasher& __hf, const key_equal& __eql,
+        const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
+        _InputIterator __first, _InputIterator __last)
+{
+    __table_.rehash(193);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
+        const hash_multimap& __u)
+    : __table_(__u.__table_)
+{
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                            _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_multi(*__first);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+     hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    typedef pair<const_iterator, const_iterator> _EqRng;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
+    {
+        _EqRng __xeq = __x.equal_range(__i->first);
+        _EqRng __yeq = __y.equal_range(__i->first);
+        if (_VSTD::distance(__xeq.first, __xeq.second) !=
+            _VSTD::distance(__yeq.first, __yeq.second) ||
+                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
+            return false;
+        __i = __xeq.second;
+    }
+    return true;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+} // __gnu_cxx
+
+#endif  // _LIBCPP_HASH_MAP
diff --git a/final/include/ext/hash_set b/final/include/ext/hash_set
new file mode 100644
index 0000000..c4bb898
--- /dev/null
+++ b/final/include/ext/hash_set
@@ -0,0 +1,661 @@
+// -*- C++ -*-
+//===------------------------- hash_set ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_HASH_SET
+#define _LIBCPP_HASH_SET
+
+/*
+
+    hash_set synopsis
+
+namespace __gnu_cxx
+{
+
+template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+          class Alloc = allocator<Value>>
+class hash_set
+{
+public:
+    // types
+    typedef Value                                                      key_type;
+    typedef key_type                                                   value_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+
+    explicit hash_set(size_type n = 193, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        hash_set(InputIterator f, InputIterator l,
+                      size_type n = 193, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    hash_set(const hash_set&);
+    ~hash_set();
+    hash_set& operator=(const hash_set&);
+
+    allocator_type get_allocator() const;
+
+    bool      empty() const;
+    size_type size() const;
+    size_type max_size() const;
+
+    iterator       begin();
+    iterator       end();
+    const_iterator begin()  const;
+    const_iterator end()    const;
+
+    pair<iterator, bool> insert(const value_type& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+
+    void erase(const_iterator position);
+    size_type erase(const key_type& k);
+    void erase(const_iterator first, const_iterator last);
+    void clear();
+
+    void swap(hash_set&);
+
+    hasher hash_funct() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    size_type bucket_count() const;
+    size_type max_bucket_count() const;
+
+    size_type elems_in_bucket(size_type n) const;
+
+    void resize(size_type n);
+};
+
+template <class Value, class Hash, class Pred, class Alloc>
+    void swap(hash_set<Value, Hash, Pred, Alloc>& x,
+              hash_set<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const hash_set<Value, Hash, Pred, Alloc>& x,
+               const hash_set<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const hash_set<Value, Hash, Pred, Alloc>& x,
+               const hash_set<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+          class Alloc = allocator<Value>>
+class hash_multiset
+{
+public:
+    // types
+    typedef Value                                                      key_type;
+    typedef key_type                                                   value_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+
+    explicit hash_multiset(size_type n = 193, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        hash_multiset(InputIterator f, InputIterator l,
+                      size_type n = 193, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    hash_multiset(const hash_multiset&);
+    ~hash_multiset();
+    hash_multiset& operator=(const hash_multiset&);
+
+    allocator_type get_allocator() const;
+
+    bool      empty() const;
+    size_type size() const;
+    size_type max_size() const;
+
+    iterator       begin();
+    iterator       end();
+    const_iterator begin()  const;
+    const_iterator end()    const;
+
+    iterator insert(const value_type& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+
+    void erase(const_iterator position);
+    size_type erase(const key_type& k);
+    void erase(const_iterator first, const_iterator last);
+    void clear();
+
+    void swap(hash_multiset&);
+
+    hasher hash_funct() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    size_type bucket_count() const;
+    size_type max_bucket_count() const;
+
+    size_type elems_in_bucket(size_type n) const;
+
+    void resize(size_type n);
+};
+
+template <class Value, class Hash, class Pred, class Alloc>
+    void swap(hash_multiset<Value, Hash, Pred, Alloc>& x,
+              hash_multiset<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const hash_multiset<Value, Hash, Pred, Alloc>& x,
+               const hash_multiset<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const hash_multiset<Value, Hash, Pred, Alloc>& x,
+               const hash_multiset<Value, Hash, Pred, Alloc>& y);
+}  // __gnu_cxx
+
+*/
+
+#include <__config>
+#include <__hash_table>
+#include <functional>
+#include <ext/__hash>
+
+#if __DEPRECATED
+#if defined(_MSC_VER) && ! defined(__clang__)
+    _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated.  Migrate to <unordered_set>")
+#else
+#   warning Use of the header <ext/hash_set> is deprecated.  Migrate to <unordered_set>
+#endif
+#endif
+
+namespace __gnu_cxx {
+
+using namespace std;
+
+template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
+          class _Alloc = allocator<_Value> >
+class _LIBCPP_TYPE_VIS_ONLY hash_set
+{
+public:
+    // types
+    typedef _Value                                                     key_type;
+    typedef key_type                                                   value_type;
+    typedef _Hash                                                      hasher;
+    typedef _Pred                                                      key_equal;
+    typedef _Alloc                                                     allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+
+private:
+    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+
+    __table __table_;
+
+public:
+    typedef typename __table::pointer         pointer;
+    typedef typename __table::const_pointer   const_pointer;
+    typedef typename __table::size_type       size_type;
+    typedef typename __table::difference_type difference_type;
+
+    typedef typename __table::const_iterator       iterator;
+    typedef typename __table::const_iterator       const_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    hash_set() {__table_.rehash(193);}
+    explicit hash_set(size_type __n, const hasher& __hf = hasher(),
+                           const key_equal& __eql = key_equal());
+    hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
+                  const allocator_type& __a);
+    template <class _InputIterator>
+        hash_set(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        hash_set(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        hash_set(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf, const key_equal& __eql,
+                      const allocator_type& __a);
+    hash_set(const hash_set& __u);
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin()        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end()          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const {return __table_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> insert(const value_type& __x)
+        {return __table_.__insert_unique(__x);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
+    template <class _InputIterator>
+        void insert(_InputIterator __first, _InputIterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __p) {__table_.erase(__p);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __first, const_iterator __last)
+        {__table_.erase(__first, __last);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(hash_set& __u) {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_funct() const {return __table_.hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const {return __table_.key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_unique(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void resize(size_type __n) {__table_.rehash(__n);}
+};
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
+        _InputIterator __first, _InputIterator __last)
+{
+    __table_.rehash(193);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
+        const hash_set& __u)
+    : __table_(__u.__table_)
+{
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                    _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_unique(*__first);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
+     hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
+           const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename hash_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
+            __i != __ex; ++__i)
+    {
+        const_iterator __j = __y.find(*__i);
+        if (__j == __ey || !(*__i == *__j))
+            return false;
+    }
+    return true;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
+           const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
+          class _Alloc = allocator<_Value> >
+class _LIBCPP_TYPE_VIS_ONLY hash_multiset
+{
+public:
+    // types
+    typedef _Value                                                     key_type;
+    typedef key_type                                                   value_type;
+    typedef _Hash                                                      hasher;
+    typedef _Pred                                                      key_equal;
+    typedef _Alloc                                                     allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+
+private:
+    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+
+    __table __table_;
+
+public:
+    typedef typename __table::pointer         pointer;
+    typedef typename __table::const_pointer   const_pointer;
+    typedef typename __table::size_type       size_type;
+    typedef typename __table::difference_type difference_type;
+
+    typedef typename __table::const_iterator       iterator;
+    typedef typename __table::const_iterator       const_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    hash_multiset() {__table_.rehash(193);}
+    explicit hash_multiset(size_type __n, const hasher& __hf = hasher(),
+                                const key_equal& __eql = key_equal());
+    hash_multiset(size_type __n, const hasher& __hf,
+                       const key_equal& __eql, const allocator_type& __a);
+    template <class _InputIterator>
+        hash_multiset(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        hash_multiset(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        hash_multiset(_InputIterator __first, _InputIterator __last,
+                      size_type __n , const hasher& __hf,
+                      const key_equal& __eql, const allocator_type& __a);
+    hash_multiset(const hash_multiset& __u);
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin()        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end()          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const {return __table_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator, const value_type& __x) {return insert(__x);}
+    template <class _InputIterator>
+        void insert(_InputIterator __first, _InputIterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __p) {__table_.erase(__p);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    void erase(const_iterator __first, const_iterator __last)
+        {__table_.erase(__first, __last);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(hash_multiset& __u) {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_funct() const {return __table_.hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const {return __table_.key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_multi(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void resize(size_type __n) {__table_.rehash(__n);}
+};
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
+        size_type __n, const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
+        size_type __n, const hasher& __hf, const key_equal& __eql,
+        const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
+        _InputIterator __first, _InputIterator __last)
+{
+    __table_.rehash(193);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
+        const hash_multiset& __u)
+    : __table_(__u.__table_)
+{
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                         _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_multi(*__first);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+     hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+           const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename hash_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    typedef pair<const_iterator, const_iterator> _EqRng;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
+    {
+        _EqRng __xeq = __x.equal_range(*__i);
+        _EqRng __yeq = __y.equal_range(*__i);
+        if (_VSTD::distance(__xeq.first, __xeq.second) !=
+            _VSTD::distance(__yeq.first, __yeq.second) ||
+                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
+            return false;
+        __i = __xeq.second;
+    }
+    return true;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+           const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+} // __gnu_cxx
+
+#endif  // _LIBCPP_HASH_SET
diff --git a/final/include/forward_list b/final/include/forward_list
new file mode 100644
index 0000000..72d31dc
--- /dev/null
+++ b/final/include/forward_list
@@ -0,0 +1,1668 @@
+// -*- C++ -*-
+//===----------------------- forward_list ---------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FORWARD_LIST
+#define _LIBCPP_FORWARD_LIST
+
+/*
+    forward_list synopsis
+
+namespace std
+{
+
+template <class T, class Allocator = allocator<T>>
+class forward_list
+{
+public:
+    typedef T         value_type;
+    typedef Allocator allocator_type;
+
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef <details> iterator;
+    typedef <details> const_iterator;
+
+    forward_list()
+        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+    explicit forward_list(const allocator_type& a);
+    explicit forward_list(size_type n);
+    explicit forward_list(size_type n, const allocator_type& a); // C++14
+    forward_list(size_type n, const value_type& v);
+    forward_list(size_type n, const value_type& v, const allocator_type& a);
+    template <class InputIterator>
+        forward_list(InputIterator first, InputIterator last);
+    template <class InputIterator>
+        forward_list(InputIterator first, InputIterator last, const allocator_type& a);
+    forward_list(const forward_list& x);
+    forward_list(const forward_list& x, const allocator_type& a);
+    forward_list(forward_list&& x)
+        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+    forward_list(forward_list&& x, const allocator_type& a);
+    forward_list(initializer_list<value_type> il);
+    forward_list(initializer_list<value_type> il, const allocator_type& a);
+
+    ~forward_list();
+
+    forward_list& operator=(const forward_list& x);
+    forward_list& operator=(forward_list&& x)
+        noexcept(
+             allocator_type::propagate_on_container_move_assignment::value &&
+             is_nothrow_move_assignable<allocator_type>::value);
+    forward_list& operator=(initializer_list<value_type> il);
+
+    template <class InputIterator>
+        void assign(InputIterator first, InputIterator last);
+    void assign(size_type n, const value_type& v);
+    void assign(initializer_list<value_type> il);
+
+    allocator_type get_allocator() const noexcept;
+
+    iterator       begin() noexcept;
+    const_iterator begin() const noexcept;
+    iterator       end() noexcept;
+    const_iterator end() const noexcept;
+
+    const_iterator cbegin() const noexcept;
+    const_iterator cend() const noexcept;
+
+    iterator       before_begin() noexcept;
+    const_iterator before_begin() const noexcept;
+    const_iterator cbefore_begin() const noexcept;
+
+    bool empty() const noexcept;
+    size_type max_size() const noexcept;
+
+    reference       front();
+    const_reference front() const;
+
+    template <class... Args> void emplace_front(Args&&... args);
+    void push_front(const value_type& v);
+    void push_front(value_type&& v);
+
+    void pop_front();
+
+    template <class... Args>
+        iterator emplace_after(const_iterator p, Args&&... args);
+    iterator insert_after(const_iterator p, const value_type& v);
+    iterator insert_after(const_iterator p, value_type&& v);
+    iterator insert_after(const_iterator p, size_type n, const value_type& v);
+    template <class InputIterator>
+        iterator insert_after(const_iterator p,
+                              InputIterator first, InputIterator last);
+    iterator insert_after(const_iterator p, initializer_list<value_type> il);
+
+    iterator erase_after(const_iterator p);
+    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);
+
+    void resize(size_type n);
+    void resize(size_type n, const value_type& v);
+    void clear() noexcept;
+
+    void splice_after(const_iterator p, forward_list& x);
+    void splice_after(const_iterator p, forward_list&& x);
+    void splice_after(const_iterator p, forward_list& x, const_iterator i);
+    void splice_after(const_iterator p, forward_list&& x, const_iterator i);
+    void splice_after(const_iterator p, forward_list& x,
+                      const_iterator first, const_iterator last);
+    void splice_after(const_iterator p, forward_list&& x,
+                      const_iterator first, const_iterator last);
+    void remove(const value_type& v);
+    template <class Predicate> void remove_if(Predicate pred);
+    void unique();
+    template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
+    void merge(forward_list& x);
+    void merge(forward_list&& x);
+    template <class Compare> void merge(forward_list& x, Compare comp);
+    template <class Compare> void merge(forward_list&& x, Compare comp);
+    void sort();
+    template <class Compare> void sort(Compare comp);
+    void reverse() noexcept;
+};
+
+template <class T, class Allocator>
+    bool operator==(const forward_list<T, Allocator>& x,
+                    const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+    bool operator< (const forward_list<T, Allocator>& x,
+                    const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+    bool operator!=(const forward_list<T, Allocator>& x,
+                    const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+    bool operator> (const forward_list<T, Allocator>& x,
+                    const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+    bool operator>=(const forward_list<T, Allocator>& x,
+                    const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+    bool operator<=(const forward_list<T, Allocator>& x,
+                    const forward_list<T, Allocator>& y);
+
+template <class T, class Allocator>
+    void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
+         noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+
+#include <initializer_list>
+#include <memory>
+#include <limits>
+#include <iterator>
+#include <algorithm>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _VoidPtr> struct __forward_list_node;
+
+template <class _NodePtr>
+struct __forward_begin_node
+{
+    typedef _NodePtr pointer;
+
+    pointer __next_;
+
+     _LIBCPP_INLINE_VISIBILITY __forward_begin_node() : __next_(nullptr) {}
+};
+
+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;
+};
+
+template <class _Tp, class _VoidPtr>
+struct __forward_list_node
+    : public __begin_node_of<_Tp, _VoidPtr>::type
+{
+    typedef _Tp value_type;
+
+    value_type __value_;
+};
+
+template<class _Tp, class _Alloc> 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;
+
+    __node_pointer __ptr_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__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 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;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return __ptr_->__value_;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_iterator& operator++()
+    {
+        __ptr_ = __ptr_->__next_;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_iterator operator++(int)
+    {
+        __forward_list_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __forward_list_iterator& __x,
+                    const __forward_list_iterator& __y)
+        {return __x.__ptr_ == __y.__ptr_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __forward_list_iterator& __x,
+                    const __forward_list_iterator& __y)
+        {return !(__x == __y);}
+};
+
+template <class _NodeConstPtr>
+class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator
+{
+    typedef _NodeConstPtr __node_const_pointer;
+
+    __node_const_pointer __ptr_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __forward_list_const_iterator(__node_const_pointer __p) _NOEXCEPT
+        : __ptr_(__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 const value_type&                                 reference;
+    typedef typename pointer_traits<__node_const_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
+                                                              pointer;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_const_iterator(__forward_list_iterator<__node_pointer> __p) _NOEXCEPT
+        : __ptr_(__p.__ptr_) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return __ptr_->__value_;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_const_iterator& operator++()
+    {
+        __ptr_ = __ptr_->__next_;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_const_iterator operator++(int)
+    {
+        __forward_list_const_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __forward_list_const_iterator& __x,
+                    const __forward_list_const_iterator& __y)
+        {return __x.__ptr_ == __y.__ptr_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __forward_list_const_iterator& __x,
+                           const __forward_list_const_iterator& __y)
+        {return !(__x == __y);}
+};
+
+template <class _Tp, class _Alloc>
+class __forward_list_base
+{
+protected:
+    typedef _Tp    value_type;
+    typedef _Alloc allocator_type;
+
+    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 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;
+
+    __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()));}
+    _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())));}
+
+    _LIBCPP_INLINE_VISIBILITY
+          __node_allocator& __alloc() _NOEXCEPT
+            {return __before_begin_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const __node_allocator& __alloc() const _NOEXCEPT
+        {return __before_begin_.second();}
+
+    typedef __forward_list_iterator<__node_pointer>             iterator;
+    typedef __forward_list_const_iterator<__node_pointer>       const_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_base()
+        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+        : __before_begin_(__begin_node()) {}
+    _LIBCPP_INLINE_VISIBILITY
+    __forward_list_base(const allocator_type& __a)
+        : __before_begin_(__begin_node(), __node_allocator(__a)) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    __forward_list_base(__forward_list_base&& __x)
+        _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
+    __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+private:
+    __forward_list_base(const __forward_list_base&);
+    __forward_list_base& operator=(const __forward_list_base&);
+
+public:
+    ~__forward_list_base();
+
+protected:
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __forward_list_base& __x)
+        {__copy_assign_alloc(__x, integral_constant<bool,
+              __node_traits::propagate_on_container_copy_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__forward_list_base& __x)
+        _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
+                   is_nothrow_move_assignable<__node_allocator>::value)
+        {__move_assign_alloc(__x, integral_constant<bool,
+              __node_traits::propagate_on_container_move_assignment::value>());}
+
+public:
+    void swap(__forward_list_base& __x)
+        _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<__node_allocator>::value);
+protected:
+    void clear() _NOEXCEPT;
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __forward_list_base&, false_type) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __forward_list_base& __x, true_type)
+    {
+        if (__alloc() != __x.__alloc())
+            clear();
+        __alloc() = __x.__alloc();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__forward_list_base& __x, false_type) _NOEXCEPT
+        {}
+    _LIBCPP_INLINE_VISIBILITY
+    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
+__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_))
+{
+    __x.__before_begin()->__next_ = nullptr;
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+__forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x,
+                                                      const allocator_type& __a)
+    : __before_begin_(__begin_node(), __node_allocator(__a))
+{
+    if (__alloc() == __x.__alloc())
+    {
+        __before_begin()->__next_ = __x.__before_begin()->__next_;
+        __x.__before_begin()->__next_ = nullptr;
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+__forward_list_base<_Tp, _Alloc>::~__forward_list_base()
+{
+    clear();
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+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)
+{
+    __swap_alloc(__alloc(), __x.__alloc());
+    using _VSTD::swap;
+    swap(__before_begin()->__next_, __x.__before_begin()->__next_);
+}
+
+template <class _Tp, class _Alloc>
+void
+__forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT
+{
+    __node_allocator& __a = __alloc();
+    for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;)
+    {
+        __node_pointer __next = __p->__next_;
+        __node_traits::destroy(__a, _VSTD::addressof(__p->__value_));
+        __node_traits::deallocate(__a, __p, 1);
+        __p = __next;
+    }
+    __before_begin()->__next_ = nullptr;
+}
+
+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;
+
+public:
+    typedef _Tp    value_type;
+    typedef _Alloc allocator_type;
+
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef typename base::iterator       iterator;
+    typedef typename base::const_iterator const_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    forward_list()
+        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+        {} // = default;
+    explicit forward_list(const allocator_type& __a);
+    explicit forward_list(size_type __n);
+#if _LIBCPP_STD_VER > 11
+    explicit forward_list(size_type __n, const allocator_type& __a);
+#endif
+    forward_list(size_type __n, const value_type& __v);
+    forward_list(size_type __n, const value_type& __v, const allocator_type& __a);
+    template <class _InputIterator>
+        forward_list(_InputIterator __f, _InputIterator __l,
+                     typename enable_if<
+                       __is_input_iterator<_InputIterator>::value
+                     >::type* = nullptr);
+    template <class _InputIterator>
+        forward_list(_InputIterator __f, _InputIterator __l,
+                     const allocator_type& __a,
+                     typename enable_if<
+                       __is_input_iterator<_InputIterator>::value
+                     >::type* = nullptr);
+    forward_list(const forward_list& __x);
+    forward_list(const forward_list& __x, const allocator_type& __a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    forward_list(forward_list&& __x)
+        _NOEXCEPT_(is_nothrow_move_constructible<base>::value)
+        : base(_VSTD::move(__x)) {}
+    forward_list(forward_list&& __x, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    forward_list(initializer_list<value_type> __il);
+    forward_list(initializer_list<value_type> __il, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    // ~forward_list() = default;
+
+    forward_list& operator=(const forward_list& __x);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    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
+    forward_list& operator=(initializer_list<value_type> __il);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template <class _InputIterator>
+        typename enable_if
+        <
+            __is_input_iterator<_InputIterator>::value,
+            void
+        >::type
+        assign(_InputIterator __f, _InputIterator __l);
+    void assign(size_type __n, const value_type& __v);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    void assign(initializer_list<value_type> __il);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT
+        {return allocator_type(base::__alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin() _NOEXCEPT
+        {return       iterator(base::__before_begin()->__next_);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT
+        {return const_iterator(base::__before_begin()->__next_);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end() _NOEXCEPT
+        {return       iterator(nullptr);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT
+        {return const_iterator(nullptr);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT
+        {return const_iterator(base::__before_begin()->__next_);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT
+        {return const_iterator(nullptr);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       before_begin() _NOEXCEPT
+        {return       iterator(base::__before_begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator before_begin() const _NOEXCEPT
+        {return const_iterator(base::__before_begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbefore_begin() const _NOEXCEPT
+        {return const_iterator(base::__before_begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT
+        {return base::__before_begin()->__next_ == nullptr;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT
+        {return numeric_limits<size_type>::max();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference       front()       {return base::__before_begin()->__next_->__value_;}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference front() const {return base::__before_begin()->__next_->__value_;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args> void emplace_front(_Args&&... __args);
+#endif
+    void push_front(value_type&& __v);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void push_front(const value_type& __v);
+
+    void pop_front();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args>
+        iterator emplace_after(const_iterator __p, _Args&&... __args);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+    iterator insert_after(const_iterator __p, value_type&& __v);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    iterator insert_after(const_iterator __p, const value_type& __v);
+    iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_input_iterator<_InputIterator>::value,
+            iterator
+        >::type
+        insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    iterator insert_after(const_iterator __p, initializer_list<value_type> __il)
+        {return insert_after(__p, __il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    iterator erase_after(const_iterator __p);
+    iterator erase_after(const_iterator __f, const_iterator __l);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(forward_list& __x)
+        _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<__node_allocator>::value)
+        {base::swap(__x);}
+
+    void resize(size_type __n);
+    void resize(size_type __n, const value_type& __v);
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {base::clear();}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void splice_after(const_iterator __p, forward_list&& __x);
+    _LIBCPP_INLINE_VISIBILITY
+    void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i);
+    _LIBCPP_INLINE_VISIBILITY
+    void splice_after(const_iterator __p, forward_list&& __x,
+                      const_iterator __f, const_iterator __l);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void splice_after(const_iterator __p, forward_list& __x);
+    void splice_after(const_iterator __p, forward_list& __x, const_iterator __i);
+    void splice_after(const_iterator __p, forward_list& __x,
+                      const_iterator __f, const_iterator __l);
+    void remove(const value_type& __v);
+    template <class _Predicate> void remove_if(_Predicate __pred);
+    _LIBCPP_INLINE_VISIBILITY
+    void unique() {unique(__equal_to<value_type>());}
+    template <class _BinaryPredicate> void unique(_BinaryPredicate __binary_pred);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void merge(forward_list&& __x) {merge(__x, __less<value_type>());}
+    template <class _Compare>
+        _LIBCPP_INLINE_VISIBILITY
+        void merge(forward_list&& __x, _Compare __comp)
+        {merge(__x, _VSTD::move(__comp));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void merge(forward_list& __x) {merge(__x, __less<value_type>());}
+    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);
+    void reverse() _NOEXCEPT;
+
+private:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void __move_assign(forward_list& __x, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+    void __move_assign(forward_list& __x, false_type);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    template <class _Compare>
+        static
+        __node_pointer
+        __merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp);
+
+    template <class _Compare>
+        static
+        __node_pointer
+        __sort(__node_pointer __f, difference_type __sz, _Compare& __comp);
+};
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a)
+    : base(__a)
+{
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n)
+{
+    if (__n > 0)
+    {
+        __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_)
+        {
+            __h.reset(__node_traits::allocate(__a, 1));
+            __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
+            __h->__next_ = nullptr;
+            __p->__next_ = __h.release();
+        }
+    }
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a)
+    : base ( __a )
+{
+    if (__n > 0)
+    {
+        __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_)
+        {
+            __h.reset(__node_traits::allocate(__a, 1));
+            __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
+            __h->__next_ = nullptr;
+            __p->__next_ = __h.release();
+        }
+    }
+}
+#endif
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v)
+{
+    insert_after(cbefore_begin(), __n, __v);
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v,
+                                        const allocator_type& __a)
+    : base(__a)
+{
+    insert_after(cbefore_begin(), __n, __v);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
+                                        typename enable_if<
+                                          __is_input_iterator<_InputIterator>::value
+                                        >::type*)
+{
+    insert_after(cbefore_begin(), __f, __l);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
+                                        const allocator_type& __a,
+                                        typename enable_if<
+                                          __is_input_iterator<_InputIterator>::value
+                                        >::type*)
+    : base(__a)
+{
+    insert_after(cbefore_begin(), __f, __l);
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
+    : base(allocator_type(
+             __node_traits::select_on_container_copy_construction(__x.__alloc())
+                         )
+          )
+{
+    insert_after(cbefore_begin(), __x.begin(), __x.end());
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x,
+                                        const allocator_type& __a)
+    : base(__a)
+{
+    insert_after(cbefore_begin(), __x.begin(), __x.end());
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x,
+                                        const allocator_type& __a)
+    : base(_VSTD::move(__x), __a)
+{
+    if (base::__alloc() != __x.__alloc())
+    {
+        typedef move_iterator<iterator> _Ip;
+        insert_after(cbefore_begin(), _Ip(__x.begin()), _Ip(__x.end()));
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il)
+{
+    insert_after(cbefore_begin(), __il.begin(), __il.end());
+}
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il,
+                                        const allocator_type& __a)
+    : base(__a)
+{
+    insert_after(cbefore_begin(), __il.begin(), __il.end());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Alloc>
+forward_list<_Tp, _Alloc>&
+forward_list<_Tp, _Alloc>::operator=(const forward_list& __x)
+{
+    if (this != &__x)
+    {
+        base::__copy_assign_alloc(__x);
+        assign(__x.begin(), __x.end());
+    }
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)
+    _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+    clear();
+    base::__move_assign_alloc(__x);
+    base::__before_begin()->__next_ = __x.__before_begin()->__next_;
+    __x.__before_begin()->__next_ = nullptr;
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type)
+{
+    if (base::__alloc() == __x.__alloc())
+        __move_assign(__x, true_type());
+    else
+    {
+        typedef move_iterator<iterator> _Ip;
+        assign(_Ip(__x.begin()), _Ip(__x.end()));
+    }
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+forward_list<_Tp, _Alloc>&
+forward_list<_Tp, _Alloc>::operator=(forward_list&& __x)
+    _NOEXCEPT_(
+             __node_traits::propagate_on_container_move_assignment::value &&
+             is_nothrow_move_assignable<allocator_type>::value)
+{
+    __move_assign(__x, integral_constant<bool,
+          __node_traits::propagate_on_container_move_assignment::value>());
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+forward_list<_Tp, _Alloc>&
+forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il)
+{
+    assign(__il.begin(), __il.end());
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+typename enable_if
+<
+    __is_input_iterator<_InputIterator>::value,
+    void
+>::type
+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)
+        *__j = *__f;
+    if (__j == __e)
+        insert_after(__i, __f, __l);
+    else
+        erase_after(__i, __e);
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v)
+{
+    iterator __i = before_begin();
+    iterator __j = _VSTD::next(__i);
+    iterator __e = end();
+    for (; __j != __e && __n > 0; --__n, ++__i, ++__j)
+        *__j = __v;
+    if (__j == __e)
+        insert_after(__i, __n, __v);
+    else
+        erase_after(__i, __e);
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)
+{
+    assign(__il.begin(), __il.end());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+void
+forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
+{
+    __node_allocator& __a = base::__alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+    __node_traits::construct(__a, _VSTD::addressof(__h->__value_),
+                                  _VSTD::forward<_Args>(__args)...);
+    __h->__next_ = base::__before_begin()->__next_;
+    base::__before_begin()->__next_ = __h.release();
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::push_front(value_type&& __v)
+{
+    __node_allocator& __a = base::__alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+    __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v));
+    __h->__next_ = base::__before_begin()->__next_;
+    base::__before_begin()->__next_ = __h.release();
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::push_front(const value_type& __v)
+{
+    __node_allocator& __a = base::__alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+    __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+    __h->__next_ = base::__before_begin()->__next_;
+    base::__before_begin()->__next_ = __h.release();
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::pop_front()
+{
+    __node_allocator& __a = base::__alloc();
+    __node_pointer __p = base::__before_begin()->__next_;
+    base::__before_begin()->__next_ = __p->__next_;
+    __node_traits::destroy(__a, _VSTD::addressof(__p->__value_));
+    __node_traits::deallocate(__a, __p, 1);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Alloc>
+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_;
+    __node_allocator& __a = base::__alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+    __node_traits::construct(__a, _VSTD::addressof(__h->__value_),
+                                  _VSTD::forward<_Args>(__args)...);
+    __h->__next_ = __r->__next_;
+    __r->__next_ = __h.release();
+    return iterator(__r->__next_);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+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_;
+    __node_allocator& __a = base::__alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+    __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v));
+    __h->__next_ = __r->__next_;
+    __r->__next_ = __h.release();
+    return iterator(__r->__next_);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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_;
+    __node_allocator& __a = base::__alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+    __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+    __h->__next_ = __r->__next_;
+    __r->__next_ = __h.release();
+    return iterator(__r->__next_);
+}
+
+template <class _Tp, class _Alloc>
+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_;
+    if (__n > 0)
+    {
+        __node_allocator& __a = base::__alloc();
+        typedef __allocator_destructor<__node_allocator> _Dp;
+        unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+        __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+        __node_pointer __first = __h.release();
+        __node_pointer __last = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (--__n; __n != 0; --__n, __last = __last->__next_)
+            {
+                __h.reset(__node_traits::allocate(__a, 1));
+                __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+                __last->__next_ = __h.release();
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (__first != nullptr)
+            {
+                __node_pointer __next = __first->__next_;
+                __node_traits::destroy(__a, _VSTD::addressof(__first->__value_));
+                __node_traits::deallocate(__a, __first, 1);
+                __first = __next;
+            }
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __last->__next_ = __r->__next_;
+        __r->__next_ = __first;
+        __r = __last;
+    }
+    return iterator(__r);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InputIterator>
+typename enable_if
+<
+    __is_input_iterator<_InputIterator>::value,
+    typename forward_list<_Tp, _Alloc>::iterator
+>::type
+forward_list<_Tp, _Alloc>::insert_after(const_iterator __p,
+                                        _InputIterator __f, _InputIterator __l)
+{
+    __node_pointer __r = __p.__ptr_;
+    if (__f != __l)
+    {
+        __node_allocator& __a = base::__alloc();
+        typedef __allocator_destructor<__node_allocator> _Dp;
+        unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1));
+        __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
+        __node_pointer __first = __h.release();
+        __node_pointer __last = __first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (++__f; __f != __l; ++__f, __last = __last->__next_)
+            {
+                __h.reset(__node_traits::allocate(__a, 1));
+                __node_traits::construct(__a, _VSTD::addressof(__h->__value_), *__f);
+                __last->__next_ = __h.release();
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (__first != nullptr)
+            {
+                __node_pointer __next = __first->__next_;
+                __node_traits::destroy(__a, _VSTD::addressof(__first->__value_));
+                __node_traits::deallocate(__a, __first, 1);
+                __first = __next;
+            }
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __last->__next_ = __r->__next_;
+        __r->__next_ = __first;
+        __r = __last;
+    }
+    return iterator(__r);
+}
+
+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_;
+    __node_pointer __n = __p->__next_;
+    __p->__next_ = __n->__next_;
+    __node_allocator& __a = base::__alloc();
+    __node_traits::destroy(__a, _VSTD::addressof(__n->__value_));
+    __node_traits::deallocate(__a, __n, 1);
+    return iterator(__p->__next_);
+}
+
+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_;
+    if (__f != __l)
+    {
+        __node_pointer __p = __f.__ptr_;
+        __node_pointer __n = __p->__next_;
+        if (__n != __e)
+        {
+            __p->__next_ = __e;
+            __node_allocator& __a = base::__alloc();
+            do
+            {
+                __p = __n->__next_;
+                __node_traits::destroy(__a, _VSTD::addressof(__n->__value_));
+                __node_traits::deallocate(__a, __n, 1);
+                __n = __p;
+            } while (__n != __e);
+        }
+    }
+    return iterator(__e);
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::resize(size_type __n)
+{
+    size_type __sz = 0;
+    iterator __p = before_begin();
+    iterator __i = begin();
+    iterator __e = end();
+    for (; __i != __e && __sz < __n; ++__p, ++__i, ++__sz)
+        ;
+    if (__i != __e)
+        erase_after(__p, __e);
+    else
+    {
+        __n -= __sz;
+        if (__n > 0)
+        {
+            __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_)
+            {
+                __h.reset(__node_traits::allocate(__a, 1));
+                __node_traits::construct(__a, _VSTD::addressof(__h->__value_));
+                __h->__next_ = nullptr;
+                __ptr->__next_ = __h.release();
+            }
+        }
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v)
+{
+    size_type __sz = 0;
+    iterator __p = before_begin();
+    iterator __i = begin();
+    iterator __e = end();
+    for (; __i != __e && __sz < __n; ++__p, ++__i, ++__sz)
+        ;
+    if (__i != __e)
+        erase_after(__p, __e);
+    else
+    {
+        __n -= __sz;
+        if (__n > 0)
+        {
+            __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_)
+            {
+                __h.reset(__node_traits::allocate(__a, 1));
+                __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v);
+                __h->__next_ = nullptr;
+                __ptr->__next_ = __h.release();
+            }
+        }
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+                                        forward_list& __x)
+{
+    if (!__x.empty())
+    {
+        if (__p.__ptr_->__next_ != nullptr)
+        {
+            const_iterator __lm1 = __x.before_begin();
+            while (__lm1.__ptr_->__next_ != nullptr)
+                ++__lm1;
+            __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
+        }
+        __p.__ptr_->__next_ = __x.__before_begin()->__next_;
+        __x.__before_begin()->__next_ = nullptr;
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+                                        forward_list& __x,
+                                        const_iterator __i)
+{
+    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_;
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+                                        forward_list& __x,
+                                        const_iterator __f, const_iterator __l)
+{
+    if (__f != __l && __p != __f)
+    {
+        const_iterator __lm1 = __f;
+        while (__lm1.__ptr_->__next_ != __l.__ptr_)
+            ++__lm1;
+        if (__f != __lm1)
+        {
+            __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
+            __p.__ptr_->__next_ = __f.__ptr_->__next_;
+            __f.__ptr_->__next_ = __l.__ptr_;
+        }
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+                                        forward_list&& __x)
+{
+    splice_after(__p, __x);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+                                        forward_list&& __x,
+                                        const_iterator __i)
+{
+    splice_after(__p, __x, __i);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
+                                        forward_list&& __x,
+                                        const_iterator __f, const_iterator __l)
+{
+    splice_after(__p, __x, __f, __l);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::remove(const value_type& __v)
+{
+    iterator __e = end();
+    for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
+    {
+        if (__i.__ptr_->__next_->__value_ == __v)
+        {
+            iterator __j = _VSTD::next(__i, 2);
+            for (; __j != __e && *__j == __v; ++__j)
+                ;
+            erase_after(__i, __j);
+            if (__j == __e)
+                break;
+            __i = __j;
+        }
+        else
+            ++__i;
+    }
+}
+
+template <class _Tp, class _Alloc>
+template <class _Predicate>
+void
+forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
+{
+    iterator __e = end();
+    for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;)
+    {
+        if (__pred(__i.__ptr_->__next_->__value_))
+        {
+            iterator __j = _VSTD::next(__i, 2);
+            for (; __j != __e && __pred(*__j); ++__j)
+                ;
+            erase_after(__i, __j);
+            if (__j == __e)
+                break;
+            __i = __j;
+        }
+        else
+            ++__i;
+    }
+}
+
+template <class _Tp, class _Alloc>
+template <class _BinaryPredicate>
+void
+forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
+{
+    for (iterator __i = begin(), __e = end(); __i != __e;)
+    {
+        iterator __j = _VSTD::next(__i);
+        for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
+            ;
+        if (__i.__ptr_->__next_ != __j.__ptr_)
+            erase_after(__i, __j);
+        __i = __j;
+    }
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+void
+forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp)
+{
+    if (this != &__x)
+    {
+        base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_,
+                                                    __x.__before_begin()->__next_,
+                                                    __comp);
+        __x.__before_begin()->__next_ = nullptr;
+    }
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+typename forward_list<_Tp, _Alloc>::__node_pointer
+forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2,
+                                   _Compare& __comp)
+{
+    if (__f1 == nullptr)
+        return __f2;
+    if (__f2 == nullptr)
+        return __f1;
+    __node_pointer __r;
+    if (__comp(__f2->__value_, __f1->__value_))
+    {
+        __node_pointer __t = __f2;
+        while (__t->__next_ != nullptr &&
+                             __comp(__t->__next_->__value_, __f1->__value_))
+            __t = __t->__next_;
+        __r = __f2;
+        __f2 = __t->__next_;
+        __t->__next_ = __f1;
+    }
+    else
+        __r = __f1;
+    __node_pointer __p = __f1;
+    __f1 = __f1->__next_;
+    while (__f1 != nullptr && __f2 != nullptr)
+    {
+        if (__comp(__f2->__value_, __f1->__value_))
+        {
+            __node_pointer __t = __f2;
+            while (__t->__next_ != nullptr &&
+                                 __comp(__t->__next_->__value_, __f1->__value_))
+                __t = __t->__next_;
+            __p->__next_ = __f2;
+            __f2 = __t->__next_;
+            __t->__next_ = __f1;
+        }
+        __p = __f1;
+        __f1 = __f1->__next_;
+    }
+    if (__f2 != nullptr)
+        __p->__next_ = __f2;
+    return __r;
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+forward_list<_Tp, _Alloc>::sort(_Compare __comp)
+{
+    base::__before_begin()->__next_ = __sort(base::__before_begin()->__next_,
+                                       _VSTD::distance(begin(), end()), __comp);
+}
+
+template <class _Tp, class _Alloc>
+template <class _Compare>
+typename forward_list<_Tp, _Alloc>::__node_pointer
+forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz,
+                                  _Compare& __comp)
+{
+    switch (__sz)
+    {
+    case 0:
+    case 1:
+        return __f1;
+    case 2:
+        if (__comp(__f1->__next_->__value_, __f1->__value_))
+        {
+            __node_pointer __t = __f1->__next_;
+            __t->__next_ = __f1;
+            __f1->__next_ = nullptr;
+            __f1 = __t;
+        }
+        return __f1;
+    }
+    difference_type __sz1 = __sz / 2;
+    difference_type __sz2 = __sz - __sz1;
+    __node_pointer __t = _VSTD::next(iterator(__f1), __sz1 - 1).__ptr_;
+    __node_pointer __f2 = __t->__next_;
+    __t->__next_ = nullptr;
+    return __merge(__sort(__f1, __sz1, __comp),
+                   __sort(__f2, __sz2, __comp), __comp);
+}
+
+template <class _Tp, class _Alloc>
+void
+forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT
+{
+    __node_pointer __p = base::__before_begin()->__next_;
+    if (__p != nullptr)
+    {
+        __node_pointer __f = __p->__next_;
+        __p->__next_ = nullptr;
+        while (__f != nullptr)
+        {
+            __node_pointer __t = __f->__next_;
+            __f->__next_ = __p;
+            __p = __f;
+            __f = __t;
+        }
+        base::__before_begin()->__next_ = __p;
+    }
+}
+
+template <class _Tp, class _Alloc>
+bool operator==(const forward_list<_Tp, _Alloc>& __x,
+                const forward_list<_Tp, _Alloc>& __y)
+{
+    typedef forward_list<_Tp, _Alloc> _Cp;
+    typedef typename _Cp::const_iterator _Ip;
+    _Ip __ix = __x.begin();
+    _Ip __ex = __x.end();
+    _Ip __iy = __y.begin();
+    _Ip __ey = __y.end();
+    for (; __ix != __ex && __iy != __ey; ++__ix, ++__iy)
+        if (!(*__ix == *__iy))
+            return false;
+    return (__ix == __ex) == (__iy == __ey);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator!=(const forward_list<_Tp, _Alloc>& __x,
+                const forward_list<_Tp, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator< (const forward_list<_Tp, _Alloc>& __x,
+                const forward_list<_Tp, _Alloc>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
+                                         __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator> (const forward_list<_Tp, _Alloc>& __x,
+                const forward_list<_Tp, _Alloc>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator>=(const forward_list<_Tp, _Alloc>& __x,
+                const forward_list<_Tp, _Alloc>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator<=(const forward_list<_Tp, _Alloc>& __x,
+                const forward_list<_Tp, _Alloc>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_FORWARD_LIST
diff --git a/final/include/fstream b/final/include/fstream
new file mode 100644
index 0000000..38778c6
--- /dev/null
+++ b/final/include/fstream
@@ -0,0 +1,1431 @@
+// -*- C++ -*-
+//===------------------------- fstream ------------------------------------===//
+//
+//                     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_FSTREAM
+#define _LIBCPP_FSTREAM
+
+/*
+    fstream synopsis
+
+template <class charT, class traits = char_traits<charT> >
+class basic_filebuf
+    : public basic_streambuf<charT, traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // 27.9.1.2 Constructors/destructor:
+    basic_filebuf();
+    basic_filebuf(basic_filebuf&& rhs);
+    virtual ~basic_filebuf();
+
+    // 27.9.1.3 Assign/swap:
+    basic_filebuf& operator=(basic_filebuf&& rhs);
+    void swap(basic_filebuf& rhs);
+
+    // 27.9.1.4 Members:
+    bool is_open() const;
+    basic_filebuf* open(const char* s, ios_base::openmode mode);
+    basic_filebuf* open(const string& s, ios_base::openmode mode);
+    basic_filebuf* close();
+
+protected:
+    // 27.9.1.5 Overridden virtual functions:
+    virtual streamsize showmanyc();
+    virtual int_type underflow();
+    virtual int_type uflow();
+    virtual int_type pbackfail(int_type c = traits_type::eof());
+    virtual int_type overflow (int_type c = traits_type::eof());
+    virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* s, streamsize n);
+    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type sp,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual int sync();
+    virtual void imbue(const locale& loc);
+};
+
+template <class charT, class traits>
+  void
+  swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
+
+typedef basic_filebuf<char>    filebuf;
+typedef basic_filebuf<wchar_t> wfilebuf;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ifstream
+    : public basic_istream<charT,traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ifstream();
+    explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
+    explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
+    basic_ifstream(basic_ifstream&& rhs);
+
+    basic_ifstream& operator=(basic_ifstream&& rhs);
+    void swap(basic_ifstream& rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* s, ios_base::openmode mode = ios_base::in);
+    void open(const string& s, ios_base::openmode mode = ios_base::in);
+    void close();
+};
+
+template <class charT, class traits>
+  void
+  swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
+
+typedef basic_ifstream<char>    ifstream;
+typedef basic_ifstream<wchar_t> wifstream;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ofstream
+    : public basic_ostream<charT,traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ofstream();
+    explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
+    explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
+    basic_ofstream(basic_ofstream&& rhs);
+
+    basic_ofstream& operator=(basic_ofstream&& rhs);
+    void swap(basic_ofstream& rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* s, ios_base::openmode mode = ios_base::out);
+    void open(const string& s, ios_base::openmode mode = ios_base::out);
+    void close();
+};
+
+template <class charT, class traits>
+  void
+  swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
+
+typedef basic_ofstream<char>    ofstream;
+typedef basic_ofstream<wchar_t> wofstream;
+
+template <class charT, class traits=char_traits<charT> >
+class basic_fstream
+    : public basic_iostream<charT,traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_fstream();
+    explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+    explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+    basic_fstream(basic_fstream&& rhs);
+
+    basic_fstream& operator=(basic_fstream&& rhs);
+    void swap(basic_fstream& rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    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);
+    void close();
+};
+
+template <class charT, class traits>
+  void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
+
+typedef basic_fstream<char>    fstream;
+typedef basic_fstream<wchar_t> wfstream;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <ostream>
+#include <istream>
+#include <__locale>
+#include <cstdio>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_filebuf
+    : public basic_streambuf<_CharT, _Traits>
+{
+public:
+    typedef _CharT                           char_type;
+    typedef _Traits                          traits_type;
+    typedef typename traits_type::int_type   int_type;
+    typedef typename traits_type::pos_type   pos_type;
+    typedef typename traits_type::off_type   off_type;
+    typedef typename traits_type::state_type state_type;
+
+    // 27.9.1.2 Constructors/destructor:
+    basic_filebuf();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_filebuf(basic_filebuf&& __rhs);
+#endif
+    virtual ~basic_filebuf();
+
+    // 27.9.1.3 Assign/swap:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_filebuf& operator=(basic_filebuf&& __rhs);
+#endif
+    void swap(basic_filebuf& __rhs);
+
+    // 27.9.1.4 Members:
+    bool is_open() const;
+    basic_filebuf* open(const char* __s, ios_base::openmode __mode);
+    basic_filebuf* open(const string& __s, ios_base::openmode __mode);
+    basic_filebuf* close();
+
+protected:
+    // 27.9.1.5 Overridden virtual functions:
+    virtual int_type underflow();
+    virtual int_type pbackfail(int_type __c = traits_type::eof());
+    virtual int_type overflow (int_type __c = traits_type::eof());
+    virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);
+    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type __sp,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+    virtual int sync();
+    virtual void imbue(const locale& __loc);
+
+private:
+    char*       __extbuf_;
+    const char* __extbufnext_;
+    const char* __extbufend_;
+    char __extbuf_min_[8];
+    size_t __ebs_;
+    char_type* __intbuf_;
+    size_t __ibs_;
+    FILE* __file_;
+    const codecvt<char_type, char, state_type>* __cv_;
+    state_type __st_;
+    state_type __st_last_;
+    ios_base::openmode __om_;
+    ios_base::openmode __cm_;
+    bool __owns_eb_;
+    bool __owns_ib_;
+    bool __always_noconv_;
+
+    bool __read_mode();
+    void __write_mode();
+};
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::basic_filebuf()
+    : __extbuf_(0),
+      __extbufnext_(0),
+      __extbufend_(0),
+      __ebs_(0),
+      __intbuf_(0),
+      __ibs_(0),
+      __file_(0),
+      __cv_(nullptr),
+      __st_(),
+      __st_last_(),
+      __om_(0),
+      __cm_(0),
+      __owns_eb_(false),
+      __owns_ib_(false),
+      __always_noconv_(false)
+{
+    if (has_facet<codecvt<char_type, char, state_type> >(this->getloc()))
+    {
+        __cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
+        __always_noconv_ = __cv_->always_noconv();
+    }
+    setbuf(0, 4096);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
+    : basic_streambuf<_CharT, _Traits>(__rhs)
+{
+    if (__rhs.__extbuf_ == __rhs.__extbuf_min_)
+    {
+        __extbuf_ = __extbuf_min_;
+        __extbufnext_ = __extbuf_ + (__rhs.__extbufnext_ - __rhs.__extbuf_);
+        __extbufend_ = __extbuf_ + (__rhs.__extbufend_ - __rhs.__extbuf_);
+    }
+    else
+    {
+        __extbuf_ = __rhs.__extbuf_;
+        __extbufnext_ = __rhs.__extbufnext_;
+        __extbufend_ = __rhs.__extbufend_;
+    }
+    __ebs_ = __rhs.__ebs_;
+    __intbuf_ = __rhs.__intbuf_;
+    __ibs_ = __rhs.__ibs_;
+    __file_ = __rhs.__file_;
+    __cv_ = __rhs.__cv_;
+    __st_ = __rhs.__st_;
+    __st_last_ = __rhs.__st_last_;
+    __om_ = __rhs.__om_;
+    __cm_ = __rhs.__cm_;
+    __owns_eb_ = __rhs.__owns_eb_;
+    __owns_ib_ = __rhs.__owns_ib_;
+    __always_noconv_ = __rhs.__always_noconv_;
+    if (__rhs.pbase())
+    {
+        if (__rhs.pbase() == __rhs.__intbuf_)
+            this->setp(__intbuf_, __intbuf_ + (__rhs. epptr() - __rhs.pbase()));
+        else
+            this->setp((char_type*)__extbuf_,
+                       (char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase()));
+        this->pbump(__rhs. pptr() - __rhs.pbase());
+    }
+    else if (__rhs.eback())
+    {
+        if (__rhs.eback() == __rhs.__intbuf_)
+            this->setg(__intbuf_, __intbuf_ + (__rhs.gptr() - __rhs.eback()),
+                                  __intbuf_ + (__rhs.egptr() - __rhs.eback()));
+        else
+            this->setg((char_type*)__extbuf_,
+                       (char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),
+                       (char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));
+    }
+    __rhs.__extbuf_ = 0;
+    __rhs.__extbufnext_ = 0;
+    __rhs.__extbufend_ = 0;
+    __rhs.__ebs_ = 0;
+    __rhs.__intbuf_ = 0;
+    __rhs.__ibs_ = 0;
+    __rhs.__file_ = 0;
+    __rhs.__st_ = state_type();
+    __rhs.__st_last_ = state_type();
+    __rhs.__om_ = 0;
+    __rhs.__cm_ = 0;
+    __rhs.__owns_eb_ = false;
+    __rhs.__owns_ib_ = false;
+    __rhs.setg(0, 0, 0);
+    __rhs.setp(0, 0);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>&
+basic_filebuf<_CharT, _Traits>::operator=(basic_filebuf&& __rhs)
+{
+    close();
+    swap(__rhs);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>::~basic_filebuf()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        close();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    if (__owns_eb_)
+        delete [] __extbuf_;
+    if (__owns_ib_)
+        delete [] __intbuf_;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
+{
+    basic_streambuf<char_type, traits_type>::swap(__rhs);
+    if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
+    {
+        _VSTD::swap(__extbuf_, __rhs.__extbuf_);
+        _VSTD::swap(__extbufnext_, __rhs.__extbufnext_);
+        _VSTD::swap(__extbufend_, __rhs.__extbufend_);
+    }
+    else
+    {
+        ptrdiff_t __ln = __extbufnext_ - __extbuf_;
+        ptrdiff_t __le = __extbufend_ - __extbuf_;
+        ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_;
+        ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_;
+        if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_)
+        {
+            __extbuf_ = __rhs.__extbuf_;
+            __rhs.__extbuf_ = __rhs.__extbuf_min_;
+        }
+        else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_)
+        {
+            __rhs.__extbuf_ = __extbuf_;
+            __extbuf_ = __extbuf_min_;
+        }
+        __extbufnext_ = __extbuf_ + __rn;
+        __extbufend_ = __extbuf_ + __re;
+        __rhs.__extbufnext_ = __rhs.__extbuf_ + __ln;
+        __rhs.__extbufend_ = __rhs.__extbuf_ + __le;
+    }
+    _VSTD::swap(__ebs_, __rhs.__ebs_);
+    _VSTD::swap(__intbuf_, __rhs.__intbuf_);
+    _VSTD::swap(__ibs_, __rhs.__ibs_);
+    _VSTD::swap(__file_, __rhs.__file_);
+    _VSTD::swap(__cv_, __rhs.__cv_);
+    _VSTD::swap(__st_, __rhs.__st_);
+    _VSTD::swap(__st_last_, __rhs.__st_last_);
+    _VSTD::swap(__om_, __rhs.__om_);
+    _VSTD::swap(__cm_, __rhs.__cm_);
+    _VSTD::swap(__owns_eb_, __rhs.__owns_eb_);
+    _VSTD::swap(__owns_ib_, __rhs.__owns_ib_);
+    _VSTD::swap(__always_noconv_, __rhs.__always_noconv_);
+    if (this->eback() == (char_type*)__rhs.__extbuf_min_)
+    {
+        ptrdiff_t __n = this->gptr() - this->eback();
+        ptrdiff_t __e = this->egptr() - this->eback();
+        this->setg((char_type*)__extbuf_min_,
+                   (char_type*)__extbuf_min_ + __n,
+                   (char_type*)__extbuf_min_ + __e);
+    }
+    else if (this->pbase() == (char_type*)__rhs.__extbuf_min_)
+    {
+        ptrdiff_t __n = this->pptr() - this->pbase();
+        ptrdiff_t __e = this->epptr() - this->pbase();
+        this->setp((char_type*)__extbuf_min_,
+                   (char_type*)__extbuf_min_ + __e);
+        this->pbump(__n);
+    }
+    if (__rhs.eback() == (char_type*)__extbuf_min_)
+    {
+        ptrdiff_t __n = __rhs.gptr() - __rhs.eback();
+        ptrdiff_t __e = __rhs.egptr() - __rhs.eback();
+        __rhs.setg((char_type*)__rhs.__extbuf_min_,
+                   (char_type*)__rhs.__extbuf_min_ + __n,
+                   (char_type*)__rhs.__extbuf_min_ + __e);
+    }
+    else if (__rhs.pbase() == (char_type*)__extbuf_min_)
+    {
+        ptrdiff_t __n = __rhs.pptr() - __rhs.pbase();
+        ptrdiff_t __e = __rhs.epptr() - __rhs.pbase();
+        __rhs.setp((char_type*)__rhs.__extbuf_min_,
+                   (char_type*)__rhs.__extbuf_min_ + __e);
+        __rhs.pbump(__n);
+    }
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_filebuf<_CharT, _Traits>::is_open() const
+{
+    return __file_ != 0;
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    basic_filebuf<_CharT, _Traits>* __rt = 0;
+    if (__file_ == 0)
+    {
+        __rt = this;
+        const char* __mdstr;
+        switch (__mode & ~ios_base::ate)
+        {
+        case ios_base::out:
+        case ios_base::out | ios_base::trunc:
+            __mdstr = "w";
+            break;
+        case ios_base::out | ios_base::app:
+        case ios_base::app:
+            __mdstr = "a";
+            break;
+        case ios_base::in:
+            __mdstr = "r";
+            break;
+        case ios_base::in | ios_base::out:
+            __mdstr = "r+";
+            break;
+        case ios_base::in | ios_base::out | ios_base::trunc:
+            __mdstr = "w+";
+            break;
+        case ios_base::in | ios_base::out | ios_base::app:
+        case ios_base::in | ios_base::app:
+            __mdstr = "a+";
+            break;
+        case ios_base::out | ios_base::binary:
+        case ios_base::out | ios_base::trunc | ios_base::binary:
+            __mdstr = "wb";
+            break;
+        case ios_base::out | ios_base::app | ios_base::binary:
+        case ios_base::app | ios_base::binary:
+            __mdstr = "ab";
+            break;
+        case ios_base::in | ios_base::binary:
+            __mdstr = "rb";
+            break;
+        case ios_base::in | ios_base::out | ios_base::binary:
+            __mdstr = "r+b";
+            break;
+        case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
+            __mdstr = "w+b";
+            break;
+        case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
+        case ios_base::in | ios_base::app | ios_base::binary:
+            __mdstr = "a+b";
+            break;
+        default:
+            __rt = 0;
+            break;
+        }
+        if (__rt)
+        {
+            __file_ = fopen(__s, __mdstr);
+            if (__file_)
+            {
+                __om_ = __mode;
+                if (__mode & ios_base::ate)
+                {
+                    if (fseek(__file_, 0, SEEK_END))
+                    {
+                        fclose(__file_);
+                        __file_ = 0;
+                        __rt = 0;
+                    }
+                }
+            }
+            else
+                __rt = 0;
+        }
+    }
+    return __rt;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    return open(__s.c_str(), __mode);
+}
+
+template <class _CharT, class _Traits>
+basic_filebuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::close()
+{
+    basic_filebuf<_CharT, _Traits>* __rt = 0;
+    if (__file_)
+    {
+        __rt = this;
+        unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);
+        if (sync())
+            __rt = 0;
+        if (fclose(__h.release()) == 0)
+            __file_ = 0;
+        else
+            __rt = 0;
+    }
+    return __rt;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::underflow()
+{
+    if (__file_ == 0)
+        return traits_type::eof();
+    bool __initial = __read_mode();
+    char_type __1buf;
+    if (this->gptr() == 0)
+        this->setg(&__1buf, &__1buf+1, &__1buf+1);
+    const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
+    int_type __c = traits_type::eof();
+    if (this->gptr() == this->egptr())
+    {
+        memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
+        if (__always_noconv_)
+        {
+            size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
+            __nmemb = fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
+            if (__nmemb != 0)
+            {
+                this->setg(this->eback(),
+                           this->eback() + __unget_sz,
+                           this->eback() + __unget_sz + __nmemb);
+                __c = traits_type::to_int_type(*this->gptr());
+            }
+        }
+        else
+        {
+            memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+            __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
+            __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
+            size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - __unget_sz),
+                                 static_cast<size_t>(__extbufend_ - __extbufnext_));
+            codecvt_base::result __r;
+            __st_last_ = __st_;
+            size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
+            if (__nr != 0)
+            {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (!__cv_)
+                    throw bad_cast();
+#endif
+                __extbufend_ = __extbufnext_ + __nr;
+                char_type*  __inext;
+                __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
+                                       this->eback() + __unget_sz,
+                                       this->eback() + __ibs_, __inext);
+                if (__r == codecvt_base::noconv)
+                {
+                    this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_);
+                    __c = traits_type::to_int_type(*this->gptr());
+                }
+                else if (__inext != this->eback() + __unget_sz)
+                {
+                    this->setg(this->eback(), this->eback() + __unget_sz, __inext);
+                    __c = traits_type::to_int_type(*this->gptr());
+                }
+            }
+        }
+    }
+    else
+        __c = traits_type::to_int_type(*this->gptr());
+    if (this->eback() == &__1buf)
+        this->setg(0, 0, 0);
+    return __c;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::pbackfail(int_type __c)
+{
+    if (__file_ && this->eback() < this->gptr())
+    {
+        if (traits_type::eq_int_type(__c, traits_type::eof()))
+        {
+            this->gbump(-1);
+            return traits_type::not_eof(__c);
+        }
+        if ((__om_ & ios_base::out) ||
+            traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
+        {
+            this->gbump(-1);
+            *this->gptr() = traits_type::to_char_type(__c);
+            return __c;
+        }
+    }
+    return traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::int_type
+basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
+{
+    if (__file_ == 0)
+        return traits_type::eof();
+    __write_mode();
+    char_type __1buf;
+    char_type* __pb_save = this->pbase();
+    char_type* __epb_save = this->epptr();
+    if (!traits_type::eq_int_type(__c, traits_type::eof()))
+    {
+        if (this->pptr() == 0)
+            this->setp(&__1buf, &__1buf+1);
+        *this->pptr() = traits_type::to_char_type(__c);
+        this->pbump(1);
+    }
+    if (this->pptr() != this->pbase())
+    {
+        if (__always_noconv_)
+        {
+            size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+            if (fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)
+                return traits_type::eof();
+        }
+        else
+        {
+            char* __extbe = __extbuf_;
+            codecvt_base::result __r;
+            do
+            {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (!__cv_)
+                    throw bad_cast();
+#endif
+                const char_type* __e;
+                __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
+                                        __extbuf_, __extbuf_ + __ebs_, __extbe);
+                if (__e == this->pbase())
+                    return traits_type::eof();
+                if (__r == codecvt_base::noconv)
+                {
+                    size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+                    if (fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)
+                        return traits_type::eof();
+                }
+                else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
+                {
+                    size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+                    if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
+                        return traits_type::eof();
+                    if (__r == codecvt_base::partial)
+                    {
+                        this->setp((char_type*)__e, this->pptr());
+                        this->pbump(this->epptr() - this->pbase());
+                    }
+                }
+                else
+                    return traits_type::eof();
+            } while (__r == codecvt_base::partial);
+        }
+        this->setp(__pb_save, __epb_save);
+    }
+    return traits_type::not_eof(__c);
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>*
+basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
+{
+    this->setg(0, 0, 0);
+    this->setp(0, 0);
+    if (__owns_eb_)
+        delete [] __extbuf_;
+    if (__owns_ib_)
+        delete [] __intbuf_;
+    __ebs_ = __n;
+    if (__ebs_ > sizeof(__extbuf_min_))
+    {
+        if (__always_noconv_ && __s)
+        {
+            __extbuf_ = (char*)__s;
+            __owns_eb_ = false;
+        }
+        else
+        {
+            __extbuf_ = new char[__ebs_];
+            __owns_eb_ = true;
+        }
+    }
+    else
+    {
+        __extbuf_ = __extbuf_min_;
+        __ebs_ = sizeof(__extbuf_min_);
+        __owns_eb_ = false;
+    }
+    if (!__always_noconv_)
+    {
+        __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
+        if (__s && __ibs_ >= sizeof(__extbuf_min_))
+        {
+            __intbuf_ = __s;
+            __owns_ib_ = false;
+        }
+        else
+        {
+            __intbuf_ = new char_type[__ibs_];
+            __owns_ib_ = true;
+        }
+    }
+    else
+    {
+        __ibs_ = 0;
+        __intbuf_ = 0;
+        __owns_ib_ = false;
+    }
+    return this;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::pos_type
+basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
+                                        ios_base::openmode)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (!__cv_)
+        throw bad_cast();
+#endif
+    int __width = __cv_->encoding();
+    if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
+        return pos_type(off_type(-1));
+    // __width > 0 || __off == 0
+    int __whence;
+    switch (__way)
+    {
+    case ios_base::beg:
+        __whence = SEEK_SET;
+        break;
+    case ios_base::cur:
+        __whence = SEEK_CUR;
+        break;
+    case ios_base::end:
+        __whence = SEEK_END;
+        break;
+    default:
+        return pos_type(off_type(-1));
+    }
+#if _WIN32
+    if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
+        return pos_type(off_type(-1));
+    pos_type __r = ftell(__file_);
+#else
+    if (fseeko(__file_, __width > 0 ? __width * __off : 0, __whence))
+        return pos_type(off_type(-1));
+    pos_type __r = ftello(__file_);
+#endif
+    __r.state(__st_);
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+typename basic_filebuf<_CharT, _Traits>::pos_type
+basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
+{
+    if (__file_ == 0 || sync())
+        return pos_type(off_type(-1));
+#if _WIN32
+    if (fseek(__file_, __sp, SEEK_SET))
+        return pos_type(off_type(-1));
+#else
+    if (fseeko(__file_, __sp, SEEK_SET))
+        return pos_type(off_type(-1));
+#endif
+    __st_ = __sp.state();
+    return __sp;
+}
+
+template <class _CharT, class _Traits>
+int
+basic_filebuf<_CharT, _Traits>::sync()
+{
+    if (__file_ == 0)
+        return 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (!__cv_)
+        throw bad_cast();
+#endif
+    if (__cm_ & ios_base::out)
+    {
+        if (this->pptr() != this->pbase())
+            if (overflow() == traits_type::eof())
+                return -1;
+        codecvt_base::result __r;
+        do
+        {
+            char* __extbe;
+            __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
+            size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+            if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
+                return -1;
+        } while (__r == codecvt_base::partial);
+        if (__r == codecvt_base::error)
+            return -1;
+        if (fflush(__file_))
+            return -1;
+    }
+    else if (__cm_ & ios_base::in)
+    {
+        off_type __c;
+        state_type __state = __st_last_;
+        bool __update_st = false;
+        if (__always_noconv_)
+            __c = this->egptr() - this->gptr();
+        else
+        {
+            int __width = __cv_->encoding();
+            __c = __extbufend_ - __extbufnext_;
+            if (__width > 0)
+                __c += __width * (this->egptr() - this->gptr());
+            else
+            {
+                if (this->gptr() != this->egptr())
+                {
+                    const int __off =  __cv_->length(__state, __extbuf_,
+                                                     __extbufnext_,
+                                                     this->gptr() - this->eback());
+                    __c += __extbufnext_ - __extbuf_ - __off;
+                    __update_st = true;
+                }
+            }
+        }
+#if _WIN32
+        if (fseek(__file_, -__c, SEEK_CUR))
+            return -1;
+#else
+        if (fseeko(__file_, -__c, SEEK_CUR))
+            return -1;
+#endif
+        if (__update_st)
+            __st_ = __state;
+        __extbufnext_ = __extbufend_ = __extbuf_;
+        this->setg(0, 0, 0);
+        __cm_ = 0;
+    }
+    return 0;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc)
+{
+    sync();
+    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+    bool __old_anc = __always_noconv_;
+    __always_noconv_ = __cv_->always_noconv();
+    if (__old_anc != __always_noconv_)
+    {
+        this->setg(0, 0, 0);
+        this->setp(0, 0);
+        // invariant, char_type is char, else we couldn't get here
+        if (__always_noconv_)  // need to dump __intbuf_
+        {
+            if (__owns_eb_)
+                delete [] __extbuf_;
+            __owns_eb_ = __owns_ib_;
+            __ebs_ = __ibs_;
+            __extbuf_ = (char*)__intbuf_;
+            __ibs_ = 0;
+            __intbuf_ = 0;
+            __owns_ib_ = false;
+        }
+        else  // need to obtain an __intbuf_.
+        {     // If __extbuf_ is user-supplied, use it, else new __intbuf_
+            if (!__owns_eb_ && __extbuf_ != __extbuf_min_)
+            {
+                __ibs_ = __ebs_;
+                __intbuf_ = (char_type*)__extbuf_;
+                __owns_ib_ = false;
+                __extbuf_ = new char[__ebs_];
+                __owns_eb_ = true;
+            }
+            else
+            {
+                __ibs_ = __ebs_;
+                __intbuf_ = new char_type[__ibs_];
+                __owns_ib_ = true;
+            }
+        }
+    }
+}
+
+template <class _CharT, class _Traits>
+bool
+basic_filebuf<_CharT, _Traits>::__read_mode()
+{
+    if (!(__cm_ & ios_base::in))
+    {
+        this->setp(0, 0);
+        if (__always_noconv_)
+            this->setg((char_type*)__extbuf_,
+                       (char_type*)__extbuf_ + __ebs_,
+                       (char_type*)__extbuf_ + __ebs_);
+        else
+            this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
+        __cm_ = ios_base::in;
+        return true;
+    }
+    return false;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_filebuf<_CharT, _Traits>::__write_mode()
+{
+    if (!(__cm_ & ios_base::out))
+    {
+        this->setg(0, 0, 0);
+        if (__ebs_ > sizeof(__extbuf_min_))
+        {
+            if (__always_noconv_)
+                this->setp((char_type*)__extbuf_,
+                           (char_type*)__extbuf_ + (__ebs_ - 1));
+            else
+                this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
+        }
+        else
+            this->setp(0, 0);
+        __cm_ = ios_base::out;
+    }
+}
+
+// basic_ifstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_ifstream
+    : public basic_istream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ifstream();
+    explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
+    explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ifstream(basic_ifstream&& __rhs);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ifstream& operator=(basic_ifstream&& __rhs);
+#endif
+    void swap(basic_ifstream& __rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* __s, ios_base::openmode __mode = ios_base::in);
+    void open(const string& __s, ios_base::openmode __mode = ios_base::in);
+    void close();
+
+private:
+    basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>::basic_ifstream()
+    : basic_istream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __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);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+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);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs)
+    : basic_istream<char_type, traits_type>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ifstream<_CharT, _Traits>&
+basic_ifstream<_CharT, _Traits>::operator=(basic_ifstream&& __rhs)
+{
+    basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ifstream<_CharT, _Traits>::swap(basic_ifstream& __rhs)
+{
+    basic_istream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_ifstream<_CharT, _Traits>::rdbuf() const
+{
+    return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_ifstream<_CharT, _Traits>::is_open() const
+{
+    return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::in))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::in))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ifstream<_CharT, _Traits>::close()
+{
+    if (__sb_.close() == 0)
+        this->setstate(ios_base::failbit);
+}
+
+// basic_ofstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_ofstream
+    : public basic_ostream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_ofstream();
+    explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
+    explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ofstream(basic_ofstream&& __rhs);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ofstream& operator=(basic_ofstream&& __rhs);
+#endif
+    void swap(basic_ofstream& __rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    void open(const char* __s, ios_base::openmode __mode = ios_base::out);
+    void open(const string& __s, ios_base::openmode __mode = ios_base::out);
+    void close();
+
+private:
+    basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>::basic_ofstream()
+    : basic_ostream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __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);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+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);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs)
+    : basic_ostream<char_type, traits_type>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ofstream<_CharT, _Traits>&
+basic_ofstream<_CharT, _Traits>::operator=(basic_ofstream&& __rhs)
+{
+    basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ofstream<_CharT, _Traits>::swap(basic_ofstream& __rhs)
+{
+    basic_ostream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_ofstream<_CharT, _Traits>::rdbuf() const
+{
+    return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_ofstream<_CharT, _Traits>::is_open() const
+{
+    return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::out))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode | ios_base::out))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ofstream<_CharT, _Traits>::close()
+{
+    if (__sb_.close() == 0)
+        this->setstate(ios_base::failbit);
+}
+
+// basic_fstream
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_fstream
+    : public basic_iostream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    basic_fstream();
+    explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+    explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_fstream(basic_fstream&& __rhs);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_fstream& operator=(basic_fstream&& __rhs);
+#endif
+    void swap(basic_fstream& __rhs);
+
+    basic_filebuf<char_type, traits_type>* rdbuf() const;
+    bool is_open() const;
+    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);
+    void close();
+
+private:
+    basic_filebuf<char_type, traits_type> __sb_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream()
+    : basic_iostream<char_type, traits_type>(&__sb_)
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
+    : basic_iostream<char_type, traits_type>(&__sb_)
+{
+    if (__sb_.open(__s, __mode) == 0)
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+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);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs)
+    : basic_iostream<char_type, traits_type>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    this->set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_fstream<_CharT, _Traits>&
+basic_fstream<_CharT, _Traits>::operator=(basic_fstream&& __rhs)
+{
+    basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_fstream<_CharT, _Traits>::swap(basic_fstream& __rhs)
+{
+    basic_iostream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_filebuf<_CharT, _Traits>*
+basic_fstream<_CharT, _Traits>::rdbuf() const
+{
+    return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_fstream<_CharT, _Traits>::is_open() const
+{
+    return __sb_.is_open();
+}
+
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+void
+basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
+{
+    if (__sb_.open(__s, __mode))
+        this->clear();
+    else
+        this->setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_fstream<_CharT, _Traits>::close()
+{
+    if (__sb_.close() == 0)
+        this->setstate(ios_base::failbit);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_FSTREAM
diff --git a/final/include/functional b/final/include/functional
new file mode 100644
index 0000000..416a9a9
--- /dev/null
+++ b/final/include/functional
@@ -0,0 +1,2419 @@
+// -*- 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_FUNCTIONAL
+#define _LIBCPP_FUNCTIONAL
+
+/*
+    functional synopsis
+
+namespace std
+{
+
+template <class Arg, class Result>
+struct unary_function
+{
+    typedef Arg    argument_type;
+    typedef Result result_type;
+};
+
+template <class Arg1, class Arg2, class Result>
+struct binary_function
+{
+    typedef Arg1   first_argument_type;
+    typedef Arg2   second_argument_type;
+    typedef Result result_type;
+};
+
+template <class T>
+class reference_wrapper
+    : public unary_function<T1, R> // if wrapping a unary functor
+    : public binary_function<T1, T2, R> // if wraping a binary functor
+{
+public:
+    // types
+    typedef T type;
+    typedef see below result_type; // Not always defined
+
+    // construct/copy/destroy
+    reference_wrapper(T&) noexcept;
+    reference_wrapper(T&&) = delete; // do not bind to temps
+    reference_wrapper(const reference_wrapper<T>& x) noexcept;
+
+    // assignment
+    reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;
+
+    // access
+    operator T& () const noexcept;
+    T& get() const noexcept;
+
+    // invoke
+    template <class... ArgTypes>
+      typename result_of<T&(ArgTypes&&...)>::type
+          operator() (ArgTypes&&...) const;
+};
+
+template <class T> reference_wrapper<T> ref(T& t) noexcept;
+template <class T> void ref(const T&& t) = delete;
+template <class T> reference_wrapper<T> ref(reference_wrapper<T>t) noexcept;
+
+template <class T> reference_wrapper<const T> cref(const T& t) noexcept;
+template <class T> void cref(const T&& t) = delete;
+template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept;
+
+template <class T> // <class T=void> in C++14
+struct plus : binary_function<T, T, T>
+{
+    T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct minus : binary_function<T, T, T>
+{
+    T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct multiplies : binary_function<T, T, T>
+{
+    T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct divides : binary_function<T, T, T>
+{
+    T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct modulus : binary_function<T, T, T>
+{
+    T operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct negate : unary_function<T, T>
+{
+    T operator()(const T& x) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct equal_to : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct not_equal_to : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct greater : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct less : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct greater_equal : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct less_equal : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct logical_and : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct logical_or : binary_function<T, T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct logical_not : unary_function<T, bool>
+{
+    bool operator()(const T& x) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_and : unary_function<T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_or : unary_function<T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T> // <class T=void> in C++14
+struct bit_xor : unary_function<T, bool>
+{
+    bool operator()(const T& x, const T& y) const;
+};
+
+template <class T=void> // C++14
+struct bit_xor : unary_function<T, bool>
+{
+    bool operator()(const T& x) const;
+};
+
+template <class Predicate>
+class unary_negate
+    : public unary_function<typename Predicate::argument_type, bool>
+{
+public:
+    explicit unary_negate(const Predicate& pred);
+    bool operator()(const typename Predicate::argument_type& x) const;
+};
+
+template <class Predicate> unary_negate<Predicate> not1(const Predicate& pred);
+
+template <class Predicate>
+class binary_negate
+    : public binary_function<typename Predicate::first_argument_type,
+                             typename Predicate::second_argument_type,
+                             bool>
+{
+public:
+    explicit binary_negate(const Predicate& pred);
+    bool operator()(const typename Predicate::first_argument_type& x,
+                    const typename Predicate::second_argument_type& y) const;
+};
+
+template <class Predicate> binary_negate<Predicate> not2(const Predicate& pred);
+
+template<class T> struct is_bind_expression;
+template<class T> struct is_placeholder;
+
+template<class Fn, class... BoundArgs>
+  unspecified bind(Fn&&, BoundArgs&&...);
+template<class R, class Fn, class... BoundArgs>
+  unspecified bind(Fn&&, BoundArgs&&...);
+
+namespace placeholders {
+  // M is the implementation-defined number of placeholders
+  extern unspecified _1;
+  extern unspecified _2;
+  .
+  .
+  .
+  extern unspecified _Mp;
+}
+
+template <class Operation>
+class binder1st
+    : public unary_function<typename Operation::second_argument_type,
+                            typename Operation::result_type>
+{
+protected:
+    Operation                               op;
+    typename Operation::first_argument_type value;
+public:
+    binder1st(const Operation& x, const typename Operation::first_argument_type y);
+    typename Operation::result_type operator()(      typename Operation::second_argument_type& x) const;
+    typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const;
+};
+
+template <class Operation, class T>
+binder1st<Operation> bind1st(const Operation& op, const T& x);
+
+template <class Operation>
+class binder2nd
+    : public unary_function<typename Operation::first_argument_type,
+                            typename Operation::result_type>
+{
+protected:
+    Operation                                op;
+    typename Operation::second_argument_type value;
+public:
+    binder2nd(const Operation& x, const typename Operation::second_argument_type y);
+    typename Operation::result_type operator()(      typename Operation::first_argument_type& x) const;
+    typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const;
+};
+
+template <class Operation, class T>
+binder2nd<Operation> bind2nd(const Operation& op, const T& x);
+
+template <class Arg, class Result>
+class pointer_to_unary_function : public unary_function<Arg, Result>
+{
+public:
+    explicit pointer_to_unary_function(Result (*f)(Arg));
+    Result operator()(Arg x) const;
+};
+
+template <class Arg, class Result>
+pointer_to_unary_function<Arg,Result> ptr_fun(Result (*f)(Arg));
+
+template <class Arg1, class Arg2, class Result>
+class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result>
+{
+public:
+    explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
+    Result operator()(Arg1 x, Arg2 y) const;
+};
+
+template <class Arg1, class Arg2, class Result>
+pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1,Arg2));
+
+template<class S, class T>
+class mem_fun_t : public unary_function<T*, S>
+{
+public:
+    explicit mem_fun_t(S (T::*p)());
+    S operator()(T* p) const;
+};
+
+template<class S, class T, class A>
+class mem_fun1_t : public binary_function<T*, A, S>
+{
+public:
+    explicit mem_fun1_t(S (T::*p)(A));
+    S operator()(T* p, A x) const;
+};
+
+template<class S, class T>          mem_fun_t<S,T>    mem_fun(S (T::*f)());
+template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
+
+template<class S, class T>
+class mem_fun_ref_t : public unary_function<T, S>
+{
+public:
+    explicit mem_fun_ref_t(S (T::*p)());
+    S operator()(T& p) const;
+};
+
+template<class S, class T, class A>
+class mem_fun1_ref_t : public binary_function<T, A, S>
+{
+public:
+    explicit mem_fun1_ref_t(S (T::*p)(A));
+    S operator()(T& p, A x) const;
+};
+
+template<class S, class T>          mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)());
+template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
+
+template <class S, class T>
+class const_mem_fun_t : public unary_function<const T*, S>
+{
+public:
+    explicit const_mem_fun_t(S (T::*p)() const);
+    S operator()(const T* p) const;
+};
+
+template <class S, class T, class A>
+class const_mem_fun1_t : public binary_function<const T*, A, S>
+{
+public:
+    explicit const_mem_fun1_t(S (T::*p)(A) const);
+    S operator()(const T* p, A x) const;
+};
+
+template <class S, class T>          const_mem_fun_t<S,T>    mem_fun(S (T::*f)() const);
+template <class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
+
+template <class S, class T>
+class const_mem_fun_ref_t : public unary_function<T, S>
+{
+public:
+    explicit const_mem_fun_ref_t(S (T::*p)() const);
+    S operator()(const T& p) const;
+};
+
+template <class S, class T, class A>
+class const_mem_fun1_ref_t : public binary_function<T, A, S>
+{
+public:
+    explicit const_mem_fun1_ref_t(S (T::*p)(A) const);
+    S operator()(const T& p, A x) const;
+};
+
+template <class S, class T>          const_mem_fun_ref_t<S,T>    mem_fun_ref(S (T::*f)() const);
+template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
+
+template<class R, class T> unspecified mem_fn(R T::*);
+
+class bad_function_call
+    : public exception
+{
+};
+
+template<class> class function; // undefined
+
+template<class R, class... ArgTypes>
+class function<R(ArgTypes...)>
+  : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
+                                      // ArgTypes contains T1
+  : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
+                                      // ArgTypes contains T1 and T2
+{
+public:
+    typedef R result_type;
+
+    // construct/copy/destroy:
+    function() noexcept;
+    function(nullptr_t) noexcept;
+    function(const function&);
+    function(function&&) noexcept;
+    template<class F>
+      function(F);
+    template<Allocator Alloc>
+      function(allocator_arg_t, const Alloc&) noexcept;
+    template<Allocator Alloc>
+      function(allocator_arg_t, const Alloc&, nullptr_t) noexcept;
+    template<Allocator Alloc>
+      function(allocator_arg_t, const Alloc&, const function&);
+    template<Allocator Alloc>
+      function(allocator_arg_t, const Alloc&, function&&);
+    template<class F, Allocator Alloc>
+      function(allocator_arg_t, const Alloc&, F);
+
+    function& operator=(const function&);
+    function& operator=(function&&) noexcept;
+    function& operator=(nullptr_t) noexcept;
+    template<class F>
+      function& operator=(F&&);
+    template<class F>
+      function& operator=(reference_wrapper<F>) noexcept;
+
+    ~function();
+
+    // function modifiers:
+    void swap(function&) noexcept;
+    template<class F, class Alloc>
+      void assign(F&&, const Alloc&);
+
+    // function capacity:
+    explicit operator bool() const noexcept;
+
+    // function invocation:
+    R operator()(ArgTypes...) const;
+
+    // function target access:
+    const std::type_info& target_type() const noexcept;
+    template <typename T>       T* target() noexcept;
+    template <typename T> const T* target() const noexcept;
+};
+
+// Null pointer comparisons:
+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;
+
+// specialized algorithms:
+template <class  R, class ... ArgTypes>
+  void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
+
+template <class T> struct hash;
+
+template <> struct hash<bool>;
+template <> struct hash<char>;
+template <> struct hash<signed char>;
+template <> struct hash<unsigned char>;
+template <> struct hash<char16_t>;
+template <> struct hash<char32_t>;
+template <> struct hash<wchar_t>;
+template <> struct hash<short>;
+template <> struct hash<unsigned short>;
+template <> struct hash<int>;
+template <> struct hash<unsigned int>;
+template <> struct hash<long>;
+template <> struct hash<long long>;
+template <> struct hash<unsigned long>;
+template <> struct hash<unsigned long long>;
+
+template <> struct hash<float>;
+template <> struct hash<double>;
+template <> struct hash<long double>;
+
+template<class T> struct hash<T*>;
+
+}  // std
+
+POLICY:  For non-variadic implementations, the number of arguments is limited
+         to 3.  It is hoped that the need for non-variadic implementations
+         will be minimal.
+
+*/
+
+#include <__config>
+#include <type_traits>
+#include <typeinfo>
+#include <exception>
+#include <memory>
+#include <tuple>
+
+#include <__functional_base>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x + __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x - __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x * __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x / __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x % __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return -__x;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x == __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x != __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x > __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+// less in <__functional_base>
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x >= __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x <= __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x && __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x || __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Tp& __x) const
+        {return !__x;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x & __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x | __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x ^ __y;}
+};
+
+#if _LIBCPP_STD_VER > 11
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp = void>
+struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return ~__x;}
+};
+
+template <>
+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); }
+    typedef void is_transparent;
+};
+#endif
+
+template <class _Predicate>
+class _LIBCPP_TYPE_VIS_ONLY unary_negate
+    : public unary_function<typename _Predicate::argument_type, bool>
+{
+    _Predicate __pred_;
+public:
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    explicit unary_negate(const _Predicate& __pred)
+        : __pred_(__pred) {}
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const typename _Predicate::argument_type& __x) const
+        {return !__pred_(__x);}
+};
+
+template <class _Predicate>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+unary_negate<_Predicate>
+not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);}
+
+template <class _Predicate>
+class _LIBCPP_TYPE_VIS_ONLY binary_negate
+    : public binary_function<typename _Predicate::first_argument_type,
+                             typename _Predicate::second_argument_type,
+                             bool>
+{
+    _Predicate __pred_;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 
+    binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
+
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const typename _Predicate::first_argument_type& __x,
+                    const typename _Predicate::second_argument_type& __y) const
+        {return !__pred_(__x, __y);}
+};
+
+template <class _Predicate>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+binary_negate<_Predicate>
+not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
+
+template <class __Operation>
+class _LIBCPP_TYPE_VIS_ONLY binder1st
+    : public unary_function<typename __Operation::second_argument_type,
+                            typename __Operation::result_type>
+{
+protected:
+    __Operation                               op;
+    typename __Operation::first_argument_type value;
+public:
+    _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x,
+                               const typename __Operation::first_argument_type __y)
+        : op(__x), value(__y) {}
+    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+        (typename __Operation::second_argument_type& __x) const
+            {return op(value, __x);}
+    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+        (const typename __Operation::second_argument_type& __x) const
+            {return op(value, __x);}
+};
+
+template <class __Operation, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+binder1st<__Operation>
+bind1st(const __Operation& __op, const _Tp& __x)
+    {return binder1st<__Operation>(__op, __x);}
+
+template <class __Operation>
+class _LIBCPP_TYPE_VIS_ONLY binder2nd
+    : public unary_function<typename __Operation::first_argument_type,
+                            typename __Operation::result_type>
+{
+protected:
+    __Operation                                op;
+    typename __Operation::second_argument_type value;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
+        : op(__x), value(__y) {}
+    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+        (      typename __Operation::first_argument_type& __x) const
+            {return op(__x, value);}
+    _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
+        (const typename __Operation::first_argument_type& __x) const
+            {return op(__x, value);}
+};
+
+template <class __Operation, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+binder2nd<__Operation>
+bind2nd(const __Operation& __op, const _Tp& __x)
+    {return binder2nd<__Operation>(__op, __x);}
+
+template <class _Arg, class _Result>
+class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function
+    : public unary_function<_Arg, _Result>
+{
+    _Result (*__f_)(_Arg);
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
+        : __f_(__f) {}
+    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
+        {return __f_(__x);}
+};
+
+template <class _Arg, class _Result>
+inline _LIBCPP_INLINE_VISIBILITY
+pointer_to_unary_function<_Arg,_Result>
+ptr_fun(_Result (*__f)(_Arg))
+    {return pointer_to_unary_function<_Arg,_Result>(__f);}
+
+template <class _Arg1, class _Arg2, class _Result>
+class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function
+    : public binary_function<_Arg1, _Arg2, _Result>
+{
+    _Result (*__f_)(_Arg1, _Arg2);
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
+        : __f_(__f) {}
+    _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
+        {return __f_(__x, __y);}
+};
+
+template <class _Arg1, class _Arg2, class _Result>
+inline _LIBCPP_INLINE_VISIBILITY
+pointer_to_binary_function<_Arg1,_Arg2,_Result>
+ptr_fun(_Result (*__f)(_Arg1,_Arg2))
+    {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);}
+
+template<class _Sp, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp>
+{
+    _Sp (_Tp::*__p_)();
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
+        {return (__p->*__p_)();}
+};
+
+template<class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp>
+{
+    _Sp (_Tp::*__p_)(_Ap);
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
+        {return (__p->*__p_)(__x);}
+};
+
+template<class _Sp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+mem_fun_t<_Sp,_Tp>
+mem_fun(_Sp (_Tp::*__f)())
+    {return mem_fun_t<_Sp,_Tp>(__f);}
+
+template<class _Sp, class _Tp, class _Ap>
+inline _LIBCPP_INLINE_VISIBILITY
+mem_fun1_t<_Sp,_Tp,_Ap>
+mem_fun(_Sp (_Tp::*__f)(_Ap))
+    {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
+
+template<class _Sp, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp>
+{
+    _Sp (_Tp::*__p_)();
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
+        {return (__p.*__p_)();}
+};
+
+template<class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp>
+{
+    _Sp (_Tp::*__p_)(_Ap);
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
+        {return (__p.*__p_)(__x);}
+};
+
+template<class _Sp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+mem_fun_ref_t<_Sp,_Tp>
+mem_fun_ref(_Sp (_Tp::*__f)())
+    {return mem_fun_ref_t<_Sp,_Tp>(__f);}
+
+template<class _Sp, class _Tp, class _Ap>
+inline _LIBCPP_INLINE_VISIBILITY
+mem_fun1_ref_t<_Sp,_Tp,_Ap>
+mem_fun_ref(_Sp (_Tp::*__f)(_Ap))
+    {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
+
+template <class _Sp, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp>
+{
+    _Sp (_Tp::*__p_)() const;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
+        {return (__p->*__p_)();}
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp>
+{
+    _Sp (_Tp::*__p_)(_Ap) const;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
+        {return (__p->*__p_)(__x);}
+};
+
+template <class _Sp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const_mem_fun_t<_Sp,_Tp>
+mem_fun(_Sp (_Tp::*__f)() const)
+    {return const_mem_fun_t<_Sp,_Tp>(__f);}
+
+template <class _Sp, class _Tp, class _Ap>
+inline _LIBCPP_INLINE_VISIBILITY
+const_mem_fun1_t<_Sp,_Tp,_Ap>
+mem_fun(_Sp (_Tp::*__f)(_Ap) const)
+    {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);}
+
+template <class _Sp, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp>
+{
+    _Sp (_Tp::*__p_)() const;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
+        {return (__p.*__p_)();}
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t
+    : public binary_function<_Tp, _Ap, _Sp>
+{
+    _Sp (_Tp::*__p_)(_Ap) const;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
+        {return (__p.*__p_)(__x);}
+};
+
+template <class _Sp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const_mem_fun_ref_t<_Sp,_Tp>
+mem_fun_ref(_Sp (_Tp::*__f)() const)
+    {return const_mem_fun_ref_t<_Sp,_Tp>(__f);}
+
+template <class _Sp, class _Tp, class _Ap>
+inline _LIBCPP_INLINE_VISIBILITY
+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
+
+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
+    template <class... _ArgTypes>
+       _LIBCPP_INLINE_VISIBILITY
+       typename __invoke_return<type, _ArgTypes...>::type
+          operator() (_ArgTypes&&... __args) const
+          {
+              return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
+          }
+};
+
+template<class _Rp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__mem_fn<_Rp _Tp::*>
+mem_fn(_Rp _Tp::* __pm)
+{
+    return __mem_fn<_Rp _Tp::*>(__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 _Rp, class ..._ArgTypes>
+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 _Rp, class ..._ArgTypes>
+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>
+{
+};
+
+template<class _Fp> class __base;
+
+template<class _Rp, class ..._ArgTypes>
+class __base<_Rp(_ArgTypes...)>
+{
+    __base(const __base&);
+    __base& operator=(const __base&);
+public:
+    _LIBCPP_INLINE_VISIBILITY __base() {}
+    _LIBCPP_INLINE_VISIBILITY virtual ~__base() {}
+    virtual __base* __clone() const = 0;
+    virtual void __clone(__base*) const = 0;
+    virtual void destroy() _NOEXCEPT = 0;
+    virtual void destroy_deallocate() _NOEXCEPT = 0;
+    virtual _Rp operator()(_ArgTypes&& ...) = 0;
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const _NOEXCEPT = 0;
+    virtual const std::type_info& target_type() const _NOEXCEPT = 0;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _FD, class _Alloc, class _FB> class __func;
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+class __func<_Fp, _Alloc, _Rp(_ArgTypes...)>
+    : public  __base<_Rp(_ArgTypes...)>
+{
+    __compressed_pair<_Fp, _Alloc> __f_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __func(_Fp&& __f)
+        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
+                                    _VSTD::forward_as_tuple()) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __func(const _Fp& __f, const _Alloc& __a)
+        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
+                                    _VSTD::forward_as_tuple(__a)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __func(const _Fp& __f, _Alloc&& __a)
+        : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f),
+                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __func(_Fp&& __f, _Alloc&& __a)
+        : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)),
+                                    _VSTD::forward_as_tuple(_VSTD::move(__a))) {}
+    virtual __base<_Rp(_ArgTypes...)>* __clone() const;
+    virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;
+    virtual void destroy() _NOEXCEPT;
+    virtual void destroy_deallocate() _NOEXCEPT;
+    virtual _Rp operator()(_ArgTypes&& ... __arg);
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* target(const type_info&) const _NOEXCEPT;
+    virtual const std::type_info& target_type() const _NOEXCEPT;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+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;
+    _Ap __a(__f_.second());
+    typedef __allocator_destructor<_Ap> _Dp;
+    unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+    ::new (__hold.get()) __func(__f_.first(), _Alloc(__a));
+    return __hold.release();
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
+{
+    ::new (__p) __func(__f_.first(), __f_.second());
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT
+{
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+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;
+    _Ap __a(__f_.second());
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+    __a.deallocate(this, 1);
+}
+
+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)...);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+const void*
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT
+{
+    if (__ti == typeid(_Fp))
+        return &__f_.first();
+    return (const void*)0;
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+const std::type_info&
+__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
+{
+    return typeid(_Fp);
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+}  // __function
+
+template<class _Rp, class ..._ArgTypes>
+class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)>
+    : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
+      public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>
+{
+    typedef __function::__base<_Rp(_ArgTypes...)> __base;
+    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;}
+
+    template <class _Fp, bool = !is_same<_Fp, function>::value &&
+                                __invokable<_Fp&, _ArgTypes...>::value>
+        struct __callable;
+    template <class _Fp>
+        struct __callable<_Fp, true>
+        {
+            static const bool value =
+                is_convertible<typename __invoke_of<_Fp&, _ArgTypes...>::type,
+                               _Rp>::value;
+        };
+    template <class _Fp>
+        struct __callable<_Fp, false>
+        {
+            static const bool value = false;
+        };
+public:
+    typedef _Rp result_type;
+
+    // construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY
+    function() _NOEXCEPT : __f_(0) {}
+    _LIBCPP_INLINE_VISIBILITY
+    function(nullptr_t) _NOEXCEPT : __f_(0) {}
+    function(const function&);
+    function(function&&) _NOEXCEPT;
+    template<class _Fp>
+      function(_Fp, typename enable_if
+                                     <
+                                        __callable<_Fp>::value &&
+                                        !is_same<_Fp, function>::value
+                                      >::type* = 0);
+
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {}
+    template<class _Alloc>
+      _LIBCPP_INLINE_VISIBILITY
+      function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {}
+    template<class _Alloc>
+      function(allocator_arg_t, const _Alloc&, const function&);
+    template<class _Alloc>
+      function(allocator_arg_t, const _Alloc&, function&&);
+    template<class _Fp, class _Alloc>
+      function(allocator_arg_t, const _Alloc& __a, _Fp __f,
+               typename enable_if<__callable<_Fp>::value>::type* = 0);
+
+    function& operator=(const function&);
+    function& operator=(function&&) _NOEXCEPT;
+    function& operator=(nullptr_t) _NOEXCEPT;
+    template<class _Fp>
+      typename enable_if
+      <
+        __callable<typename decay<_Fp>::type>::value &&
+        !is_same<typename remove_reference<_Fp>::type, function>::value,
+        function&
+      >::type
+      operator=(_Fp&&);
+
+    ~function();
+
+    // function modifiers:
+    void swap(function&) _NOEXCEPT;
+    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);}
+
+    // function capacity:
+    _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
+
+    // deleted overloads close possible hole in the type system
+    template<class _R2, class... _ArgTypes2>
+      bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
+    template<class _R2, class... _ArgTypes2>
+      bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
+public:
+    // function invocation:
+    _Rp operator()(_ArgTypes...) const;
+
+#ifndef _LIBCPP_NO_RTTI
+    // function target access:
+    const std::type_info& target_type() const _NOEXCEPT;
+    template <typename _Tp> _Tp* target() _NOEXCEPT;
+    template <typename _Tp> const _Tp* target() const _NOEXCEPT;
+#endif  // _LIBCPP_NO_RTTI
+};
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>::function(const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Alloc>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
+                                     const function& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (const __base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+        __f_ = __f.__f_->__clone();
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+    {
+        __f_ = __f.__f_;
+        __f.__f_ = 0;
+    }
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Alloc>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
+                                     function&& __f)
+{
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+    {
+        __f_ = __f.__f_;
+        __f.__f_ = 0;
+    }
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp>
+function<_Rp(_ArgTypes...)>::function(_Fp __f,
+                                     typename enable_if
+                                     <
+                                        __callable<_Fp>::value &&
+                                        !is_same<_Fp, function>::value
+                                     >::type*)
+    : __f_(0)
+{
+    if (__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));
+        }
+        else
+        {
+            typedef allocator<_FF> _Ap;
+            _Ap __a;
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp, class _Alloc>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
+                                     typename enable_if<__callable<_Fp>::value>::type*)
+    : __f_(0)
+{
+    typedef allocator_traits<_Alloc> __alloc_traits;
+    if (__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;
+        _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));
+        }
+        else
+        {
+            typedef __allocator_destructor<_Ap> _Dp;
+            unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+            ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a));
+            __f_ = __hold.release();
+        }
+    }
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>&
+function<_Rp(_ArgTypes...)>::operator=(const function& __f)
+{
+    function(__f).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>&
+function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+    __f_ = 0;
+    if (__f.__f_ == 0)
+        __f_ = 0;
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__clone(__f_);
+    }
+    else
+    {
+        __f_ = __f.__f_;
+        __f.__f_ = 0;
+    }
+    return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>&
+function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+    __f_ = 0;
+    return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp>
+typename enable_if
+<
+    function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
+    !is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
+    function<_Rp(_ArgTypes...)>&
+>::type
+function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
+{
+    function(_VSTD::forward<_Fp>(__f)).swap(*this);
+    return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+function<_Rp(_ArgTypes...)>::~function()
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+}
+
+template<class _Rp, class ..._ArgTypes>
+void
+function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT
+{
+    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+    {
+        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+        __base* __t = (__base*)&__tempbuf;
+        __f_->__clone(__t);
+        __f_->destroy();
+        __f_ = 0;
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = 0;
+        __f_ = (__base*)&__buf_;
+        __t->__clone((__base*)&__f.__buf_);
+        __t->destroy();
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f_ == (__base*)&__buf_)
+    {
+        __f_->__clone((__base*)&__f.__buf_);
+        __f_->destroy();
+        __f_ = __f.__f_;
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f.__f_->__clone((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = __f_;
+        __f_ = (__base*)&__buf_;
+    }
+    else
+        _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class ..._ArgTypes>
+_Rp
+function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__f_ == 0)
+        throw bad_function_call();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Rp, class ..._ArgTypes>
+const std::type_info&
+function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT
+{
+    if (__f_ == 0)
+        return typeid(void);
+    return __f_->target_type();
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <typename _Tp>
+_Tp*
+function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
+{
+    if (__f_ == 0)
+        return (_Tp*)0;
+    return (_Tp*)__f_->target(typeid(_Tp));
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <typename _Tp>
+const _Tp*
+function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
+{
+    if (__f_ == 0)
+        return (const _Tp*)0;
+    return (const _Tp*)__f_->target(typeid(_Tp));
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
+{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 {};
+
+_LIBCPP_FUNC_VIS extern __ph<1>   _1;
+_LIBCPP_FUNC_VIS extern __ph<2>   _2;
+_LIBCPP_FUNC_VIS extern __ph<3>   _3;
+_LIBCPP_FUNC_VIS extern __ph<4>   _4;
+_LIBCPP_FUNC_VIS extern __ph<5>   _5;
+_LIBCPP_FUNC_VIS extern __ph<6>   _6;
+_LIBCPP_FUNC_VIS extern __ph<7>   _7;
+_LIBCPP_FUNC_VIS extern __ph<8>   _8;
+_LIBCPP_FUNC_VIS extern __ph<9>   _9;
+_LIBCPP_FUNC_VIS 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 <class _Ti, class ..._Uj, size_t ..._Indx>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __invoke_of<_Ti&, _Uj...>::type
+__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
+{
+    return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
+}
+
+template <class _Ti, class ..._Uj>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_bind_expression<_Ti>::value,
+    typename __invoke_of<_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;
+    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&)
+{
+    return __ti;
+}
+
+template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
+          class _TupleUj>
+struct ____mu_return;
+
+template <bool _Invokable, class _Ti, class ..._Uj>
+struct ____mu_return_invokable  // false
+{
+    typedef __nat type;
+};
+
+template <class _Ti, class ..._Uj>
+struct ____mu_return_invokable<true, _Ti, _Uj...>
+{
+    typedef typename __invoke_of<_Ti&, _Uj...>::type type;
+};
+
+template <class _Ti, class ..._Uj>
+struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> >
+    : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
+{
+};
+
+template <class _Ti, class _TupleUj>
+struct ____mu_return<_Ti, false, false, true, _TupleUj>
+{
+    typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
+                                   _TupleUj>::type&& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct ____mu_return<_Ti, true, false, false, _TupleUj>
+{
+    typedef typename _Ti::type& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct ____mu_return<_Ti, false, false, false, _TupleUj>
+{
+    typedef _Ti& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return
+    : public ____mu_return<_Ti,
+                           __is_reference_wrapper<_Ti>::value,
+                           is_bind_expression<_Ti>::value,
+                           0 < is_placeholder<_Ti>::value &&
+                           is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
+                           _TupleUj>
+{
+};
+
+template <class _Fp, class _BoundArgs, class _TupleUj>
+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>
+{
+    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>
+{
+    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>
+struct __bind_return;
+
+template <class _Fp, class ..._BoundArgs, class _TupleUj>
+struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
+{
+    typedef typename __invoke_of
+    <
+        _Fp&,
+        typename __mu_return
+        <
+            _BoundArgs,
+            _TupleUj
+        >::type...
+    >::type type;
+};
+
+template <class _Fp, class ..._BoundArgs, class _TupleUj>
+struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
+{
+    typedef typename __invoke_of
+    <
+        _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
+    : public __weak_result_type<typename decay<_Fp>::type>
+{
+protected:
+    typedef typename decay<_Fp>::type _Fd;
+    typedef tuple<typename decay<_BoundArgs>::type...> _Td;
+private:
+    _Fd __f_;
+    _Td __bound_args_;
+
+    typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
+public:
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind(const __bind& __b)
+        : __f_(__b.__f_),
+          __bound_args_(__b.__bound_args_) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind& operator=(const __bind& __b)
+    {
+        __f_ = __b.__f_;
+        __bound_args_ = __b.__bound_args_;
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind(__bind&& __b)
+        : __f_(_VSTD::move(__b.__f_)),
+          __bound_args_(_VSTD::move(__b.__bound_args_)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind& operator=(__bind&& __b)
+    {
+        __f_ = _VSTD::move(__b.__f_);
+        __bound_args_ = _VSTD::move(__b.__bound_args_);
+        return *this;
+    }
+
+#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    template <class _Gp, class ..._BA,
+              class = typename enable_if
+                               <
+                                  is_constructible<_Fd, _Gp>::value &&
+                                  !is_same<typename remove_reference<_Gp>::type,
+                                           __bind>::value
+                               >::type>
+      _LIBCPP_INLINE_VISIBILITY
+      explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
+        : __f_(_VSTD::forward<_Gp>(__f)),
+          __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
+
+    template <class ..._Args>
+        _LIBCPP_INLINE_VISIBILITY
+        typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
+        operator()(_Args&& ...__args)
+        {
+            return __apply_functor(__f_, __bound_args_, __indices(),
+                                  tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
+        }
+
+    template <class ..._Args>
+        _LIBCPP_INLINE_VISIBILITY
+        typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
+        operator()(_Args&& ...__args) const
+        {
+            return __apply_functor(__f_, __bound_args_, __indices(),
+                                   tuple<_Args&&...>(_VSTD::forward<_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;
+    typedef typename base::_Fd _Fd;
+    typedef typename base::_Td _Td;
+public:
+    typedef _Rp result_type;
+
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind_r(const __bind_r& __b)
+        : base(_VSTD::forward<const base&>(__b)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind_r& operator=(const __bind_r& __b)
+    {
+        base::operator=(_VSTD::forward<const base&>(__b));
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind_r(__bind_r&& __b)
+        : base(_VSTD::forward<base>(__b)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bind_r& operator=(__bind_r&& __b)
+    {
+        base::operator=(_VSTD::forward<base>(__b));
+        return *this;
+    }
+
+#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+    template <class _Gp, class ..._BA,
+              class = typename enable_if
+                               <
+                                  is_constructible<_Fd, _Gp>::value &&
+                                  !is_same<typename remove_reference<_Gp>::type,
+                                           __bind_r>::value
+                               >::type>
+      _LIBCPP_INLINE_VISIBILITY
+      explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
+        : base(_VSTD::forward<_Gp>(__f),
+               _VSTD::forward<_BA>(__bound_args)...) {}
+
+    template <class ..._Args>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
+                           result_type>::value,
+            result_type
+        >::type
+        operator()(_Args&& ...__args)
+        {
+            return base::operator()(_VSTD::forward<_Args>(__args)...);
+        }
+
+    template <class ..._Args>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
+                           result_type>::value,
+            result_type
+        >::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<_Fp, _BoundArgs...>
+bind(_Fp&& __f, _BoundArgs&&... __bound_args)
+{
+    typedef __bind<_Fp, _BoundArgs...> 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, _Fp, _BoundArgs...>
+bind(_Fp&& __f, _BoundArgs&&... __bound_args)
+{
+    typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
+    return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<bool>
+    : public unary_function<bool, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<char>
+    : public unary_function<char, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
+    : public unary_function<signed char, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
+    : public unary_function<unsigned char, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<char16_t>
+    : public unary_function<char16_t, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<char32_t>
+    : public unary_function<char32_t, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t>
+    : public unary_function<wchar_t, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<short>
+    : public unary_function<short, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
+    : public unary_function<unsigned short, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<int>
+    : public unary_function<int, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
+    : public unary_function<unsigned int, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<long>
+    : public unary_function<long, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long>
+    : public unary_function<unsigned long, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<long long>
+    : public __scalar_hash<long long>
+{
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long>
+    : public __scalar_hash<unsigned long long>
+{
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<float>
+    : public __scalar_hash<float>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(float __v) const _NOEXCEPT
+    {
+        // -0.0 and 0.0 should return same hash
+       if (__v == 0)
+           return 0;
+        return __scalar_hash<float>::operator()(__v);
+    }
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<double>
+    : public __scalar_hash<double>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(double __v) const _NOEXCEPT
+    {
+        // -0.0 and 0.0 should return same hash
+       if (__v == 0)
+           return 0;
+        return __scalar_hash<double>::operator()(__v);
+    }
+};
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
+    : public __scalar_hash<long double>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(long double __v) const _NOEXCEPT
+    {
+        // -0.0 and 0.0 should return same hash
+        if (__v == 0)
+            return 0;
+#if defined(__i386__)
+        // Zero out padding bits
+        union
+        {
+            long double __t;
+            struct
+            {
+                size_t __a;
+                size_t __b;
+                size_t __c;
+                size_t __d;
+            };
+        } __u;
+        __u.__a = 0;
+        __u.__b = 0;
+        __u.__c = 0;
+        __u.__d = 0;
+        __u.__t = __v;
+        return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d;
+#elif defined(__x86_64__)
+        // Zero out padding bits
+        union
+        {
+            long double __t;
+            struct
+            {
+                size_t __a;
+                size_t __b;
+            };
+        } __u;
+        __u.__a = 0;
+        __u.__b = 0;
+        __u.__t = __v;
+        return __u.__a ^ __u.__b;
+#else
+        return __scalar_hash<long double>::operator()(__v);
+#endif
+    }
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY hash
+    : public unary_function<_Tp, size_t>
+{
+    static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types");
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(_Tp __v) const _NOEXCEPT
+    {
+        typedef typename underlying_type<_Tp>::type type;
+        return hash<type>{}(static_cast<type>(__v));
+    }
+};
+#endif
+
+// struct hash<T*> in <memory>
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_FUNCTIONAL
diff --git a/final/include/future b/final/include/future
new file mode 100644
index 0000000..de00f25
--- /dev/null
+++ b/final/include/future
@@ -0,0 +1,2615 @@
+// -*- C++ -*-
+//===--------------------------- future -----------------------------------===//
+//
+//                     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_FUTURE
+#define _LIBCPP_FUTURE
+
+/*
+    future synopsis
+
+namespace std
+{
+
+enum class future_errc
+{
+    future_already_retrieved = 1,
+    promise_already_satisfied,
+    no_state,
+    broken_promise
+};
+
+enum class launch
+{
+    async = 1,
+    deferred = 2,
+    any = async | deferred
+};
+
+enum class future_status
+{
+    ready,
+    timeout,
+    deferred
+};
+
+template <> struct is_error_code_enum<future_errc> : public true_type { };
+error_code make_error_code(future_errc e) noexcept;
+error_condition make_error_condition(future_errc e) noexcept;
+
+const error_category& future_category() noexcept;
+
+class future_error
+    : public logic_error
+{
+public:
+    future_error(error_code ec);  // exposition only
+
+    const error_code& code() const noexcept;
+    const char*       what() const noexcept;
+};
+
+template <class R>
+class promise
+{
+public:
+    promise();
+    template <class Allocator>
+        promise(allocator_arg_t, const Allocator& a);
+    promise(promise&& rhs) noexcept;
+    promise(const promise& rhs) = delete;
+    ~promise();
+
+    // assignment
+    promise& operator=(promise&& rhs) noexcept;
+    promise& operator=(const promise& rhs) = delete;
+    void swap(promise& other) noexcept;
+
+    // retrieving the result
+    future<R> get_future();
+
+    // setting the result
+    void set_value(const R& r);
+    void set_value(R&& r);
+    void set_exception(exception_ptr p);
+
+    // setting the result with deferred notification
+    void set_value_at_thread_exit(const R& r);
+    void set_value_at_thread_exit(R&& r);
+    void set_exception_at_thread_exit(exception_ptr p);
+};
+
+template <class R>
+class promise<R&>
+{
+public:
+    promise();
+    template <class Allocator>
+        promise(allocator_arg_t, const Allocator& a);
+    promise(promise&& rhs) noexcept;
+    promise(const promise& rhs) = delete;
+    ~promise();
+
+    // assignment
+    promise& operator=(promise&& rhs) noexcept;
+    promise& operator=(const promise& rhs) = delete;
+    void swap(promise& other) noexcept;
+
+    // retrieving the result
+    future<R&> get_future();
+
+    // setting the result
+    void set_value(R& r);
+    void set_exception(exception_ptr p);
+
+    // setting the result with deferred notification
+    void set_value_at_thread_exit(R&);
+    void set_exception_at_thread_exit(exception_ptr p);
+};
+
+template <>
+class promise<void>
+{
+public:
+    promise();
+    template <class Allocator>
+        promise(allocator_arg_t, const Allocator& a);
+    promise(promise&& rhs) noexcept;
+    promise(const promise& rhs) = delete;
+    ~promise();
+
+    // assignment
+    promise& operator=(promise&& rhs) noexcept;
+    promise& operator=(const promise& rhs) = delete;
+    void swap(promise& other) noexcept;
+
+    // retrieving the result
+    future<void> get_future();
+
+    // setting the result
+    void set_value();
+    void set_exception(exception_ptr p);
+
+    // setting the result with deferred notification
+    void set_value_at_thread_exit();
+    void set_exception_at_thread_exit(exception_ptr p);
+};
+
+template <class R> void swap(promise<R>& x, promise<R>& y) noexcept;
+
+template <class R, class Alloc>
+    struct uses_allocator<promise<R>, Alloc> : public true_type {};
+
+template <class R>
+class future
+{
+public:
+    future() noexcept;
+    future(future&&) noexcept;
+    future(const future& rhs) = delete;
+    ~future();
+    future& operator=(const future& rhs) = delete;
+    future& operator=(future&&) noexcept;
+    shared_future<R> share();
+
+    // retrieving the value
+    R get();
+
+    // functions to check state
+    bool valid() const noexcept;
+
+    void wait() const;
+    template <class Rep, class Period>
+        future_status
+        wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+    template <class Clock, class Duration>
+        future_status
+        wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class R>
+class future<R&>
+{
+public:
+    future() noexcept;
+    future(future&&) noexcept;
+    future(const future& rhs) = delete;
+    ~future();
+    future& operator=(const future& rhs) = delete;
+    future& operator=(future&&) noexcept;
+    shared_future<R&> share();
+
+    // retrieving the value
+    R& get();
+
+    // functions to check state
+    bool valid() const noexcept;
+
+    void wait() const;
+    template <class Rep, class Period>
+        future_status
+        wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+    template <class Clock, class Duration>
+        future_status
+        wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <>
+class future<void>
+{
+public:
+    future() noexcept;
+    future(future&&) noexcept;
+    future(const future& rhs) = delete;
+    ~future();
+    future& operator=(const future& rhs) = delete;
+    future& operator=(future&&) noexcept;
+    shared_future<void> share();
+
+    // retrieving the value
+    void get();
+
+    // functions to check state
+    bool valid() const noexcept;
+
+    void wait() const;
+    template <class Rep, class Period>
+        future_status
+        wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+    template <class Clock, class Duration>
+        future_status
+        wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class R>
+class shared_future
+{
+public:
+    shared_future() noexcept;
+    shared_future(const shared_future& rhs);
+    shared_future(future<R>&&) noexcept;
+    shared_future(shared_future&& rhs) noexcept;
+    ~shared_future();
+    shared_future& operator=(const shared_future& rhs);
+    shared_future& operator=(shared_future&& rhs) noexcept;
+
+    // retrieving the value
+    const R& get() const;
+
+    // functions to check state
+    bool valid() const noexcept;
+
+    void wait() const;
+    template <class Rep, class Period>
+        future_status
+        wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+    template <class Clock, class Duration>
+        future_status
+        wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class R>
+class shared_future<R&>
+{
+public:
+    shared_future() noexcept;
+    shared_future(const shared_future& rhs);
+    shared_future(future<R&>&&) noexcept;
+    shared_future(shared_future&& rhs) noexcept;
+    ~shared_future();
+    shared_future& operator=(const shared_future& rhs);
+    shared_future& operator=(shared_future&& rhs) noexcept;
+
+    // retrieving the value
+    R& get() const;
+
+    // functions to check state
+    bool valid() const noexcept;
+
+    void wait() const;
+    template <class Rep, class Period>
+        future_status
+        wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+    template <class Clock, class Duration>
+        future_status
+        wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <>
+class shared_future<void>
+{
+public:
+    shared_future() noexcept;
+    shared_future(const shared_future& rhs);
+    shared_future(future<void>&&) noexcept;
+    shared_future(shared_future&& rhs) noexcept;
+    ~shared_future();
+    shared_future& operator=(const shared_future& rhs);
+    shared_future& operator=(shared_future&& rhs) noexcept;
+
+    // retrieving the value
+    void get() const;
+
+    // functions to check state
+    bool valid() const noexcept;
+
+    void wait() const;
+    template <class Rep, class Period>
+        future_status
+        wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+    template <class Clock, class Duration>
+        future_status
+        wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+};
+
+template <class F, class... Args>
+  future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
+  async(F&& f, Args&&... args);
+
+template <class F, class... Args>
+  future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
+  async(launch policy, F&& f, Args&&... args);
+
+template <class> class packaged_task; // undefined
+
+template <class R, class... ArgTypes>
+class packaged_task<R(ArgTypes...)>
+{
+public:
+    typedef R result_type;
+
+    // construction and destruction
+    packaged_task() noexcept;
+    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();
+
+    // no copy
+    packaged_task(const packaged_task&) = delete;
+    packaged_task& operator=(const packaged_task&) = delete;
+
+    // move support
+    packaged_task(packaged_task&& other) noexcept;
+    packaged_task& operator=(packaged_task&& other) noexcept;
+    void swap(packaged_task& other) noexcept;
+
+    bool valid() const noexcept;
+
+    // result retrieval
+    future<R> get_future();
+
+    // execution
+    void operator()(ArgTypes... );
+    void make_ready_at_thread_exit(ArgTypes...);
+
+    void reset();
+};
+
+template <class R>
+  void swap(packaged_task<R(ArgTypes...)&, packaged_task<R(ArgTypes...)>&) noexcept;
+
+template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <system_error>
+#include <memory>
+#include <chrono>
+#include <exception>
+#include <mutex>
+#include <thread>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+//enum class future_errc
+_LIBCPP_DECLARE_STRONG_ENUM(future_errc)
+{
+    future_already_retrieved = 1,
+    promise_already_satisfied,
+    no_state,
+    broken_promise
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc> : public true_type {};
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc::__lx> : public true_type { };
+#endif
+
+//enum class launch
+_LIBCPP_DECLARE_STRONG_ENUM(launch)
+{
+    async = 1,
+    deferred = 2,
+    any = async | deferred
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
+
+#ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
+
+#ifdef _LIBCXX_UNDERLYING_TYPE
+typedef underlying_type<launch>::type __launch_underlying_type;
+#else
+typedef int __launch_underlying_type;
+#endif
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator&(launch __x, launch __y)
+{
+    return static_cast<launch>(static_cast<__launch_underlying_type>(__x) &
+                               static_cast<__launch_underlying_type>(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator|(launch __x, launch __y)
+{
+    return static_cast<launch>(static_cast<__launch_underlying_type>(__x) |
+                               static_cast<__launch_underlying_type>(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator^(launch __x, launch __y)
+{
+    return static_cast<launch>(static_cast<__launch_underlying_type>(__x) ^
+                               static_cast<__launch_underlying_type>(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+launch
+operator~(launch __x)
+{
+    return static_cast<launch>(~static_cast<__launch_underlying_type>(__x) & 3);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+launch&
+operator&=(launch& __x, launch __y)
+{
+    __x = __x & __y; return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+launch&
+operator|=(launch& __x, launch __y)
+{
+    __x = __x | __y; return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+launch&
+operator^=(launch& __x, launch __y)
+{
+    __x = __x ^ __y; return __x;
+}
+
+#endif  // !_LIBCPP_HAS_NO_STRONG_ENUMS
+
+//enum class future_status
+_LIBCPP_DECLARE_STRONG_ENUM(future_status)
+{
+    ready,
+    timeout,
+    deferred
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_status)
+
+_LIBCPP_FUNC_VIS
+const error_category& future_category() _NOEXCEPT;
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_code
+make_error_code(future_errc __e) _NOEXCEPT
+{
+    return error_code(static_cast<int>(__e), future_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_condition
+make_error_condition(future_errc __e) _NOEXCEPT
+{
+    return error_condition(static_cast<int>(__e), future_category());
+}
+
+class _LIBCPP_EXCEPTION_ABI future_error
+    : public logic_error
+{
+    error_code __ec_;
+public:
+    future_error(error_code __ec);
+
+    _LIBCPP_INLINE_VISIBILITY
+    const error_code& code() const _NOEXCEPT {return __ec_;}
+
+    virtual ~future_error() _NOEXCEPT;
+};
+
+class _LIBCPP_TYPE_VIS __assoc_sub_state
+    : public __shared_count
+{
+protected:
+    exception_ptr __exception_;
+    mutable mutex __mut_;
+    mutable condition_variable __cv_;
+    unsigned __state_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+    void __sub_wait(unique_lock<mutex>& __lk);
+public:
+    enum
+    {
+        __constructed = 1,
+        __future_attached = 2,
+        ready = 4,
+        deferred = 8
+    };
+
+    _LIBCPP_INLINE_VISIBILITY
+    __assoc_sub_state() : __state_(0) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool __has_value() const
+        {return (__state_ & __constructed) || (__exception_ != nullptr);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_future_attached()
+    {
+        lock_guard<mutex> __lk(__mut_);
+        __state_ |= __future_attached;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    bool __has_future_attached() const {return (__state_ & __future_attached) != 0;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_deferred() {__state_ |= deferred;}
+
+    void __make_ready();
+    _LIBCPP_INLINE_VISIBILITY
+    bool __is_ready() const {return (__state_ & ready) != 0;}
+
+    void set_value();
+    void set_value_at_thread_exit();
+
+    void set_exception(exception_ptr __p);
+    void set_exception_at_thread_exit(exception_ptr __p);
+
+    void copy();
+
+    void wait();
+    template <class _Rep, class _Period>
+        future_status
+        wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const;
+    template <class _Clock, class _Duration>
+        future_status
+        wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const;
+
+    virtual void __execute();
+};
+
+template <class _Clock, class _Duration>
+future_status
+__assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+{
+    unique_lock<mutex> __lk(__mut_);
+    if (__state_ & deferred)
+        return future_status::deferred;
+    while (!(__state_ & ready) && _Clock::now() < __abs_time)
+        __cv_.wait_until(__lk, __abs_time);
+    if (__state_ & ready)
+        return future_status::ready;
+    return future_status::timeout;
+}
+
+template <class _Rep, class _Period>
+inline _LIBCPP_INLINE_VISIBILITY
+future_status
+__assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+{
+    return wait_until(chrono::steady_clock::now() + __rel_time);
+}
+
+template <class _Rp>
+class __assoc_state
+    : public __assoc_sub_state
+{
+    typedef __assoc_sub_state base;
+    typedef typename aligned_storage<sizeof(_Rp), alignment_of<_Rp>::value>::type _Up;
+protected:
+    _Up __value_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+public:
+
+    template <class _Arg>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        void set_value(_Arg&& __arg);
+#else
+        void set_value(_Arg& __arg);
+#endif
+
+    template <class _Arg>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        void set_value_at_thread_exit(_Arg&& __arg);
+#else
+        void set_value_at_thread_exit(_Arg& __arg);
+#endif
+
+    _Rp move();
+    typename add_lvalue_reference<_Rp>::type copy();
+};
+
+template <class _Rp>
+void
+__assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT
+{
+    if (this->__state_ & base::__constructed)
+        reinterpret_cast<_Rp*>(&__value_)->~_Rp();
+    delete this;
+}
+
+template <class _Rp>
+template <class _Arg>
+void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__assoc_state<_Rp>::set_value(_Arg&& __arg)
+#else
+__assoc_state<_Rp>::set_value(_Arg& __arg)
+#endif
+{
+    unique_lock<mutex> __lk(this->__mut_);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (this->__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+#endif
+    ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
+    this->__state_ |= base::__constructed | base::ready;
+    __lk.unlock();
+    __cv_.notify_all();
+}
+
+template <class _Rp>
+template <class _Arg>
+void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg)
+#else
+__assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg)
+#endif
+{
+    unique_lock<mutex> __lk(this->__mut_);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (this->__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+#endif
+    ::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>
+_Rp
+__assoc_state<_Rp>::move()
+{
+    unique_lock<mutex> __lk(this->__mut_);
+    this->__sub_wait(__lk);
+    if (this->__exception_ != nullptr)
+        rethrow_exception(this->__exception_);
+    return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_));
+}
+
+template <class _Rp>
+typename add_lvalue_reference<_Rp>::type
+__assoc_state<_Rp>::copy()
+{
+    unique_lock<mutex> __lk(this->__mut_);
+    this->__sub_wait(__lk);
+    if (this->__exception_ != nullptr)
+        rethrow_exception(this->__exception_);
+    return *reinterpret_cast<_Rp*>(&__value_);
+}
+
+template <class _Rp>
+class __assoc_state<_Rp&>
+    : public __assoc_sub_state
+{
+    typedef __assoc_sub_state base;
+    typedef _Rp* _Up;
+protected:
+    _Up __value_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+public:
+
+    void set_value(_Rp& __arg);
+    void set_value_at_thread_exit(_Rp& __arg);
+
+    _Rp& copy();
+};
+
+template <class _Rp>
+void
+__assoc_state<_Rp&>::__on_zero_shared() _NOEXCEPT
+{
+    delete this;
+}
+
+template <class _Rp>
+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
+    __value_ = _VSTD::addressof(__arg);
+    this->__state_ |= base::__constructed | base::ready;
+    __lk.unlock();
+    __cv_.notify_all();
+}
+
+template <class _Rp>
+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
+    __value_ = _VSTD::addressof(__arg);
+    this->__state_ |= base::__constructed;
+    __thread_local_data()->__make_ready_at_thread_exit(this);
+    __lk.unlock();
+}
+
+template <class _Rp>
+_Rp&
+__assoc_state<_Rp&>::copy()
+{
+    unique_lock<mutex> __lk(this->__mut_);
+    this->__sub_wait(__lk);
+    if (this->__exception_ != nullptr)
+        rethrow_exception(this->__exception_);
+    return *__value_;
+}
+
+template <class _Rp, class _Alloc>
+class __assoc_state_alloc
+    : public __assoc_state<_Rp>
+{
+    typedef __assoc_state<_Rp> base;
+    _Alloc __alloc_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __assoc_state_alloc(const _Alloc& __a)
+        : __alloc_(__a) {}
+};
+
+template <class _Rp, class _Alloc>
+void
+__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_);
+    this->~__assoc_state_alloc();
+    __a.deallocate(this, 1);
+}
+
+template <class _Rp, class _Alloc>
+class __assoc_state_alloc<_Rp&, _Alloc>
+    : public __assoc_state<_Rp&>
+{
+    typedef __assoc_state<_Rp&> base;
+    _Alloc __alloc_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __assoc_state_alloc(const _Alloc& __a)
+        : __alloc_(__a) {}
+};
+
+template <class _Rp, class _Alloc>
+void
+__assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT
+{
+    typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_);
+    this->~__assoc_state_alloc();
+    __a.deallocate(this, 1);
+}
+
+template <class _Alloc>
+class __assoc_sub_state_alloc
+    : public __assoc_sub_state
+{
+    typedef __assoc_sub_state base;
+    _Alloc __alloc_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __assoc_sub_state_alloc(const _Alloc& __a)
+        : __alloc_(__a) {}
+};
+
+template <class _Alloc>
+void
+__assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT
+{
+    typename _Alloc::template rebind<__assoc_sub_state_alloc>::other __a(__alloc_);
+    this->~__assoc_sub_state_alloc();
+    __a.deallocate(this, 1);
+}
+
+template <class _Rp, class _Fp>
+class __deferred_assoc_state
+    : public __assoc_state<_Rp>
+{
+    typedef __assoc_state<_Rp> base;
+
+    _Fp __func_;
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    explicit __deferred_assoc_state(_Fp&& __f);
+#endif
+
+    virtual void __execute();
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Rp, class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+__deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f)
+    : __func_(_VSTD::forward<_Fp>(__f))
+{
+    this->__set_deferred();
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Rp, class _Fp>
+void
+__deferred_assoc_state<_Rp, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        this->set_value(__func_());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->set_exception(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Fp>
+class __deferred_assoc_state<void, _Fp>
+    : public __assoc_sub_state
+{
+    typedef __assoc_sub_state base;
+
+    _Fp __func_;
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    explicit __deferred_assoc_state(_Fp&& __f);
+#endif
+
+    virtual void __execute();
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+__deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f)
+    : __func_(_VSTD::forward<_Fp>(__f))
+{
+    this->__set_deferred();
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Fp>
+void
+__deferred_assoc_state<void, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __func_();
+        this->set_value();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->set_exception(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Rp, class _Fp>
+class __async_assoc_state
+    : public __assoc_state<_Rp>
+{
+    typedef __assoc_state<_Rp> base;
+
+    _Fp __func_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    explicit __async_assoc_state(_Fp&& __f);
+#endif
+
+    virtual void __execute();
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Rp, class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+__async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f)
+    : __func_(_VSTD::forward<_Fp>(__f))
+{
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Rp, class _Fp>
+void
+__async_assoc_state<_Rp, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        this->set_value(__func_());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->set_exception(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Rp, class _Fp>
+void
+__async_assoc_state<_Rp, _Fp>::__on_zero_shared() _NOEXCEPT
+{
+    this->wait();
+    base::__on_zero_shared();
+}
+
+template <class _Fp>
+class __async_assoc_state<void, _Fp>
+    : public __assoc_sub_state
+{
+    typedef __assoc_sub_state base;
+
+    _Fp __func_;
+
+    virtual void __on_zero_shared() _NOEXCEPT;
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    explicit __async_assoc_state(_Fp&& __f);
+#endif
+
+    virtual void __execute();
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+__async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f)
+    : __func_(_VSTD::forward<_Fp>(__f))
+{
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Fp>
+void
+__async_assoc_state<void, _Fp>::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __func_();
+        this->set_value();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->set_exception(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Fp>
+void
+__async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT
+{
+    this->wait();
+    base::__on_zero_shared();
+}
+
+template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY promise;
+template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY shared_future;
+
+// future
+
+template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY future;
+
+template <class _Rp, class _Fp>
+future<_Rp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__make_deferred_assoc_state(_Fp&& __f);
+#else
+__make_deferred_assoc_state(_Fp __f);
+#endif
+
+template <class _Rp, class _Fp>
+future<_Rp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__make_async_assoc_state(_Fp&& __f);
+#else
+__make_async_assoc_state(_Fp __f);
+#endif
+
+template <class _Rp>
+class _LIBCPP_TYPE_VIS_ONLY future
+{
+    __assoc_state<_Rp>* __state_;
+
+    explicit future(__assoc_state<_Rp>* __state);
+
+    template <class> friend class promise;
+    template <class> friend class shared_future;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_async_assoc_state(_Fp&& __f);
+#else
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_deferred_assoc_state(_Fp __f);
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_async_assoc_state(_Fp __f);
+#endif
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    future() _NOEXCEPT : __state_(nullptr) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    future(future&& __rhs) _NOEXCEPT
+        : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+    future(const future&) = delete;
+    future& operator=(const future&) = delete;
+    _LIBCPP_INLINE_VISIBILITY
+    future& operator=(future&& __rhs) _NOEXCEPT
+        {
+            future(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    future(const future&);
+    future& operator=(const future&);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~future();
+    shared_future<_Rp> share();
+
+    // retrieving the value
+    _Rp get();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // functions to check state
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void wait() const {__state_->wait();}
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+            {return __state_->wait_for(__rel_time);}
+    template <class _Clock, class _Duration>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+            {return __state_->wait_until(__abs_time);}
+};
+
+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
+    __state_->__add_shared();
+    __state_->__set_future_attached();
+}
+
+struct __release_shared_count
+{
+    void operator()(__shared_count* p) {p->__release_shared();}
+};
+
+template <class _Rp>
+future<_Rp>::~future()
+{
+    if (__state_)
+        __state_->__release_shared();
+}
+
+template <class _Rp>
+_Rp
+future<_Rp>::get()
+{
+    unique_ptr<__shared_count, __release_shared_count> __(__state_);
+    __assoc_state<_Rp>* __s = __state_;
+    __state_ = nullptr;
+    return __s->move();
+}
+
+template <class _Rp>
+class _LIBCPP_TYPE_VIS_ONLY future<_Rp&>
+{
+    __assoc_state<_Rp&>* __state_;
+
+    explicit future(__assoc_state<_Rp&>* __state);
+
+    template <class> friend class promise;
+    template <class> friend class shared_future;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_async_assoc_state(_Fp&& __f);
+#else
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_deferred_assoc_state(_Fp __f);
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_async_assoc_state(_Fp __f);
+#endif
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    future() _NOEXCEPT : __state_(nullptr) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    future(future&& __rhs) _NOEXCEPT
+        : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+    future(const future&) = delete;
+    future& operator=(const future&) = delete;
+    _LIBCPP_INLINE_VISIBILITY
+    future& operator=(future&& __rhs) _NOEXCEPT
+        {
+            future(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    future(const future&);
+    future& operator=(const future&);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~future();
+    shared_future<_Rp&> share();
+
+    // retrieving the value
+    _Rp& get();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // functions to check state
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void wait() const {__state_->wait();}
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+            {return __state_->wait_for(__rel_time);}
+    template <class _Clock, class _Duration>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+            {return __state_->wait_until(__abs_time);}
+};
+
+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
+    __state_->__add_shared();
+    __state_->__set_future_attached();
+}
+
+template <class _Rp>
+future<_Rp&>::~future()
+{
+    if (__state_)
+        __state_->__release_shared();
+}
+
+template <class _Rp>
+_Rp&
+future<_Rp&>::get()
+{
+    unique_ptr<__shared_count, __release_shared_count> __(__state_);
+    __assoc_state<_Rp&>* __s = __state_;
+    __state_ = nullptr;
+    return __s->copy();
+}
+
+template <>
+class _LIBCPP_TYPE_VIS future<void>
+{
+    __assoc_sub_state* __state_;
+
+    explicit future(__assoc_sub_state* __state);
+
+    template <class> friend class promise;
+    template <class> friend class shared_future;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_deferred_assoc_state(_Fp&& __f);
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_async_assoc_state(_Fp&& __f);
+#else
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_deferred_assoc_state(_Fp __f);
+    template <class _R1, class _Fp>
+        friend future<_R1> __make_async_assoc_state(_Fp __f);
+#endif
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    future() _NOEXCEPT : __state_(nullptr) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    future(future&& __rhs) _NOEXCEPT
+        : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+    future(const future&) = delete;
+    future& operator=(const future&) = delete;
+    _LIBCPP_INLINE_VISIBILITY
+    future& operator=(future&& __rhs) _NOEXCEPT
+        {
+            future(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    future(const future&);
+    future& operator=(const future&);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~future();
+    shared_future<void> share();
+
+    // retrieving the value
+    void get();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // functions to check state
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void wait() const {__state_->wait();}
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+            {return __state_->wait_for(__rel_time);}
+    template <class _Clock, class _Duration>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+            {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT
+{
+    __x.swap(__y);
+}
+
+// promise<R>
+
+template <class _Callable> class packaged_task;
+
+template <class _Rp>
+class _LIBCPP_TYPE_VIS_ONLY promise
+{
+    __assoc_state<_Rp>* __state_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
+
+    template <class> friend class packaged_task;
+public:
+    promise();
+    template <class _Alloc>
+        promise(allocator_arg_t, const _Alloc& __a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    promise(promise&& __rhs) _NOEXCEPT
+        : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+    promise(const promise& __rhs) = delete;
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    promise(const promise& __rhs);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~promise();
+
+    // assignment
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    promise& operator=(promise&& __rhs) _NOEXCEPT
+        {
+            promise(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+    promise& operator=(const promise& __rhs) = delete;
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    promise& operator=(const promise& __rhs);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // retrieving the result
+    future<_Rp> get_future();
+
+    // setting the result
+    void set_value(const _Rp& __r);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void set_value(_Rp&& __r);
+#endif
+    void set_exception(exception_ptr __p);
+
+    // setting the result with deferred notification
+    void set_value_at_thread_exit(const _Rp& __r);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void set_value_at_thread_exit(_Rp&& __r);
+#endif
+    void set_exception_at_thread_exit(exception_ptr __p);
+};
+
+template <class _Rp>
+promise<_Rp>::promise()
+    : __state_(new __assoc_state<_Rp>)
+{
+}
+
+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 __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();
+}
+
+template <class _Rp>
+promise<_Rp>::~promise()
+{
+    if (__state_)
+    {
+        if (!__state_->__has_value() && __state_->use_count() > 1)
+            __state_->set_exception(make_exception_ptr(
+                      future_error(make_error_code(future_errc::broken_promise))
+                                                      ));
+        __state_->__release_shared();
+    }
+}
+
+template <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
+    return future<_Rp>(__state_);
+}
+
+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
+    __state_->set_value(__r);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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
+    __state_->set_value(_VSTD::move(__r));
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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
+    __state_->set_exception(__p);
+}
+
+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
+    __state_->set_value_at_thread_exit(__r);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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
+    __state_->set_value_at_thread_exit(_VSTD::move(__r));
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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
+    __state_->set_exception_at_thread_exit(__p);
+}
+
+// promise<R&>
+
+template <class _Rp>
+class _LIBCPP_TYPE_VIS_ONLY promise<_Rp&>
+{
+    __assoc_state<_Rp&>* __state_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
+
+    template <class> friend class packaged_task;
+
+public:
+    promise();
+    template <class _Allocator>
+        promise(allocator_arg_t, const _Allocator& __a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    promise(promise&& __rhs) _NOEXCEPT
+        : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+    promise(const promise& __rhs) = delete;
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    promise(const promise& __rhs);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~promise();
+
+    // assignment
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    promise& operator=(promise&& __rhs) _NOEXCEPT
+        {
+            promise(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+    promise& operator=(const promise& __rhs) = delete;
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    promise& operator=(const promise& __rhs);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // retrieving the result
+    future<_Rp&> get_future();
+
+    // setting the result
+    void set_value(_Rp& __r);
+    void set_exception(exception_ptr __p);
+
+    // setting the result with deferred notification
+    void set_value_at_thread_exit(_Rp&);
+    void set_exception_at_thread_exit(exception_ptr __p);
+};
+
+template <class _Rp>
+promise<_Rp&>::promise()
+    : __state_(new __assoc_state<_Rp&>)
+{
+}
+
+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 __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();
+}
+
+template <class _Rp>
+promise<_Rp&>::~promise()
+{
+    if (__state_)
+    {
+        if (!__state_->__has_value() && __state_->use_count() > 1)
+            __state_->set_exception(make_exception_ptr(
+                      future_error(make_error_code(future_errc::broken_promise))
+                                                      ));
+        __state_->__release_shared();
+    }
+}
+
+template <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
+    return future<_Rp&>(__state_);
+}
+
+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
+    __state_->set_value(__r);
+}
+
+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
+    __state_->set_exception(__p);
+}
+
+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
+    __state_->set_value_at_thread_exit(__r);
+}
+
+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
+    __state_->set_exception_at_thread_exit(__p);
+}
+
+// promise<void>
+
+template <>
+class _LIBCPP_TYPE_VIS promise<void>
+{
+    __assoc_sub_state* __state_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
+
+    template <class> friend class packaged_task;
+
+public:
+    promise();
+    template <class _Allocator>
+        promise(allocator_arg_t, const _Allocator& __a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    promise(promise&& __rhs) _NOEXCEPT
+        : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;}
+    promise(const promise& __rhs) = delete;
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    promise(const promise& __rhs);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~promise();
+
+    // assignment
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    promise& operator=(promise&& __rhs) _NOEXCEPT
+        {
+            promise(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+    promise& operator=(const promise& __rhs) = delete;
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+private:
+    promise& operator=(const promise& __rhs);
+public:
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // retrieving the result
+    future<void> get_future();
+
+    // setting the result
+    void set_value();
+    void set_exception(exception_ptr __p);
+
+    // setting the result with deferred notification
+    void set_value_at_thread_exit();
+    void set_exception_at_thread_exit(exception_ptr __p);
+};
+
+template <class _Alloc>
+promise<void>::promise(allocator_arg_t, const _Alloc& __a0)
+{
+    typedef typename _Alloc::template rebind<__assoc_sub_state_alloc<_Alloc> >::other _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();
+}
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT
+{
+    __x.swap(__y);
+}
+
+template <class _Rp, class _Alloc>
+    struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<promise<_Rp>, _Alloc>
+        : public true_type {};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+// packaged_task
+
+template<class _Fp> class __packaged_task_base;
+
+template<class _Rp, class ..._ArgTypes>
+class __packaged_task_base<_Rp(_ArgTypes...)>
+{
+    __packaged_task_base(const __packaged_task_base&);
+    __packaged_task_base& operator=(const __packaged_task_base&);
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __packaged_task_base() {}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual ~__packaged_task_base() {}
+    virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
+    virtual void destroy() = 0;
+    virtual void destroy_deallocate() = 0;
+    virtual _Rp operator()(_ArgTypes&& ...) = 0;
+};
+
+template<class _FD, class _Alloc, class _FB> class __packaged_task_func;
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+class __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>
+    : public  __packaged_task_base<_Rp(_ArgTypes...)>
+{
+    __compressed_pair<_Fp, _Alloc> __f_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __packaged_task_func(const _Fp& __f) : __f_(__f) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    __packaged_task_func(const _Fp& __f, const _Alloc& __a)
+        : __f_(__f, __a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    __packaged_task_func(_Fp&& __f, const _Alloc& __a)
+        : __f_(_VSTD::move(__f), __a) {}
+    virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT;
+    virtual void destroy();
+    virtual void destroy_deallocate();
+    virtual _Rp operator()(_ArgTypes&& ... __args);
+};
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(
+                              __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT
+{
+    ::new (__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second()));
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+void
+__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy()
+{
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+}
+
+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;
+    _Ap __a(__f_.second());
+    __f_.~__compressed_pair<_Fp, _Alloc>();
+    __a.deallocate(this, 1);
+}
+
+template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
+_Rp
+__packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
+{
+    return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...);
+}
+
+template <class _Callable> class __packaged_task_function;
+
+template<class _Rp, class ..._ArgTypes>
+class __packaged_task_function<_Rp(_ArgTypes...)>
+{
+    typedef __packaged_task_base<_Rp(_ArgTypes...)> __base;
+    typename aligned_storage<3*sizeof(void*)>::type __buf_;
+    __base* __f_;
+
+public:
+    typedef _Rp result_type;
+
+    // construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY
+    __packaged_task_function() _NOEXCEPT : __f_(nullptr) {}
+    template<class _Fp>
+      __packaged_task_function(_Fp&& __f);
+    template<class _Fp, class _Alloc>
+      __packaged_task_function(allocator_arg_t, const _Alloc& __a, _Fp&& __f);
+
+    __packaged_task_function(__packaged_task_function&&) _NOEXCEPT;
+    __packaged_task_function& operator=(__packaged_task_function&&) _NOEXCEPT;
+
+    __packaged_task_function(const __packaged_task_function&) =  delete;
+    __packaged_task_function& operator=(const __packaged_task_function&) =  delete;
+
+    ~__packaged_task_function();
+
+    void swap(__packaged_task_function&) _NOEXCEPT;
+
+    _Rp operator()(_ArgTypes...) const;
+};
+
+template<class _Rp, class ..._ArgTypes>
+__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(__packaged_task_function&& __f) _NOEXCEPT
+{
+    if (__f.__f_ == nullptr)
+        __f_ = nullptr;
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__move_to(__f_);
+    }
+    else
+    {
+        __f_ = __f.__f_;
+        __f.__f_ = nullptr;
+    }
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp>
+__packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f)
+    : __f_(nullptr)
+{
+    typedef typename remove_reference<typename decay<_Fp>::type>::type _FR;
+    typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF;
+    if (sizeof(_FF) <= sizeof(__buf_))
+    {
+        __f_ = (__base*)&__buf_;
+        ::new (__f_) _FF(_VSTD::forward<_Fp>(__f));
+    }
+    else
+    {
+        typedef allocator<_FF> _Ap;
+        _Ap __a;
+        typedef __allocator_destructor<_Ap> _Dp;
+        unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+        ::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a));
+        __f_ = __hold.release();
+    }
+}
+
+template<class _Rp, class ..._ArgTypes>
+template <class _Fp, class _Alloc>
+__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_))
+    {
+        __f_ = (__base*)&__buf_;
+        ::new (__f_) _FF(_VSTD::forward<_Fp>(__f));
+    }
+    else
+    {
+        typedef typename __alloc_traits::template
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+            rebind_alloc<_FF>
+#else
+            rebind_alloc<_FF>::other
+#endif
+                                                     _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();
+    }
+}
+
+template<class _Rp, class ..._ArgTypes>
+__packaged_task_function<_Rp(_ArgTypes...)>&
+__packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&& __f) _NOEXCEPT
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+    __f_ = nullptr;
+    if (__f.__f_ == nullptr)
+        __f_ = nullptr;
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f_ = (__base*)&__buf_;
+        __f.__f_->__move_to(__f_);
+    }
+    else
+    {
+        __f_ = __f.__f_;
+        __f.__f_ = nullptr;
+    }
+    return *this;
+}
+
+template<class _Rp, class ..._ArgTypes>
+__packaged_task_function<_Rp(_ArgTypes...)>::~__packaged_task_function()
+{
+    if (__f_ == (__base*)&__buf_)
+        __f_->destroy();
+    else if (__f_)
+        __f_->destroy_deallocate();
+}
+
+template<class _Rp, class ..._ArgTypes>
+void
+__packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) _NOEXCEPT
+{
+    if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
+    {
+        typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+        __base* __t = (__base*)&__tempbuf;
+        __f_->__move_to(__t);
+        __f_->destroy();
+        __f_ = nullptr;
+        __f.__f_->__move_to((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = nullptr;
+        __f_ = (__base*)&__buf_;
+        __t->__move_to((__base*)&__f.__buf_);
+        __t->destroy();
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f_ == (__base*)&__buf_)
+    {
+        __f_->__move_to((__base*)&__f.__buf_);
+        __f_->destroy();
+        __f_ = __f.__f_;
+        __f.__f_ = (__base*)&__f.__buf_;
+    }
+    else if (__f.__f_ == (__base*)&__f.__buf_)
+    {
+        __f.__f_->__move_to((__base*)&__buf_);
+        __f.__f_->destroy();
+        __f.__f_ = __f_;
+        __f_ = (__base*)&__buf_;
+    }
+    else
+        _VSTD::swap(__f_, __f.__f_);
+}
+
+template<class _Rp, class ..._ArgTypes>
+inline _LIBCPP_INLINE_VISIBILITY
+_Rp
+__packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
+{
+    return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
+}
+
+template<class _Rp, class ..._ArgTypes>
+class _LIBCPP_TYPE_VIS_ONLY packaged_task<_Rp(_ArgTypes...)>
+{
+public:
+    typedef _Rp result_type;
+
+private:
+    __packaged_task_function<result_type(_ArgTypes...)> __f_;
+    promise<result_type>                                __p_;
+
+public:
+    // construction and destruction
+    _LIBCPP_INLINE_VISIBILITY
+    packaged_task() _NOEXCEPT : __p_(nullptr) {}
+    template <class _Fp,
+              class = typename enable_if
+              <
+                  !is_same<
+                      typename decay<_Fp>::type, 
+                      packaged_task
+                      >::value
+                  >::type
+             >
+        _LIBCPP_INLINE_VISIBILITY
+        explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
+    template <class _Fp, class _Allocator,
+              class = typename enable_if
+              <
+                  !is_same<
+                      typename decay<_Fp>::type, 
+                      packaged_task
+                      >::value
+                  >::type
+              >
+        _LIBCPP_INLINE_VISIBILITY
+        explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
+             : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
+               __p_(allocator_arg, __a) {}
+    // ~packaged_task() = default;
+
+    // no copy
+    packaged_task(const packaged_task&) = delete;
+    packaged_task& operator=(const packaged_task&) = delete;
+
+    // move support
+    _LIBCPP_INLINE_VISIBILITY
+    packaged_task(packaged_task&& __other) _NOEXCEPT
+        : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    packaged_task& operator=(packaged_task&& __other) _NOEXCEPT
+    {
+        __f_ = _VSTD::move(__other.__f_);
+        __p_ = _VSTD::move(__other.__p_);
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(packaged_task& __other) _NOEXCEPT
+    {
+        __f_.swap(__other.__f_);
+        __p_.swap(__other.__p_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;}
+
+    // result retrieval
+    _LIBCPP_INLINE_VISIBILITY
+    future<result_type> get_future() {return __p_.get_future();}
+
+    // execution
+    void operator()(_ArgTypes... __args);
+    void make_ready_at_thread_exit(_ArgTypes... __args);
+
+    void reset();
+};
+
+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));
+    if (__p_.__state_->__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __p_.set_value(__f_(_VSTD::forward<_ArgTypes>(__args)...));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __p_.set_exception(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<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));
+    if (__p_.__state_->__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __p_.set_value_at_thread_exit(__f_(_VSTD::forward<_ArgTypes>(__args)...));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __p_.set_exception_at_thread_exit(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<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
+    __p_ = promise<result_type>();
+}
+
+template<class ..._ArgTypes>
+class _LIBCPP_TYPE_VIS_ONLY packaged_task<void(_ArgTypes...)>
+{
+public:
+    typedef void result_type;
+
+private:
+    __packaged_task_function<result_type(_ArgTypes...)> __f_;
+    promise<result_type>                                __p_;
+
+public:
+    // construction and destruction
+    _LIBCPP_INLINE_VISIBILITY
+    packaged_task() _NOEXCEPT : __p_(nullptr) {}
+    template <class _Fp,
+              class = typename enable_if
+              <
+                  !is_same<
+                      typename decay<_Fp>::type, 
+                      packaged_task
+                      >::value
+                  >::type
+              >
+        _LIBCPP_INLINE_VISIBILITY
+        explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
+    template <class _Fp, class _Allocator,
+              class = typename enable_if
+              <
+                  !is_same<
+                      typename decay<_Fp>::type, 
+                      packaged_task
+                      >::value
+                  >::type
+              >    
+        _LIBCPP_INLINE_VISIBILITY
+        explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
+             : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
+               __p_(allocator_arg, __a) {}
+    // ~packaged_task() = default;
+
+    // no copy
+    packaged_task(const packaged_task&) = delete;
+    packaged_task& operator=(const packaged_task&) = delete;
+
+    // move support
+    _LIBCPP_INLINE_VISIBILITY
+    packaged_task(packaged_task&& __other) _NOEXCEPT
+        : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    packaged_task& operator=(packaged_task&& __other) _NOEXCEPT
+    {
+        __f_ = _VSTD::move(__other.__f_);
+        __p_ = _VSTD::move(__other.__p_);
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(packaged_task& __other) _NOEXCEPT
+    {
+        __f_.swap(__other.__f_);
+        __p_.swap(__other.__p_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;}
+
+    // result retrieval
+    _LIBCPP_INLINE_VISIBILITY
+    future<result_type> get_future() {return __p_.get_future();}
+
+    // execution
+    void operator()(_ArgTypes... __args);
+    void make_ready_at_thread_exit(_ArgTypes... __args);
+
+    void reset();
+};
+
+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));
+    if (__p_.__state_->__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __f_(_VSTD::forward<_ArgTypes>(__args)...);
+        __p_.set_value();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __p_.set_exception(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<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));
+    if (__p_.__state_->__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __f_(_VSTD::forward<_ArgTypes>(__args)...);
+        __p_.set_value_at_thread_exit();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __p_.set_exception_at_thread_exit(current_exception());
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<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
+    __p_ = promise<result_type>();
+}
+
+template <class _Callable>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT
+{
+    __x.swap(__y);
+}
+
+template <class _Callable, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<packaged_task<_Callable>, _Alloc>
+    : public true_type {};
+
+template <class _Rp, class _Fp>
+future<_Rp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__make_deferred_assoc_state(_Fp&& __f)
+#else
+__make_deferred_assoc_state(_Fp __f)
+#endif
+{
+    unique_ptr<__deferred_assoc_state<_Rp, _Fp>, __release_shared_count>
+        __h(new __deferred_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
+    return future<_Rp>(__h.get());
+}
+
+template <class _Rp, class _Fp>
+future<_Rp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__make_async_assoc_state(_Fp&& __f)
+#else
+__make_async_assoc_state(_Fp __f)
+#endif
+{
+    unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count>
+        __h(new __async_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f)));
+    _VSTD::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach();
+    return future<_Rp>(__h.get());
+}
+
+template <class _Fp, class... _Args>
+class __async_func
+{
+    tuple<_Fp, _Args...> __f_;
+
+public:
+    typedef typename __invoke_of<_Fp, _Args...>::type _Rp;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __async_func(_Fp&& __f, _Args&&... __args)
+        : __f_(_VSTD::move(__f), _VSTD::move(__args)...) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __async_func(__async_func&& __f) : __f_(_VSTD::move(__f.__f_)) {}
+
+    _Rp operator()()
+    {
+        typedef typename __make_tuple_indices<1+sizeof...(_Args), 1>::type _Index;
+        return __execute(_Index());
+    }
+private:
+    template <size_t ..._Indices>
+    _Rp
+    __execute(__tuple_indices<_Indices...>)
+    {
+        return __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...);
+    }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, launch __value )
+{ return (int(__policy) & int(__value)) != 0; }
+
+template <class _Fp, class... _Args>
+future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
+async(launch __policy, _Fp&& __f, _Args&&... __args)
+{
+    typedef __async_func<typename decay<_Fp>::type, typename decay<_Args>::type...> _BF;
+    typedef typename _BF::_Rp _Rp;
+
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif
+        if (__does_policy_contain(__policy, launch::async))
+        return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
+                                                     __decay_copy(_VSTD::forward<_Args>(__args))...));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch ( ... ) { if (__policy == launch::async) throw ; }
+#endif
+
+    if (__does_policy_contain(__policy, launch::deferred))
+        return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)),
+                                                        __decay_copy(_VSTD::forward<_Args>(__args))...));
+    return future<_Rp>{};
+}
+
+template <class _Fp, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
+async(_Fp&& __f, _Args&&... __args)
+{
+    return _VSTD::async(launch::any, _VSTD::forward<_Fp>(__f),
+                                    _VSTD::forward<_Args>(__args)...);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+// shared_future
+
+template <class _Rp>
+class _LIBCPP_TYPE_VIS_ONLY shared_future
+{
+    __assoc_state<_Rp>* __state_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future() _NOEXCEPT : __state_(nullptr) {}
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
+        {if (__state_) __state_->__add_shared();}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(future<_Rp>&& __f) _NOEXCEPT : __state_(__f.__state_)
+        {__f.__state_ = nullptr;}
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
+        {__rhs.__state_ = nullptr;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~shared_future();
+    shared_future& operator=(const shared_future& __rhs);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
+        {
+            shared_future(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    // retrieving the value
+    _LIBCPP_INLINE_VISIBILITY
+    const _Rp& get() const {return __state_->copy();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // functions to check state
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void wait() const {__state_->wait();}
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+            {return __state_->wait_for(__rel_time);}
+    template <class _Clock, class _Duration>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+            {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+shared_future<_Rp>::~shared_future()
+{
+    if (__state_)
+        __state_->__release_shared();
+}
+
+template <class _Rp>
+shared_future<_Rp>&
+shared_future<_Rp>::operator=(const shared_future& __rhs)
+{
+    if (__rhs.__state_)
+        __rhs.__state_->__add_shared();
+    if (__state_)
+        __state_->__release_shared();
+    __state_ = __rhs.__state_;
+    return *this;
+}
+
+template <class _Rp>
+class _LIBCPP_TYPE_VIS_ONLY shared_future<_Rp&>
+{
+    __assoc_state<_Rp&>* __state_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future() _NOEXCEPT : __state_(nullptr) {}
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
+        {if (__state_) __state_->__add_shared();}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(future<_Rp&>&& __f) _NOEXCEPT : __state_(__f.__state_)
+        {__f.__state_ = nullptr;}
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
+        {__rhs.__state_ = nullptr;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~shared_future();
+    shared_future& operator=(const shared_future& __rhs);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
+        {
+            shared_future(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    // retrieving the value
+    _LIBCPP_INLINE_VISIBILITY
+    _Rp& get() const {return __state_->copy();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // functions to check state
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void wait() const {__state_->wait();}
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+            {return __state_->wait_for(__rel_time);}
+    template <class _Clock, class _Duration>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+            {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+shared_future<_Rp&>::~shared_future()
+{
+    if (__state_)
+        __state_->__release_shared();
+}
+
+template <class _Rp>
+shared_future<_Rp&>&
+shared_future<_Rp&>::operator=(const shared_future& __rhs)
+{
+    if (__rhs.__state_)
+        __rhs.__state_->__add_shared();
+    if (__state_)
+        __state_->__release_shared();
+    __state_ = __rhs.__state_;
+    return *this;
+}
+
+template <>
+class _LIBCPP_TYPE_VIS shared_future<void>
+{
+    __assoc_sub_state* __state_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future() _NOEXCEPT : __state_(nullptr) {}
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(const shared_future& __rhs) : __state_(__rhs.__state_)
+        {if (__state_) __state_->__add_shared();}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(future<void>&& __f) _NOEXCEPT : __state_(__f.__state_)
+        {__f.__state_ = nullptr;}
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
+        {__rhs.__state_ = nullptr;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    ~shared_future();
+    shared_future& operator=(const shared_future& __rhs);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
+        {
+            shared_future(std::move(__rhs)).swap(*this);
+            return *this;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    // retrieving the value
+    _LIBCPP_INLINE_VISIBILITY
+    void get() const {__state_->copy();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);}
+
+    // functions to check state
+    _LIBCPP_INLINE_VISIBILITY
+    bool valid() const _NOEXCEPT {return __state_ != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void wait() const {__state_->wait();}
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const
+            {return __state_->wait_for(__rel_time);}
+    template <class _Clock, class _Duration>
+        _LIBCPP_INLINE_VISIBILITY
+        future_status
+        wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const
+            {return __state_->wait_until(__abs_time);}
+};
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT
+{
+    __x.swap(__y);
+}
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_future<_Rp>
+future<_Rp>::share()
+{
+    return shared_future<_Rp>(_VSTD::move(*this));
+}
+
+template <class _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_future<_Rp&>
+future<_Rp&>::share()
+{
+    return shared_future<_Rp&>(_VSTD::move(*this));
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+inline _LIBCPP_INLINE_VISIBILITY
+shared_future<void>
+future<void>::share()
+{
+    return shared_future<void>(_VSTD::move(*this));
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_FUTURE
diff --git a/final/include/initializer_list b/final/include/initializer_list
new file mode 100644
index 0000000..663e49b
--- /dev/null
+++ b/final/include/initializer_list
@@ -0,0 +1,118 @@
+// -*- C++ -*-
+//===----------------------- initializer_list -----------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_INITIALIZER_LIST
+#define _LIBCPP_INITIALIZER_LIST
+
+/*
+    initializer_list synopsis
+
+namespace std
+{
+
+template<class E>
+class initializer_list
+{
+public:
+    typedef E        value_type;
+    typedef const E& reference;
+    typedef const E& const_reference;
+    typedef size_t   size_type;
+
+    typedef const E* iterator;
+    typedef const E* const_iterator;
+
+    initializer_list() noexcept; // constexpr in C++14
+
+    size_t   size()  const noexcept; // constexpr in C++14
+    const E* begin() const noexcept; // constexpr in C++14
+    const E* end()   const noexcept; // constexpr in C++14
+};
+
+template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14
+template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14
+
+}  // std
+
+*/
+
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+namespace std  // purposefully not versioned
+{
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _Ep>
+class _LIBCPP_TYPE_VIS_ONLY initializer_list
+{
+    const _Ep* __begin_;
+    size_t    __size_;
+
+    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_CONSTEXPR_AFTER_CXX11
+    initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT
+        : __begin_(__b),
+          __size_(__s)
+        {}
+public:
+    typedef _Ep        value_type;
+    typedef const _Ep& reference;
+    typedef const _Ep& const_reference;
+    typedef size_t    size_type;
+
+    typedef const _Ep* iterator;
+    typedef const _Ep* const_iterator;
+
+    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_CONSTEXPR_AFTER_CXX11
+    initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_CONSTEXPR_AFTER_CXX11
+    size_t    size()  const _NOEXCEPT {return __size_;}
+    
+    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_CONSTEXPR_AFTER_CXX11
+    const _Ep* begin() const _NOEXCEPT {return __begin_;}
+
+    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_CONSTEXPR_AFTER_CXX11
+    const _Ep* end()   const _NOEXCEPT {return __begin_ + __size_;}
+};
+
+template<class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Ep*
+begin(initializer_list<_Ep> __il) _NOEXCEPT
+{
+    return __il.begin();
+}
+
+template<class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR_AFTER_CXX11
+const _Ep*
+end(initializer_list<_Ep> __il) _NOEXCEPT
+{
+    return __il.end();
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+}  // std
+
+#endif  // _LIBCPP_INITIALIZER_LIST
diff --git a/final/include/iomanip b/final/include/iomanip
new file mode 100644
index 0000000..a5042c7
--- /dev/null
+++ b/final/include/iomanip
@@ -0,0 +1,654 @@
+// -*- C++ -*-
+//===--------------------------- iomanip ----------------------------------===//
+//
+//                     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_IOMANIP
+#define _LIBCPP_IOMANIP
+
+/*
+    iomanip synopsis
+
+namespace std {
+
+// types T1, T2, ... are unspecified implementation types
+T1 resetiosflags(ios_base::fmtflags mask);
+T2 setiosflags (ios_base::fmtflags mask);
+T3 setbase(int base);
+template<charT> T4 setfill(charT c);
+T5 setprecision(int n);
+T6 setw(int n);
+template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
+template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
+template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
+template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
+
+template <class charT>
+  T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14
+
+template <class charT, class traits, class Allocator>
+  T12 quoted(const basic_string<charT, traits, Allocator>& s,
+             charT delim=charT('"'), charT escape=charT('\\')); // C++14
+
+template <class charT, class traits, class Allocator>
+  T13 quoted(basic_string<charT, traits, Allocator>& s,
+             charT delim=charT('"'), charT escape=charT('\\')); // C++14
+
+}  // std
+
+*/
+
+#include <__config>
+#include <istream>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// resetiosflags
+
+class __iom_t1
+{
+    ios_base::fmtflags __mask_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {}
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x)
+    {
+        __is.unsetf(__x.__mask_);
+        return __is;
+    }
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x)
+    {
+        __os.unsetf(__x.__mask_);
+        return __os;
+    }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t1
+resetiosflags(ios_base::fmtflags __mask)
+{
+    return __iom_t1(__mask);
+}
+
+// setiosflags
+
+class __iom_t2
+{
+    ios_base::fmtflags __mask_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {}
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x)
+    {
+        __is.setf(__x.__mask_);
+        return __is;
+    }
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x)
+    {
+        __os.setf(__x.__mask_);
+        return __os;
+    }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t2
+setiosflags(ios_base::fmtflags __mask)
+{
+    return __iom_t2(__mask);
+}
+
+// setbase
+
+class __iom_t3
+{
+    int __base_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __iom_t3(int __b) : __base_(__b) {}
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x)
+    {
+        __is.setf(__x.__base_ == 8  ? ios_base::oct :
+                  __x.__base_ == 10 ? ios_base::dec :
+                  __x.__base_ == 16 ? ios_base::hex :
+                  ios_base::fmtflags(0), ios_base::basefield);
+        return __is;
+    }
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x)
+    {
+        __os.setf(__x.__base_ == 8  ? ios_base::oct :
+                  __x.__base_ == 10 ? ios_base::dec :
+                  __x.__base_ == 16 ? ios_base::hex :
+                  ios_base::fmtflags(0), ios_base::basefield);
+        return __os;
+    }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t3
+setbase(int __base)
+{
+    return __iom_t3(__base);
+}
+
+// setfill
+
+template<class _CharT>
+class __iom_t4
+{
+    _CharT __fill_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __iom_t4(_CharT __c) : __fill_(__c) {}
+
+    template <class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x)
+    {
+        __os.fill(__x.__fill_);
+        return __os;
+    }
+};
+
+template<class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t4<_CharT>
+setfill(_CharT __c)
+{
+    return __iom_t4<_CharT>(__c);
+}
+
+// setprecision
+
+class __iom_t5
+{
+    int __n_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __iom_t5(int __n) : __n_(__n) {}
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x)
+    {
+        __is.precision(__x.__n_);
+        return __is;
+    }
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x)
+    {
+        __os.precision(__x.__n_);
+        return __os;
+    }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t5
+setprecision(int __n)
+{
+    return __iom_t5(__n);
+}
+
+// setw
+
+class __iom_t6
+{
+    int __n_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __iom_t6(int __n) : __n_(__n) {}
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x)
+    {
+        __is.width(__x.__n_);
+        return __is;
+    }
+
+    template <class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x)
+    {
+        __os.width(__x.__n_);
+        return __os;
+    }
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t6
+setw(int __n)
+{
+    return __iom_t6(__n);
+}
+
+// get_money
+
+template <class _MoneyT> class __iom_t7;
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
+
+template <class _MoneyT>
+class __iom_t7
+{
+    _MoneyT& __mon_;
+    bool __intl_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __iom_t7(_MoneyT& __mon, bool __intl)
+        : __mon_(__mon), __intl_(__intl) {}
+
+    template <class _CharT, class _Traits, class _Mp>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_Mp>& __x);
+};
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+        if (__s)
+        {
+            typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+            typedef money_get<_CharT, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            const _Fp& __mf = use_facet<_Fp>(__is.getloc());
+            __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
+            __is.setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+template <class _MoneyT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t7<_MoneyT>
+get_money(_MoneyT& __mon, bool __intl = false)
+{
+    return __iom_t7<_MoneyT>(__mon, __intl);
+}
+
+// put_money
+
+template <class _MoneyT> class __iom_t8;
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
+
+template <class _MoneyT>
+class __iom_t8
+{
+    const _MoneyT& __mon_;
+    bool __intl_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __iom_t8(const _MoneyT& __mon, bool __intl)
+        : __mon_(__mon), __intl_(__intl) {}
+
+    template <class _CharT, class _Traits, class _Mp>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_Mp>& __x);
+};
+
+template <class _CharT, class _Traits, class _MoneyT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+        if (__s)
+        {
+            typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+            typedef money_put<_CharT, _Op> _Fp;
+            const _Fp& __mf = use_facet<_Fp>(__os.getloc());
+            if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
+                __os.setstate(ios_base::badbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __os.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __os;
+}
+
+template <class _MoneyT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t8<_MoneyT>
+put_money(const _MoneyT& __mon, bool __intl = false)
+{
+    return __iom_t8<_MoneyT>(__mon, __intl);
+}
+
+// get_time
+
+template <class _CharT> class __iom_t9;
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
+
+template <class _CharT>
+class __iom_t9
+{
+    tm* __tm_;
+    const _CharT* __fmt_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __iom_t9(tm* __tm, const _CharT* __fmt)
+        : __tm_(__tm), __fmt_(__fmt) {}
+
+    template <class _Cp, class _Traits>
+    friend
+    basic_istream<_Cp, _Traits>&
+    operator>>(basic_istream<_Cp, _Traits>& __is, const __iom_t9<_Cp>& __x);
+};
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+        if (__s)
+        {
+            typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+            typedef time_get<_CharT, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            const _Fp& __tf = use_facet<_Fp>(__is.getloc());
+            __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_,
+                     __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
+            __is.setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t9<_CharT>
+get_time(tm* __tm, const _CharT* __fmt)
+{
+    return __iom_t9<_CharT>(__tm, __fmt);
+}
+
+// put_time
+
+template <class _CharT> class __iom_t10;
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
+
+template <class _CharT>
+class __iom_t10
+{
+    const tm* __tm_;
+    const _CharT* __fmt_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __iom_t10(const tm* __tm, const _CharT* __fmt)
+        : __tm_(__tm), __fmt_(__fmt) {}
+
+    template <class _Cp, class _Traits>
+    friend
+    basic_ostream<_Cp, _Traits>&
+    operator<<(basic_ostream<_Cp, _Traits>& __os, const __iom_t10<_Cp>& __x);
+};
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+        if (__s)
+        {
+            typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+            typedef time_put<_CharT, _Op> _Fp;
+            const _Fp& __tf = use_facet<_Fp>(__os.getloc());
+            if (__tf.put(_Op(__os), __os, __os.fill(), __x.__tm_,
+                         __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())
+                __os.setstate(ios_base::badbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __os.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __os;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+__iom_t10<_CharT>
+put_time(const tm* __tm, const _CharT* __fmt)
+{
+    return __iom_t10<_CharT>(__tm, __fmt);
+}
+
+#if _LIBCPP_STD_VER > 11
+
+template <class _CharT, class _Traits, class _ForwardIterator>
+std::basic_ostream<_CharT, _Traits> &
+__quoted_output ( basic_ostream<_CharT, _Traits> &__os, 
+        _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
+{
+    _VSTD::basic_string<_CharT, _Traits> __str;
+    __str.push_back(__delim);
+    for ( ; __first != __last; ++ __first )
+    {
+        if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim))
+            __str.push_back(__escape);
+        __str.push_back(*__first);
+    }
+    __str.push_back(__delim);
+    return __put_character_sequence(__os, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _String>
+basic_istream<_CharT, _Traits> &
+__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape )
+{
+    __string.clear ();
+    _CharT __c;
+    __is >> __c;
+    if ( __is.fail ())
+        return __is;
+
+    if (!_Traits::eq (__c, __delim))    // no delimiter, read the whole string
+    {
+        __is.unget ();
+        __is >> __string;
+        return __is;
+    }
+
+    __save_flags<_CharT, _Traits> sf(__is);
+    noskipws (__is);
+    while (true)
+        {
+        __is >> __c;
+        if ( __is.fail ())
+            break;
+        if (_Traits::eq (__c, __escape))
+        {
+            __is >> __c;
+            if ( __is.fail ())
+                break;
+        }
+        else if (_Traits::eq (__c, __delim))
+            break;
+        __string.push_back ( __c );
+        }
+    return __is;
+}
+
+
+template <class _CharT, class _Iter, class _Traits=char_traits<_CharT>>
+struct __quoted_output_proxy
+{
+    _Iter  __first;
+    _Iter  __last;
+    _CharT  __delim;
+    _CharT  __escape;
+
+    __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
+    : __first(__f), __last(__l), __delim(__d), __escape(__e) {}
+    //  This would be a nice place for a string_ref 
+};
+
+template <class _CharT, class _Traits, class _Iter>
+basic_ostream<_CharT, _Traits>& operator<<(
+         basic_ostream<_CharT, _Traits>& __os, 
+         const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy)
+{
+    return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+struct __quoted_proxy
+{
+    basic_string<_CharT, _Traits, _Allocator> &__string;
+    _CharT  __delim;
+    _CharT  __escape;
+
+    __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e)
+    : __string(__s), __delim(__d), __escape(__e) {}
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>& operator<<(
+        basic_ostream<_CharT, _Traits>& __os, 
+        const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
+{
+    return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape);
+}
+
+//  extractor for non-const basic_string& proxies
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>& operator>>(
+        basic_istream<_CharT, _Traits>& __is, 
+        const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
+{
+    return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape );
+}
+
+
+template <class _CharT>
+_LIBCPP_INLINE_VISIBILITY
+__quoted_output_proxy<_CharT, const _CharT *>
+quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\'))
+{
+    const _CharT *__end = __s;
+    while ( *__end ) ++__end;
+    return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+_LIBCPP_INLINE_VISIBILITY
+__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
+quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+    return __quoted_output_proxy<_CharT, 
+            typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> 
+                    ( __s.cbegin(), __s.cend (), __delim, __escape );
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+__quoted_proxy<_CharT, _Traits, _Allocator>
+quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
+{
+    return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_IOMANIP
diff --git a/final/include/ios b/final/include/ios
new file mode 100644
index 0000000..d95f18a
--- /dev/null
+++ b/final/include/ios
@@ -0,0 +1,1023 @@
+// -*- C++ -*-
+//===---------------------------- ios -------------------------------------===//
+//
+//                     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_IOS
+#define _LIBCPP_IOS
+
+/*
+    ios synopsis
+
+#include <iosfwd>
+
+namespace std
+{
+
+typedef OFF_T streamoff;
+typedef SZ_T streamsize;
+template <class stateT> class fpos;
+
+class ios_base
+{
+public:
+    class failure;
+
+    typedef T1 fmtflags;
+    static constexpr fmtflags boolalpha;
+    static constexpr fmtflags dec;
+    static constexpr fmtflags fixed;
+    static constexpr fmtflags hex;
+    static constexpr fmtflags internal;
+    static constexpr fmtflags left;
+    static constexpr fmtflags oct;
+    static constexpr fmtflags right;
+    static constexpr fmtflags scientific;
+    static constexpr fmtflags showbase;
+    static constexpr fmtflags showpoint;
+    static constexpr fmtflags showpos;
+    static constexpr fmtflags skipws;
+    static constexpr fmtflags unitbuf;
+    static constexpr fmtflags uppercase;
+    static constexpr fmtflags adjustfield;
+    static constexpr fmtflags basefield;
+    static constexpr fmtflags floatfield;
+
+    typedef T2 iostate;
+    static constexpr iostate badbit;
+    static constexpr iostate eofbit;
+    static constexpr iostate failbit;
+    static constexpr iostate goodbit;
+
+    typedef T3 openmode;
+    static constexpr openmode app;
+    static constexpr openmode ate;
+    static constexpr openmode binary;
+    static constexpr openmode in;
+    static constexpr openmode out;
+    static constexpr openmode trunc;
+
+    typedef T4 seekdir;
+    static constexpr seekdir beg;
+    static constexpr seekdir cur;
+    static constexpr seekdir end;
+
+    class Init;
+
+    // 27.5.2.2 fmtflags state:
+    fmtflags flags() const;
+    fmtflags flags(fmtflags fmtfl);
+    fmtflags setf(fmtflags fmtfl);
+    fmtflags setf(fmtflags fmtfl, fmtflags mask);
+    void unsetf(fmtflags mask);
+
+    streamsize precision() const;
+    streamsize precision(streamsize prec);
+    streamsize width() const;
+    streamsize width(streamsize wide);
+
+    // 27.5.2.3 locales:
+    locale imbue(const locale& loc);
+    locale getloc() const;
+
+    // 27.5.2.5 storage:
+    static int xalloc();
+    long& iword(int index);
+    void*& pword(int index);
+
+    // destructor
+    virtual ~ios_base();
+
+    // 27.5.2.6 callbacks;
+    enum event { erase_event, imbue_event, copyfmt_event };
+    typedef void (*event_callback)(event, ios_base&, int index);
+    void register_callback(event_callback fn, int index);
+
+    ios_base(const ios_base&) = delete;
+    ios_base& operator=(const ios_base&) = delete;
+
+    static bool sync_with_stdio(bool sync = true);
+
+protected:
+    ios_base();
+};
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ios
+    : public ios_base
+{
+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 traits traits_type;
+
+    operator unspecified-bool-type() const;
+    bool operator!() const;
+    iostate rdstate() const;
+    void clear(iostate state = goodbit);
+    void setstate(iostate state);
+    bool good() const;
+    bool eof() const;
+    bool fail() const;
+    bool bad() const;
+
+    iostate exceptions() const;
+    void exceptions(iostate except);
+
+    // 27.5.4.1 Constructor/destructor:
+    explicit basic_ios(basic_streambuf<charT,traits>* sb);
+    virtual ~basic_ios();
+
+    // 27.5.4.2 Members:
+    basic_ostream<charT,traits>* tie() const;
+    basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
+
+    basic_streambuf<charT,traits>* rdbuf() const;
+    basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
+
+    basic_ios& copyfmt(const basic_ios& rhs);
+
+    char_type fill() const;
+    char_type fill(char_type ch);
+
+    locale imbue(const locale& loc);
+
+    char narrow(char_type c, char dfault) const;
+    char_type widen(char c) const;
+
+    basic_ios(const basic_ios& ) = delete;
+    basic_ios& operator=(const basic_ios&) = delete;
+
+protected:
+    basic_ios();
+    void init(basic_streambuf<charT,traits>* sb);
+    void move(basic_ios& rhs);
+    void swap(basic_ios& rhs) noexcept;
+    void set_rdbuf(basic_streambuf<charT, traits>* sb);
+};
+
+// 27.5.5, manipulators:
+ios_base& boolalpha (ios_base& str);
+ios_base& noboolalpha(ios_base& str);
+ios_base& showbase (ios_base& str);
+ios_base& noshowbase (ios_base& str);
+ios_base& showpoint (ios_base& str);
+ios_base& noshowpoint(ios_base& str);
+ios_base& showpos (ios_base& str);
+ios_base& noshowpos (ios_base& str);
+ios_base& skipws (ios_base& str);
+ios_base& noskipws (ios_base& str);
+ios_base& uppercase (ios_base& str);
+ios_base& nouppercase(ios_base& str);
+ios_base& unitbuf (ios_base& str);
+ios_base& nounitbuf (ios_base& str);
+
+// 27.5.5.2 adjustfield:
+ios_base& internal (ios_base& str);
+ios_base& left (ios_base& str);
+ios_base& right (ios_base& str);
+
+// 27.5.5.3 basefield:
+ios_base& dec (ios_base& str);
+ios_base& hex (ios_base& str);
+ios_base& oct (ios_base& str);
+
+// 27.5.5.4 floatfield:
+ios_base& fixed (ios_base& str);
+ios_base& scientific (ios_base& str);
+ios_base& hexfloat (ios_base& str);
+ios_base& defaultfloat(ios_base& str);
+
+// 27.5.5.5 error reporting:
+enum class io_errc
+{
+    stream = 1
+};
+
+concept_map ErrorCodeEnum<io_errc> { };
+error_code make_error_code(io_errc e) noexcept; 
+error_condition make_error_condition(io_errc e) noexcept; 
+storage-class-specifier const error_category& iostream_category() noexcept;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <iosfwd>
+#include <__locale>
+#include <system_error>
+
+#if __has_feature(cxx_atomic)
+#include <atomic>     // for __xindex_
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+typedef ptrdiff_t streamsize;
+
+class _LIBCPP_TYPE_VIS ios_base
+{
+public:
+    class _LIBCPP_TYPE_VIS failure;
+
+    typedef unsigned int fmtflags;
+    static const fmtflags boolalpha   = 0x0001;
+    static const fmtflags dec         = 0x0002;
+    static const fmtflags fixed       = 0x0004;
+    static const fmtflags hex         = 0x0008;
+    static const fmtflags internal    = 0x0010;
+    static const fmtflags left        = 0x0020;
+    static const fmtflags oct         = 0x0040;
+    static const fmtflags right       = 0x0080;
+    static const fmtflags scientific  = 0x0100;
+    static const fmtflags showbase    = 0x0200;
+    static const fmtflags showpoint   = 0x0400;
+    static const fmtflags showpos     = 0x0800;
+    static const fmtflags skipws      = 0x1000;
+    static const fmtflags unitbuf     = 0x2000;
+    static const fmtflags uppercase   = 0x4000;
+    static const fmtflags adjustfield = left | right | internal;
+    static const fmtflags basefield   = dec | oct | hex;
+    static const fmtflags floatfield  = scientific | fixed;
+
+    typedef unsigned int iostate;
+    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;
+    static const openmode in     = 0x08;
+    static const openmode out    = 0x10;
+    static const openmode trunc  = 0x20;
+
+    enum seekdir {beg, cur, end};
+    typedef seekdir seek_dir;
+
+    typedef _VSTD::streamoff streamoff;
+    typedef _VSTD::streampos streampos;
+
+    class _LIBCPP_TYPE_VIS Init;
+
+    // 27.5.2.2 fmtflags state:
+    _LIBCPP_INLINE_VISIBILITY fmtflags flags() const;
+    _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl);
+    _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl);
+    _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
+    _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask);
+
+    _LIBCPP_INLINE_VISIBILITY streamsize precision() const;
+    _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec);
+    _LIBCPP_INLINE_VISIBILITY streamsize width() const;
+    _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide);
+
+    // 27.5.2.3 locales:
+    locale imbue(const locale& __loc);
+    locale getloc() const;
+
+    // 27.5.2.5 storage:
+    static int xalloc();
+    long& iword(int __index);
+    void*& pword(int __index);
+
+    // destructor
+    virtual ~ios_base();
+
+    // 27.5.2.6 callbacks;
+    enum event { erase_event, imbue_event, copyfmt_event };
+    typedef void (*event_callback)(event, ios_base&, int __index);
+    void register_callback(event_callback __fn, int __index);
+
+private:
+    ios_base(const ios_base&); // = delete;
+    ios_base& operator=(const ios_base&); // = delete;
+
+public:
+    static bool sync_with_stdio(bool __sync = true);
+
+    _LIBCPP_INLINE_VISIBILITY iostate rdstate() const;
+    void clear(iostate __state = goodbit);
+    _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state);
+
+    _LIBCPP_INLINE_VISIBILITY bool good() const;
+    _LIBCPP_INLINE_VISIBILITY bool eof() const;
+    _LIBCPP_INLINE_VISIBILITY bool fail() const;
+    _LIBCPP_INLINE_VISIBILITY bool bad() const;
+
+    _LIBCPP_INLINE_VISIBILITY iostate exceptions() const;
+    _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate);
+
+    void __set_badbit_and_consider_rethrow();
+    void __set_failbit_and_consider_rethrow();
+
+protected:
+    _LIBCPP_INLINE_VISIBILITY
+    ios_base() {// purposefully does no initialization
+               }
+
+    void init(void* __sb);
+    _LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;}
+
+    _LIBCPP_ALWAYS_INLINE
+    void rdbuf(void* __sb)
+    {
+        __rdbuf_ = __sb;
+        clear();
+    }
+
+    void __call_callbacks(event);
+    void copyfmt(const ios_base&);
+    void move(ios_base&);
+    void swap(ios_base&) _NOEXCEPT;
+
+    _LIBCPP_ALWAYS_INLINE
+    void set_rdbuf(void* __sb)
+    {
+        __rdbuf_ = __sb;
+    }
+
+private:
+    // All data members must be scalars
+    fmtflags        __fmtflags_;
+    streamsize      __precision_;
+    streamsize      __width_;
+    iostate         __rdstate_;
+    iostate         __exceptions_;
+    void*           __rdbuf_;
+    void*           __loc_;
+    event_callback* __fn_;
+    int*            __index_;
+    size_t          __event_size_;
+    size_t          __event_cap_;
+#if __has_feature(cxx_atomic)
+    static atomic<int> __xindex_;
+#else
+    static int      __xindex_;
+#endif
+    long*           __iarray_;
+    size_t          __iarray_size_;
+    size_t          __iarray_cap_;
+    void**          __parray_;
+    size_t          __parray_size_;
+    size_t          __parray_cap_;
+};
+
+//enum class io_errc
+_LIBCPP_DECLARE_STRONG_ENUM(io_errc)
+{
+    stream = 1
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc> : public true_type { };
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc::__lx> : public true_type { };
+#endif
+
+_LIBCPP_FUNC_VIS
+const error_category& iostream_category() _NOEXCEPT;
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_code
+make_error_code(io_errc __e) _NOEXCEPT
+{
+    return error_code(static_cast<int>(__e), iostream_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_condition
+make_error_condition(io_errc __e) _NOEXCEPT
+{
+    return error_condition(static_cast<int>(__e), iostream_category());
+}
+
+class _LIBCPP_EXCEPTION_ABI ios_base::failure
+    : public system_error
+{
+public:
+    explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
+    explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
+    virtual ~failure() throw();
+};
+
+class _LIBCPP_TYPE_VIS ios_base::Init
+{
+public:
+    Init();
+    ~Init();
+};
+
+// fmtflags
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::flags() const
+{
+    return __fmtflags_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::flags(fmtflags __fmtfl)
+{
+    fmtflags __r = __fmtflags_;
+    __fmtflags_ = __fmtfl;
+    return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::setf(fmtflags __fmtfl)
+{
+    fmtflags __r = __fmtflags_;
+    __fmtflags_ |= __fmtfl;
+    return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+ios_base::unsetf(fmtflags __mask)
+{
+    __fmtflags_ &= ~__mask;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::fmtflags
+ios_base::setf(fmtflags __fmtfl, fmtflags __mask)
+{
+    fmtflags __r = __fmtflags_;
+    unsetf(__mask);
+    __fmtflags_ |= __fmtfl & __mask;
+    return __r;
+}
+
+// precision
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::precision() const
+{
+    return __precision_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::precision(streamsize __prec)
+{
+    streamsize __r = __precision_;
+    __precision_ = __prec;
+    return __r;
+}
+
+// width
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::width() const
+{
+    return __width_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+ios_base::width(streamsize __wide)
+{
+    streamsize __r = __width_;
+    __width_ = __wide;
+    return __r;
+}
+
+// iostate
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::iostate
+ios_base::rdstate() const
+{
+    return __rdstate_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+ios_base::setstate(iostate __state)
+{
+    clear(__rdstate_ | __state);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::good() const
+{
+    return __rdstate_ == 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::eof() const
+{
+    return (__rdstate_ & eofbit) != 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::fail() const
+{
+    return (__rdstate_ & (failbit | badbit)) != 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+ios_base::bad() const
+{
+    return (__rdstate_ & badbit) != 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base::iostate
+ios_base::exceptions() const
+{
+    return __exceptions_;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void
+ios_base::exceptions(iostate __iostate)
+{
+    __exceptions_ = __iostate;
+    clear(__rdstate_);
+}
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_ios
+    : public ios_base
+{
+public:
+    // types:
+    typedef _CharT char_type;
+    typedef _Traits traits_type;
+
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    _LIBCPP_ALWAYS_INLINE
+        _LIBCPP_EXPLICIT
+        operator bool() const {return !fail();}
+    _LIBCPP_ALWAYS_INLINE bool operator!() const    {return  fail();}
+    _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return ios_base::rdstate();}
+    _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
+    _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);}
+    _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();}
+    _LIBCPP_ALWAYS_INLINE bool eof() const  {return ios_base::eof();}
+    _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();}
+    _LIBCPP_ALWAYS_INLINE bool bad() const  {return ios_base::bad();}
+
+    _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();}
+    _LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);}
+
+    // 27.5.4.1 Constructor/destructor:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
+    virtual ~basic_ios();
+
+    // 27.5.4.2 Members:
+    _LIBCPP_INLINE_VISIBILITY 
+    basic_ostream<char_type, traits_type>* tie() const;
+    _LIBCPP_INLINE_VISIBILITY 
+    basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
+
+    _LIBCPP_INLINE_VISIBILITY 
+    basic_streambuf<char_type, traits_type>* rdbuf() const;
+    _LIBCPP_INLINE_VISIBILITY 
+    basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
+
+    basic_ios& copyfmt(const basic_ios& __rhs);
+
+    _LIBCPP_INLINE_VISIBILITY 
+    char_type fill() const;
+    _LIBCPP_INLINE_VISIBILITY 
+    char_type fill(char_type __ch);
+
+    _LIBCPP_INLINE_VISIBILITY 
+    locale imbue(const locale& __loc);
+
+    _LIBCPP_INLINE_VISIBILITY 
+    char narrow(char_type __c, char __dfault) const;
+    _LIBCPP_INLINE_VISIBILITY 
+    char_type widen(char __c) const;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    basic_ios() {// purposefully does no initialization
+                }
+    _LIBCPP_INLINE_VISIBILITY 
+    void init(basic_streambuf<char_type, traits_type>* __sb);
+
+    _LIBCPP_INLINE_VISIBILITY 
+    void move(basic_ios& __rhs);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_ALWAYS_INLINE
+    void move(basic_ios&& __rhs) {move(__rhs);}
+#endif
+    _LIBCPP_INLINE_VISIBILITY 
+    void swap(basic_ios& __rhs) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY 
+    void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
+private:
+    basic_ostream<char_type, traits_type>* __tie_;
+     mutable int_type __fill_;
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb)
+{
+    init(__sb);
+}
+
+template <class _CharT, class _Traits>
+basic_ios<_CharT, _Traits>::~basic_ios()
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
+{
+    ios_base::init(__sb);
+    __tie_ = 0;
+    __fill_ = traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::tie() const
+{
+    return __tie_;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr)
+{
+    basic_ostream<char_type, traits_type>* __r = __tie_;
+    __tie_ = __tiestr;
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_streambuf<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::rdbuf() const
+{
+    return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_streambuf<_CharT, _Traits>*
+basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb)
+{
+    basic_streambuf<char_type, traits_type>* __r = rdbuf();
+    ios_base::rdbuf(__sb);
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+locale
+basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
+{
+    locale __r = getloc();
+    ios_base::imbue(__loc);
+    if (rdbuf())
+        rdbuf()->pubimbue(__loc);
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+char
+basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
+{
+    return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+basic_ios<_CharT, _Traits>::widen(char __c) const
+{
+    return use_facet<ctype<char_type> >(getloc()).widen(__c);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+basic_ios<_CharT, _Traits>::fill() const
+{
+    if (traits_type::eq_int_type(traits_type::eof(), __fill_))
+        __fill_ = widen(' ');
+    return __fill_;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT
+basic_ios<_CharT, _Traits>::fill(char_type __ch)
+{
+    char_type __r = __fill_;
+    __fill_ = __ch;
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+basic_ios<_CharT, _Traits>&
+basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
+{
+    if (this != &__rhs)
+    {
+        __call_callbacks(erase_event);
+        ios_base::copyfmt(__rhs);
+        __tie_ = __rhs.__tie_;
+        __fill_ = __rhs.__fill_;
+        __call_callbacks(copyfmt_event);
+        exceptions(__rhs.exceptions());
+    }
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
+{
+    ios_base::move(__rhs);
+    __tie_ = __rhs.__tie_;
+    __rhs.__tie_ = 0;
+    __fill_ = __rhs.__fill_;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT
+{
+    ios_base::swap(__rhs);
+    _VSTD::swap(__tie_, __rhs.__tie_);
+    _VSTD::swap(__fill_, __rhs.__fill_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb)
+{
+    ios_base::set_rdbuf(__sb);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+boolalpha(ios_base& __str)
+{
+    __str.setf(ios_base::boolalpha);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+noboolalpha(ios_base& __str)
+{
+    __str.unsetf(ios_base::boolalpha);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+showbase(ios_base& __str)
+{
+    __str.setf(ios_base::showbase);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+noshowbase(ios_base& __str)
+{
+    __str.unsetf(ios_base::showbase);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+showpoint(ios_base& __str)
+{
+    __str.setf(ios_base::showpoint);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+noshowpoint(ios_base& __str)
+{
+    __str.unsetf(ios_base::showpoint);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+showpos(ios_base& __str)
+{
+    __str.setf(ios_base::showpos);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+noshowpos(ios_base& __str)
+{
+    __str.unsetf(ios_base::showpos);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+skipws(ios_base& __str)
+{
+    __str.setf(ios_base::skipws);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+noskipws(ios_base& __str)
+{
+    __str.unsetf(ios_base::skipws);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+uppercase(ios_base& __str)
+{
+    __str.setf(ios_base::uppercase);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+nouppercase(ios_base& __str)
+{
+    __str.unsetf(ios_base::uppercase);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+unitbuf(ios_base& __str)
+{
+    __str.setf(ios_base::unitbuf);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+nounitbuf(ios_base& __str)
+{
+    __str.unsetf(ios_base::unitbuf);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+internal(ios_base& __str)
+{
+    __str.setf(ios_base::internal, ios_base::adjustfield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+left(ios_base& __str)
+{
+    __str.setf(ios_base::left, ios_base::adjustfield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+right(ios_base& __str)
+{
+    __str.setf(ios_base::right, ios_base::adjustfield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+dec(ios_base& __str)
+{
+    __str.setf(ios_base::dec, ios_base::basefield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+hex(ios_base& __str)
+{
+    __str.setf(ios_base::hex, ios_base::basefield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+oct(ios_base& __str)
+{
+    __str.setf(ios_base::oct, ios_base::basefield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+fixed(ios_base& __str)
+{
+    __str.setf(ios_base::fixed, ios_base::floatfield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+scientific(ios_base& __str)
+{
+    __str.setf(ios_base::scientific, ios_base::floatfield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+hexfloat(ios_base& __str)
+{
+    __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
+    return __str;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+ios_base&
+defaultfloat(ios_base& __str)
+{
+    __str.unsetf(ios_base::floatfield);
+    return __str;
+}
+
+template <class _CharT, class _Traits>
+class __save_flags
+{
+    typedef basic_ios<_CharT, _Traits> __stream_type;
+    typedef typename __stream_type::fmtflags fmtflags;
+
+    __stream_type& __stream_;
+    fmtflags       __fmtflags_;
+    _CharT         __fill_;
+
+    __save_flags(const __save_flags&);
+    __save_flags& operator=(const __save_flags&);
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __save_flags(__stream_type& __stream)
+        : __stream_(__stream),
+          __fmtflags_(__stream.flags()),
+          __fill_(__stream.fill())
+        {}
+    _LIBCPP_INLINE_VISIBILITY
+    ~__save_flags()
+    {
+        __stream_.flags(__fmtflags_);
+        __stream_.fill(__fill_);
+    }
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_IOS
diff --git a/final/include/iosfwd b/final/include/iosfwd
new file mode 100644
index 0000000..d24c227
--- /dev/null
+++ b/final/include/iosfwd
@@ -0,0 +1,194 @@
+// -*- C++ -*-
+//===--------------------------- iosfwd -----------------------------------===//
+//
+//                     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_IOSFWD
+#define _LIBCPP_IOSFWD
+
+/*
+    iosfwd synopsis
+
+namespace std
+{
+
+template<class charT> struct char_traits;
+template<class T>     class allocator;
+
+class ios_base;
+template <class charT, class traits = char_traits<charT> > class basic_ios;
+
+template <class charT, class traits = char_traits<charT> > class basic_streambuf;
+template <class charT, class traits = char_traits<charT> > class basic_istream;
+template <class charT, class traits = char_traits<charT> > class basic_ostream;
+template <class charT, class traits = char_traits<charT> > class basic_iostream;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+    class basic_stringbuf;
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+    class basic_istringstream;
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+    class basic_ostringstream;
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+    class basic_stringstream;
+
+template <class charT, class traits = char_traits<charT> > class basic_filebuf;
+template <class charT, class traits = char_traits<charT> > class basic_ifstream;
+template <class charT, class traits = char_traits<charT> > class basic_ofstream;
+template <class charT, class traits = char_traits<charT> > class basic_fstream;
+
+template <class charT, class traits = char_traits<charT> > class istreambuf_iterator;
+template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
+
+typedef basic_ios<char>              ios;
+typedef basic_ios<wchar_t>           wios;
+
+typedef basic_streambuf<char>        streambuf;
+typedef basic_istream<char>          istream;
+typedef basic_ostream<char>          ostream;
+typedef basic_iostream<char>         iostream;
+
+typedef basic_stringbuf<char>        stringbuf;
+typedef basic_istringstream<char>    istringstream;
+typedef basic_ostringstream<char>    ostringstream;
+typedef basic_stringstream<char>     stringstream;
+
+typedef basic_filebuf<char>          filebuf;
+typedef basic_ifstream<char>         ifstream;
+typedef basic_ofstream<char>         ofstream;
+typedef basic_fstream<char>          fstream;
+
+typedef basic_streambuf<wchar_t>     wstreambuf;
+typedef basic_istream<wchar_t>       wistream;
+typedef basic_ostream<wchar_t>       wostream;
+typedef basic_iostream<wchar_t>      wiostream;
+
+typedef basic_stringbuf<wchar_t>     wstringbuf;
+typedef basic_istringstream<wchar_t> wistringstream;
+typedef basic_ostringstream<wchar_t> wostringstream;
+typedef basic_stringstream<wchar_t>  wstringstream;
+
+typedef basic_filebuf<wchar_t>       wfilebuf;
+typedef basic_ifstream<wchar_t>      wifstream;
+typedef basic_ofstream<wchar_t>      wofstream;
+typedef basic_fstream<wchar_t>       wfstream;
+
+template <class state> class fpos;
+typedef fpos<char_traits<char>::state_type>    streampos;
+typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <wchar.h>  // for mbstate_t
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS ios_base;
+
+template<class _CharT>  struct _LIBCPP_TYPE_VIS_ONLY char_traits;
+template<class _Tp>     class _LIBCPP_TYPE_VIS_ONLY allocator;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_ios;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_streambuf;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_istream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_ostream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_iostream;
+
+template <class _CharT, class _Traits = char_traits<_CharT>,
+          class _Allocator = allocator<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf;
+template <class _CharT, class _Traits = char_traits<_CharT>,
+          class _Allocator = allocator<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_istringstream;
+template <class _CharT, class _Traits = char_traits<_CharT>,
+          class _Allocator = allocator<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream;
+template <class _CharT, class _Traits = char_traits<_CharT>,
+          class _Allocator = allocator<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_stringstream;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_filebuf;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_ifstream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_ofstream;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_fstream;
+
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator;
+template <class _CharT, class _Traits = char_traits<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator;
+
+typedef basic_ios<char>              ios;
+typedef basic_ios<wchar_t>           wios;
+
+typedef basic_streambuf<char>        streambuf;
+typedef basic_istream<char>          istream;
+typedef basic_ostream<char>          ostream;
+typedef basic_iostream<char>         iostream;
+
+typedef basic_stringbuf<char>        stringbuf;
+typedef basic_istringstream<char>    istringstream;
+typedef basic_ostringstream<char>    ostringstream;
+typedef basic_stringstream<char>     stringstream;
+
+typedef basic_filebuf<char>          filebuf;
+typedef basic_ifstream<char>         ifstream;
+typedef basic_ofstream<char>         ofstream;
+typedef basic_fstream<char>          fstream;
+
+typedef basic_streambuf<wchar_t>     wstreambuf;
+typedef basic_istream<wchar_t>       wistream;
+typedef basic_ostream<wchar_t>       wostream;
+typedef basic_iostream<wchar_t>      wiostream;
+
+typedef basic_stringbuf<wchar_t>     wstringbuf;
+typedef basic_istringstream<wchar_t> wistringstream;
+typedef basic_ostringstream<wchar_t> wostringstream;
+typedef basic_stringstream<wchar_t>  wstringstream;
+
+typedef basic_filebuf<wchar_t>       wfilebuf;
+typedef basic_ifstream<wchar_t>      wifstream;
+typedef basic_ofstream<wchar_t>      wofstream;
+typedef basic_fstream<wchar_t>       wfstream;
+
+template <class _State>             class _LIBCPP_TYPE_VIS_ONLY fpos;
+typedef fpos<mbstate_t>    streampos;
+typedef fpos<mbstate_t>    wstreampos;
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+typedef fpos<mbstate_t>    u16streampos;
+typedef fpos<mbstate_t>    u32streampos;
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef long long streamoff;        // for char_traits in <string>
+
+template <class _CharT,             // for <stdexcept>
+          class _Traits = char_traits<_CharT>,
+          class _Allocator = allocator<_CharT> >
+    class _LIBCPP_TYPE_VIS_ONLY basic_string;
+typedef basic_string<char, char_traits<char>, allocator<char> > string;
+typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_IOSFWD
diff --git a/final/include/iostream b/final/include/iostream
new file mode 100644
index 0000000..ddf2484
--- /dev/null
+++ b/final/include/iostream
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+//===--------------------------- iostream ---------------------------------===//
+//
+//                     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_IOSTREAM
+#define _LIBCPP_IOSTREAM
+
+/*
+    iostream synopsis
+
+#include <ios>
+#include <streambuf>
+#include <istream>
+#include <ostream>
+
+namespace std {
+
+extern istream cin;
+extern ostream cout;
+extern ostream cerr;
+extern ostream clog;
+extern wistream wcin;
+extern wostream wcout;
+extern wostream wcerr;
+extern wostream wclog;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <ios>
+#include <streambuf>
+#include <istream>
+#include <ostream>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+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;
+extern _LIBCPP_FUNC_VIS wostream wcout;
+extern _LIBCPP_FUNC_VIS wostream wcerr;
+extern _LIBCPP_FUNC_VIS wostream wclog;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_IOSTREAM
diff --git a/final/include/istream b/final/include/istream
new file mode 100644
index 0000000..14fa466
--- /dev/null
+++ b/final/include/istream
@@ -0,0 +1,1716 @@
+// -*- C++ -*-
+//===--------------------------- istream ----------------------------------===//
+//
+//                     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_ISTREAM
+#define _LIBCPP_ISTREAM
+
+/*
+    istream synopsis
+
+template <class charT, class traits = char_traits<charT> >
+class basic_istream
+    : virtual public basic_ios<charT,traits>
+{
+public:
+    // types (inherited from basic_ios (27.5.4)):
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // 27.7.1.1.1 Constructor/destructor:
+    explicit basic_istream(basic_streambuf<char_type, traits_type>* sb);
+    basic_istream(basic_istream&& rhs);
+    virtual ~basic_istream();
+
+    // 27.7.1.1.2 Assign/swap:
+    basic_istream& operator=(basic_istream&& rhs);
+    void swap(basic_istream& rhs);
+
+    // 27.7.1.1.3 Prefix/suffix:
+    class sentry;
+
+    // 27.7.1.2 Formatted input:
+    basic_istream& operator>>(basic_istream& (*pf)(basic_istream&));
+    basic_istream& operator>>(basic_ios<char_type, traits_type>&
+                              (*pf)(basic_ios<char_type, traits_type>&));
+    basic_istream& operator>>(ios_base& (*pf)(ios_base&));
+    basic_istream& operator>>(basic_streambuf<char_type, traits_type>* sb);
+    basic_istream& operator>>(bool& n);
+    basic_istream& operator>>(short& n);
+    basic_istream& operator>>(unsigned short& n);
+    basic_istream& operator>>(int& n);
+    basic_istream& operator>>(unsigned int& n);
+    basic_istream& operator>>(long& n);
+    basic_istream& operator>>(unsigned long& n);
+    basic_istream& operator>>(long long& n);
+    basic_istream& operator>>(unsigned long long& n);
+    basic_istream& operator>>(float& f);
+    basic_istream& operator>>(double& f);
+    basic_istream& operator>>(long double& f);
+    basic_istream& operator>>(void*& p);
+
+    // 27.7.1.3 Unformatted input:
+    streamsize gcount() const;
+    int_type get();
+    basic_istream& get(char_type& c);
+    basic_istream& get(char_type* s, streamsize n);
+    basic_istream& get(char_type* s, streamsize n, char_type delim);
+    basic_istream& get(basic_streambuf<char_type,traits_type>& sb);
+    basic_istream& get(basic_streambuf<char_type,traits_type>& sb, char_type delim);
+
+    basic_istream& getline(char_type* s, streamsize n);
+    basic_istream& getline(char_type* s, streamsize n, char_type delim);
+
+    basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof());
+    int_type peek();
+    basic_istream& read (char_type* s, streamsize n);
+    streamsize readsome(char_type* s, streamsize n);
+
+    basic_istream& putback(char_type c);
+    basic_istream& unget();
+    int sync();
+
+    pos_type tellg();
+    basic_istream& seekg(pos_type);
+    basic_istream& seekg(off_type, ios_base::seekdir);
+};
+
+// 27.7.1.2.3 character extraction templates:
+template<class charT, class traits>
+  basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT&);
+
+template<class traits>
+  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char&);
+
+template<class traits>
+  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char&);
+
+template<class charT, class traits>
+  basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&, charT*);
+
+template<class traits>
+  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, unsigned char*);
+
+template<class traits>
+  basic_istream<char,traits>& operator>>(basic_istream<char,traits>&, signed char*);
+
+template <class charT, class traits>
+  void
+  swap(basic_istream<charT, traits>& x, basic_istream<charT, traits>& y);
+
+typedef basic_istream<char> istream;
+typedef basic_istream<wchar_t> wistream;
+
+template <class charT, class traits = char_traits<charT> >
+class basic_iostream :
+    public basic_istream<charT,traits>,
+    public basic_ostream<charT,traits>
+{
+public:
+    // types:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // constructor/destructor
+    explicit basic_iostream(basic_streambuf<char_type, traits_type>* sb);
+    basic_iostream(basic_iostream&& rhs);
+    virtual ~basic_iostream();
+
+    // assign/swap
+    basic_iostream& operator=(basic_iostream&& rhs);
+    void swap(basic_iostream& rhs);
+};
+
+template <class charT, class traits>
+  void
+  swap(basic_iostream<charT, traits>& x, basic_iostream<charT, traits>& y);
+
+typedef basic_iostream<char> iostream;
+typedef basic_iostream<wchar_t> wiostream;
+
+template <class charT, class traits>
+  basic_istream<charT,traits>&
+  ws(basic_istream<charT,traits>& is);
+
+template <class charT, class traits, class T>
+  basic_istream<charT, traits>&
+  operator>>(basic_istream<charT, traits>&& is, T& x);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <ostream>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_istream
+    : virtual public basic_ios<_CharT, _Traits>
+{
+    streamsize __gc_;
+public:
+    // types (inherited from basic_ios (27.5.4)):
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // 27.7.1.1.1 Constructor/destructor:
+    explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb);
+    virtual ~basic_istream();
+protected:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_istream(basic_istream&& __rhs);
+#endif
+
+    // 27.7.1.1.2 Assign/swap:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_istream& operator=(basic_istream&& __rhs);
+#endif
+    void swap(basic_istream& __rhs);
+public:
+
+    // 27.7.1.1.3 Prefix/suffix:
+    class _LIBCPP_TYPE_VIS_ONLY sentry;
+
+    // 27.7.1.2 Formatted input:
+    basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&));
+    basic_istream& operator>>(basic_ios<char_type, traits_type>&
+                              (*__pf)(basic_ios<char_type, traits_type>&));
+    basic_istream& operator>>(ios_base& (*__pf)(ios_base&));
+    basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb);
+    basic_istream& operator>>(bool& __n);
+    basic_istream& operator>>(short& __n);
+    basic_istream& operator>>(unsigned short& __n);
+    basic_istream& operator>>(int& __n);
+    basic_istream& operator>>(unsigned int& __n);
+    basic_istream& operator>>(long& __n);
+    basic_istream& operator>>(unsigned long& __n);
+    basic_istream& operator>>(long long& __n);
+    basic_istream& operator>>(unsigned long long& __n);
+    basic_istream& operator>>(float& __f);
+    basic_istream& operator>>(double& __f);
+    basic_istream& operator>>(long double& __f);
+    basic_istream& operator>>(void*& __p);
+
+    // 27.7.1.3 Unformatted input:
+    _LIBCPP_INLINE_VISIBILITY
+    streamsize gcount() const {return __gc_;}
+    int_type get();
+    basic_istream& get(char_type& __c);
+    basic_istream& get(char_type* __s, streamsize __n);
+    basic_istream& get(char_type* __s, streamsize __n, char_type __dlm);
+    basic_istream& get(basic_streambuf<char_type, traits_type>& __sb);
+    basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm);
+
+    basic_istream& getline(char_type* __s, streamsize __n);
+    basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm);
+
+    basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
+    int_type peek();
+    basic_istream& read (char_type* __s, streamsize __n);
+    streamsize readsome(char_type* __s, streamsize __n);
+
+    basic_istream& putback(char_type __c);
+    basic_istream& unget();
+    int sync();
+
+    pos_type tellg();
+    basic_istream& seekg(pos_type __pos);
+    basic_istream& seekg(off_type __off, ios_base::seekdir __dir);
+};
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry
+{
+    bool __ok_;
+
+    sentry(const sentry&); // = delete;
+    sentry& operator=(const sentry&); // = delete;
+
+public:
+    explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
+//    ~sentry() = default;
+
+    _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_EXPLICIT
+        operator bool() const {return __ok_;}
+};
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is,
+                                               bool __noskipws)
+    : __ok_(false)
+{
+    if (__is.good())
+    {
+        if (__is.tie())
+            __is.tie()->flush();
+        if (!__noskipws && (__is.flags() & ios_base::skipws))
+        {
+            typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+            _Ip __i(__is);
+            _Ip __eof;
+            for (; __i != __eof; ++__i)
+                if (!__ct.is(__ct.space, *__i))
+                    break;
+            if (__i == __eof)
+                __is.setstate(ios_base::failbit | ios_base::eofbit);
+        }
+        __ok_ = __is.good();
+    }
+    else
+        __is.setstate(ios_base::failbit);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb)
+    : __gc_(0)
+{
+    this->init(__sb);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
+    : __gc_(__rhs.__gc_)
+{
+    __rhs.__gc_ = 0;
+    this->move(__rhs);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
+{
+    swap(__rhs);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>::~basic_istream()
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
+{
+    _VSTD::swap(__gc_, __rhs.__gc_);
+    basic_ios<char_type, traits_type>::swap(__rhs);
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(long& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(long long& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(float& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(double& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(long double& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(bool& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(void*& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(short& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            long __temp;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp);
+            if (__temp < numeric_limits<short>::min())
+            {
+                __err |= ios_base::failbit;
+                __n = numeric_limits<short>::min();
+            }
+            else if (__temp > numeric_limits<short>::max())
+            {
+                __err |= ios_base::failbit;
+                __n = numeric_limits<short>::max();
+            }
+            else
+                __n = static_cast<short>(__temp);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(int& __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef istreambuf_iterator<char_type, traits_type> _Ip;
+            typedef num_get<char_type, _Ip> _Fp;
+            ios_base::iostate __err = ios_base::goodbit;
+            long __temp;
+            use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp);
+            if (__temp < numeric_limits<int>::min())
+            {
+                __err |= ios_base::failbit;
+                __n = numeric_limits<int>::min();
+            }
+            else if (__temp > numeric_limits<int>::max())
+            {
+                __err |= ios_base::failbit;
+                __n = numeric_limits<int>::max();
+            }
+            else
+                __n = static_cast<int>(__temp);
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&))
+{
+    return __pf(*this);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>&
+                                           (*__pf)(basic_ios<char_type, traits_type>&))
+{
+    __pf(*this);
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
+{
+    __pf(*this);
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+        if (__sen)
+        {
+            streamsize __n = __is.width();
+            if (__n <= 0)
+                __n = numeric_limits<streamsize>::max() / sizeof(_CharT) - 1;
+            streamsize __c = 0;
+            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+            ios_base::iostate __err = ios_base::goodbit;
+            while (__c < __n-1)
+            {
+                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+                if (_Traits::eq_int_type(__i, _Traits::eof()))
+                {
+                   __err |= ios_base::eofbit;
+                   break;
+                }
+                _CharT __ch = _Traits::to_char_type(__i);
+                if (__ct.is(__ct.space, __ch))
+                    break;
+                *__s++ = __ch;
+                ++__c;
+                 __is.rdbuf()->sbumpc();
+            }
+            *__s = _CharT();
+            __is.width(0);
+            if (__c == 0)
+               __err |= ios_base::failbit;
+            __is.setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, unsigned char* __s)
+{
+    return __is >> (char*)__s;
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, signed char* __s)
+{
+    return __is >> (char*)__s;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+        if (__sen)
+        {
+            typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
+            if (_Traits::eq_int_type(__i, _Traits::eof()))
+                __is.setstate(ios_base::eofbit | ios_base::failbit);
+            else
+                __c = _Traits::to_char_type(__i);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, unsigned char& __c)
+{
+    return __is >> (char&)__c;
+}
+
+template<class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<char, _Traits>&
+operator>>(basic_istream<char, _Traits>& __is, signed char& __c)
+{
+    return __is >> (char&)__c;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb)
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this, true);
+        if (__s)
+        {
+            if (__sb)
+            {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                try
+                {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                    ios_base::iostate __err = ios_base::goodbit;
+                    while (true)
+                    {
+                        typename traits_type::int_type __i = this->rdbuf()->sgetc();
+                        if (traits_type::eq_int_type(__i, _Traits::eof()))
+                        {
+                           __err |= ios_base::eofbit;
+                           break;
+                        }
+                        if (traits_type::eq_int_type(
+                                __sb->sputc(traits_type::to_char_type(__i)),
+                                traits_type::eof()))
+                            break;
+                        ++__gc_;
+                        this->rdbuf()->sbumpc();
+                    }
+                    if (__gc_ == 0)
+                       __err |= ios_base::failbit;
+                    this->setstate(__err);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                }
+                catch (...)
+                {
+                    if (__gc_ == 0)
+                        this->__set_failbit_and_consider_rethrow();
+                }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            }
+            else
+                this->setstate(ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+typename basic_istream<_CharT, _Traits>::int_type
+basic_istream<_CharT, _Traits>::get()
+{
+    __gc_ = 0;
+    int_type __r = traits_type::eof();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this, true);
+        if (__s)
+        {
+            __r = this->rdbuf()->sbumpc();
+            if (traits_type::eq_int_type(__r, traits_type::eof()))
+               this->setstate(ios_base::failbit | ios_base::eofbit);
+            else
+                __gc_ = 1;
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __r;
+}
+
+template<class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::get(char_type& __c)
+{
+    int_type __ch = get();
+    if (__ch != traits_type::eof())
+        __c = traits_type::to_char_type(__ch);
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm)
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            if (__n > 0)
+            {
+                ios_base::iostate __err = ios_base::goodbit;
+                while (__gc_ < __n-1)
+                {
+                    int_type __i = this->rdbuf()->sgetc();
+                    if (traits_type::eq_int_type(__i, traits_type::eof()))
+                    {
+                       __err |= ios_base::eofbit;
+                       break;
+                    }
+                    char_type __ch = traits_type::to_char_type(__i);
+                    if (traits_type::eq(__ch, __dlm))
+                        break;
+                    *__s++ = __ch;
+                    ++__gc_;
+                     this->rdbuf()->sbumpc();
+                }
+                *__s = char_type();
+                if (__gc_ == 0)
+                   __err |= ios_base::failbit;
+                this->setstate(__err);
+            }
+            else
+                this->setstate(ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n)
+{
+    return get(__s, __n, this->widen('\n'));
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
+                                    char_type __dlm)
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            ios_base::iostate __err = ios_base::goodbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            try
+            {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                while (true)
+                {
+                    typename traits_type::int_type __i = this->rdbuf()->sgetc();
+                    if (traits_type::eq_int_type(__i, traits_type::eof()))
+                    {
+                       __err |= ios_base::eofbit;
+                       break;
+                    }
+                    char_type __ch = traits_type::to_char_type(__i);
+                    if (traits_type::eq(__ch, __dlm))
+                        break;
+                    if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
+                        break;
+                    ++__gc_;
+                    this->rdbuf()->sbumpc();
+                }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            }
+            catch (...)
+            {
+            }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            if (__gc_ == 0)
+               __err |= ios_base::failbit;
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb)
+{
+    return get(__sb, this->widen('\n'));
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            ios_base::iostate __err = ios_base::goodbit;
+            while (true)
+            {
+                typename traits_type::int_type __i = this->rdbuf()->sgetc();
+                if (traits_type::eq_int_type(__i, traits_type::eof()))
+                {
+                   __err |= ios_base::eofbit;
+                   break;
+                }
+                char_type __ch = traits_type::to_char_type(__i);
+                if (traits_type::eq(__ch, __dlm))
+                {
+                    this->rdbuf()->sbumpc();
+                    ++__gc_;
+                    break;
+                }
+                if (__gc_ >= __n-1)
+                {
+                    __err |= ios_base::failbit;
+                    break;
+                }
+                *__s++ = __ch;
+                this->rdbuf()->sbumpc();
+                ++__gc_;
+            }
+            if (__n > 0)
+                *__s = char_type();
+            if (__gc_ == 0)
+               __err |= ios_base::failbit;
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n)
+{
+    return getline(__s, __n, this->widen('\n'));
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            ios_base::iostate __err = ios_base::goodbit;
+            if (__n == numeric_limits<streamsize>::max())
+            {
+                while (true)
+                {
+                    typename traits_type::int_type __i = this->rdbuf()->sbumpc();
+                    if (traits_type::eq_int_type(__i, traits_type::eof()))
+                    {
+                       __err |= ios_base::eofbit;
+                       break;
+                    }
+                    ++__gc_;
+                    if (traits_type::eq_int_type(__i, __dlm))
+                        break;
+                }
+            }
+            else
+            {
+                while (__gc_ < __n)
+                {
+                    typename traits_type::int_type __i = this->rdbuf()->sbumpc();
+                    if (traits_type::eq_int_type(__i, traits_type::eof()))
+                    {
+                       __err |= ios_base::eofbit;
+                       break;
+                    }
+                    ++__gc_;
+                    if (traits_type::eq_int_type(__i, __dlm))
+                        break;
+                }
+            }
+            this->setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+typename basic_istream<_CharT, _Traits>::int_type
+basic_istream<_CharT, _Traits>::peek()
+{
+    __gc_ = 0;
+    int_type __r = traits_type::eof();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            __r = this->rdbuf()->sgetc();
+            if (traits_type::eq_int_type(__r, traits_type::eof()))
+                this->setstate(ios_base::eofbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __r;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            __gc_ = this->rdbuf()->sgetn(__s, __n);
+            if (__gc_ != __n)
+                this->setstate(ios_base::failbit | ios_base::eofbit);
+        }
+        else
+            this->setstate(ios_base::failbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+streamsize
+basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
+{
+    __gc_ = 0;
+    streamsize __c = this->rdbuf()->in_avail();
+    switch (__c)
+    {
+    case -1:
+        this->setstate(ios_base::eofbit);
+        break;
+    case 0:
+        break;
+    default:
+        read(__s, _VSTD::min(__c, __n));
+        break;
+    }
+    return __gc_;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::putback(char_type __c)
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        this->clear(this->rdstate() & ~ios_base::eofbit);
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())
+                this->setstate(ios_base::badbit);
+        }
+        else
+            this->setstate(ios_base::failbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::unget()
+{
+    __gc_ = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        this->clear(this->rdstate() & ~ios_base::eofbit);
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())
+                this->setstate(ios_base::badbit);
+        }
+        else
+            this->setstate(ios_base::failbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+int
+basic_istream<_CharT, _Traits>::sync()
+{
+    int __r = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            if (this->rdbuf() == 0)
+                return -1;
+            if (this->rdbuf()->pubsync() == -1)
+            {
+                this->setstate(ios_base::badbit);
+                return -1;
+            }
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __r;
+}
+
+template<class _CharT, class _Traits>
+typename basic_istream<_CharT, _Traits>::pos_type
+basic_istream<_CharT, _Traits>::tellg()
+{
+    pos_type __r(-1);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+            __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __r;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        this->clear(this->rdstate() & ~ios_base::eofbit);
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
+                this->setstate(ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this, true);
+        if (__sen)
+        {
+            if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
+                this->setstate(ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+ws(basic_istream<_CharT, _Traits>& __is)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
+        if (__sen)
+        {
+            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+            while (true)
+            {
+                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+                if (_Traits::eq_int_type(__i, _Traits::eof()))
+                {
+                   __is.setstate(ios_base::eofbit);
+                   break;
+                }
+                if (!__ct.is(__ct.space, _Traits::to_char_type(__i)))
+                    break;
+                __is.rdbuf()->sbumpc();
+            }
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
+{
+    __is >> __x;
+    return __is;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_iostream
+    : public basic_istream<_CharT, _Traits>,
+      public basic_ostream<_CharT, _Traits>
+{
+public:
+    // types:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // constructor/destructor
+    explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb);
+    virtual ~basic_iostream();
+protected:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_iostream(basic_iostream&& __rhs);
+#endif
+
+    // assign/swap
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_iostream& operator=(basic_iostream&& __rhs);
+#endif
+    void swap(basic_iostream& __rhs);
+public:
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
+    : basic_istream<_CharT, _Traits>(__sb)
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
+    : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_iostream<_CharT, _Traits>&
+basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
+{
+    swap(__rhs);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+basic_iostream<_CharT, _Traits>::~basic_iostream()
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs)
+{
+    basic_istream<char_type, traits_type>::swap(__rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+        if (__sen)
+        {
+            __str.clear();
+            streamsize __n = __is.width();
+            if (__n <= 0)
+                __n = __str.max_size();
+            if (__n <= 0)
+                __n = numeric_limits<streamsize>::max();
+            streamsize __c = 0;
+            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+            ios_base::iostate __err = ios_base::goodbit;
+            while (__c < __n)
+            {
+                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+                if (_Traits::eq_int_type(__i, _Traits::eof()))
+                {
+                   __err |= ios_base::eofbit;
+                   break;
+                }
+                _CharT __ch = _Traits::to_char_type(__i);
+                if (__ct.is(__ct.space, __ch))
+                    break;
+                __str.push_back(__ch);
+                ++__c;
+                 __is.rdbuf()->sbumpc();
+            }
+            __is.width(0);
+            if (__c == 0)
+               __err |= ios_base::failbit;
+            __is.setstate(__err);
+        }
+        else
+            __is.setstate(ios_base::failbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
+        if (__sen)
+        {
+            __str.clear();
+            ios_base::iostate __err = ios_base::goodbit;
+            streamsize __extr = 0;
+            while (true)
+            {
+                typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
+                if (_Traits::eq_int_type(__i, _Traits::eof()))
+                {
+                   __err |= ios_base::eofbit;
+                   break;
+                }
+                ++__extr;
+                _CharT __ch = _Traits::to_char_type(__i);
+                if (_Traits::eq(__ch, __dlm))
+                    break;
+                __str.push_back(__ch);
+                if (__str.size() == __str.max_size())
+                {
+                    __err |= ios_base::failbit;
+                    break;
+                }
+            }
+            if (__extr == 0)
+               __err |= ios_base::failbit;
+            __is.setstate(__err);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+    return getline(__is, __str, __is.widen('\n'));
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
+{
+    return getline(__is, __str, __dlm);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+    return getline(__is, __str, __is.widen('\n'));
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+        if (__sen)
+        {
+            basic_string<_CharT, _Traits> __str;
+            const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
+            streamsize __c = 0;
+            ios_base::iostate __err = ios_base::goodbit;
+            _CharT __zero = __ct.widen('0');
+            _CharT __one = __ct.widen('1');
+            while (__c < _Size)
+            {
+                typename _Traits::int_type __i = __is.rdbuf()->sgetc();
+                if (_Traits::eq_int_type(__i, _Traits::eof()))
+                {
+                   __err |= ios_base::eofbit;
+                   break;
+                }
+                _CharT __ch = _Traits::to_char_type(__i);
+                if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one))
+                    break;
+                __str.push_back(__ch);
+                ++__c;
+                 __is.rdbuf()->sbumpc();
+            }
+            __x = bitset<_Size>(__str);
+            if (__c == 0)
+               __err |= ios_base::failbit;
+            __is.setstate(__err);
+        }
+        else
+            __is.setstate(ios_base::failbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __is.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __is;
+}
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream<char>)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_ISTREAM
diff --git a/final/include/iterator b/final/include/iterator
new file mode 100644
index 0000000..f338e01
--- /dev/null
+++ b/final/include/iterator
@@ -0,0 +1,1577 @@
+// -*- C++ -*-
+//===-------------------------- iterator ----------------------------------===//
+//
+//                     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_ITERATOR
+#define _LIBCPP_ITERATOR
+
+/*
+    iterator synopsis
+
+namespace std
+{
+
+template<class Iterator>
+struct iterator_traits
+{
+    typedef typename Iterator::difference_type difference_type;
+    typedef typename Iterator::value_type value_type;
+    typedef typename Iterator::pointer pointer;
+    typedef typename Iterator::reference reference;
+    typedef typename Iterator::iterator_category iterator_category;
+};
+
+template<class T>
+struct iterator_traits<T*>
+{
+    typedef ptrdiff_t difference_type;
+    typedef T value_type;
+    typedef T* pointer;
+    typedef T& reference;
+    typedef random_access_iterator_tag iterator_category;
+};
+
+template<class T>
+struct iterator_traits<const T*>
+{
+    typedef ptrdiff_t difference_type;
+    typedef T value_type;
+    typedef const T* pointer;
+    typedef const T& reference;
+    typedef random_access_iterator_tag iterator_category;
+};
+
+template<class Category, class T, class Distance = ptrdiff_t,
+         class Pointer = T*, class Reference = T&>
+struct iterator
+{
+    typedef T         value_type;
+    typedef Distance  difference_type;
+    typedef Pointer   pointer;
+    typedef Reference reference;
+    typedef Category  iterator_category;
+};
+
+struct input_iterator_tag  {};
+struct output_iterator_tag {};
+struct forward_iterator_tag       : public input_iterator_tag         {};
+struct bidirectional_iterator_tag : public forward_iterator_tag       {};
+struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+
+// extension: second argument not conforming to C++03
+template <class InputIterator>
+void advance(InputIterator& i,
+             typename iterator_traits<InputIterator>::difference_type n);
+
+template <class InputIterator>
+typename iterator_traits<InputIterator>::difference_type
+distance(InputIterator first, InputIterator last);
+
+template <class Iterator>
+class reverse_iterator
+    : public iterator<typename iterator_traits<Iterator>::iterator_category,
+                      typename iterator_traits<Iterator>::value_type,
+                      typename iterator_traits<Iterator>::difference_type,
+                      typename iterator_traits<Iterator>::pointer,
+                      typename iterator_traits<Iterator>::reference>
+{
+protected:
+    Iterator current;
+public:
+    typedef Iterator                                            iterator_type;
+    typedef typename iterator_traits<Iterator>::difference_type difference_type;
+    typedef typename iterator_traits<Iterator>::reference       reference;
+    typedef typename iterator_traits<Iterator>::pointer         pointer;
+
+    reverse_iterator();
+    explicit reverse_iterator(Iterator x);
+    template <class U> reverse_iterator(const reverse_iterator<U>& u);
+    Iterator base() const;
+    reference operator*() const;
+    pointer   operator->() const;
+    reverse_iterator& operator++();
+    reverse_iterator  operator++(int);
+    reverse_iterator& operator--();
+    reverse_iterator  operator--(int);
+    reverse_iterator  operator+ (difference_type n) const;
+    reverse_iterator& operator+=(difference_type n);
+    reverse_iterator  operator- (difference_type n) const;
+    reverse_iterator& operator-=(difference_type n);
+    reference         operator[](difference_type n) const;
+};
+
+template <class Iterator1, class Iterator2>
+bool
+operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+bool
+operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+bool
+operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+bool
+operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+bool
+operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+bool
+operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator1, class Iterator2>
+typename reverse_iterator<Iterator1>::difference_type
+operator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y);
+
+template <class Iterator>
+reverse_iterator<Iterator>
+operator+(typename reverse_iterator<Iterator>::difference_type n, const reverse_iterator<Iterator>& x);
+
+template <class Iterator> reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14
+
+template <class Container>
+class back_insert_iterator
+{
+protected:
+    Container* container;
+public:
+    typedef Container                   container_type;
+    typedef void                        value_type;
+    typedef void                        difference_type;
+    typedef back_insert_iterator<Cont>& reference;
+    typedef void                        pointer;
+
+    explicit back_insert_iterator(Container& x);
+    back_insert_iterator& operator=(const typename Container::value_type& value);
+    back_insert_iterator& operator*();
+    back_insert_iterator& operator++();
+    back_insert_iterator  operator++(int);
+};
+
+template <class Container> back_insert_iterator<Container> back_inserter(Container& x);
+
+template <class Container>
+class front_insert_iterator
+{
+protected:
+    Container* container;
+public:
+    typedef Container                    container_type;
+    typedef void                         value_type;
+    typedef void                         difference_type;
+    typedef front_insert_iterator<Cont>& reference;
+    typedef void                         pointer;
+
+    explicit front_insert_iterator(Container& x);
+    front_insert_iterator& operator=(const typename Container::value_type& value);
+    front_insert_iterator& operator*();
+    front_insert_iterator& operator++();
+    front_insert_iterator  operator++(int);
+};
+
+template <class Container> front_insert_iterator<Container> front_inserter(Container& x);
+
+template <class Container>
+class insert_iterator
+{
+protected:
+    Container* container;
+    typename Container::iterator iter;
+public:
+    typedef Container              container_type;
+    typedef void                   value_type;
+    typedef void                   difference_type;
+    typedef insert_iterator<Cont>& reference;
+    typedef void                   pointer;
+
+    insert_iterator(Container& x, typename Container::iterator i);
+    insert_iterator& operator=(const typename Container::value_type& value);
+    insert_iterator& operator*();
+    insert_iterator& operator++();
+    insert_iterator& operator++(int);
+};
+
+template <class Container, class Iterator>
+insert_iterator<Container> inserter(Container& x, Iterator i);
+
+template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t>
+class istream_iterator
+    : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
+{
+public:
+    typedef charT char_type;
+    typedef traits traits_type;
+    typedef basic_istream<charT,traits> istream_type;
+
+    istream_iterator();
+    istream_iterator(istream_type& s);
+    istream_iterator(const istream_iterator& x);
+    ~istream_iterator();
+
+    const T& operator*() const;
+    const T* operator->() const;
+    istream_iterator& operator++();
+    istream_iterator  operator++(int);
+};
+
+template <class T, class charT, class traits, class Distance>
+bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
+                const istream_iterator<T,charT,traits,Distance>& y);
+template <class T, class charT, class traits, class Distance>
+bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
+                const istream_iterator<T,charT,traits,Distance>& y);
+
+template <class T, class charT = char, class traits = char_traits<charT> >
+class ostream_iterator
+    : public iterator<output_iterator_tag, void, void, void ,void>
+{
+public:
+    typedef charT char_type;
+    typedef traits traits_type;
+    typedef basic_ostream<charT,traits> ostream_type;
+
+    ostream_iterator(ostream_type& s);
+    ostream_iterator(ostream_type& s, const charT* delimiter);
+    ostream_iterator(const ostream_iterator& x);
+    ~ostream_iterator();
+    ostream_iterator& operator=(const T& value);
+
+    ostream_iterator& operator*();
+    ostream_iterator& operator++();
+    ostream_iterator& operator++(int);
+};
+
+template<class charT, class traits = char_traits<charT> >
+class istreambuf_iterator
+    : public iterator<input_iterator_tag, charT,
+                      typename traits::off_type, unspecified,
+                      charT>
+{
+public:
+    typedef charT                         char_type;
+    typedef traits                        traits_type;
+    typedef typename traits::int_type     int_type;
+    typedef basic_streambuf<charT,traits> streambuf_type;
+    typedef basic_istream<charT,traits>   istream_type;
+
+    istreambuf_iterator() noexcept;
+    istreambuf_iterator(istream_type& s) noexcept;
+    istreambuf_iterator(streambuf_type* s) noexcept;
+    istreambuf_iterator(a-private-type) noexcept;
+
+    charT                operator*() const;
+    pointer operator->() const;
+    istreambuf_iterator& operator++();
+    a-private-type       operator++(int);
+
+    bool equal(const istreambuf_iterator& b) const;
+};
+
+template <class charT, class traits>
+bool operator==(const istreambuf_iterator<charT,traits>& a,
+                const istreambuf_iterator<charT,traits>& b);
+template <class charT, class traits>
+bool operator!=(const istreambuf_iterator<charT,traits>& a,
+                const istreambuf_iterator<charT,traits>& b);
+
+template <class charT, class traits = char_traits<charT> >
+class ostreambuf_iterator
+    : public iterator<output_iterator_tag, void, void, void, void>
+{
+public:
+    typedef charT                         char_type;
+    typedef traits                        traits_type;
+    typedef basic_streambuf<charT,traits> streambuf_type;
+    typedef basic_ostream<charT,traits>   ostream_type;
+
+    ostreambuf_iterator(ostream_type& s) noexcept;
+    ostreambuf_iterator(streambuf_type* s) noexcept;
+    ostreambuf_iterator& operator=(charT c);
+    ostreambuf_iterator& operator*();
+    ostreambuf_iterator& operator++();
+    ostreambuf_iterator& operator++(int);
+    bool failed() const noexcept;
+};
+
+template <class C> auto begin(C& c) -> decltype(c.begin());
+template <class C> auto begin(const C& c) -> decltype(c.begin());
+template <class C> auto end(C& c) -> decltype(c.end());
+template <class C> auto end(const C& c) -> decltype(c.end());
+template <class T, size_t N> T* begin(T (&array)[N]);
+template <class T, size_t N> T* end(T (&array)[N]);
+
+template <class C> auto cbegin(const C& c) -> decltype(std::begin(c));        // C++14
+template <class C> auto cend(const C& c) -> decltype(std::end(c));            // C++14
+template <class C> auto rbegin(C& c) -> decltype(c.rbegin());                 // C++14
+template <class C> auto rbegin(const C& c) -> decltype(c.rbegin());           // C++14
+template <class C> auto rend(C& c) -> decltype(c.rend());                     // C++14
+template <class C> auto rend(const C& c) -> decltype(c.rend());               // C++14
+template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14
+template <class E> reverse_iterator<const E*> rend(initializer_list<E> il);   // C++14
+template <class T, size_t N> reverse_iterator<T*> rbegin(T (&array)[N]);      // C++14
+template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]);        // C++14
+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
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__functional_base>
+#include <type_traits>
+#include <cstddef>
+#include <iosfwd>
+#include <initializer_list>
+#ifdef __APPLE__
+#include <Availability.h>
+#endif
+
+#ifdef _LIBCPP_DEBUG
+#   include <__debug>
+#else
+#   define _LIBCPP_ASSERT(x, m) ((void)0)
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+struct _LIBCPP_TYPE_VIS_ONLY input_iterator_tag {};
+struct _LIBCPP_TYPE_VIS_ONLY output_iterator_tag {};
+struct _LIBCPP_TYPE_VIS_ONLY forward_iterator_tag       : public input_iterator_tag {};
+struct _LIBCPP_TYPE_VIS_ONLY bidirectional_iterator_tag : public forward_iterator_tag {};
+struct _LIBCPP_TYPE_VIS_ONLY random_access_iterator_tag : public bidirectional_iterator_tag {};
+
+template <class _Tp>
+struct __has_iterator_category
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::iterator_category* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Iter, bool> struct __iterator_traits_impl {};
+
+template <class _Iter>
+struct __iterator_traits_impl<_Iter, true>
+{
+    typedef typename _Iter::difference_type   difference_type;
+    typedef typename _Iter::value_type        value_type;
+    typedef typename _Iter::pointer           pointer;
+    typedef typename _Iter::reference         reference;
+    typedef typename _Iter::iterator_category iterator_category;
+};
+
+template <class _Iter, bool> struct __iterator_traits {};
+
+template <class _Iter>
+struct __iterator_traits<_Iter, true>
+    :  __iterator_traits_impl
+      <
+        _Iter,
+        is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
+        is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value
+      >
+{};
+
+// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
+//    exists.  Else iterator_traits<Iterator> will be an empty class.  This is a
+//    conforming extension which allows some programs to compile and behave as
+//    the client expects instead of failing at compile time.
+
+template <class _Iter>
+struct _LIBCPP_TYPE_VIS_ONLY iterator_traits
+    : __iterator_traits<_Iter, __has_iterator_category<_Iter>::value> {};
+
+template<class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY iterator_traits<_Tp*>
+{
+    typedef ptrdiff_t difference_type;
+    typedef typename remove_const<_Tp>::type value_type;
+    typedef _Tp* pointer;
+    typedef _Tp& reference;
+    typedef random_access_iterator_tag iterator_category;
+};
+
+template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>
+struct __has_iterator_category_convertible_to
+    : public integral_constant<bool, is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up>::value>
+{};
+
+template <class _Tp, class _Up>
+struct __has_iterator_category_convertible_to<_Tp, _Up, false> : public false_type {};
+
+template <class _Tp>
+struct __is_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {};
+
+template <class _Tp>
+struct __is_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {};
+
+template <class _Tp>
+struct __is_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {};
+
+template <class _Tp>
+struct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {};
+
+template<class _Category, class _Tp, class _Distance = ptrdiff_t,
+         class _Pointer = _Tp*, class _Reference = _Tp&>
+struct _LIBCPP_TYPE_VIS_ONLY iterator
+{
+    typedef _Tp        value_type;
+    typedef _Distance  difference_type;
+    typedef _Pointer   pointer;
+    typedef _Reference reference;
+    typedef _Category  iterator_category;
+};
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY
+void __advance(_InputIter& __i,
+             typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag)
+{
+    for (; __n > 0; --__n)
+        ++__i;
+}
+
+template <class _BiDirIter>
+inline _LIBCPP_INLINE_VISIBILITY
+void __advance(_BiDirIter& __i,
+             typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag)
+{
+    if (__n >= 0)
+        for (; __n > 0; --__n)
+            ++__i;
+    else
+        for (; __n < 0; ++__n)
+            --__i;
+}
+
+template <class _RandIter>
+inline _LIBCPP_INLINE_VISIBILITY
+void __advance(_RandIter& __i,
+             typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag)
+{
+   __i += __n;
+}
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY
+void advance(_InputIter& __i,
+             typename iterator_traits<_InputIter>::difference_type __n)
+{
+    __advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
+}
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY
+typename iterator_traits<_InputIter>::difference_type
+__distance(_InputIter __first, _InputIter __last, input_iterator_tag)
+{
+    typename iterator_traits<_InputIter>::difference_type __r(0);
+    for (; __first != __last; ++__first)
+        ++__r;
+    return __r;
+}
+
+template <class _RandIter>
+inline _LIBCPP_INLINE_VISIBILITY
+typename iterator_traits<_RandIter>::difference_type
+__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag)
+{
+    return __last - __first;
+}
+
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY
+typename iterator_traits<_InputIter>::difference_type
+distance(_InputIter __first, _InputIter __last)
+{
+    return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category());
+}
+
+template <class _ForwardIter>
+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)
+{
+    _VSTD::advance(__x, __n);
+    return __x;
+}
+
+template <class _BidiretionalIter>
+inline _LIBCPP_INLINE_VISIBILITY
+_BidiretionalIter
+prev(_BidiretionalIter __x,
+     typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,
+     typename enable_if<__is_bidirectional_iterator<_BidiretionalIter>::value>::type* = 0)
+{
+    _VSTD::advance(__x, -__n);
+    return __x;
+}
+
+template <class _Iter>
+class _LIBCPP_TYPE_VIS_ONLY reverse_iterator
+    : public iterator<typename iterator_traits<_Iter>::iterator_category,
+                      typename iterator_traits<_Iter>::value_type,
+                      typename iterator_traits<_Iter>::difference_type,
+                      typename iterator_traits<_Iter>::pointer,
+                      typename iterator_traits<_Iter>::reference>
+{
+private:
+    mutable _Iter __t;  // no longer used as of LWG #2360, not removed due to ABI break
+protected:
+    _Iter current;
+public:
+    typedef _Iter                                            iterator_type;
+    typedef typename iterator_traits<_Iter>::difference_type difference_type;
+    typedef typename iterator_traits<_Iter>::reference       reference;
+    typedef typename iterator_traits<_Iter>::pointer         pointer;
+
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator() : current() {}
+    _LIBCPP_INLINE_VISIBILITY explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {}
+    template <class _Up> _LIBCPP_INLINE_VISIBILITY reverse_iterator(const reverse_iterator<_Up>& __u)
+        : __t(__u.base()), current(__u.base()) {}
+    _LIBCPP_INLINE_VISIBILITY _Iter base() const {return current;}
+    _LIBCPP_INLINE_VISIBILITY reference operator*() const {_Iter __tmp = current; return *--__tmp;}
+    _LIBCPP_INLINE_VISIBILITY pointer  operator->() const {return _VSTD::addressof(operator*());}
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator++() {--current; return *this;}
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator  operator++(int)
+        {reverse_iterator __tmp(*this); --current; return __tmp;}
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator--() {++current; return *this;}
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator  operator--(int)
+        {reverse_iterator __tmp(*this); ++current; return __tmp;}
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator  operator+ (difference_type __n) const
+        {return reverse_iterator(current - __n);}
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator& operator+=(difference_type __n)
+        {current -= __n; return *this;}
+    _LIBCPP_INLINE_VISIBILITY reverse_iterator  operator- (difference_type __n) const
+        {return reverse_iterator(current + __n);}
+    _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];}
+};
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+    return __x.base() == __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+    return __x.base() > __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+    return __x.base() != __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+    return __x.base() < __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+    return __x.base() <= __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+    return __x.base() >= __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename reverse_iterator<_Iter1>::difference_type
+operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
+{
+    return __y.base() - __x.base();
+}
+
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY
+reverse_iterator<_Iter>
+operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x)
+{
+    return reverse_iterator<_Iter>(__x.base() - __n);
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY
+reverse_iterator<_Iter> make_reverse_iterator(_Iter __i)
+{
+    return reverse_iterator<_Iter>(__i);
+}
+#endif
+
+template <class _Container>
+class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator
+    : public iterator<output_iterator_tag,
+                      void,
+                      void,
+                      void,
+                      back_insert_iterator<_Container>&>
+{
+protected:
+    _Container* container;
+public:
+    typedef _Container container_type;
+
+    _LIBCPP_INLINE_VISIBILITY explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
+    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(const typename _Container::value_type& __value_)
+        {container->push_back(__value_); return *this;}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator=(typename _Container::value_type&& __value_)
+        {container->push_back(_VSTD::move(__value_)); return *this;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator*()     {return *this;}
+    _LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++()    {return *this;}
+    _LIBCPP_INLINE_VISIBILITY back_insert_iterator  operator++(int) {return *this;}
+};
+
+template <class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+back_insert_iterator<_Container>
+back_inserter(_Container& __x)
+{
+    return back_insert_iterator<_Container>(__x);
+}
+
+template <class _Container>
+class _LIBCPP_TYPE_VIS_ONLY front_insert_iterator
+    : public iterator<output_iterator_tag,
+                      void,
+                      void,
+                      void,
+                      front_insert_iterator<_Container>&>
+{
+protected:
+    _Container* container;
+public:
+    typedef _Container container_type;
+
+    _LIBCPP_INLINE_VISIBILITY explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {}
+    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(const typename _Container::value_type& __value_)
+        {container->push_front(__value_); return *this;}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator=(typename _Container::value_type&& __value_)
+        {container->push_front(_VSTD::move(__value_)); return *this;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator*()     {return *this;}
+    _LIBCPP_INLINE_VISIBILITY front_insert_iterator& operator++()    {return *this;}
+    _LIBCPP_INLINE_VISIBILITY front_insert_iterator  operator++(int) {return *this;}
+};
+
+template <class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+front_insert_iterator<_Container>
+front_inserter(_Container& __x)
+{
+    return front_insert_iterator<_Container>(__x);
+}
+
+template <class _Container>
+class _LIBCPP_TYPE_VIS_ONLY insert_iterator
+    : public iterator<output_iterator_tag,
+                      void,
+                      void,
+                      void,
+                      insert_iterator<_Container>&>
+{
+protected:
+    _Container* container;
+    typename _Container::iterator iter;
+public:
+    typedef _Container container_type;
+
+    _LIBCPP_INLINE_VISIBILITY insert_iterator(_Container& __x, typename _Container::iterator __i)
+        : container(_VSTD::addressof(__x)), iter(__i) {}
+    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(const typename _Container::value_type& __value_)
+        {iter = container->insert(iter, __value_); ++iter; return *this;}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator=(typename _Container::value_type&& __value_)
+        {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator*()        {return *this;}
+    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++()       {return *this;}
+    _LIBCPP_INLINE_VISIBILITY insert_iterator& operator++(int)    {return *this;}
+};
+
+template <class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+insert_iterator<_Container>
+inserter(_Container& __x, typename _Container::iterator __i)
+{
+    return insert_iterator<_Container>(__x, __i);
+}
+
+template <class _Tp, class _CharT = char,
+          class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
+class _LIBCPP_TYPE_VIS_ONLY istream_iterator
+    : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
+{
+public:
+    typedef _CharT char_type;
+    typedef _Traits traits_type;
+    typedef basic_istream<_CharT,_Traits> istream_type;
+private:
+    istream_type* __in_stream_;
+    _Tp __value_;
+public:
+    _LIBCPP_INLINE_VISIBILITY istream_iterator() : __in_stream_(0) {}
+    _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(&__s)
+        {
+            if (!(*__in_stream_ >> __value_))
+                __in_stream_ = 0;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;}
+    _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return &(operator*());}
+    _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++()
+        {
+            if (!(*__in_stream_ >> __value_))
+                __in_stream_ = 0;
+            return *this;
+        }
+    _LIBCPP_INLINE_VISIBILITY istream_iterator  operator++(int)
+        {istream_iterator __t(*this); ++(*this); return __t;}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const istream_iterator& __x, const istream_iterator& __y)
+        {return __x.__in_stream_ == __y.__in_stream_;}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const istream_iterator& __x, const istream_iterator& __y)
+        {return !(__x == __y);}
+};
+
+template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY ostream_iterator
+    : public iterator<output_iterator_tag, void, void, void, void>
+{
+public:
+    typedef _CharT char_type;
+    typedef _Traits traits_type;
+    typedef basic_ostream<_CharT,_Traits> ostream_type;
+private:
+    ostream_type* __out_stream_;
+    const char_type* __delim_;
+public:
+    _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s)
+        : __out_stream_(&__s), __delim_(0) {}
+    _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter)
+        : __out_stream_(&__s), __delim_(__delimiter) {}
+    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_)
+        {
+            *__out_stream_ << __value_;
+            if (__delim_)
+                *__out_stream_ << __delim_;
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*()     {return *this;}
+    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++()    {return *this;}
+    _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;}
+};
+
+template<class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator
+    : public iterator<input_iterator_tag, _CharT,
+                      typename _Traits::off_type, _CharT*,
+                      _CharT>
+{
+public:
+    typedef _CharT                          char_type;
+    typedef _Traits                         traits_type;
+    typedef typename _Traits::int_type      int_type;
+    typedef basic_streambuf<_CharT,_Traits> streambuf_type;
+    typedef basic_istream<_CharT,_Traits>   istream_type;
+private:
+    mutable streambuf_type* __sbuf_;
+
+    class __proxy
+    {
+        char_type __keep_;
+        streambuf_type* __sbuf_;
+        _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s)
+            : __keep_(__c), __sbuf_(__s) {}
+        friend class istreambuf_iterator;
+    public:
+        _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;}
+    };
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool __test_for_eof() const
+    {
+        if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof()))
+            __sbuf_ = 0;
+        return __sbuf_ == 0;
+    }
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(0) {}
+    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT
+        : __sbuf_(__s.rdbuf()) {}
+    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT
+        : __sbuf_(__s) {}
+    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT
+        : __sbuf_(__p.__sbuf_) {}
+
+    _LIBCPP_INLINE_VISIBILITY char_type  operator*() const
+        {return static_cast<char_type>(__sbuf_->sgetc());}
+    _LIBCPP_INLINE_VISIBILITY char_type* operator->() const {return nullptr;}
+    _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++()
+        {
+            __sbuf_->sbumpc();
+            return *this;
+        }
+    _LIBCPP_INLINE_VISIBILITY __proxy              operator++(int)
+        {
+            return __proxy(__sbuf_->sbumpc(), __sbuf_);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const
+        {return __test_for_eof() == __b.__test_for_eof();}
+};
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
+                const istreambuf_iterator<_CharT,_Traits>& __b)
+                {return __a.equal(__b);}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a,
+                const istreambuf_iterator<_CharT,_Traits>& __b)
+                {return !__a.equal(__b);}
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator
+    : public iterator<output_iterator_tag, void, void, void, void>
+{
+public:
+    typedef _CharT                          char_type;
+    typedef _Traits                         traits_type;
+    typedef basic_streambuf<_CharT,_Traits> streambuf_type;
+    typedef basic_ostream<_CharT,_Traits>   ostream_type;
+private:
+    streambuf_type* __sbuf_;
+public:
+    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT
+        : __sbuf_(__s.rdbuf()) {}
+    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT
+        : __sbuf_(__s) {}
+    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c)
+        {
+            if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof()))
+                __sbuf_ = 0;
+            return *this;
+        }
+    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*()     {return *this;}
+    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++()    {return *this;}
+    _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
+    _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;}
+
+#if !defined(__APPLE__) || \
+    (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \
+    (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0)
+
+    template <class _Ch, class _Tr>
+    friend
+    _LIBCPP_HIDDEN
+    ostreambuf_iterator<_Ch, _Tr>
+    __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
+                     const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
+                     ios_base& __iob, _Ch __fl);
+#endif
+};
+
+template <class _Iter>
+class _LIBCPP_TYPE_VIS_ONLY move_iterator
+{
+private:
+    _Iter __i;
+public:
+    typedef _Iter                                            iterator_type;
+    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;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    typedef value_type&& reference;
+#else
+    typedef typename iterator_traits<iterator_type>::reference reference;
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY move_iterator() : __i() {}
+    _LIBCPP_INLINE_VISIBILITY explicit move_iterator(_Iter __x) : __i(__x) {}
+    template <class _Up> _LIBCPP_INLINE_VISIBILITY move_iterator(const move_iterator<_Up>& __u)
+        : __i(__u.base()) {}
+    _LIBCPP_INLINE_VISIBILITY _Iter base() const {return __i;}
+    _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 move_iterator& operator++() {++__i; return *this;}
+    _LIBCPP_INLINE_VISIBILITY move_iterator  operator++(int)
+        {move_iterator __tmp(*this); ++__i; return __tmp;}
+    _LIBCPP_INLINE_VISIBILITY move_iterator& operator--() {--__i; return *this;}
+    _LIBCPP_INLINE_VISIBILITY move_iterator  operator--(int)
+        {move_iterator __tmp(*this); --__i; return __tmp;}
+    _LIBCPP_INLINE_VISIBILITY move_iterator  operator+ (difference_type __n) const
+        {return move_iterator(__i + __n);}
+    _LIBCPP_INLINE_VISIBILITY move_iterator& operator+=(difference_type __n)
+        {__i += __n; return *this;}
+    _LIBCPP_INLINE_VISIBILITY move_iterator  operator- (difference_type __n) const
+        {return move_iterator(__i - __n);}
+    _LIBCPP_INLINE_VISIBILITY move_iterator& operator-=(difference_type __n)
+        {__i -= __n; return *this;}
+    _LIBCPP_INLINE_VISIBILITY reference         operator[](difference_type __n) const
+    {
+      return static_cast<reference>(__i[__n]);
+    }
+};
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+    return __x.base() == __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+    return __x.base() < __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+    return __x.base() != __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+    return __x.base() > __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+    return __x.base() >= __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+    return __x.base() <= __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename move_iterator<_Iter1>::difference_type
+operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
+{
+    return __x.base() - __y.base();
+}
+
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY
+move_iterator<_Iter>
+operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x)
+{
+    return move_iterator<_Iter>(__x.base() + __n);
+}
+
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY
+move_iterator<_Iter>
+make_move_iterator(_Iter __i)
+{
+    return move_iterator<_Iter>(__i);
+}
+
+// __wrap_iter
+
+template <class _Iter> class __wrap_iter;
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+template <class _Iter1, class _Iter2>
+_LIBCPP_INLINE_VISIBILITY
+typename __wrap_iter<_Iter1>::difference_type
+operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+template <class _Iter>
+_LIBCPP_INLINE_VISIBILITY
+__wrap_iter<_Iter>
+operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT;
+
+template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, _Op);
+template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY copy_backward(_B1, _B1, _B2);
+template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY move(_Ip, _Ip, _Op);
+template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY move_backward(_B1, _B1, _B2);
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_trivially_copy_assignable<_Tp>::value,
+    _Tp*
+>::type
+__unwrap_iter(__wrap_iter<_Tp*>);
+
+template <class _Iter>
+class __wrap_iter
+{
+public:
+    typedef _Iter                                                      iterator_type;
+    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 typename iterator_traits<iterator_type>::reference         reference;
+private:
+    iterator_type __i;
+public:
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter() _NOEXCEPT
+#if _LIBCPP_STD_VER > 11
+                : __i{}
+#endif
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_i(this);
+#endif
+    }
+    template <class _Up> _LIBCPP_INLINE_VISIBILITY __wrap_iter(const __wrap_iter<_Up>& __u,
+        typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT
+        : __i(__u.base())
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__iterator_copy(this, &__u);
+#endif
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    __wrap_iter(const __wrap_iter& __x)
+        : __i(__x.base())
+    {
+        __get_db()->__iterator_copy(this, &__x);
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __wrap_iter& operator=(const __wrap_iter& __x)
+    {
+        if (this != &__x)
+        {
+            __get_db()->__iterator_copy(this, &__x);
+            __i = __x.__i;
+        }
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    ~__wrap_iter()
+    {
+        __get_db()->__erase_i(this);
+    }
+#endif
+    _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to dereference a non-dereferenceable iterator");
+#endif
+        return *__i;
+    }
+    _LIBCPP_INLINE_VISIBILITY pointer  operator->() const _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to dereference a non-dereferenceable iterator");
+#endif
+        return (pointer)&reinterpret_cast<const volatile char&>(*__i);
+    }
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter& operator++() _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to increment non-incrementable iterator");
+#endif
+        ++__i;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter  operator++(int) _NOEXCEPT
+        {__wrap_iter __tmp(*this); ++(*this); return __tmp;}
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter& operator--() _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
+                       "Attempted to decrement non-decrementable iterator");
+#endif
+        --__i;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter  operator--(int) _NOEXCEPT
+        {__wrap_iter __tmp(*this); --(*this); return __tmp;}
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter  operator+ (difference_type __n) const _NOEXCEPT
+        {__wrap_iter __w(*this); __w += __n; return __w;}
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
+                   "Attempted to add/subtract iterator outside of valid range");
+#endif
+        __i += __n;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter  operator- (difference_type __n) const _NOEXCEPT
+        {return *this + (-__n);}
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
+        {*this += -__n; return *this;}
+    _LIBCPP_INLINE_VISIBILITY reference        operator[](difference_type __n) const _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
+                   "Attempted to subscript iterator outside of valid range");
+#endif
+        return __i[__n];
+    }
+
+    _LIBCPP_INLINE_VISIBILITY iterator_type base() const _NOEXCEPT {return __i;}
+
+private:
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter(const void* __p, iterator_type __x) : __i(__x)
+    {
+        __get_db()->__insert_ic(this, __p);
+    }
+#else
+    _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
+#endif
+
+    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 _Iter1, class _Iter2>
+    friend
+    bool
+    operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+    template <class _Iter1, class _Iter2>
+    friend
+    bool
+    operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+    template <class _Iter1, class _Iter2>
+    friend
+    bool
+    operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+    template <class _Iter1, class _Iter2>
+    friend
+    bool
+    operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+    template <class _Iter1, class _Iter2>
+    friend
+    bool
+    operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+    template <class _Iter1, class _Iter2>
+    friend
+    bool
+    operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+    template <class _Iter1, class _Iter2>
+    friend
+    typename __wrap_iter<_Iter1>::difference_type
+    operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
+
+    template <class _Iter1>
+    friend
+    __wrap_iter<_Iter1>
+    operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT;
+
+    template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op);
+    template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2);
+    template <class _Ip, class _Op> friend _Op move(_Ip, _Ip, _Op);
+    template <class _B1, class _B2> friend _B2 move_backward(_B1, _B1, _B2);
+
+    template <class _Tp>
+    friend
+    typename enable_if
+    <
+        is_trivially_copy_assignable<_Tp>::value,
+        _Tp*
+    >::type
+    __unwrap_iter(__wrap_iter<_Tp*>);
+};
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+    return __x.base() == __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
+                   "Attempted to compare incomparable iterators");
+#endif
+    return __x.base() < __y.base();
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+    return !(__x == __y);
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+    return __y < __x;
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+    return !(__x < __y);
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+    return !(__y < __x);
+}
+
+template <class _Iter1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+    return !(__x == __y);
+}
+
+template <class _Iter1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+    return __y < __x;
+}
+
+template <class _Iter1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+    return !(__x < __y);
+}
+
+template <class _Iter1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
+{
+    return !(__y < __x);
+}
+
+template <class _Iter1, class _Iter2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __wrap_iter<_Iter1>::difference_type
+operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
+                   "Attempted to subtract incompatible iterators");
+#endif
+    return __x.base() - __y.base();
+}
+
+template <class _Iter>
+inline _LIBCPP_INLINE_VISIBILITY
+__wrap_iter<_Iter>
+operator+(typename __wrap_iter<_Iter>::difference_type __n,
+          __wrap_iter<_Iter> __x) _NOEXCEPT
+{
+    __x += __n;
+    return __x;
+}
+
+template <class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp*
+begin(_Tp (&__array)[_Np])
+{
+    return __array;
+}
+
+template <class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp*
+end(_Tp (&__array)[_Np])
+{
+    return __array + _Np;
+}
+
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN)
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+begin(_Cp& __c) -> decltype(__c.begin())
+{
+    return __c.begin();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+begin(const _Cp& __c) -> decltype(__c.begin())
+{
+    return __c.begin();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+end(_Cp& __c) -> decltype(__c.end())
+{
+    return __c.end();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto
+end(const _Cp& __c) -> decltype(__c.end())
+{
+    return __c.end();
+}
+
+#if _LIBCPP_STD_VER > 11
+
+template <class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY
+reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
+{
+    return reverse_iterator<_Tp*>(__array + _Np);
+}
+
+template <class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY
+reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
+{
+    return reverse_iterator<_Tp*>(__array);
+}
+
+template <class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
+{
+    return reverse_iterator<const _Ep*>(__il.end());
+}
+
+template <class _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
+{
+    return reverse_iterator<const _Ep*>(__il.begin());
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+auto cbegin(const _Cp& __c) -> decltype(begin(__c))
+{
+    return begin(__c);
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+auto cend(const _Cp& __c) -> decltype(end(__c))
+{
+    return end(__c);
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
+{
+    return __c.rbegin();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
+{
+    return __c.rbegin();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto rend(_Cp& __c) -> decltype(__c.rend())
+{
+    return __c.rend();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto rend(const _Cp& __c) -> decltype(__c.rend())
+{
+    return __c.rend();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto crbegin(const _Cp& __c) -> decltype(rbegin(__c))
+{
+    return rbegin(__c);
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+auto crend(const _Cp& __c) -> decltype(rend(__c))
+{
+    return rend(__c);
+}
+
+#endif
+
+
+#else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN)
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename _Cp::iterator
+begin(_Cp& __c)
+{
+    return __c.begin();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename _Cp::const_iterator
+begin(const _Cp& __c)
+{
+    return __c.begin();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename _Cp::iterator
+end(_Cp& __c)
+{
+    return __c.end();
+}
+
+template <class _Cp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename _Cp::const_iterator
+end(const _Cp& __c)
+{
+    return __c.end();
+}
+
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_ITERATOR
diff --git a/final/include/limits b/final/include/limits
new file mode 100644
index 0000000..2216966
--- /dev/null
+++ b/final/include/limits
@@ -0,0 +1,813 @@
+// -*- C++ -*-
+//===---------------------------- limits ----------------------------------===//
+//
+//                     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_LIMITS
+#define _LIBCPP_LIMITS
+
+/*
+    limits synopsis
+
+namespace std
+{
+
+template<class T>
+class numeric_limits
+{
+public:
+    static constexpr bool is_specialized = false;
+    static constexpr T min() noexcept;
+    static constexpr T max() noexcept;
+    static constexpr T lowest() noexcept;
+
+    static constexpr int  digits = 0;
+    static constexpr int  digits10 = 0;
+    static constexpr int  max_digits10 = 0;
+    static constexpr bool is_signed = false;
+    static constexpr bool is_integer = false;
+    static constexpr bool is_exact = false;
+    static constexpr int  radix = 0;
+    static constexpr T epsilon() noexcept;
+    static constexpr T round_error() noexcept;
+
+    static constexpr int  min_exponent = 0;
+    static constexpr int  min_exponent10 = 0;
+    static constexpr int  max_exponent = 0;
+    static constexpr int  max_exponent10 = 0;
+
+    static constexpr bool has_infinity = false;
+    static constexpr bool has_quiet_NaN = false;
+    static constexpr bool has_signaling_NaN = false;
+    static constexpr float_denorm_style has_denorm = denorm_absent;
+    static constexpr bool has_denorm_loss = false;
+    static constexpr T infinity() noexcept;
+    static constexpr T quiet_NaN() noexcept;
+    static constexpr T signaling_NaN() noexcept;
+    static constexpr T denorm_min() noexcept;
+
+    static constexpr bool is_iec559 = false;
+    static constexpr bool is_bounded = false;
+    static constexpr bool is_modulo = false;
+
+    static constexpr bool traps = false;
+    static constexpr bool tinyness_before = false;
+    static constexpr float_round_style round_style = round_toward_zero;
+};
+
+enum float_round_style
+{
+    round_indeterminate       = -1,
+    round_toward_zero         =  0,
+    round_to_nearest          =  1,
+    round_toward_infinity     =  2,
+    round_toward_neg_infinity =  3
+};
+
+enum float_denorm_style
+{
+    denorm_indeterminate = -1,
+    denorm_absent = 0,
+    denorm_present = 1
+};
+
+template<> class numeric_limits<cv bool>;
+
+template<> class numeric_limits<cv char>;
+template<> class numeric_limits<cv signed char>;
+template<> class numeric_limits<cv unsigned char>;
+template<> class numeric_limits<cv wchar_t>;
+template<> class numeric_limits<cv char16_t>;
+template<> class numeric_limits<cv char32_t>;
+
+template<> class numeric_limits<cv short>;
+template<> class numeric_limits<cv int>;
+template<> class numeric_limits<cv long>;
+template<> class numeric_limits<cv long long>;
+template<> class numeric_limits<cv unsigned short>;
+template<> class numeric_limits<cv unsigned int>;
+template<> class numeric_limits<cv unsigned long>;
+template<> class numeric_limits<cv unsigned long long>;
+
+template<> class numeric_limits<cv float>;
+template<> class numeric_limits<cv double>;
+template<> class numeric_limits<cv long double>;
+
+}  // std
+
+*/
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include <__config>
+#include <type_traits>
+
+#include <__undef_min_max>
+
+#if defined(_LIBCPP_MSVCRT)
+#include "support/win32/limits_win32.h"
+#endif // _LIBCPP_MSVCRT
+
+#if defined(__IBMCPP__)
+#include "support/ibm/limits.h"
+#endif // __IBMCPP__
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum float_round_style
+{
+    round_indeterminate       = -1,
+    round_toward_zero         =  0,
+    round_to_nearest          =  1,
+    round_toward_infinity     =  2,
+    round_toward_neg_infinity =  3
+};
+
+enum float_denorm_style
+{
+    denorm_indeterminate = -1,
+    denorm_absent = 0,
+    denorm_present = 1
+};
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+class __libcpp_numeric_limits
+{
+protected:
+    typedef _Tp type;
+
+    static _LIBCPP_CONSTEXPR const  bool is_specialized = false;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return type();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return type();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return type();}
+
+    static _LIBCPP_CONSTEXPR const int  digits = 0;
+    static _LIBCPP_CONSTEXPR const int  digits10 = 0;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = 0;
+    static _LIBCPP_CONSTEXPR const bool is_signed = false;
+    static _LIBCPP_CONSTEXPR const bool is_integer = false;
+    static _LIBCPP_CONSTEXPR const bool is_exact = false;
+    static _LIBCPP_CONSTEXPR const int  radix = 0;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type();}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = 0;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = 0;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = 0;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = 0;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = false;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type();}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = false;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+    static _LIBCPP_CONSTEXPR const bool traps = false;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
+};
+
+template <class _Tp, int digits, bool is_signed>
+struct __libcpp_compute_min
+{
+    static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << digits);
+};
+
+template <class _Tp, int digits>
+struct __libcpp_compute_min<_Tp, digits, false>
+{
+    static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);
+};
+
+template <class _Tp>
+class __libcpp_numeric_limits<_Tp, true>
+{
+protected:
+    typedef _Tp type;
+
+    static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+    static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
+    static _LIBCPP_CONSTEXPR const int  digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
+    static _LIBCPP_CONSTEXPR const int  digits10 = digits * 3 / 10;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = 0;
+    static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
+    static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
+
+    static _LIBCPP_CONSTEXPR const bool is_integer = true;
+    static _LIBCPP_CONSTEXPR const bool is_exact = true;
+    static _LIBCPP_CONSTEXPR const int  radix = 2;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = 0;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = 0;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = 0;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = 0;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = false;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = true;
+
+#if __i386__ || __x86_64__
+    static _LIBCPP_CONSTEXPR const bool traps = true;
+#else
+    static _LIBCPP_CONSTEXPR const bool traps = false;
+#endif
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
+};
+
+template <>
+class __libcpp_numeric_limits<bool, true>
+{
+protected:
+    typedef bool type;
+
+    static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+    static _LIBCPP_CONSTEXPR const bool is_signed = false;
+    static _LIBCPP_CONSTEXPR const int  digits = 1;
+    static _LIBCPP_CONSTEXPR const int  digits10 = 0;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = 0;
+    static _LIBCPP_CONSTEXPR const type __min = false;
+    static _LIBCPP_CONSTEXPR const type __max = true;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __min;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __max;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return min();}
+
+    static _LIBCPP_CONSTEXPR const bool is_integer = true;
+    static _LIBCPP_CONSTEXPR const bool is_exact = true;
+    static _LIBCPP_CONSTEXPR const int  radix = 2;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return type(0);}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = 0;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = 0;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = 0;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = 0;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = false;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return type(0);}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+    static _LIBCPP_CONSTEXPR const bool traps = false;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
+};
+
+template <>
+class __libcpp_numeric_limits<float, true>
+{
+protected:
+    typedef float type;
+
+    static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+    static _LIBCPP_CONSTEXPR const bool is_signed = true;
+    static _LIBCPP_CONSTEXPR const int  digits = __FLT_MANT_DIG__;
+    static _LIBCPP_CONSTEXPR const int  digits10 = __FLT_DIG__;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = 2+(digits * 30103)/100000;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __FLT_MIN__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __FLT_MAX__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
+
+    static _LIBCPP_CONSTEXPR const bool is_integer = false;
+    static _LIBCPP_CONSTEXPR const bool is_exact = false;
+    static _LIBCPP_CONSTEXPR const int  radix = __FLT_RADIX__;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __FLT_EPSILON__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5F;}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = __FLT_MIN_EXP__;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = __FLT_MIN_10_EXP__;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = __FLT_MAX_EXP__;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = __FLT_MAX_10_EXP__;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = true;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_valf();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanf("");}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansf("");}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __FLT_DENORM_MIN__;}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+    static _LIBCPP_CONSTEXPR const bool traps = false;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
+};
+
+template <>
+class __libcpp_numeric_limits<double, true>
+{
+protected:
+    typedef double type;
+
+    static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+    static _LIBCPP_CONSTEXPR const bool is_signed = true;
+    static _LIBCPP_CONSTEXPR const int  digits = __DBL_MANT_DIG__;
+    static _LIBCPP_CONSTEXPR const int  digits10 = __DBL_DIG__;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = 2+(digits * 30103)/100000;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __DBL_MIN__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __DBL_MAX__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
+
+    static _LIBCPP_CONSTEXPR const bool is_integer = false;
+    static _LIBCPP_CONSTEXPR const bool is_exact = false;
+    static _LIBCPP_CONSTEXPR const int  radix = __FLT_RADIX__;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __DBL_EPSILON__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = __DBL_MIN_EXP__;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = __DBL_MIN_10_EXP__;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = __DBL_MAX_EXP__;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = __DBL_MAX_10_EXP__;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = true;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_val();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nan("");}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nans("");}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __DBL_DENORM_MIN__;}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+    static _LIBCPP_CONSTEXPR const bool traps = false;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
+};
+
+template <>
+class __libcpp_numeric_limits<long double, true>
+{
+protected:
+    typedef long double type;
+
+    static _LIBCPP_CONSTEXPR const bool is_specialized = true;
+
+    static _LIBCPP_CONSTEXPR const bool is_signed = true;
+    static _LIBCPP_CONSTEXPR const int  digits = __LDBL_MANT_DIG__;
+    static _LIBCPP_CONSTEXPR const int  digits10 = __LDBL_DIG__;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = 2+(digits * 30103)/100000;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __LDBL_MIN__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __LDBL_MAX__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
+
+    static _LIBCPP_CONSTEXPR const bool is_integer = false;
+    static _LIBCPP_CONSTEXPR const bool is_exact = false;
+    static _LIBCPP_CONSTEXPR const int  radix = __FLT_RADIX__;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __LDBL_EPSILON__;}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = __LDBL_MIN_EXP__;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = __LDBL_MIN_10_EXP__;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = __LDBL_MAX_EXP__;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = __LDBL_MAX_10_EXP__;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = true;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_vall();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanl("");}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __LDBL_DENORM_MIN__;}
+
+#if (defined(__ppc__) || defined(__ppc64__))
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
+#else
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
+#endif
+    static _LIBCPP_CONSTEXPR const bool is_bounded = true;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = false;
+
+    static _LIBCPP_CONSTEXPR const bool traps = false;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
+};
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY numeric_limits
+    : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
+{
+    typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
+    typedef typename __base::type type;
+public:
+    static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+    static _LIBCPP_CONSTEXPR const int  digits = __base::digits;
+    static _LIBCPP_CONSTEXPR const int  digits10 = __base::digits10;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = __base::max_digits10;
+    static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+    static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+    static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+    static _LIBCPP_CONSTEXPR const int  radix = __base::radix;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = __base::min_exponent;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = __base::min_exponent10;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = __base::max_exponent;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = __base::max_exponent10;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+    static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY numeric_limits<const _Tp>
+    : private numeric_limits<_Tp>
+{
+    typedef numeric_limits<_Tp> __base;
+    typedef _Tp type;
+public:
+    static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+    static _LIBCPP_CONSTEXPR const int  digits = __base::digits;
+    static _LIBCPP_CONSTEXPR const int  digits10 = __base::digits10;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = __base::max_digits10;
+    static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+    static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+    static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+    static _LIBCPP_CONSTEXPR const int  radix = __base::radix;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = __base::min_exponent;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = __base::min_exponent10;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = __base::max_exponent;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = __base::max_exponent10;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+    static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_specialized;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_signed;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_integer;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_exact;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::radix;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_infinity;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_quiet_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_signaling_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const _Tp>::has_denorm;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_denorm_loss;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_iec559;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_bounded;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_modulo;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::traps;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::tinyness_before;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style;
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY numeric_limits<volatile _Tp>
+    : private numeric_limits<_Tp>
+{
+    typedef numeric_limits<_Tp> __base;
+    typedef _Tp type;
+public:
+    static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+    static _LIBCPP_CONSTEXPR const int  digits = __base::digits;
+    static _LIBCPP_CONSTEXPR const int  digits10 = __base::digits10;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = __base::max_digits10;
+    static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+    static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+    static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+    static _LIBCPP_CONSTEXPR const int  radix = __base::radix;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = __base::min_exponent;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = __base::min_exponent10;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = __base::max_exponent;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = __base::max_exponent10;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+    static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_specialized;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_signed;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_integer;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_exact;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::radix;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_infinity;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_quiet_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_signaling_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<volatile _Tp>::has_denorm;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_denorm_loss;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_iec559;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_bounded;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_modulo;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::traps;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::tinyness_before;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style;
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY numeric_limits<const volatile _Tp>
+    : private numeric_limits<_Tp>
+{
+    typedef numeric_limits<_Tp> __base;
+    typedef _Tp type;
+public:
+    static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __base::min();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __base::max();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return __base::lowest();}
+
+    static _LIBCPP_CONSTEXPR const int  digits = __base::digits;
+    static _LIBCPP_CONSTEXPR const int  digits10 = __base::digits10;
+    static _LIBCPP_CONSTEXPR const int  max_digits10 = __base::max_digits10;
+    static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
+    static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
+    static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
+    static _LIBCPP_CONSTEXPR const int  radix = __base::radix;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __base::epsilon();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return __base::round_error();}
+
+    static _LIBCPP_CONSTEXPR const int  min_exponent = __base::min_exponent;
+    static _LIBCPP_CONSTEXPR const int  min_exponent10 = __base::min_exponent10;
+    static _LIBCPP_CONSTEXPR const int  max_exponent = __base::max_exponent;
+    static _LIBCPP_CONSTEXPR const int  max_exponent10 = __base::max_exponent10;
+
+    static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
+    static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
+    static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
+    static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
+    static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();}
+    _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {return __base::denorm_min();}
+
+    static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
+    static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
+    static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
+
+    static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
+    static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
+    static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
+};
+
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_specialized;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_digits10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_integer;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_exact;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::radix;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent10;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_infinity;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_quiet_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_signaling_NaN;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const volatile _Tp>::has_denorm;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_denorm_loss;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_iec559;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_bounded;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_modulo;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::traps;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::tinyness_before;
+template <class _Tp>
+    _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const volatile _Tp>::round_style;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_LIMITS
diff --git a/final/include/list b/final/include/list
new file mode 100644
index 0000000..800a1a3
--- /dev/null
+++ b/final/include/list
@@ -0,0 +1,2355 @@
+// -*- C++ -*-
+//===---------------------------- list ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_LIST
+#define _LIBCPP_LIST
+
+/*
+    list synopsis
+
+namespace std
+{
+
+template <class T, class Alloc = allocator<T> >
+class list
+{
+public:
+
+    // types:
+    typedef T value_type;
+    typedef Alloc allocator_type;
+    typedef typename allocator_type::reference reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef typename allocator_type::pointer pointer;
+    typedef typename allocator_type::const_pointer const_pointer;
+    typedef implementation-defined iterator;
+    typedef implementation-defined const_iterator;
+    typedef implementation-defined size_type;
+    typedef implementation-defined difference_type;
+    typedef reverse_iterator<iterator> reverse_iterator;
+    typedef reverse_iterator<const_iterator> const_reverse_iterator;
+
+    list()
+        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+    explicit list(const allocator_type& a);
+    explicit list(size_type n);
+    explicit list(size_type n, const allocator_type& a); // C++14
+    list(size_type n, const value_type& value);
+    list(size_type n, const value_type& value, const allocator_type& a);
+    template <class Iter>
+        list(Iter first, Iter last);
+    template <class Iter>
+        list(Iter first, Iter last, const allocator_type& a);
+    list(const list& x);
+    list(const list&, const allocator_type& a);
+    list(list&& x)
+        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+    list(list&&, const allocator_type& a);
+    list(initializer_list<value_type>);
+    list(initializer_list<value_type>, const allocator_type& a);
+
+    ~list();
+
+    list& operator=(const list& x);
+    list& operator=(list&& x)
+        noexcept(
+             allocator_type::propagate_on_container_move_assignment::value &&
+             is_nothrow_move_assignable<allocator_type>::value);
+    list& operator=(initializer_list<value_type>);
+    template <class Iter>
+        void assign(Iter first, Iter last);
+    void assign(size_type n, const value_type& t);
+    void assign(initializer_list<value_type>);
+
+    allocator_type get_allocator() const noexcept;
+
+    iterator begin() noexcept;
+    const_iterator begin() const noexcept;
+    iterator end() noexcept;
+    const_iterator end() const noexcept;
+    reverse_iterator rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+    reverse_iterator rend() noexcept;
+    const_reverse_iterator rend() const noexcept;
+    const_iterator cbegin() const noexcept;
+    const_iterator cend() const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend() const noexcept;
+
+    reference front();
+    const_reference front() const;
+    reference back();
+    const_reference back() const;
+
+    bool empty() const noexcept;
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+
+    template <class... Args>
+        void emplace_front(Args&&... args);
+    void pop_front();
+    template <class... Args>
+        void emplace_back(Args&&... args);
+    void pop_back();
+    void push_front(const value_type& x);
+    void push_front(value_type&& x);
+    void push_back(const value_type& x);
+    void push_back(value_type&& x);
+    template <class... Args>
+        iterator emplace(const_iterator position, Args&&... args);
+    iterator insert(const_iterator position, const value_type& x);
+    iterator insert(const_iterator position, value_type&& x);
+    iterator insert(const_iterator position, size_type n, const value_type& x);
+    template <class Iter>
+        iterator insert(const_iterator position, Iter first, Iter last);
+    iterator insert(const_iterator position, initializer_list<value_type> il);
+
+    iterator erase(const_iterator position);
+    iterator erase(const_iterator position, const_iterator last);
+
+    void resize(size_type sz);
+    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);
+    void clear() noexcept;
+
+    void splice(const_iterator position, list& x);
+    void splice(const_iterator position, list&& x);
+    void splice(const_iterator position, list& x, const_iterator i);
+    void splice(const_iterator position, list&& x, const_iterator i);
+    void splice(const_iterator position, list& x, const_iterator first,
+                                                  const_iterator last);
+    void splice(const_iterator position, list&& x, const_iterator first,
+                                                  const_iterator last);
+
+    void remove(const value_type& value);
+    template <class Pred> void remove_if(Pred pred);
+    void unique();
+    template <class BinaryPredicate>
+        void unique(BinaryPredicate binary_pred);
+    void merge(list& x);
+    void merge(list&& x);
+    template <class Compare>
+        void merge(list& x, Compare comp);
+    template <class Compare>
+        void merge(list&& x, Compare comp);
+    void sort();
+    template <class Compare>
+        void sort(Compare comp);
+    void reverse() noexcept;
+};
+
+template <class T, class Alloc>
+    bool operator==(const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+    bool operator< (const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+    bool operator!=(const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+    bool operator> (const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+    bool operator>=(const list<T,Alloc>& x, const list<T,Alloc>& y);
+template <class T, class Alloc>
+    bool operator<=(const list<T,Alloc>& x, const list<T,Alloc>& y);
+
+template <class T, class Alloc>
+    void swap(list<T,Alloc>& x, list<T,Alloc>& y)
+         noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+
+#include <memory>
+#include <limits>
+#include <initializer_list>
+#include <iterator>
+#include <algorithm>
+
+#include <__undef_min_max>
+
+#ifdef _LIBCPP_DEBUG
+#   include <__debug>
+#else
+#   define _LIBCPP_ASSERT(x, m) ((void)0)
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _VoidPtr> struct __list_node;
+
+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;
+#else
+        rebind<__list_node<_Tp, _VoidPtr> >::other 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
+
+    pointer __prev_;
+    pointer __next_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_node_base()
+        : __prev_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this))),
+          __next_(static_cast<pointer>(pointer_traits<__base_pointer>::pointer_to(*this)))
+          {}
+};
+
+template <class _Tp, class _VoidPtr>
+struct __list_node
+    : public __list_node_base<_Tp, _VoidPtr>
+{
+    _Tp __value_;
+};
+
+template <class _Tp, class _Alloc> 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
+
+    __node_pointer __ptr_;
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __list_iterator(__node_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) {}
+#endif
+
+
+
+    template<class, class> friend class list;
+    template<class, class> friend class __list_imp;
+    template<class, class> friend class __list_const_iterator;
+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 pointer_traits<pointer>::difference_type difference_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_iterator() _NOEXCEPT : __ptr_(nullptr)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_i(this);
+#endif
+    }
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_iterator(const __list_iterator& __p)
+        : __ptr_(__p.__ptr_)
+    {
+        __get_db()->__iterator_copy(this, &__p);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__list_iterator()
+    {
+        __get_db()->__erase_i(this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_iterator& operator=(const __list_iterator& __p)
+    {
+        if (this != &__p)
+        {
+            __get_db()->__iterator_copy(this, &__p);
+            __ptr_ = __p.__ptr_;
+        }
+        return *this;
+    }
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to dereference a non-dereferenceable list::iterator");
+#endif
+        return __ptr_->__value_;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to dereference a non-dereferenceable list::iterator");
+#endif
+        return pointer_traits<pointer>::pointer_to(__ptr_->__value_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_iterator& operator++()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to increment non-incrementable list::iterator");
+#endif
+        __ptr_ = __ptr_->__next_;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __list_iterator operator++(int) {__list_iterator __t(*this); ++(*this); return __t;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_iterator& operator--()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
+                       "Attempted to decrement non-decrementable list::iterator");
+#endif
+        __ptr_ = __ptr_->__prev_;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __list_iterator operator--(int) {__list_iterator __t(*this); --(*this); return __t;}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __list_iterator& __x, const __list_iterator& __y)
+    {
+        return __x.__ptr_ == __y.__ptr_;
+    }
+    friend _LIBCPP_INLINE_VISIBILITY
+     bool operator!=(const __list_iterator& __x, const __list_iterator& __y)
+        {return !(__x == __y);}
+};
+
+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
+
+    __node_pointer __ptr_;
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __list_const_iterator(__node_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) {}
+#endif
+
+    template<class, class> friend class list;
+    template<class, class> friend class __list_imp;
+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 pointer_traits<pointer>::difference_type difference_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator() _NOEXCEPT : __ptr_(nullptr)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_i(this);
+#endif
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
+        : __ptr_(__p.__ptr_)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__iterator_copy(this, &__p);
+#endif
+    }
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator(const __list_const_iterator& __p)
+        : __ptr_(__p.__ptr_)
+    {
+        __get_db()->__iterator_copy(this, &__p);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__list_const_iterator()
+    {
+        __get_db()->__erase_i(this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator& operator=(const __list_const_iterator& __p)
+    {
+        if (this != &__p)
+        {
+            __get_db()->__iterator_copy(this, &__p);
+            __ptr_ = __p.__ptr_;
+        }
+        return *this;
+    }
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to dereference a non-dereferenceable list::const_iterator");
+#endif
+        return __ptr_->__value_;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to dereference a non-dereferenceable list::iterator");
+#endif
+        return pointer_traits<pointer>::pointer_to(__ptr_->__value_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator& operator++()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
+                       "Attempted to increment non-incrementable list::const_iterator");
+#endif
+        __ptr_ = __ptr_->__next_;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator operator++(int) {__list_const_iterator __t(*this); ++(*this); return __t;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator& operator--()
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        _LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
+                       "Attempted to decrement non-decrementable list::const_iterator");
+#endif
+        __ptr_ = __ptr_->__prev_;
+        return *this;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator operator--(int) {__list_const_iterator __t(*this); --(*this); return __t;}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y)
+    {
+        return __x.__ptr_ == __y.__ptr_;
+    }
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y)
+        {return !(__x == __y);}
+};
+
+template <class _Tp, class _Alloc>
+class __list_imp
+{
+    __list_imp(const __list_imp&);
+    __list_imp& operator=(const __list_imp&);
+protected:
+    typedef _Tp                                                     value_type;
+    typedef _Alloc                                                  allocator_type;
+    typedef allocator_traits<allocator_type>                        __alloc_traits;
+    typedef typename __alloc_traits::size_type                      size_type;
+    typedef typename __alloc_traits::void_pointer                   __void_pointer;
+    typedef __list_iterator<value_type, __void_pointer>             iterator;
+    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 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 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 allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
+
+    __node_base __end_;
+    __compressed_pair<size_type, __node_allocator> __size_alloc_;
+
+    _LIBCPP_INLINE_VISIBILITY
+          size_type& __sz() _NOEXCEPT {return __size_alloc_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+    const size_type& __sz() const _NOEXCEPT
+        {return __size_alloc_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+          __node_allocator& __node_alloc() _NOEXCEPT
+          {return __size_alloc_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const __node_allocator& __node_alloc() const _NOEXCEPT
+        {return __size_alloc_.second();}
+
+    static void __unlink_nodes(__node_pointer __f, __node_pointer __l) _NOEXCEPT;
+
+    __list_imp()
+        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
+    __list_imp(const allocator_type& __a);
+    ~__list_imp();
+    void clear() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT {return __sz() == 0;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator begin() _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return iterator(__end_.__next_, this);
+#else
+        return iterator(__end_.__next_);
+#endif
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const  _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return const_iterator(__end_.__next_, this);
+#else
+        return const_iterator(__end_.__next_);
+#endif
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    iterator end() _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        return iterator(static_cast<__node_pointer>(
+                pointer_traits<__node_base_pointer>::pointer_to(__end_)), this);
+#else
+        return iterator(static_cast<__node_pointer>(
+                      pointer_traits<__node_base_pointer>::pointer_to(__end_)));
+#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);
+#else
+        return const_iterator(static_cast<__node_const_pointer>(
+        pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_))));
+#endif
+    }
+
+    void swap(__list_imp& __c)
+        _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<__node_allocator>::value);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __list_imp& __c)
+        {__copy_assign_alloc(__c, integral_constant<bool,
+                      __node_alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__list_imp& __c)
+        _NOEXCEPT_(
+            !__node_alloc_traits::propagate_on_container_move_assignment::value ||
+            is_nothrow_move_assignable<__node_allocator>::value)
+        {__move_assign_alloc(__c, integral_constant<bool,
+                      __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)
+        {
+            if (__node_alloc() != __c.__node_alloc())
+                clear();
+            __node_alloc() = __c.__node_alloc();
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __list_imp& __c, false_type)
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__list_imp& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
+        {
+            __node_alloc() = _VSTD::move(__c.__node_alloc());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__list_imp& __c, false_type)
+        _NOEXCEPT
+        {}
+};
+
+// Unlink nodes [__f, __l]
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__list_imp<_Tp, _Alloc>::__unlink_nodes(__node_pointer __f, __node_pointer __l)
+    _NOEXCEPT
+{
+    __f->__prev_->__next_ = __l->__next_;
+    __l->__next_->__prev_ = __f->__prev_;
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+__list_imp<_Tp, _Alloc>::__list_imp()
+        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+    : __size_alloc_(0)
+{
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+__list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
+    : __size_alloc_(0, __node_allocator(__a))
+{
+}
+
+template <class _Tp, class _Alloc>
+__list_imp<_Tp, _Alloc>::~__list_imp()
+{
+    clear();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__erase_c(this);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+void
+__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_));
+        __unlink_nodes(__f, __l->__prev_);
+        __sz() = 0;
+        while (__f != __l)
+        {
+            __node_pointer __n = __f;
+            __f = __f->__next_;
+            __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
+            __node_alloc_traits::deallocate(__na, __n, 1);
+        }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __c_node* __c = __get_db()->__find_c_and_lock(this);
+        for (__i_node** __p = __c->end_; __p != __c->beg_; )
+        {
+            --__p;
+            const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
+            if (__i->__ptr_ != __l)
+            {
+                (*__p)->__c_ = nullptr;
+                if (--__c->end_ != __p)
+                    memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+            }
+        }
+        __get_db()->unlock();
+#endif
+    }
+}
+
+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)
+{
+    _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(__sz(), __c.__sz());
+    swap(__end_, __c.__end_);
+    if (__sz() == 0)
+        __end_.__next_ = __end_.__prev_ = static_cast<__node_pointer>(
+                       pointer_traits<__node_base_pointer>::pointer_to(__end_));
+    else
+        __end_.__prev_->__next_ = __end_.__next_->__prev_
+                                = static_cast<__node_pointer>(
+                       pointer_traits<__node_base_pointer>::pointer_to(__end_));
+    if (__c.__sz() == 0)
+        __c.__end_.__next_ = __c.__end_.__prev_
+                           = static_cast<__node_pointer>(
+                       pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
+    else
+        __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_
+                                    = static_cast<__node_pointer>(
+                       pointer_traits<__node_base_pointer>::pointer_to(__c.__end_));
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __libcpp_db* __db = __get_db();
+    __c_node* __cn1 = __db->__find_c_and_lock(this);
+    __c_node* __cn2 = __db->__find_c(&__c);
+    std::swap(__cn1->beg_, __cn2->beg_);
+    std::swap(__cn1->end_, __cn2->end_);
+    std::swap(__cn1->cap_, __cn2->cap_);
+    for (__i_node** __p = __cn1->end_; __p != __cn1->beg_;)
+    {
+        --__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_)))
+        {
+            __cn2->__add(*__p);
+            if (--__cn1->end_ != __p)
+                memmove(__p, __p+1, (__cn1->end_ - __p)*sizeof(__i_node*));
+        }
+        else
+            (*__p)->__c_ = __cn1;
+    }
+    for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
+    {
+        --__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_)))
+        {
+            __cn1->__add(*__p);
+            if (--__cn2->end_ != __p)
+                memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+        }
+        else
+            (*__p)->__c_ = __cn2;
+    }
+    __db->unlock();
+#endif
+}
+
+template <class _Tp, class _Alloc = allocator<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY list
+    : private __list_imp<_Tp, _Alloc>
+{
+    typedef __list_imp<_Tp, _Alloc> base;
+    typedef typename base::__node              __node;
+    typedef typename base::__node_allocator    __node_allocator;
+    typedef typename base::__node_pointer      __node_pointer;
+    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;
+
+public:
+    typedef _Tp                                      value_type;
+    typedef _Alloc                                   allocator_type;
+    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+                  "Invalid allocator::value_type");
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+    typedef typename base::pointer                   pointer;
+    typedef typename base::const_pointer             const_pointer;
+    typedef typename base::size_type                 size_type;
+    typedef typename base::difference_type           difference_type;
+    typedef typename base::iterator                  iterator;
+    typedef typename base::const_iterator            const_iterator;
+    typedef _VSTD::reverse_iterator<iterator>         reverse_iterator;
+    typedef _VSTD::reverse_iterator<const_iterator>   const_reverse_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    list()
+        _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_c(this);
+#endif
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    explicit list(const allocator_type& __a) : base(__a)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_c(this);
+#endif
+    }
+    explicit list(size_type __n);
+#if _LIBCPP_STD_VER > 11
+    explicit list(size_type __n, const allocator_type& __a);
+#endif
+    list(size_type __n, const value_type& __x);
+    list(size_type __n, const value_type& __x, const allocator_type& __a);
+    template <class _InpIter>
+        list(_InpIter __f, _InpIter __l,
+             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+    template <class _InpIter>
+        list(_InpIter __f, _InpIter __l, const allocator_type& __a,
+             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+
+    list(const list& __c);
+    list(const list& __c, const allocator_type& __a);
+    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
+    list(list&& __c)
+        _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
+    list(list&& __c, const allocator_type& __a);
+    list& operator=(list&& __c)
+        _NOEXCEPT_(
+            __node_alloc_traits::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<__node_allocator>::value);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    list& operator=(initializer_list<value_type> __il)
+        {assign(__il.begin(), __il.end()); return *this;}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template <class _InpIter>
+        void assign(_InpIter __f, _InpIter __l,
+             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+    void assign(size_type __n, const value_type& __x);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    void assign(initializer_list<value_type> __il)
+        {assign(__il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    allocator_type get_allocator() const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT     {return base::__sz();}
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT         {return base::empty();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT
+        {return numeric_limits<difference_type>::max();}
+
+    _LIBCPP_INLINE_VISIBILITY
+          iterator begin() _NOEXCEPT        {return base::begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const _NOEXCEPT {return base::begin();}
+    _LIBCPP_INLINE_VISIBILITY
+          iterator end() _NOEXCEPT          {return base::end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const _NOEXCEPT {return base::end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return base::begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend()   const _NOEXCEPT {return base::end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rbegin() _NOEXCEPT
+            {return       reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin()  const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rend() _NOEXCEPT
+            {return       reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend()    const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend()   const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference front()
+    {
+        _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
+        return base::__end_.__next_->__value_;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference front() const
+    {
+        _LIBCPP_ASSERT(!empty(), "list::front called on empty list");
+        return base::__end_.__next_->__value_;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    reference back()
+    {
+        _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
+        return base::__end_.__prev_->__value_;
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference back() const
+    {
+        _LIBCPP_ASSERT(!empty(), "list::back called on empty list");
+        return base::__end_.__prev_->__value_;
+    }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void push_front(value_type&& __x);
+    void push_back(value_type&& __x);
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args>
+       void emplace_front(_Args&&... __args);
+    template <class... _Args>
+        void emplace_back(_Args&&... __args);
+    template <class... _Args>
+        iterator emplace(const_iterator __p, _Args&&... __args);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+    iterator insert(const_iterator __p, value_type&& __x);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    void push_front(const value_type& __x);
+    void push_back(const value_type& __x);
+
+    iterator insert(const_iterator __p, const value_type& __x);
+    iterator insert(const_iterator __p, size_type __n, const value_type& __x);
+    template <class _InpIter>
+        iterator insert(const_iterator __p, _InpIter __f, _InpIter __l,
+             typename enable_if<__is_input_iterator<_InpIter>::value>::type* = 0);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, initializer_list<value_type> __il)
+        {return insert(__p, __il.begin(), __il.end());}
+#endif   // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(list& __c)
+        _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<__node_allocator>::value)
+        {base::swap(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {base::clear();}
+
+    void pop_front();
+    void pop_back();
+
+    iterator erase(const_iterator __p);
+    iterator erase(const_iterator __f, const_iterator __l);
+
+    void resize(size_type __n);
+    void resize(size_type __n, const value_type& __x);
+
+    void splice(const_iterator __p, list& __c);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void splice(const_iterator __p, list&& __c) {splice(__p, __c);}
+#endif
+    void splice(const_iterator __p, list& __c, const_iterator __i);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void splice(const_iterator __p, list&& __c, const_iterator __i)
+        {splice(__p, __c, __i);}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l)
+        {splice(__p, __c, __f, __l);}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    void remove(const value_type& __x);
+    template <class _Pred> void remove_if(_Pred __pred);
+    void unique();
+    template <class _BinaryPred>
+        void unique(_BinaryPred __binary_pred);
+    void merge(list& __c);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void merge(list&& __c) {merge(__c);}
+#endif
+    template <class _Comp>
+        void merge(list& __c, _Comp __comp);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Comp>
+    _LIBCPP_INLINE_VISIBILITY
+        void merge(list&& __c, _Comp __comp) {merge(__c, __comp);}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void sort();
+    template <class _Comp>
+        void sort(_Comp __comp);
+
+    void reverse() _NOEXCEPT;
+
+    bool __invariants() const;
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const;
+    bool __decrementable(const const_iterator* __i) const;
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+private:
+    static void __link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l);
+    iterator __iterator(size_type __n);
+    template <class _Comp>
+        static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
+
+    void __move_assign(list& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);
+    void __move_assign(list& __c, false_type);
+};
+
+// Link in nodes [__f, __l] just prior to __p
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l)
+{
+    __p->__prev_->__next_ = __f;
+    __f->__prev_ = __p->__prev_;
+    __p->__prev_ = __l;
+    __l->__next_ = __p;
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::__iterator(size_type __n)
+{
+    return __n <= base::__sz() / 2 ? _VSTD::next(begin(), __n)
+                                   : _VSTD::prev(end(), base::__sz() - __n);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(size_type __n)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __n > 0; --__n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        emplace_back();
+#else
+        push_back(value_type());
+#endif
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __n > 0; --__n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        emplace_back();
+#else
+        push_back(value_type());
+#endif
+}
+#endif
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(size_type __n, const value_type& __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __n > 0; --__n)
+        push_back(__x);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(size_type __n, const value_type& __x, const allocator_type& __a)
+    : base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __n > 0; --__n)
+        push_back(__x);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
+                        typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __f != __l; ++__f)
+        push_back(*__f);
+}
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
+                        typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+    : base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __f != __l; ++__f)
+        push_back(*__f);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(const list& __c)
+    : base(allocator_type(
+           __node_alloc_traits::select_on_container_copy_construction(
+                __c.__node_alloc())))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
+        push_back(*__i);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(const list& __c, const allocator_type& __a)
+    : base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
+        push_back(*__i);
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)
+    : base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
+            __e = __il.end(); __i != __e; ++__i)
+        push_back(*__i);
+}
+
+template <class _Tp, class _Alloc>
+list<_Tp, _Alloc>::list(initializer_list<value_type> __il)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (typename initializer_list<value_type>::const_iterator __i = __il.begin(),
+            __e = __il.end(); __i != __e; ++__i)
+        push_back(*__i);
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+list<_Tp, _Alloc>&
+list<_Tp, _Alloc>::operator=(const list& __c)
+{
+    if (this != &__c)
+    {
+        base::__copy_assign_alloc(__c);
+        assign(__c.begin(), __c.end());
+    }
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+list<_Tp, _Alloc>::list(list&& __c)
+    _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
+    : base(allocator_type(_VSTD::move(__c.__node_alloc())))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    splice(end(), __c);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a)
+    : base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__a == __c.get_allocator())
+        splice(end(), __c);
+    else
+    {
+        typedef move_iterator<iterator> _Ip;
+        assign(_Ip(__c.begin()), _Ip(__c.end()));
+    }
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+list<_Tp, _Alloc>&
+list<_Tp, _Alloc>::operator=(list&& __c)
+        _NOEXCEPT_(
+            __node_alloc_traits::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<__node_allocator>::value)
+{
+    __move_assign(__c, integral_constant<bool,
+          __node_alloc_traits::propagate_on_container_move_assignment::value>());
+    return *this;
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::__move_assign(list& __c, false_type)
+{
+    if (base::__node_alloc() != __c.__node_alloc())
+    {
+        typedef move_iterator<iterator> _Ip;
+        assign(_Ip(__c.begin()), _Ip(__c.end()));
+    }
+    else
+        __move_assign(__c, true_type());
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::__move_assign(list& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
+{
+    clear();
+    base::__move_assign_alloc(__c);
+    splice(end(), __c);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+void
+list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
+                          typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+{
+    iterator __i = begin();
+    iterator __e = end();
+    for (; __f != __l && __i != __e; ++__f, ++__i)
+        *__i = *__f;
+    if (__i == __e)
+        insert(__e, __f, __l);
+    else
+        erase(__i, __e);
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
+{
+    iterator __i = begin();
+    iterator __e = end();
+    for (; __n > 0 && __i != __e; --__n, ++__i)
+        *__i = __x;
+    if (__i == __e)
+        insert(__e, __n, __x);
+    else
+        erase(__i, __e);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+_Alloc
+list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT
+{
+    return allocator_type(base::__node_alloc());
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::insert(iterator, x) called with an iterator not"
+        " referring to this list");
+#endif
+    __node_allocator& __na = base::__node_alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    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());
+    ++base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(__hold.release(), this);
+#else
+    return iterator(__hold.release());
+#endif
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::insert(iterator, n, x) called with an iterator not"
+        " referring to this list");
+    iterator __r(__p.__ptr_, this);
+#else
+    iterator __r(__p.__ptr_);
+#endif
+    if (__n > 0)
+    {
+        size_type __ds = 0;
+        __node_allocator& __na = base::__node_alloc();
+        typedef __allocator_destructor<__node_allocator> _Dp;
+        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);
+        ++__ds;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __r = iterator(__hold.get(), this);
+#else
+        __r = iterator(__hold.get());
+#endif
+        __hold.release();
+        iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (--__n; __n != 0; --__n, ++__e, ++__ds)
+            {
+                __hold.reset(__node_alloc_traits::allocate(__na, 1));
+                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+                __e.__ptr_->__next_ = __hold.get();
+                __hold->__prev_ = __e.__ptr_;
+                __hold.release();
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (true)
+            {
+                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+                __node_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                if (__prev == 0)
+                    break;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+                __e = iterator(__prev, this);
+#else
+                __e = iterator(__prev);
+#endif
+            }
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
+        base::__sz() += __ds;
+    }
+    return __r;
+}
+
+template <class _Tp, class _Alloc>
+template <class _InpIter>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
+             typename enable_if<__is_input_iterator<_InpIter>::value>::type*)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::insert(iterator, range) called with an iterator not"
+        " referring to this list");
+    iterator __r(__p.__ptr_, this);
+#else
+    iterator __r(__p.__ptr_);
+#endif
+    if (__f != __l)
+    {
+        size_type __ds = 0;
+        __node_allocator& __na = base::__node_alloc();
+        typedef __allocator_destructor<__node_allocator> _Dp;
+        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_), *__f);
+        ++__ds;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __r = iterator(__hold.get(), this);
+#else
+        __r = iterator(__hold.get());
+#endif
+        __hold.release();
+        iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (++__f; __f != __l; ++__f, ++__e, ++__ds)
+            {
+                __hold.reset(__node_alloc_traits::allocate(__na, 1));
+                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
+                __e.__ptr_->__next_ = __hold.get();
+                __hold->__prev_ = __e.__ptr_;
+                __hold.release();
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (true)
+            {
+                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+                __node_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                if (__prev == 0)
+                    break;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+                __e = iterator(__prev, this);
+#else
+                __e = iterator(__prev);
+#endif
+            }
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
+        base::__sz() += __ds;
+    }
+    return __r;
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_front(const value_type& __x)
+{
+    __node_allocator& __na = base::__node_alloc();
+    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(base::__end_.__next_, __hold.get(), __hold.get());
+    ++base::__sz();
+    __hold.release();
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_back(const value_type& __x)
+{
+    __node_allocator& __na = base::__node_alloc();
+    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(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
+                         pointer_to(base::__end_)), __hold.get(), __hold.get());
+    ++base::__sz();
+    __hold.release();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_front(value_type&& __x)
+{
+    __node_allocator& __na = base::__node_alloc();
+    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(base::__end_.__next_, __hold.get(), __hold.get());
+    ++base::__sz();
+    __hold.release();
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::push_back(value_type&& __x)
+{
+    __node_allocator& __na = base::__node_alloc();
+    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(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
+                         pointer_to(base::__end_)), __hold.get(), __hold.get());
+    ++base::__sz();
+    __hold.release();
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+void
+list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
+{
+    __node_allocator& __na = base::__node_alloc();
+    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(base::__end_.__next_, __hold.get(), __hold.get());
+    ++base::__sz();
+    __hold.release();
+}
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+void
+list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
+{
+    __node_allocator& __na = base::__node_alloc();
+    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(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
+                         pointer_to(base::__end_)), __hold.get(), __hold.get());
+    ++base::__sz();
+    __hold.release();
+}
+
+template <class _Tp, class _Alloc>
+template <class... _Args>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::emplace(iterator, args...) called with an iterator not"
+        " referring to this list");
+#endif
+    __node_allocator& __na = base::__node_alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    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());
+    ++base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(__hold.release(), this);
+#else
+    return iterator(__hold.release());
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::insert(iterator, x) called with an iterator not"
+        " referring to this list");
+#endif
+    __node_allocator& __na = base::__node_alloc();
+    typedef __allocator_destructor<__node_allocator> _Dp;
+    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());
+    ++base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(__hold.release(), this);
+#else
+    return iterator(__hold.release());
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Alloc>
+void
+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_;
+    base::__unlink_nodes(__n, __n);
+    --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __c_node* __c = __get_db()->__find_c_and_lock(this);
+    for (__i_node** __p = __c->end_; __p != __c->beg_; )
+    {
+        --__p;
+        iterator* __i = static_cast<iterator*>((*__p)->__i_);
+        if (__i->__ptr_ == __n)
+        {
+            (*__p)->__c_ = nullptr;
+            if (--__c->end_ != __p)
+                memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+        }
+    }
+    __get_db()->unlock();
+#endif
+    __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
+    __node_alloc_traits::deallocate(__na, __n, 1);
+}
+
+template <class _Tp, class _Alloc>
+void
+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_;
+    base::__unlink_nodes(__n, __n);
+    --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __c_node* __c = __get_db()->__find_c_and_lock(this);
+    for (__i_node** __p = __c->end_; __p != __c->beg_; )
+    {
+        --__p;
+        iterator* __i = static_cast<iterator*>((*__p)->__i_);
+        if (__i->__ptr_ == __n)
+        {
+            (*__p)->__c_ = nullptr;
+            if (--__c->end_ != __p)
+                memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+        }
+    }
+    __get_db()->unlock();
+#endif
+    __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
+    __node_alloc_traits::deallocate(__na, __n, 1);
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::erase(const_iterator __p)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::erase(iterator) called with an iterator not"
+        " referring to this list");
+#endif
+    _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_;
+    base::__unlink_nodes(__n, __n);
+    --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __c_node* __c = __get_db()->__find_c_and_lock(this);
+    for (__i_node** __p = __c->end_; __p != __c->beg_; )
+    {
+        --__p;
+        iterator* __i = static_cast<iterator*>((*__p)->__i_);
+        if (__i->__ptr_ == __n)
+        {
+            (*__p)->__c_ = nullptr;
+            if (--__c->end_ != __p)
+                memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+        }
+    }
+    __get_db()->unlock();
+#endif
+    __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
+    __node_alloc_traits::deallocate(__na, __n, 1);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(__r, this);
+#else
+    return iterator(__r);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,
+        "list::erase(iterator, iterator) called with an iterator not"
+        " referring to this list");
+#endif
+    if (__f != __l)
+    {
+        __node_allocator& __na = base::__node_alloc();
+        base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
+        while (__f != __l)
+        {
+            __node_pointer __n = __f.__ptr_;
+            ++__f;
+            --base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            __c_node* __c = __get_db()->__find_c_and_lock(this);
+            for (__i_node** __p = __c->end_; __p != __c->beg_; )
+            {
+                --__p;
+                iterator* __i = static_cast<iterator*>((*__p)->__i_);
+                if (__i->__ptr_ == __n)
+                {
+                    (*__p)->__c_ = nullptr;
+                    if (--__c->end_ != __p)
+                        memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+                }
+            }
+            __get_db()->unlock();
+#endif
+            __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_));
+            __node_alloc_traits::deallocate(__na, __n, 1);
+        }
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(__l.__ptr_, this);
+#else
+    return iterator(__l.__ptr_);
+#endif
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::resize(size_type __n)
+{
+    if (__n < base::__sz())
+        erase(__iterator(__n), end());
+    else if (__n > base::__sz())
+    {
+        __n -= base::__sz();
+        size_type __ds = 0;
+        __node_allocator& __na = base::__node_alloc();
+        typedef __allocator_destructor<__node_allocator> _Dp;
+        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_));
+        ++__ds;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        iterator __r = iterator(__hold.release(), this);
+#else
+        iterator __r = iterator(__hold.release());
+#endif
+        iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (--__n; __n != 0; --__n, ++__e, ++__ds)
+            {
+                __hold.reset(__node_alloc_traits::allocate(__na, 1));
+                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
+                __e.__ptr_->__next_ = __hold.get();
+                __hold->__prev_ = __e.__ptr_;
+                __hold.release();
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (true)
+            {
+                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+                __node_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                if (__prev == 0)
+                    break;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+                __e = iterator(__prev, this);
+#else
+                __e = iterator(__prev);
+#endif
+            }
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
+                         pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
+        base::__sz() += __ds;
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
+{
+    if (__n < base::__sz())
+        erase(__iterator(__n), end());
+    else if (__n > base::__sz())
+    {
+        __n -= base::__sz();
+        size_type __ds = 0;
+        __node_allocator& __na = base::__node_alloc();
+        typedef __allocator_destructor<__node_allocator> _Dp;
+        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);
+        ++__ds;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        iterator __r = iterator(__hold.release(), this);
+#else
+        iterator __r = iterator(__hold.release());
+#endif
+        iterator __e = __r;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (--__n; __n != 0; --__n, ++__e, ++__ds)
+            {
+                __hold.reset(__node_alloc_traits::allocate(__na, 1));
+                __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
+                __e.__ptr_->__next_ = __hold.get();
+                __hold->__prev_ = __e.__ptr_;
+                __hold.release();
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            while (true)
+            {
+                __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e));
+                __node_pointer __prev = __e.__ptr_->__prev_;
+                __node_alloc_traits::deallocate(__na, __e.__ptr_, 1);
+                if (__prev == 0)
+                    break;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+                __e = iterator(__prev, this);
+#else
+                __e = iterator(__prev);
+#endif
+            }
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>::
+                         pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_);
+        base::__sz() += __ds;
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
+{
+    _LIBCPP_ASSERT(this != &__c,
+                   "list::splice(iterator, list) called with this == &list");
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::splice(iterator, list) called with an iterator not"
+        " referring to this list");
+#endif
+    if (!__c.empty())
+    {
+        __node_pointer __f = __c.__end_.__next_;
+        __node_pointer __l = __c.__end_.__prev_;
+        base::__unlink_nodes(__f, __l);
+        __link_nodes(__p.__ptr_, __f, __l);
+        base::__sz() += __c.__sz();
+        __c.__sz() = 0;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __libcpp_db* __db = __get_db();
+        __c_node* __cn1 = __db->__find_c_and_lock(this);
+        __c_node* __cn2 = __db->__find_c(&__c);
+        for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
+        {
+            --__p;
+            iterator* __i = static_cast<iterator*>((*__p)->__i_);
+            if (__i->__ptr_ != static_cast<__node_pointer>(
+                       pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
+            {
+                __cn1->__add(*__p);
+                (*__p)->__c_ = __cn1;
+                if (--__cn2->end_ != __p)
+                    memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+            }
+        }
+        __db->unlock();
+#endif
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::splice(iterator, list, iterator) called with first iterator not"
+        " referring to this list");
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__i) == &__c,
+        "list::splice(iterator, list, iterator) called with second iterator not"
+        " referring to list argument");
+    _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i),
+        "list::splice(iterator, list, iterator) called with second iterator not"
+        " derefereceable");
+#endif
+    if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_)
+    {
+        __node_pointer __f = __i.__ptr_;
+        base::__unlink_nodes(__f, __f);
+        __link_nodes(__p.__ptr_, __f, __f);
+        --__c.__sz();
+        ++base::__sz();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __libcpp_db* __db = __get_db();
+        __c_node* __cn1 = __db->__find_c_and_lock(this);
+        __c_node* __cn2 = __db->__find_c(&__c);
+        for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
+        {
+            --__p;
+            iterator* __j = static_cast<iterator*>((*__p)->__i_);
+            if (__j->__ptr_ == __f)
+            {
+                __cn1->__add(*__p);
+                (*__p)->__c_ = __cn1;
+                if (--__cn2->end_ != __p)
+                    memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+            }
+        }
+        __db->unlock();
+#endif
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+        "list::splice(iterator, list, iterator, iterator) called with first iterator not"
+        " referring to this list");
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == &__c,
+        "list::splice(iterator, list, iterator, iterator) called with second iterator not"
+        " referring to list argument");
+    if (this == &__c)
+    {
+        for (const_iterator __i = __f; __i != __l; ++__i)
+            _LIBCPP_ASSERT(__i != __p,
+                           "list::splice(iterator, list, iterator, iterator)"
+                           " called with the first iterator within the range"
+                           " of the second and third iterators");
+    }
+#endif
+    if (__f != __l)
+    {
+        if (this != &__c)
+        {
+            size_type __s = _VSTD::distance(__f, __l);
+            __c.__sz() -= __s;
+            base::__sz() += __s;
+        }
+        __node_pointer __first = __f.__ptr_;
+        --__l;
+        __node_pointer __last = __l.__ptr_;
+        base::__unlink_nodes(__first, __last);
+        __link_nodes(__p.__ptr_, __first, __last);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __libcpp_db* __db = __get_db();
+        __c_node* __cn1 = __db->__find_c_and_lock(this);
+        __c_node* __cn2 = __db->__find_c(&__c);
+        for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
+        {
+            --__p;
+            iterator* __j = static_cast<iterator*>((*__p)->__i_);
+            for (__node_pointer __k = __f.__ptr_;
+                                          __k != __l.__ptr_; __k = __k->__next_)
+            {
+                if (__j->__ptr_ == __k)
+                {
+                    __cn1->__add(*__p);
+                    (*__p)->__c_ = __cn1;
+                    if (--__cn2->end_ != __p)
+                        memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+                }
+            }
+        }
+        __db->unlock();
+#endif
+    }
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::remove(const value_type& __x)
+{
+    for (iterator __i = begin(), __e = end(); __i != __e;)
+    {
+        if (*__i == __x)
+        {
+            iterator __j = _VSTD::next(__i);
+            for (; __j != __e && *__j == __x; ++__j)
+                ;
+            __i = erase(__i, __j);
+        }
+        else
+            ++__i;
+    }
+}
+
+template <class _Tp, class _Alloc>
+template <class _Pred>
+void
+list<_Tp, _Alloc>::remove_if(_Pred __pred)
+{
+    for (iterator __i = begin(), __e = end(); __i != __e;)
+    {
+        if (__pred(*__i))
+        {
+            iterator __j = _VSTD::next(__i);
+            for (; __j != __e && __pred(*__j); ++__j)
+                ;
+            __i = erase(__i, __j);
+        }
+        else
+            ++__i;
+    }
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+list<_Tp, _Alloc>::unique()
+{
+    unique(__equal_to<value_type>());
+}
+
+template <class _Tp, class _Alloc>
+template <class _BinaryPred>
+void
+list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
+{
+    for (iterator __i = begin(), __e = end(); __i != __e;)
+    {
+        iterator __j = _VSTD::next(__i);
+        for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
+            ;
+        if (++__i != __j)
+            __i = erase(__i, __j);
+    }
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+list<_Tp, _Alloc>::merge(list& __c)
+{
+    merge(__c, __less<value_type>());
+}
+
+template <class _Tp, class _Alloc>
+template <class _Comp>
+void
+list<_Tp, _Alloc>::merge(list& __c, _Comp __comp)
+{
+    if (this != &__c)
+    {
+        iterator __f1 = begin();
+        iterator __e1 = end();
+        iterator __f2 = __c.begin();
+        iterator __e2 = __c.end();
+        while (__f1 != __e1 && __f2 != __e2)
+        {
+            if (__comp(*__f2, *__f1))
+            {
+                size_type __ds = 1;
+                iterator __m2 = _VSTD::next(__f2);
+                for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, ++__ds)
+                    ;
+                base::__sz() += __ds;
+                __c.__sz() -= __ds;
+                __node_pointer __f = __f2.__ptr_;
+                __node_pointer __l = __m2.__ptr_->__prev_;
+                __f2 = __m2;
+                base::__unlink_nodes(__f, __l);
+                __m2 = _VSTD::next(__f1);
+                __link_nodes(__f1.__ptr_, __f, __l);
+                __f1 = __m2;
+            }
+            else
+                ++__f1;
+        }
+        splice(__e1, __c);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __libcpp_db* __db = __get_db();
+        __c_node* __cn1 = __db->__find_c_and_lock(this);
+        __c_node* __cn2 = __db->__find_c(&__c);
+        for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;)
+        {
+            --__p;
+            iterator* __i = static_cast<iterator*>((*__p)->__i_);
+            if (__i->__ptr_ != static_cast<__node_pointer>(
+                       pointer_traits<__node_base_pointer>::pointer_to(__c.__end_)))
+            {
+                __cn1->__add(*__p);
+                (*__p)->__c_ = __cn1;
+                if (--__cn2->end_ != __p)
+                    memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*));
+            }
+        }
+        __db->unlock();
+#endif
+    }
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+list<_Tp, _Alloc>::sort()
+{
+    sort(__less<value_type>());
+}
+
+template <class _Tp, class _Alloc>
+template <class _Comp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+list<_Tp, _Alloc>::sort(_Comp __comp)
+{
+    __sort(begin(), end(), base::__sz(), __comp);
+}
+
+template <class _Tp, class _Alloc>
+template <class _Comp>
+typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp)
+{
+    switch (__n)
+    {
+    case 0:
+    case 1:
+        return __f1;
+    case 2:
+        if (__comp(*--__e2, *__f1))
+        {
+            __node_pointer __f = __e2.__ptr_;
+            base::__unlink_nodes(__f, __f);
+            __link_nodes(__f1.__ptr_, __f, __f);
+            return __e2;
+        }
+        return __f1;
+    }
+    size_type __n2 = __n / 2;
+    iterator __e1 = _VSTD::next(__f1, __n2);
+    iterator  __r = __f1 = __sort(__f1, __e1, __n2, __comp);
+    iterator __f2 = __e1 = __sort(__e1, __e2, __n - __n2, __comp);
+    if (__comp(*__f2, *__f1))
+    {
+        iterator __m2 = _VSTD::next(__f2);
+        for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
+            ;
+        __node_pointer __f = __f2.__ptr_;
+        __node_pointer __l = __m2.__ptr_->__prev_;
+        __r = __f2;
+        __e1 = __f2 = __m2;
+        base::__unlink_nodes(__f, __l);
+        __m2 = _VSTD::next(__f1);
+        __link_nodes(__f1.__ptr_, __f, __l);
+        __f1 = __m2;
+    }
+    else
+        ++__f1;
+    while (__f1 != __e1 && __f2 != __e2)
+    {
+        if (__comp(*__f2, *__f1))
+        {
+            iterator __m2 = _VSTD::next(__f2);
+            for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2)
+                ;
+            __node_pointer __f = __f2.__ptr_;
+            __node_pointer __l = __m2.__ptr_->__prev_;
+            if (__e1 == __f2)
+                __e1 = __m2;
+            __f2 = __m2;
+            base::__unlink_nodes(__f, __l);
+            __m2 = _VSTD::next(__f1);
+            __link_nodes(__f1.__ptr_, __f, __l);
+            __f1 = __m2;
+        }
+        else
+            ++__f1;
+    }
+    return __r;
+}
+
+template <class _Tp, class _Alloc>
+void
+list<_Tp, _Alloc>::reverse() _NOEXCEPT
+{
+    if (base::__sz() > 1)
+    {
+        iterator __e = end();
+        for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;)
+        {
+            _VSTD::swap(__i.__ptr_->__prev_, __i.__ptr_->__next_);
+            __i.__ptr_ = __i.__ptr_->__prev_;
+        }
+        _VSTD::swap(__e.__ptr_->__prev_, __e.__ptr_->__next_);
+    }
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__invariants() const
+{
+    return size() == _VSTD::distance(begin(), end());
+}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+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_)));
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__decrementable(const const_iterator* __i) const
+{
+    return !empty() &&  __i->__ptr_ != base::__end_.__next_;
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__addable(const const_iterator* __i, ptrdiff_t __n) const
+{
+    return false;
+}
+
+template <class _Tp, class _Alloc>
+bool
+list<_Tp, _Alloc>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+{
+    return false;
+}
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_LIST
diff --git a/final/include/locale b/final/include/locale
new file mode 100644
index 0000000..fcff402
--- /dev/null
+++ b/final/include/locale
@@ -0,0 +1,4465 @@
+// -*- C++ -*-
+//===-------------------------- locale ------------------------------------===//
+//
+//                     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_LOCALE
+#define _LIBCPP_LOCALE
+
+/*
+    locale synopsis
+
+namespace std
+{
+
+class locale
+{
+public:
+    // types:
+    class facet;
+    class id;
+
+    typedef int category;
+    static const category // values assigned here are for exposition only
+        none     = 0x000,
+        collate  = 0x010,
+        ctype    = 0x020,
+        monetary = 0x040,
+        numeric  = 0x080,
+        time     = 0x100,
+        messages = 0x200,
+        all = collate | ctype | monetary | numeric | time | messages;
+
+    // construct/copy/destroy:
+    locale() noexcept;
+    locale(const locale& other) noexcept;
+    explicit locale(const char* std_name);
+    explicit locale(const string& std_name);
+    locale(const locale& other, const char* std_name, category);
+    locale(const locale& other, const string& std_name, category);
+    template <class Facet> locale(const locale& other, Facet* f);
+    locale(const locale& other, const locale& one, category);
+
+    ~locale(); // not virtual
+
+    const locale& operator=(const locale& other) noexcept;
+
+    template <class Facet> locale combine(const locale& other) const;
+
+    // locale operations:
+    basic_string<char> name() const;
+    bool operator==(const locale& other) const;
+    bool operator!=(const locale& other) const;
+    template <class charT, class Traits, class Allocator>
+      bool operator()(const basic_string<charT,Traits,Allocator>& s1,
+                      const basic_string<charT,Traits,Allocator>& s2) const;
+
+    // global locale objects:
+    static locale global(const locale&);
+    static const locale& classic();
+};
+
+template <class Facet> const Facet& use_facet(const locale&);
+template <class Facet> bool has_facet(const locale&) noexcept;
+
+// 22.3.3, convenience interfaces:
+template <class charT> bool isspace (charT c, const locale& loc);
+template <class charT> bool isprint (charT c, const locale& loc);
+template <class charT> bool iscntrl (charT c, const locale& loc);
+template <class charT> bool isupper (charT c, const locale& loc);
+template <class charT> bool islower (charT c, const locale& loc);
+template <class charT> bool isalpha (charT c, const locale& loc);
+template <class charT> bool isdigit (charT c, const locale& loc);
+template <class charT> bool ispunct (charT c, const locale& loc);
+template <class charT> bool isxdigit(charT c, const locale& loc);
+template <class charT> bool isalnum (charT c, const locale& loc);
+template <class charT> bool isgraph (charT c, const locale& loc);
+template <class charT> charT toupper(charT c, const locale& loc);
+template <class charT> charT tolower(charT c, const locale& loc);
+
+template<class Codecvt, class Elem = wchar_t,
+         class Wide_alloc = allocator<Elem>,
+         class Byte_alloc = allocator<char>>
+class wstring_convert
+{
+public:
+    typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string;
+    typedef basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
+    typedef typename Codecvt::state_type                      state_type;
+    typedef typename wide_string::traits_type::int_type       int_type;
+
+    explicit wstring_convert(Codecvt* pcvt = new Codecvt);          // explicit in C++14
+    wstring_convert(Codecvt* pcvt, state_type state);
+    explicit wstring_convert(const byte_string& byte_err,           // explicit in C++14
+                    const wide_string& wide_err = wide_string());
+    wstring_convert(const wstring_convert&) = delete;               // C++14
+    wstring_convert & operator=(const wstring_convert &) = delete;  // C++14
+    ~wstring_convert();
+
+    wide_string from_bytes(char byte);
+    wide_string from_bytes(const char* ptr);
+    wide_string from_bytes(const byte_string& str);
+    wide_string from_bytes(const char* first, const char* last);
+
+    byte_string to_bytes(Elem wchar);
+    byte_string to_bytes(const Elem* wptr);
+    byte_string to_bytes(const wide_string& wstr);
+    byte_string to_bytes(const Elem* first, const Elem* last);
+
+    size_t converted() const; // noexcept in C++14
+    state_type state() const;
+};
+
+template <class Codecvt, class Elem = wchar_t, class Tr = char_traits<Elem>>
+class wbuffer_convert
+    : public basic_streambuf<Elem, Tr>
+{
+public:
+    typedef typename Tr::state_type state_type;
+
+    explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
+                    state_type state = state_type());       // explicit in C++14
+    wbuffer_convert(const wbuffer_convert&) = delete;               // C++14
+    wbuffer_convert & operator=(const wbuffer_convert &) = delete;  // C++14
+    ~wbuffer_convert();                                             // C++14
+    
+    streambuf* rdbuf() const;
+    streambuf* rdbuf(streambuf* bytebuf);
+
+    state_type state() const;
+};
+
+// 22.4.1 and 22.4.1.3, ctype:
+class ctype_base;
+template <class charT> class ctype;
+template <> class ctype<char>; // specialization
+template <class charT> class ctype_byname;
+template <> class ctype_byname<char>; // specialization
+
+class codecvt_base;
+template <class internT, class externT, class stateT> class codecvt;
+template <class internT, class externT, class stateT> class codecvt_byname;
+
+// 22.4.2 and 22.4.3, numeric:
+template <class charT, class InputIterator> class num_get;
+template <class charT, class OutputIterator> class num_put;
+template <class charT> class numpunct;
+template <class charT> class numpunct_byname;
+
+// 22.4.4, col lation:
+template <class charT> class collate;
+template <class charT> class collate_byname;
+
+// 22.4.5, date and time:
+class time_base;
+template <class charT, class InputIterator> class time_get;
+template <class charT, class InputIterator> class time_get_byname;
+template <class charT, class OutputIterator> class time_put;
+template <class charT, class OutputIterator> class time_put_byname;
+
+// 22.4.6, money:
+class money_base;
+template <class charT, class InputIterator> class money_get;
+template <class charT, class OutputIterator> class money_put;
+template <class charT, bool Intl> class moneypunct;
+template <class charT, bool Intl> class moneypunct_byname;
+
+// 22.4.7, message retrieval:
+class messages_base;
+template <class charT> class messages;
+template <class charT> class messages_byname;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__locale>
+#include <algorithm>
+#include <memory>
+#include <ios>
+#include <streambuf>
+#include <iterator>
+#include <limits>
+#ifndef __APPLE__
+#include <cstdarg>
+#endif
+#include <cstdlib>
+#include <ctime>
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#include <support/win32/locale_win32.h>
+#elif !defined(__ANDROID__)
+#include <nl_types.h>
+#endif
+
+#ifdef __APPLE__
+#include <Availability.h>
+#endif
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
+#  define _LIBCPP_GET_C_LOCALE 0
+#elif defined(__NetBSD__)
+#  define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
+#else
+#  define _LIBCPP_GET_C_LOCALE __cloc()
+   // Get the C locale object
+   _LIBCPP_FUNC_VIS locale_t __cloc();
+#define __cloc_defined
+#endif
+
+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)
+
+#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
+//  [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
+//  __b will be incremented (visibly), consuming CharT until a match is found
+//  or proved to not exist.  A keyword may be "", in which will match anything.
+//  If one keyword is a prefix of another, and the next CharT in the input
+//  might match another keyword, the algorithm will attempt to find the longest
+//  matching keyword.  If the longer matching keyword ends up not matching, then
+//  no keyword match is found.  If no keyword match is found, __ke is returned
+//  and failbit is set in __err.
+//  Else an iterator pointing to the matching keyword is found.  If more than
+//  one keyword matches, an iterator to the first matching keyword is returned.
+//  If on exit __b == __e, eofbit is set in __err.  If __case_sensitive is false,
+//  __ct is used to force to lower case before comparing characters.
+//  Examples:
+//  Keywords:  "a", "abb"
+//  If the input is "a", the first keyword matches and eofbit is set.
+//  If the input is "abc", no match is found and "ab" are consumed.
+template <class _InputIterator, class _ForwardIterator, class _Ctype>
+_LIBCPP_HIDDEN
+_ForwardIterator
+__scan_keyword(_InputIterator& __b, _InputIterator __e,
+               _ForwardIterator __kb, _ForwardIterator __ke,
+               const _Ctype& __ct, ios_base::iostate& __err,
+               bool __case_sensitive = true)
+{
+    typedef typename iterator_traits<_InputIterator>::value_type _CharT;
+    size_t __nkw = static_cast<size_t>(_VSTD::distance(__kb, __ke));
+    const unsigned char __doesnt_match = '\0';
+    const unsigned char __might_match = '\1';
+    const unsigned char __does_match = '\2';
+    unsigned char __statbuf[100];
+    unsigned char* __status = __statbuf;
+    unique_ptr<unsigned char, void(*)(void*)> __stat_hold(0, free);
+    if (__nkw > sizeof(__statbuf))
+    {
+        __status = (unsigned char*)malloc(__nkw);
+        if (__status == 0)
+            __throw_bad_alloc();
+        __stat_hold.reset(__status);
+    }
+    size_t __n_might_match = __nkw;  // At this point, any keyword might match
+    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)
+    {
+        if (!__ky->empty())
+            *__st = __might_match;
+        else
+        {
+            *__st = __does_match;
+            --__n_might_match;
+            ++__n_does_match;
+        }
+    }
+    // While there might be a match, test keywords against the next CharT
+    for (size_t __indx = 0; __b != __e && __n_might_match > 0; ++__indx)
+    {
+        // Peek at the next CharT but don't consume it
+        _CharT __c = *__b;
+        if (!__case_sensitive)
+            __c = __ct.toupper(__c);
+        bool __consume = false;
+        // For each keyword which might match, see if the __indx character is __c
+        // If a match if found, consume __c
+        // If a match is found, and that is the last character in the keyword,
+        //    then that keyword matches.
+        // 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)
+        {
+            if (*__st == __might_match)
+            {
+                _CharT __kc = (*__ky)[__indx];
+                if (!__case_sensitive)
+                    __kc = __ct.toupper(__kc);
+                if (__c == __kc)
+                {
+                    __consume = true;
+                    if (__ky->size() == __indx+1)
+                    {
+                        *__st = __does_match;
+                        --__n_might_match;
+                        ++__n_does_match;
+                    }
+                }
+                else
+                {
+                    *__st = __doesnt_match;
+                    --__n_might_match;
+                }
+            }
+        }
+        // consume if we matched a character
+        if (__consume)
+        {
+            ++__b;
+            // If we consumed a character and there might be a matched keyword that
+            //   was marked matched on a previous iteration, then such keywords
+            //   which are now marked as not matching.
+            if (__n_might_match + __n_does_match > 1)
+            {
+                __st = __status;
+                for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, ++__st)
+                {
+                    if (*__st == __does_match && __ky->size() != __indx+1)
+                    {
+                        *__st = __doesnt_match;
+                        --__n_does_match;
+                    }
+                }
+            }
+        }
+    }
+    // We've exited the loop because we hit eof and/or we have no more "might matches".
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    // Return the first matching result
+    for (__st = __status; __kb != __ke; ++__kb, ++__st)
+        if (*__st == __does_match)
+            break;
+    if (__kb == __ke)
+        __err |= ios_base::failbit;
+    return __kb;
+}
+
+struct _LIBCPP_TYPE_VIS __num_get_base
+{
+    static const int __num_get_buf_sz = 40;
+
+    static int __get_base(ios_base&);
+    static const char __src[33];
+};
+
+_LIBCPP_FUNC_VIS
+void __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
+                      ios_base::iostate& __err);
+
+template <class _CharT>
+struct __num_get
+    : protected __num_get_base
+{
+    static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
+    static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
+                                      _CharT& __thousands_sep);
+    static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+                  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+                  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+    static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
+                                   char* __a, char*& __a_end,
+                                   _CharT __decimal_point, _CharT __thousands_sep,
+                                   const string& __grouping, unsigned* __g,
+                                   unsigned*& __g_end, unsigned& __dc, _CharT* __atoms);
+};
+
+template <class _CharT>
+string
+__num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
+{
+    locale __loc = __iob.getloc();
+    use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);
+    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+    __thousands_sep = __np.thousands_sep();
+    return __np.grouping();
+}
+
+template <class _CharT>
+string
+__num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
+                    _CharT& __thousands_sep)
+{
+    locale __loc = __iob.getloc();
+    use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);
+    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
+    __decimal_point = __np.decimal_point();
+    __thousands_sep = __np.thousands_sep();
+    return __np.grouping();
+}
+
+template <class _CharT>
+int
+__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+                  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+                  unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
+{
+    if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
+    {
+        *__a_end++ = __ct == __atoms[24] ? '+' : '-';
+        __dc = 0;
+        return 0;
+    }
+    if (__grouping.size() != 0 && __ct == __thousands_sep)
+    {
+        if (__g_end-__g < __num_get_buf_sz)
+        {
+            *__g_end++ = __dc;
+            __dc = 0;
+        }
+        return 0;
+    }
+    ptrdiff_t __f = find(__atoms, __atoms + 26, __ct) - __atoms;
+    if (__f >= 24)
+        return -1;
+    switch (__base)
+    {
+    case 8:
+    case 10:
+        if (__f >= __base)
+            return -1;
+        break;
+    case 16:
+        if (__f < 22)
+            break;
+        if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0')
+        {
+            __dc = 0;
+            *__a_end++ = __src[__f];
+            return 0;
+        }
+        return -1;
+    }
+    *__a_end++ = __src[__f];
+    ++__dc;
+    return 0;
+}
+
+template <class _CharT>
+int
+__num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp, char* __a, char*& __a_end,
+                    _CharT __decimal_point, _CharT __thousands_sep, const string& __grouping,
+                    unsigned* __g, unsigned*& __g_end, unsigned& __dc, _CharT* __atoms)
+{
+    if (__ct == __decimal_point)
+    {
+        if (!__in_units)
+            return -1;
+        __in_units = false;
+        *__a_end++ = '.';
+        if (__grouping.size() != 0 && __g_end-__g < __num_get_buf_sz)
+            *__g_end++ = __dc;
+        return 0;
+    }
+    if (__ct == __thousands_sep && __grouping.size() != 0)
+    {
+        if (!__in_units)
+            return -1;
+        if (__g_end-__g < __num_get_buf_sz)
+        {
+            *__g_end++ = __dc;
+            __dc = 0;
+        }
+        return 0;
+    }
+    ptrdiff_t __f = find(__atoms, __atoms + 32, __ct) - __atoms;
+    if (__f >= 32)
+        return -1;
+    char __x = __src[__f];
+    if (__x == '-' || __x == '+')
+    {
+        if (__a_end == __a || (__a_end[-1] & 0x5F) == (__exp & 0x7F))
+        {
+            *__a_end++ = __x;
+            return 0;
+        }
+        return -1;
+    }
+    if (__x == 'x' || __x == 'X')
+        __exp = 'P';
+    else if ((__x & 0x5F) == __exp)
+    {
+        __exp |= 0x80;
+        if (__in_units)
+        {
+            __in_units = false;
+            if (__grouping.size() != 0 && __g_end-__g < __num_get_buf_sz)
+                *__g_end++ = __dc;
+        }
+    }
+    *__a_end++ = __x;
+    if (__f >= 22)
+        return 0;
+    ++__dc;
+    return 0;
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<char>)
+_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<wchar_t>)
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY num_get
+    : public locale::facet,
+      private __num_get<_CharT>
+{
+public:
+    typedef _CharT char_type;
+    typedef _InputIterator iter_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit num_get(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, bool& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, long& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, long long& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, unsigned short& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, unsigned int& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, unsigned long& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, unsigned long long& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, float& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, double& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, long double& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, void*& __v) const
+    {
+        return do_get(__b, __e, __iob, __err, __v);
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~num_get() {}
+
+    template <class _Fp>
+    iter_type __do_get_floating_point
+                            (iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, _Fp& __v) const;
+
+    template <class _Signed>
+    iter_type __do_get_signed
+                            (iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, _Signed& __v) const;
+
+    template <class _Unsigned>
+    iter_type __do_get_unsigned
+                            (iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, _Unsigned& __v) const;
+
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, bool& __v) const;
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, long& __v) const
+    { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, long long& __v) const
+    { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, unsigned short& __v) const
+    { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, unsigned int& __v) const
+    { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, unsigned long& __v) const
+    { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, unsigned long long& __v) const
+    { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, float& __v) const
+    { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, double& __v) const
+    { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, long double& __v) const
+    { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); }
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, void*& __v) const;
+};
+
+template <class _CharT, class _InputIterator>
+locale::id
+num_get<_CharT, _InputIterator>::id;
+
+template <class _Tp>
+_Tp
+__num_get_signed_integral(const char* __a, const char* __a_end,
+                          ios_base::iostate& __err, int __base)
+{
+    if (__a != __a_end)
+    {
+        typename remove_reference<decltype(errno)>::type __save_errno = errno;
+        errno = 0;
+        char *__p2;
+        long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+        typename remove_reference<decltype(errno)>::type __current_errno = errno;
+        if (__current_errno == 0)
+            errno = __save_errno;
+        if (__p2 != __a_end)
+        {
+            __err = ios_base::failbit;
+            return 0;
+        }
+        else if (__current_errno == ERANGE         ||
+                 __ll < numeric_limits<_Tp>::min() ||
+                 numeric_limits<_Tp>::max() < __ll)
+        {
+            __err = ios_base::failbit;
+            if (__ll > 0)
+                return numeric_limits<_Tp>::max();
+            else
+                return numeric_limits<_Tp>::min();
+        }
+        return static_cast<_Tp>(__ll);
+    }
+    __err = ios_base::failbit;
+    return 0;
+}
+
+template <class _Tp>
+_Tp
+__num_get_unsigned_integral(const char* __a, const char* __a_end,
+                            ios_base::iostate& __err, int __base)
+{
+    if (__a != __a_end)
+    {
+        if (*__a == '-')
+        {
+            __err = ios_base::failbit;
+            return 0;
+        }
+        typename remove_reference<decltype(errno)>::type __save_errno = errno;
+        errno = 0;
+        char *__p2;
+        unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
+        typename remove_reference<decltype(errno)>::type __current_errno = errno;
+        if (__current_errno == 0)
+            errno = __save_errno;
+        if (__p2 != __a_end)
+        {
+            __err = ios_base::failbit;
+            return 0;
+        }
+        else if (__current_errno == ERANGE ||
+                 numeric_limits<_Tp>::max() < __ll)
+        {
+            __err = ios_base::failbit;
+            return numeric_limits<_Tp>::max();
+        }
+        return static_cast<_Tp>(__ll);
+    }
+    __err = ios_base::failbit;
+    return 0;
+}
+
+template <class _Tp>
+_Tp
+__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
+{
+    if (__a != __a_end)
+    {
+        typename remove_reference<decltype(errno)>::type __save_errno = errno;
+        errno = 0;
+        char *__p2;
+        long double __ld = strtold_l(__a, &__p2, _LIBCPP_GET_C_LOCALE);
+        typename remove_reference<decltype(errno)>::type __current_errno = errno;
+        if (__current_errno == 0)
+            errno = __save_errno;
+        if (__p2 != __a_end)
+        {
+            __err = ios_base::failbit;
+            return 0;
+        }
+        else if (__current_errno == ERANGE)
+            __err = ios_base::failbit;
+        return static_cast<_Tp>(__ld);
+    }
+    __err = ios_base::failbit;
+    return 0;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+                                        ios_base& __iob,
+                                        ios_base::iostate& __err,
+                                        bool& __v) const
+{
+    if ((__iob.flags() & ios_base::boolalpha) == 0)
+    {
+        long __lv = -1;
+        __b = do_get(__b, __e, __iob, __err, __lv);
+        switch (__lv)
+        {
+        case 0:
+            __v = false;
+            break;
+        case 1:
+            __v = true;
+            break;
+        default:
+            __v = true;
+            __err = ios_base::failbit;
+            break;
+        }
+        return __b;
+    }
+    const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__iob.getloc());
+    const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__iob.getloc());
+    typedef typename numpunct<_CharT>::string_type string_type;
+    const string_type __names[2] = {__np.truename(), __np.falsename()};
+    const string_type* __i = __scan_keyword(__b, __e, __names, __names+2,
+                                            __ct, __err);
+    __v = __i == __names;
+    return __b;
+}
+
+// signed
+
+template <class _CharT, class _InputIterator>
+template <class _Signed>
+_InputIterator
+num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e,
+                                        ios_base& __iob,
+                                        ios_base::iostate& __err,
+                                        _Signed& __v) const
+{
+    // Stage 1
+    int __base = this->__get_base(__iob);
+    // Stage 2
+    char_type __atoms[26];
+    char_type __thousands_sep;
+    string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+    string __buf;
+    __buf.resize(__buf.capacity());
+    char* __a = &__buf[0];
+    char* __a_end = __a;
+    unsigned __g[__num_get_base::__num_get_buf_sz];
+    unsigned* __g_end = __g;
+    unsigned __dc = 0;
+    for (; __b != __e; ++__b)
+    {
+        if (__a_end == __a + __buf.size())
+        {
+            size_t __tmp = __buf.size();
+            __buf.resize(2*__buf.size());
+            __buf.resize(__buf.capacity());
+            __a = &__buf[0];
+            __a_end = __a + __tmp;
+        }
+        if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc,
+                                    __thousands_sep, __grouping, __g, __g_end,
+                                    __atoms))
+            break;
+    }
+    if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
+        *__g_end++ = __dc;
+    // Stage 3
+    __v = __num_get_signed_integral<_Signed>(__a, __a_end, __err, __base);
+    // Digit grouping checked
+    __check_grouping(__grouping, __g, __g_end, __err);
+    // EOF checked
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __b;
+}
+
+// unsigned
+
+template <class _CharT, class _InputIterator>
+template <class _Unsigned>
+_InputIterator
+num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e,
+                                        ios_base& __iob,
+                                        ios_base::iostate& __err,
+                                        _Unsigned& __v) const
+{
+    // Stage 1
+    int __base = this->__get_base(__iob);
+    // Stage 2
+    char_type __atoms[26];
+    char_type __thousands_sep;
+    string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+    string __buf;
+    __buf.resize(__buf.capacity());
+    char* __a = &__buf[0];
+    char* __a_end = __a;
+    unsigned __g[__num_get_base::__num_get_buf_sz];
+    unsigned* __g_end = __g;
+    unsigned __dc = 0;
+    for (; __b != __e; ++__b)
+    {
+        if (__a_end == __a + __buf.size())
+        {
+            size_t __tmp = __buf.size();
+            __buf.resize(2*__buf.size());
+            __buf.resize(__buf.capacity());
+            __a = &__buf[0];
+            __a_end = __a + __tmp;
+        }
+        if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc,
+                                    __thousands_sep, __grouping, __g, __g_end,
+                                    __atoms))
+            break;
+    }
+    if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz)
+        *__g_end++ = __dc;
+    // Stage 3
+    __v = __num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base);
+    // Digit grouping checked
+    __check_grouping(__grouping, __g, __g_end, __err);
+    // EOF checked
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __b;
+}
+
+// floating point
+
+template <class _CharT, class _InputIterator>
+template <class _Fp>
+_InputIterator
+num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_type __e,
+                                        ios_base& __iob,
+                                        ios_base::iostate& __err,
+                                        _Fp& __v) const
+{
+    // Stage 1, nothing to do
+    // Stage 2
+    char_type __atoms[32];
+    char_type __decimal_point;
+    char_type __thousands_sep;
+    string __grouping = this->__stage2_float_prep(__iob, __atoms,
+                                                  __decimal_point,
+                                                  __thousands_sep);
+    string __buf;
+    __buf.resize(__buf.capacity());
+    char* __a = &__buf[0];
+    char* __a_end = __a;
+    unsigned __g[__num_get_base::__num_get_buf_sz];
+    unsigned* __g_end = __g;
+    unsigned __dc = 0;
+    bool __in_units = true;
+    char __exp = 'E';
+    for (; __b != __e; ++__b)
+    {
+        if (__a_end == __a + __buf.size())
+        {
+            size_t __tmp = __buf.size();
+            __buf.resize(2*__buf.size());
+            __buf.resize(__buf.capacity());
+            __a = &__buf[0];
+            __a_end = __a + __tmp;
+        }
+        if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end,
+                                      __decimal_point, __thousands_sep,
+                                      __grouping, __g, __g_end,
+                                      __dc, __atoms))
+            break;
+    }
+    if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz)
+        *__g_end++ = __dc;
+    // Stage 3
+    __v = __num_get_float<_Fp>(__a, __a_end, __err);
+    // Digit grouping checked
+    __check_grouping(__grouping, __g, __g_end, __err);
+    // EOF checked
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+                                        ios_base& __iob,
+                                        ios_base::iostate& __err,
+                                        void*& __v) const
+{
+    // Stage 1
+    int __base = 16;
+    // Stage 2
+    char_type __atoms[26];
+    char_type __thousands_sep = 0;
+    string __grouping;
+    use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src,
+                                                    __num_get_base::__src + 26, __atoms);
+    string __buf;
+    __buf.resize(__buf.capacity());
+    char* __a = &__buf[0];
+    char* __a_end = __a;
+    unsigned __g[__num_get_base::__num_get_buf_sz];
+    unsigned* __g_end = __g;
+    unsigned __dc = 0;
+    for (; __b != __e; ++__b)
+    {
+        if (__a_end == __a + __buf.size())
+        {
+            size_t __tmp = __buf.size();
+            __buf.resize(2*__buf.size());
+            __buf.resize(__buf.capacity());
+            __a = &__buf[0];
+            __a_end = __a + __tmp;
+        }
+        if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc,
+                                    __thousands_sep, __grouping,
+                                    __g, __g_end, __atoms))
+            break;
+    }
+    // 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
+        __err = ios_base::failbit;
+    // EOF checked
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __b;
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<wchar_t>)
+
+struct _LIBCPP_TYPE_VIS __num_put_base
+{
+protected:
+    static void __format_int(char* __fmt, const char* __len, bool __signd,
+                             ios_base::fmtflags __flags);
+    static bool __format_float(char* __fmt, const char* __len,
+                               ios_base::fmtflags __flags);
+    static char* __identify_padding(char* __nb, char* __ne,
+                                    const ios_base& __iob);
+};
+
+template <class _CharT>
+struct __num_put
+    : protected __num_put_base
+{
+    static void __widen_and_group_int(char* __nb, char* __np, char* __ne,
+                                      _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+                                      const locale& __loc);
+    static void __widen_and_group_float(char* __nb, char* __np, char* __ne,
+                                        _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+                                        const locale& __loc);
+};
+
+template <class _CharT>
+void
+__num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne,
+                                         _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+                                         const locale& __loc)
+{
+    const ctype<_CharT>&    __ct = use_facet<ctype<_CharT> >   (__loc);
+    const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);
+    string __grouping = __npt.grouping();
+    if (__grouping.empty())
+    {
+        __ct.widen(__nb, __ne, __ob);
+        __oe = __ob + (__ne - __nb);
+    }
+    else
+    {
+        __oe = __ob;
+        char* __nf = __nb;
+        if (*__nf == '-' || *__nf == '+')
+            *__oe++ = __ct.widen(*__nf++);
+        if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' ||
+                                                   __nf[1] == 'X'))
+        {
+            *__oe++ = __ct.widen(*__nf++);
+            *__oe++ = __ct.widen(*__nf++);
+        }
+        reverse(__nf, __ne);
+        _CharT __thousands_sep = __npt.thousands_sep();
+        unsigned __dc = 0;
+        unsigned __dg = 0;
+        for (char* __p = __nf; __p < __ne; ++__p)
+        {
+            if (static_cast<unsigned>(__grouping[__dg]) > 0 &&
+                __dc == static_cast<unsigned>(__grouping[__dg]))
+            {
+                *__oe++ = __thousands_sep;
+                __dc = 0;
+                if (__dg < __grouping.size()-1)
+                    ++__dg;
+            }
+            *__oe++ = __ct.widen(*__p);
+            ++__dc;
+        }
+        reverse(__ob + (__nf - __nb), __oe);
+    }
+    if (__np == __ne)
+        __op = __oe;
+    else
+        __op = __ob + (__np - __nb);
+}
+
+template <class _CharT>
+void
+__num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
+                                           _CharT* __ob, _CharT*& __op, _CharT*& __oe,
+                                           const locale& __loc)
+{
+    const ctype<_CharT>&    __ct = use_facet<ctype<_CharT> >   (__loc);
+    const numpunct<_CharT>& __npt = use_facet<numpunct<_CharT> >(__loc);
+    string __grouping = __npt.grouping();
+    __oe = __ob;
+    char* __nf = __nb;
+    if (*__nf == '-' || *__nf == '+')
+        *__oe++ = __ct.widen(*__nf++);
+    char* __ns;
+    if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' ||
+                                               __nf[1] == 'X'))
+    {
+        *__oe++ = __ct.widen(*__nf++);
+        *__oe++ = __ct.widen(*__nf++);
+        for (__ns = __nf; __ns < __ne; ++__ns)
+            if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
+                break;
+    }
+    else
+    {
+        for (__ns = __nf; __ns < __ne; ++__ns)
+            if (!isdigit_l(*__ns, _LIBCPP_GET_C_LOCALE))
+                break;
+    }
+    if (__grouping.empty())
+    {
+        __ct.widen(__nf, __ns, __oe);
+        __oe += __ns - __nf;
+    }
+    else
+    {
+        reverse(__nf, __ns);
+        _CharT __thousands_sep = __npt.thousands_sep();
+        unsigned __dc = 0;
+        unsigned __dg = 0;
+        for (char* __p = __nf; __p < __ns; ++__p)
+        {
+            if (__grouping[__dg] > 0 && __dc == static_cast<unsigned>(__grouping[__dg]))
+            {
+                *__oe++ = __thousands_sep;
+                __dc = 0;
+                if (__dg < __grouping.size()-1)
+                    ++__dg;
+            }
+            *__oe++ = __ct.widen(*__p);
+            ++__dc;
+        }
+        reverse(__ob + (__nf - __nb), __oe);
+    }
+    for (__nf = __ns; __nf < __ne; ++__nf)
+    {
+        if (*__nf == '.')
+        {
+            *__oe++ = __npt.decimal_point();
+            ++__nf;
+            break;
+        }
+        else
+            *__oe++ = __ct.widen(*__nf);
+    }
+    __ct.widen(__nf, __ne, __oe);
+    __oe += __ne - __nf;
+    if (__np == __ne)
+        __op = __oe;
+    else
+        __op = __ob + (__np - __nb);
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<char>)
+_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<wchar_t>)
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY num_put
+    : public locale::facet,
+      private __num_put<_CharT>
+{
+public:
+    typedef _CharT char_type;
+    typedef _OutputIterator iter_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit num_put(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  bool __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  long __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  long long __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  unsigned long __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  unsigned long long __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  double __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  long double __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  const void* __v) const
+    {
+        return do_put(__s, __iob, __fl, __v);
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~num_put() {}
+
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             bool __v) const;
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             long __v) const;
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             long long __v) const;
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             unsigned long) const;
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             unsigned long long) const;
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             double __v) const;
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             long double __v) const;
+    virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl,
+                             const void* __v) const;
+};
+
+template <class _CharT, class _OutputIterator>
+locale::id
+num_put<_CharT, _OutputIterator>::id;
+
+template <class _CharT, class _OutputIterator>
+_LIBCPP_HIDDEN
+_OutputIterator
+__pad_and_output(_OutputIterator __s,
+                 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
+                 ios_base& __iob, _CharT __fl)
+{
+    streamsize __sz = __oe - __ob;
+    streamsize __ns = __iob.width();
+    if (__ns > __sz)
+        __ns -= __sz;
+    else
+        __ns = 0;
+    for (;__ob < __op; ++__ob, ++__s)
+        *__s = *__ob;
+    for (; __ns; --__ns, ++__s)
+        *__s = __fl;
+    for (; __ob < __oe; ++__ob, ++__s)
+        *__s = *__ob;
+    __iob.width(0);
+    return __s;
+}
+
+#if !defined(__APPLE__) || \
+    (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \
+    (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0)
+
+template <class _CharT, class _Traits>
+_LIBCPP_HIDDEN
+ostreambuf_iterator<_CharT, _Traits>
+__pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s,
+                 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
+                 ios_base& __iob, _CharT __fl)
+{
+    if (__s.__sbuf_ == nullptr)
+        return __s;
+    streamsize __sz = __oe - __ob;
+    streamsize __ns = __iob.width();
+    if (__ns > __sz)
+        __ns -= __sz;
+    else
+        __ns = 0;
+    streamsize __np = __op - __ob;
+    if (__np > 0)
+    {
+        if (__s.__sbuf_->sputn(__ob, __np) != __np)
+        {
+            __s.__sbuf_ = nullptr;
+            return __s;
+        }
+    }
+    if (__ns > 0)
+    {
+        basic_string<_CharT, _Traits> __sp(__ns, __fl);
+        if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns)
+        {
+            __s.__sbuf_ = nullptr;
+            return __s;
+        }
+    }
+    __np = __oe - __op;
+    if (__np > 0)
+    {
+        if (__s.__sbuf_->sputn(__op, __np) != __np)
+        {
+            __s.__sbuf_ = nullptr;
+            return __s;
+        }
+    }
+    __iob.width(0);
+    return __s;
+}
+
+#endif
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, bool __v) const
+{
+    if ((__iob.flags() & ios_base::boolalpha) == 0)
+        return do_put(__s, __iob, __fl, (unsigned long)__v);
+    const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc());
+    typedef typename numpunct<char_type>::string_type string_type;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    string_type __tmp(__v ? __np.truename() : __np.falsename());
+    string_type __nm = _VSTD::move(__tmp);
+#else
+    string_type __nm = __v ? __np.truename() : __np.falsename();
+#endif
+    for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s)
+        *__s = *__i;
+    return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, long __v) const
+{
+    // Stage 1 - Get number in narrow char
+    char __fmt[6] = {'%', 0};
+    const char* __len = "l";
+    this->__format_int(__fmt+1, __len, true, __iob.flags());
+    const unsigned __nbuf = (numeric_limits<long>::digits / 3)
+                          + ((numeric_limits<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
+    char* __ne = __nar + __nc;
+    char* __np = this->__identify_padding(__nar, __ne, __iob);
+    // Stage 2 - Widen __nar while adding thousands separators
+    char_type __o[2*(__nbuf-1) - 1];
+    char_type* __op;  // pad here
+    char_type* __oe;  // end of output
+    this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
+    // [__o, __oe) contains thousands_sep'd wide number
+    // Stage 3 & 4
+    return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, long long __v) const
+{
+    // Stage 1 - Get number in narrow char
+    char __fmt[8] = {'%', 0};
+    const char* __len = "ll";
+    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;
+    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
+    char* __ne = __nar + __nc;
+    char* __np = this->__identify_padding(__nar, __ne, __iob);
+    // Stage 2 - Widen __nar while adding thousands separators
+    char_type __o[2*(__nbuf-1) - 1];
+    char_type* __op;  // pad here
+    char_type* __oe;  // end of output
+    this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
+    // [__o, __oe) contains thousands_sep'd wide number
+    // Stage 3 & 4
+    return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, unsigned long __v) const
+{
+    // Stage 1 - Get number in narrow char
+    char __fmt[6] = {'%', 0};
+    const char* __len = "l";
+    this->__format_int(__fmt+1, __len, false, __iob.flags());
+    const unsigned __nbuf = (numeric_limits<unsigned long>::digits / 3)
+                          + ((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
+    char* __ne = __nar + __nc;
+    char* __np = this->__identify_padding(__nar, __ne, __iob);
+    // Stage 2 - Widen __nar while adding thousands separators
+    char_type __o[2*(__nbuf-1) - 1];
+    char_type* __op;  // pad here
+    char_type* __oe;  // end of output
+    this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
+    // [__o, __oe) contains thousands_sep'd wide number
+    // Stage 3 & 4
+    return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, unsigned long long __v) const
+{
+    // Stage 1 - Get number in narrow char
+    char __fmt[8] = {'%', 0};
+    const char* __len = "ll";
+    this->__format_int(__fmt+1, __len, false, __iob.flags());
+    const unsigned __nbuf = (numeric_limits<unsigned long long>::digits / 3)
+                          + ((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
+    char* __ne = __nar + __nc;
+    char* __np = this->__identify_padding(__nar, __ne, __iob);
+    // Stage 2 - Widen __nar while adding thousands separators
+    char_type __o[2*(__nbuf-1) - 1];
+    char_type* __op;  // pad here
+    char_type* __oe;  // end of output
+    this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
+    // [__o, __oe) contains thousands_sep'd wide number
+    // Stage 3 & 4
+    return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, double __v) const
+{
+    // Stage 1 - Get number in narrow char
+    char __fmt[8] = {'%', 0};
+    const char* __len = "";
+    bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags());
+    const unsigned __nbuf = 30;
+    char __nar[__nbuf];
+    char* __nb = __nar;
+    int __nc;
+    if (__specify_precision)
+#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
+        __nc = 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
+    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
+        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
+        if (__nb == 0)
+            __throw_bad_alloc();
+        __nbh.reset(__nb);
+    }
+    char* __ne = __nb + __nc;
+    char* __np = this->__identify_padding(__nb, __ne, __iob);
+    // Stage 2 - Widen __nar while adding thousands separators
+    char_type __o[2*(__nbuf-1) - 1];
+    char_type* __ob = __o;
+    unique_ptr<char_type, void(*)(void*)> __obh(0, free);
+    if (__nb != __nar)
+    {
+        __ob = (char_type*)malloc(2*static_cast<size_t>(__nc)*sizeof(char_type));
+        if (__ob == 0)
+            __throw_bad_alloc();
+        __obh.reset(__ob);
+    }
+    char_type* __op;  // pad here
+    char_type* __oe;  // end of output
+    this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());
+    // [__o, __oe) contains thousands_sep'd wide number
+    // Stage 3 & 4
+    __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
+    return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, long double __v) const
+{
+    // Stage 1 - Get number in narrow char
+    char __fmt[8] = {'%', 0};
+    const char* __len = "L";
+    bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags());
+    const unsigned __nbuf = 30;
+    char __nar[__nbuf];
+    char* __nb = __nar;
+    int __nc;
+    if (__specify_precision)
+#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
+        __nc = 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
+    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
+        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
+        if (__nb == 0)
+            __throw_bad_alloc();
+        __nbh.reset(__nb);
+    }
+    char* __ne = __nb + __nc;
+    char* __np = this->__identify_padding(__nb, __ne, __iob);
+    // Stage 2 - Widen __nar while adding thousands separators
+    char_type __o[2*(__nbuf-1) - 1];
+    char_type* __ob = __o;
+    unique_ptr<char_type, void(*)(void*)> __obh(0, free);
+    if (__nb != __nar)
+    {
+        __ob = (char_type*)malloc(2*static_cast<size_t>(__nc)*sizeof(char_type));
+        if (__ob == 0)
+            __throw_bad_alloc();
+        __obh.reset(__ob);
+    }
+    char_type* __op;  // pad here
+    char_type* __oe;  // end of output
+    this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());
+    // [__o, __oe) contains thousands_sep'd wide number
+    // Stage 3 & 4
+    __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
+    return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
+                                         char_type __fl, const void* __v) const
+{
+    // Stage 1 - Get pointer in narrow char
+    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
+    char* __ne = __nar + __nc;
+    char* __np = this->__identify_padding(__nar, __ne, __iob);
+    // Stage 2 - Widen __nar
+    char_type __o[2*(__nbuf-1) - 1];
+    char_type* __op;  // pad here
+    char_type* __oe;  // end of output
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+    __ct.widen(__nar, __ne, __o);
+    __oe = __o + (__ne - __nar);
+    if (__np == __ne)
+        __op = __oe;
+    else
+        __op = __o + (__np - __nar);
+    // [__o, __oe) contains wide number
+    // Stage 3 & 4
+    return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<wchar_t>)
+
+template <class _CharT, class _InputIterator>
+_LIBCPP_HIDDEN
+int
+__get_up_to_n_digits(_InputIterator& __b, _InputIterator __e,
+                     ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n)
+{
+    // Precondition:  __n >= 1
+    if (__b == __e)
+    {
+        __err |= ios_base::eofbit | ios_base::failbit;
+        return 0;
+    }
+    // get first digit
+    _CharT __c = *__b;
+    if (!__ct.is(ctype_base::digit, __c))
+    {
+        __err |= ios_base::failbit;
+        return 0;
+    }
+    int __r = __ct.narrow(__c, 0) - '0';
+    for (++__b, --__n; __b != __e && __n > 0; ++__b, --__n)
+    {
+        // get next digit
+        __c = *__b;
+        if (!__ct.is(ctype_base::digit, __c))
+            return __r;
+        __r = __r * 10 + __ct.narrow(__c, 0) - '0';
+    }
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __r;
+}
+
+class _LIBCPP_TYPE_VIS time_base
+{
+public:
+    enum dateorder {no_order, dmy, mdy, ymd, ydm};
+};
+
+template <class _CharT>
+class _LIBCPP_TYPE_VIS_ONLY __time_get_c_storage
+{
+protected:
+    typedef basic_string<_CharT> string_type;
+
+    virtual const string_type* __weeks() const;
+    virtual const string_type* __months() const;
+    virtual const string_type* __am_pm() const;
+    virtual const string_type& __c() const;
+    virtual const string_type& __r() const;
+    virtual const string_type& __x() const;
+    virtual const string_type& __X() const;
+};
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY time_get
+    : public locale::facet,
+      public time_base,
+      private __time_get_c_storage<_CharT>
+{
+public:
+    typedef _CharT                  char_type;
+    typedef _InputIterator          iter_type;
+    typedef time_base::dateorder    dateorder;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit time_get(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    dateorder date_order() const
+    {
+        return this->do_date_order();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get_time(iter_type __b, iter_type __e, ios_base& __iob,
+                       ios_base::iostate& __err, tm* __tm) const
+    {
+        return do_get_time(__b, __e, __iob, __err, __tm);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get_date(iter_type __b, iter_type __e, ios_base& __iob,
+                       ios_base::iostate& __err, tm* __tm) const
+    {
+        return do_get_date(__b, __e, __iob, __err, __tm);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get_weekday(iter_type __b, iter_type __e, ios_base& __iob,
+                          ios_base::iostate& __err, tm* __tm) const
+    {
+        return do_get_weekday(__b, __e, __iob, __err, __tm);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get_monthname(iter_type __b, iter_type __e, ios_base& __iob,
+                            ios_base::iostate& __err, tm* __tm) const
+    {
+        return do_get_monthname(__b, __e, __iob, __err, __tm);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get_year(iter_type __b, iter_type __e, ios_base& __iob,
+                       ios_base::iostate& __err, tm* __tm) const
+    {
+        return do_get_year(__b, __e, __iob, __err, __tm);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, tm *__tm,
+                  char __fmt, char __mod = 0) const
+    {
+        return do_get(__b, __e, __iob, __err, __tm, __fmt, __mod);
+    }
+
+    iter_type get(iter_type __b, iter_type __e, ios_base& __iob,
+                  ios_base::iostate& __err, tm* __tm,
+                  const char_type* __fmtb, const char_type* __fmte) const;
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~time_get() {}
+
+    virtual dateorder do_date_order() const;
+    virtual iter_type do_get_time(iter_type __b, iter_type __e, ios_base& __iob,
+                                  ios_base::iostate& __err, tm* __tm) const;
+    virtual iter_type do_get_date(iter_type __b, iter_type __e, ios_base& __iob,
+                                  ios_base::iostate& __err, tm* __tm) const;
+    virtual iter_type do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob,
+                                     ios_base::iostate& __err, tm* __tm) const;
+    virtual iter_type do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob,
+                                       ios_base::iostate& __err, tm* __tm) const;
+    virtual iter_type do_get_year(iter_type __b, iter_type __e, ios_base& __iob,
+                                  ios_base::iostate& __err, tm* __tm) const;
+    virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob,
+                             ios_base::iostate& __err, tm* __tm,
+                             char __fmt, char __mod) const;
+private:
+    void __get_white_space(iter_type& __b, iter_type __e,
+                           ios_base::iostate& __err, const ctype<char_type>& __ct) const;
+    void __get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err,
+                       const ctype<char_type>& __ct) const;
+
+    void __get_weekdayname(int& __m,
+                           iter_type& __b, iter_type __e,
+                           ios_base::iostate& __err,
+                           const ctype<char_type>& __ct) const;
+    void __get_monthname(int& __m,
+                         iter_type& __b, iter_type __e,
+                         ios_base::iostate& __err,
+                         const ctype<char_type>& __ct) const;
+    void __get_day(int& __d,
+                   iter_type& __b, iter_type __e,
+                   ios_base::iostate& __err,
+                   const ctype<char_type>& __ct) const;
+    void __get_month(int& __m,
+                     iter_type& __b, iter_type __e,
+                     ios_base::iostate& __err,
+                     const ctype<char_type>& __ct) const;
+    void __get_year(int& __y,
+                   iter_type& __b, iter_type __e,
+                   ios_base::iostate& __err,
+                   const ctype<char_type>& __ct) const;
+    void __get_year4(int& __y,
+                    iter_type& __b, iter_type __e,
+                    ios_base::iostate& __err,
+                    const ctype<char_type>& __ct) const;
+    void __get_hour(int& __d,
+                    iter_type& __b, iter_type __e,
+                    ios_base::iostate& __err,
+                    const ctype<char_type>& __ct) const;
+    void __get_12_hour(int& __h,
+                       iter_type& __b, iter_type __e,
+                       ios_base::iostate& __err,
+                       const ctype<char_type>& __ct) const;
+    void __get_am_pm(int& __h,
+                     iter_type& __b, iter_type __e,
+                     ios_base::iostate& __err,
+                     const ctype<char_type>& __ct) const;
+    void __get_minute(int& __m,
+                      iter_type& __b, iter_type __e,
+                      ios_base::iostate& __err,
+                      const ctype<char_type>& __ct) const;
+    void __get_second(int& __s,
+                      iter_type& __b, iter_type __e,
+                      ios_base::iostate& __err,
+                      const ctype<char_type>& __ct) const;
+    void __get_weekday(int& __w,
+                       iter_type& __b, iter_type __e,
+                       ios_base::iostate& __err,
+                       const ctype<char_type>& __ct) const;
+    void __get_day_year_num(int& __w,
+                            iter_type& __b, iter_type __e,
+                            ios_base::iostate& __err,
+                            const ctype<char_type>& __ct) const;
+};
+
+template <class _CharT, class _InputIterator>
+locale::id
+time_get<_CharT, _InputIterator>::id;
+
+// time_get primitives
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_weekdayname(int& __w,
+                                                    iter_type& __b, iter_type __e,
+                                                    ios_base::iostate& __err,
+                                                    const ctype<char_type>& __ct) const
+{
+    // Note:  ignoring case comes from the POSIX strptime spec
+    const string_type* __wk = this->__weeks();
+    ptrdiff_t __i = __scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk;
+    if (__i < 14)
+        __w = __i % 7;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_monthname(int& __m,
+                                                  iter_type& __b, iter_type __e,
+                                                  ios_base::iostate& __err,
+                                                  const ctype<char_type>& __ct) const
+{
+    // Note:  ignoring case comes from the POSIX strptime spec
+    const string_type* __month = this->__months();
+    ptrdiff_t __i = __scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month;
+    if (__i < 24)
+        __m = __i % 12;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_day(int& __d,
+                                            iter_type& __b, iter_type __e,
+                                            ios_base::iostate& __err,
+                                            const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+    if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31)
+        __d = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_month(int& __m,
+                                              iter_type& __b, iter_type __e,
+                                              ios_base::iostate& __err,
+                                              const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
+    if (!(__err & ios_base::failbit) && __t <= 11)
+        __m = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_year(int& __y,
+                                             iter_type& __b, iter_type __e,
+                                             ios_base::iostate& __err,
+                                             const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
+    if (!(__err & ios_base::failbit))
+    {
+        if (__t < 69)
+            __t += 2000;
+        else if (69 <= __t && __t <= 99)
+            __t += 1900;
+        __y = __t - 1900;
+    }
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_year4(int& __y,
+                                              iter_type& __b, iter_type __e,
+                                              ios_base::iostate& __err,
+                                              const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4);
+    if (!(__err & ios_base::failbit))
+        __y = __t - 1900;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_hour(int& __h,
+                                             iter_type& __b, iter_type __e,
+                                             ios_base::iostate& __err,
+                                             const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+    if (!(__err & ios_base::failbit) && __t <= 23)
+        __h = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_12_hour(int& __h,
+                                                iter_type& __b, iter_type __e,
+                                                ios_base::iostate& __err,
+                                                const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+    if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)
+        __h = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_minute(int& __m,
+                                               iter_type& __b, iter_type __e,
+                                               ios_base::iostate& __err,
+                                               const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+    if (!(__err & ios_base::failbit) && __t <= 59)
+        __m = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_second(int& __s,
+                                               iter_type& __b, iter_type __e,
+                                               ios_base::iostate& __err,
+                                               const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2);
+    if (!(__err & ios_base::failbit) && __t <= 60)
+        __s = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_weekday(int& __w,
+                                                iter_type& __b, iter_type __e,
+                                                ios_base::iostate& __err,
+                                                const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 1);
+    if (!(__err & ios_base::failbit) && __t <= 6)
+        __w = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_day_year_num(int& __d,
+                                                     iter_type& __b, iter_type __e,
+                                                     ios_base::iostate& __err,
+                                                     const ctype<char_type>& __ct) const
+{
+    int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 3);
+    if (!(__err & ios_base::failbit) && __t <= 365)
+        __d = __t;
+    else
+        __err |= ios_base::failbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_white_space(iter_type& __b, iter_type __e,
+                                                    ios_base::iostate& __err,
+                                                    const ctype<char_type>& __ct) const
+{
+    for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b)
+        ;
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_am_pm(int& __h,
+                                              iter_type& __b, iter_type __e,
+                                              ios_base::iostate& __err,
+                                              const ctype<char_type>& __ct) const
+{
+    const string_type* __ap = this->__am_pm();
+    if (__ap[0].size() + __ap[1].size() == 0)
+    {
+        __err |= ios_base::failbit;
+        return;
+    }
+    ptrdiff_t __i = __scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap;
+    if (__i == 0 && __h == 12)
+        __h = 0;
+    else if (__i == 1 && __h < 12)
+        __h += 12;
+}
+
+template <class _CharT, class _InputIterator>
+void
+time_get<_CharT, _InputIterator>::__get_percent(iter_type& __b, iter_type __e,
+                                                ios_base::iostate& __err,
+                                                const ctype<char_type>& __ct) const
+{
+    if (__b == __e)
+    {
+        __err |= ios_base::eofbit | ios_base::failbit;
+        return;
+    }
+    if (__ct.narrow(*__b, 0) != '%')
+        __err |= ios_base::failbit;
+    else if(++__b == __e)
+        __err |= ios_base::eofbit;
+}
+
+// time_get end primitives
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::get(iter_type __b, iter_type __e,
+                                      ios_base& __iob,
+                                      ios_base::iostate& __err, tm* __tm,
+                                      const char_type* __fmtb, const char_type* __fmte) const
+{
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+    __err = ios_base::goodbit;
+    while (__fmtb != __fmte && __err == ios_base::goodbit)
+    {
+        if (__b == __e)
+        {
+            __err = ios_base::failbit;
+            break;
+        }
+        if (__ct.narrow(*__fmtb, 0) == '%')
+        {
+            if (++__fmtb == __fmte)
+            {
+                __err = ios_base::failbit;
+                break;
+            }
+            char __cmd = __ct.narrow(*__fmtb, 0);
+            char __opt = '\0';
+            if (__cmd == 'E' || __cmd == '0')
+            {
+                if (++__fmtb == __fmte)
+                {
+                    __err = ios_base::failbit;
+                    break;
+                }
+                __opt = __cmd;
+                __cmd = __ct.narrow(*__fmtb, 0);
+            }
+            __b = do_get(__b, __e, __iob, __err, __tm, __cmd, __opt);
+            ++__fmtb;
+        }
+        else if (__ct.is(ctype_base::space, *__fmtb))
+        {
+            for (++__fmtb; __fmtb != __fmte && __ct.is(ctype_base::space, *__fmtb); ++__fmtb)
+                ;
+            for (        ;    __b != __e    && __ct.is(ctype_base::space, *__b);    ++__b)
+                ;
+        }
+        else if (__ct.toupper(*__b) == __ct.toupper(*__fmtb))
+        {
+            ++__b;
+            ++__fmtb;
+        }
+        else
+            __err = ios_base::failbit;
+    }
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __b;
+}
+
+template <class _CharT, class _InputIterator>
+typename time_get<_CharT, _InputIterator>::dateorder
+time_get<_CharT, _InputIterator>::do_date_order() const
+{
+    return mdy;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_time(iter_type __b, iter_type __e,
+                                              ios_base& __iob,
+                                              ios_base::iostate& __err,
+                                              tm* __tm) const
+{
+    const char_type __fmt[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
+    return get(__b, __e, __iob, __err, __tm, __fmt, __fmt + sizeof(__fmt)/sizeof(__fmt[0]));
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_date(iter_type __b, iter_type __e,
+                                              ios_base& __iob,
+                                              ios_base::iostate& __err,
+                                              tm* __tm) const
+{
+    const string_type& __fmt = this->__x();
+    return get(__b, __e, __iob, __err, __tm, __fmt.data(), __fmt.data() + __fmt.size());
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_weekday(iter_type __b, iter_type __e,
+                                                 ios_base& __iob,
+                                                 ios_base::iostate& __err,
+                                                 tm* __tm) const
+{
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+    __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
+    return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_monthname(iter_type __b, iter_type __e,
+                                                   ios_base& __iob,
+                                                   ios_base::iostate& __err,
+                                                   tm* __tm) const
+{
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+    __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
+    return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get_year(iter_type __b, iter_type __e,
+                                              ios_base& __iob,
+                                              ios_base::iostate& __err,
+                                              tm* __tm) const
+{
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+    __get_year(__tm->tm_year, __b, __e, __err, __ct);
+    return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+                                         ios_base& __iob,
+                                         ios_base::iostate& __err, tm* __tm,
+                                         char __fmt, char) const
+{
+    __err = ios_base::goodbit;
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+    switch (__fmt)
+    {
+    case 'a':
+    case 'A':
+        __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
+        break;
+    case 'b':
+    case 'B':
+    case 'h':
+        __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
+        break;
+    case 'c':
+        {
+        const string_type& __fm = this->__c();
+        __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
+        }
+        break;
+    case 'd':
+    case 'e':
+        __get_day(__tm->tm_mday, __b, __e, __err, __ct);
+        break;
+    case 'D':
+        {
+        const char_type __fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
+        __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+        }
+        break;
+    case 'F':
+        {
+        const char_type __fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
+        __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+        }
+        break;
+    case 'H':
+        __get_hour(__tm->tm_hour, __b, __e, __err, __ct);
+        break;
+    case 'I':
+        __get_12_hour(__tm->tm_hour, __b, __e, __err, __ct);
+        break;
+    case 'j':
+        __get_day_year_num(__tm->tm_yday, __b, __e, __err, __ct);
+        break;
+    case 'm':
+        __get_month(__tm->tm_mon, __b, __e, __err, __ct);
+        break;
+    case 'M':
+        __get_minute(__tm->tm_min, __b, __e, __err, __ct);
+        break;
+    case 'n':
+    case 't':
+        __get_white_space(__b, __e, __err, __ct);
+        break;
+    case 'p':
+        __get_am_pm(__tm->tm_hour, __b, __e, __err, __ct);
+        break;
+    case 'r':
+        {
+        const char_type __fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
+        __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+        }
+        break;
+    case 'R':
+        {
+        const char_type __fm[] = {'%', 'H', ':', '%', 'M'};
+        __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+        }
+        break;
+    case 'S':
+        __get_second(__tm->tm_sec, __b, __e, __err, __ct);
+        break;
+    case 'T':
+        {
+        const char_type __fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
+        __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0]));
+        }
+        break;
+    case 'w':
+        __get_weekday(__tm->tm_wday, __b, __e, __err, __ct);
+        break;
+    case 'x':
+        return do_get_date(__b, __e, __iob, __err, __tm);
+    case 'X':
+        {
+        const string_type& __fm = this->__X();
+        __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
+        }
+        break;
+    case 'y':
+        __get_year(__tm->tm_year, __b, __e, __err, __ct);
+        break;
+    case 'Y':
+        __get_year4(__tm->tm_year, __b, __e, __err, __ct);
+        break;
+    case '%':
+        __get_percent(__b, __e, __err, __ct);
+        break;
+    default:
+        __err |= ios_base::failbit;
+    }
+    return __b;
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<wchar_t>)
+
+class _LIBCPP_TYPE_VIS __time_get
+{
+protected:
+    locale_t __loc_;
+
+    __time_get(const char* __nm);
+    __time_get(const string& __nm);
+    ~__time_get();
+};
+
+template <class _CharT>
+class _LIBCPP_TYPE_VIS_ONLY __time_get_storage
+    : public __time_get
+{
+protected:
+    typedef basic_string<_CharT> string_type;
+
+    string_type __weeks_[14];
+    string_type __months_[24];
+    string_type __am_pm_[2];
+    string_type __c_;
+    string_type __r_;
+    string_type __x_;
+    string_type __X_;
+
+    explicit __time_get_storage(const char* __nm);
+    explicit __time_get_storage(const string& __nm);
+
+    _LIBCPP_ALWAYS_INLINE ~__time_get_storage() {}
+
+    time_base::dateorder __do_date_order() const;
+
+private:
+    void init(const ctype<_CharT>&);
+    string_type __analyze(char __fmt, const ctype<_CharT>&);
+};
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY time_get_byname
+    : public time_get<_CharT, _InputIterator>,
+      private __time_get_storage<_CharT>
+{
+public:
+    typedef time_base::dateorder    dateorder;
+    typedef _InputIterator          iter_type;
+    typedef _CharT                  char_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit time_get_byname(const char* __nm, size_t __refs = 0)
+        : time_get<_CharT, _InputIterator>(__refs),
+          __time_get_storage<_CharT>(__nm) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit time_get_byname(const string& __nm, size_t __refs = 0)
+        : time_get<_CharT, _InputIterator>(__refs),
+          __time_get_storage<_CharT>(__nm) {}
+
+protected:
+    _LIBCPP_INLINE_VISIBILITY
+    ~time_get_byname() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    virtual dateorder do_date_order() const {return this->__do_date_order();}
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    virtual const string_type* __weeks() const  {return this->__weeks_;}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual const string_type* __months() const {return this->__months_;}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual const string_type* __am_pm() const  {return this->__am_pm_;}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual const string_type& __c() const      {return this->__c_;}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual const string_type& __r() const      {return this->__r_;}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual const string_type& __x() const      {return this->__x_;}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual const string_type& __X() const      {return this->__X_;}
+};
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<wchar_t>)
+
+class _LIBCPP_TYPE_VIS __time_put
+{
+    locale_t __loc_;
+protected:
+    _LIBCPP_ALWAYS_INLINE __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}
+    __time_put(const char* __nm);
+    __time_put(const string& __nm);
+    ~__time_put();
+    void __do_put(char* __nb, char*& __ne, const tm* __tm,
+                  char __fmt, char __mod) const;
+    void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
+                  char __fmt, char __mod) const;
+};
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY time_put
+    : public locale::facet,
+      private __time_put
+{
+public:
+    typedef _CharT char_type;
+    typedef _OutputIterator iter_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit time_put(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm,
+                  const char_type* __pb, const char_type* __pe) const;
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, ios_base& __iob, char_type __fl,
+                  const tm* __tm, char __fmt, char __mod = 0) const
+    {
+        return do_put(__s, __iob, __fl, __tm, __fmt, __mod);
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~time_put() {}
+    virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm,
+                             char __fmt, char __mod) const;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit time_put(const char* __nm, size_t __refs)
+        : locale::facet(__refs),
+          __time_put(__nm) {}
+    _LIBCPP_ALWAYS_INLINE
+    explicit time_put(const string& __nm, size_t __refs)
+        : locale::facet(__refs),
+          __time_put(__nm) {}
+};
+
+template <class _CharT, class _OutputIterator>
+locale::id
+time_put<_CharT, _OutputIterator>::id;
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+time_put<_CharT, _OutputIterator>::put(iter_type __s, ios_base& __iob,
+                                       char_type __fl, const tm* __tm,
+                                       const char_type* __pb,
+                                       const char_type* __pe) const
+{
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__iob.getloc());
+    for (; __pb != __pe; ++__pb)
+    {
+        if (__ct.narrow(*__pb, 0) == '%')
+        {
+            if (++__pb == __pe)
+            {
+                *__s++ = __pb[-1];
+                break;
+            }
+            char __mod = 0;
+            char __fmt = __ct.narrow(*__pb, 0);
+            if (__fmt == 'E' || __fmt == 'O')
+            {
+                if (++__pb == __pe)
+                {
+                    *__s++ = __pb[-2];
+                    *__s++ = __pb[-1];
+                    break;
+                }
+                __mod = __fmt;
+                __fmt = __ct.narrow(*__pb, 0);
+            }
+            __s = do_put(__s, __iob, __fl, __tm, __fmt, __mod);
+        }
+        else
+            *__s++ = *__pb;
+    }
+    return __s;
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
+                                          char_type, const tm* __tm,
+                                          char __fmt, char __mod) const
+{
+    char_type __nar[100];
+    char_type* __nb = __nar;
+    char_type* __ne = __nb + 100;
+    __do_put(__nb, __ne, __tm, __fmt, __mod);
+    return _VSTD::copy(__nb, __ne, __s);
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<wchar_t>)
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY time_put_byname
+    : public time_put<_CharT, _OutputIterator>
+{
+public:
+    _LIBCPP_ALWAYS_INLINE
+    explicit time_put_byname(const char* __nm, size_t __refs = 0)
+        : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit time_put_byname(const string& __nm, size_t __refs = 0)
+        : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~time_put_byname() {}
+};
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<wchar_t>)
+
+// money_base
+
+class _LIBCPP_TYPE_VIS money_base
+{
+public:
+    enum part {none, space, symbol, sign, value};
+    struct pattern {char field[4];};
+
+    _LIBCPP_ALWAYS_INLINE money_base() {}
+};
+
+// moneypunct
+
+template <class _CharT, bool _International = false>
+class _LIBCPP_TYPE_VIS_ONLY moneypunct
+    : public locale::facet,
+      public money_base
+{
+public:
+    typedef _CharT                  char_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit moneypunct(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE char_type   decimal_point() const {return do_decimal_point();}
+    _LIBCPP_ALWAYS_INLINE char_type   thousands_sep() const {return do_thousands_sep();}
+    _LIBCPP_ALWAYS_INLINE string      grouping()      const {return do_grouping();}
+    _LIBCPP_ALWAYS_INLINE string_type curr_symbol()   const {return do_curr_symbol();}
+    _LIBCPP_ALWAYS_INLINE string_type positive_sign() const {return do_positive_sign();}
+    _LIBCPP_ALWAYS_INLINE string_type negative_sign() const {return do_negative_sign();}
+    _LIBCPP_ALWAYS_INLINE int         frac_digits()   const {return do_frac_digits();}
+    _LIBCPP_ALWAYS_INLINE pattern     pos_format()    const {return do_pos_format();}
+    _LIBCPP_ALWAYS_INLINE pattern     neg_format()    const {return do_neg_format();}
+
+    static locale::id id;
+    static const bool intl = _International;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~moneypunct() {}
+
+    virtual char_type   do_decimal_point() const {return numeric_limits<char_type>::max();}
+    virtual char_type   do_thousands_sep() const {return numeric_limits<char_type>::max();}
+    virtual string      do_grouping()      const {return string();}
+    virtual string_type do_curr_symbol()   const {return string_type();}
+    virtual string_type do_positive_sign() const {return string_type();}
+    virtual string_type do_negative_sign() const {return string_type(1, '-');}
+    virtual int         do_frac_digits()   const {return 0;}
+    virtual pattern     do_pos_format()    const
+        {pattern __p = {{symbol, sign, none, value}}; return __p;}
+    virtual pattern     do_neg_format()    const
+        {pattern __p = {{symbol, sign, none, value}}; return __p;}
+};
+
+template <class _CharT, bool _International>
+locale::id
+moneypunct<_CharT, _International>::id;
+
+template <class _CharT, bool _International>
+const bool
+moneypunct<_CharT, _International>::intl;
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, false>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, true>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, false>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, true>)
+
+// moneypunct_byname
+
+template <class _CharT, bool _International = false>
+class _LIBCPP_TYPE_VIS_ONLY moneypunct_byname
+    : public moneypunct<_CharT, _International>
+{
+public:
+    typedef money_base::pattern  pattern;
+    typedef _CharT                  char_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit moneypunct_byname(const char* __nm, size_t __refs = 0)
+        : moneypunct<_CharT, _International>(__refs) {init(__nm);}
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit moneypunct_byname(const string& __nm, size_t __refs = 0)
+        : moneypunct<_CharT, _International>(__refs) {init(__nm.c_str());}
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~moneypunct_byname() {}
+
+    virtual char_type   do_decimal_point() const {return __decimal_point_;}
+    virtual char_type   do_thousands_sep() const {return __thousands_sep_;}
+    virtual string      do_grouping()      const {return __grouping_;}
+    virtual string_type do_curr_symbol()   const {return __curr_symbol_;}
+    virtual string_type do_positive_sign() const {return __positive_sign_;}
+    virtual string_type do_negative_sign() const {return __negative_sign_;}
+    virtual int         do_frac_digits()   const {return __frac_digits_;}
+    virtual pattern     do_pos_format()    const {return __pos_format_;}
+    virtual pattern     do_neg_format()    const {return __neg_format_;}
+
+private:
+    char_type   __decimal_point_;
+    char_type   __thousands_sep_;
+    string      __grouping_;
+    string_type __curr_symbol_;
+    string_type __positive_sign_;
+    string_type __negative_sign_;
+    int         __frac_digits_;
+    pattern     __pos_format_;
+    pattern     __neg_format_;
+
+    void init(const char*);
+};
+
+template<> void moneypunct_byname<char, false>::init(const char*);
+template<> void moneypunct_byname<char, true>::init(const char*);
+template<> void moneypunct_byname<wchar_t, false>::init(const char*);
+template<> void moneypunct_byname<wchar_t, true>::init(const char*);
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, false>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, true>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, false>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, true>)
+
+// money_get
+
+template <class _CharT>
+class __money_get
+{
+protected:
+    typedef _CharT                  char_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_ALWAYS_INLINE __money_get() {}
+
+    static void __gather_info(bool __intl, const locale& __loc,
+                              money_base::pattern& __pat, char_type& __dp,
+                              char_type& __ts, string& __grp,
+                              string_type& __sym, string_type& __psn,
+                              string_type& __nsn, int& __fd);
+};
+
+template <class _CharT>
+void
+__money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
+                                   money_base::pattern& __pat, char_type& __dp,
+                                   char_type& __ts, string& __grp,
+                                   string_type& __sym, string_type& __psn,
+                                   string_type& __nsn, int& __fd)
+{
+    if (__intl)
+    {
+        const moneypunct<char_type, true>& __mp =
+            use_facet<moneypunct<char_type, true> >(__loc);
+        __pat = __mp.neg_format();
+        __nsn = __mp.negative_sign();
+        __psn = __mp.positive_sign();
+        __dp = __mp.decimal_point();
+        __ts = __mp.thousands_sep();
+        __grp = __mp.grouping();
+        __sym = __mp.curr_symbol();
+        __fd = __mp.frac_digits();
+    }
+    else
+    {
+        const moneypunct<char_type, false>& __mp =
+            use_facet<moneypunct<char_type, false> >(__loc);
+        __pat = __mp.neg_format();
+        __nsn = __mp.negative_sign();
+        __psn = __mp.positive_sign();
+        __dp = __mp.decimal_point();
+        __ts = __mp.thousands_sep();
+        __grp = __mp.grouping();
+        __sym = __mp.curr_symbol();
+        __fd = __mp.frac_digits();
+    }
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<wchar_t>)
+
+template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY money_get
+    : public locale::facet,
+      private __money_get<_CharT>
+{
+public:
+    typedef _CharT                  char_type;
+    typedef _InputIterator          iter_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit money_get(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob,
+                  ios_base::iostate& __err, long double& __v) const
+    {
+        return do_get(__b, __e, __intl, __iob, __err, __v);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob,
+                  ios_base::iostate& __err, string_type& __v) const
+    {
+        return do_get(__b, __e, __intl, __iob, __err, __v);
+    }
+
+    static locale::id id;
+
+protected:
+
+    _LIBCPP_ALWAYS_INLINE
+    ~money_get() {}
+
+    virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
+                             ios_base& __iob, ios_base::iostate& __err,
+                             long double& __v) const;
+    virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl,
+                             ios_base& __iob, ios_base::iostate& __err,
+                             string_type& __v) const;
+
+private:
+    static bool __do_get(iter_type& __b, iter_type __e,
+                         bool __intl, const locale& __loc,
+                         ios_base::fmtflags __flags, ios_base::iostate& __err,
+                         bool& __neg, const ctype<char_type>& __ct,
+                         unique_ptr<char_type, void(*)(void*)>& __wb,
+                         char_type*& __wn, char_type* __we);
+};
+
+template <class _CharT, class _InputIterator>
+locale::id
+money_get<_CharT, _InputIterator>::id;
+
+_LIBCPP_FUNC_VIS void __do_nothing(void*);
+
+template <class _Tp>
+_LIBCPP_HIDDEN
+void
+__double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e)
+{
+    bool __owns = __b.get_deleter() != __do_nothing;
+    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();
+    size_t __n_off = static_cast<size_t>(__n - __b.get());
+    _Tp* __t = (_Tp*)realloc(__owns ? __b.get() : 0, __new_cap);
+    if (__t == 0)
+        __throw_bad_alloc();
+    if (__owns)
+        __b.release();
+    __b = unique_ptr<_Tp, void(*)(void*)>(__t, free);
+    __new_cap /= sizeof(_Tp);
+    __n = __b.get() + __n_off;
+    __e = __b.get() + __new_cap;
+}
+
+// true == success
+template <class _CharT, class _InputIterator>
+bool
+money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e,
+                                            bool __intl, const locale& __loc,
+                                            ios_base::fmtflags __flags,
+                                            ios_base::iostate& __err,
+                                            bool& __neg,
+                                            const ctype<char_type>& __ct,
+                                            unique_ptr<char_type, void(*)(void*)>& __wb,
+                                            char_type*& __wn, char_type* __we)
+{
+    const unsigned __bz = 100;
+    unsigned __gbuf[__bz];
+    unique_ptr<unsigned, void(*)(void*)> __gb(__gbuf, __do_nothing);
+    unsigned* __gn = __gb.get();
+    unsigned* __ge = __gn + __bz;
+    money_base::pattern __pat;
+    char_type __dp;
+    char_type __ts;
+    string __grp;
+    string_type __sym;
+    string_type __psn;
+    string_type __nsn;
+    // Capture the spaces read into money_base::{space,none} so they
+    // can be compared to initial spaces in __sym.
+    string_type __spaces;
+    int __fd;
+    __money_get<_CharT>::__gather_info(__intl, __loc, __pat, __dp, __ts, __grp,
+                                       __sym, __psn, __nsn, __fd);
+    const string_type* __trailing_sign = 0;
+    __wn = __wb.get();
+    for (unsigned __p = 0; __p < 4 && __b != __e; ++__p)
+    {
+        switch (__pat.field[__p])
+        {
+        case money_base::space:
+            if (__p != 3)
+            {
+                if (__ct.is(ctype_base::space, *__b))
+                    __spaces.push_back(*__b++);
+                else
+                {
+                    __err |= ios_base::failbit;
+                    return false;
+                }
+            }
+            // drop through
+        case money_base::none:
+            if (__p != 3)
+            {
+                while (__b != __e && __ct.is(ctype_base::space, *__b))
+                    __spaces.push_back(*__b++);
+            }
+            break;
+        case money_base::sign:
+            if (__psn.size() + __nsn.size() > 0)
+            {
+                if (__psn.size() == 0 || __nsn.size() == 0)
+                {   // sign is optional
+                    if (__psn.size() > 0)
+                    {   // __nsn.size() == 0
+                        if (*__b == __psn[0])
+                        {
+                            ++__b;
+                            if (__psn.size() > 1)
+                                __trailing_sign = &__psn;
+                        }
+                        else
+                            __neg = true;
+                    }
+                    else if (*__b == __nsn[0])  // __nsn.size() > 0 &&  __psn.size() == 0
+                    {
+                        ++__b;
+                        __neg = true;
+                        if (__nsn.size() > 1)
+                            __trailing_sign = &__nsn;
+                    }
+                }
+                else  // sign is required
+                {
+                    if (*__b == __psn[0])
+                    {
+                        ++__b;
+                        if (__psn.size() > 1)
+                            __trailing_sign = &__psn;
+                    }
+                    else if (*__b == __nsn[0])
+                    {
+                        ++__b;
+                        __neg = true;
+                        if (__nsn.size() > 1)
+                            __trailing_sign = &__nsn;
+                    }
+                    else
+                    {
+                        __err |= ios_base::failbit;
+                        return false;
+                    }
+                }
+            }
+            break;
+        case money_base::symbol:
+            {
+            bool __more_needed = __trailing_sign ||
+                                 (__p < 2)       ||
+                                 (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none));
+            bool __sb = (__flags & ios_base::showbase) != 0;
+            if (__sb || __more_needed)
+            {
+                typename string_type::const_iterator __sym_space_end = __sym.begin();
+                if (__p > 0 && (__pat.field[__p - 1] == money_base::none ||
+                                __pat.field[__p - 1] == money_base::space)) {
+                    // Match spaces we've already read against spaces at
+                    // the beginning of __sym.
+                    while (__sym_space_end != __sym.end() &&
+                           __ct.is(ctype_base::space, *__sym_space_end))
+                        ++__sym_space_end;
+                    const size_t __num_spaces = __sym_space_end - __sym.begin();
+                    if (__num_spaces > __spaces.size() ||
+                        !equal(__spaces.end() - __num_spaces, __spaces.end(),
+                               __sym.begin())) {
+                        // No match. Put __sym_space_end back at the
+                        // beginning of __sym, which will prevent a
+                        // match in the next loop.
+                        __sym_space_end = __sym.begin();
+                    }
+                }
+                typename string_type::const_iterator __sym_curr_char = __sym_space_end;
+                while (__sym_curr_char != __sym.end() && __b != __e &&
+                       *__b == *__sym_curr_char) {
+                    ++__b;
+                    ++__sym_curr_char;
+                }
+                if (__sb && __sym_curr_char != __sym.end())
+                {
+                    __err |= ios_base::failbit;
+                    return false;
+                }
+            }
+            }
+            break;
+        case money_base::value:
+            {
+            unsigned __ng = 0;
+            for (; __b != __e; ++__b)
+            {
+                char_type __c = *__b;
+                if (__ct.is(ctype_base::digit, __c))
+                {
+                    if (__wn == __we)
+                        __double_or_nothing(__wb, __wn, __we);
+                    *__wn++ = __c;
+                    ++__ng;
+                }
+                else if (__grp.size() > 0 && __ng > 0 && __c == __ts)
+                {
+                    if (__gn == __ge)
+                        __double_or_nothing(__gb, __gn, __ge);
+                    *__gn++ = __ng;
+                    __ng = 0;
+                }
+                else
+                    break;
+            }
+            if (__gb.get() != __gn && __ng > 0)
+            {
+                if (__gn == __ge)
+                    __double_or_nothing(__gb, __gn, __ge);
+                *__gn++ = __ng;
+            }
+            if (__fd > 0)
+            {
+                if (__b == __e || *__b != __dp)
+                {
+                    __err |= ios_base::failbit;
+                    return false;
+                }
+                for (++__b; __fd > 0; --__fd, ++__b)
+                {
+                    if (__b == __e || !__ct.is(ctype_base::digit, *__b))
+                    {
+                        __err |= ios_base::failbit;
+                        return false;
+                    }
+                    if (__wn == __we)
+                        __double_or_nothing(__wb, __wn, __we);
+                    *__wn++ = *__b;
+                }
+            }
+            if (__wn == __wb.get())
+            {
+                __err |= ios_base::failbit;
+                return false;
+            }
+            }
+            break;
+        }
+    }
+    if (__trailing_sign)
+    {
+        for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b)
+        {
+            if (__b == __e || *__b != (*__trailing_sign)[__i])
+            {
+                __err |= ios_base::failbit;
+                return false;
+            }
+        }
+    }
+    if (__gb.get() != __gn)
+    {
+        ios_base::iostate __et = ios_base::goodbit;
+        __check_grouping(__grp, __gb.get(), __gn, __et);
+        if (__et)
+        {
+            __err |= ios_base::failbit;
+            return false;
+        }
+    }
+    return true;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+                                          bool __intl, ios_base& __iob,
+                                          ios_base::iostate& __err,
+                                          long double& __v) const
+{
+    const int __bz = 100;
+    char_type __wbuf[__bz];
+    unique_ptr<char_type, void(*)(void*)> __wb(__wbuf, __do_nothing);
+    char_type* __wn;
+    char_type* __we = __wbuf + __bz;
+    locale __loc = __iob.getloc();
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+    bool __neg = false;
+    if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
+                 __wb, __wn, __we))
+    {
+        const char __src[] = "0123456789";
+        char_type __atoms[sizeof(__src)-1];
+        __ct.widen(__src, __src + (sizeof(__src)-1), __atoms);
+        char __nbuf[__bz];
+        char* __nc = __nbuf;
+        unique_ptr<char, void(*)(void*)> __h(0, free);
+        if (__wn - __wb.get() > __bz-2)
+        {
+            __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
+            if (__h.get() == 0)
+                __throw_bad_alloc();
+            __nc = __h.get();
+        }
+        if (__neg)
+            *__nc++ = '-';
+        for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)
+            *__nc = __src[find(__atoms, _VSTD::end(__atoms), *__w) - __atoms];
+        *__nc = char();
+        if (sscanf(__nbuf, "%Lf", &__v) != 1)
+            __throw_runtime_error("money_get error");
+    }
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __b;
+}
+
+template <class _CharT, class _InputIterator>
+_InputIterator
+money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
+                                          bool __intl, ios_base& __iob,
+                                          ios_base::iostate& __err,
+                                          string_type& __v) const
+{
+    const int __bz = 100;
+    char_type __wbuf[__bz];
+    unique_ptr<char_type, void(*)(void*)> __wb(__wbuf, __do_nothing);
+    char_type* __wn;
+    char_type* __we = __wbuf + __bz;
+    locale __loc = __iob.getloc();
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+    bool __neg = false;
+    if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct,
+                 __wb, __wn, __we))
+    {
+        __v.clear();
+        if (__neg)
+            __v.push_back(__ct.widen('-'));
+        char_type __z = __ct.widen('0');
+        char_type* __w;
+        for (__w = __wb.get(); __w < __wn-1; ++__w)
+            if (*__w != __z)
+                break;
+        __v.append(__w, __wn);
+    }
+    if (__b == __e)
+        __err |= ios_base::eofbit;
+    return __b;
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<wchar_t>)
+
+// money_put
+
+template <class _CharT>
+class __money_put
+{
+protected:
+    typedef _CharT                  char_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_ALWAYS_INLINE __money_put() {}
+
+    static void __gather_info(bool __intl, bool __neg, const locale& __loc,
+                              money_base::pattern& __pat, char_type& __dp,
+                              char_type& __ts, string& __grp,
+                              string_type& __sym, string_type& __sn,
+                              int& __fd);
+    static void __format(char_type* __mb, char_type*& __mi, char_type*& __me,
+                         ios_base::fmtflags __flags,
+                         const char_type* __db, const char_type* __de,
+                         const ctype<char_type>& __ct, bool __neg,
+                         const money_base::pattern& __pat, char_type __dp,
+                         char_type __ts, const string& __grp,
+                         const string_type& __sym, const string_type& __sn,
+                         int __fd);
+};
+
+template <class _CharT>
+void
+__money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc,
+                                   money_base::pattern& __pat, char_type& __dp,
+                                   char_type& __ts, string& __grp,
+                                   string_type& __sym, string_type& __sn,
+                                   int& __fd)
+{
+    if (__intl)
+    {
+        const moneypunct<char_type, true>& __mp =
+            use_facet<moneypunct<char_type, true> >(__loc);
+        if (__neg)
+        {
+            __pat = __mp.neg_format();
+            __sn = __mp.negative_sign();
+        }
+        else
+        {
+            __pat = __mp.pos_format();
+            __sn = __mp.positive_sign();
+        }
+        __dp = __mp.decimal_point();
+        __ts = __mp.thousands_sep();
+        __grp = __mp.grouping();
+        __sym = __mp.curr_symbol();
+        __fd = __mp.frac_digits();
+    }
+    else
+    {
+        const moneypunct<char_type, false>& __mp =
+            use_facet<moneypunct<char_type, false> >(__loc);
+        if (__neg)
+        {
+            __pat = __mp.neg_format();
+            __sn = __mp.negative_sign();
+        }
+        else
+        {
+            __pat = __mp.pos_format();
+            __sn = __mp.positive_sign();
+        }
+        __dp = __mp.decimal_point();
+        __ts = __mp.thousands_sep();
+        __grp = __mp.grouping();
+        __sym = __mp.curr_symbol();
+        __fd = __mp.frac_digits();
+    }
+}
+
+template <class _CharT>
+void
+__money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __me,
+                              ios_base::fmtflags __flags,
+                              const char_type* __db, const char_type* __de,
+                              const ctype<char_type>& __ct, bool __neg,
+                              const money_base::pattern& __pat, char_type __dp,
+                              char_type __ts, const string& __grp,
+                              const string_type& __sym, const string_type& __sn,
+                              int __fd)
+{
+    __me = __mb;
+    for (unsigned __p = 0; __p < 4; ++__p)
+    {
+        switch (__pat.field[__p])
+        {
+        case money_base::none:
+            __mi = __me;
+            break;
+        case money_base::space:
+            __mi = __me;
+            *__me++ = __ct.widen(' ');
+            break;
+        case money_base::sign:
+            if (!__sn.empty())
+                *__me++ = __sn[0];
+            break;
+        case money_base::symbol:
+            if (!__sym.empty() && (__flags & ios_base::showbase))
+                __me = _VSTD::copy(__sym.begin(), __sym.end(), __me);
+            break;
+        case money_base::value:
+            {
+            // remember start of value so we can reverse it
+            char_type* __t = __me;
+            // find beginning of digits
+            if (__neg)
+                ++__db;
+            // find end of digits
+            const char_type* __d;
+            for (__d = __db; __d < __de; ++__d)
+                if (!__ct.is(ctype_base::digit, *__d))
+                    break;
+            // print fractional part
+            if (__fd > 0)
+            {
+                int __f;
+                for (__f = __fd; __d > __db && __f > 0; --__f)
+                    *__me++ = *--__d;
+                char_type __z = __f > 0 ? __ct.widen('0') : char_type();
+                for (; __f > 0; --__f)
+                    *__me++ = __z;
+                *__me++ = __dp;
+            }
+            // print units part
+            if (__d == __db)
+            {
+                *__me++ = __ct.widen('0');
+            }
+            else
+            {
+                unsigned __ng = 0;
+                unsigned __ig = 0;
+                unsigned __gl = __grp.empty() ? numeric_limits<unsigned>::max()
+                                              : static_cast<unsigned>(__grp[__ig]);
+                while (__d != __db)
+                {
+                    if (__ng == __gl)
+                    {
+                        *__me++ = __ts;
+                        __ng = 0;
+                        if (++__ig < __grp.size())
+                            __gl = __grp[__ig] == numeric_limits<char>::max() ?
+                                        numeric_limits<unsigned>::max() :
+                                        static_cast<unsigned>(__grp[__ig]);
+                    }
+                    *__me++ = *--__d;
+                    ++__ng;
+                }
+            }
+            // reverse it
+            reverse(__t, __me);
+            }
+            break;
+        }
+    }
+    // print rest of sign, if any
+    if (__sn.size() > 1)
+        __me = _VSTD::copy(__sn.begin()+1, __sn.end(), __me);
+    // set alignment
+    if ((__flags & ios_base::adjustfield) == ios_base::left)
+        __mi = __me;
+    else if ((__flags & ios_base::adjustfield) != ios_base::internal)
+        __mi = __mb;
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<wchar_t>)
+
+template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY money_put
+    : public locale::facet,
+      private __money_put<_CharT>
+{
+public:
+    typedef _CharT                  char_type;
+    typedef _OutputIterator         iter_type;
+    typedef basic_string<char_type> string_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit money_put(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl,
+                  long double __units) const
+    {
+        return do_put(__s, __intl, __iob, __fl, __units);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl,
+                  const string_type& __digits) const
+    {
+        return do_put(__s, __intl, __iob, __fl, __digits);
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~money_put() {}
+
+    virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
+                             char_type __fl, long double __units) const;
+    virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob,
+                             char_type __fl, const string_type& __digits) const;
+};
+
+template <class _CharT, class _OutputIterator>
+locale::id
+money_put<_CharT, _OutputIterator>::id;
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
+                                           ios_base& __iob, char_type __fl,
+                                           long double __units) const
+{
+    // convert to char
+    const size_t __bs = 100;
+    char __buf[__bs];
+    char* __bb = __buf;
+    char_type __digits[__bs];
+    char_type* __db = __digits;
+    size_t __n = static_cast<size_t>(snprintf(__bb, __bs, "%.0Lf", __units));
+    unique_ptr<char, void(*)(void*)> __hn(0, free);
+    unique_ptr<char_type, void(*)(void*)> __hd(0, free);
+    // 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
+        if (__bb == 0)
+            __throw_bad_alloc();
+        __hn.reset(__bb);
+        __hd.reset((char_type*)malloc(__n * sizeof(char_type)));
+        if (__hd == nullptr)
+            __throw_bad_alloc();
+        __db = __hd.get();
+    }
+    // gather info
+    locale __loc = __iob.getloc();
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+    __ct.widen(__bb, __bb + __n, __db);
+    bool __neg = __n > 0 && __bb[0] == '-';
+    money_base::pattern __pat;
+    char_type __dp;
+    char_type __ts;
+    string __grp;
+    string_type __sym;
+    string_type __sn;
+    int __fd;
+    this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+    // secure memory for formatting
+    char_type __mbuf[__bs];
+    char_type* __mb = __mbuf;
+    unique_ptr<char_type, void(*)(void*)> __hw(0, free);
+    size_t __exn = static_cast<int>(__n) > __fd ?
+                   (__n - static_cast<size_t>(__fd)) * 2 + __sn.size() +
+                    __sym.size() + static_cast<size_t>(__fd) + 1
+                 : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
+    if (__exn > __bs)
+    {
+        __hw.reset((char_type*)malloc(__exn * sizeof(char_type)));
+        __mb = __hw.get();
+        if (__mb == 0)
+            __throw_bad_alloc();
+    }
+    // format
+    char_type* __mi;
+    char_type* __me;
+    this->__format(__mb, __mi, __me, __iob.flags(),
+                   __db, __db + __n, __ct,
+                   __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+    return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
+}
+
+template <class _CharT, class _OutputIterator>
+_OutputIterator
+money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
+                                           ios_base& __iob, char_type __fl,
+                                           const string_type& __digits) const
+{
+    // gather info
+    locale __loc = __iob.getloc();
+    const ctype<char_type>& __ct = use_facet<ctype<char_type> >(__loc);
+    bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');
+    money_base::pattern __pat;
+    char_type __dp;
+    char_type __ts;
+    string __grp;
+    string_type __sym;
+    string_type __sn;
+    int __fd;
+    this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+    // secure memory for formatting
+    char_type __mbuf[100];
+    char_type* __mb = __mbuf;
+    unique_ptr<char_type, void(*)(void*)> __h(0, free);
+    size_t __exn = static_cast<int>(__digits.size()) > __fd ?
+                   (__digits.size() - static_cast<size_t>(__fd)) * 2 +
+                    __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 1
+                 : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
+    if (__exn > 100)
+    {
+        __h.reset((char_type*)malloc(__exn * sizeof(char_type)));
+        __mb = __h.get();
+        if (__mb == 0)
+            __throw_bad_alloc();
+    }
+    // format
+    char_type* __mi;
+    char_type* __me;
+    this->__format(__mb, __mi, __me, __iob.flags(),
+                   __digits.data(), __digits.data() + __digits.size(), __ct,
+                   __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
+    return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<wchar_t>)
+
+// messages
+
+class _LIBCPP_TYPE_VIS messages_base
+{
+public:
+    typedef ptrdiff_t catalog;
+
+    _LIBCPP_ALWAYS_INLINE messages_base() {}
+};
+
+template <class _CharT>
+class _LIBCPP_TYPE_VIS_ONLY messages
+    : public locale::facet,
+      public messages_base
+{
+public:
+    typedef _CharT               char_type;
+    typedef basic_string<_CharT> string_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit messages(size_t __refs = 0)
+        : locale::facet(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    catalog open(const basic_string<char>& __nm, const locale& __loc) const
+    {
+        return do_open(__nm, __loc);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    string_type get(catalog __c, int __set, int __msgid,
+                    const string_type& __dflt) const
+    {
+        return do_get(__c, __set, __msgid, __dflt);
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    void close(catalog __c) const
+    {
+        do_close(__c);
+    }
+
+    static locale::id id;
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~messages() {}
+
+    virtual catalog do_open(const basic_string<char>&, const locale&) const;
+    virtual string_type do_get(catalog, int __set, int __msgid,
+                               const string_type& __dflt) const;
+    virtual void do_close(catalog) const;
+};
+
+template <class _CharT>
+locale::id
+messages<_CharT>::id;
+
+template <class _CharT>
+typename messages<_CharT>::catalog
+messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
+{
+#if defined(_WIN32) || defined(__ANDROID__)
+    return -1;
+#else // _WIN32 || __ANDROID__
+    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__
+}
+
+template <class _CharT>
+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__)
+    return __dflt;
+#else // _WIN32
+    string __ndflt;
+    __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
+                                                       __dflt.c_str(),
+                                                       __dflt.c_str() + __dflt.size());
+    if (__c != -1)
+        __c <<= 1;
+    nl_catd __cat = (nl_catd)__c;
+    char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
+    string_type __w;
+    __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
+                                                        __n, __n + strlen(__n));
+    return __w;
+#endif // _WIN32
+}
+
+template <class _CharT>
+void
+messages<_CharT>::do_close(catalog __c) const
+{
+#if !defined(_WIN32) && !defined(__ANDROID__)
+    if (__c != -1)
+        __c <<= 1;
+    nl_catd __cat = (nl_catd)__c;
+    catclose(__cat);
+#endif // !_WIN32
+}
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<wchar_t>)
+
+template <class _CharT>
+class _LIBCPP_TYPE_VIS_ONLY messages_byname
+    : public messages<_CharT>
+{
+public:
+    typedef messages_base::catalog catalog;
+    typedef basic_string<_CharT> string_type;
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit messages_byname(const char*, size_t __refs = 0)
+        : messages<_CharT>(__refs) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    explicit messages_byname(const string&, size_t __refs = 0)
+        : messages<_CharT>(__refs) {}
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    ~messages_byname() {}
+};
+
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<char>)
+_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<wchar_t>)
+
+template<class _Codecvt, class _Elem = wchar_t,
+         class _Wide_alloc = allocator<_Elem>,
+         class _Byte_alloc = allocator<char> >
+class _LIBCPP_TYPE_VIS_ONLY wstring_convert
+{
+public:
+    typedef basic_string<char, char_traits<char>, _Byte_alloc>   byte_string;
+    typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string;
+    typedef typename _Codecvt::state_type                        state_type;
+    typedef typename wide_string::traits_type::int_type          int_type;
+
+private:
+    byte_string __byte_err_string_;
+    wide_string __wide_err_string_;
+    _Codecvt* __cvtptr_;
+    state_type __cvtstate_;
+    size_t __cvtcount_;
+
+    wstring_convert(const wstring_convert& __wc);
+    wstring_convert& operator=(const wstring_convert& __wc);
+public:
+    _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
+    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
+    wstring_convert(wstring_convert&& __wc);
+#endif
+    ~wstring_convert();
+
+    _LIBCPP_ALWAYS_INLINE
+    wide_string from_bytes(char __byte)
+        {return from_bytes(&__byte, &__byte+1);}
+    _LIBCPP_ALWAYS_INLINE
+    wide_string from_bytes(const char* __ptr)
+        {return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));}
+    _LIBCPP_ALWAYS_INLINE
+    wide_string from_bytes(const byte_string& __str)
+        {return from_bytes(__str.data(), __str.data() + __str.size());}
+    wide_string from_bytes(const char* __first, const char* __last);
+
+    _LIBCPP_ALWAYS_INLINE
+    byte_string to_bytes(_Elem __wchar)
+        {return to_bytes(&__wchar, &__wchar+1);}
+    _LIBCPP_ALWAYS_INLINE
+    byte_string to_bytes(const _Elem* __wptr)
+        {return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));}
+    _LIBCPP_ALWAYS_INLINE
+    byte_string to_bytes(const wide_string& __wstr)
+        {return to_bytes(__wstr.data(), __wstr.data() + __wstr.size());}
+    byte_string to_bytes(const _Elem* __first, const _Elem* __last);
+
+    _LIBCPP_ALWAYS_INLINE
+    size_t converted() const _NOEXCEPT {return __cvtcount_;}
+    _LIBCPP_ALWAYS_INLINE
+    state_type state() const {return __cvtstate_;}
+};
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+inline _LIBCPP_ALWAYS_INLINE
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+    wstring_convert(_Codecvt* __pcvt)
+        : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0)
+{
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+inline _LIBCPP_ALWAYS_INLINE
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+    wstring_convert(_Codecvt* __pcvt, state_type __state)
+        : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0)
+{
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+    wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err)
+        : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err),
+          __cvtstate_(), __cvtcount_(0)
+{
+    __cvtptr_ = new _Codecvt;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+inline _LIBCPP_ALWAYS_INLINE
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+    wstring_convert(wstring_convert&& __wc)
+        : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)),
+          __wide_err_string_(_VSTD::move(__wc.__wide_err_string_)),
+          __cvtptr_(__wc.__cvtptr_),
+          __cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtstate_)
+{
+    __wc.__cvtptr_ = nullptr;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert()
+{
+    delete __cvtptr_;
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+    from_bytes(const char* __frm, const char* __frm_end)
+{
+    __cvtcount_ = 0;
+    if (__cvtptr_ != nullptr)
+    {
+        wide_string __ws(2*(__frm_end - __frm), _Elem());
+        if (__frm != __frm_end)
+            __ws.resize(__ws.capacity());
+        codecvt_base::result __r = codecvt_base::ok;
+        state_type __st = __cvtstate_;
+        if (__frm != __frm_end)
+        {
+            _Elem* __to = &__ws[0];
+            _Elem* __to_end = __to + __ws.size();
+            const char* __frm_nxt;
+            do
+            {
+                _Elem* __to_nxt;
+                __r = __cvtptr_->in(__st, __frm, __frm_end, __frm_nxt,
+                                          __to, __to_end, __to_nxt);
+                __cvtcount_ += __frm_nxt - __frm;
+                if (__frm_nxt == __frm)
+                {
+                    __r = codecvt_base::error;
+                }
+                else if (__r == codecvt_base::noconv)
+                {
+                    __ws.resize(__to - &__ws[0]);
+                    // This only gets executed if _Elem is char
+                    __ws.append((const _Elem*)__frm, (const _Elem*)__frm_end);
+                    __frm = __frm_nxt;
+                    __r = codecvt_base::ok;
+                }
+                else if (__r == codecvt_base::ok)
+                {
+                    __ws.resize(__to_nxt - &__ws[0]);
+                    __frm = __frm_nxt;
+                }
+                else if (__r == codecvt_base::partial)
+                {
+                    ptrdiff_t __s = __to_nxt - &__ws[0];
+                    __ws.resize(2 * __s);
+                    __to = &__ws[0] + __s;
+                    __to_end = &__ws[0] + __ws.size();
+                    __frm = __frm_nxt;
+                }
+            } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
+        }
+        if (__r == codecvt_base::ok)
+            return __ws;
+    }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__wide_err_string_.empty())
+        throw range_error("wstring_convert: from_bytes error");
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __wide_err_string_;
+}
+
+template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc>
+typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::byte_string
+wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
+    to_bytes(const _Elem* __frm, const _Elem* __frm_end)
+{
+    __cvtcount_ = 0;
+    if (__cvtptr_ != nullptr)
+    {
+        byte_string __bs(2*(__frm_end - __frm), char());
+        if (__frm != __frm_end)
+            __bs.resize(__bs.capacity());
+        codecvt_base::result __r = codecvt_base::ok;
+        state_type __st = __cvtstate_;
+        if (__frm != __frm_end)
+        {
+            char* __to = &__bs[0];
+            char* __to_end = __to + __bs.size();
+            const _Elem* __frm_nxt;
+            do
+            {
+                char* __to_nxt;
+                __r = __cvtptr_->out(__st, __frm, __frm_end, __frm_nxt,
+                                           __to, __to_end, __to_nxt);
+                __cvtcount_ += __frm_nxt - __frm;
+                if (__frm_nxt == __frm)
+                {
+                    __r = codecvt_base::error;
+                }
+                else if (__r == codecvt_base::noconv)
+                {
+                    __bs.resize(__to - &__bs[0]);
+                    // This only gets executed if _Elem is char
+                    __bs.append((const char*)__frm, (const char*)__frm_end);
+                    __frm = __frm_nxt;
+                    __r = codecvt_base::ok;
+                }
+                else if (__r == codecvt_base::ok)
+                {
+                    __bs.resize(__to_nxt - &__bs[0]);
+                    __frm = __frm_nxt;
+                }
+                else if (__r == codecvt_base::partial)
+                {
+                    ptrdiff_t __s = __to_nxt - &__bs[0];
+                    __bs.resize(2 * __s);
+                    __to = &__bs[0] + __s;
+                    __to_end = &__bs[0] + __bs.size();
+                    __frm = __frm_nxt;
+                }
+            } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
+        }
+        if (__r == codecvt_base::ok)
+        {
+            size_t __s = __bs.size();
+            __bs.resize(__bs.capacity());
+            char* __to = &__bs[0] + __s;
+            char* __to_end = __to + __bs.size();
+            do
+            {
+                char* __to_nxt;
+                __r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt);
+                if (__r == codecvt_base::noconv)
+                {
+                    __bs.resize(__to - &__bs[0]);
+                    __r = codecvt_base::ok;
+                }
+                else if (__r == codecvt_base::ok)
+                {
+                    __bs.resize(__to_nxt - &__bs[0]);
+                }
+                else if (__r == codecvt_base::partial)
+                {
+                    ptrdiff_t __sp = __to_nxt - &__bs[0];
+                    __bs.resize(2 * __sp);
+                    __to = &__bs[0] + __sp;
+                    __to_end = &__bs[0] + __bs.size();
+                }
+            } while (__r == codecvt_base::partial);
+            if (__r == codecvt_base::ok)
+                return __bs;
+        }
+    }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__byte_err_string_.empty())
+        throw range_error("wstring_convert: to_bytes error");
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __byte_err_string_;
+}
+
+template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
+class _LIBCPP_TYPE_VIS_ONLY wbuffer_convert
+    : public basic_streambuf<_Elem, _Tr>
+{
+public:
+    // types:
+    typedef _Elem                          char_type;
+    typedef _Tr                            traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef typename _Codecvt::state_type  state_type;
+
+private:
+    char*       __extbuf_;
+    const char* __extbufnext_;
+    const char* __extbufend_;
+    char __extbuf_min_[8];
+    size_t __ebs_;
+    char_type* __intbuf_;
+    size_t __ibs_;
+    streambuf* __bufptr_;
+    _Codecvt* __cv_;
+    state_type __st_;
+    ios_base::openmode __cm_;
+    bool __owns_eb_;
+    bool __owns_ib_;
+    bool __always_noconv_;
+
+    wbuffer_convert(const wbuffer_convert&);
+    wbuffer_convert& operator=(const wbuffer_convert&);
+public:
+    _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0, 
+            _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
+    ~wbuffer_convert();
+
+    _LIBCPP_INLINE_VISIBILITY
+    streambuf* rdbuf() const {return __bufptr_;}
+    _LIBCPP_INLINE_VISIBILITY
+    streambuf* rdbuf(streambuf* __bytebuf)
+    {
+        streambuf* __r = __bufptr_;
+        __bufptr_ = __bytebuf;
+        return __r;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    state_type state() const {return __st_;}
+
+protected:
+    virtual int_type underflow();
+    virtual int_type pbackfail(int_type __c = traits_type::eof());
+    virtual int_type overflow (int_type __c = traits_type::eof());
+    virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s,
+                                                            streamsize __n);
+    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type __sp,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+    virtual int sync();
+
+private:
+    bool __read_mode();
+    void __write_mode();
+    wbuffer_convert* __close();
+};
+
+template <class _Codecvt, class _Elem, class _Tr>
+wbuffer_convert<_Codecvt, _Elem, _Tr>::
+    wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
+    : __extbuf_(0),
+      __extbufnext_(0),
+      __extbufend_(0),
+      __ebs_(0),
+      __intbuf_(0),
+      __ibs_(0),
+      __bufptr_(__bytebuf),
+      __cv_(__pcvt),
+      __st_(__state),
+      __cm_(0),
+      __owns_eb_(false),
+      __owns_ib_(false),
+      __always_noconv_(__cv_ ? __cv_->always_noconv() : false)
+{
+    setbuf(0, 4096);
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+wbuffer_convert<_Codecvt, _Elem, _Tr>::~wbuffer_convert()
+{
+    __close();
+    delete __cv_;
+    if (__owns_eb_)
+        delete [] __extbuf_;
+    if (__owns_ib_)
+        delete [] __intbuf_;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
+{
+    if (__cv_ == 0 || __bufptr_ == 0)
+        return traits_type::eof();
+    bool __initial = __read_mode();
+    char_type __1buf;
+    if (this->gptr() == 0)
+        this->setg(&__1buf, &__1buf+1, &__1buf+1);
+    const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
+    int_type __c = traits_type::eof();
+    if (this->gptr() == this->egptr())
+    {
+        memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
+        if (__always_noconv_)
+        {
+            streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz);
+            __nmemb = __bufptr_->sgetn((char*)this->eback() + __unget_sz, __nmemb);
+            if (__nmemb != 0)
+            {
+                this->setg(this->eback(),
+                           this->eback() + __unget_sz,
+                           this->eback() + __unget_sz + __nmemb);
+                __c = *this->gptr();
+            }
+        }
+        else
+        {
+            memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+            __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
+            __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
+            streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
+                                 static_cast<streamsize>(__extbufend_ - __extbufnext_));
+            codecvt_base::result __r;
+            state_type __svs = __st_;
+            streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb);
+            if (__nr != 0)
+            {
+                __extbufend_ = __extbufnext_ + __nr;
+                char_type*  __inext;
+                __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
+                                       this->eback() + __unget_sz,
+                                       this->egptr(), __inext);
+                if (__r == codecvt_base::noconv)
+                {
+                    this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_);
+                    __c = *this->gptr();
+                }
+                else if (__inext != this->eback() + __unget_sz)
+                {
+                    this->setg(this->eback(), this->eback() + __unget_sz, __inext);
+                    __c = *this->gptr();
+                }
+            }
+        }
+    }
+    else
+        __c = *this->gptr();
+    if (this->eback() == &__1buf)
+        this->setg(0, 0, 0);
+    return __c;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c)
+{
+    if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr())
+    {
+        if (traits_type::eq_int_type(__c, traits_type::eof()))
+        {
+            this->gbump(-1);
+            return traits_type::not_eof(__c);
+        }
+        if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
+        {
+            this->gbump(-1);
+            *this->gptr() = traits_type::to_char_type(__c);
+            return __c;
+        }
+    }
+    return traits_type::eof();
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
+{
+    if (__cv_ == 0 || __bufptr_ == 0)
+        return traits_type::eof();
+    __write_mode();
+    char_type __1buf;
+    char_type* __pb_save = this->pbase();
+    char_type* __epb_save = this->epptr();
+    if (!traits_type::eq_int_type(__c, traits_type::eof()))
+    {
+        if (this->pptr() == 0)
+            this->setp(&__1buf, &__1buf+1);
+        *this->pptr() = traits_type::to_char_type(__c);
+        this->pbump(1);
+    }
+    if (this->pptr() != this->pbase())
+    {
+        if (__always_noconv_)
+        {
+            streamsize __nmemb = static_cast<streamsize>(this->pptr() - this->pbase());
+            if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
+                return traits_type::eof();
+        }
+        else
+        {
+            char* __extbe = __extbuf_;
+            codecvt_base::result __r;
+            do
+            {
+                const char_type* __e;
+                __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
+                                        __extbuf_, __extbuf_ + __ebs_, __extbe);
+                if (__e == this->pbase())
+                    return traits_type::eof();
+                if (__r == codecvt_base::noconv)
+                {
+                    streamsize __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
+                    if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
+                        return traits_type::eof();
+                }
+                else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
+                {
+                    streamsize __nmemb = static_cast<size_t>(__extbe - __extbuf_);
+                    if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
+                        return traits_type::eof();
+                    if (__r == codecvt_base::partial)
+                    {
+                        this->setp((char_type*)__e, this->pptr());
+                        this->pbump(this->epptr() - this->pbase());
+                    }
+                }
+                else
+                    return traits_type::eof();
+            } while (__r == codecvt_base::partial);
+        }
+        this->setp(__pb_save, __epb_save);
+    }
+    return traits_type::not_eof(__c);
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+basic_streambuf<_Elem, _Tr>*
+wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n)
+{
+    this->setg(0, 0, 0);
+    this->setp(0, 0);
+    if (__owns_eb_)
+        delete [] __extbuf_;
+    if (__owns_ib_)
+        delete [] __intbuf_;
+    __ebs_ = __n;
+    if (__ebs_ > sizeof(__extbuf_min_))
+    {
+        if (__always_noconv_ && __s)
+        {
+            __extbuf_ = (char*)__s;
+            __owns_eb_ = false;
+        }
+        else
+        {
+            __extbuf_ = new char[__ebs_];
+            __owns_eb_ = true;
+        }
+    }
+    else
+    {
+        __extbuf_ = __extbuf_min_;
+        __ebs_ = sizeof(__extbuf_min_);
+        __owns_eb_ = false;
+    }
+    if (!__always_noconv_)
+    {
+        __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
+        if (__s && __ibs_ >= sizeof(__extbuf_min_))
+        {
+            __intbuf_ = __s;
+            __owns_ib_ = false;
+        }
+        else
+        {
+            __intbuf_ = new char_type[__ibs_];
+            __owns_ib_ = true;
+        }
+    }
+    else
+    {
+        __ibs_ = 0;
+        __intbuf_ = 0;
+        __owns_ib_ = false;
+    }
+    return this;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way,
+                                        ios_base::openmode __om)
+{
+    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:
+        return pos_type(off_type(-1));
+    }
+    pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om);
+    __r.state(__st_);
+    return __r;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
+wbuffer_convert<_Codecvt, _Elem, _Tr>::seekpos(pos_type __sp, ios_base::openmode __wch)
+{
+    if (__cv_ == 0 || __bufptr_ == 0 || sync())
+        return pos_type(off_type(-1));
+    if (__bufptr_->pubseekpos(__sp, __wch) == pos_type(off_type(-1)))
+        return pos_type(off_type(-1));
+    return __sp;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+int
+wbuffer_convert<_Codecvt, _Elem, _Tr>::sync()
+{
+    if (__cv_ == 0 || __bufptr_ == 0)
+        return 0;
+    if (__cm_ & ios_base::out)
+    {
+        if (this->pptr() != this->pbase())
+            if (overflow() == traits_type::eof())
+                return -1;
+        codecvt_base::result __r;
+        do
+        {
+            char* __extbe;
+            __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
+            streamsize __nmemb = static_cast<streamsize>(__extbe - __extbuf_);
+            if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
+                return -1;
+        } while (__r == codecvt_base::partial);
+        if (__r == codecvt_base::error)
+            return -1;
+        if (__bufptr_->pubsync())
+            return -1;
+    }
+    else if (__cm_ & ios_base::in)
+    {
+        off_type __c;
+        if (__always_noconv_)
+            __c = this->egptr() - this->gptr();
+        else
+        {
+            int __width = __cv_->encoding();
+            __c = __extbufend_ - __extbufnext_;
+            if (__width > 0)
+                __c += __width * (this->egptr() - this->gptr());
+            else
+            {
+                if (this->gptr() != this->egptr())
+                {
+                    reverse(this->gptr(), this->egptr());
+                    codecvt_base::result __r;
+                    const char_type* __e = this->gptr();
+                    char* __extbe;
+                    do
+                    {
+                        __r = __cv_->out(__st_, __e, this->egptr(), __e,
+                                         __extbuf_, __extbuf_ + __ebs_, __extbe);
+                        switch (__r)
+                        {
+                        case codecvt_base::noconv:
+                            __c += this->egptr() - this->gptr();
+                            break;
+                        case codecvt_base::ok:
+                        case codecvt_base::partial:
+                            __c += __extbe - __extbuf_;
+                            break;
+                        default:
+                            return -1;
+                        }
+                    } while (__r == codecvt_base::partial);
+                }
+            }
+        }
+        if (__bufptr_->pubseekoff(-__c, ios_base::cur, __cm_) == pos_type(off_type(-1)))
+            return -1;
+        this->setg(0, 0, 0);
+        __cm_ = 0;
+    }
+    return 0;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+bool
+wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode()
+{
+    if (!(__cm_ & ios_base::in))
+    {
+        this->setp(0, 0);
+        if (__always_noconv_)
+            this->setg((char_type*)__extbuf_,
+                       (char_type*)__extbuf_ + __ebs_,
+                       (char_type*)__extbuf_ + __ebs_);
+        else
+            this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
+        __cm_ = ios_base::in;
+        return true;
+    }
+    return false;
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+void
+wbuffer_convert<_Codecvt, _Elem, _Tr>::__write_mode()
+{
+    if (!(__cm_ & ios_base::out))
+    {
+        this->setg(0, 0, 0);
+        if (__ebs_ > sizeof(__extbuf_min_))
+        {
+            if (__always_noconv_)
+                this->setp((char_type*)__extbuf_,
+                           (char_type*)__extbuf_ + (__ebs_ - 1));
+            else
+                this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
+        }
+        else
+            this->setp(0, 0);
+        __cm_ = ios_base::out;
+    }
+}
+
+template <class _Codecvt, class _Elem, class _Tr>
+wbuffer_convert<_Codecvt, _Elem, _Tr>*
+wbuffer_convert<_Codecvt, _Elem, _Tr>::__close()
+{
+    wbuffer_convert* __rt = 0;
+    if (__cv_ != 0 && __bufptr_ != 0)
+    {
+        __rt = this;
+        if ((__cm_ & ios_base::out) && sync())
+            __rt = 0;
+    }
+    return __rt;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_LOCALE
diff --git a/final/include/map b/final/include/map
new file mode 100644
index 0000000..5534e40
--- /dev/null
+++ b/final/include/map
@@ -0,0 +1,2063 @@
+// -*- C++ -*-
+//===----------------------------- map ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_MAP
+#define _LIBCPP_MAP
+
+/*
+
+    map synopsis
+
+namespace std
+{
+
+template <class Key, class T, class Compare = less<Key>,
+          class Allocator = allocator<pair<const Key, T>>>
+class map
+{
+public:
+    // types:
+    typedef Key                                      key_type;
+    typedef T                                        mapped_type;
+    typedef pair<const key_type, mapped_type>        value_type;
+    typedef Compare                                  key_compare;
+    typedef Allocator                                allocator_type;
+    typedef typename allocator_type::reference       reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef typename allocator_type::pointer         pointer;
+    typedef typename allocator_type::const_pointer   const_pointer;
+    typedef typename allocator_type::size_type       size_type;
+    typedef typename allocator_type::difference_type difference_type;
+
+    typedef implementation-defined                   iterator;
+    typedef implementation-defined                   const_iterator;
+    typedef std::reverse_iterator<iterator>          reverse_iterator;
+    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+
+    class value_compare
+        : public binary_function<value_type, value_type, bool>
+    {
+        friend class map;
+    protected:
+        key_compare comp;
+
+        value_compare(key_compare c);
+    public:
+        bool operator()(const value_type& x, const value_type& y) const;
+    };
+
+    // construct/copy/destroy:
+    map()
+        noexcept(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value);
+    explicit map(const key_compare& comp);
+    map(const key_compare& comp, const allocator_type& a);
+    template <class InputIterator>
+        map(InputIterator first, InputIterator last,
+            const key_compare& comp = key_compare());
+    template <class InputIterator>
+        map(InputIterator first, InputIterator last,
+            const key_compare& comp, const allocator_type& a);
+    map(const map& m);
+    map(map&& m)
+        noexcept(
+            is_nothrow_move_constructible<allocator_type>::value &&
+            is_nothrow_move_constructible<key_compare>::value);
+    explicit map(const allocator_type& a);
+    map(const map& m, const allocator_type& a);
+    map(map&& m, const allocator_type& a);
+    map(initializer_list<value_type> il, const key_compare& comp = key_compare());
+    map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+    template <class InputIterator>
+        map(InputIterator first, InputIterator last, const allocator_type& a)
+            : map(first, last, Compare(), a) {}  // C++14
+    map(initializer_list<value_type> il, const allocator_type& a)
+        : map(il, Compare(), a) {}  // C++14
+   ~map();
+
+    map& operator=(const map& m);
+    map& operator=(map&& m)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<key_compare>::value);
+    map& operator=(initializer_list<value_type> il);
+
+    // iterators:
+          iterator begin() noexcept;
+    const_iterator begin() const noexcept;
+          iterator end() noexcept;
+    const_iterator end()   const noexcept;
+
+          reverse_iterator rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+          reverse_iterator rend() noexcept;
+    const_reverse_iterator rend()   const noexcept;
+
+    const_iterator         cbegin()  const noexcept;
+    const_iterator         cend()    const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend()   const noexcept;
+
+    // capacity:
+    bool      empty()    const noexcept;
+    size_type size()     const noexcept;
+    size_type max_size() const noexcept;
+
+    // element access:
+    mapped_type& operator[](const key_type& k);
+    mapped_type& operator[](key_type&& k);
+
+          mapped_type& at(const key_type& k);
+    const mapped_type& at(const key_type& k) const;
+
+    // modifiers:
+    template <class... Args>
+        pair<iterator, bool> emplace(Args&&... args);
+    template <class... Args>
+        iterator emplace_hint(const_iterator position, Args&&... args);
+    pair<iterator, bool> insert(const value_type& v);
+    template <class P>
+        pair<iterator, bool> insert(P&& p);
+    iterator insert(const_iterator position, const value_type& v);
+    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);
+
+    iterator  erase(const_iterator position);
+    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));
+
+    // observers:
+    allocator_type get_allocator() const noexcept;
+    key_compare    key_comp()      const;
+    value_compare  value_comp()    const;
+
+    // map operations:
+          iterator find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    template<typename K>
+        iterator find(const K& x);              // C++14
+    template<typename K>
+        const_iterator find(const K& x) const;  // C++14
+    template<typename K>
+      size_type count(const K& x) const;
+
+    size_type      count(const key_type& k) const;
+          iterator lower_bound(const key_type& k);
+    const_iterator lower_bound(const key_type& k) const;
+    template<typename K>
+        iterator lower_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator lower_bound(const K& x) const;  // C++14
+
+          iterator upper_bound(const key_type& k);
+    const_iterator upper_bound(const key_type& k) const;
+    template<typename K>
+        iterator upper_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator upper_bound(const K& x) const;  // C++14
+
+    pair<iterator,iterator>             equal_range(const key_type& k);
+    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+    template<typename K>
+        pair<iterator,iterator>             equal_range(const K& x);        // C++14
+    template<typename K>
+        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
+};
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator==(const map<Key, T, Compare, Allocator>& x,
+           const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator< (const map<Key, T, Compare, Allocator>& x,
+           const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator!=(const map<Key, T, Compare, Allocator>& x,
+           const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator> (const map<Key, T, Compare, Allocator>& x,
+           const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator>=(const map<Key, T, Compare, Allocator>& x,
+           const map<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator<=(const map<Key, T, Compare, Allocator>& x,
+           const map<Key, T, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class T, class Compare, class Allocator>
+void
+swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y)
+    noexcept(noexcept(x.swap(y)));
+
+template <class Key, class T, class Compare = less<Key>,
+          class Allocator = allocator<pair<const Key, T>>>
+class multimap
+{
+public:
+    // types:
+    typedef Key                                      key_type;
+    typedef T                                        mapped_type;
+    typedef pair<const key_type,mapped_type>         value_type;
+    typedef Compare                                  key_compare;
+    typedef Allocator                                allocator_type;
+    typedef typename allocator_type::reference       reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef typename allocator_type::size_type       size_type;
+    typedef typename allocator_type::difference_type difference_type;
+    typedef typename allocator_type::pointer         pointer;
+    typedef typename allocator_type::const_pointer   const_pointer;
+
+    typedef implementation-defined                   iterator;
+    typedef implementation-defined                   const_iterator;
+    typedef std::reverse_iterator<iterator>          reverse_iterator;
+    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+
+    class value_compare
+        : public binary_function<value_type,value_type,bool>
+    {
+        friend class multimap;
+    protected:
+        key_compare comp;
+        value_compare(key_compare c);
+    public:
+        bool operator()(const value_type& x, const value_type& y) const;
+    };
+
+    // construct/copy/destroy:
+    multimap()
+        noexcept(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value);
+    explicit multimap(const key_compare& comp);
+    multimap(const key_compare& comp, const allocator_type& a);
+    template <class InputIterator>
+        multimap(InputIterator first, InputIterator last, const key_compare& comp);
+    template <class InputIterator>
+        multimap(InputIterator first, InputIterator last, const key_compare& comp,
+                 const allocator_type& a);
+    multimap(const multimap& m);
+    multimap(multimap&& m)
+        noexcept(
+            is_nothrow_move_constructible<allocator_type>::value &&
+            is_nothrow_move_constructible<key_compare>::value);
+    explicit multimap(const allocator_type& a);
+    multimap(const multimap& m, const allocator_type& a);
+    multimap(multimap&& m, const allocator_type& a);
+    multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+    multimap(initializer_list<value_type> il, const key_compare& comp,
+             const allocator_type& a);
+    template <class InputIterator>
+        multimap(InputIterator first, InputIterator last, const allocator_type& a)
+            : multimap(first, last, Compare(), a) {} // C++14
+    multimap(initializer_list<value_type> il, const allocator_type& a)
+        : multimap(il, Compare(), a) {} // C++14
+    ~multimap();
+
+    multimap& operator=(const multimap& m);
+    multimap& operator=(multimap&& m)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<key_compare>::value);
+    multimap& operator=(initializer_list<value_type> il);
+
+    // iterators:
+          iterator begin() noexcept;
+    const_iterator begin() const noexcept;
+          iterator end() noexcept;
+    const_iterator end()   const noexcept;
+
+          reverse_iterator rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+          reverse_iterator rend() noexcept;
+    const_reverse_iterator rend()   const noexcept;
+
+    const_iterator         cbegin()  const noexcept;
+    const_iterator         cend()    const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend()   const noexcept;
+
+    // capacity:
+    bool      empty()    const noexcept;
+    size_type size()     const noexcept;
+    size_type max_size() const noexcept;
+
+    // modifiers:
+    template <class... Args>
+        iterator emplace(Args&&... args);
+    template <class... Args>
+        iterator emplace_hint(const_iterator position, Args&&... args);
+    iterator insert(const value_type& v);
+    template <class P>
+        iterator insert(P&& p);
+    iterator insert(const_iterator position, const value_type& v);
+    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);
+
+    iterator  erase(const_iterator position);
+    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));
+
+    // observers:
+    allocator_type get_allocator() const noexcept;
+    key_compare    key_comp()      const;
+    value_compare  value_comp()    const;
+
+    // map operations:
+          iterator find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    template<typename K>
+        iterator find(const K& x);              // C++14
+    template<typename K>
+        const_iterator find(const K& x) const;  // C++14
+    template<typename K>
+      size_type count(const K& x) const;
+
+    size_type      count(const key_type& k) const;
+          iterator lower_bound(const key_type& k);
+    const_iterator lower_bound(const key_type& k) const;
+    template<typename K>
+        iterator lower_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator lower_bound(const K& x) const;  // C++14
+
+          iterator upper_bound(const key_type& k);
+    const_iterator upper_bound(const key_type& k) const;
+    template<typename K>
+        iterator upper_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator upper_bound(const K& x) const;  // C++14
+
+    pair<iterator,iterator>             equal_range(const key_type& k);
+    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+    template<typename K>
+        pair<iterator,iterator>             equal_range(const K& x);        // C++14
+    template<typename K>
+        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
+};
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator==(const multimap<Key, T, Compare, Allocator>& x,
+           const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator< (const multimap<Key, T, Compare, Allocator>& x,
+           const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator!=(const multimap<Key, T, Compare, Allocator>& x,
+           const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator> (const multimap<Key, T, Compare, Allocator>& x,
+           const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator>=(const multimap<Key, T, Compare, Allocator>& x,
+           const multimap<Key, T, Compare, Allocator>& y);
+
+template <class Key, class T, class Compare, class Allocator>
+bool
+operator<=(const multimap<Key, T, Compare, Allocator>& x,
+           const multimap<Key, T, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class T, class Compare, class Allocator>
+void
+swap(multimap<Key, T, Compare, Allocator>& x,
+     multimap<Key, T, Compare, Allocator>& y)
+    noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__tree>
+#include <iterator>
+#include <memory>
+#include <utility>
+#include <functional>
+#include <initializer_list>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_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
+         >
+class __map_value_compare
+    : private _Compare
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __map_value_compare()
+        _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
+        : _Compare() {}
+    _LIBCPP_INLINE_VISIBILITY
+    __map_value_compare(_Compare c)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
+        : _Compare(c) {}
+    _LIBCPP_INLINE_VISIBILITY
+    const _Compare& key_comp() const _NOEXCEPT {return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _CP& __x, const _CP& __y) const
+        {return static_cast<const _Compare&>(*this)(__x.__cc.first, __y.__cc.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _CP& __x, const _Key& __y) const
+        {return static_cast<const _Compare&>(*this)(__x.__cc.first, __y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Key& __x, const _CP& __y) const
+        {return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);}
+
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+    operator () ( const _K2& __x, const _CP& __y ) const
+        {return static_cast<const _Compare&>(*this) (__x, __y.__cc.first);}
+
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+    operator () (const _CP& __x, const _K2& __y) const
+        {return static_cast<const _Compare&>(*this) (__x.__cc.first, __y);}
+#endif
+};
+
+template <class _Key, class _CP, class _Compare>
+class __map_value_compare<_Key, _CP, _Compare, false>
+{
+    _Compare comp;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __map_value_compare()
+        _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
+        : comp() {}
+    _LIBCPP_INLINE_VISIBILITY
+    __map_value_compare(_Compare c)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
+        : comp(c) {}
+    _LIBCPP_INLINE_VISIBILITY
+    const _Compare& key_comp() const _NOEXCEPT {return comp;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _CP& __x, const _CP& __y) const
+        {return comp(__x.__cc.first, __y.__cc.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _CP& __x, const _Key& __y) const
+        {return comp(__x.__cc.first, __y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Key& __x, const _CP& __y) const
+        {return comp(__x, __y.__cc.first);}
+
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+    operator () ( const _K2& __x, const _CP& __y ) const
+        {return comp (__x, __y.__cc.first);}
+
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type
+    operator () (const _CP& __x, const _K2& __y) const
+        {return comp (__x.__cc.first, __y);}
+#endif
+};
+
+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;
+
+    allocator_type& __na_;
+
+    __map_node_destructor& operator=(const __map_node_destructor&);
+
+public:
+    bool __first_constructed;
+    bool __second_constructed;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __map_node_destructor(allocator_type& __na) _NOEXCEPT
+        : __na_(__na),
+          __first_constructed(false),
+          __second_constructed(false)
+        {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT
+        : __na_(__x.__na_),
+          __first_constructed(__x.__value_constructed),
+          __second_constructed(__x.__value_constructed)
+        {
+            __x.__value_constructed = false;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    void operator()(pointer __p) _NOEXCEPT
+    {
+        if (__second_constructed)
+            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
+        if (__first_constructed)
+            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
+        if (__p)
+            __alloc_traits::deallocate(__na_, __p, 1);
+    }
+};
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+    class map;
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+    class multimap;
+template <class _TreeIterator> class __map_const_iterator;
+
+#if __cplusplus >= 201103L
+
+template <class _Key, class _Tp>
+union __value_type
+{
+    typedef _Key                                     key_type;
+    typedef _Tp                                      mapped_type;
+    typedef pair<const key_type, mapped_type>        value_type;
+    typedef pair<key_type, mapped_type>              __nc_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;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__value_type() {__cc.~value_type();}
+};
+
+#else
+
+template <class _Key, class _Tp>
+struct __value_type
+{
+    typedef _Key                                     key_type;
+    typedef _Tp                                      mapped_type;
+    typedef pair<const key_type, mapped_type>        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) {}
+};
+
+#endif
+
+template <class _TreeIterator>
+class _LIBCPP_TYPE_VIS_ONLY __map_iterator
+{
+    _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 _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;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __map_iterator() _NOEXCEPT {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return __i_->__cc;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __map_iterator& operator++() {++__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __map_iterator operator++(int)
+    {
+        __map_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __map_iterator& operator--() {--__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __map_iterator operator--(int)
+    {
+        __map_iterator __t(*this);
+        --(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __map_iterator& __x, const __map_iterator& __y)
+        {return __x.__i_ == __y.__i_;}
+    friend 
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
+        {return __x.__i_ != __y.__i_;}
+
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator;
+};
+
+template <class _TreeIterator>
+class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator
+{
+    _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 _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;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __map_const_iterator() _NOEXCEPT {}
+
+    _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_) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return __i_->__cc;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __map_const_iterator& operator++() {++__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __map_const_iterator operator++(int)
+    {
+        __map_const_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __map_const_iterator& operator--() {--__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __map_const_iterator operator--(int)
+    {
+        __map_const_iterator __t(*this);
+        --(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y)
+        {return __x.__i_ == __y.__i_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y)
+        {return __x.__i_ != __y.__i_;}
+
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map;
+    template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap;
+    template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
+};
+
+template <class _Key, class _Tp, class _Compare = less<_Key>,
+          class _Allocator = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TYPE_VIS_ONLY map
+{
+public:
+    // types:
+    typedef _Key                                     key_type;
+    typedef _Tp                                      mapped_type;
+    typedef pair<const key_type, mapped_type>        value_type;
+    typedef pair<key_type, mapped_type>              __nc_value_type;
+    typedef _Compare                                 key_compare;
+    typedef _Allocator                               allocator_type;
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+
+    class _LIBCPP_TYPE_VIS_ONLY value_compare
+        : public binary_function<value_type, value_type, bool>
+    {
+        friend class map;
+    protected:
+        key_compare comp;
+
+        _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {}
+    public:
+        _LIBCPP_INLINE_VISIBILITY
+        bool operator()(const value_type& __x, const value_type& __y) const
+            {return comp(__x.first, __y.first);}
+    };
+
+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 __tree<__value_type, __vc, __allocator_type>   __base;
+    typedef typename __base::__node_traits                 __node_traits;
+    typedef allocator_traits<allocator_type>               __alloc_traits;
+
+    __base __tree_;
+
+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 __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;
+
+    _LIBCPP_INLINE_VISIBILITY
+    map()
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(__vc(key_compare())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit map(const key_compare& __comp)
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(__vc(__comp)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit map(const key_compare& __comp, const allocator_type& __a)
+        : __tree_(__vc(__comp), __a) {}
+
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY
+        map(_InputIterator __f, _InputIterator __l,
+            const key_compare& __comp = key_compare())
+        : __tree_(__vc(__comp))
+        {
+            insert(__f, __l);
+        }
+
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY
+        map(_InputIterator __f, _InputIterator __l,
+            const key_compare& __comp, const allocator_type& __a)
+        : __tree_(__vc(__comp), __a)
+        {
+            insert(__f, __l);
+        }
+
+#if _LIBCPP_STD_VER > 11
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY 
+    map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+        : map(__f, __l, key_compare(), __a) {}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    map(const map& __m)
+        : __tree_(__m.__tree_)
+        {
+            insert(__m.begin(), __m.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    map& operator=(const map& __m)
+        {
+#if __cplusplus >= 201103L
+            __tree_ = __m.__tree_;
+#else
+            if (this != &__m) {
+                __tree_.clear();
+                __tree_.value_comp() = __m.__tree_.value_comp();
+                __tree_.__copy_assign_alloc(__m.__tree_);
+                insert(__m.begin(), __m.end());
+            }
+#endif
+            return *this;
+        }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    map(map&& __m)
+        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+        : __tree_(_VSTD::move(__m.__tree_))
+        {
+        }
+
+    map(map&& __m, const allocator_type& __a);
+
+    _LIBCPP_INLINE_VISIBILITY
+    map& operator=(map&& __m)
+        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+        {
+            __tree_ = _VSTD::move(__m.__tree_);
+            return *this;
+        }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
+        : __tree_(__vc(__comp))
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
+        : __tree_(__vc(__comp), __a)
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+#if _LIBCPP_STD_VER > 11
+    _LIBCPP_INLINE_VISIBILITY 
+    map(initializer_list<value_type> __il, const allocator_type& __a)
+        : map(__il, key_compare(), __a) {}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    map& operator=(initializer_list<value_type> __il)
+        {
+            __tree_.__assign_unique(__il.begin(), __il.end());
+            return *this;
+        }
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit map(const allocator_type& __a)
+        : __tree_(__a)
+        {
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    map(const map& __m, const allocator_type& __a)
+        : __tree_(__m.__tree_.value_comp(), __a)
+        {
+            insert(__m.begin(), __m.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+          iterator begin() _NOEXCEPT {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+          iterator end() _NOEXCEPT {return __tree_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT {return __tree_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rend() _NOEXCEPT
+            {return       reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend() const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const _NOEXCEPT {return __tree_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT {return __tree_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+    mapped_type& operator[](const key_type& __k);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    mapped_type& operator[](key_type&& __k);
+#endif
+
+          mapped_type& at(const key_type& __k);
+    const mapped_type& at(const key_type& __k) const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_compare    key_comp()      const {return __tree_.value_comp().key_comp();}
+    _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
+
+    template <class ..._Args>
+        pair<iterator, bool>
+        emplace(_Args&& ...__args);
+
+    template <class ..._Args>
+        iterator
+        emplace_hint(const_iterator __p, _Args&& ...__args);
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    template <class _Pp,
+              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> insert(_Pp&& __p)
+            {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));}
+
+    template <class _Pp,
+              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator insert(const_iterator __pos, _Pp&& __p)
+            {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool>
+        insert(const value_type& __v) {return __tree_.__insert_unique(__v);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator
+        insert(const_iterator __p, const value_type& __v)
+            {return __tree_.__insert_unique(__p.__i_, __v);}
+
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        void insert(_InputIterator __f, _InputIterator __l)
+        {
+            for (const_iterator __e = cend(); __f != __l; ++__f)
+                insert(__e.__i_, *__f);
+        }
+
+#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
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator erase(const_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
+    iterator  erase(const_iterator __f, const_iterator __l)
+        {return __tree_.erase(__f.__i_, __l.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__tree_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(map& __m)
+        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+        {__tree_.swap(__m.__tree_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator find(const key_type& __k)             {return __tree_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    find(const _K2& __k)                           {return __tree_.find(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    find(const _K2& __k) const                     {return __tree_.find(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type      count(const key_type& __k) const
+        {return __tree_.__count_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator lower_bound(const key_type& __k)
+        {return __tree_.lower_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator lower_bound(const key_type& __k) const
+        {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
+
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator upper_bound(const key_type& __k)
+        {return __tree_.upper_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator upper_bound(const key_type& __k) const
+        {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator,iterator> equal_range(const key_type& __k)
+        {return __tree_.__equal_range_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+        {return __tree_.__equal_range_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+    equal_range(const _K2& __k)       {return __tree_.__equal_range_unique(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+    equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
+#endif
+
+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
+    __node_holder __construct_node_with_key(const key_type& __k);
+
+    __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 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,
+                                                       const key_type& __k) const
+{
+    __node_const_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 const_cast<const __node_base_const_pointer&>(__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 const_cast<const __node_base_const_pointer&>(__parent->__right_);
+                }
+            }
+            else
+            {
+                __parent = static_cast<__node_base_pointer>(__nd);
+                return __parent;
+            }
+        }
+    }
+    __parent = static_cast<__node_base_pointer>(__tree_.__end_node());
+    return const_cast<const __node_base_const_pointer&>(__parent->__left_);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
+    : __tree_(_VSTD::move(__m.__tree_), __a)
+{
+    if (__a != __m.get_allocator())
+    {
+        const_iterator __e = cend();
+        while (!__m.empty())
+            __tree_.__insert_unique(__e.__i_,
+                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
+    }
+}
+
+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;
+}
+
+#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
+
+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(const 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), __k);
+    __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
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+_Tp&
+map<_Key, _Tp, _Compare, _Allocator>::operator[](const 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(__k);
+        __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+        __r = __h.release();
+    }
+    return __r->__value_.__cc.second;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+_Tp&
+map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __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_pointer>(__child)->__value_.__cc.second;
+}
+
+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);
+#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;
+}
+
+#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
+bool
+operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+           const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const map<_Key, _Tp, _Compare, _Allocator>& __x,
+           const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+           const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const map<_Key, _Tp, _Compare, _Allocator>& __x,
+           const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+           const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x,
+           const map<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
+     map<_Key, _Tp, _Compare, _Allocator>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Key, class _Tp, class _Compare = less<_Key>,
+          class _Allocator = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TYPE_VIS_ONLY multimap
+{
+public:
+    // types:
+    typedef _Key                                     key_type;
+    typedef _Tp                                      mapped_type;
+    typedef pair<const key_type, mapped_type>        value_type;
+    typedef pair<key_type, mapped_type>              __nc_value_type;
+    typedef _Compare                                 key_compare;
+    typedef _Allocator                               allocator_type;
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+
+    class _LIBCPP_TYPE_VIS_ONLY value_compare
+        : public binary_function<value_type, value_type, bool>
+    {
+        friend class multimap;
+    protected:
+        key_compare comp;
+
+        _LIBCPP_INLINE_VISIBILITY
+        value_compare(key_compare c) : comp(c) {}
+    public:
+        _LIBCPP_INLINE_VISIBILITY
+        bool operator()(const value_type& __x, const value_type& __y) const
+            {return comp(__x.first, __y.first);}
+    };
+
+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 __tree<__value_type, __vc, __allocator_type>            __base;
+    typedef typename __base::__node_traits                          __node_traits;
+    typedef allocator_traits<allocator_type>                        __alloc_traits;
+
+    __base __tree_;
+
+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 __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;
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap()
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(__vc(key_compare())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit multimap(const key_compare& __comp)
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(__vc(__comp)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit multimap(const key_compare& __comp, const allocator_type& __a)
+        : __tree_(__vc(__comp), __a) {}
+
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        multimap(_InputIterator __f, _InputIterator __l,
+            const key_compare& __comp = key_compare())
+        : __tree_(__vc(__comp))
+        {
+            insert(__f, __l);
+        }
+
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        multimap(_InputIterator __f, _InputIterator __l,
+            const key_compare& __comp, const allocator_type& __a)
+        : __tree_(__vc(__comp), __a)
+        {
+            insert(__f, __l);
+        }
+
+#if _LIBCPP_STD_VER > 11
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY 
+    multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+        : multimap(__f, __l, key_compare(), __a) {}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap(const multimap& __m)
+        : __tree_(__m.__tree_.value_comp(),
+          __alloc_traits::select_on_container_copy_construction(__m.__tree_.__alloc()))
+        {
+            insert(__m.begin(), __m.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap& operator=(const multimap& __m)
+        {
+#if __cplusplus >= 201103L
+            __tree_ = __m.__tree_;
+#else
+            if (this != &__m) {
+                __tree_.clear();
+                __tree_.value_comp() = __m.__tree_.value_comp();
+                __tree_.__copy_assign_alloc(__m.__tree_);
+                insert(__m.begin(), __m.end());
+            }
+#endif
+            return *this;
+        }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap(multimap&& __m)
+        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+        : __tree_(_VSTD::move(__m.__tree_))
+        {
+        }
+
+    multimap(multimap&& __m, const allocator_type& __a);
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap& operator=(multimap&& __m)
+        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+        {
+            __tree_ = _VSTD::move(__m.__tree_);
+            return *this;
+        }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
+        : __tree_(__vc(__comp))
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
+        : __tree_(__vc(__comp), __a)
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+#if _LIBCPP_STD_VER > 11
+    _LIBCPP_INLINE_VISIBILITY 
+    multimap(initializer_list<value_type> __il, const allocator_type& __a)
+        : multimap(__il, key_compare(), __a) {}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap& operator=(initializer_list<value_type> __il)
+        {
+            __tree_.__assign_multi(__il.begin(), __il.end());
+            return *this;
+        }
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit multimap(const allocator_type& __a)
+        : __tree_(__a)
+        {
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    multimap(const multimap& __m, const allocator_type& __a)
+        : __tree_(__m.__tree_.value_comp(), __a)
+        {
+            insert(__m.begin(), __m.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+          iterator begin() _NOEXCEPT {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+          iterator end() _NOEXCEPT {return __tree_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT {return __tree_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend() const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin()  const _NOEXCEPT {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT {return __tree_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_compare    key_comp() const {return __tree_.value_comp().key_comp();}
+    _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
+
+    template <class ..._Args>
+        iterator
+        emplace(_Args&& ...__args);
+
+    template <class ..._Args>
+        iterator
+        emplace_hint(const_iterator __p, _Args&& ...__args);
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    template <class _Pp,
+              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator insert(_Pp&& __p)
+            {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));}
+
+    template <class _Pp,
+              class = typename enable_if<is_constructible<value_type, _Pp>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY
+        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(const value_type& __v) {return __tree_.__insert_multi(__v);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, const value_type& __v)
+            {return __tree_.__insert_multi(__p.__i_, __v);}
+
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        void insert(_InputIterator __f, _InputIterator __l)
+        {
+            for (const_iterator __e = cend(); __f != __l; ++__f)
+                __tree_.__insert_multi(__e.__i_, *__f);
+        }
+
+#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
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator erase(const_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)
+        {return __tree_.erase(__f.__i_, __l.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() {__tree_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(multimap& __m)
+        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+        {__tree_.swap(__m.__tree_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator find(const key_type& __k)             {return __tree_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    find(const _K2& __k)                           {return __tree_.find(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    find(const _K2& __k) const                     {return __tree_.find(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type      count(const key_type& __k) const
+        {return __tree_.__count_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator lower_bound(const key_type& __k)
+        {return __tree_.lower_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator lower_bound(const key_type& __k) const
+            {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
+
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator upper_bound(const key_type& __k)
+            {return __tree_.upper_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator upper_bound(const key_type& __k) const
+            {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator,iterator>             equal_range(const key_type& __k)
+            {return __tree_.__equal_range_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+            {return __tree_.__equal_range_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
+#endif
+
+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
+
+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)
+{
+    if (__a != __m.get_allocator())
+    {
+        const_iterator __e = cend();
+        while (!__m.empty())
+            __tree_.__insert_multi(__e.__i_,
+                    _VSTD::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
+    }
+}
+
+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)
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+           const multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Key, class _Tp, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,
+     multimap<_Key, _Tp, _Compare, _Allocator>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_MAP
diff --git a/final/include/memory b/final/include/memory
new file mode 100644
index 0000000..dc9aeba
--- /dev/null
+++ b/final/include/memory
@@ -0,0 +1,5429 @@
+// -*- C++ -*-
+//===-------------------------- memory ------------------------------------===//
+//
+//                     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_MEMORY
+#define _LIBCPP_MEMORY
+
+/*
+    memory synopsis
+
+namespace std
+{
+
+struct allocator_arg_t { };
+constexpr allocator_arg_t allocator_arg = allocator_arg_t();
+
+template <class T, class Alloc> struct uses_allocator;
+
+template <class Ptr>
+struct pointer_traits
+{
+    typedef Ptr pointer;
+    typedef <details> element_type;
+    typedef <details> difference_type;
+
+    template <class U> using rebind = <details>;
+
+    static pointer pointer_to(<details>);
+};
+
+template <class T>
+struct pointer_traits<T*>
+{
+    typedef T* pointer;
+    typedef T element_type;
+    typedef ptrdiff_t difference_type;
+
+    template <class U> using rebind = U*;
+
+    static pointer pointer_to(<details>) noexcept;
+};
+
+template <class Alloc>
+struct allocator_traits
+{
+    typedef Alloc                        allocator_type;
+    typedef typename allocator_type::value_type
+                                         value_type;
+
+    typedef Alloc::pointer | value_type* pointer;
+    typedef Alloc::const_pointer
+          | pointer_traits<pointer>::rebind<const value_type>
+                                         const_pointer;
+    typedef Alloc::void_pointer
+          | pointer_traits<pointer>::rebind<void>
+                                         void_pointer;
+    typedef Alloc::const_void_pointer
+          | pointer_traits<pointer>::rebind<const void>
+                                         const_void_pointer;
+    typedef Alloc::difference_type
+          | pointer_traits<pointer>::difference_type
+                                         difference_type;
+    typedef Alloc::size_type
+          | make_unsigned<difference_type>::type
+                                         size_type;
+    typedef Alloc::propagate_on_container_copy_assignment
+          | false_type                   propagate_on_container_copy_assignment;
+    typedef Alloc::propagate_on_container_move_assignment
+          | false_type                   propagate_on_container_move_assignment;
+    typedef Alloc::propagate_on_container_swap
+          | false_type                   propagate_on_container_swap;
+
+    template <class T> using rebind_alloc  = Alloc::rebind<U>::other | Alloc<T, Args...>;
+    template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+
+    static pointer allocate(allocator_type& a, size_type n);
+    static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
+
+    static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
+
+    template <class T, class... Args>
+        static void construct(allocator_type& a, T* p, Args&&... args);
+
+    template <class T>
+        static void destroy(allocator_type& a, T* p);
+
+    static size_type max_size(const allocator_type& a); // noexcept in C++14
+
+    static allocator_type
+        select_on_container_copy_construction(const allocator_type& a);
+};
+
+template <>
+class allocator<void>
+{
+public:
+    typedef void*                                 pointer;
+    typedef const void*                           const_pointer;
+    typedef void                                  value_type;
+
+    template <class _Up> struct rebind {typedef allocator<_Up> other;};
+};
+
+template <class T>
+class allocator
+{
+public:
+    typedef size_t                                size_type;
+    typedef ptrdiff_t                             difference_type;
+    typedef T*                                    pointer;
+    typedef const T*                              const_pointer;
+    typedef typename add_lvalue_reference<T>::type       reference;
+    typedef typename add_lvalue_reference<const T>::type const_reference;
+    typedef T                                     value_type;
+
+    template <class U> struct rebind {typedef allocator<U> other;};
+
+    allocator() noexcept;
+    allocator(const allocator&) noexcept;
+    template <class U> allocator(const allocator<U>&) noexcept;
+    ~allocator();
+    pointer address(reference x) const noexcept;
+    const_pointer address(const_reference x) const noexcept;
+    pointer allocate(size_type, allocator<void>::const_pointer hint = 0);
+    void deallocate(pointer p, size_type n) noexcept;
+    size_type max_size() const noexcept;
+    template<class U, class... Args>
+        void construct(U* p, Args&&... args);
+    template <class U>
+        void destroy(U* p);
+};
+
+template <class T, class U>
+bool operator==(const allocator<T>&, const allocator<U>&) noexcept;
+
+template <class T, class U>
+bool operator!=(const allocator<T>&, const allocator<U>&) noexcept;
+
+template <class OutputIterator, class T>
+class raw_storage_iterator
+    : public iterator<output_iterator_tag,
+                      T,                               // purposefully not C++03
+                      ptrdiff_t,                       // purposefully not C++03
+                      T*,                              // purposefully not C++03
+                      raw_storage_iterator&>           // purposefully not C++03
+{
+public:
+    explicit raw_storage_iterator(OutputIterator x);
+    raw_storage_iterator& operator*();
+    raw_storage_iterator& operator=(const T& element);
+    raw_storage_iterator& operator++();
+    raw_storage_iterator  operator++(int);
+};
+
+template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept;
+template <class T> void               return_temporary_buffer(T* p) noexcept;
+
+template <class T> T* addressof(T& r) noexcept;
+
+template <class InputIterator, class ForwardIterator>
+ForwardIterator
+uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result);
+
+template <class InputIterator, class Size, class ForwardIterator>
+ForwardIterator
+uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result);
+
+template <class ForwardIterator, class T>
+void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x);
+
+template <class ForwardIterator, class Size, class T>
+ForwardIterator
+uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+
+template <class Y> struct auto_ptr_ref {};
+
+template<class X>
+class auto_ptr
+{
+public:
+    typedef X element_type;
+
+    explicit auto_ptr(X* p =0) throw();
+    auto_ptr(auto_ptr&) throw();
+    template<class Y> auto_ptr(auto_ptr<Y>&) throw();
+    auto_ptr& operator=(auto_ptr&) throw();
+    template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
+    auto_ptr& operator=(auto_ptr_ref<X> r) throw();
+    ~auto_ptr() throw();
+
+    typename add_lvalue_reference<X>::type operator*() const throw();
+    X* operator->() const throw();
+    X* get() const throw();
+    X* release() throw();
+    void reset(X* p =0) throw();
+
+    auto_ptr(auto_ptr_ref<X>) throw();
+    template<class Y> operator auto_ptr_ref<Y>() throw();
+    template<class Y> operator auto_ptr<Y>() throw();
+};
+
+template <class T>
+struct default_delete
+{
+    constexpr default_delete() noexcept = default;
+    template <class U> default_delete(const default_delete<U>&) noexcept;
+
+    void operator()(T*) const noexcept;
+};
+
+template <class T>
+struct default_delete<T[]>
+{
+    constexpr default_delete() noexcept = default;
+    void operator()(T*) const noexcept;
+    template <class U> void operator()(U*) const = delete;
+};
+
+template <class T, class D = default_delete<T>>
+class unique_ptr
+{
+public:
+    typedef see below pointer;
+    typedef T element_type;
+    typedef D deleter_type;
+
+    // constructors
+    constexpr unique_ptr() noexcept;
+    explicit unique_ptr(pointer p) noexcept;
+    unique_ptr(pointer p, see below d1) noexcept;
+    unique_ptr(pointer p, see below d2) noexcept;
+    unique_ptr(unique_ptr&& u) noexcept;
+    unique_ptr(nullptr_t) noexcept : unique_ptr() { }
+    template <class U, class E>
+        unique_ptr(unique_ptr<U, E>&& u) noexcept;
+    template <class U>
+        unique_ptr(auto_ptr<U>&& u) noexcept;
+
+    // destructor
+    ~unique_ptr();
+
+    // assignment
+    unique_ptr& operator=(unique_ptr&& u) noexcept;
+    template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
+    unique_ptr& operator=(nullptr_t) noexcept;
+
+    // observers
+    typename add_lvalue_reference<T>::type operator*() const;
+    pointer operator->() const noexcept;
+    pointer get() const noexcept;
+    deleter_type& get_deleter() noexcept;
+    const deleter_type& get_deleter() const noexcept;
+    explicit operator bool() const noexcept;
+
+    // modifiers
+    pointer release() noexcept;
+    void reset(pointer p = pointer()) noexcept;
+    void swap(unique_ptr& u) noexcept;
+};
+
+template <class T, class D>
+class unique_ptr<T[], D>
+{
+public:
+    typedef implementation-defined pointer;
+    typedef T element_type;
+    typedef D deleter_type;
+
+    // constructors
+    constexpr unique_ptr() noexcept;
+    explicit unique_ptr(pointer p) noexcept;
+    unique_ptr(pointer p, see below d) noexcept;
+    unique_ptr(pointer p, see below d) noexcept;
+    unique_ptr(unique_ptr&& u) noexcept;
+    unique_ptr(nullptr_t) noexcept : unique_ptr() { }
+
+    // destructor
+    ~unique_ptr();
+
+    // assignment
+    unique_ptr& operator=(unique_ptr&& u) noexcept;
+    unique_ptr& operator=(nullptr_t) noexcept;
+
+    // observers
+    T& operator[](size_t i) const;
+    pointer get() const noexcept;
+    deleter_type& get_deleter() noexcept;
+    const deleter_type& get_deleter() const noexcept;
+    explicit operator bool() const noexcept;
+
+    // modifiers
+    pointer release() noexcept;
+    void reset(pointer p = pointer()) noexcept;
+    void reset(nullptr_t) noexcept;
+    template <class U> void reset(U) = delete;
+    void swap(unique_ptr& u) noexcept;
+};
+
+template <class T, class D>
+    void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
+
+template <class T1, class D1, class T2, class D2>
+    bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+    bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+    bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+    bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+    bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+template <class T1, class D1, class T2, class D2>
+    bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+template <class T, class D>
+    bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+template <class T, class D>
+    bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+template <class T, class D>
+    bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+template <class T, class D>
+    bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+
+template <class T, class D>
+    bool operator<(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+    bool operator<(nullptr_t, const unique_ptr<T, D>& y);
+template <class T, class D>
+    bool operator<=(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+    bool operator<=(nullptr_t, const unique_ptr<T, D>& y);
+template <class T, class D>
+    bool operator>(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+    bool operator>(nullptr_t, const unique_ptr<T, D>& y);
+template <class T, class D>
+    bool operator>=(const unique_ptr<T, D>& x, nullptr_t);
+template <class T, class D>
+    bool operator>=(nullptr_t, const unique_ptr<T, D>& y);
+
+class bad_weak_ptr
+    : public std::exception
+{
+    bad_weak_ptr() noexcept;
+};
+
+template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args);     // C++14
+template<class T>                unique_ptr<T> make_unique(size_t n);           // C++14
+template<class T, class... Args> unspecified   make_unique(Args&&...) = delete; // C++14, T == U[N]
+
+template<class T>
+class shared_ptr
+{
+public:
+    typedef T element_type;
+
+    // constructors:
+    constexpr shared_ptr() noexcept;
+    template<class Y> explicit shared_ptr(Y* p);
+    template<class Y, class D> shared_ptr(Y* p, D d);
+    template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+    template <class D> shared_ptr(nullptr_t p, D d);
+    template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
+    template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
+    shared_ptr(const shared_ptr& r) noexcept;
+    template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
+    shared_ptr(shared_ptr&& r) noexcept;
+    template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
+    template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
+    template<class Y> shared_ptr(auto_ptr<Y>&& r);
+    template <class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
+    shared_ptr(nullptr_t) : shared_ptr() { }
+
+    // destructor:
+    ~shared_ptr();
+
+    // assignment:
+    shared_ptr& operator=(const shared_ptr& r) noexcept;
+    template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r) noexcept;
+    shared_ptr& operator=(shared_ptr&& r) noexcept;
+    template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
+    template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r);
+    template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
+
+    // modifiers:
+    void swap(shared_ptr& r) noexcept;
+    void reset() noexcept;
+    template<class Y> void reset(Y* p);
+    template<class Y, class D> void reset(Y* p, D d);
+    template<class Y, class D, class A> void reset(Y* p, D d, A a);
+
+    // observers:
+    T* get() const noexcept;
+    T& operator*() const noexcept;
+    T* operator->() const noexcept;
+    long use_count() const noexcept;
+    bool unique() const noexcept;
+    explicit operator bool() const noexcept;
+    template<class U> bool owner_before(shared_ptr<U> const& b) const;
+    template<class U> bool owner_before(weak_ptr<U> const& b) const;
+};
+
+// shared_ptr comparisons:
+template<class T, class U>
+    bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+    bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+    bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+    bool operator>(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+    bool operator<=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+template<class T, class U>
+    bool operator>=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
+
+template <class T>
+    bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+    bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+    bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+    bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+    bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+    bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+    bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+    bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+    bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
+template <class T>
+    bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
+template <class T>
+    bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
+
+// shared_ptr specialized algorithms:
+template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b) noexcept;
+
+// shared_ptr casts:
+template<class T, class U>
+    shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r) noexcept;
+template<class T, class U>
+    shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r) noexcept;
+template<class T, class U>
+    shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r) noexcept;
+
+// shared_ptr I/O:
+template<class E, class T, class Y>
+    basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
+
+// shared_ptr get_deleter:
+template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept;
+
+template<class T, class... Args>
+    shared_ptr<T> make_shared(Args&&... args);
+template<class T, class A, class... Args>
+    shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+
+template<class T>
+class weak_ptr
+{
+public:
+    typedef T element_type;
+
+    // constructors
+    constexpr weak_ptr() noexcept;
+    template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
+    weak_ptr(weak_ptr const& r) noexcept;
+    template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
+    weak_ptr(weak_ptr&& r) noexcept;                      // C++14
+    template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept; // C++14
+
+    // destructor
+    ~weak_ptr();
+
+    // assignment
+    weak_ptr& operator=(weak_ptr const& r) noexcept;
+    template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
+    template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
+    weak_ptr& operator=(weak_ptr&& r) noexcept;                      // C++14
+    template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept; // C++14
+
+    // modifiers
+    void swap(weak_ptr& r) noexcept;
+    void reset() noexcept;
+
+    // observers
+    long use_count() const noexcept;
+    bool expired() const noexcept;
+    shared_ptr<T> lock() const noexcept;
+    template<class U> bool owner_before(shared_ptr<U> const& b) const;
+    template<class U> bool owner_before(weak_ptr<U> const& b) const;
+};
+
+// weak_ptr specialized algorithms:
+template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
+
+// class owner_less:
+template<class T> struct owner_less;
+
+template<class T>
+struct owner_less<shared_ptr<T>>
+    : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
+{
+    typedef bool result_type;
+    bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const;
+    bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+    bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+};
+
+template<class T>
+struct owner_less<weak_ptr<T>>
+    : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
+{
+    typedef bool result_type;
+    bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const;
+    bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+    bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+};
+
+template<class T>
+class enable_shared_from_this
+{
+protected:
+    constexpr enable_shared_from_this() noexcept;
+    enable_shared_from_this(enable_shared_from_this const&) noexcept;
+    enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept;
+    ~enable_shared_from_this();
+public:
+    shared_ptr<T> shared_from_this();
+    shared_ptr<T const> shared_from_this() const;
+};
+
+template<class T>
+    bool atomic_is_lock_free(const shared_ptr<T>* p);
+template<class T>
+    shared_ptr<T> atomic_load(const shared_ptr<T>* p);
+template<class T>
+    shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
+template<class T>
+    void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
+template<class T>
+    void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
+template<class T>
+    shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
+template<class T>
+    shared_ptr<T>
+    atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
+template<class T>
+    bool
+    atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
+template<class T>
+    bool
+    atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
+template<class T>
+    bool
+    atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+                                          shared_ptr<T> w, memory_order success,
+                                          memory_order failure);
+template<class T>
+    bool
+    atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+                                            shared_ptr<T> w, memory_order success,
+                                            memory_order failure);
+// Hash support
+template <class T> struct hash;
+template <class T, class D> struct hash<unique_ptr<T, D> >;
+template <class T> struct hash<shared_ptr<T> >;
+
+// Pointer safety
+enum class pointer_safety { relaxed, preferred, strict };
+void declare_reachable(void *p);
+template <class T> T *undeclare_reachable(T *p);
+void declare_no_pointers(char *p, size_t n);
+void undeclare_no_pointers(char *p, size_t n);
+pointer_safety get_pointer_safety() noexcept;
+
+void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <type_traits>
+#include <typeinfo>
+#include <cstddef>
+#include <cstdint>
+#include <new>
+#include <utility>
+#include <limits>
+#include <iterator>
+#include <__functional_base>
+#include <iosfwd>
+#include <tuple>
+#include <cstring>
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+    #include <cassert>
+#endif
+
+#if __has_feature(cxx_atomic)
+#  include <atomic>
+#endif
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// addressof moved to <__functional_base>
+
+template <class _Tp> class allocator;
+
+template <>
+class _LIBCPP_TYPE_VIS_ONLY allocator<void>
+{
+public:
+    typedef void*             pointer;
+    typedef const void*       const_pointer;
+    typedef void              value_type;
+
+    template <class _Up> struct rebind {typedef allocator<_Up> other;};
+};
+
+template <>
+class _LIBCPP_TYPE_VIS_ONLY allocator<const void>
+{
+public:
+    typedef const void*       pointer;
+    typedef const void*       const_pointer;
+    typedef const void        value_type;
+
+    template <class _Up> struct rebind {typedef allocator<_Up> other;};
+};
+
+// pointer_traits
+
+template <class _Tp>
+struct __has_element_type
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::element_type* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Ptr, bool = __has_element_type<_Ptr>::value>
+struct __pointer_traits_element_type;
+
+template <class _Ptr>
+struct __pointer_traits_element_type<_Ptr, true>
+{
+    typedef typename _Ptr::element_type type;
+};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args>
+struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
+{
+    typedef typename _Sp<_Tp, _Args...>::element_type type;
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args>
+struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
+{
+    typedef _Tp type;
+};
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <template <class> class _Sp, class _Tp>
+struct __pointer_traits_element_type<_Sp<_Tp>, true>
+{
+    typedef typename _Sp<_Tp>::element_type type;
+};
+
+template <template <class> class _Sp, class _Tp>
+struct __pointer_traits_element_type<_Sp<_Tp>, false>
+{
+    typedef _Tp type;
+};
+
+template <template <class, class> class _Sp, class _Tp, class _A0>
+struct __pointer_traits_element_type<_Sp<_Tp, _A0>, true>
+{
+    typedef typename _Sp<_Tp, _A0>::element_type type;
+};
+
+template <template <class, class> class _Sp, class _Tp, class _A0>
+struct __pointer_traits_element_type<_Sp<_Tp, _A0>, false>
+{
+    typedef _Tp type;
+};
+
+template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
+struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, true>
+{
+    typedef typename _Sp<_Tp, _A0, _A1>::element_type type;
+};
+
+template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1>
+struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1>, false>
+{
+    typedef _Tp type;
+};
+
+template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
+                                                           class _A1, class _A2>
+struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, true>
+{
+    typedef typename _Sp<_Tp, _A0, _A1, _A2>::element_type type;
+};
+
+template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
+                                                           class _A1, class _A2>
+struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false>
+{
+    typedef _Tp type;
+};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp>
+struct __has_difference_type
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::difference_type* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
+struct __pointer_traits_difference_type
+{
+    typedef ptrdiff_t type;
+};
+
+template <class _Ptr>
+struct __pointer_traits_difference_type<_Ptr, true>
+{
+    typedef typename _Ptr::difference_type type;
+};
+
+template <class _Tp, class _Up>
+struct __has_rebind
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Xp> static __two __test(...);
+    template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
+struct __pointer_traits_rebind
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename _Tp::template rebind<_Up> type;
+#else
+    typedef typename _Tp::template rebind<_Up>::other type;
+#endif
+};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
+#else
+    typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false>
+{
+    typedef _Sp<_Up, _Args...> type;
+};
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <template <class> class _Sp, class _Tp, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename _Sp<_Tp>::template rebind<_Up> type;
+#else
+    typedef typename _Sp<_Tp>::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class> class _Sp, class _Tp, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false>
+{
+    typedef _Sp<_Up> type;
+};
+
+template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type;
+#else
+    typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class> class _Sp, class _Tp, class _A0, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, false>
+{
+    typedef _Sp<_Up, _A0> type;
+};
+
+template <template <class, class, class> class _Sp, class _Tp, class _A0,
+                                         class _A1, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type;
+#else
+    typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class, class> class _Sp, class _Tp, class _A0,
+                                         class _A1, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, false>
+{
+    typedef _Sp<_Up, _A0, _A1> type;
+};
+
+template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
+                                                class _A1, class _A2, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type;
+#else
+    typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
+#endif
+};
+
+template <template <class, class, class, class> class _Sp, class _Tp, class _A0,
+                                                class _A1, class _A2, class _Up>
+struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false>
+{
+    typedef _Sp<_Up, _A0, _A1, _A2> type;
+};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Ptr>
+struct _LIBCPP_TYPE_VIS_ONLY pointer_traits
+{
+    typedef _Ptr                                                     pointer;
+    typedef typename __pointer_traits_element_type<pointer>::type    element_type;
+    typedef typename __pointer_traits_difference_type<pointer>::type difference_type;
+
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type;
+#else
+    template <class _Up> struct rebind
+        {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+private:
+    struct __nat {};
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    static pointer pointer_to(typename conditional<is_void<element_type>::value,
+                                           __nat, element_type>::type& __r)
+        {return pointer::pointer_to(__r);}
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*>
+{
+    typedef _Tp*      pointer;
+    typedef _Tp       element_type;
+    typedef ptrdiff_t difference_type;
+
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class _Up> using rebind = _Up*;
+#else
+    template <class _Up> struct rebind {typedef _Up* other;};
+#endif
+
+private:
+    struct __nat {};
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    static pointer pointer_to(typename conditional<is_void<element_type>::value,
+                                      __nat, element_type>::type& __r) _NOEXCEPT
+        {return _VSTD::addressof(__r);}
+};
+
+// allocator_traits
+
+namespace __has_pointer_type_imp
+{
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::pointer* = 0);
+}
+
+template <class _Tp>
+struct __has_pointer_type
+    : public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1>
+{
+};
+
+namespace __pointer_type_imp
+{
+
+template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value>
+struct __pointer_type
+{
+    typedef typename _Dp::pointer type;
+};
+
+template <class _Tp, class _Dp>
+struct __pointer_type<_Tp, _Dp, false>
+{
+    typedef _Tp* type;
+};
+
+}  // __pointer_type_imp
+
+template <class _Tp, class _Dp>
+struct __pointer_type
+{
+    typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
+};
+
+template <class _Tp>
+struct __has_const_pointer
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::const_pointer* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
+struct __const_pointer
+{
+    typedef typename _Alloc::const_pointer type;
+};
+
+template <class _Tp, class _Ptr, class _Alloc>
+struct __const_pointer<_Tp, _Ptr, _Alloc, false>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
+#else
+    typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
+#endif
+};
+
+template <class _Tp>
+struct __has_void_pointer
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::void_pointer* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
+struct __void_pointer
+{
+    typedef typename _Alloc::void_pointer type;
+};
+
+template <class _Ptr, class _Alloc>
+struct __void_pointer<_Ptr, _Alloc, false>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename pointer_traits<_Ptr>::template rebind<void> type;
+#else
+    typedef typename pointer_traits<_Ptr>::template rebind<void>::other type;
+#endif
+};
+
+template <class _Tp>
+struct __has_const_void_pointer
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::const_void_pointer* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
+struct __const_void_pointer
+{
+    typedef typename _Alloc::const_void_pointer type;
+};
+
+template <class _Ptr, class _Alloc>
+struct __const_void_pointer<_Ptr, _Alloc, false>
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    typedef typename pointer_traits<_Ptr>::template rebind<const void> type;
+#else
+    typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type;
+#endif
+};
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+__to_raw_pointer(_Tp* __p) _NOEXCEPT
+{
+    return __p;
+}
+
+template <class _Pointer>
+inline _LIBCPP_INLINE_VISIBILITY
+typename pointer_traits<_Pointer>::element_type*
+__to_raw_pointer(_Pointer __p) _NOEXCEPT
+{
+    return _VSTD::__to_raw_pointer(__p.operator->());
+}
+
+template <class _Tp>
+struct __has_size_type
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::size_type* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
+struct __size_type
+{
+    typedef typename make_unsigned<_DiffType>::type type;
+};
+
+template <class _Alloc, class _DiffType>
+struct __size_type<_Alloc, _DiffType, true>
+{
+    typedef typename _Alloc::size_type type;
+};
+
+template <class _Tp>
+struct __has_propagate_on_container_copy_assignment
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
+struct __propagate_on_container_copy_assignment
+{
+    typedef false_type type;
+};
+
+template <class _Alloc>
+struct __propagate_on_container_copy_assignment<_Alloc, true>
+{
+    typedef typename _Alloc::propagate_on_container_copy_assignment type;
+};
+
+template <class _Tp>
+struct __has_propagate_on_container_move_assignment
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
+struct __propagate_on_container_move_assignment
+{
+    typedef false_type type;
+};
+
+template <class _Alloc>
+struct __propagate_on_container_move_assignment<_Alloc, true>
+{
+    typedef typename _Alloc::propagate_on_container_move_assignment type;
+};
+
+template <class _Tp>
+struct __has_propagate_on_container_swap
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
+struct __propagate_on_container_swap
+{
+    typedef false_type type;
+};
+
+template <class _Alloc>
+struct __propagate_on_container_swap<_Alloc, true>
+{
+    typedef typename _Alloc::propagate_on_container_swap type;
+};
+
+template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
+struct __has_rebind_other
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Xp> static __two __test(...);
+    template <class _Xp> static char __test(typename _Xp::template rebind<_Up>::other* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+template <class _Tp, class _Up>
+struct __has_rebind_other<_Tp, _Up, false>
+{
+    static const bool value = false;
+};
+
+template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
+struct __allocator_traits_rebind
+{
+    typedef typename _Tp::template rebind<_Up>::other type;
+};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
+{
+    typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
+};
+
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
+{
+    typedef _Alloc<_Up, _Args...> type;
+};
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <template <class> class _Alloc, class _Tp, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, true>
+{
+    typedef typename _Alloc<_Tp>::template rebind<_Up>::other type;
+};
+
+template <template <class> class _Alloc, class _Tp, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp>, _Up, false>
+{
+    typedef _Alloc<_Up> type;
+};
+
+template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, true>
+{
+    typedef typename _Alloc<_Tp, _A0>::template rebind<_Up>::other type;
+};
+
+template <template <class, class> class _Alloc, class _Tp, class _A0, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _A0>, _Up, false>
+{
+    typedef _Alloc<_Up, _A0> type;
+};
+
+template <template <class, class, class> class _Alloc, class _Tp, class _A0,
+                                         class _A1, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, true>
+{
+    typedef typename _Alloc<_Tp, _A0, _A1>::template rebind<_Up>::other type;
+};
+
+template <template <class, class, class> class _Alloc, class _Tp, class _A0,
+                                         class _A1, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1>, _Up, false>
+{
+    typedef _Alloc<_Up, _A0, _A1> type;
+};
+
+template <template <class, class, class, class> class _Alloc, class _Tp, class _A0,
+                                                class _A1, class _A2, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, true>
+{
+    typedef typename _Alloc<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type;
+};
+
+template <template <class, class, class, class> class _Alloc, class _Tp, class _A0,
+                                                class _A1, class _A2, class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false>
+{
+    typedef _Alloc<_Up, _A0, _A1, _A2> type;
+};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+template <class _Alloc, class _SizeType, class _ConstVoidPtr>
+auto
+__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
+    -> decltype(__a.allocate(__sz, __p), true_type());
+
+template <class _Alloc, class _SizeType, class _ConstVoidPtr>
+auto
+__has_allocate_hint_test(const _Alloc& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
+    -> false_type;
+
+template <class _Alloc, class _SizeType, class _ConstVoidPtr>
+struct __has_allocate_hint
+    : integral_constant<bool,
+        is_same<
+            decltype(__has_allocate_hint_test(declval<_Alloc>(),
+                                          declval<_SizeType>(),
+                                          declval<_ConstVoidPtr>())),
+            true_type>::value>
+{
+};
+
+#else  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+template <class _Alloc, class _SizeType, class _ConstVoidPtr>
+struct __has_allocate_hint
+    : true_type
+{
+};
+
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+
+template <class _Alloc, class _Tp, class ..._Args>
+decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(),
+                                           _VSTD::declval<_Args>()...),
+                                           true_type())
+__has_construct_test(_Alloc&& __a, _Tp* __p, _Args&& ...__args);
+
+template <class _Alloc, class _Pointer, class ..._Args>
+false_type
+__has_construct_test(const _Alloc& __a, _Pointer&& __p, _Args&& ...__args);
+
+template <class _Alloc, class _Pointer, class ..._Args>
+struct __has_construct
+    : integral_constant<bool,
+        is_same<
+            decltype(__has_construct_test(declval<_Alloc>(),
+                                          declval<_Pointer>(),
+                                          declval<_Args>()...)),
+            true_type>::value>
+{
+};
+
+template <class _Alloc, class _Pointer>
+auto
+__has_destroy_test(_Alloc&& __a, _Pointer&& __p)
+    -> decltype(__a.destroy(__p), true_type());
+
+template <class _Alloc, class _Pointer>
+auto
+__has_destroy_test(const _Alloc& __a, _Pointer&& __p)
+    -> false_type;
+
+template <class _Alloc, class _Pointer>
+struct __has_destroy
+    : integral_constant<bool,
+        is_same<
+            decltype(__has_destroy_test(declval<_Alloc>(),
+                                        declval<_Pointer>())),
+            true_type>::value>
+{
+};
+
+template <class _Alloc>
+auto
+__has_max_size_test(_Alloc&& __a)
+    -> decltype(__a.max_size(), true_type());
+
+template <class _Alloc>
+auto
+__has_max_size_test(const volatile _Alloc& __a)
+    -> false_type;
+
+template <class _Alloc>
+struct __has_max_size
+    : integral_constant<bool,
+        is_same<
+            decltype(__has_max_size_test(declval<_Alloc&>())),
+            true_type>::value>
+{
+};
+
+template <class _Alloc>
+auto
+__has_select_on_container_copy_construction_test(_Alloc&& __a)
+    -> decltype(__a.select_on_container_copy_construction(), true_type());
+
+template <class _Alloc>
+auto
+__has_select_on_container_copy_construction_test(const volatile _Alloc& __a)
+    -> false_type;
+
+template <class _Alloc>
+struct __has_select_on_container_copy_construction
+    : integral_constant<bool,
+        is_same<
+            decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())),
+            true_type>::value>
+{
+};
+
+#else  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Alloc, class _Pointer, class ..._Args>
+struct __has_construct
+    : false_type
+{
+};
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Alloc, class _Pointer, class _Args>
+struct __has_construct
+    : false_type
+{
+};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Alloc, class _Pointer>
+struct __has_destroy
+    : false_type
+{
+};
+
+template <class _Alloc>
+struct __has_max_size
+    : true_type
+{
+};
+
+template <class _Alloc>
+struct __has_select_on_container_copy_construction
+    : false_type
+{
+};
+
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
+struct __alloc_traits_difference_type
+{
+    typedef typename pointer_traits<_Ptr>::difference_type type;
+};
+
+template <class _Alloc, class _Ptr>
+struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
+{
+    typedef typename _Alloc::difference_type type;
+};
+
+template <class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
+{
+    typedef _Alloc                              allocator_type;
+    typedef typename allocator_type::value_type value_type;
+
+    typedef typename __pointer_type<value_type, allocator_type>::type pointer;
+    typedef typename __const_pointer<value_type, pointer, allocator_type>::type const_pointer;
+    typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
+    typedef typename __const_void_pointer<pointer, allocator_type>::type const_void_pointer;
+
+    typedef typename __alloc_traits_difference_type<allocator_type, pointer>::type difference_type;
+    typedef typename __size_type<allocator_type, difference_type>::type size_type;
+
+    typedef typename __propagate_on_container_copy_assignment<allocator_type>::type
+                     propagate_on_container_copy_assignment;
+    typedef typename __propagate_on_container_move_assignment<allocator_type>::type
+                     propagate_on_container_move_assignment;
+    typedef typename __propagate_on_container_swap<allocator_type>::type
+                     propagate_on_container_swap;
+
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class _Tp> using rebind_alloc =
+                  typename __allocator_traits_rebind<allocator_type, _Tp>::type;
+    template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class _Tp> struct rebind_alloc
+        {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
+    template <class _Tp> struct rebind_traits
+        {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+    _LIBCPP_INLINE_VISIBILITY
+    static pointer allocate(allocator_type& __a, size_type __n)
+        {return __a.allocate(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
+        {return allocate(__a, __n, __hint,
+            __has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
+        {__a.deallocate(__p, __n);}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    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...>(),
+                         __a, __p, _VSTD::forward<_Args>(__args)...);}
+#else  // _LIBCPP_HAS_NO_VARIADICS
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        static void construct(allocator_type& __a, _Tp* __p)
+            {
+                ::new ((void*)__p) _Tp();
+            }
+    template <class _Tp, class _A0>
+        _LIBCPP_INLINE_VISIBILITY
+        static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0)
+            {
+                ::new ((void*)__p) _Tp(__a0);
+            }
+    template <class _Tp, class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0,
+                              const _A1& __a1)
+            {
+                ::new ((void*)__p) _Tp(__a0, __a1);
+            }
+    template <class _Tp, class _A0, class _A1, class _A2>
+        _LIBCPP_INLINE_VISIBILITY
+        static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0,
+                              const _A1& __a1, const _A2& __a2)
+            {
+                ::new ((void*)__p) _Tp(__a0, __a1, __a2);
+            }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        static void destroy(allocator_type& __a, _Tp* __p)
+            {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    static size_type max_size(const allocator_type& __a) _NOEXCEPT
+        {return __max_size(__has_max_size<const allocator_type>(), __a);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    static allocator_type
+        select_on_container_copy_construction(const allocator_type& __a)
+            {return select_on_container_copy_construction(
+                __has_select_on_container_copy_construction<const allocator_type>(),
+                __a);}
+
+    template <class _Ptr>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        void
+        __construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2)
+        {
+            for (; __begin1 != __end1; ++__begin1, ++__begin2)
+                construct(__a, _VSTD::__to_raw_pointer(__begin2), _VSTD::move_if_noexcept(*__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_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
+        {
+            ptrdiff_t _Np = __end1 - __begin1;
+            _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
+            __begin2 += _Np;
+        }
+
+    template <class _Ptr>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        void
+        __construct_backward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2)
+        {
+            while (__end1 != __begin1)
+            {
+                construct(__a, _VSTD::__to_raw_pointer(__end2-1), _VSTD::move_if_noexcept(*--__end1));
+                --__end2;
+            }
+        }
+
+    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_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
+        {
+            ptrdiff_t _Np = __end1 - __begin1;
+            __end2 -= _Np;
+            _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
+        }
+
+private:
+
+    _LIBCPP_INLINE_VISIBILITY
+    static pointer allocate(allocator_type& __a, size_type __n,
+        const_void_pointer __hint, true_type)
+        {return __a.allocate(__n, __hint);}
+    _LIBCPP_INLINE_VISIBILITY
+    static pointer allocate(allocator_type& __a, size_type __n,
+        const_void_pointer, false_type)
+        {return __a.allocate(__n);}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class _Tp, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
+            {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
+    template <class _Tp, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
+            {
+                ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
+            }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        static void __destroy(true_type, allocator_type& __a, _Tp* __p)
+            {__a.destroy(__p);}
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        static void __destroy(false_type, allocator_type&, _Tp* __p)
+            {
+                __p->~_Tp();
+            }
+
+    _LIBCPP_INLINE_VISIBILITY
+    static size_type __max_size(true_type, const allocator_type& __a)
+            {return __a.max_size();}
+    _LIBCPP_INLINE_VISIBILITY
+    static size_type __max_size(false_type, const allocator_type&)
+            {return numeric_limits<size_type>::max();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    static allocator_type
+        select_on_container_copy_construction(true_type, const allocator_type& __a)
+            {return __a.select_on_container_copy_construction();}
+    _LIBCPP_INLINE_VISIBILITY
+    static allocator_type
+        select_on_container_copy_construction(false_type, const allocator_type& __a)
+            {return __a;}
+};
+
+// allocator
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY allocator
+{
+public:
+    typedef size_t            size_type;
+    typedef ptrdiff_t         difference_type;
+    typedef _Tp*              pointer;
+    typedef const _Tp*        const_pointer;
+    typedef _Tp&              reference;
+    typedef const _Tp&        const_reference;
+    typedef _Tp               value_type;
+
+    typedef true_type propagate_on_container_move_assignment;
+
+    template <class _Up> struct rebind {typedef allocator<_Up> other;};
+
+    _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
+    template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
+        {return _VSTD::addressof(__x);}
+    _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)));}
+    _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
+        {_VSTD::__deallocate((void*)__p);}
+    _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
+        {return size_type(~0) / sizeof(_Tp);}
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class _Up, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(_Up* __p, _Args&&... __args)
+        {
+            ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+        }
+#else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p)
+        {
+            ::new((void*)__p) _Tp();
+        }
+# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    template <class _A0>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, _A0& __a0)
+        {
+            ::new((void*)__p) _Tp(__a0);
+        }
+    template <class _A0>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, const _A0& __a0)
+        {
+            ::new((void*)__p) _Tp(__a0);
+        }
+# endif  // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, _A0& __a0, _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, const _A0& __a0, _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, _A0& __a0, const _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, const _A0& __a0, const _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
+};
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY allocator<const _Tp>
+{
+public:
+    typedef size_t            size_type;
+    typedef ptrdiff_t         difference_type;
+    typedef const _Tp*        pointer;
+    typedef const _Tp*        const_pointer;
+    typedef const _Tp&        reference;
+    typedef const _Tp&        const_reference;
+    typedef const _Tp         value_type;
+
+    typedef true_type propagate_on_container_move_assignment;
+
+    template <class _Up> struct rebind {typedef allocator<_Up> other;};
+
+    _LIBCPP_INLINE_VISIBILITY allocator() _NOEXCEPT {}
+    template <class _Up> _LIBCPP_INLINE_VISIBILITY allocator(const allocator<_Up>&) _NOEXCEPT {}
+    _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)));}
+    _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
+        {_VSTD::__deallocate((void*)__p);}
+    _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
+        {return size_type(~0) / sizeof(_Tp);}
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class _Up, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(_Up* __p, _Args&&... __args)
+        {
+            ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
+        }
+#else  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p)
+        {
+            ::new((void*)__p) _Tp();
+        }
+# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    template <class _A0>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, _A0& __a0)
+        {
+            ::new((void*)__p) _Tp(__a0);
+        }
+    template <class _A0>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, const _A0& __a0)
+        {
+            ::new((void*)__p) _Tp(__a0);
+        }
+# endif  // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, _A0& __a0, _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, const _A0& __a0, _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, _A0& __a0, const _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        construct(pointer __p, const _A0& __a0, const _A1& __a1)
+        {
+            ::new((void*)__p) _Tp(__a0, __a1);
+        }
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
+};
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
+
+template <class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
+
+template <class _OutputIterator, class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator
+    : public iterator<output_iterator_tag,
+                      _Tp,                                         // purposefully not C++03
+                      ptrdiff_t,                                   // purposefully not C++03
+                      _Tp*,                                        // purposefully not C++03
+                      raw_storage_iterator<_OutputIterator, _Tp>&> // purposefully not C++03
+{
+private:
+    _OutputIterator __x_;
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit raw_storage_iterator(_OutputIterator __x) : __x_(__x) {}
+    _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;}
+    _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;}
+};
+
+template <class _Tp>
+pair<_Tp*, ptrdiff_t>
+get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
+{
+    pair<_Tp*, ptrdiff_t> __r(0, 0);
+    const ptrdiff_t __m = (~ptrdiff_t(0) ^
+                           ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1)))
+                           / sizeof(_Tp);
+    if (__n > __m)
+        __n = __m;
+    while (__n > 0)
+    {
+        __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
+        if (__r.first)
+        {
+            __r.second = __n;
+            break;
+        }
+        __n /= 2;
+    }
+    return __r;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);}
+
+template <class _Tp>
+struct auto_ptr_ref
+{
+    _Tp* __ptr_;
+};
+
+template<class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY auto_ptr
+{
+private:
+    _Tp* __ptr_;
+public:
+    typedef _Tp element_type;
+
+    _LIBCPP_INLINE_VISIBILITY explicit auto_ptr(_Tp* __p = 0) throw() : __ptr_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr& __p) throw() : __ptr_(__p.release()) {}
+    template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr<_Up>& __p) throw()
+        : __ptr_(__p.release()) {}
+    _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr& __p) throw()
+        {reset(__p.release()); return *this;}
+    template<class _Up> _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr<_Up>& __p) throw()
+        {reset(__p.release()); return *this;}
+    _LIBCPP_INLINE_VISIBILITY auto_ptr& operator=(auto_ptr_ref<_Tp> __p) throw()
+        {reset(__p.__ptr_); return *this;}
+    _LIBCPP_INLINE_VISIBILITY ~auto_ptr() throw() {delete __ptr_;}
+
+    _LIBCPP_INLINE_VISIBILITY _Tp& operator*() const throw()
+        {return *__ptr_;}
+    _LIBCPP_INLINE_VISIBILITY _Tp* operator->() const throw() {return __ptr_;}
+    _LIBCPP_INLINE_VISIBILITY _Tp* get() const throw() {return __ptr_;}
+    _LIBCPP_INLINE_VISIBILITY _Tp* release() throw()
+    {
+        _Tp* __t = __ptr_;
+        __ptr_ = 0;
+        return __t;
+    }
+    _LIBCPP_INLINE_VISIBILITY void reset(_Tp* __p = 0) throw()
+    {
+        if (__ptr_ != __p)
+            delete __ptr_;
+        __ptr_ = __p;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY auto_ptr(auto_ptr_ref<_Tp> __p) throw() : __ptr_(__p.__ptr_) {}
+    template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr_ref<_Up>() throw()
+        {auto_ptr_ref<_Up> __t; __t.__ptr_ = release(); return __t;}
+    template<class _Up> _LIBCPP_INLINE_VISIBILITY operator auto_ptr<_Up>() throw()
+        {return auto_ptr<_Up>(release());}
+};
+
+template <>
+class _LIBCPP_TYPE_VIS_ONLY auto_ptr<void>
+{
+public:
+    typedef void element_type;
+};
+
+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
+                                ,
+                                bool = is_empty<_T2>::value
+#if __has_feature(is_final)
+                                       && !__is_final(_T2)
+#endif
+         >
+struct __libcpp_compressed_pair_switch;
+
+template <class _T1, class _T2, bool IsSame>
+struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, false> {enum {value = 0};};
+
+template <class _T1, class _T2, bool IsSame>
+struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, true, false>  {enum {value = 1};};
+
+template <class _T1, class _T2, bool IsSame>
+struct __libcpp_compressed_pair_switch<_T1, _T2, IsSame, false, true>  {enum {value = 2};};
+
+template <class _T1, class _T2>
+struct __libcpp_compressed_pair_switch<_T1, _T2, false, true, true>    {enum {value = 3};};
+
+template <class _T1, class _T2>
+struct __libcpp_compressed_pair_switch<_T1, _T2, true, true, true>     {enum {value = 1};};
+
+template <class _T1, class _T2, unsigned = __libcpp_compressed_pair_switch<_T1, _T2>::value>
+class __libcpp_compressed_pair_imp;
+
+template <class _T1, class _T2>
+class __libcpp_compressed_pair_imp<_T1, _T2, 0>
+{
+private:
+    _T1 __first_;
+    _T2 __second_;
+public:
+    typedef _T1 _T1_param;
+    typedef _T2 _T2_param;
+
+    typedef typename remove_reference<_T1>::type& _T1_reference;
+    typedef typename remove_reference<_T2>::type& _T2_reference;
+
+    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 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)
+        : __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)) {}
+
+#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : __first_(__p.first()),
+          __second_(__p.second()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            __first_ = __p.first();
+            __second_ = __p.second();
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
+                   is_nothrow_move_constructible<_T2>::value)
+        : __first_(_VSTD::forward<_T1>(__p.first())),
+          __second_(_VSTD::forward<_T2>(__p.second())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            __first_ = _VSTD::forward<_T1>(__p.first());
+            __second_ = _VSTD::forward<_T2>(__p.second());
+            return *this;
+        }
+
+#endif  // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
+        _LIBCPP_INLINE_VISIBILITY
+        __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
+                                     tuple<_Args1...> __first_args,
+                                     tuple<_Args2...> __second_args,
+                                     __tuple_indices<_I1...>,
+                                     __tuple_indices<_I2...>)
+            : __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
+              __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
+            {}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;}
+    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
+
+    _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return __second_;}
+    _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;}
+
+    _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
+        _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+                   __is_nothrow_swappable<_T2>::value)
+    {
+        using _VSTD::swap;
+        swap(__first_, __x.__first_);
+        swap(__second_, __x.__second_);
+    }
+};
+
+template <class _T1, class _T2>
+class __libcpp_compressed_pair_imp<_T1, _T2, 1>
+    : private _T1
+{
+private:
+    _T2 __second_;
+public:
+    typedef _T1 _T1_param;
+    typedef _T2 _T2_param;
+
+    typedef _T1&                                        _T1_reference;
+    typedef typename remove_reference<_T2>::type& _T2_reference;
+
+    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 explicit __libcpp_compressed_pair_imp(_T1_param __t1)
+        : _T1(_VSTD::forward<_T1_param>(__t1)) {}
+    _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)
+        : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
+
+#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : _T1(__p.first()), __second_(__p.second()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            _T1::operator=(__p.first());
+            __second_ = __p.second();
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
+                   is_nothrow_move_constructible<_T2>::value)
+        : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            _T1::operator=(_VSTD::move(__p.first()));
+            __second_ = _VSTD::forward<_T2>(__p.second());
+            return *this;
+        }
+
+#endif  // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
+        _LIBCPP_INLINE_VISIBILITY
+        __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
+                                     tuple<_Args1...> __first_args,
+                                     tuple<_Args2...> __second_args,
+                                     __tuple_indices<_I1...>,
+                                     __tuple_indices<_I2...>)
+            : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
+              __second_(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
+            {}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;}
+    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
+
+    _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return __second_;}
+    _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return __second_;}
+
+    _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
+        _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+                   __is_nothrow_swappable<_T2>::value)
+    {
+        using _VSTD::swap;
+        swap(__second_, __x.__second_);
+    }
+};
+
+template <class _T1, class _T2>
+class __libcpp_compressed_pair_imp<_T1, _T2, 2>
+    : private _T2
+{
+private:
+    _T1 __first_;
+public:
+    typedef _T1 _T1_param;
+    typedef _T2 _T2_param;
+
+    typedef typename remove_reference<_T1>::type& _T1_reference;
+    typedef _T2&                                        _T2_reference;
+
+    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 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)) {}
+    _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)
+        : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {}
+
+#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : _T2(__p.second()), __first_(__p.first()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            _T2::operator=(__p.second());
+            __first_ = __p.first();
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
+                   is_nothrow_move_constructible<_T2>::value)
+        : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            _T2::operator=(_VSTD::forward<_T2>(__p.second()));
+            __first_ = _VSTD::move(__p.first());
+            return *this;
+        }
+
+#endif  // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
+        _LIBCPP_INLINE_VISIBILITY
+        __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
+                                     tuple<_Args1...> __first_args,
+                                     tuple<_Args2...> __second_args,
+                                     __tuple_indices<_I1...>,
+                                     __tuple_indices<_I2...>)
+            : _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...),
+              __first_(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...)
+              
+            {}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;}
+    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
+
+    _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return *this;}
+    _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;}
+
+    _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp& __x)
+        _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+                   __is_nothrow_swappable<_T2>::value)
+    {
+        using _VSTD::swap;
+        swap(__first_, __x.__first_);
+    }
+};
+
+template <class _T1, class _T2>
+class __libcpp_compressed_pair_imp<_T1, _T2, 3>
+    : private _T1,
+      private _T2
+{
+public:
+    typedef _T1 _T1_param;
+    typedef _T2 _T2_param;
+
+    typedef _T1& _T1_reference;
+    typedef _T2& _T2_reference;
+
+    typedef const _T1& _T1_const_reference;
+    typedef const _T2& _T2_const_reference;
+
+    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
+    _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
+        : _T1(_VSTD::forward<_T1_param>(__t1)) {}
+    _LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
+        : _T2(_VSTD::forward<_T2_param>(__t2)) {}
+    _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
+        : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {}
+
+#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : _T1(__p.first()), _T2(__p.second()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            _T1::operator=(__p.first());
+            _T2::operator=(__p.second());
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
+                   is_nothrow_move_constructible<_T2>::value)
+        : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            _T1::operator=(_VSTD::move(__p.first()));
+            _T2::operator=(_VSTD::move(__p.second()));
+            return *this;
+        }
+
+#endif  // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
+        _LIBCPP_INLINE_VISIBILITY
+        __libcpp_compressed_pair_imp(piecewise_construct_t __pc,
+                                     tuple<_Args1...> __first_args,
+                                     tuple<_Args2...> __second_args,
+                                     __tuple_indices<_I1...>,
+                                     __tuple_indices<_I2...>)
+            : _T1(_VSTD::forward<_Args1>(_VSTD::get<_I1>(__first_args))...),
+              _T2(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
+            {}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;}
+    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
+
+    _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return *this;}
+    _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return *this;}
+
+    _LIBCPP_INLINE_VISIBILITY void swap(__libcpp_compressed_pair_imp&)
+        _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+                   __is_nothrow_swappable<_T2>::value)
+    {
+    }
+};
+
+template <class _T1, class _T2>
+class __compressed_pair
+    : private __libcpp_compressed_pair_imp<_T1, _T2>
+{
+    typedef __libcpp_compressed_pair_imp<_T1, _T2> base;
+public:
+    typedef typename base::_T1_param _T1_param;
+    typedef typename base::_T2_param _T2_param;
+
+    typedef typename base::_T1_reference _T1_reference;
+    typedef typename base::_T2_reference _T2_reference;
+
+    typedef typename base::_T1_const_reference _T1_const_reference;
+    typedef typename base::_T2_const_reference _T2_const_reference;
+
+    _LIBCPP_INLINE_VISIBILITY __compressed_pair() {}
+    _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T1_param __t1)
+        : base(_VSTD::forward<_T1_param>(__t1)) {}
+    _LIBCPP_INLINE_VISIBILITY explicit __compressed_pair(_T2_param __t2)
+        : base(_VSTD::forward<_T2_param>(__t2)) {}
+    _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2)
+        : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {}
+
+#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+    _LIBCPP_INLINE_VISIBILITY
+    __compressed_pair(const __compressed_pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value &&
+                   is_nothrow_copy_constructible<_T2>::value)
+        : base(__p) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __compressed_pair& operator=(const __compressed_pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value &&
+                   is_nothrow_copy_assignable<_T2>::value)
+        {
+            base::operator=(__p);
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __compressed_pair(__compressed_pair&& __p)
+        _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
+                   is_nothrow_move_constructible<_T2>::value)
+        : base(_VSTD::move(__p)) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __compressed_pair& operator=(__compressed_pair&& __p)
+        _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value &&
+                   is_nothrow_move_assignable<_T2>::value)
+        {
+            base::operator=(_VSTD::move(__p));
+            return *this;
+        }
+
+#endif  // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    template <class... _Args1, class... _Args2>
+        _LIBCPP_INLINE_VISIBILITY
+        __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
+                                                      tuple<_Args2...> __second_args)
+            : base(__pc, _VSTD::move(__first_args), _VSTD::move(__second_args),
+                   typename __make_tuple_indices<sizeof...(_Args1)>::type(),
+                   typename __make_tuple_indices<sizeof...(_Args2) >::type())
+            {}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return base::first();}
+    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();}
+
+    _LIBCPP_INLINE_VISIBILITY _T2_reference       second() _NOEXCEPT       {return base::second();}
+    _LIBCPP_INLINE_VISIBILITY _T2_const_reference second() const _NOEXCEPT {return base::second();}
+
+    _LIBCPP_INLINE_VISIBILITY void swap(__compressed_pair& __x)
+        _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+                   __is_nothrow_swappable<_T2>::value)
+        {base::swap(__x);}
+};
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
+        _NOEXCEPT_(__is_nothrow_swappable<_T1>::value &&
+                   __is_nothrow_swappable<_T2>::value)
+    {__x.swap(__y);}
+
+// __same_or_less_cv_qualified
+
+template <class _Ptr1, class _Ptr2,
+          bool = is_same<typename remove_cv<typename pointer_traits<_Ptr1>::element_type>::type,
+                         typename remove_cv<typename pointer_traits<_Ptr2>::element_type>::type
+                        >::value
+         >
+struct __same_or_less_cv_qualified_imp
+    : is_convertible<_Ptr1, _Ptr2> {};
+
+template <class _Ptr1, class _Ptr2>
+struct __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2, false>
+    : false_type {};
+
+template <class _Ptr1, class _Ptr2, bool = is_pointer<_Ptr1>::value ||
+                                           is_same<_Ptr1, _Ptr2>::value ||
+                                           __has_element_type<_Ptr1>::value>
+struct __same_or_less_cv_qualified
+    : __same_or_less_cv_qualified_imp<_Ptr1, _Ptr2> {};
+
+template <class _Ptr1, class _Ptr2>
+struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false>
+    : false_type {};
+
+// default_delete
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY default_delete
+{
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
+#else
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {}
+#endif
+    template <class _Up>
+        _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up>&,
+             typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) 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");
+            delete __ptr;
+        }
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]>
+{
+public:
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
+#else
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {}
+#endif
+    template <class _Up>
+        _LIBCPP_INLINE_VISIBILITY default_delete(const default_delete<_Up[]>&,
+             typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {}
+    template <class _Up>
+        _LIBCPP_INLINE_VISIBILITY
+        void operator() (_Up* __ptr,
+                         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");
+            delete [] __ptr;
+        }
+};
+
+template <class _Tp, class _Dp = default_delete<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY unique_ptr
+{
+public:
+    typedef _Tp element_type;
+    typedef _Dp deleter_type;
+    typedef typename __pointer_type<_Tp, deleter_type>::type pointer;
+private:
+    __compressed_pair<pointer, deleter_type> __ptr_;
+
+#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    unique_ptr(unique_ptr&);
+    template <class _Up, class _Ep>
+        unique_ptr(unique_ptr<_Up, _Ep>&);
+    unique_ptr& operator=(unique_ptr&);
+    template <class _Up, class _Ep>
+        unique_ptr& operator=(unique_ptr<_Up, _Ep>&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    struct __nat {int __for_bool_;};
+
+    typedef       typename remove_reference<deleter_type>::type& _Dp_reference;
+    typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference;
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
+        : __ptr_(pointer())
+        {
+            static_assert(!is_pointer<deleter_type>::value,
+                "unique_ptr constructed with null function pointer deleter");
+        }
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT
+        : __ptr_(pointer())
+        {
+            static_assert(!is_pointer<deleter_type>::value,
+                "unique_ptr constructed with null function pointer deleter");
+        }
+    _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p) _NOEXCEPT
+        : __ptr_(_VSTD::move(__p))
+        {
+            static_assert(!is_pointer<deleter_type>::value,
+                "unique_ptr constructed with null function pointer deleter");
+        }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename conditional<
+                                        is_reference<deleter_type>::value,
+                                        deleter_type,
+                                        typename add_lvalue_reference<const deleter_type>::type>::type __d)
+             _NOEXCEPT
+        : __ptr_(__p, __d) {}
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, typename remove_reference<deleter_type>::type&& __d)
+             _NOEXCEPT
+        : __ptr_(__p, _VSTD::move(__d))
+        {
+            static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
+        }
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT
+        : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
+    template <class _Up, class _Ep>
+        _LIBCPP_INLINE_VISIBILITY
+        unique_ptr(unique_ptr<_Up, _Ep>&& __u,
+                   typename enable_if
+                      <
+                        !is_array<_Up>::value &&
+                         is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value &&
+                         is_convertible<_Ep, deleter_type>::value &&
+                         (
+                            !is_reference<deleter_type>::value ||
+                            is_same<deleter_type, _Ep>::value
+                         ),
+                         __nat
+                      >::type = __nat()) _NOEXCEPT
+            : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {}
+
+    template <class _Up>
+        _LIBCPP_INLINE_VISIBILITY unique_ptr(auto_ptr<_Up>&& __p,
+                typename enable_if<
+                                      is_convertible<_Up*, _Tp*>::value &&
+                                      is_same<_Dp, default_delete<_Tp> >::value,
+                                      __nat
+                                  >::type = __nat()) _NOEXCEPT
+            : __ptr_(__p.release())
+            {
+            }
+
+        _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT
+            {
+                reset(__u.release());
+                __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
+                return *this;
+            }
+
+        template <class _Up, class _Ep>
+            _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) _NOEXCEPT
+            {
+                reset(__u.release());
+                __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
+                return *this;
+            }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>()
+    {
+        return __rv<unique_ptr>(*this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u)
+        : __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)
+    {
+        reset(__u.release());
+        __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d)
+        : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {}
+
+    template <class _Up>
+        _LIBCPP_INLINE_VISIBILITY
+                typename enable_if<
+                                      is_convertible<_Up*, _Tp*>::value &&
+                                      is_same<_Dp, default_delete<_Tp> >::value,
+                                      unique_ptr&
+                                  >::type
+        operator=(auto_ptr<_Up> __p)
+            {reset(__p.release()); return *this;}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT
+    {
+        reset();
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator*() const
+        {return *__ptr_.first();}
+    _LIBCPP_INLINE_VISIBILITY pointer operator->() const _NOEXCEPT {return __ptr_.first();}
+    _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();}
+    _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter() _NOEXCEPT
+        {return __ptr_.second();}
+    _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT
+        {return __ptr_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
+        {return __ptr_.first() != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
+    {
+        pointer __t = __ptr_.first();
+        __ptr_.first() = pointer();
+        return __t;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY void reset(pointer __p = pointer()) _NOEXCEPT
+    {
+        pointer __tmp = __ptr_.first();
+        __ptr_.first() = __p;
+        if (__tmp)
+            __ptr_.second()(__tmp);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY void swap(unique_ptr& __u) _NOEXCEPT
+        {__ptr_.swap(__u.__ptr_);}
+};
+
+template <class _Tp, class _Dp>
+class _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp>
+{
+public:
+    typedef _Tp element_type;
+    typedef _Dp deleter_type;
+    typedef typename __pointer_type<_Tp, deleter_type>::type pointer;
+private:
+    __compressed_pair<pointer, deleter_type> __ptr_;
+
+#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    unique_ptr(unique_ptr&);
+    template <class _Up>
+        unique_ptr(unique_ptr<_Up>&);
+    unique_ptr& operator=(unique_ptr&);
+    template <class _Up>
+        unique_ptr& operator=(unique_ptr<_Up>&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    struct __nat {int __for_bool_;};
+
+    typedef       typename remove_reference<deleter_type>::type& _Dp_reference;
+    typedef const typename remove_reference<deleter_type>::type& _Dp_const_reference;
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT
+        : __ptr_(pointer())
+        {
+            static_assert(!is_pointer<deleter_type>::value,
+                "unique_ptr constructed with null function pointer deleter");
+        }
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT
+        : __ptr_(pointer())
+        {
+            static_assert(!is_pointer<deleter_type>::value,
+                "unique_ptr constructed with null function pointer deleter");
+        }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p,
+            typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat()) _NOEXCEPT
+        : __ptr_(__p)
+        {
+            static_assert(!is_pointer<deleter_type>::value,
+                "unique_ptr constructed with null function pointer deleter");
+        }
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p, typename conditional<
+                                       is_reference<deleter_type>::value,
+                                       deleter_type,
+                                       typename add_lvalue_reference<const deleter_type>::type>::type __d,
+                                       typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
+             _NOEXCEPT
+        : __ptr_(__p, __d) {}
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename conditional<
+                                       is_reference<deleter_type>::value,
+                                       deleter_type,
+                                       typename add_lvalue_reference<const deleter_type>::type>::type __d)
+             _NOEXCEPT
+        : __ptr_(pointer(), __d) {}
+
+    template <class _Pp>
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(_Pp __p,
+                                         typename remove_reference<deleter_type>::type&& __d,
+                                         typename enable_if<__same_or_less_cv_qualified<_Pp, pointer>::value, __nat>::type = __nat())
+             _NOEXCEPT
+        : __ptr_(__p, _VSTD::move(__d))
+        {
+            static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
+        }
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, typename remove_reference<deleter_type>::type&& __d)
+             _NOEXCEPT
+        : __ptr_(pointer(), _VSTD::move(__d))
+        {
+            static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
+        }
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(unique_ptr&& __u) _NOEXCEPT
+        : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT
+        {
+            reset(__u.release());
+            __ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
+            return *this;
+        }
+
+    template <class _Up, class _Ep>
+        _LIBCPP_INLINE_VISIBILITY
+        unique_ptr(unique_ptr<_Up, _Ep>&& __u,
+                   typename enable_if
+                            <
+                                is_array<_Up>::value &&
+                                __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value
+                                && is_convertible<_Ep, deleter_type>::value &&
+                                (
+                                    !is_reference<deleter_type>::value ||
+                                    is_same<deleter_type, _Ep>::value
+                                ),
+                                __nat
+                            >::type = __nat()
+                  ) _NOEXCEPT
+        : __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {}
+
+
+        template <class _Up, class _Ep>
+            _LIBCPP_INLINE_VISIBILITY
+            typename enable_if
+            <
+                is_array<_Up>::value &&
+                __same_or_less_cv_qualified<typename unique_ptr<_Up, _Ep>::pointer, pointer>::value &&
+                is_assignable<deleter_type&, _Ep&&>::value,
+                unique_ptr&
+            >::type
+            operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
+            {
+                reset(__u.release());
+                __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
+                return *this;
+            }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(pointer __p)
+        : __ptr_(__p)
+        {
+            static_assert(!is_pointer<deleter_type>::value,
+                "unique_ptr constructed with null function pointer deleter");
+        }
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(pointer __p, deleter_type __d)
+        : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {}
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(nullptr_t, deleter_type __d)
+        : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {}
+
+    _LIBCPP_INLINE_VISIBILITY operator __rv<unique_ptr>()
+    {
+        return __rv<unique_ptr>(*this);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr(__rv<unique_ptr> __u)
+        : __ptr_(__u->release(), _VSTD::forward<deleter_type>(__u->get_deleter())) {}
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(__rv<unique_ptr> __u)
+    {
+        reset(__u->release());
+        __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter());
+        return *this;
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
+
+    _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(nullptr_t) _NOEXCEPT
+    {
+        reset();
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY typename add_lvalue_reference<_Tp>::type operator[](size_t __i) const
+        {return __ptr_.first()[__i];}
+    _LIBCPP_INLINE_VISIBILITY pointer get() const _NOEXCEPT {return __ptr_.first();}
+    _LIBCPP_INLINE_VISIBILITY       _Dp_reference get_deleter() _NOEXCEPT
+        {return __ptr_.second();}
+    _LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT
+        {return __ptr_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
+        {return __ptr_.first() != nullptr;}
+
+    _LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
+    {
+        pointer __t = __ptr_.first();
+        __ptr_.first() = pointer();
+        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
+    reset(_Pp __p) _NOEXCEPT
+    {
+        pointer __tmp = __ptr_.first();
+        __ptr_.first() = __p;
+        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
+    {
+        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:
+
+#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Up>
+        explicit unique_ptr(_Up);
+    template <class _Up>
+        unique_ptr(_Up __u,
+                   typename conditional<
+                                       is_reference<deleter_type>::value,
+                                       deleter_type,
+                                       typename add_lvalue_reference<const deleter_type>::type>::type,
+                   typename enable_if
+                      <
+                         is_convertible<_Up, pointer>::value,
+                         __nat
+                      >::type = __nat());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+};
+
+template <class _Tp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {__x.swap(__y);}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x == __y);}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+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());
+}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __y < __x;}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__y < __x);}
+
+template <class _T1, class _D1, class _T2, class _D2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
+{
+    return !__x;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
+{
+    return !__x;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
+{
+    return static_cast<bool>(__x);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
+{
+    return static_cast<bool>(__x);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+    typedef typename unique_ptr<_T1, _D1>::pointer _P1;
+    return less<_P1>()(__x.get(), nullptr);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+    typedef typename unique_ptr<_T1, _D1>::pointer _P1;
+    return less<_P1>()(nullptr, __x.get());
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+    return nullptr < __x;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+    return __x < nullptr;
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+    return !(nullptr < __x);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+    return !(__x < nullptr);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const unique_ptr<_T1, _D1>& __x, nullptr_t)
+{
+    return !(__x < nullptr);
+}
+
+template <class _T1, class _D1>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
+{
+    return !(nullptr < __x);
+}
+
+#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+unique_ptr<_Tp, _Dp>
+move(unique_ptr<_Tp, _Dp>& __t)
+{
+    return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t));
+}
+
+#endif
+
+#if _LIBCPP_STD_VER > 11
+
+template<class _Tp>
+struct __unique_if
+{
+    typedef unique_ptr<_Tp> __unique_single;
+};
+
+template<class _Tp>
+struct __unique_if<_Tp[]>
+{
+    typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
+};
+
+template<class _Tp, size_t _Np>
+struct __unique_if<_Tp[_Np]>
+{
+    typedef void __unique_array_known_bound;
+};
+
+template<class _Tp, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __unique_if<_Tp>::__unique_single
+make_unique(_Args&&... __args)
+{
+    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename __unique_if<_Tp>::__unique_array_unknown_bound
+make_unique(size_t __n)
+{
+    typedef typename remove_extent<_Tp>::type _Up;
+    return unique_ptr<_Tp>(new _Up[__n]());
+}
+
+template<class _Tp, class... _Args>
+    typename __unique_if<_Tp>::__unique_array_known_bound
+    make_unique(_Args&&...) = delete;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+template <class _Tp> struct hash;
+
+template <class _Size>
+inline _LIBCPP_INLINE_VISIBILITY
+_Size
+__loadword(const void* __p)
+{
+    _Size __r;
+    std::memcpy(&__r, __p, sizeof(__r));
+    return __r;
+}
+
+// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
+// is 64 bits.  This is because cityhash64 uses 64bit x 64bit
+// multiplication, which can be very slow on 32-bit systems.
+template <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__>
+struct __murmur2_or_cityhash;
+
+template <class _Size>
+struct __murmur2_or_cityhash<_Size, 32>
+{
+    _Size operator()(const void* __key, _Size __len);
+};
+
+// murmur2
+template <class _Size>
+_Size
+__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len)
+{
+    const _Size __m = 0x5bd1e995;
+    const _Size __r = 24;
+    _Size __h = __len;
+    const unsigned char* __data = static_cast<const unsigned char*>(__key);
+    for (; __len >= 4; __data += 4, __len -= 4)
+    {
+        _Size __k = __loadword<_Size>(__data);
+        __k *= __m;
+        __k ^= __k >> __r;
+        __k *= __m;
+        __h *= __m;
+        __h ^= __k;
+    }
+    switch (__len)
+    {
+    case 3:
+        __h ^= __data[2] << 16;
+    case 2:
+        __h ^= __data[1] << 8;
+    case 1:
+        __h ^= __data[0];
+        __h *= __m;
+    }
+    __h ^= __h >> 13;
+    __h *= __m;
+    __h ^= __h >> 15;
+    return __h;
+}
+
+template <class _Size>
+struct __murmur2_or_cityhash<_Size, 64>
+{
+    _Size operator()(const void* __key, _Size __len);
+
+ private:
+  // Some primes between 2^63 and 2^64.
+  static const _Size __k0 = 0xc3a5c85c97cb3127ULL;
+  static const _Size __k1 = 0xb492b66fbe98f273ULL;
+  static const _Size __k2 = 0x9ae16a3b2f90404fULL;
+  static const _Size __k3 = 0xc949d7c7509e6557ULL;
+
+  static _Size __rotate(_Size __val, int __shift) {
+    return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
+  }
+
+  static _Size __rotate_by_at_least_1(_Size __val, int __shift) {
+    return (__val >> __shift) | (__val << (64 - __shift));
+  }
+
+  static _Size __shift_mix(_Size __val) {
+    return __val ^ (__val >> 47);
+  }
+
+  static _Size __hash_len_16(_Size __u, _Size __v) {
+    const _Size __mul = 0x9ddfea08eb382d69ULL;
+    _Size __a = (__u ^ __v) * __mul;
+    __a ^= (__a >> 47);
+    _Size __b = (__v ^ __a) * __mul;
+    __b ^= (__b >> 47);
+    __b *= __mul;
+    return __b;
+  }
+
+  static _Size __hash_len_0_to_16(const char* __s, _Size __len) {
+    if (__len > 8) {
+      const _Size __a = __loadword<_Size>(__s);
+      const _Size __b = __loadword<_Size>(__s + __len - 8);
+      return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
+    }
+    if (__len >= 4) {
+      const uint32_t __a = __loadword<uint32_t>(__s);
+      const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
+      return __hash_len_16(__len + (__a << 3), __b);
+    }
+    if (__len > 0) {
+      const unsigned char __a = __s[0];
+      const unsigned char __b = __s[__len >> 1];
+      const unsigned char __c = __s[__len - 1];
+      const uint32_t __y = static_cast<uint32_t>(__a) +
+                           (static_cast<uint32_t>(__b) << 8);
+      const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2);
+      return __shift_mix(__y * __k2 ^ __z * __k3) * __k2;
+    }
+    return __k2;
+  }
+
+  static _Size __hash_len_17_to_32(const char *__s, _Size __len) {
+    const _Size __a = __loadword<_Size>(__s) * __k1;
+    const _Size __b = __loadword<_Size>(__s + 8);
+    const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;
+    const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;
+    return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
+                         __a + __rotate(__b ^ __k3, 20) - __c + __len);
+  }
+
+  // Return a 16-byte hash for 48 bytes.  Quick and dirty.
+  // Callers do best to use "random-looking" values for a and b.
+  static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
+      _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) {
+    __a += __w;
+    __b = __rotate(__b + __a + __z, 21);
+    const _Size __c = __a;
+    __a += __x;
+    __a += __y;
+    __b += __rotate(__a, 44);
+    return pair<_Size, _Size>(__a + __z, __b + __c);
+  }
+
+  // Return a 16-byte hash for s[0] ... s[31], a, and b.  Quick and dirty.
+  static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
+      const char* __s, _Size __a, _Size __b) {
+    return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),
+                                         __loadword<_Size>(__s + 8),
+                                         __loadword<_Size>(__s + 16),
+                                         __loadword<_Size>(__s + 24),
+                                         __a,
+                                         __b);
+  }
+
+  // Return an 8-byte hash for 33 to 64 bytes.
+  static _Size __hash_len_33_to_64(const char *__s, size_t __len) {
+    _Size __z = __loadword<_Size>(__s + 24);
+    _Size __a = __loadword<_Size>(__s) +
+                (__len + __loadword<_Size>(__s + __len - 16)) * __k0;
+    _Size __b = __rotate(__a + __z, 52);
+    _Size __c = __rotate(__a, 37);
+    __a += __loadword<_Size>(__s + 8);
+    __c += __rotate(__a, 7);
+    __a += __loadword<_Size>(__s + 16);
+    _Size __vf = __a + __z;
+    _Size __vs = __b + __rotate(__a, 31) + __c;
+    __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);
+    __z += __loadword<_Size>(__s + __len - 8);
+    __b = __rotate(__a + __z, 52);
+    __c = __rotate(__a, 37);
+    __a += __loadword<_Size>(__s + __len - 24);
+    __c += __rotate(__a, 7);
+    __a += __loadword<_Size>(__s + __len - 16);
+    _Size __wf = __a + __z;
+    _Size __ws = __b + __rotate(__a, 31) + __c;
+    _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
+    return __shift_mix(__r * __k0 + __vs) * __k2;
+  }
+};
+
+// cityhash64
+template <class _Size>
+_Size
+__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len)
+{
+  const char* __s = static_cast<const char*>(__key);
+  if (__len <= 32) {
+    if (__len <= 16) {
+      return __hash_len_0_to_16(__s, __len);
+    } else {
+      return __hash_len_17_to_32(__s, __len);
+    }
+  } else if (__len <= 64) {
+    return __hash_len_33_to_64(__s, __len);
+  }
+
+  // For strings over 64 bytes we hash the end first, and then as we
+  // loop we keep 56 bytes of state: v, w, x, y, and z.
+  _Size __x = __loadword<_Size>(__s + __len - 40);
+  _Size __y = __loadword<_Size>(__s + __len - 16) +
+              __loadword<_Size>(__s + __len - 56);
+  _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,
+                          __loadword<_Size>(__s + __len - 24));
+  pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
+  pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
+  __x = __x * __k1 + __loadword<_Size>(__s);
+
+  // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
+  __len = (__len - 1) & ~static_cast<_Size>(63);
+  do {
+    __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;
+    __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;
+    __x ^= __w.second;
+    __y += __v.first + __loadword<_Size>(__s + 40);
+    __z = __rotate(__z + __w.first, 33) * __k1;
+    __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
+    __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
+                                        __y + __loadword<_Size>(__s + 16));
+    std::swap(__z, __x);
+    __s += 64;
+    __len -= 64;
+  } while (__len != 0);
+  return __hash_len_16(
+      __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z,
+      __hash_len_16(__v.second, __w.second) + __x);
+}
+
+template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
+struct __scalar_hash;
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 0>
+    : public unary_function<_Tp, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(_Tp __v) const _NOEXCEPT
+    {
+        union
+        {
+            _Tp    __t;
+            size_t __a;
+        } __u;
+        __u.__a = 0;
+        __u.__t = __v;
+        return __u.__a;
+    }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 1>
+    : public unary_function<_Tp, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(_Tp __v) const _NOEXCEPT
+    {
+        union
+        {
+            _Tp    __t;
+            size_t __a;
+        } __u;
+        __u.__t = __v;
+        return __u.__a;
+    }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 2>
+    : public unary_function<_Tp, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(_Tp __v) const _NOEXCEPT
+    {
+        union
+        {
+            _Tp __t;
+            struct
+            {
+                size_t __a;
+                size_t __b;
+            };
+        } __u;
+        __u.__t = __v;
+        return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+    }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 3>
+    : public unary_function<_Tp, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(_Tp __v) const _NOEXCEPT
+    {
+        union
+        {
+            _Tp __t;
+            struct
+            {
+                size_t __a;
+                size_t __b;
+                size_t __c;
+            };
+        } __u;
+        __u.__t = __v;
+        return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+    }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 4>
+    : public unary_function<_Tp, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(_Tp __v) const _NOEXCEPT
+    {
+        union
+        {
+            _Tp __t;
+            struct
+            {
+                size_t __a;
+                size_t __b;
+                size_t __c;
+                size_t __d;
+            };
+        } __u;
+        __u.__t = __v;
+        return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+    }
+};
+
+template<class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*>
+    : public unary_function<_Tp*, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(_Tp* __v) const _NOEXCEPT
+    {
+        union
+        {
+            _Tp* __t;
+            size_t __a;
+        } __u;
+        __u.__t = __v;
+        return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
+    }
+};
+
+template <class _Tp, class _Dp>
+struct _LIBCPP_TYPE_VIS_ONLY hash<unique_ptr<_Tp, _Dp> >
+{
+    typedef unique_ptr<_Tp, _Dp> argument_type;
+    typedef size_t               result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator()(const argument_type& __ptr) const _NOEXCEPT
+    {
+        typedef typename argument_type::pointer pointer;
+        return hash<pointer>()(__ptr.get());
+    }
+};
+
+struct __destruct_n
+{
+private:
+    size_t size;
+
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY void __process(_Tp* __p, false_type) _NOEXCEPT
+        {for (size_t __i = 0; __i < size; ++__i, ++__p) __p->~_Tp();}
+
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY void __process(_Tp*, true_type) _NOEXCEPT
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY void __incr(false_type) _NOEXCEPT
+        {++size;}
+    _LIBCPP_INLINE_VISIBILITY void __incr(true_type) _NOEXCEPT
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, false_type) _NOEXCEPT
+        {size = __s;}
+    _LIBCPP_INLINE_VISIBILITY void __set(size_t, true_type) _NOEXCEPT
+        {}
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit __destruct_n(size_t __s) _NOEXCEPT
+        : size(__s) {}
+
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY void __incr(_Tp*) _NOEXCEPT
+        {__incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
+
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY void __set(size_t __s, _Tp*) _NOEXCEPT
+        {__set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
+
+    template <class _Tp>
+    _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) _NOEXCEPT
+        {__process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>());}
+};
+
+template <class _Alloc>
+class __allocator_destructor
+{
+    typedef allocator_traits<_Alloc> __alloc_traits;
+public:
+    typedef typename __alloc_traits::pointer pointer;
+    typedef typename __alloc_traits::size_type size_type;
+private:
+    _Alloc& __alloc_;
+    size_type __s_;
+public:
+    _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s)
+             _NOEXCEPT
+        : __alloc_(__a), __s_(__s) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void operator()(pointer __p) _NOEXCEPT
+        {__alloc_traits::deallocate(__alloc_, __p, __s_);}
+};
+
+template <class _InputIterator, class _ForwardIterator>
+_ForwardIterator
+uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
+{
+    typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    _ForwardIterator __s = __r;
+    try
+    {
+#endif
+        for (; __f != __l; ++__f, ++__r)
+            ::new(&*__r) value_type(*__f);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        for (; __s != __r; ++__s)
+            __s->~value_type();
+        throw;
+    }
+#endif
+    return __r;
+}
+
+template <class _InputIterator, class _Size, class _ForwardIterator>
+_ForwardIterator
+uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
+{
+    typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    _ForwardIterator __s = __r;
+    try
+    {
+#endif
+        for (; __n > 0; ++__f, ++__r, --__n)
+            ::new(&*__r) value_type(*__f);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        for (; __s != __r; ++__s)
+            __s->~value_type();
+        throw;
+    }
+#endif
+    return __r;
+}
+
+template <class _ForwardIterator, class _Tp>
+void
+uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
+{
+    typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    _ForwardIterator __s = __f;
+    try
+    {
+#endif
+        for (; __f != __l; ++__f)
+            ::new(&*__f) value_type(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        for (; __s != __f; ++__s)
+            __s->~value_type();
+        throw;
+    }
+#endif
+}
+
+template <class _ForwardIterator, class _Size, class _Tp>
+_ForwardIterator
+uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
+{
+    typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    _ForwardIterator __s = __f;
+    try
+    {
+#endif
+        for (; __n > 0; ++__f, --__n)
+            ::new(&*__f) value_type(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        for (; __s != __f; ++__s)
+            __s->~value_type();
+        throw;
+    }
+#endif
+    return __f;
+}
+
+class _LIBCPP_EXCEPTION_ABI bad_weak_ptr
+    : public std::exception
+{
+public:
+    virtual ~bad_weak_ptr() _NOEXCEPT;
+    virtual const char* what() const  _NOEXCEPT;
+};
+
+template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
+
+class _LIBCPP_TYPE_VIS __shared_count
+{
+    __shared_count(const __shared_count&);
+    __shared_count& operator=(const __shared_count&);
+
+protected:
+    long __shared_owners_;
+    virtual ~__shared_count();
+private:
+    virtual void __on_zero_shared() _NOEXCEPT = 0;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __shared_count(long __refs = 0) _NOEXCEPT
+        : __shared_owners_(__refs) {}
+
+    void __add_shared() _NOEXCEPT;
+    bool __release_shared() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    long use_count() const _NOEXCEPT {return __shared_owners_ + 1;}
+};
+
+class _LIBCPP_TYPE_VIS __shared_weak_count
+    : private __shared_count
+{
+    long __shared_weak_owners_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __shared_weak_count(long __refs = 0) _NOEXCEPT
+        : __shared_count(__refs),
+          __shared_weak_owners_(__refs) {}
+protected:
+    virtual ~__shared_weak_count();
+
+public:
+    void __add_shared() _NOEXCEPT;
+    void __add_weak() _NOEXCEPT;
+    void __release_shared() _NOEXCEPT;
+    void __release_weak() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    long use_count() const _NOEXCEPT {return __shared_count::use_count();}
+    __shared_weak_count* lock() _NOEXCEPT;
+
+    // Define the function out only if we build static libc++ without RTTI.
+    // Otherwise we may break clients who need to compile their projects with
+    // -fno-rtti and yet link against a libc++.dylib compiled
+    // without -fno-rtti.
+#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
+    virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
+#endif
+private:
+    virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
+};
+
+template <class _Tp, class _Dp, class _Alloc>
+class __shared_ptr_pointer
+    : public __shared_weak_count
+{
+    __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
+        :  __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {}
+
+#ifndef _LIBCPP_NO_RTTI
+    virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
+#endif
+
+private:
+    virtual void __on_zero_shared() _NOEXCEPT;
+    virtual void __on_zero_shared_weak() _NOEXCEPT;
+};
+
+#ifndef _LIBCPP_NO_RTTI
+
+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;
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template <class _Tp, class _Dp, class _Alloc>
+void
+__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT
+{
+    __data_.first().second()(__data_.first().first());
+    __data_.first().second().~_Dp();
+}
+
+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());
+    __data_.second().~_Alloc();
+    __a.deallocate(this, 1);
+}
+
+template <class _Tp, class _Alloc>
+class __shared_ptr_emplace
+    : public __shared_weak_count
+{
+    __compressed_pair<_Alloc, _Tp> __data_;
+public:
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __shared_ptr_emplace(_Alloc __a)
+        :  __data_(_VSTD::move(__a)) {}
+
+    template <class ..._Args>
+        _LIBCPP_INLINE_VISIBILITY
+        __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
+            :  __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
+                   _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {}
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+    _LIBCPP_INLINE_VISIBILITY
+    __shared_ptr_emplace(_Alloc __a)
+        :  __data_(__a) {}
+
+    template <class _A0>
+        _LIBCPP_INLINE_VISIBILITY
+        __shared_ptr_emplace(_Alloc __a, _A0& __a0)
+            :  __data_(__a, _Tp(__a0)) {}
+
+    template <class _A0, class _A1>
+        _LIBCPP_INLINE_VISIBILITY
+        __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1)
+            :  __data_(__a, _Tp(__a0, __a1)) {}
+
+    template <class _A0, class _A1, class _A2>
+        _LIBCPP_INLINE_VISIBILITY
+        __shared_ptr_emplace(_Alloc __a, _A0& __a0, _A1& __a1, _A2& __a2)
+            :  __data_(__a, _Tp(__a0, __a1, __a2)) {}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+private:
+    virtual void __on_zero_shared() _NOEXCEPT;
+    virtual void __on_zero_shared_weak() _NOEXCEPT;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp* get() _NOEXCEPT {return &__data_.second();}
+};
+
+template <class _Tp, class _Alloc>
+void
+__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT
+{
+    __data_.second().~_Tp();
+}
+
+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());
+    __data_.first().~_Alloc();
+    __a.deallocate(this, 1);
+}
+
+template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this;
+
+template<class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY shared_ptr
+{
+public:
+    typedef _Tp element_type;
+private:
+    element_type*      __ptr_;
+    __shared_weak_count* __cntrl_;
+
+    struct __nat {int __for_bool_;};
+public:
+    _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT;
+    template<class _Yp>
+        explicit shared_ptr(_Yp* __p,
+                            typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
+    template<class _Yp, class _Dp>
+        shared_ptr(_Yp* __p, _Dp __d,
+                   typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
+    template<class _Yp, class _Dp, class _Alloc>
+        shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
+                   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;
+    shared_ptr(const shared_ptr& __r) _NOEXCEPT;
+    template<class _Yp>
+        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
+    shared_ptr(shared_ptr&& __r) _NOEXCEPT;
+    template<class _Yp> shared_ptr(shared_ptr<_Yp>&& __r,
+                   typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type = __nat())
+                       _NOEXCEPT;
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r,
+                   typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type= __nat());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template<class _Yp>
+        shared_ptr(auto_ptr<_Yp>&& __r,
+                   typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
+#else
+    template<class _Yp>
+        shared_ptr(auto_ptr<_Yp> __r,
+                   typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat());
+#endif
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Yp, class _Dp>
+        shared_ptr(unique_ptr<_Yp, _Dp>&&,
+                   typename enable_if
+                   <
+                       !is_lvalue_reference<_Dp>::value &&
+                       !is_array<_Yp>::value &&
+                       is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+                       __nat
+                   >::type = __nat());
+    template <class _Yp, class _Dp>
+        shared_ptr(unique_ptr<_Yp, _Dp>&&,
+                   typename enable_if
+                   <
+                       is_lvalue_reference<_Dp>::value &&
+                       !is_array<_Yp>::value &&
+                       is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+                       __nat
+                   >::type = __nat());
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Yp, class _Dp>
+        shared_ptr(unique_ptr<_Yp, _Dp>,
+                   typename enable_if
+                   <
+                       !is_lvalue_reference<_Dp>::value &&
+                       !is_array<_Yp>::value &&
+                       is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+                       __nat
+                   >::type = __nat());
+    template <class _Yp, class _Dp>
+        shared_ptr(unique_ptr<_Yp, _Dp>,
+                   typename enable_if
+                   <
+                       is_lvalue_reference<_Dp>::value &&
+                       !is_array<_Yp>::value &&
+                       is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+                       __nat
+                   >::type = __nat());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    ~shared_ptr();
+
+    shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT;
+    template<class _Yp>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            shared_ptr&
+        >::type
+        operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT;
+    template<class _Yp>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            shared_ptr<_Tp>&
+        >::type
+        operator=(shared_ptr<_Yp>&& __r);
+    template<class _Yp>
+        typename enable_if
+        <
+            !is_array<_Yp>::value &&
+            is_convertible<_Yp*, element_type*>::value,
+            shared_ptr
+        >::type&
+        operator=(auto_ptr<_Yp>&& __r);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template<class _Yp>
+        typename enable_if
+        <
+            !is_array<_Yp>::value &&
+            is_convertible<_Yp*, element_type*>::value,
+            shared_ptr&
+        >::type
+        operator=(auto_ptr<_Yp> __r);
+#endif
+    template <class _Yp, class _Dp>
+        typename enable_if
+        <
+            !is_array<_Yp>::value &&
+            is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+            shared_ptr&
+        >::type
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        operator=(unique_ptr<_Yp, _Dp>&& __r);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        operator=(unique_ptr<_Yp, _Dp> __r);
+#endif
+
+    void swap(shared_ptr& __r) _NOEXCEPT;
+    void reset() _NOEXCEPT;
+    template<class _Yp>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            void
+        >::type
+        reset(_Yp* __p);
+    template<class _Yp, class _Dp>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            void
+        >::type
+        reset(_Yp* __p, _Dp __d);
+    template<class _Yp, class _Dp, class _Alloc>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            void
+        >::type
+        reset(_Yp* __p, _Dp __d, _Alloc __a);
+
+    _LIBCPP_INLINE_VISIBILITY
+    element_type* get() const _NOEXCEPT {return __ptr_;}
+    _LIBCPP_INLINE_VISIBILITY
+    typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT
+        {return *__ptr_;}
+    _LIBCPP_INLINE_VISIBILITY
+    element_type* operator->() const _NOEXCEPT {return __ptr_;}
+    _LIBCPP_INLINE_VISIBILITY
+    long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool unique() const _NOEXCEPT {return use_count() == 1;}
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;}
+    template <class _Up>
+        _LIBCPP_INLINE_VISIBILITY
+        bool owner_before(shared_ptr<_Up> const& __p) const
+        {return __cntrl_ < __p.__cntrl_;}
+    template <class _Up>
+        _LIBCPP_INLINE_VISIBILITY
+        bool owner_before(weak_ptr<_Up> const& __p) const
+        {return __cntrl_ < __p.__cntrl_;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool
+    __owner_equivalent(const shared_ptr& __p) const
+        {return __cntrl_ == __p.__cntrl_;}
+
+#ifndef _LIBCPP_NO_RTTI
+    template <class _Dp>
+        _LIBCPP_INLINE_VISIBILITY
+        _Dp* __get_deleter() const _NOEXCEPT
+            {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);}
+#endif  // _LIBCPP_NO_RTTI
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    template<class ..._Args>
+        static
+        shared_ptr<_Tp>
+        make_shared(_Args&& ...__args);
+
+    template<class _Alloc, class ..._Args>
+        static
+        shared_ptr<_Tp>
+        allocate_shared(const _Alloc& __a, _Args&& ...__args);
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+    static shared_ptr<_Tp> make_shared();
+
+    template<class _A0>
+        static shared_ptr<_Tp> make_shared(_A0&);
+
+    template<class _A0, class _A1>
+        static shared_ptr<_Tp> make_shared(_A0&, _A1&);
+
+    template<class _A0, class _A1, class _A2>
+        static shared_ptr<_Tp> make_shared(_A0&, _A1&, _A2&);
+
+    template<class _Alloc>
+        static shared_ptr<_Tp>
+        allocate_shared(const _Alloc& __a);
+
+    template<class _Alloc, class _A0>
+        static shared_ptr<_Tp>
+        allocate_shared(const _Alloc& __a, _A0& __a0);
+
+    template<class _Alloc, class _A0, class _A1>
+        static shared_ptr<_Tp>
+        allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1);
+
+    template<class _Alloc, class _A0, class _A1, class _A2>
+        static shared_ptr<_Tp>
+        allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2);
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+private:
+
+    template <class _Yp>
+        _LIBCPP_INLINE_VISIBILITY
+        void
+        __enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT
+        {
+            if (__e)
+                __e->__weak_this_ = *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __enable_weak_this(const 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
+_LIBCPP_CONSTEXPR
+shared_ptr<_Tp>::shared_ptr() _NOEXCEPT
+    : __ptr_(0),
+      __cntrl_(0)
+{
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT
+    : __ptr_(0),
+      __cntrl_(0)
+{
+}
+
+template<class _Tp>
+template<class _Yp>
+shared_ptr<_Tp>::shared_ptr(_Yp* __p,
+                            typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
+    : __ptr_(__p)
+{
+    unique_ptr<_Yp> __hold(__p);
+    typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
+    __cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>());
+    __hold.release();
+    __enable_weak_this(__p);
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp>
+shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d,
+                            typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
+    : __ptr_(__p)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
+        __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>());
+        __enable_weak_this(__p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __d(__p);
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Dp>
+shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d)
+    : __ptr_(0)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typedef __shared_ptr_pointer<nullptr_t, _Dp, allocator<_Tp> > _CntrlBlk;
+        __cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>());
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __d(__p);
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp, class _Alloc>
+shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a,
+                            typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
+    : __ptr_(__p)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
+        typedef typename _Alloc::template rebind<_CntrlBlk>::other _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();
+        __enable_weak_this(__p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __d(__p);
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Dp, class _Alloc>
+shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a)
+    : __ptr_(0)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
+        typedef typename _Alloc::template rebind<_CntrlBlk>::other _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();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __d(__p);
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT
+    : __ptr_(__p),
+      __cntrl_(__r.__cntrl_)
+{
+    if (__cntrl_)
+        __cntrl_->__add_shared();
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    if (__cntrl_)
+        __cntrl_->__add_shared();
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r,
+                            typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
+         _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    if (__cntrl_)
+        __cntrl_->__add_shared();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    __r.__ptr_ = 0;
+    __r.__cntrl_ = 0;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r,
+                            typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
+         _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    __r.__ptr_ = 0;
+    __r.__cntrl_ = 0;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+template<class _Yp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r,
+#else
+shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp> __r,
+#endif
+                            typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type)
+    : __ptr_(__r.get())
+{
+    typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
+    __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>());
+    __enable_weak_this(__r.get());
+    __r.release();
+}
+
+template<class _Tp>
+template <class _Yp, class _Dp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
+#else
+shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
+#endif
+                            typename enable_if
+                            <
+                                !is_lvalue_reference<_Dp>::value &&
+                                !is_array<_Yp>::value &&
+                                is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+                                __nat
+                            >::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());
+    __r.release();
+}
+
+template<class _Tp>
+template <class _Yp, class _Dp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r,
+#else
+shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
+#endif
+                            typename enable_if
+                            <
+                                is_lvalue_reference<_Dp>::value &&
+                                !is_array<_Yp>::value &&
+                                is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
+                                __nat
+                            >::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());
+    __r.release();
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Tp>
+template<class ..._Args>
+shared_ptr<_Tp>
+shared_ptr<_Tp>::make_shared(_Args&& ...__args)
+{
+    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
+    typedef allocator<_CntrlBlk> _A2;
+    typedef __allocator_destructor<_A2> _D2;
+    _A2 __a2;
+    unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
+    ::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)...);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _Alloc, class ..._Args>
+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 __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)...);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Tp>
+shared_ptr<_Tp>
+shared_ptr<_Tp>::make_shared()
+{
+    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
+    typedef allocator<_CntrlBlk> _Alloc2;
+    typedef __allocator_destructor<_Alloc2> _D2;
+    _Alloc2 __alloc2;
+    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
+    ::new(__hold2.get()) _CntrlBlk(__alloc2);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _A0>
+shared_ptr<_Tp>
+shared_ptr<_Tp>::make_shared(_A0& __a0)
+{
+    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
+    typedef allocator<_CntrlBlk> _Alloc2;
+    typedef __allocator_destructor<_Alloc2> _D2;
+    _Alloc2 __alloc2;
+    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
+    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _A0, class _A1>
+shared_ptr<_Tp>
+shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1)
+{
+    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
+    typedef allocator<_CntrlBlk> _Alloc2;
+    typedef __allocator_destructor<_Alloc2> _D2;
+    _Alloc2 __alloc2;
+    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
+    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _A0, class _A1, class _A2>
+shared_ptr<_Tp>
+shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
+{
+    typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
+    typedef allocator<_CntrlBlk> _Alloc2;
+    typedef __allocator_destructor<_Alloc2> _D2;
+    _Alloc2 __alloc2;
+    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
+    ::new(__hold2.get()) _CntrlBlk(__alloc2, __a0, __a1, __a2);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _Alloc>
+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 __allocator_destructor<_Alloc2> _D2;
+    _Alloc2 __alloc2(__a);
+    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
+    ::new(__hold2.get()) _CntrlBlk(__a);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _Alloc, class _A0>
+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 __allocator_destructor<_Alloc2> _D2;
+    _Alloc2 __alloc2(__a);
+    unique_ptr<_CntrlBlk, _D2> __hold2(__alloc2.allocate(1), _D2(__alloc2, 1));
+    ::new(__hold2.get()) _CntrlBlk(__a, __a0);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _Alloc, class _A0, class _A1>
+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 __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);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+template<class _Tp>
+template<class _Alloc, class _A0, class _A1, class _A2>
+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 __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);
+    shared_ptr<_Tp> __r;
+    __r.__ptr_ = __hold2.get()->get();
+    __r.__cntrl_ = __hold2.release();
+    __r.__enable_weak_this(__r.__ptr_);
+    return __r;
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Tp>
+shared_ptr<_Tp>::~shared_ptr()
+{
+    if (__cntrl_)
+        __cntrl_->__release_shared();
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>&
+shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT
+{
+    shared_ptr(__r).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT
+{
+    shared_ptr(__r).swap(*this);
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>&
+shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT
+{
+    shared_ptr(_VSTD::move(__r)).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r)
+{
+    shared_ptr(_VSTD::move(__r)).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Yp>::value &&
+    is_convertible<_Yp*, _Tp*>::value,
+    shared_ptr<_Tp>
+>::type&
+shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r)
+{
+    shared_ptr(_VSTD::move(__r)).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+template <class _Yp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Yp>::value &&
+    is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value,
+    shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r)
+{
+    shared_ptr(_VSTD::move(__r)).swap(*this);
+    return *this;
+}
+
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Yp>::value &&
+    is_convertible<_Yp*, _Tp*>::value,
+    shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(auto_ptr<_Yp> __r)
+{
+    shared_ptr(__r).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+template <class _Yp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Yp>::value &&
+    is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, _Tp*>::value,
+    shared_ptr<_Tp>&
+>::type
+shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r)
+{
+    shared_ptr(_VSTD::move(__r)).swap(*this);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT
+{
+    _VSTD::swap(__ptr_, __r.__ptr_);
+    _VSTD::swap(__cntrl_, __r.__cntrl_);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+shared_ptr<_Tp>::reset() _NOEXCEPT
+{
+    shared_ptr().swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    void
+>::type
+shared_ptr<_Tp>::reset(_Yp* __p)
+{
+    shared_ptr(__p).swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    void
+>::type
+shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d)
+{
+    shared_ptr(__p, __d).swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp, class _Dp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    void
+>::type
+shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a)
+{
+    shared_ptr(__p, __d, __a).swap(*this);
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Tp, class ..._Args>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Tp>::value,
+    shared_ptr<_Tp>
+>::type
+make_shared(_Args&& ...__args)
+{
+    return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
+}
+
+template<class _Tp, class _Alloc, class ..._Args>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Tp>::value,
+    shared_ptr<_Tp>
+>::type
+allocate_shared(const _Alloc& __a, _Args&& ...__args)
+{
+    return shared_ptr<_Tp>::allocate_shared(__a, _VSTD::forward<_Args>(__args)...);
+}
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+make_shared()
+{
+    return shared_ptr<_Tp>::make_shared();
+}
+
+template<class _Tp, class _A0>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+make_shared(_A0& __a0)
+{
+    return shared_ptr<_Tp>::make_shared(__a0);
+}
+
+template<class _Tp, class _A0, class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+make_shared(_A0& __a0, _A1& __a1)
+{
+    return shared_ptr<_Tp>::make_shared(__a0, __a1);
+}
+
+template<class _Tp, class _A0, class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
+{
+    return shared_ptr<_Tp>::make_shared(__a0, __a1, __a2);
+}
+
+template<class _Tp, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+allocate_shared(const _Alloc& __a)
+{
+    return shared_ptr<_Tp>::allocate_shared(__a);
+}
+
+template<class _Tp, class _Alloc, class _A0>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+allocate_shared(const _Alloc& __a, _A0& __a0)
+{
+    return shared_ptr<_Tp>::allocate_shared(__a, __a0);
+}
+
+template<class _Tp, class _Alloc, class _A0, class _A1>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
+{
+    return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1);
+}
+
+template<class _Tp, class _Alloc, class _A0, class _A1, class _A2>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2)
+{
+    return shared_ptr<_Tp>::allocate_shared(__a, __a0, __a1, __a2);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+    return __x.get() == __y.get();
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+    return !(__x == __y);
+}
+
+template<class _Tp, class _Up>
+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());
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+    return __y < __x;
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+    return !(__y < __x);
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
+{
+    return !(__x < __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+    return !__x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+    return !__x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+    return static_cast<bool>(__x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+    return static_cast<bool>(__x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+    return less<_Tp*>()(__x.get(), nullptr);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+    return less<_Tp*>()(nullptr, __x.get());
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+    return nullptr < __x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+    return __x < nullptr;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+    return !(nullptr < __x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+    return !(__x < nullptr);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
+{
+    return !(__x < nullptr);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT
+{
+    return !(nullptr < __x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(shared_ptr<_Tp>& __x, shared_ptr<_Tp>& __y) _NOEXCEPT
+{
+    __x.swap(__y);
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Tp>::value && !is_array<_Up>::value,
+    shared_ptr<_Tp>
+>::type
+static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
+{
+    return shared_ptr<_Tp>(__r, static_cast<_Tp*>(__r.get()));
+}
+
+template<class _Tp, class _Up>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_array<_Tp>::value && !is_array<_Up>::value,
+    shared_ptr<_Tp>
+>::type
+dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
+{
+    _Tp* __p = dynamic_cast<_Tp*>(__r.get());
+    return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>();
+}
+
+template<class _Tp, class _Up>
+typename enable_if
+<
+    is_array<_Tp>::value == is_array<_Up>::value,
+    shared_ptr<_Tp>
+>::type
+const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT
+{
+    typedef typename remove_extent<_Tp>::type _RTp;
+    return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get()));
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+template<class _Dp, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Dp*
+get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT
+{
+    return __p.template __get_deleter<_Dp>();
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+template<class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY weak_ptr
+{
+public:
+    typedef _Tp element_type;
+private:
+    element_type*        __ptr_;
+    __shared_weak_count* __cntrl_;
+
+public:
+    _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT;
+    template<class _Yp> weak_ptr(shared_ptr<_Yp> const& __r,
+                   typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0)
+                        _NOEXCEPT;
+    weak_ptr(weak_ptr const& __r) _NOEXCEPT;
+    template<class _Yp> 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
+    weak_ptr(weak_ptr&& __r) _NOEXCEPT;
+    template<class _Yp> 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();
+
+    weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT;
+    template<class _Yp>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            weak_ptr&
+        >::type
+        operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
+    template<class _Yp>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            weak_ptr&
+        >::type
+        operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    template<class _Yp>
+        typename enable_if
+        <
+            is_convertible<_Yp*, element_type*>::value,
+            weak_ptr&
+        >::type
+        operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT;
+
+    void swap(weak_ptr& __r) _NOEXCEPT;
+    void reset() _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    long use_count() const _NOEXCEPT
+        {return __cntrl_ ? __cntrl_->use_count() : 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool expired() const _NOEXCEPT
+        {return __cntrl_ == 0 || __cntrl_->use_count() == 0;}
+    shared_ptr<_Tp> lock() const _NOEXCEPT;
+    template<class _Up>
+        _LIBCPP_INLINE_VISIBILITY
+        bool owner_before(const shared_ptr<_Up>& __r) const
+        {return __cntrl_ < __r.__cntrl_;}
+    template<class _Up>
+        _LIBCPP_INLINE_VISIBILITY
+        bool owner_before(const weak_ptr<_Up>& __r) const
+        {return __cntrl_ < __r.__cntrl_;}
+
+    template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
+    template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
+};
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+weak_ptr<_Tp>::weak_ptr() _NOEXCEPT
+    : __ptr_(0),
+      __cntrl_(0)
+{
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    if (__cntrl_)
+        __cntrl_->__add_weak();
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r,
+                        typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
+                         _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    if (__cntrl_)
+        __cntrl_->__add_weak();
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r,
+                        typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
+         _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    if (__cntrl_)
+        __cntrl_->__add_weak();
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    __r.__ptr_ = 0;
+    __r.__cntrl_ = 0;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r,
+                        typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type)
+         _NOEXCEPT
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_)
+{
+    __r.__ptr_ = 0;
+    __r.__cntrl_ = 0;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+weak_ptr<_Tp>::~weak_ptr()
+{
+    if (__cntrl_)
+        __cntrl_->__release_weak();
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp>&
+weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT
+{
+    weak_ptr(__r).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    weak_ptr<_Tp>&
+>::type
+weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT
+{
+    weak_ptr(__r).swap(*this);
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+weak_ptr<_Tp>&
+weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT
+{
+    weak_ptr(_VSTD::move(__r)).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    weak_ptr<_Tp>&
+>::type
+weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT
+{
+    weak_ptr(_VSTD::move(__r)).swap(*this);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _Tp>
+template<class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    is_convertible<_Yp*, _Tp*>::value,
+    weak_ptr<_Tp>&
+>::type
+weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT
+{
+    weak_ptr(__r).swap(*this);
+    return *this;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT
+{
+    _VSTD::swap(__ptr_, __r.__ptr_);
+    _VSTD::swap(__cntrl_, __r.__cntrl_);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT
+{
+    __x.swap(__y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+weak_ptr<_Tp>::reset() _NOEXCEPT
+{
+    weak_ptr().swap(*this);
+}
+
+template<class _Tp>
+template<class _Yp>
+shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
+                            typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat>::type)
+    : __ptr_(__r.__ptr_),
+      __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
+{
+    if (__cntrl_ == 0)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw bad_weak_ptr();
+#else
+        assert(!"bad_weak_ptr");
+#endif
+}
+
+template<class _Tp>
+shared_ptr<_Tp>
+weak_ptr<_Tp>::lock() const _NOEXCEPT
+{
+    shared_ptr<_Tp> __r;
+    __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_;
+    if (__r.__cntrl_)
+        __r.__ptr_ = __ptr_;
+    return __r;
+}
+
+template <class _Tp> struct owner_less;
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> >
+    : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool>
+{
+    typedef bool result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const
+        {return __x.owner_before(__y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const
+        {return __x.owner_before(__y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const
+        {return __x.owner_before(__y);}
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> >
+    : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool>
+{
+    typedef bool result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(  weak_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const
+        {return __x.owner_before(__y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(shared_ptr<_Tp> const& __x,   weak_ptr<_Tp> const& __y) const
+        {return __x.owner_before(__y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(  weak_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const
+        {return __x.owner_before(__y);}
+};
+
+template<class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this
+{
+    mutable weak_ptr<_Tp> __weak_this_;
+protected:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+    enable_shared_from_this() _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY
+    enable_shared_from_this(enable_shared_from_this const&) _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY
+    enable_shared_from_this& operator=(enable_shared_from_this const&) _NOEXCEPT
+        {return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    ~enable_shared_from_this() {}
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    shared_ptr<_Tp> shared_from_this()
+        {return shared_ptr<_Tp>(__weak_this_);}
+    _LIBCPP_INLINE_VISIBILITY
+    shared_ptr<_Tp const> shared_from_this() const
+        {return shared_ptr<const _Tp>(__weak_this_);}
+
+    template <class _Up> friend class shared_ptr;
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY hash<shared_ptr<_Tp> >
+{
+    typedef shared_ptr<_Tp>      argument_type;
+    typedef size_t               result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator()(const argument_type& __ptr) const _NOEXCEPT
+    {
+        return hash<_Tp*>()(__ptr.get());
+    }
+};
+
+template<class _CharT, class _Traits, class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p);
+
+#if __has_feature(cxx_atomic)
+
+class _LIBCPP_TYPE_VIS __sp_mut
+{
+    void* __lx;
+public:
+    void lock() _NOEXCEPT;
+    void unlock() _NOEXCEPT;
+
+private:
+    _LIBCPP_CONSTEXPR __sp_mut(void*) _NOEXCEPT;
+    __sp_mut(const __sp_mut&);
+    __sp_mut& operator=(const __sp_mut&);
+
+    friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*);
+};
+
+_LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*);
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_is_lock_free(const shared_ptr<_Tp>*)
+{
+    return false;
+}
+
+template <class _Tp>
+shared_ptr<_Tp>
+atomic_load(const shared_ptr<_Tp>* __p)
+{
+    __sp_mut& __m = __get_sp_mut(__p);
+    __m.lock();
+    shared_ptr<_Tp> __q = *__p;
+    __m.unlock();
+    return __q;
+}
+  
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order)
+{
+    return atomic_load(__p);
+}
+
+template <class _Tp>
+void
+atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
+{
+    __sp_mut& __m = __get_sp_mut(__p);
+    __m.lock();
+    __p->swap(__r);
+    __m.unlock();
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
+{
+    atomic_store(__p, __r);
+}
+
+template <class _Tp>
+shared_ptr<_Tp>
+atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
+{
+    __sp_mut& __m = __get_sp_mut(__p);
+    __m.lock();
+    __p->swap(__r);
+    __m.unlock();
+    return __r;
+}
+  
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+shared_ptr<_Tp>
+atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order)
+{
+    return atomic_exchange(__p, __r);
+}
+
+template <class _Tp>
+bool
+atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
+{
+    __sp_mut& __m = __get_sp_mut(__p);
+    __m.lock();
+    if (__p->__owner_equivalent(*__v))
+    {
+        *__p = __w;
+        __m.unlock();
+        return true;
+    }
+    *__v = *__p;
+    __m.unlock();
+    return false;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w)
+{
+    return atomic_compare_exchange_strong(__p, __v, __w);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_strong_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
+                                        shared_ptr<_Tp> __w, memory_order, memory_order)
+{
+    return atomic_compare_exchange_strong(__p, __v, __w);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v,
+                                      shared_ptr<_Tp> __w, memory_order, memory_order)
+{
+    return atomic_compare_exchange_weak(__p, __v, __w);
+}
+
+#endif  // __has_feature(cxx_atomic)
+
+//enum class
+struct _LIBCPP_TYPE_VIS pointer_safety
+{
+    enum __lx
+    {
+        relaxed,
+        preferred,
+        strict
+    };
+
+    __lx __v_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    pointer_safety(__lx __v) : __v_(__v) {}
+    _LIBCPP_INLINE_VISIBILITY
+    operator int() const {return __v_;}
+};
+
+_LIBCPP_FUNC_VIS void declare_reachable(void* __p);
+_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n);
+_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n);
+_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
+_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p);
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+undeclare_reachable(_Tp* __p)
+{
+    return static_cast<_Tp*>(__undeclare_reachable(__p));
+}
+
+_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_MEMORY
diff --git a/final/include/module.modulemap b/final/include/module.modulemap
new file mode 100644
index 0000000..a0f4254
--- /dev/null
+++ b/final/include/module.modulemap
@@ -0,0 +1,471 @@
+module std [system] {
+  // FIXME: The standard does not require that each of these submodules
+  // re-exports its imported modules. We should provide an alternative form of
+  // export that issues a warning if a name from the submodule is used, and
+  // use that to provide a 'strict mode' for libc++.
+  module algorithm {
+    header "algorithm"
+    export initializer_list
+    export *
+  }
+  module array {
+    header "array"
+    export initializer_list
+    export *
+  }
+  module atomic {
+    header "atomic"
+    export *
+  }
+  module bitset {
+    header "bitset"
+    export string
+    export iosfwd
+    export *
+  }
+  // No submodule for cassert. It fundamentally needs repeated, textual inclusion.
+  module ccomplex {
+    header "ccomplex"
+    export complex
+    export *
+  }
+  module cctype {
+    header "cctype"
+    export *
+  }
+  module cerrno {
+    header "cerrno"
+/*
+    export_macros    ECONNREFUSED, EIO,          ENODEV,      ENOTEMPTY,       ERANGE,
+      E2BIG,         ECONNRESET,   EISCONN,      ENOENT,      ENOTRECOVERABLE, EROFS,
+      EACCES,        EDEADLK,      EISDIR,       ENOEXEC,     ENOTSOCK,        ESPIPE,
+      EADDRINUSE,    EDESTADDRREQ, ELOOP,        ENOLCK,      ENOTSUP,         ESRCH,
+      EADDRNOTAVAIL, EDOM,         EMFILE,       ENOLINK,     ENOTTY,          ETIME,
+      EAFNOSUPPORT,  EEXIST,       EMLINK,       ENOMEM,      ENXIO,           ETIMEDOUT,
+      EAGAIN,        EFAULT,       EMSGSIZE,     ENOMSG,      EOPNOTSUPP,      ETXTBSY,
+      EALREADY,      EFBIG,        ENAMETOOLONG, ENOPROTOOPT, EOVERFLOW,       EWOULDBLOCK,
+      EBADF,         EHOSTUNREACH, ENETDOWN,     ENOSPC,      EOWNERDEAD,      EXDEV,
+      EBADMSG,       EIDRM,        ENETRESET,    ENOSR,       EPERM,           errno,
+      EBUSY,         EILSEQ,       ENETUNREACH,  ENOSTR,      EPIPE,
+      ECANCELED,     EINPROGRESS,  ENFILE,       ENOSYS,      EPROTO,
+      ECHILD,        EINTR,        ENOBUFS,      ENOTCONN,    EPROTONOSUPPORT,
+      ECONNABORTED,  EINVAL,       ENODATA,      ENOTDIR,     EPROTOTYPE
+*/
+    export *
+  }
+  module cfenv {
+    header "cfenv"
+/*
+    export_macros FE_ALL_EXCEPT, FE_DIVBYZERO, FE_INEXACT, FE_INVALID, FE_OVERFLOW,
+                  FE_UNDERFLOW, FE_DOWNWARD, FE_TONEAREST, FE_TOWARDZERO, FE_UPWARD,
+                  FE_DFL_ENV
+*/
+    export *
+  }
+  module cfloat {
+    header "cfloat"
+/*
+    export_macros FLT_EVAL_METHOD, FLT_RADIX, FLT_ROUNDS,
+                  FLT_DIG, FLT_EPSILON, FLT_MANT_DIG,
+                  FLT_MAX, FLT_MAX_10_EXP, FLT_MAX_EXP,
+                  FLT_MIN, FLT_MIN_10_EXP, FLT_MIN_EXP,
+                  DBL_DIG, DBL_EPSILON, DBL_MANT_DIG,
+                  DBL_MAX, DBL_MAX_10_EXP, DBL_MAX_EXP,
+                  DBL_MIN, DBL_MIN_10_EXP, DBL_MIN_EXP,
+                  LDBL_DIG, LDBL_EPSILON, LDBL_MANT_DIG,
+                  LDBL_MAX, LDBL_MAX_10_EXP, LDBL_MAX_EXP,
+                  LDBL_MIN, LDBL_MIN_10_EXP, LDBL_MIN_EXP
+*/
+    export *
+  }
+  module chrono {
+    header "chrono"
+    export *
+  }
+  module cinttypes {
+    header "cinttypes"
+    export cstdint
+/*
+    export_macros
+      PRId8, PRId16, PRId32, PRId64, PRIdFAST8, PRIdFAST16, PRIdFAST32, PRIdFAST64, PRIdLEAST8, PRIdLEAST16, PRIdLEAST32, PRIdLEAST64, PRIdMAX, PRIdPTR,
+      PRIi8, PRIi16, PRIi32, PRIi64, PRIiFAST8, PRIiFAST16, PRIiFAST32, PRIiFAST64, PRIiLEAST8, PRIiLEAST16, PRIiLEAST32, PRIiLEAST64, PRIiMAX, PRIiPTR,
+      PRIo8, PRIo16, PRIo32, PRIo64, PRIoFAST8, PRIoFAST16, PRIoFAST32, PRIoFAST64, PRIoLEAST8, PRIoLEAST16, PRIoLEAST32, PRIoLEAST64, PRIoMAX, PRIoPTR,
+      PRIu8, PRIu16, PRIu32, PRIu64, PRIuFAST8, PRIuFAST16, PRIuFAST32, PRIuFAST64, PRIuLEAST8, PRIuLEAST16, PRIuLEAST32, PRIuLEAST64, PRIuMAX, PRIuPTR,
+      PRIx8, PRIx16, PRIx32, PRIx64, PRIxFAST8, PRIxFAST16, PRIxFAST32, PRIxFAST64, PRIxLEAST8, PRIxLEAST16, PRIxLEAST32, PRIxLEAST64, PRIxMAX, PRIxPTR,
+      PRIX8, PRIX16, PRIX32, PRIX64, PRIXFAST8, PRIXFAST16, PRIXFAST32, PRIXFAST64, PRIXLEAST8, PRIXLEAST16, PRIXLEAST32, PRIXLEAST64, PRIXMAX, PRIXPTR,
+      SCNd8, SCNd16, SCNd32, SCNd64, SCNdFAST8, SCNdFAST16, SCNdFAST32, SCNdFAST64, SCNdLEAST8, SCNdLEAST16, SCNdLEAST32, SCNdLEAST64, SCNdMAX, SCNdPTR,
+      SCNi8, SCNi16, SCNi32, SCNi64, SCNiFAST8, SCNiFAST16, SCNiFAST32, SCNiFAST64, SCNiLEAST8, SCNiLEAST16, SCNiLEAST32, SCNiLEAST64, SCNiMAX, SCNiPTR,
+      SCNo8, SCNo16, SCNo32, SCNo64, SCNoFAST8, SCNoFAST16, SCNoFAST32, SCNoFAST64, SCNoLEAST8, SCNoLEAST16, SCNoLEAST32, SCNoLEAST64, SCNoMAX, SCNoPTR,
+      SCNu8, SCNu16, SCNu32, SCNu64, SCNuFAST8, SCNuFAST16, SCNuFAST32, SCNuFAST64, SCNuLEAST8, SCNuLEAST16, SCNuLEAST32, SCNuLEAST64, SCNuMAX, SCNuPTR,
+      SCNx8, SCNx16, SCNx32, SCNx64, SCNxFAST8, SCNxFAST16, SCNxFAST32, SCNxFAST64, SCNxLEAST8, SCNxLEAST16, SCNxLEAST32, SCNxLEAST64, SCNxMAX, SCNxPTR,
+      SCNX8, SCNX16, SCNX32, SCNX64, SCNXFAST8, SCNXFAST16, SCNXFAST32, SCNXFAST64, SCNXLEAST8, SCNXLEAST16, SCNXLEAST32, SCNXLEAST64, SCNXMAX, SCNXPTR
+*/
+    export *
+  }
+  module ciso646 {
+    header "ciso646"
+    export *
+  }
+  module climits {
+    header "climits"
+/*
+    export_macros CHAR_BIT,  CHAR_MIN,  CHAR_MAX,
+                  SCHAR_MIN, SCHAR_MAX, UCHAR_MAX,
+                  SHRT_MIN,  SHRT_MAX,  USHRT_MAX,
+                  INT_MIN,   INT_MAX,   UINT_MAX,
+                  LONG_MIN,  LONG_MAX,  ULONG_MAX,
+                  LLONG_MIN, LLONG_MAX, ULLONG_MAX,
+                  MB_LEN_MAX
+*/
+    export *
+  }
+  module clocale {
+    header "clocale"
+/*
+    export_macros LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, NULL
+*/
+    export *
+  }
+  module cmath {
+    header "cmath"
+/*
+    export_macros FP_FAST_FMA, FP_FAST_FMAF, FP_FAST_FMAL, FP_ILOGBO, FP_ILOGBNAN,
+                  FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL, FP_ZERO,
+                  HUGE_VAL, HUGE_VALF, HUGE_VALL, INFINITY, NAN,
+                  MATH_ERRNO, MATH_ERREXCEPT, math_errhandling
+*/
+    export *
+  }
+  module codecvt {
+    header "codecvt"
+    export *
+  }
+  module complex {
+    header "complex"
+    export *
+  }
+  module condition_variable {
+    header "condition_variable"
+    export *
+  }
+  module csetjmp {
+    header "csetjmp"
+/*
+    export_macros setjmp
+*/
+    export *
+  }
+  module csignal {
+    header "csignal"
+/*
+    export_macros SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM,
+                  SIG_DFL, SIG_IGN, SIG_ERR
+*/
+    export *
+  }
+  module cstdarg {
+    header "cstdarg"
+/*
+    export_macros va_arg, va_start, va_end, va_copy
+*/
+    export *
+  }
+  module cstdbool {
+    header "cstdbool"
+/*
+    export_macros __bool_true_false_are_defined
+*/
+    export *
+  }
+  module cstddef {
+    header "cstddef"
+/*
+    export_macros NULL, offsetof
+*/
+    export *
+  }
+  module cstdint {
+    header "cstdint"
+/*
+    export_macros
+      INT_8_MIN, INT_8_MAX, UINT_8_MAX, INT_16_MIN, INT_16_MAX, UINT_16_MAX,
+      INT_32_MIN, INT_32_MAX, UINT_32_MAX, INT_64_MIN, INT_64_MAX, UINT_64_MAX,
+      INT_FAST8_MIN, INT_FAST8_MAX, UINT_FAST8_MAX, INT_FAST16_MIN, INT_FAST16_MAX, UINT_FAST16_MAX,
+      INT_FAST32_MIN, INT_FAST32_MAX, UINT_FAST32_MAX, INT_FAST64_MIN, INT_FAST64_MAX, UINT_FAST64_MAX,
+      INT_LEAST8_MIN, INT_LEAST8_MAX, UINT_LEAST8_MAX, INT_LEAST16_MIN, INT_LEAST16_MAX, UINT_LEAST16_MAX,
+      INT_LEAST32_MIN, INT_LEAST32_MAX, UINT_LEAST32_MAX, INT_LEAST64_MIN, INT_LEAST64_MAX, UINT_LEAST64_MAX,
+      INT_MAX_MIN, INT_MAX_MAX, UINT_MAX_MAX, INT_PTR_MIN, INT_PTR_MAX, UINT_PTR_MAX,
+      PTRDIFF_MIN, PTRDIFF_MAX, SIG_ATOMIC_MIN, SIG_ATOMIC_MAX, WCHAR_MIN, WCHAR_MAX, WINT_MIN, WINT_MAX,
+      SIZE_MAX
+*/
+    export *
+  }
+  module cstdio {
+    header "cstdio"
+/*
+    export_macros BUFSIZ, EOF, FILENAME_MAX, FOPEN_MAX, L_tmpnam, NULL,
+                  SEEK_CUR, SEEK_END, SEEK_SET, TMP_MAX, _IOFBF, _IOLBF,
+                  stdin, stdout, stderr
+*/
+    export *
+  }
+  module cstdlib {
+    header "cstdlib"
+/*
+    export_macros RAND_MAX
+*/
+    export *
+  }
+  module cstring {
+    header "cstring"
+/*
+    export_macros NULL
+*/
+    export *
+  }
+  module ctgmath {
+    header "ctgmath"
+    export ccomplex
+    export cmath
+    export *
+  }
+  module ctime {
+    header "ctime"
+/*
+    export_macros NULL, CLOCKS_PER_SEC
+*/
+    export *
+  }
+  module cwchar {
+    header "cwchar"
+/*
+    export_macros NULL, WCHAR_MAX, WCHAR_MIN, WEOF
+*/
+    export *
+  }
+  module cwctype {
+    header "cwctype"
+/*
+    export_macros WEOF
+*/
+    export *
+  }
+  module deque {
+    header "deque"
+    export initializer_list
+    export *
+  }
+  module exception {
+    header "exception"
+    export *
+  }
+  module forward_list {
+    header "forward_list"
+    export initializer_list
+    export *
+  }
+  module fstream {
+    header "fstream"
+    export *
+  }
+  module functional {
+    header "functional"
+    export *
+  }
+  module future {
+    header "future"
+    export *
+  }
+  module initializer_list {
+    header "initializer_list"
+    export *
+  }
+  module iomanip {
+    header "iomanip"
+    export *
+  }
+  module ios {
+    header "ios"
+    export iosfwd
+    export *
+  }
+  module iosfwd {
+    header "iosfwd"
+    export *
+  }
+  module iostream {
+    header "iostream"
+    export ios
+    export streambuf
+    export istream
+    export ostream
+    export *
+  }
+  module istream {
+    header "istream"
+    // FIXME: should re-export ios, streambuf?
+    export *
+  }
+  module iterator {
+    header "iterator"
+    export *
+  }
+  module limits {
+    header "limits"
+    export *
+  }
+  module list {
+    header "list"
+    export initializer_list
+    export *
+  }
+  module locale {
+    header "locale"
+    export *
+  }
+  module map {
+    header "map"
+    export initializer_list
+    export *
+  }
+  module memory {
+    header "memory"
+    export *
+  }
+  module mutex {
+    header "mutex"
+    export *
+  }
+  module new {
+    header "new"
+    export *
+  }
+  module numeric {
+    header "numeric"
+    export *
+  }
+  module ostream {
+    header "ostream"
+    // FIXME: should re-export ios, streambuf?
+    export *
+  }
+  module queue {
+    header "queue"
+    export initializer_list
+    export *
+  }
+  module random {
+    header "random"
+    export initializer_list
+    export *
+  }
+  module ratio {
+    header "ratio"
+    export *
+  }
+  module regex {
+    header "regex"
+    export initializer_list
+    export *
+  }
+  module scoped_allocator {
+    header "scoped_allocator"
+    export *
+  }
+  module set {
+    header "set"
+    export initializer_list
+    export *
+  }
+  module sstream {
+    header "sstream"
+    // FIXME: should re-export istream, ostream, ios, streambuf, string?
+    export *
+  }
+  module stack {
+    header "stack"
+    export initializer_list
+    export *
+  }
+  module stdexcept {
+    header "stdexcept"
+    export *
+  }
+  module streambuf {
+    header "streambuf"
+    export *
+  }
+  module string {
+    header "string"
+    export initializer_list
+    export *
+  }
+  module strstream {
+    header "strstream"
+    requires !cplusplus11
+  }
+  module system_error {
+    header "system_error"
+    export *
+  }
+  module thread {
+    header "thread"
+    export *
+  }
+  module tuple {
+    header "tuple"
+    export *
+  }
+  module type_traits {
+    header "type_traits"
+    export *
+  }
+  module typeindex {
+    header "typeindex"
+    export *
+  }
+  module typeinfo {
+    header "typeinfo"
+    export *
+  }
+  module unordered_map {
+    header "unordered_map"
+    export initializer_list
+    export *
+  }
+  module unordered_set {
+    header "unordered_set"
+    export initializer_list
+    export *
+  }
+  module utility {
+    header "utility"
+    export initializer_list
+    export *
+  }
+  module valarray {
+    header "valarray"
+    export initializer_list
+    export *
+  }
+  module vector {
+    header "vector"
+    export initializer_list
+    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 * }
+  module __locale { header "__locale" export * }
+  module __mutex_base { header "__mutex_base" export * }
+  module __split_buffer { header "__split_buffer" export * }
+  module __sso_allocator { header "__sso_allocator" export * }
+  module __std_stream { header "__std_stream" export * }
+  module __tree { header "__tree" export * }
+  module __tuple { header "__tuple" export * }
+  module __undef_min_max { header "__undef_min_max" export * }
+}
diff --git a/final/include/mutex b/final/include/mutex
new file mode 100644
index 0000000..e0c02ad
--- /dev/null
+++ b/final/include/mutex
@@ -0,0 +1,566 @@
+// -*- C++ -*-
+//===--------------------------- mutex ------------------------------------===//
+//
+//                     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_MUTEX
+#define _LIBCPP_MUTEX
+
+/*
+    mutex synopsis
+
+namespace std
+{
+
+class mutex
+{
+public:
+     constexpr mutex() noexcept;
+     ~mutex();
+
+    mutex(const mutex&) = delete;
+    mutex& operator=(const mutex&) = delete;
+
+    void lock();
+    bool try_lock();
+    void unlock();
+
+    typedef pthread_mutex_t* native_handle_type;
+    native_handle_type native_handle();
+};
+
+class recursive_mutex
+{
+public:
+     recursive_mutex();
+     ~recursive_mutex();
+
+    recursive_mutex(const recursive_mutex&) = delete;
+    recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+    void lock();
+    bool try_lock() noexcept;
+    void unlock();
+
+    typedef pthread_mutex_t* native_handle_type;
+    native_handle_type native_handle();
+};
+
+class timed_mutex
+{
+public:
+     timed_mutex();
+     ~timed_mutex();
+
+    timed_mutex(const timed_mutex&) = delete;
+    timed_mutex& operator=(const timed_mutex&) = delete;
+
+    void lock();
+    bool try_lock();
+    template <class Rep, class Period>
+        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+    template <class Clock, class Duration>
+        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+    void unlock();
+};
+
+class recursive_timed_mutex
+{
+public:
+     recursive_timed_mutex();
+     ~recursive_timed_mutex();
+
+    recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+    recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+    void lock();
+    bool try_lock() noexcept;
+    template <class Rep, class Period>
+        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+    template <class Clock, class Duration>
+        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+    void unlock();
+};
+
+struct defer_lock_t {};
+struct try_to_lock_t {};
+struct adopt_lock_t {};
+
+constexpr defer_lock_t  defer_lock{};
+constexpr try_to_lock_t try_to_lock{};
+constexpr adopt_lock_t  adopt_lock{};
+
+template <class Mutex>
+class lock_guard
+{
+public:
+    typedef Mutex mutex_type;
+
+    explicit lock_guard(mutex_type& m);
+    lock_guard(mutex_type& m, adopt_lock_t);
+    ~lock_guard();
+
+    lock_guard(lock_guard const&) = delete;
+    lock_guard& operator=(lock_guard const&) = delete;
+};
+
+template <class Mutex>
+class unique_lock
+{
+public:
+    typedef Mutex mutex_type;
+    unique_lock() noexcept;
+    explicit unique_lock(mutex_type& m);
+    unique_lock(mutex_type& m, defer_lock_t) noexcept;
+    unique_lock(mutex_type& m, try_to_lock_t);
+    unique_lock(mutex_type& m, adopt_lock_t);
+    template <class Clock, class Duration>
+        unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+    template <class Rep, class Period>
+        unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+    ~unique_lock();
+
+    unique_lock(unique_lock const&) = delete;
+    unique_lock& operator=(unique_lock const&) = delete;
+
+    unique_lock(unique_lock&& u) noexcept;
+    unique_lock& operator=(unique_lock&& u) noexcept;
+
+    void lock();
+    bool try_lock();
+
+    template <class Rep, class Period>
+        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+    template <class Clock, class Duration>
+        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+    void unlock();
+
+    void swap(unique_lock& u) noexcept;
+    mutex_type* release() noexcept;
+
+    bool owns_lock() const noexcept;
+    explicit operator bool () const noexcept;
+    mutex_type* mutex() const noexcept;
+};
+
+template <class Mutex>
+  void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y) noexcept;
+
+template <class L1, class L2, class... L3>
+  int try_lock(L1&, L2&, L3&...);
+template <class L1, class L2, class... L3>
+  void lock(L1&, L2&, L3&...);
+
+struct once_flag
+{
+    constexpr once_flag() noexcept;
+
+    once_flag(const once_flag&) = delete;
+    once_flag& operator=(const once_flag&) = delete;
+};
+
+template<class Callable, class ...Args>
+  void call_once(once_flag& flag, Callable&& func, Args&&... args);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__mutex_base>
+#include <functional>
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+#include <tuple>
+#endif
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS recursive_mutex
+{
+    pthread_mutex_t __m_;
+
+public:
+     recursive_mutex();
+     ~recursive_mutex();
+
+private:
+    recursive_mutex(const recursive_mutex&); // = delete;
+    recursive_mutex& operator=(const recursive_mutex&); // = delete;
+
+public:
+    void lock();
+    bool try_lock() _NOEXCEPT;
+    void unlock()  _NOEXCEPT;
+
+    typedef pthread_mutex_t* native_handle_type;
+    _LIBCPP_INLINE_VISIBILITY
+    native_handle_type native_handle() {return &__m_;}
+};
+
+class _LIBCPP_TYPE_VIS timed_mutex
+{
+    mutex              __m_;
+    condition_variable __cv_;
+    bool               __locked_;
+public:
+     timed_mutex();
+     ~timed_mutex();
+
+private:
+    timed_mutex(const timed_mutex&); // = delete;
+    timed_mutex& operator=(const timed_mutex&); // = delete;
+
+public:
+    void lock();
+    bool try_lock() _NOEXCEPT;
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+            {return try_lock_until(chrono::steady_clock::now() + __d);}
+    template <class _Clock, class _Duration>
+        bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
+    void unlock() _NOEXCEPT;
+};
+
+template <class _Clock, class _Duration>
+bool
+timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+    using namespace chrono;
+    unique_lock<mutex> __lk(__m_);
+    bool no_timeout = _Clock::now() < __t;
+    while (no_timeout && __locked_)
+        no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
+    if (!__locked_)
+    {
+        __locked_ = true;
+        return true;
+    }
+    return false;
+}
+
+class _LIBCPP_TYPE_VIS recursive_timed_mutex
+{
+    mutex              __m_;
+    condition_variable __cv_;
+    size_t             __count_;
+    pthread_t          __id_;
+public:
+     recursive_timed_mutex();
+     ~recursive_timed_mutex();
+
+private:
+    recursive_timed_mutex(const recursive_timed_mutex&); // = delete;
+    recursive_timed_mutex& operator=(const recursive_timed_mutex&); // = delete;
+
+public:
+    void lock();
+    bool try_lock() _NOEXCEPT;
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+            {return try_lock_until(chrono::steady_clock::now() + __d);}
+    template <class _Clock, class _Duration>
+        bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
+    void unlock() _NOEXCEPT;
+};
+
+template <class _Clock, class _Duration>
+bool
+recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+    using namespace chrono;
+    pthread_t __id = pthread_self();
+    unique_lock<mutex> lk(__m_);
+    if (pthread_equal(__id, __id_))
+    {
+        if (__count_ == numeric_limits<size_t>::max())
+            return false;
+        ++__count_;
+        return true;
+    }
+    bool no_timeout = _Clock::now() < __t;
+    while (no_timeout && __count_ != 0)
+        no_timeout = __cv_.wait_until(lk, __t) == cv_status::no_timeout;
+    if (__count_ == 0)
+    {
+        __count_ = 1;
+        __id_ = __id;
+        return true;
+    }
+    return false;
+}
+
+template <class _L0, class _L1>
+int
+try_lock(_L0& __l0, _L1& __l1)
+{
+    unique_lock<_L0> __u0(__l0, try_to_lock);
+    if (__u0.owns_lock())
+    {
+        if (__l1.try_lock())
+        {
+            __u0.release();
+            return -1;
+        }
+        else
+            return 1;
+    }
+    return 0;
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _L0, class _L1, class _L2, class... _L3>
+int
+try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
+{
+    int __r = 0;
+    unique_lock<_L0> __u0(__l0, try_to_lock);
+    if (__u0.owns_lock())
+    {
+        __r = try_lock(__l1, __l2, __l3...);
+        if (__r == -1)
+            __u0.release();
+        else
+            ++__r;
+    }
+    return __r;
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _L0, class _L1>
+void
+lock(_L0& __l0, _L1& __l1)
+{
+    while (true)
+    {
+        {
+            unique_lock<_L0> __u0(__l0);
+            if (__l1.try_lock())
+            {
+                __u0.release();
+                break;
+            }
+        }
+        sched_yield();
+        {
+            unique_lock<_L1> __u1(__l1);
+            if (__l0.try_lock())
+            {
+                __u1.release();
+                break;
+            }
+        }
+        sched_yield();
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _L0, class _L1, class _L2, class ..._L3>
+void
+__lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
+{
+    while (true)
+    {
+        switch (__i)
+        {
+        case 0:
+            {
+                unique_lock<_L0> __u0(__l0);
+                __i = try_lock(__l1, __l2, __l3...);
+                if (__i == -1)
+                {
+                    __u0.release();
+                    return;
+                }
+            }
+            ++__i;
+            sched_yield();
+            break;
+        case 1:
+            {
+                unique_lock<_L1> __u1(__l1);
+                __i = try_lock(__l2, __l3..., __l0);
+                if (__i == -1)
+                {
+                    __u1.release();
+                    return;
+                }
+            }
+            if (__i == sizeof...(_L3) + 1)
+                __i = 0;
+            else
+                __i += 2;
+            sched_yield();
+            break;
+        default:
+            __lock_first(__i - 2, __l2, __l3..., __l0, __l1);
+            return;
+        }
+    }
+}
+
+template <class _L0, class _L1, class _L2, class ..._L3>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3& ...__l3)
+{
+    __lock_first(0, __l0, __l1, __l2, __l3...);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+struct _LIBCPP_TYPE_VIS once_flag;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Callable, class... _Args>
+_LIBCPP_INLINE_VISIBILITY
+void call_once(once_flag&, _Callable&&, _Args&&...);
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Callable>
+_LIBCPP_INLINE_VISIBILITY
+void call_once(once_flag&, _Callable);
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+struct _LIBCPP_TYPE_VIS_ONLY once_flag
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR
+        once_flag() _NOEXCEPT : __state_(0) {}
+
+private:
+    once_flag(const once_flag&); // = delete;
+    once_flag& operator=(const once_flag&); // = delete;
+
+    unsigned long __state_;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template<class _Callable, class... _Args>
+    friend
+    void call_once(once_flag&, _Callable&&, _Args&&...);
+#else  // _LIBCPP_HAS_NO_VARIADICS
+    template<class _Callable>
+    friend
+    void call_once(once_flag&, _Callable);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Fp>
+class __call_once_param
+{
+    _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
+
+    _LIBCPP_INLINE_VISIBILITY
+    void operator()()
+    {
+        typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index;
+        __execute(_Index());
+    }
+
+private:
+    template <size_t ..._Indices>
+    _LIBCPP_INLINE_VISIBILITY
+    void __execute(__tuple_indices<_Indices...>)
+    {
+        __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...);
+    }
+};
+
+#else
+
+template <class _Fp>
+class __call_once_param
+{
+    _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
+
+    _LIBCPP_INLINE_VISIBILITY
+    void operator()()
+    {
+        __f_();
+    }
+};
+
+#endif
+
+template <class _Fp>
+void
+__call_once_proxy(void* __vp)
+{
+    __call_once_param<_Fp>* __p = static_cast<__call_once_param<_Fp>*>(__vp);
+    (*__p)();
+}
+
+_LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*));
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Callable, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
+{
+    if (__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))...));
+        __call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
+    }
+}
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template<class _Callable>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+call_once(once_flag& __flag, _Callable __func)
+{
+    if (__flag.__state_ != ~0ul)
+    {
+        __call_once_param<_Callable> __p(__func);
+        __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_MUTEX
diff --git a/final/include/new b/final/include/new
new file mode 100644
index 0000000..a710ed9
--- /dev/null
+++ b/final/include/new
@@ -0,0 +1,170 @@
+// -*- C++ -*-
+//===----------------------------- new ------------------------------------===//
+//
+//                     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_NEW
+#define _LIBCPP_NEW
+
+/*
+    new synopsis
+
+namespace std
+{
+
+class bad_alloc
+    : public exception
+{
+public:
+    bad_alloc() noexcept;
+    bad_alloc(const bad_alloc&) noexcept;
+    bad_alloc& operator=(const bad_alloc&) noexcept;
+    virtual const char* what() const noexcept;
+};
+
+class bad_array_length : public bad_alloc // C++14
+{
+public:
+    bad_array_length() noexcept;
+};
+
+class bad_array_new_length : public bad_alloc
+{
+public:
+    bad_array_new_length() noexcept;
+};
+
+struct nothrow_t {};
+extern const nothrow_t nothrow;
+typedef void (*new_handler)();
+new_handler set_new_handler(new_handler new_p) noexcept;
+new_handler get_new_handler() noexcept;
+
+}  // std
+
+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, 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, const std::nothrow_t&) noexcept;     // replaceable
+
+void* operator new  (std::size_t size, void* ptr) noexcept;
+void* operator new[](std::size_t size, void* ptr) noexcept;
+void  operator delete  (void* ptr, void*) noexcept;
+void  operator delete[](void* ptr, void*) noexcept;
+
+*/
+
+#include <__config>
+#include <exception>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+namespace std  // purposefully not using versioning namespace
+{
+
+class _LIBCPP_EXCEPTION_ABI bad_alloc
+    : public exception
+{
+public:
+    bad_alloc() _NOEXCEPT;
+    virtual ~bad_alloc() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_array_new_length
+    : public bad_alloc
+{
+public:
+    bad_array_new_length() _NOEXCEPT;
+    virtual ~bad_array_new_length() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+#if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
+
+class _LIBCPP_EXCEPTION_ABI bad_array_length
+    : public bad_alloc
+{
+public:
+    bad_array_length() _NOEXCEPT;
+    virtual ~bad_array_length() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+#define _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
+
+#endif  // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
+
+_LIBCPP_FUNC_VIS void __throw_bad_alloc();  // not in C++ spec
+
+struct _LIBCPP_TYPE_VIS nothrow_t {};
+extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
+typedef void (*new_handler)();
+_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
+_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
+
+}  // std
+
+#if defined(_WIN32) && !defined(cxx_EXPORTS)
+# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS_ONLY
+#else
+# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS
+#endif
+
+_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz)
+#if !__has_feature(cxx_noexcept)
+    throw(std::bad_alloc)
+#endif
+;
+_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;
+
+_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
+#if !__has_feature(cxx_noexcept)
+    throw(std::bad_alloc)
+#endif
+;
+_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;
+
+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;}
+inline _LIBCPP_INLINE_VISIBILITY void  operator delete  (void*, void*) _NOEXCEPT {}
+inline _LIBCPP_INLINE_VISIBILITY void  operator delete[](void*, void*) _NOEXCEPT {}
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) {
+#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
+  return ::operator new(__size);
+#else
+  return __builtin_operator_new(__size);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY void __deallocate(void *__ptr) {
+#ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
+  ::operator delete(__ptr);
+#else
+  __builtin_operator_delete(__ptr);
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_NEW
diff --git a/final/include/numeric b/final/include/numeric
new file mode 100644
index 0000000..e520c8e
--- /dev/null
+++ b/final/include/numeric
@@ -0,0 +1,197 @@
+// -*- C++ -*-
+//===---------------------------- numeric ---------------------------------===//
+//
+//                     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_NUMERIC
+#define _LIBCPP_NUMERIC
+
+/*
+    numeric synopsis
+
+namespace std
+{
+
+template <class InputIterator, class T>
+    T
+    accumulate(InputIterator first, InputIterator last, T init);
+
+template <class InputIterator, class T, class BinaryOperation>
+    T
+    accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
+
+template <class InputIterator1, class InputIterator2, class T>
+    T
+    inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
+
+template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
+    T
+    inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
+                  T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
+
+template <class InputIterator, class OutputIterator>
+    OutputIterator
+    partial_sum(InputIterator first, InputIterator last, OutputIterator result);
+
+template <class InputIterator, class OutputIterator, class BinaryOperation>
+    OutputIterator
+    partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
+
+template <class InputIterator, class OutputIterator>
+    OutputIterator
+    adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
+
+template <class InputIterator, class OutputIterator, class BinaryOperation>
+    OutputIterator
+    adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
+
+template <class ForwardIterator, class T>
+    void iota(ForwardIterator first, ForwardIterator last, T value);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <iterator>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _InputIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
+{
+    for (; __first != __last; ++__first)
+        __init = __init + *__first;
+    return __init;
+}
+
+template <class _InputIterator, class _Tp, class _BinaryOperation>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
+{
+    for (; __first != __last; ++__first)
+        __init = __binary_op(__init, *__first);
+    return __init;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
+{
+    for (; __first1 != __last1; ++__first1, ++__first2)
+        __init = __init + *__first1 * *__first2;
+    return __init;
+}
+
+template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
+              _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
+{
+    for (; __first1 != __last1; ++__first1, ++__first2)
+        __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
+    return __init;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    if (__first != __last)
+    {
+        typename iterator_traits<_InputIterator>::value_type __t(*__first);
+        *__result = __t;
+        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        {
+            __t = __t + *__first;
+            *__result = __t;
+        }
+    }
+    return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+              _BinaryOperation __binary_op)
+{
+    if (__first != __last)
+    {
+        typename iterator_traits<_InputIterator>::value_type __t(*__first);
+        *__result = __t;
+        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        {
+            __t = __binary_op(__t, *__first);
+            *__result = __t;
+        }
+    }
+    return __result;
+}
+
+template <class _InputIterator, class _OutputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
+{
+    if (__first != __last)
+    {
+        typename iterator_traits<_InputIterator>::value_type __t1(*__first);
+        *__result = __t1;
+        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        {
+            typename iterator_traits<_InputIterator>::value_type __t2(*__first);
+            *__result = __t2 - __t1;
+            __t1 = _VSTD::move(__t2);
+        }
+    }
+    return __result;
+}
+
+template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
+                      _BinaryOperation __binary_op)
+{
+    if (__first != __last)
+    {
+        typename iterator_traits<_InputIterator>::value_type __t1(*__first);
+        *__result = __t1;
+        for (++__first, ++__result; __first != __last; ++__first, ++__result)
+        {
+            typename iterator_traits<_InputIterator>::value_type __t2(*__first);
+            *__result = __binary_op(__t2, __t1);
+            __t1 = _VSTD::move(__t2);
+        }
+    }
+    return __result;
+}
+
+template <class _ForwardIterator, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
+{
+    for (; __first != __last; ++__first, ++__value_)
+        *__first = __value_;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_NUMERIC
diff --git a/final/include/ostream b/final/include/ostream
new file mode 100644
index 0000000..9d96fd8
--- /dev/null
+++ b/final/include/ostream
@@ -0,0 +1,1101 @@
+// -*- C++ -*-
+//===-------------------------- ostream -----------------------------------===//
+//
+//                     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_OSTREAM
+#define _LIBCPP_OSTREAM
+
+/*
+    ostream synopsis
+
+template <class charT, class traits = char_traits<charT> >
+class basic_ostream
+    : virtual public basic_ios<charT,traits>
+{
+public:
+    // types (inherited from basic_ios (27.5.4)):
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // 27.7.2.2 Constructor/destructor:
+    explicit basic_ostream(basic_streambuf<char_type,traits>* sb);
+    basic_ostream(basic_ostream&& rhs);
+    virtual ~basic_ostream();
+
+    // 27.7.2.3 Assign/swap
+    basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14
+    basic_ostream& operator=(basic_ostream&& rhs);
+    void swap(basic_ostream& rhs);
+
+    // 27.7.2.4 Prefix/suffix:
+    class sentry;
+
+    // 27.7.2.6 Formatted output:
+    basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
+    basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT,traits>&));
+    basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
+    basic_ostream& operator<<(bool n);
+    basic_ostream& operator<<(short n);
+    basic_ostream& operator<<(unsigned short n);
+    basic_ostream& operator<<(int n);
+    basic_ostream& operator<<(unsigned int n);
+    basic_ostream& operator<<(long n);
+    basic_ostream& operator<<(unsigned long n);
+    basic_ostream& operator<<(long long n);
+    basic_ostream& operator<<(unsigned long long n);
+    basic_ostream& operator<<(float f);
+    basic_ostream& operator<<(double f);
+    basic_ostream& operator<<(long double f);
+    basic_ostream& operator<<(const void* p);
+    basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
+
+    // 27.7.2.7 Unformatted output:
+    basic_ostream& put(char_type c);
+    basic_ostream& write(const char_type* s, streamsize n);
+    basic_ostream& flush();
+
+    // 27.7.2.5 seeks:
+    pos_type tellp();
+    basic_ostream& seekp(pos_type);
+    basic_ostream& seekp(off_type, ios_base::seekdir);
+};
+
+// 27.7.2.6.4 character inserters
+
+template<class charT, class traits>
+  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT);
+
+template<class charT, class traits>
+  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char);
+
+template<class traits>
+  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char);
+
+// signed and unsigned
+
+template<class traits>
+  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char);
+
+template<class traits>
+  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char);
+
+// NTBS
+template<class charT, class traits>
+  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
+
+template<class charT, class traits>
+  basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*);
+
+template<class traits>
+  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*);
+
+// signed and unsigned
+template<class traits>
+basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*);
+
+template<class traits>
+  basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*);
+
+// swap:
+template <class charT, class traits>
+  void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y);
+
+template <class charT, class traits>
+  basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
+
+template <class charT, class traits>
+  basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
+
+template <class charT, class traits>
+  basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
+
+// rvalue stream insertion
+template <class charT, class traits, class T>
+  basic_ostream<charT, traits>&
+  operator<<(basic_ostream<charT, traits>&& os, const T& x);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <ios>
+#include <streambuf>
+#include <locale>
+#include <iterator>
+#include <bitset>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_ostream
+    : virtual public basic_ios<_CharT, _Traits>
+{
+public:
+    // types (inherited from basic_ios (27.5.4)):
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    // 27.7.2.2 Constructor/destructor:
+    explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb);
+    virtual ~basic_ostream();
+protected:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream(basic_ostream&& __rhs);
+#endif
+
+    // 27.7.2.3 Assign/swap
+#if _LIBCPP_STD_VER > 11
+    basic_ostream& operator=(const basic_ostream&) = delete;
+#endif
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream& operator=(basic_ostream&& __rhs);
+#endif
+    void swap(basic_ostream& __rhs);
+public:
+
+    // 27.7.2.4 Prefix/suffix:
+    class _LIBCPP_TYPE_VIS_ONLY sentry;
+
+    // 27.7.2.6 Formatted output:
+    basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&));
+    basic_ostream& operator<<(basic_ios<char_type, traits_type>&
+                              (*__pf)(basic_ios<char_type,traits_type>&));
+    basic_ostream& operator<<(ios_base& (*__pf)(ios_base&));
+    basic_ostream& operator<<(bool __n);
+    basic_ostream& operator<<(short __n);
+    basic_ostream& operator<<(unsigned short __n);
+    basic_ostream& operator<<(int __n);
+    basic_ostream& operator<<(unsigned int __n);
+    basic_ostream& operator<<(long __n);
+    basic_ostream& operator<<(unsigned long __n);
+    basic_ostream& operator<<(long long __n);
+    basic_ostream& operator<<(unsigned long long __n);
+    basic_ostream& operator<<(float __f);
+    basic_ostream& operator<<(double __f);
+    basic_ostream& operator<<(long double __f);
+    basic_ostream& operator<<(const void* __p);
+    basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
+
+    // 27.7.2.7 Unformatted output:
+    basic_ostream& put(char_type __c);
+    basic_ostream& write(const char_type* __s, streamsize __n);
+    basic_ostream& flush();
+
+    // 27.7.2.5 seeks:
+    pos_type tellp();
+    basic_ostream& seekp(pos_type __pos);
+    basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
+
+protected:
+    _LIBCPP_ALWAYS_INLINE
+    basic_ostream() {}  // extension, intentially does not initialize
+};
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_ostream<_CharT, _Traits>::sentry
+{
+    bool __ok_;
+    basic_ostream<_CharT, _Traits>& __os_;
+
+    sentry(const sentry&); // = delete;
+    sentry& operator=(const sentry&); // = delete;
+
+public:
+    explicit sentry(basic_ostream<_CharT, _Traits>& __os);
+    ~sentry();
+
+    _LIBCPP_ALWAYS_INLINE
+        _LIBCPP_EXPLICIT
+        operator bool() const {return __ok_;}
+};
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os)
+    : __ok_(false),
+      __os_(__os)
+{
+    if (__os.good())
+    {
+        if (__os.tie())
+            __os.tie()->flush();
+        __ok_ = true;
+    }
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>::sentry::~sentry()
+{
+    if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf)
+                      && !uncaught_exception())
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            if (__os_.rdbuf()->pubsync() == -1)
+                __os_.setstate(ios_base::badbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
+{
+    this->init(__sb);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
+{
+    this->move(__rhs);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
+{
+    swap(__rhs);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>::~basic_ostream()
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs)
+{
+    basic_ios<char_type, traits_type>::swap(__rhs);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(basic_ostream& (*__pf)(basic_ostream&))
+{
+    return __pf(*this);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(basic_ios<char_type, traits_type>&
+                                           (*__pf)(basic_ios<char_type,traits_type>&))
+{
+    __pf(*this);
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(ios_base& (*__pf)(ios_base&))
+{
+    __pf(*this);
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            if (__sb)
+            {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                try
+                {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                    typedef istreambuf_iterator<_CharT, _Traits> _Ip;
+                    typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+                    _Ip __i(__sb);
+                    _Ip __eof;
+                    _Op __o(*this);
+                    size_t __c = 0;
+                    for (; __i != __eof; ++__i, ++__o, ++__c)
+                    {
+                        *__o = *__i;
+                        if (__o.failed())
+                            break;
+                    }
+                    if (__c == 0)
+                        this->setstate(ios_base::failbit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                }
+                catch (...)
+                {
+                    this->__set_failbit_and_consider_rethrow();
+                }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            }
+            else
+                this->setstate(ios_base::badbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(bool __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(short __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(),
+                        __flags == ios_base::oct || __flags == ios_base::hex ?
+                        static_cast<long>(static_cast<unsigned short>(__n))  :
+                        static_cast<long>(__n)).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(int __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(),
+                        __flags == ios_base::oct || __flags == ios_base::hex ?
+                        static_cast<long>(static_cast<unsigned int>(__n))  :
+                        static_cast<long>(__n)).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(long long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(float __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(double __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(long double __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
+            const _Fp& __f = use_facet<_Fp>(this->getloc());
+            if (__f.put(*this, *this, this->fill(), __n).failed())
+                this->setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
+                          const _CharT* __str, size_t __len)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+        if (__s)
+        {
+            typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
+            if (__pad_and_output(_Ip(__os),
+                                 __str,
+                                 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
+                                     __str + __len :
+                                     __str,
+                                 __str + __len,
+                                 __os,
+                                 __os.fill()).failed())
+                __os.setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __os.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __os;
+}
+
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
+{
+    return _VSTD::__put_character_sequence(__os, &__c, 1);
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+        if (__s)
+        {
+            _CharT __c = __os.widen(__cn);
+            typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
+            if (__pad_and_output(_Ip(__os),
+                                 &__c,
+                                 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
+                                     &__c + 1 :
+                                     &__c,
+                                 &__c + 1,
+                                 __os,
+                                 __os.fill()).failed())
+                __os.setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __os.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __os;
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, char __c)
+{
+    return _VSTD::__put_character_sequence(__os, &__c, 1);
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
+{
+    return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
+{
+    return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
+{
+    return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
+}
+
+template<class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
+        if (__s)
+        {
+            typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
+            size_t __len = char_traits<char>::length(__strn);
+            const int __bs = 100;
+            _CharT __wbb[__bs];
+            _CharT* __wb = __wbb;
+            unique_ptr<_CharT, void(*)(void*)> __h(0, free);
+            if (__len > __bs)
+            {
+                __wb = (_CharT*)malloc(__len*sizeof(_CharT));
+                if (__wb == 0)
+                    __throw_bad_alloc();
+                __h.reset(__wb);
+            }
+            for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
+                *__p = __os.widen(*__strn);
+            if (__pad_and_output(_Ip(__os),
+                                 __wb,
+                                 (__os.flags() & ios_base::adjustfield) == ios_base::left ?
+                                     __wb + __len :
+                                     __wb,
+                                 __wb + __len,
+                                 __os,
+                                 __os.fill()).failed())
+                __os.setstate(ios_base::badbit | ios_base::failbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        __os.__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __os;
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
+{
+    return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
+{
+    const char *__s = (const char *) __str;
+    return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
+}
+
+template<class _Traits>
+basic_ostream<char, _Traits>&
+operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
+{
+    const char *__s = (const char *) __str;
+    return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::put(char_type __c)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __s(*this);
+        if (__s)
+        {
+            typedef ostreambuf_iterator<_CharT, _Traits> _Op;
+            _Op __o(*this);
+            *__o = __c;
+            if (__o.failed())
+                this->setstate(ios_base::badbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        sentry __sen(*this);
+        if (__sen && __n)
+        {
+            if (this->rdbuf()->sputn(__s, __n) != __n)
+                this->setstate(ios_base::badbit);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::flush()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        if (this->rdbuf())
+        {
+            sentry __s(*this);
+            if (__s)
+            {
+                if (this->rdbuf()->pubsync() == -1)
+                    this->setstate(ios_base::badbit);
+            }
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        this->__set_badbit_and_consider_rethrow();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_ostream<_CharT, _Traits>::pos_type
+basic_ostream<_CharT, _Traits>::tellp()
+{
+    if (this->fail())
+        return pos_type(-1);
+    return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
+{
+    sentry __s(*this);
+    if (__s)
+    {
+        if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
+            this->setstate(ios_base::failbit);
+    }
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
+{
+    sentry __s(*this);
+    if (__s)
+    {
+        if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
+            this->setstate(ios_base::failbit);
+    }
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+endl(basic_ostream<_CharT, _Traits>& __os)
+{
+    __os.put(__os.widen('\n'));
+    __os.flush();
+    return __os;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+ends(basic_ostream<_CharT, _Traits>& __os)
+{
+    __os.put(_CharT());
+    return __os;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+flush(basic_ostream<_CharT, _Traits>& __os)
+{
+    __os.flush();
+    return __os;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Stream, class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    !is_lvalue_reference<_Stream>::value &&
+    is_base_of<ios_base, _Stream>::value,
+    _Stream&&
+>::type
+operator<<(_Stream&& __os, const _Tp& __x)
+{
+    __os << __x;
+    return _VSTD::move(__os);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+    return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
+{
+    return __os << __ec.category().name() << ':' << __ec.value();
+}
+
+template<class _CharT, class _Traits, class _Yp>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
+{
+    return __os << __p.get();
+}
+
+template <class _CharT, class _Traits, size_t _Size>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
+{
+    return __os << __x.template to_string<_CharT, _Traits>
+                        (use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
+                         use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
+}
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<wchar_t>)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_OSTREAM
diff --git a/final/include/queue b/final/include/queue
new file mode 100644
index 0000000..bdfd706
--- /dev/null
+++ b/final/include/queue
@@ -0,0 +1,717 @@
+// -*- C++ -*-
+//===--------------------------- queue ------------------------------------===//
+//
+//                     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_QUEUE
+#define _LIBCPP_QUEUE
+
+/*
+    queue synopsis
+
+namespace std
+{
+
+template <class T, class Container = deque<T>>
+class queue
+{
+public:
+    typedef Container                                container_type;
+    typedef typename container_type::value_type      value_type;
+    typedef typename container_type::reference       reference;
+    typedef typename container_type::const_reference const_reference;
+    typedef typename container_type::size_type       size_type;
+
+protected:
+    container_type c;
+
+public:
+    queue() = default;
+    ~queue() = default;
+
+    queue(const queue& q) = default;
+    queue(queue&& q) = default;
+
+    queue& operator=(const queue& q) = default;
+    queue& operator=(queue&& q) = default;
+
+    explicit queue(const container_type& c);
+    explicit queue(container_type&& c)
+    template <class Alloc>
+        explicit queue(const Alloc& a);
+    template <class Alloc>
+        queue(const container_type& c, const Alloc& a);
+    template <class Alloc>
+        queue(container_type&& c, const Alloc& a);
+    template <class Alloc>
+        queue(const queue& q, const Alloc& a);
+    template <class Alloc>
+        queue(queue&& q, const Alloc& a);
+
+    bool      empty() const;
+    size_type size() const;
+
+    reference       front();
+    const_reference front() const;
+    reference       back();
+    const_reference back() const;
+
+    void push(const value_type& v);
+    void push(value_type&& v);
+    template <class... Args> void emplace(Args&&... args);
+    void pop();
+
+    void swap(queue& q) noexcept(noexcept(swap(c, q.c)));
+};
+
+template <class T, class Container>
+  bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+  bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+  bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+  bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+template <class T, class Container>
+  void swap(queue<T, Container>& x, queue<T, Container>& y)
+  noexcept(noexcept(x.swap(y)));
+
+template <class T, class Container = vector<T>,
+          class Compare = less<typename Container::value_type>>
+class priority_queue
+{
+public:
+    typedef Container                                container_type;
+    typedef typename container_type::value_type      value_type;
+    typedef typename container_type::reference       reference;
+    typedef typename container_type::const_reference const_reference;
+    typedef typename container_type::size_type       size_type;
+
+protected:
+    container_type c;
+    Compare comp;
+
+public:
+    priority_queue() = default;
+    ~priority_queue() = default;
+
+    priority_queue(const priority_queue& q) = default;
+    priority_queue(priority_queue&& q) = default;
+
+    priority_queue& operator=(const priority_queue& q) = default;
+    priority_queue& operator=(priority_queue&& q) = default;
+
+    explicit priority_queue(const Compare& comp);
+    priority_queue(const Compare& comp, const container_type& c);
+    explicit priority_queue(const Compare& comp, container_type&& c);
+    template <class InputIterator>
+        priority_queue(InputIterator first, InputIterator last,
+                       const Compare& comp = Compare());
+    template <class InputIterator>
+        priority_queue(InputIterator first, InputIterator last,
+                       const Compare& comp, const container_type& c);
+    template <class InputIterator>
+        priority_queue(InputIterator first, InputIterator last,
+                       const Compare& comp, container_type&& c);
+    template <class Alloc>
+        explicit priority_queue(const Alloc& a);
+    template <class Alloc>
+        priority_queue(const Compare& comp, const Alloc& a);
+    template <class Alloc>
+        priority_queue(const Compare& comp, const container_type& c,
+                       const Alloc& a);
+    template <class Alloc>
+        priority_queue(const Compare& comp, container_type&& c,
+                       const Alloc& a);
+    template <class Alloc>
+        priority_queue(const priority_queue& q, const Alloc& a);
+    template <class Alloc>
+        priority_queue(priority_queue&& q, const Alloc& a);
+
+    bool            empty() const;
+    size_type       size() const;
+    const_reference top() const;
+
+    void push(const value_type& v);
+    void push(value_type&& v);
+    template <class... Args> void emplace(Args&&... args);
+    void pop();
+
+    void swap(priority_queue& q)
+        noexcept(noexcept(swap(c, q.c)) && noexcept(swap(comp.q.comp)));
+};
+
+template <class T, class Container, class Compare>
+  void swap(priority_queue<T, Container, Compare>& x,
+            priority_queue<T, Container, Compare>& y)
+            noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+#include <deque>
+#include <vector>
+#include <functional>
+#include <algorithm>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS_ONLY queue;
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container = deque<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY queue
+{
+public:
+    typedef _Container                               container_type;
+    typedef typename container_type::value_type      value_type;
+    typedef typename container_type::reference       reference;
+    typedef typename container_type::const_reference const_reference;
+    typedef typename container_type::size_type       size_type;
+
+protected:
+    container_type c;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    queue()
+        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
+        : c() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    queue(const queue& __q) : c(__q.c) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    queue(queue&& __q)
+        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
+        : c(_VSTD::move(__q.c)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    queue& operator=(const queue& __q) {c = __q.c; return *this;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    queue& operator=(queue&& __q)
+        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
+        {c = _VSTD::move(__q.c); return *this;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit queue(const container_type& __c)  : c(__c) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit queue(const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0)
+            : c(__a) {}
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        queue(const queue& __q, const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0)
+            : c(__q.c, __a) {}
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        queue(const container_type& __c, const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0)
+            : c(__c, __a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        queue(container_type&& __c, const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0)
+            : c(_VSTD::move(__c), __a) {}
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        queue(queue&& __q, const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0)
+            : c(_VSTD::move(__q.c), __a) {}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const {return c.empty();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const  {return c.size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference       front()       {return c.front();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference front() const {return c.front();}
+    _LIBCPP_INLINE_VISIBILITY
+    reference       back()        {return c.back();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference back() const  {return c.back();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void push(const value_type& __v) {c.push_back(__v);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void emplace(_Args&&... __args)
+            {c.emplace_back(_VSTD::forward<_Args>(__args)...);}
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void pop() {c.pop_front();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(queue& __q)
+        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
+    {
+        using _VSTD::swap;
+        swap(c, __q.c);
+    }
+
+    template <class _T1, class _C1>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    bool
+    operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
+
+    template <class _T1, class _C1>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    bool
+    operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
+};
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+    return __x.c == __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+    return __x.c < __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Tp, class _Container, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<queue<_Tp, _Container>, _Alloc>
+    : public uses_allocator<_Container, _Alloc>
+{
+};
+
+template <class _Tp, class _Container = vector<_Tp>,
+          class _Compare = less<typename _Container::value_type> >
+class _LIBCPP_TYPE_VIS_ONLY priority_queue
+{
+public:
+    typedef _Container                               container_type;
+    typedef _Compare                                 value_compare;
+    typedef typename container_type::value_type      value_type;
+    typedef typename container_type::reference       reference;
+    typedef typename container_type::const_reference const_reference;
+    typedef typename container_type::size_type       size_type;
+
+protected:
+    container_type c;
+    value_compare comp;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    priority_queue()
+        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
+                   is_nothrow_default_constructible<value_compare>::value)
+        : c(), comp() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    priority_queue(priority_queue&& __q)
+        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
+                   is_nothrow_move_constructible<value_compare>::value)
+        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    priority_queue& operator=(const priority_queue& __q)
+        {c = __q.c; comp = __q.comp; return *this;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    priority_queue& operator=(priority_queue&& __q)
+        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
+                   is_nothrow_move_assignable<value_compare>::value)
+        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit priority_queue(const value_compare& __comp)
+        : c(), comp(__comp) {}
+    priority_queue(const value_compare& __comp, const container_type& __c);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    explicit priority_queue(const value_compare& __comp, container_type&& __c);
+#endif
+    template <class _InputIter>
+        priority_queue(_InputIter __f, _InputIter __l,
+                       const value_compare& __comp = value_compare());
+    template <class _InputIter>
+        priority_queue(_InputIter __f, _InputIter __l,
+                       const value_compare& __comp, const container_type& __c);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _InputIter>
+        priority_queue(_InputIter __f, _InputIter __l,
+                       const value_compare& __comp, container_type&& __c);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Alloc>
+        explicit priority_queue(const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0);
+    template <class _Alloc>
+        priority_queue(const value_compare& __comp, const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0);
+    template <class _Alloc>
+        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>
+        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>
+        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>
+        priority_queue(priority_queue&& __q, const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool            empty() const {return c.empty();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type       size() const  {return c.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference top() const   {return c.front();}
+
+    void push(const value_type& __v);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void push(value_type&& __v);
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args> void emplace(_Args&&... __args);
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void pop();
+
+    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
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
+                                                          const container_type& __c)
+    : c(__c),
+      comp(__comp)
+{
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+                                                          container_type&& __c)
+    : c(_VSTD::move(__c)),
+      comp(__comp)
+{
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
+                                                          const value_compare& __comp)
+    : c(__f, __l),
+      comp(__comp)
+{
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
+                                                          const value_compare& __comp,
+                                                          const container_type& __c)
+    : c(__c),
+      comp(__comp)
+{
+    c.insert(c.end(), __f, __l);
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+template <class _InputIter>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
+                                                          const value_compare& __comp,
+                                                          container_type&& __c)
+    : c(_VSTD::move(__c)),
+      comp(__comp)
+{
+    c.insert(c.end(), __f, __l);
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type*)
+    : c(__a)
+{
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+                                                          const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type*)
+    : c(__a),
+      comp(__comp)
+{
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+                                                          const container_type& __c,
+                                                          const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type*)
+    : c(__c, __a),
+      comp(__comp)
+{
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
+                                                          const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type*)
+    : c(__q.c, __a),
+      comp(__q.comp)
+{
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
+                                                          container_type&& __c,
+                                                          const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type*)
+    : c(_VSTD::move(__c), __a),
+      comp(__comp)
+{
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+template <class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
+                                                          const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type*)
+    : c(_VSTD::move(__q.c), __a),
+      comp(_VSTD::move(__q.comp))
+{
+    _VSTD::make_heap(c.begin(), c.end(), comp);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
+{
+    c.push_back(__v);
+    _VSTD::push_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
+{
+    c.push_back(_VSTD::move(__v));
+    _VSTD::push_heap(c.begin(), c.end(), comp);
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Container, class _Compare>
+template <class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
+{
+    c.emplace_back(_VSTD::forward<_Args>(__args)...);
+    _VSTD::push_heap(c.begin(), c.end(), comp);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Container, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+priority_queue<_Tp, _Container, _Compare>::pop()
+{
+    _VSTD::pop_heap(c.begin(), c.end(), comp);
+    c.pop_back();
+}
+
+template <class _Tp, class _Container, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
+        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
+                   __is_nothrow_swappable<value_compare>::value)
+{
+    using _VSTD::swap;
+    swap(c, __q.c);
+    swap(comp, __q.comp);
+}
+
+template <class _Tp, class _Container, class _Compare>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(priority_queue<_Tp, _Container, _Compare>& __x,
+     priority_queue<_Tp, _Container, _Compare>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Tp, class _Container, class _Compare, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
+    : public uses_allocator<_Container, _Alloc>
+{
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_QUEUE
diff --git a/final/include/random b/final/include/random
new file mode 100644
index 0000000..c0db1ab
--- /dev/null
+++ b/final/include/random
@@ -0,0 +1,6725 @@
+// -*- C++ -*-
+//===--------------------------- random -----------------------------------===//
+//
+//                     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_RANDOM
+#define _LIBCPP_RANDOM
+
+/*
+    random synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+// Engines
+
+template <class UIntType, UIntType a, UIntType c, UIntType m>
+class linear_congruential_engine
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+    // engine characteristics
+    static constexpr result_type multiplier = a;
+    static constexpr result_type increment = c;
+    static constexpr result_type modulus = m;
+    static constexpr result_type min() { return c == 0u ? 1u: 0u;}
+    static constexpr result_type max() { return m - 1u;}
+    static constexpr result_type default_seed = 1u;
+
+    // constructors and seeding functions
+    explicit linear_congruential_engine(result_type s = default_seed);
+    template<class Sseq> explicit linear_congruential_engine(Sseq& q);
+    void seed(result_type s = default_seed);
+    template<class Sseq> void seed(Sseq& q);
+
+    // generating functions
+    result_type operator()();
+    void discard(unsigned long long z);
+};
+
+template <class UIntType, UIntType a, UIntType c, UIntType m>
+bool
+operator==(const linear_congruential_engine<UIntType, a, c, m>& x,
+           const linear_congruential_engine<UIntType, a, c, m>& y);
+
+template <class UIntType, UIntType a, UIntType c, UIntType m>
+bool
+operator!=(const linear_congruential_engine<UIntType, a, c, m>& x,
+           const linear_congruential_engine<UIntType, a, c, m>& y);
+
+template <class charT, class traits,
+          class UIntType, UIntType a, UIntType c, UIntType m>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+           const linear_congruential_engine<UIntType, a, c, m>& x);
+
+template <class charT, class traits,
+          class UIntType, UIntType a, UIntType c, UIntType m>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+           linear_congruential_engine<UIntType, a, c, m>& x);
+
+template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+          UIntType a, size_t u, UIntType d, size_t s,
+          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+class mersenne_twister_engine
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+    // engine characteristics
+    static constexpr size_t word_size = w;
+    static constexpr size_t state_size = n;
+    static constexpr size_t shift_size = m;
+    static constexpr size_t mask_bits = r;
+    static constexpr result_type xor_mask = a;
+    static constexpr size_t tempering_u = u;
+    static constexpr result_type tempering_d = d;
+    static constexpr size_t tempering_s = s;
+    static constexpr result_type tempering_b = b;
+    static constexpr size_t tempering_t = t;
+    static constexpr result_type tempering_c = c;
+    static constexpr size_t tempering_l = l;
+    static constexpr result_type initialization_multiplier = f;
+    static constexpr result_type min () { return 0; }
+    static constexpr result_type max() { return 2^w - 1; }
+    static constexpr result_type default_seed = 5489u;
+
+    // constructors and seeding functions
+    explicit mersenne_twister_engine(result_type value = default_seed);
+    template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
+    void seed(result_type value = default_seed);
+    template<class Sseq> void seed(Sseq& q);
+
+    // generating functions
+    result_type operator()();
+    void discard(unsigned long long z);
+};
+
+template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+          UIntType a, size_t u, UIntType d, size_t s,
+          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+bool
+operator==(
+    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
+    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
+
+template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+          UIntType a, size_t u, UIntType d, size_t s,
+          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+bool
+operator!=(
+    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
+    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
+
+template <class charT, class traits,
+          class UIntType, size_t w, size_t n, size_t m, size_t r,
+          UIntType a, size_t u, UIntType d, size_t s,
+          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+           const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+template <class charT, class traits,
+          class UIntType, size_t w, size_t n, size_t m, size_t r,
+          UIntType a, size_t u, UIntType d, size_t s,
+          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+           mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+template<class UIntType, size_t w, size_t s, size_t r>
+class subtract_with_carry_engine
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+    // engine characteristics
+    static constexpr size_t word_size = w;
+    static constexpr size_t short_lag = s;
+    static constexpr size_t long_lag = r;
+    static constexpr result_type min() { return 0; }
+    static constexpr result_type max() { return m-1; }
+    static constexpr result_type default_seed = 19780503u;
+
+    // constructors and seeding functions
+    explicit subtract_with_carry_engine(result_type value = default_seed);
+    template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
+    void seed(result_type value = default_seed);
+    template<class Sseq> void seed(Sseq& q);
+
+    // generating functions
+    result_type operator()();
+    void discard(unsigned long long z);
+};
+
+template<class UIntType, size_t w, size_t s, size_t r>
+bool
+operator==(
+    const subtract_with_carry_engine<UIntType, w, s, r>& x,
+    const subtract_with_carry_engine<UIntType, w, s, r>& y);
+
+template<class UIntType, size_t w, size_t s, size_t r>
+bool
+operator!=(
+    const subtract_with_carry_engine<UIntType, w, s, r>& x,
+    const subtract_with_carry_engine<UIntType, w, s, r>& y);
+
+template <class charT, class traits,
+          class UIntType, size_t w, size_t s, size_t r>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+           const subtract_with_carry_engine<UIntType, w, s, r>& x);
+
+template <class charT, class traits,
+          class UIntType, size_t w, size_t s, size_t r>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+           subtract_with_carry_engine<UIntType, w, s, r>& x);
+
+template<class Engine, size_t p, size_t r>
+class discard_block_engine
+{
+public:
+    // types
+    typedef typename Engine::result_type result_type;
+
+    // engine characteristics
+    static constexpr size_t block_size = p;
+    static constexpr size_t used_block = r;
+    static constexpr result_type min() { return Engine::min(); }
+    static constexpr result_type max() { return Engine::max(); }
+
+    // constructors and seeding functions
+    discard_block_engine();
+    explicit discard_block_engine(const Engine& e);
+    explicit discard_block_engine(Engine&& e);
+    explicit discard_block_engine(result_type s);
+    template<class Sseq> explicit discard_block_engine(Sseq& q);
+    void seed();
+    void seed(result_type s);
+    template<class Sseq> void seed(Sseq& q);
+
+    // generating functions
+    result_type operator()();
+    void discard(unsigned long long z);
+
+    // property functions
+    const Engine& base() const noexcept;
+};
+
+template<class Engine, size_t p, size_t r>
+bool
+operator==(
+    const discard_block_engine<Engine, p, r>& x,
+    const discard_block_engine<Engine, p, r>& y);
+
+template<class Engine, size_t p, size_t r>
+bool
+operator!=(
+    const discard_block_engine<Engine, p, r>& x,
+    const discard_block_engine<Engine, p, r>& y);
+
+template <class charT, class traits,
+          class Engine, size_t p, size_t r>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+           const discard_block_engine<Engine, p, r>& x);
+
+template <class charT, class traits,
+          class Engine, size_t p, size_t r>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+           discard_block_engine<Engine, p, r>& x);
+
+template<class Engine, size_t w, class UIntType>
+class independent_bits_engine
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+    // engine characteristics
+    static constexpr result_type min() { return 0; }
+    static constexpr result_type max() { return 2^w - 1; }
+
+    // constructors and seeding functions
+    independent_bits_engine();
+    explicit independent_bits_engine(const Engine& e);
+    explicit independent_bits_engine(Engine&& e);
+    explicit independent_bits_engine(result_type s);
+    template<class Sseq> explicit independent_bits_engine(Sseq& q);
+    void seed();
+    void seed(result_type s);
+    template<class Sseq> void seed(Sseq& q);
+
+    // generating functions
+    result_type operator()(); void discard(unsigned long long z);
+
+    // property functions
+    const Engine& base() const noexcept;
+};
+
+template<class Engine, size_t w, class UIntType>
+bool
+operator==(
+    const independent_bits_engine<Engine, w, UIntType>& x,
+    const independent_bits_engine<Engine, w, UIntType>& y);
+
+template<class Engine, size_t w, class UIntType>
+bool
+operator!=(
+    const independent_bits_engine<Engine, w, UIntType>& x,
+    const independent_bits_engine<Engine, w, UIntType>& y);
+
+template <class charT, class traits,
+          class Engine, size_t w, class UIntType>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+           const independent_bits_engine<Engine, w, UIntType>& x);
+
+template <class charT, class traits,
+          class Engine, size_t w, class UIntType>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+           independent_bits_engine<Engine, w, UIntType>& x);
+
+template<class Engine, size_t k>
+class shuffle_order_engine
+{
+public:
+    // types
+    typedef typename Engine::result_type result_type;
+
+    // engine characteristics
+    static constexpr size_t table_size = k;
+    static constexpr result_type min() { return Engine::min; }
+    static constexpr result_type max() { return Engine::max; }
+
+    // constructors and seeding functions
+    shuffle_order_engine();
+    explicit shuffle_order_engine(const Engine& e);
+    explicit shuffle_order_engine(Engine&& e);
+    explicit shuffle_order_engine(result_type s);
+    template<class Sseq> explicit shuffle_order_engine(Sseq& q);
+    void seed();
+    void seed(result_type s);
+    template<class Sseq> void seed(Sseq& q);
+
+    // generating functions
+    result_type operator()();
+    void discard(unsigned long long z);
+
+    // property functions
+    const Engine& base() const noexcept;
+};
+
+template<class Engine, size_t k>
+bool
+operator==(
+    const shuffle_order_engine<Engine, k>& x,
+    const shuffle_order_engine<Engine, k>& y);
+
+template<class Engine, size_t k>
+bool
+operator!=(
+    const shuffle_order_engine<Engine, k>& x,
+    const shuffle_order_engine<Engine, k>& y);
+
+template <class charT, class traits,
+          class Engine, size_t k>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os,
+           const shuffle_order_engine<Engine, k>& x);
+
+template <class charT, class traits,
+          class Engine, size_t k>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is,
+           shuffle_order_engine<Engine, k>& x);
+
+typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
+                                                                   minstd_rand0;
+typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
+                                                                    minstd_rand;
+typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
+                                0x9908b0df,
+                                11, 0xffffffff,
+                                7,  0x9d2c5680,
+                                15, 0xefc60000,
+                                18, 1812433253>                         mt19937;
+typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
+                                0xb5026f5aa96619e9,
+                                29, 0x5555555555555555,
+                                17, 0x71d67fffeda60000,
+                                37, 0xfff7eee000000000,
+                                43, 6364136223846793005>             mt19937_64;
+typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>     ranlux24_base;
+typedef subtract_with_carry_engine<uint_fast64_t, 48,  5, 12>     ranlux48_base;
+typedef discard_block_engine<ranlux24_base, 223, 23>                   ranlux24;
+typedef discard_block_engine<ranlux48_base, 389, 11>                   ranlux48;
+typedef shuffle_order_engine<minstd_rand0, 256>                         knuth_b;
+typedef minstd_rand                                       default_random_engine;
+
+// Generators
+
+class random_device
+{
+public:
+    // types
+    typedef unsigned int result_type;
+
+    // generator characteristics
+    static constexpr result_type min() { return numeric_limits<result_type>::min(); }
+    static constexpr result_type max() { return numeric_limits<result_type>::max(); }
+
+    // constructors
+    explicit random_device(const string& token = "/dev/urandom");
+
+    // generating functions
+    result_type operator()();
+
+    // property functions
+    double entropy() const noexcept;
+
+    // no copy functions
+    random_device(const random_device& ) = delete;
+    void operator=(const random_device& ) = delete;
+};
+
+// Utilities
+
+class seed_seq
+{
+public:
+    // types
+    typedef uint_least32_t result_type;
+
+    // constructors
+    seed_seq();
+    template<class T>
+        seed_seq(initializer_list<T> il);
+    template<class InputIterator>
+        seed_seq(InputIterator begin, InputIterator end);
+
+    // generating functions
+    template<class RandomAccessIterator>
+        void generate(RandomAccessIterator begin, RandomAccessIterator end);
+
+    // property functions
+    size_t size() const;
+    template<class OutputIterator>
+        void param(OutputIterator dest) const;
+
+    // no copy functions
+    seed_seq(const seed_seq&) = delete;
+    void operator=(const seed_seq& ) = delete;
+};
+
+template<class RealType, size_t bits, class URNG>
+    RealType generate_canonical(URNG& g);
+
+// Distributions
+
+template<class IntType = int>
+class uniform_int_distribution
+{
+public:
+    // types
+    typedef IntType result_type;
+
+    class param_type
+    {
+    public:
+        typedef uniform_int_distribution distribution_type;
+
+        explicit param_type(IntType a = 0,
+                                    IntType b = numeric_limits<IntType>::max());
+
+        result_type a() const;
+        result_type b() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit uniform_int_distribution(IntType a = 0,
+                                    IntType b = numeric_limits<IntType>::max());
+    explicit uniform_int_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type a() const;
+    result_type b() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const uniform_int_distribution& x,
+                           const uniform_int_distribution& y);
+    friend bool operator!=(const uniform_int_distribution& x,
+                           const uniform_int_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const uniform_int_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               uniform_int_distribution& x);
+};
+
+template<class RealType = double>
+class uniform_real_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef uniform_real_distribution distribution_type;
+
+        explicit param_type(RealType a = 0,
+                            RealType b = 1);
+
+        result_type a() const;
+        result_type b() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0);
+    explicit uniform_real_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type a() const;
+    result_type b() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const uniform_real_distribution& x,
+                           const uniform_real_distribution& y);
+    friend bool operator!=(const uniform_real_distribution& x,
+                           const uniform_real_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const uniform_real_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               uniform_real_distribution& x);
+};
+
+class bernoulli_distribution
+{
+public:
+    // types
+    typedef bool result_type;
+
+    class param_type
+    {
+    public:
+        typedef bernoulli_distribution distribution_type;
+
+        explicit param_type(double p = 0.5);
+
+        double p() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit bernoulli_distribution(double p = 0.5);
+    explicit bernoulli_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    double p() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const bernoulli_distribution& x,
+                           const bernoulli_distribution& y);
+    friend bool operator!=(const bernoulli_distribution& x,
+                           const bernoulli_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const bernoulli_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               bernoulli_distribution& x);
+};
+
+template<class IntType = int>
+class binomial_distribution
+{
+public:
+    // types
+    typedef IntType result_type;
+
+    class param_type
+    {
+    public:
+        typedef binomial_distribution distribution_type;
+
+        explicit param_type(IntType t = 1, double p = 0.5);
+
+        IntType t() const;
+        double p() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit binomial_distribution(IntType t = 1, double p = 0.5);
+    explicit binomial_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    IntType t() const;
+    double p() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const binomial_distribution& x,
+                           const binomial_distribution& y);
+    friend bool operator!=(const binomial_distribution& x,
+                           const binomial_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const binomial_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               binomial_distribution& x);
+};
+
+template<class IntType = int>
+class geometric_distribution
+{
+public:
+    // types
+    typedef IntType result_type;
+
+    class param_type
+    {
+    public:
+        typedef geometric_distribution distribution_type;
+
+        explicit param_type(double p = 0.5);
+
+        double p() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit geometric_distribution(double p = 0.5);
+    explicit geometric_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    double p() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const geometric_distribution& x,
+                           const geometric_distribution& y);
+    friend bool operator!=(const geometric_distribution& x,
+                           const geometric_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const geometric_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               geometric_distribution& x);
+};
+
+template<class IntType = int>
+class negative_binomial_distribution
+{
+public:
+    // types
+    typedef IntType result_type;
+
+    class param_type
+    {
+    public:
+        typedef negative_binomial_distribution distribution_type;
+
+        explicit param_type(result_type k = 1, double p = 0.5);
+
+        result_type k() const;
+        double p() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit negative_binomial_distribution(result_type k = 1, double p = 0.5);
+    explicit negative_binomial_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type k() const;
+    double p() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const negative_binomial_distribution& x,
+                           const negative_binomial_distribution& y);
+    friend bool operator!=(const negative_binomial_distribution& x,
+                           const negative_binomial_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const negative_binomial_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               negative_binomial_distribution& x);
+};
+
+template<class IntType = int>
+class poisson_distribution
+{
+public:
+    // types
+    typedef IntType result_type;
+
+    class param_type
+    {
+    public:
+        typedef poisson_distribution distribution_type;
+
+        explicit param_type(double mean = 1.0);
+
+        double mean() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit poisson_distribution(double mean = 1.0);
+    explicit poisson_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    double mean() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const poisson_distribution& x,
+                           const poisson_distribution& y);
+    friend bool operator!=(const poisson_distribution& x,
+                           const poisson_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const poisson_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               poisson_distribution& x);
+};
+
+template<class RealType = double>
+class exponential_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef exponential_distribution distribution_type;
+
+        explicit param_type(result_type lambda = 1.0);
+
+        result_type lambda() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit exponential_distribution(result_type lambda = 1.0);
+    explicit exponential_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type lambda() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const exponential_distribution& x,
+                           const exponential_distribution& y);
+    friend bool operator!=(const exponential_distribution& x,
+                           const exponential_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const exponential_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               exponential_distribution& x);
+};
+
+template<class RealType = double>
+class gamma_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef gamma_distribution distribution_type;
+
+        explicit param_type(result_type alpha = 1, result_type beta = 1);
+
+        result_type alpha() const;
+        result_type beta() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit gamma_distribution(result_type alpha = 1, result_type beta = 1);
+    explicit gamma_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type alpha() const;
+    result_type beta() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const gamma_distribution& x,
+                           const gamma_distribution& y);
+    friend bool operator!=(const gamma_distribution& x,
+                           const gamma_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const gamma_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               gamma_distribution& x);
+};
+
+template<class RealType = double>
+class weibull_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef weibull_distribution distribution_type;
+
+        explicit param_type(result_type alpha = 1, result_type beta = 1);
+
+        result_type a() const;
+        result_type b() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit weibull_distribution(result_type a = 1, result_type b = 1);
+    explicit weibull_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type a() const;
+    result_type b() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const weibull_distribution& x,
+                           const weibull_distribution& y);
+    friend bool operator!=(const weibull_distribution& x,
+                           const weibull_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const weibull_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               weibull_distribution& x);
+};
+
+template<class RealType = double>
+class extreme_value_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef extreme_value_distribution distribution_type;
+
+        explicit param_type(result_type a = 0, result_type b = 1);
+
+        result_type a() const;
+        result_type b() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit extreme_value_distribution(result_type a = 0, result_type b = 1);
+    explicit extreme_value_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type a() const;
+    result_type b() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const extreme_value_distribution& x,
+                           const extreme_value_distribution& y);
+    friend bool operator!=(const extreme_value_distribution& x,
+                           const extreme_value_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const extreme_value_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               extreme_value_distribution& x);
+};
+
+template<class RealType = double>
+class normal_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef normal_distribution distribution_type;
+
+        explicit param_type(result_type mean = 0, result_type stddev = 1);
+
+        result_type mean() const;
+        result_type stddev() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructors and reset functions
+    explicit normal_distribution(result_type mean = 0, result_type stddev = 1);
+    explicit normal_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type mean() const;
+    result_type stddev() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const normal_distribution& x,
+                           const normal_distribution& y);
+    friend bool operator!=(const normal_distribution& x,
+                           const normal_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const normal_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               normal_distribution& x);
+};
+
+template<class RealType = double>
+class lognormal_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef lognormal_distribution distribution_type;
+
+        explicit param_type(result_type m = 0, result_type s = 1);
+
+        result_type m() const;
+        result_type s() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit lognormal_distribution(result_type m = 0, result_type s = 1);
+    explicit lognormal_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type m() const;
+    result_type s() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const lognormal_distribution& x,
+                           const lognormal_distribution& y);
+    friend bool operator!=(const lognormal_distribution& x,
+                           const lognormal_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const lognormal_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               lognormal_distribution& x);
+};
+
+template<class RealType = double>
+class chi_squared_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef chi_squared_distribution distribution_type;
+
+        explicit param_type(result_type n = 1);
+
+        result_type n() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit chi_squared_distribution(result_type n = 1);
+    explicit chi_squared_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type n() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const chi_squared_distribution& x,
+                           const chi_squared_distribution& y);
+    friend bool operator!=(const chi_squared_distribution& x,
+                           const chi_squared_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const chi_squared_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               chi_squared_distribution& x);
+};
+
+template<class RealType = double>
+class cauchy_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef cauchy_distribution distribution_type;
+
+        explicit param_type(result_type a = 0, result_type b = 1);
+
+        result_type a() const;
+        result_type b() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit cauchy_distribution(result_type a = 0, result_type b = 1);
+    explicit cauchy_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type a() const;
+    result_type b() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const cauchy_distribution& x,
+                           const cauchy_distribution& y);
+    friend bool operator!=(const cauchy_distribution& x,
+                           const cauchy_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const cauchy_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               cauchy_distribution& x);
+};
+
+template<class RealType = double>
+class fisher_f_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef fisher_f_distribution distribution_type;
+
+        explicit param_type(result_type m = 1, result_type n = 1);
+
+        result_type m() const;
+        result_type n() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit fisher_f_distribution(result_type m = 1, result_type n = 1);
+    explicit fisher_f_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type m() const;
+    result_type n() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const fisher_f_distribution& x,
+                           const fisher_f_distribution& y);
+    friend bool operator!=(const fisher_f_distribution& x,
+                           const fisher_f_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const fisher_f_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               fisher_f_distribution& x);
+};
+
+template<class RealType = double>
+class student_t_distribution
+{
+public:
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef student_t_distribution distribution_type;
+
+        explicit param_type(result_type n = 1);
+
+        result_type n() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    explicit student_t_distribution(result_type n = 1);
+    explicit student_t_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    result_type n() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const student_t_distribution& x,
+                           const student_t_distribution& y);
+    friend bool operator!=(const student_t_distribution& x,
+                           const student_t_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const student_t_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               student_t_distribution& x);
+};
+
+template<class IntType = int>
+class discrete_distribution
+{
+public:
+    // types
+    typedef IntType result_type;
+
+    class param_type
+    {
+    public:
+        typedef discrete_distribution distribution_type;
+
+        param_type();
+        template<class InputIterator>
+            param_type(InputIterator firstW, InputIterator lastW);
+        param_type(initializer_list<double> wl);
+        template<class UnaryOperation>
+            param_type(size_t nw, double xmin, double xmax, UnaryOperation fw);
+
+        vector<double> probabilities() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    discrete_distribution();
+    template<class InputIterator>
+        discrete_distribution(InputIterator firstW, InputIterator lastW);
+    discrete_distribution(initializer_list<double> wl);
+    template<class UnaryOperation>
+        discrete_distribution(size_t nw, double xmin, double xmax,
+                              UnaryOperation fw);
+    explicit discrete_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    vector<double> probabilities() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const discrete_distribution& x,
+                           const discrete_distribution& y);
+    friend bool operator!=(const discrete_distribution& x,
+                           const discrete_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const discrete_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               discrete_distribution& x);
+};
+
+template<class RealType = double>
+class piecewise_constant_distribution
+{
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef piecewise_constant_distribution distribution_type;
+
+        param_type();
+        template<class InputIteratorB, class InputIteratorW>
+            param_type(InputIteratorB firstB, InputIteratorB lastB,
+                       InputIteratorW firstW);
+        template<class UnaryOperation>
+            param_type(initializer_list<result_type> bl, UnaryOperation fw);
+        template<class UnaryOperation>
+            param_type(size_t nw, result_type xmin, result_type xmax,
+                       UnaryOperation fw);
+
+        vector<result_type> intervals() const;
+        vector<result_type> densities() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    piecewise_constant_distribution();
+    template<class InputIteratorB, class InputIteratorW>
+        piecewise_constant_distribution(InputIteratorB firstB,
+                                        InputIteratorB lastB,
+                                        InputIteratorW firstW);
+    template<class UnaryOperation>
+        piecewise_constant_distribution(initializer_list<result_type> bl,
+                                        UnaryOperation fw);
+    template<class UnaryOperation>
+        piecewise_constant_distribution(size_t nw, result_type xmin,
+                                        result_type xmax, UnaryOperation fw);
+    explicit piecewise_constant_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    vector<result_type> intervals() const;
+    vector<result_type> densities() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const piecewise_constant_distribution& x,
+                           const piecewise_constant_distribution& y);
+    friend bool operator!=(const piecewise_constant_distribution& x,
+                           const piecewise_constant_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const piecewise_constant_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               piecewise_constant_distribution& x);
+};
+
+template<class RealType = double>
+class piecewise_linear_distribution
+{
+    // types
+    typedef RealType result_type;
+
+    class param_type
+    {
+    public:
+        typedef piecewise_linear_distribution distribution_type;
+
+        param_type();
+        template<class InputIteratorB, class InputIteratorW>
+            param_type(InputIteratorB firstB, InputIteratorB lastB,
+                       InputIteratorW firstW);
+        template<class UnaryOperation>
+            param_type(initializer_list<result_type> bl, UnaryOperation fw);
+        template<class UnaryOperation>
+            param_type(size_t nw, result_type xmin, result_type xmax,
+                       UnaryOperation fw);
+
+        vector<result_type> intervals() const;
+        vector<result_type> densities() const;
+
+        friend bool operator==(const param_type& x, const param_type& y);
+        friend bool operator!=(const param_type& x, const param_type& y);
+    };
+
+    // constructor and reset functions
+    piecewise_linear_distribution();
+    template<class InputIteratorB, class InputIteratorW>
+        piecewise_linear_distribution(InputIteratorB firstB,
+                                      InputIteratorB lastB,
+                                      InputIteratorW firstW);
+
+    template<class UnaryOperation>
+        piecewise_linear_distribution(initializer_list<result_type> bl,
+                                      UnaryOperation fw);
+
+    template<class UnaryOperation>
+        piecewise_linear_distribution(size_t nw, result_type xmin,
+                                      result_type xmax, UnaryOperation fw);
+
+    explicit piecewise_linear_distribution(const param_type& parm);
+    void reset();
+
+    // generating functions
+    template<class URNG> result_type operator()(URNG& g);
+    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+    // property functions
+    vector<result_type> intervals() const;
+    vector<result_type> densities() const;
+
+    param_type param() const;
+    void param(const param_type& parm);
+
+    result_type min() const;
+    result_type max() const;
+
+    friend bool operator==(const piecewise_linear_distribution& x,
+                           const piecewise_linear_distribution& y);
+    friend bool operator!=(const piecewise_linear_distribution& x,
+                           const piecewise_linear_distribution& y);
+
+    template <class charT, class traits>
+    friend
+    basic_ostream<charT, traits>&
+    operator<<(basic_ostream<charT, traits>& os,
+               const piecewise_linear_distribution& x);
+
+    template <class charT, class traits>
+    friend
+    basic_istream<charT, traits>&
+    operator>>(basic_istream<charT, traits>& is,
+               piecewise_linear_distribution& x);
+};
+
+} // std
+*/
+
+#include <__config>
+#include <cstddef>
+#include <type_traits>
+#include <initializer_list>
+#include <cstdint>
+#include <limits>
+#include <algorithm>
+#include <numeric>
+#include <vector>
+#include <string>
+#include <istream>
+#include <ostream>
+#include <cmath>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __is_seed_sequence
+
+template <class _Sseq, class _Engine>
+struct __is_seed_sequence
+{
+    static _LIBCPP_CONSTEXPR const bool value =
+              !is_convertible<_Sseq, typename _Engine::result_type>::value &&
+              !is_same<typename remove_cv<_Sseq>::type, _Engine>::value;
+};
+
+// linear_congruential_engine
+
+template <unsigned long long __a, unsigned long long __c,
+          unsigned long long __m, unsigned long long _Mp,
+          bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a)>
+struct __lce_ta;
+
+// 64
+
+template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
+struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true>
+{
+    typedef unsigned long long result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        // Schrage's algorithm
+        const result_type __q = __m / __a;
+        const result_type __r = __m % __a;
+        const result_type __t0 = __a * (__x % __q);
+        const result_type __t1 = __r * (__x / __q);
+        __x = __t0 + (__t0 < __t1) * __m - __t1;
+        __x += __c - (__x >= __m - __c) * __m;
+        return __x;
+    }
+};
+
+template <unsigned long long __a, unsigned long long __m>
+struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true>
+{
+    typedef unsigned long long result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        // Schrage's algorithm
+        const result_type __q = __m / __a;
+        const result_type __r = __m % __a;
+        const result_type __t0 = __a * (__x % __q);
+        const result_type __t1 = __r * (__x / __q);
+        __x = __t0 + (__t0 < __t1) * __m - __t1;
+        return __x;
+    }
+};
+
+template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
+struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), false>
+{
+    typedef unsigned long long result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        return (__a * __x + __c) % __m;
+    }
+};
+
+template <unsigned long long __a, unsigned long long __c>
+struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false>
+{
+    typedef unsigned long long result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        return __a * __x + __c;
+    }
+};
+
+// 32
+
+template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
+struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true>
+{
+    typedef unsigned result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        const result_type __a = static_cast<result_type>(_Ap);
+        const result_type __c = static_cast<result_type>(_Cp);
+        const result_type __m = static_cast<result_type>(_Mp);
+        // Schrage's algorithm
+        const result_type __q = __m / __a;
+        const result_type __r = __m % __a;
+        const result_type __t0 = __a * (__x % __q);
+        const result_type __t1 = __r * (__x / __q);
+        __x = __t0 + (__t0 < __t1) * __m - __t1;
+        __x += __c - (__x >= __m - __c) * __m;
+        return __x;
+    }
+};
+
+template <unsigned long long _Ap, unsigned long long _Mp>
+struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true>
+{
+    typedef unsigned result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        const result_type __a = static_cast<result_type>(_Ap);
+        const result_type __m = static_cast<result_type>(_Mp);
+        // Schrage's algorithm
+        const result_type __q = __m / __a;
+        const result_type __r = __m % __a;
+        const result_type __t0 = __a * (__x % __q);
+        const result_type __t1 = __r * (__x / __q);
+        __x = __t0 + (__t0 < __t1) * __m - __t1;
+        return __x;
+    }
+};
+
+template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
+struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false>
+{
+    typedef unsigned result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        const result_type __a = static_cast<result_type>(_Ap);
+        const result_type __c = static_cast<result_type>(_Cp);
+        const result_type __m = static_cast<result_type>(_Mp);
+        return (__a * __x + __c) % __m;
+    }
+};
+
+template <unsigned long long _Ap, unsigned long long _Cp>
+struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false>
+{
+    typedef unsigned result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        const result_type __a = static_cast<result_type>(_Ap);
+        const result_type __c = static_cast<result_type>(_Cp);
+        return __a * __x + __c;
+    }
+};
+
+// 16
+
+template <unsigned long long __a, unsigned long long __c, unsigned long long __m, bool __b>
+struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b>
+{
+    typedef unsigned short result_type;
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type next(result_type __x)
+    {
+        return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(~0)>::next(__x));
+    }
+};
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine;
+
+template <class _CharT, class _Traits,
+          class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+_LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&);
+
+template <class _CharT, class _Traits,
+          class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine
+{
+public:
+    // types
+    typedef _UIntType result_type;
+
+private:
+    result_type __x_;
+
+    static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0);
+
+    static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters");
+    static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
+public:
+    static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u;
+    static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u;
+    static_assert(_Min < _Max,           "linear_congruential_engine invalid parameters");
+
+    // engine characteristics
+    static _LIBCPP_CONSTEXPR const result_type multiplier = __a;
+    static _LIBCPP_CONSTEXPR const result_type increment = __c;
+    static _LIBCPP_CONSTEXPR const result_type modulus = __m;
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type min() {return _Min;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type max() {return _Max;}
+    static _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
+
+    // constructors and seeding functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit linear_congruential_engine(result_type __s = default_seed)
+        {seed(__s);}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit linear_congruential_engine(_Sseq& __q,
+        typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0)
+        {seed(__q);}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(result_type __s = default_seed)
+        {seed(integral_constant<bool, __m == 0>(),
+              integral_constant<bool, __c == 0>(), __s);}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_seed_sequence<_Sseq, linear_congruential_engine>::value,
+            void
+        >::type
+        seed(_Sseq& __q)
+            {__seed(__q, integral_constant<unsigned,
+                1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1)/32
+                             :  (__m > 0x100000000ull))>());}
+
+    // generating functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator()()
+        {return __x_ = static_cast<result_type>(__lce_ta<__a, __c, __m, _Mp>::next(__x_));}
+    _LIBCPP_INLINE_VISIBILITY
+    void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const linear_congruential_engine& __x,
+                    const linear_congruential_engine& __y)
+        {return __x.__x_ == __y.__x_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const linear_congruential_engine& __x,
+                    const linear_congruential_engine& __y)
+        {return !(__x == __y);}
+
+private:
+
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(true_type, true_type, result_type __s) {__x_ = __s == 0 ? 1 : __s;}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(true_type, false_type, result_type __s) {__x_ = __s;}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(false_type, true_type, result_type __s) {__x_ = __s % __m == 0 ?
+                                                                 1 : __s % __m;}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(false_type, false_type, result_type __s) {__x_ = __s % __m;}
+
+    template<class _Sseq>
+        void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
+    template<class _Sseq>
+        void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
+
+    template <class _CharT, class _Traits,
+              class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&);
+
+    template <class _CharT, class _Traits,
+              class _Up, _Up _Ap, _Up _Cp, _Up _Np>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
+};
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+    _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+    linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+    _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+    linear_congruential_engine<_UIntType, __a, __c, __m>::increment;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+    _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+    linear_congruential_engine<_UIntType, __a, __c, __m>::modulus;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+    _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
+    linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed;
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+template<class _Sseq>
+void
+linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q,
+                                                 integral_constant<unsigned, 1>)
+{
+    const unsigned __k = 1;
+    uint32_t __ar[__k+3];
+    __q.generate(__ar, __ar + __k + 3);
+    result_type __s = static_cast<result_type>(__ar[3] % __m);
+    __x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
+}
+
+template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+template<class _Sseq>
+void
+linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q,
+                                                 integral_constant<unsigned, 2>)
+{
+    const unsigned __k = 2;
+    uint32_t __ar[__k+3];
+    __q.generate(__ar, __ar + __k + 3);
+    result_type __s = static_cast<result_type>((__ar[3] +
+                                              ((uint64_t)__ar[4] << 32)) % __m);
+    __x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
+}
+
+template <class _CharT, class _Traits,
+          class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left);
+    __os.fill(__os.widen(' '));
+    return __os << __x.__x_;
+}
+
+template <class _CharT, class _Traits,
+          class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           linear_congruential_engine<_UIntType, __a, __c, __m>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    _UIntType __t;
+    __is >> __t;
+    if (!__is.fail())
+        __x.__x_ = __t;
+    return __is;
+}
+
+typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
+                                                                   minstd_rand0;
+typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
+                                                                    minstd_rand;
+typedef minstd_rand                                       default_random_engine;
+// mersenne_twister_engine
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine;
+
+template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+bool
+operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+           const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+           const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                   _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine
+{
+public:
+    // types
+    typedef _UIntType result_type;
+
+private:
+    result_type __x_[__n];
+    size_t      __i_;
+
+    static_assert(  0 <  __m, "mersenne_twister_engine invalid parameters");
+    static_assert(__m <= __n, "mersenne_twister_engine invalid parameters");
+    static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits;
+    static_assert(__w <= _Dt, "mersenne_twister_engine invalid parameters");
+    static_assert(  2 <= __w, "mersenne_twister_engine invalid parameters");
+    static_assert(__r <= __w, "mersenne_twister_engine invalid parameters");
+    static_assert(__u <= __w, "mersenne_twister_engine invalid parameters");
+    static_assert(__s <= __w, "mersenne_twister_engine invalid parameters");
+    static_assert(__t <= __w, "mersenne_twister_engine invalid parameters");
+    static_assert(__l <= __w, "mersenne_twister_engine invalid parameters");
+public:
+    static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+    static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) :
+                                                      (result_type(1) << __w) - result_type(1);
+    static_assert(_Min < _Max, "mersenne_twister_engine invalid parameters");
+    static_assert(__a <= _Max, "mersenne_twister_engine invalid parameters");
+    static_assert(__b <= _Max, "mersenne_twister_engine invalid parameters");
+    static_assert(__c <= _Max, "mersenne_twister_engine invalid parameters");
+    static_assert(__d <= _Max, "mersenne_twister_engine invalid parameters");
+    static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters");
+
+    // engine characteristics
+    static _LIBCPP_CONSTEXPR const size_t word_size = __w;
+    static _LIBCPP_CONSTEXPR const size_t state_size = __n;
+    static _LIBCPP_CONSTEXPR const size_t shift_size = __m;
+    static _LIBCPP_CONSTEXPR const size_t mask_bits = __r;
+    static _LIBCPP_CONSTEXPR const result_type xor_mask = __a;
+    static _LIBCPP_CONSTEXPR const size_t tempering_u = __u;
+    static _LIBCPP_CONSTEXPR const result_type tempering_d = __d;
+    static _LIBCPP_CONSTEXPR const size_t tempering_s = __s;
+    static _LIBCPP_CONSTEXPR const result_type tempering_b = __b;
+    static _LIBCPP_CONSTEXPR const size_t tempering_t = __t;
+    static _LIBCPP_CONSTEXPR const result_type tempering_c = __c;
+    static _LIBCPP_CONSTEXPR const size_t tempering_l = __l;
+    static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+    static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
+
+    // constructors and seeding functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit mersenne_twister_engine(result_type __sd = default_seed)
+        {seed(__sd);}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit mersenne_twister_engine(_Sseq& __q,
+        typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0)
+        {seed(__q);}
+    void seed(result_type __sd = default_seed);
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_seed_sequence<_Sseq, mersenne_twister_engine>::value,
+            void
+        >::type
+        seed(_Sseq& __q)
+            {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
+
+    // generating functions
+    result_type operator()();
+    _LIBCPP_INLINE_VISIBILITY
+    void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+    template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+              _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+              _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+    friend
+    bool
+    operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                             _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+               const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                             _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+    template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+              _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+              _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+    friend
+    bool
+    operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                             _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+               const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                             _Bp, _Tp, _Cp, _Lp, _Fp>& __y);
+
+    template <class _CharT, class _Traits,
+              class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+              _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+              _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                             _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+
+    template <class _CharT, class _Traits,
+              class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+              _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+              _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                       _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
+private:
+
+    template<class _Sseq>
+        void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
+    template<class _Sseq>
+        void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
+
+    template <size_t __count>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        typename enable_if
+        <
+            __count < __w,
+            result_type
+        >::type
+        __lshift(result_type __x) {return (__x << __count) & _Max;}
+
+    template <size_t __count>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        typename enable_if
+        <
+            (__count >= __w),
+            result_type
+        >::type
+        __lshift(result_type) {return result_type(0);}
+
+    template <size_t __count>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        typename enable_if
+        <
+            __count < _Dt,
+            result_type
+        >::type
+        __rshift(result_type __x) {return __x >> __count;}
+
+    template <size_t __count>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        typename enable_if
+        <
+            (__count >= _Dt),
+            result_type
+        >::type
+        __rshift(result_type) {return result_type(0);}
+};
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t 
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t 
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t 
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t 
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t 
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t 
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const size_t 
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::initialization_multiplier;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+    _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type
+    mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed;
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+void
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+    __t, __c, __l, __f>::seed(result_type __sd)
+{   // __w >= 2
+    __x_[0] = __sd & _Max;
+    for (size_t __i = 1; __i < __n; ++__i)
+        __x_[__i] = (__f * (__x_[__i-1] ^ __rshift<__w - 2>(__x_[__i-1])) + __i) & _Max;
+    __i_ = 0;
+}
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+template<class _Sseq>
+void
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+    __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 1>)
+{
+    const unsigned __k = 1;
+    uint32_t __ar[__n * __k];
+    __q.generate(__ar, __ar + __n * __k);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
+    const result_type __mask = __r == _Dt ? result_type(~0) :
+                                       (result_type(1) << __r) - result_type(1);
+    __i_ = 0;
+    if ((__x_[0] & ~__mask) == 0)
+    {
+        for (size_t __i = 1; __i < __n; ++__i)
+            if (__x_[__i] != 0)
+                return;
+        __x_[0] = _Max;
+    }
+}
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+template<class _Sseq>
+void
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+    __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 2>)
+{
+    const unsigned __k = 2;
+    uint32_t __ar[__n * __k];
+    __q.generate(__ar, __ar + __n * __k);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __x_[__i] = static_cast<result_type>(
+            (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
+    const result_type __mask = __r == _Dt ? result_type(~0) :
+                                       (result_type(1) << __r) - result_type(1);
+    __i_ = 0;
+    if ((__x_[0] & ~__mask) == 0)
+    {
+        for (size_t __i = 1; __i < __n; ++__i)
+            if (__x_[__i] != 0)
+                return;
+        __x_[0] = _Max;
+    }
+}
+
+template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
+          _UIntType __a, size_t __u, _UIntType __d, size_t __s,
+          _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f>
+_UIntType
+mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
+    __t, __c, __l, __f>::operator()()
+{
+    const size_t __j = (__i_ + 1) % __n;
+    const result_type __mask = __r == _Dt ? result_type(~0) :
+                                       (result_type(1) << __r) - result_type(1);
+    const result_type _Yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask);
+    const size_t __k = (__i_ + __m) % __n;
+    __x_[__i_] = __x_[__k] ^ __rshift<1>(_Yp) ^ (__a * (_Yp & 1));
+    result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d);
+    __i_ = __j;
+    __z ^= __lshift<__s>(__z) & __b;
+    __z ^= __lshift<__t>(__z) & __c;
+    return __z ^ __rshift<__l>(__z);
+}
+
+template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+bool
+operator==(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+           const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __y)
+{
+    if (__x.__i_ == __y.__i_)
+        return _VSTD::equal(__x.__x_, __x.__x_ + _Np, __y.__x_);
+    if (__x.__i_ == 0 || __y.__i_ == 0)
+    {
+        size_t __j = _VSTD::min(_Np - __x.__i_, _Np - __y.__i_);
+        if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j,
+                         __y.__x_ + __y.__i_))
+            return false;
+        if (__x.__i_ == 0)
+            return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Np, __y.__x_);
+        return _VSTD::equal(__x.__x_, __x.__x_ + (_Np - __j), __y.__x_ + __j);
+    }
+    if (__x.__i_ < __y.__i_)
+    {
+        size_t __j = _Np - __y.__i_;
+        if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j),
+                         __y.__x_ + __y.__i_))
+            return false;
+        if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Np,
+                         __y.__x_))
+            return false;
+        return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_,
+                           __y.__x_ + (_Np - (__x.__i_ + __j)));
+    }
+    size_t __j = _Np - __x.__i_;
+    if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j),
+                     __x.__x_ + __x.__i_))
+        return false;
+    if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Np,
+                     __x.__x_))
+        return false;
+    return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_,
+                       __x.__x_ + (_Np - (__y.__i_ + __j)));
+}
+
+template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __x,
+           const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                         _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.__x_[__x.__i_];
+    for (size_t __j = __x.__i_ + 1; __j < _Np; ++__j)
+        __os << __sp << __x.__x_[__j];
+    for (size_t __j = 0; __j < __x.__i_; ++__j)
+        __os << __sp << __x.__x_[__j];
+    return __os;
+}
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp,
+          _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp,
+          _UI _Bp, size_t _Tp, _UI _Cp, size_t _Lp, _UI _Fp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           mersenne_twister_engine<_UI, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp,
+                                   _Bp, _Tp, _Cp, _Lp, _Fp>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    _UI __t[_Np];
+    for (size_t __i = 0; __i < _Np; ++__i)
+        __is >> __t[__i];
+    if (!__is.fail())
+    {
+        for (size_t __i = 0; __i < _Np; ++__i)
+            __x.__x_[__i] = __t[__i];
+        __x.__i_ = 0;
+    }
+    return __is;
+}
+
+typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
+                                0x9908b0df, 11, 0xffffffff,
+                                7,  0x9d2c5680,
+                                15, 0xefc60000,
+                                18, 1812433253>                         mt19937;
+typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
+                                0xb5026f5aa96619e9ULL, 29, 0x5555555555555555ULL,
+                                17, 0x71d67fffeda60000ULL,
+                                37, 0xfff7eee000000000ULL,
+                                43, 6364136223846793005ULL>          mt19937_64;
+
+// subtract_with_carry_engine
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine;
+
+template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+bool
+operator==(
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x,
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y);
+
+template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x,
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y);
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x);
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x);
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine
+{
+public:
+    // types
+    typedef _UIntType result_type;
+
+private:
+    result_type __x_[__r];
+    result_type  __c_;
+    size_t      __i_;
+
+    static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits;
+    static_assert(  0 <  __w, "subtract_with_carry_engine invalid parameters");
+    static_assert(__w <= _Dt, "subtract_with_carry_engine invalid parameters");
+    static_assert(  0 <  __s, "subtract_with_carry_engine invalid parameters");
+    static_assert(__s <  __r, "subtract_with_carry_engine invalid parameters");
+public:
+    static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+    static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) :
+                                                      (result_type(1) << __w) - result_type(1);
+    static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters");
+
+    // engine characteristics
+    static _LIBCPP_CONSTEXPR const size_t word_size = __w;
+    static _LIBCPP_CONSTEXPR const size_t short_lag = __s;
+    static _LIBCPP_CONSTEXPR const size_t long_lag = __r;
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+    static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
+
+    // constructors and seeding functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit subtract_with_carry_engine(result_type __sd = default_seed)
+        {seed(__sd);}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit subtract_with_carry_engine(_Sseq& __q,
+        typename enable_if<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value>::type* = 0)
+        {seed(__q);}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(result_type __sd = default_seed)
+        {seed(__sd, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_seed_sequence<_Sseq, subtract_with_carry_engine>::value,
+            void
+        >::type
+        seed(_Sseq& __q)
+            {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
+
+    // generating functions
+    result_type operator()();
+    _LIBCPP_INLINE_VISIBILITY
+    void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+    template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+    friend
+    bool
+    operator==(
+        const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x,
+        const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y);
+
+    template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+    friend
+    bool
+    operator!=(
+        const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x,
+        const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y);
+
+    template <class _CharT, class _Traits,
+              class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x);
+
+    template <class _CharT, class _Traits,
+              class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x);
+
+private:
+
+    void seed(result_type __sd, integral_constant<unsigned, 1>);
+    void seed(result_type __sd, integral_constant<unsigned, 2>);
+    template<class _Sseq>
+        void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
+    template<class _Sseq>
+        void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
+};
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+    _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+    _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+    _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+    _LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type
+    subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed;
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd,
+        integral_constant<unsigned, 1>)
+{
+    linear_congruential_engine<result_type, 40014u, 0u, 2147483563u>
+        __e(__sd == 0u ? default_seed : __sd);
+    for (size_t __i = 0; __i < __r; ++__i)
+        __x_[__i] = static_cast<result_type>(__e() & _Max);
+    __c_ = __x_[__r-1] == 0;
+    __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd,
+        integral_constant<unsigned, 2>)
+{
+    linear_congruential_engine<result_type, 40014u, 0u, 2147483563u>
+        __e(__sd == 0u ? default_seed : __sd);
+    for (size_t __i = 0; __i < __r; ++__i)
+    {
+        result_type __e0 = __e();
+        __x_[__i] = static_cast<result_type>(
+                                    (__e0 + ((uint64_t)__e() << 32)) & _Max);
+    }
+    __c_ = __x_[__r-1] == 0;
+    __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+template<class _Sseq>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q,
+        integral_constant<unsigned, 1>)
+{
+    const unsigned __k = 1;
+    uint32_t __ar[__r * __k];
+    __q.generate(__ar, __ar + __r * __k);
+    for (size_t __i = 0; __i < __r; ++__i)
+        __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
+    __c_ = __x_[__r-1] == 0;
+    __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+template<class _Sseq>
+void
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q,
+        integral_constant<unsigned, 2>)
+{
+    const unsigned __k = 2;
+    uint32_t __ar[__r * __k];
+    __q.generate(__ar, __ar + __r * __k);
+    for (size_t __i = 0; __i < __r; ++__i)
+        __x_[__i] = static_cast<result_type>(
+                  (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
+    __c_ = __x_[__r-1] == 0;
+    __i_ = 0;
+}
+
+template<class _UIntType, size_t __w, size_t __s, size_t __r>
+_UIntType
+subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()()
+{
+    const result_type& __xs = __x_[(__i_ + (__r - __s)) % __r];
+    result_type& __xr = __x_[__i_];
+    result_type __new_c = __c_ == 0 ? __xs < __xr : __xs != 0 ? __xs <= __xr : 1;
+    __xr = (__xs - __xr - __c_) & _Max;
+    __c_ = __new_c;
+    __i_ = (__i_ + 1) % __r;
+    return __xr;
+}
+
+template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+bool
+operator==(
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x,
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y)
+{
+    if (__x.__c_ != __y.__c_)
+        return false;
+    if (__x.__i_ == __y.__i_)
+        return _VSTD::equal(__x.__x_, __x.__x_ + _Rp, __y.__x_);
+    if (__x.__i_ == 0 || __y.__i_ == 0)
+    {
+        size_t __j = _VSTD::min(_Rp - __x.__i_, _Rp - __y.__i_);
+        if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j,
+                         __y.__x_ + __y.__i_))
+            return false;
+        if (__x.__i_ == 0)
+            return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Rp, __y.__x_);
+        return _VSTD::equal(__x.__x_, __x.__x_ + (_Rp - __j), __y.__x_ + __j);
+    }
+    if (__x.__i_ < __y.__i_)
+    {
+        size_t __j = _Rp - __y.__i_;
+        if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j),
+                         __y.__x_ + __y.__i_))
+            return false;
+        if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Rp,
+                         __y.__x_))
+            return false;
+        return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_,
+                           __y.__x_ + (_Rp - (__x.__i_ + __j)));
+    }
+    size_t __j = _Rp - __x.__i_;
+    if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j),
+                     __x.__x_ + __x.__i_))
+        return false;
+    if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Rp,
+                     __x.__x_))
+        return false;
+    return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_,
+                       __x.__x_ + (_Rp - (__y.__i_ + __j)));
+}
+
+template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x,
+    const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.__x_[__x.__i_];
+    for (size_t __j = __x.__i_ + 1; __j < _Rp; ++__j)
+        __os << __sp << __x.__x_[__j];
+    for (size_t __j = 0; __j < __x.__i_; ++__j)
+        __os << __sp << __x.__x_[__j];
+    __os << __sp << __x.__c_;
+    return __os;
+}
+
+template <class _CharT, class _Traits,
+          class _UI, size_t _Wp, size_t _Sp, size_t _Rp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    _UI __t[_Rp+1];
+    for (size_t __i = 0; __i < _Rp+1; ++__i)
+        __is >> __t[__i];
+    if (!__is.fail())
+    {
+        for (size_t __i = 0; __i < _Rp; ++__i)
+            __x.__x_[__i] = __t[__i];
+        __x.__c_ = __t[_Rp];
+        __x.__i_ = 0;
+    }
+    return __is;
+}
+
+typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>     ranlux24_base;
+typedef subtract_with_carry_engine<uint_fast64_t, 48,  5, 12>     ranlux48_base;
+
+// discard_block_engine
+
+template<class _Engine, size_t __p, size_t __r>
+class _LIBCPP_TYPE_VIS_ONLY discard_block_engine
+{
+    _Engine __e_;
+    int     __n_;
+
+    static_assert(  0 <  __r, "discard_block_engine invalid parameters");
+    static_assert(__r <= __p, "discard_block_engine invalid parameters");
+public:
+    // types
+    typedef typename _Engine::result_type result_type;
+
+    // engine characteristics
+    static _LIBCPP_CONSTEXPR const size_t block_size = __p;
+    static _LIBCPP_CONSTEXPR const size_t used_block = __r;
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    static const result_type _Min = _Engine::_Min;
+    static const result_type _Max = _Engine::_Max;
+#else
+    static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min();
+    static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max();
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); }
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type max() { return _Engine::max(); }
+
+    // constructors and seeding functions
+    _LIBCPP_INLINE_VISIBILITY
+    discard_block_engine() : __n_(0) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit discard_block_engine(const _Engine& __e)
+        : __e_(__e), __n_(0) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit discard_block_engine(_Engine&& __e)
+        : __e_(_VSTD::move(__e)), __n_(0) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit discard_block_engine(_Sseq& __q,
+        typename enable_if<__is_seed_sequence<_Sseq, discard_block_engine>::value &&
+                           !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+        : __e_(__q), __n_(0) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed() {__e_.seed(); __n_ = 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(result_type __sd) {__e_.seed(__sd); __n_ = 0;}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_seed_sequence<_Sseq, discard_block_engine>::value,
+            void
+        >::type
+        seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;}
+
+    // generating functions
+    result_type operator()();
+    _LIBCPP_INLINE_VISIBILITY
+    void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    const _Engine& base() const _NOEXCEPT {return __e_;}
+
+    template<class _Eng, size_t _Pp, size_t _Rp>
+    friend
+    bool
+    operator==(
+        const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+        const discard_block_engine<_Eng, _Pp, _Rp>& __y);
+
+    template<class _Eng, size_t _Pp, size_t _Rp>
+    friend
+    bool
+    operator!=(
+        const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+        const discard_block_engine<_Eng, _Pp, _Rp>& __y);
+
+    template <class _CharT, class _Traits,
+              class _Eng, size_t _Pp, size_t _Rp>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const discard_block_engine<_Eng, _Pp, _Rp>& __x);
+
+    template <class _CharT, class _Traits,
+              class _Eng, size_t _Pp, size_t _Rp>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               discard_block_engine<_Eng, _Pp, _Rp>& __x);
+};
+
+template<class _Engine, size_t __p, size_t __r>
+    _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size;
+
+template<class _Engine, size_t __p, size_t __r>
+    _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block;
+
+template<class _Engine, size_t __p, size_t __r>
+typename discard_block_engine<_Engine, __p, __r>::result_type
+discard_block_engine<_Engine, __p, __r>::operator()()
+{
+    if (__n_ >= __r)
+    {
+        __e_.discard(__p - __r);
+        __n_ = 0;
+    }
+    ++__n_;
+    return __e_();
+}
+
+template<class _Eng, size_t _Pp, size_t _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+           const discard_block_engine<_Eng, _Pp, _Rp>& __y)
+{
+    return __x.__n_ == __y.__n_ && __x.__e_ == __y.__e_;
+}
+
+template<class _Eng, size_t _Pp, size_t _Rp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x,
+           const discard_block_engine<_Eng, _Pp, _Rp>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+          class _Eng, size_t _Pp, size_t _Rp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const discard_block_engine<_Eng, _Pp, _Rp>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    return __os << __x.__e_ << __sp << __x.__n_;
+}
+
+template <class _CharT, class _Traits,
+          class _Eng, size_t _Pp, size_t _Rp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           discard_block_engine<_Eng, _Pp, _Rp>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    _Eng __e;
+    int __n;
+    __is >> __e >> __n;
+    if (!__is.fail())
+    {
+        __x.__e_ = __e;
+        __x.__n_ = __n;
+    }
+    return __is;
+}
+
+typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
+typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
+
+// independent_bits_engine
+
+template<class _Engine, size_t __w, class _UIntType>
+class _LIBCPP_TYPE_VIS_ONLY independent_bits_engine
+{
+    template <class _UI, _UI _R0, size_t _Wp, size_t _Mp>
+    class __get_n
+    {
+        static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UI>::digits;
+        static _LIBCPP_CONSTEXPR const size_t _Np = _Wp / _Mp + (_Wp % _Mp != 0);
+        static _LIBCPP_CONSTEXPR const size_t _W0 = _Wp / _Np;
+        static _LIBCPP_CONSTEXPR const _UI _Y0 = _W0 >= _Dt ? 0 : (_R0 >> _W0) << _W0;
+    public:
+        static _LIBCPP_CONSTEXPR const size_t value = _R0 - _Y0 > _Y0 / _Np ? _Np + 1 : _Np;
+    };
+public:
+    // types
+    typedef _UIntType result_type;
+
+private:
+    _Engine __e_;
+
+    static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits;
+    static_assert(  0 <  __w, "independent_bits_engine invalid parameters");
+    static_assert(__w <= _Dt, "independent_bits_engine invalid parameters");
+
+    typedef typename _Engine::result_type _Engine_result_type;
+    typedef typename conditional
+        <
+            sizeof(_Engine_result_type) <= sizeof(result_type),
+                result_type,
+                _Engine_result_type
+        >::type _Working_result_type;
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min
+                                          + _Working_result_type(1);
+#else
+    static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min()
+                                                            + _Working_result_type(1);
+#endif
+    static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value;
+    static _LIBCPP_CONSTEXPR const size_t __n = __get_n<_Working_result_type, _Rp, __w, __m>::value;
+    static _LIBCPP_CONSTEXPR const size_t __w0 = __w / __n;
+    static _LIBCPP_CONSTEXPR const size_t __n0 = __n - __w % __n;
+    static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits;
+    static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits;
+    static _LIBCPP_CONSTEXPR const _Working_result_type __y0 = __w0 >= _WDt ? 0 :
+                                                               (_Rp >> __w0) << __w0;
+    static _LIBCPP_CONSTEXPR const _Working_result_type __y1 = __w0 >= _WDt - 1 ? 0 :
+                                                               (_Rp >> (__w0+1)) << (__w0+1);
+    static _LIBCPP_CONSTEXPR const _Engine_result_type __mask0 = __w0 > 0 ?
+                                _Engine_result_type(~0) >> (_EDt - __w0) :
+                                _Engine_result_type(0);
+    static _LIBCPP_CONSTEXPR const _Engine_result_type __mask1 = __w0 < _EDt - 1 ?
+                                _Engine_result_type(~0) >> (_EDt - (__w0 + 1)) :
+                                _Engine_result_type(~0);
+public:
+    static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+    static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) :
+                                                      (result_type(1) << __w) - result_type(1);
+    static_assert(_Min < _Max, "independent_bits_engine invalid parameters");
+
+    // engine characteristics
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+
+    // constructors and seeding functions
+    _LIBCPP_INLINE_VISIBILITY
+    independent_bits_engine() {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit independent_bits_engine(const _Engine& __e)
+        : __e_(__e) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit independent_bits_engine(_Engine&& __e)
+        : __e_(_VSTD::move(__e)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit independent_bits_engine(result_type __sd) : __e_(__sd) {}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit independent_bits_engine(_Sseq& __q,
+        typename enable_if<__is_seed_sequence<_Sseq, independent_bits_engine>::value &&
+                           !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+         : __e_(__q) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed() {__e_.seed();}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(result_type __sd) {__e_.seed(__sd);}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_seed_sequence<_Sseq, independent_bits_engine>::value,
+            void
+        >::type
+        seed(_Sseq& __q) {__e_.seed(__q);}
+
+    // generating functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
+    _LIBCPP_INLINE_VISIBILITY
+    void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    const _Engine& base() const _NOEXCEPT {return __e_;}
+
+    template<class _Eng, size_t _Wp, class _UI>
+    friend
+    bool
+    operator==(
+        const independent_bits_engine<_Eng, _Wp, _UI>& __x,
+        const independent_bits_engine<_Eng, _Wp, _UI>& __y);
+
+    template<class _Eng, size_t _Wp, class _UI>
+    friend
+    bool
+    operator!=(
+        const independent_bits_engine<_Eng, _Wp, _UI>& __x,
+        const independent_bits_engine<_Eng, _Wp, _UI>& __y);
+
+    template <class _CharT, class _Traits,
+              class _Eng, size_t _Wp, class _UI>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const independent_bits_engine<_Eng, _Wp, _UI>& __x);
+
+    template <class _CharT, class _Traits,
+              class _Eng, size_t _Wp, class _UI>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               independent_bits_engine<_Eng, _Wp, _UI>& __x);
+
+private:
+    result_type __eval(false_type);
+    result_type __eval(true_type);
+
+    template <size_t __count>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        typename enable_if
+        <
+            __count < _Dt,
+            result_type
+        >::type
+        __lshift(result_type __x) {return __x << __count;}
+
+    template <size_t __count>
+        _LIBCPP_INLINE_VISIBILITY
+        static
+        typename enable_if
+        <
+            (__count >= _Dt),
+            result_type
+        >::type
+        __lshift(result_type) {return result_type(0);}
+};
+
+template<class _Engine, size_t __w, class _UIntType>
+inline _LIBCPP_INLINE_VISIBILITY
+_UIntType
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type)
+{
+    return static_cast<result_type>(__e_() & __mask0);
+}
+
+template<class _Engine, size_t __w, class _UIntType>
+_UIntType
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type)
+{
+    result_type _Sp = 0;
+    for (size_t __k = 0; __k < __n0; ++__k)
+    {
+        _Engine_result_type __u;
+        do
+        {
+            __u = __e_() - _Engine::min();
+        } while (__u >= __y0);
+        _Sp = static_cast<result_type>(__lshift<__w0>(_Sp) + (__u & __mask0));
+    }
+    for (size_t __k = __n0; __k < __n; ++__k)
+    {
+        _Engine_result_type __u;
+        do
+        {
+            __u = __e_() - _Engine::min();
+        } while (__u >= __y1);
+        _Sp = static_cast<result_type>(__lshift<__w0+1>(_Sp) + (__u & __mask1));
+    }
+    return _Sp;
+}
+
+template<class _Eng, size_t _Wp, class _UI>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(
+    const independent_bits_engine<_Eng, _Wp, _UI>& __x,
+    const independent_bits_engine<_Eng, _Wp, _UI>& __y)
+{
+    return __x.base() == __y.base();
+}
+
+template<class _Eng, size_t _Wp, class _UI>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+    const independent_bits_engine<_Eng, _Wp, _UI>& __x,
+    const independent_bits_engine<_Eng, _Wp, _UI>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+          class _Eng, size_t _Wp, class _UI>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const independent_bits_engine<_Eng, _Wp, _UI>& __x)
+{
+    return __os << __x.base();
+}
+
+template <class _CharT, class _Traits,
+          class _Eng, size_t _Wp, class _UI>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           independent_bits_engine<_Eng, _Wp, _UI>& __x)
+{
+    _Eng __e;
+    __is >> __e;
+    if (!__is.fail())
+        __x.__e_ = __e;
+    return __is;
+}
+
+// shuffle_order_engine
+
+template <uint64_t _Xp, uint64_t _Yp>
+struct __ugcd
+{
+    static _LIBCPP_CONSTEXPR const uint64_t value = __ugcd<_Yp, _Xp % _Yp>::value;
+};
+
+template <uint64_t _Xp>
+struct __ugcd<_Xp, 0>
+{
+    static _LIBCPP_CONSTEXPR const uint64_t value = _Xp;
+};
+
+template <uint64_t _Np, uint64_t _Dp>
+class __uratio
+{
+    static_assert(_Dp != 0, "__uratio divide by 0");
+    static _LIBCPP_CONSTEXPR const uint64_t __gcd = __ugcd<_Np, _Dp>::value;
+public:
+    static _LIBCPP_CONSTEXPR const uint64_t num = _Np / __gcd;
+    static _LIBCPP_CONSTEXPR const uint64_t den = _Dp / __gcd;
+
+    typedef __uratio<num, den> type;
+};
+
+template<class _Engine, size_t __k>
+class _LIBCPP_TYPE_VIS_ONLY shuffle_order_engine
+{
+    static_assert(0 < __k, "shuffle_order_engine invalid parameters");
+public:
+    // types
+    typedef typename _Engine::result_type result_type;
+
+private:
+    _Engine __e_;
+    result_type _V_[__k];
+    result_type _Y_;
+
+public:
+    // engine characteristics
+    static _LIBCPP_CONSTEXPR const size_t table_size = __k;
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    static const result_type _Min = _Engine::_Min;
+    static const result_type _Max = _Engine::_Max;
+#else
+    static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min();
+    static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max();
+#endif
+    static_assert(_Min < _Max, "shuffle_order_engine invalid parameters");
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
+
+    static _LIBCPP_CONSTEXPR const unsigned long long _Rp = _Max - _Min + 1ull;
+
+    // constructors and seeding functions
+    _LIBCPP_INLINE_VISIBILITY
+    shuffle_order_engine() {__init();}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit shuffle_order_engine(const _Engine& __e)
+        : __e_(__e) {__init();}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit shuffle_order_engine(_Engine&& __e)
+        : __e_(_VSTD::move(__e)) {__init();}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit shuffle_order_engine(_Sseq& __q,
+        typename enable_if<__is_seed_sequence<_Sseq, shuffle_order_engine>::value &&
+                           !is_convertible<_Sseq, _Engine>::value>::type* = 0)
+         : __e_(__q) {__init();}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed() {__e_.seed(); __init();}
+    _LIBCPP_INLINE_VISIBILITY
+    void seed(result_type __sd) {__e_.seed(__sd); __init();}
+    template<class _Sseq>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_seed_sequence<_Sseq, shuffle_order_engine>::value,
+            void
+        >::type
+        seed(_Sseq& __q) {__e_.seed(__q); __init();}
+
+    // generating functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());}
+    _LIBCPP_INLINE_VISIBILITY
+    void discard(unsigned long long __z) {for (; __z; --__z) operator()();}
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    const _Engine& base() const _NOEXCEPT {return __e_;}
+
+private:
+    template<class _Eng, size_t _Kp>
+    friend
+    bool
+    operator==(
+        const shuffle_order_engine<_Eng, _Kp>& __x,
+        const shuffle_order_engine<_Eng, _Kp>& __y);
+
+    template<class _Eng, size_t _Kp>
+    friend
+    bool
+    operator!=(
+        const shuffle_order_engine<_Eng, _Kp>& __x,
+        const shuffle_order_engine<_Eng, _Kp>& __y);
+
+    template <class _CharT, class _Traits,
+              class _Eng, size_t _Kp>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const shuffle_order_engine<_Eng, _Kp>& __x);
+
+    template <class _CharT, class _Traits,
+              class _Eng, size_t _Kp>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               shuffle_order_engine<_Eng, _Kp>& __x);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __init()
+    {
+        for (size_t __i = 0; __i < __k; ++__i)
+            _V_[__i] = __e_();
+        _Y_ = __e_();
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type __eval(false_type) {return __eval2(integral_constant<bool, __k & 1>());}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type __eval(true_type) {return __eval(__uratio<__k, _Rp>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type __eval2(false_type) {return __eval(__uratio<__k/2, 0x8000000000000000ull>());}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type __eval2(true_type) {return __evalf<__k, 0>();}
+
+    template <uint64_t _Np, uint64_t _Dp>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            (__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)),
+            result_type
+        >::type
+        __eval(__uratio<_Np, _Dp>)
+            {return __evalf<__uratio<_Np, _Dp>::num, __uratio<_Np, _Dp>::den>();}
+
+    template <uint64_t _Np, uint64_t _Dp>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min),
+            result_type
+        >::type
+        __eval(__uratio<_Np, _Dp>)
+        {
+            const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (_Y_ - _Min)
+                                                   / __uratio<_Np, _Dp>::den);
+            _Y_ = _V_[__j];
+            _V_[__j] = __e_();
+            return _Y_;
+        }
+
+    template <uint64_t __n, uint64_t __d>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type __evalf()
+        {
+            const double _Fp = __d == 0 ?
+                __n / (2. * 0x8000000000000000ull) :
+                __n / (double)__d;
+            const size_t __j = static_cast<size_t>(_Fp * (_Y_ - _Min));
+            _Y_ = _V_[__j];
+            _V_[__j] = __e_();
+            return _Y_;
+        }
+};
+
+template<class _Engine, size_t __k>
+    _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;
+
+template<class _Eng, size_t _Kp>
+bool
+operator==(
+    const shuffle_order_engine<_Eng, _Kp>& __x,
+    const shuffle_order_engine<_Eng, _Kp>& __y)
+{
+    return __x._Y_ == __y._Y_ && _VSTD::equal(__x._V_, __x._V_ + _Kp, __y._V_) &&
+           __x.__e_ == __y.__e_;
+}
+
+template<class _Eng, size_t _Kp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(
+    const shuffle_order_engine<_Eng, _Kp>& __x,
+    const shuffle_order_engine<_Eng, _Kp>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _CharT, class _Traits,
+          class _Eng, size_t _Kp>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const shuffle_order_engine<_Eng, _Kp>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.__e_ << __sp << __x._V_[0];
+    for (size_t __i = 1; __i < _Kp; ++__i)
+        __os << __sp << __x._V_[__i];
+    return __os << __sp << __x._Y_;
+}
+
+template <class _CharT, class _Traits,
+          class _Eng, size_t _Kp>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           shuffle_order_engine<_Eng, _Kp>& __x)
+{
+    typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type;
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    _Eng __e;
+    result_type _Vp[_Kp+1];
+    __is >> __e;
+    for (size_t __i = 0; __i < _Kp+1; ++__i)
+        __is >> _Vp[__i];
+    if (!__is.fail())
+    {
+        __x.__e_ = __e;
+        for (size_t __i = 0; __i < _Kp; ++__i)
+            __x._V_[__i] = _Vp[__i];
+        __x._Y_ = _Vp[_Kp];
+    }
+    return __is;
+}
+
+typedef shuffle_order_engine<minstd_rand0, 256>                         knuth_b;
+
+// random_device
+
+class _LIBCPP_TYPE_VIS random_device
+{
+#if !defined(_WIN32)
+    int __f_;
+#endif // defined(_WIN32)
+public:
+    // types
+    typedef unsigned result_type;
+
+    // generator characteristics
+    static _LIBCPP_CONSTEXPR const result_type _Min = 0;
+    static _LIBCPP_CONSTEXPR const result_type _Max = 0xFFFFFFFFu;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type min() { return _Min;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR result_type max() { return _Max;}
+
+    // constructors
+    explicit random_device(const string& __token = "/dev/urandom");
+    ~random_device();
+
+    // generating functions
+    result_type operator()();
+
+    // property functions
+    double entropy() const _NOEXCEPT;
+
+private:
+    // no copy functions
+    random_device(const random_device&); // = delete;
+    random_device& operator=(const random_device&); // = delete;
+};
+
+// seed_seq
+
+class _LIBCPP_TYPE_VIS_ONLY seed_seq
+{
+public:
+    // types
+    typedef uint32_t result_type;
+
+private:
+    vector<result_type> __v_;
+
+    template<class _InputIterator>
+        void init(_InputIterator __first, _InputIterator __last);
+public:
+    // constructors
+    _LIBCPP_INLINE_VISIBILITY
+    seed_seq() _NOEXCEPT {}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    template<class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        seed_seq(initializer_list<_Tp> __il) {init(__il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template<class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        seed_seq(_InputIterator __first, _InputIterator __last)
+             {init(__first, __last);}
+
+    // generating functions
+    template<class _RandomAccessIterator>
+        void generate(_RandomAccessIterator __first, _RandomAccessIterator __last);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const _NOEXCEPT {return __v_.size();}
+    template<class _OutputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        void param(_OutputIterator __dest) const
+            {_VSTD::copy(__v_.begin(), __v_.end(), __dest);}
+
+private:
+    // no copy functions
+    seed_seq(const seed_seq&); // = delete;
+    void operator=(const seed_seq&); // = delete;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static result_type _Tp(result_type __x) {return __x ^ (__x >> 27);}
+};
+
+template<class _InputIterator>
+void
+seed_seq::init(_InputIterator __first, _InputIterator __last)
+{
+    for (_InputIterator __s = __first; __s != __last; ++__s)
+        __v_.push_back(*__s & 0xFFFFFFFF);
+}
+
+template<class _RandomAccessIterator>
+void
+seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last)
+{
+    if (__first != __last)
+    {
+        _VSTD::fill(__first, __last, 0x8b8b8b8b);
+        const size_t __n = static_cast<size_t>(__last - __first);
+        const size_t __s = __v_.size();
+        const size_t __t = (__n >= 623) ? 11
+                         : (__n >= 68) ? 7
+                         : (__n >= 39) ? 5
+                         : (__n >= 7)  ? 3
+                         : (__n - 1) / 2;
+        const size_t __p = (__n - __t) / 2;
+        const size_t __q = __p + __t;
+        const size_t __m = _VSTD::max(__s + 1, __n);
+        // __k = 0;
+        {
+            result_type __r = 1664525 * _Tp(__first[0] ^ __first[__p]
+                                                      ^  __first[__n - 1]);
+            __first[__p] += __r;
+            __r += __s;
+            __first[__q] += __r;
+            __first[0] = __r;
+        }
+        for (size_t __k = 1; __k <= __s; ++__k)
+        {
+            const size_t __kmodn = __k % __n;
+            const size_t __kpmodn = (__k + __p) % __n;
+            result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]
+                                           ^ __first[(__k - 1) % __n]);
+            __first[__kpmodn] += __r;
+            __r +=  __kmodn + __v_[__k-1];
+            __first[(__k + __q) % __n] += __r;
+            __first[__kmodn] = __r;
+        }
+        for (size_t __k = __s + 1; __k < __m; ++__k)
+        {
+            const size_t __kmodn = __k % __n;
+            const size_t __kpmodn = (__k + __p) % __n;
+            result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn]
+                                           ^ __first[(__k - 1) % __n]);
+            __first[__kpmodn] += __r;
+            __r +=  __kmodn;
+            __first[(__k + __q) % __n] += __r;
+            __first[__kmodn] = __r;
+        }
+        for (size_t __k = __m; __k < __m + __n; ++__k)
+        {
+            const size_t __kmodn = __k % __n;
+            const size_t __kpmodn = (__k + __p) % __n;
+            result_type __r = 1566083941 * _Tp(__first[__kmodn] +
+                                              __first[__kpmodn] +
+                                              __first[(__k - 1) % __n]);
+            __first[__kpmodn] ^= __r;
+            __r -= __kmodn;
+            __first[(__k + __q) % __n] ^= __r;
+            __first[__kmodn] = __r;
+        }
+    }
+}
+
+// generate_canonical
+
+template<class _RealType, size_t __bits, class _URNG>
+_RealType
+generate_canonical(_URNG& __g)
+{
+    const size_t _Dt = numeric_limits<_RealType>::digits;
+    const size_t __b = _Dt < __bits ? _Dt : __bits;
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    const size_t __logR = __log2<uint64_t, _URNG::_Max - _URNG::_Min + uint64_t(1)>::value;
+#else
+    const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value;
+#endif
+    const size_t __k = __b / __logR + (__b % __logR != 0) + (__b == 0);
+    const _RealType _Rp = _URNG::max() - _URNG::min() + _RealType(1);
+    _RealType __base = _Rp;
+    _RealType _Sp = __g() - _URNG::min();
+    for (size_t __i = 1; __i < __k; ++__i, __base *= _Rp)
+        _Sp += (__g() - _URNG::min()) * __base;
+    return _Sp / __base;
+}
+
+// uniform_int_distribution
+
+// in <algorithm>
+
+template <class _CharT, class _Traits, class _IT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const uniform_int_distribution<_IT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    return __os << __x.a() << __sp << __x.b();
+}
+
+template <class _CharT, class _Traits, class _IT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           uniform_int_distribution<_IT>& __x)
+{
+    typedef uniform_int_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);
+    result_type __a;
+    result_type __b;
+    __is >> __a >> __b;
+    if (!__is.fail())
+        __x.param(param_type(__a, __b));
+    return __is;
+}
+
+// uniform_real_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY uniform_real_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __a_;
+        result_type __b_;
+    public:
+        typedef uniform_real_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __a = 0,
+                            result_type __b = 1)
+            : __a_(__a), __b_(__b) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type a() const {return __a_;}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type b() const {return __b_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit uniform_real_distribution(result_type __a = 0, result_type __b = 1)
+        : __p_(param_type(__a, __b)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit uniform_real_distribution(const param_type& __p) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type a() const {return __p_.a();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type b() const {return __p_.b();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return a();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return b();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const uniform_real_distribution& __x,
+                        const uniform_real_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const uniform_real_distribution& __x,
+                        const uniform_real_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template<class _RealType>
+template<class _URNG>
+inline _LIBCPP_INLINE_VISIBILITY
+typename uniform_real_distribution<_RealType>::result_type
+uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    return (__p.b() - __p.a())
+        * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
+        + __p.a();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const uniform_real_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    return __os << __x.a() << __sp << __x.b();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           uniform_real_distribution<_RT>& __x)
+{
+    typedef uniform_real_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);
+    result_type __a;
+    result_type __b;
+    __is >> __a >> __b;
+    if (!__is.fail())
+        __x.param(param_type(__a, __b));
+    return __is;
+}
+
+// bernoulli_distribution
+
+class _LIBCPP_TYPE_VIS_ONLY bernoulli_distribution
+{
+public:
+    // types
+    typedef bool result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        double __p_;
+    public:
+        typedef bernoulli_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(double __p = 0.5) : __p_(__p) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        double p() const {return __p_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__p_ == __y.__p_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit bernoulli_distribution(double __p = 0.5)
+        : __p_(param_type(__p)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit bernoulli_distribution(const param_type& __p) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    double p() const {return __p_.p();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return false;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return true;}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const bernoulli_distribution& __x,
+                        const bernoulli_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const bernoulli_distribution& __x,
+                        const bernoulli_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template<class _URNG>
+inline _LIBCPP_INLINE_VISIBILITY
+bernoulli_distribution::result_type
+bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
+{
+    uniform_real_distribution<double> __gen;
+    return __gen(__g) < __p.p();
+}
+
+template <class _CharT, class _Traits>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    return __os << __x.p();
+}
+
+template <class _CharT, class _Traits>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x)
+{
+    typedef bernoulli_distribution _Eng;
+    typedef typename _Eng::param_type param_type;
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    double __p;
+    __is >> __p;
+    if (!__is.fail())
+        __x.param(param_type(__p));
+    return __is;
+}
+
+// binomial_distribution
+
+template<class _IntType = int>
+class _LIBCPP_TYPE_VIS_ONLY binomial_distribution
+{
+public:
+    // types
+    typedef _IntType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __t_;
+        double __p_;
+        double __pr_;
+        double __odds_ratio_;
+        result_type __r0_;
+    public:
+        typedef binomial_distribution distribution_type;
+
+        explicit param_type(result_type __t = 1, double __p = 0.5);
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type t() const {return __t_;}
+        _LIBCPP_INLINE_VISIBILITY
+        double p() const {return __p_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__t_ == __y.__t_ && __x.__p_ == __y.__p_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+
+        friend class binomial_distribution;
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit binomial_distribution(result_type __t = 1, double __p = 0.5)
+        : __p_(param_type(__t, __p)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit binomial_distribution(const param_type& __p) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type t() const {return __p_.t();}
+    _LIBCPP_INLINE_VISIBILITY
+    double p() const {return __p_.p();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return t();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const binomial_distribution& __x,
+                        const binomial_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const binomial_distribution& __x,
+                        const binomial_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template<class _IntType>
+binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p)
+    : __t_(__t), __p_(__p)
+{
+    if (0 < __p_ && __p_ < 1)
+    {
+        __r0_ = static_cast<result_type>((__t_ + 1) * __p_);
+        __pr_ = _VSTD::exp(_VSTD::lgamma(__t_ + 1.) - _VSTD::lgamma(__r0_ + 1.) -
+                          _VSTD::lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) +
+                          (__t_ - __r0_) * _VSTD::log(1 - __p_));
+        __odds_ratio_ = __p_ / (1 - __p_);
+    }
+}
+
+template<class _IntType>
+template<class _URNG>
+_IntType
+binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
+{
+    if (__pr.__t_ == 0 || __pr.__p_ == 0)
+        return 0;
+    if (__pr.__p_ == 1)
+        return __pr.__t_;
+    uniform_real_distribution<double> __gen;
+    double __u = __gen(__g) - __pr.__pr_;
+    if (__u < 0)
+        return __pr.__r0_;
+    double __pu = __pr.__pr_;
+    double __pd = __pu;
+    result_type __ru = __pr.__r0_;
+    result_type __rd = __ru;
+    while (true)
+    {
+        if (__rd >= 1)
+        {
+            __pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1));
+            __u -= __pd;
+            if (__u < 0)
+                return __rd - 1;
+        }
+        --__rd;
+        ++__ru;
+        if (__ru <= __pr.__t_)
+        {
+            __pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru;
+            __u -= __pu;
+            if (__u < 0)
+                return __ru;
+        }
+    }
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const binomial_distribution<_IntType>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    return __os << __x.t() << __sp << __x.p();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           binomial_distribution<_IntType>& __x)
+{
+    typedef binomial_distribution<_IntType> _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);
+    result_type __t;
+    double __p;
+    __is >> __t >> __p;
+    if (!__is.fail())
+        __x.param(param_type(__t, __p));
+    return __is;
+}
+
+// exponential_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY exponential_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __lambda_;
+    public:
+        typedef exponential_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __lambda = 1) : __lambda_(__lambda) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type lambda() const {return __lambda_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__lambda_ == __y.__lambda_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit exponential_distribution(result_type __lambda = 1)
+        : __p_(param_type(__lambda)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit exponential_distribution(const param_type& __p) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type lambda() const {return __p_.lambda();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const exponential_distribution& __x,
+                        const exponential_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const exponential_distribution& __x,
+                        const exponential_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    return -_VSTD::log
+                  (
+                      result_type(1) -
+                      _VSTD::generate_canonical<result_type,
+                                       numeric_limits<result_type>::digits>(__g)
+                  )
+                  / __p.lambda();
+}
+
+template <class _CharT, class _Traits, class _RealType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const exponential_distribution<_RealType>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    return __os << __x.lambda();
+}
+
+template <class _CharT, class _Traits, class _RealType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           exponential_distribution<_RealType>& __x)
+{
+    typedef exponential_distribution<_RealType> _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);
+    result_type __lambda;
+    __is >> __lambda;
+    if (!__is.fail())
+        __x.param(param_type(__lambda));
+    return __is;
+}
+
+// normal_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY normal_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __mean_;
+        result_type __stddev_;
+    public:
+        typedef normal_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __mean = 0, result_type __stddev = 1)
+            : __mean_(__mean), __stddev_(__stddev) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type mean() const {return __mean_;}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type stddev() const {return __stddev_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__mean_ == __y.__mean_ && __x.__stddev_ == __y.__stddev_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+    result_type _V_;
+    bool _V_hot_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit normal_distribution(result_type __mean = 0, result_type __stddev = 1)
+        : __p_(param_type(__mean, __stddev)), _V_hot_(false) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit normal_distribution(const param_type& __p)
+        : __p_(__p), _V_hot_(false) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {_V_hot_ = false;}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type mean() const {return __p_.mean();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type stddev() const {return __p_.stddev();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return -numeric_limits<result_type>::infinity();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const normal_distribution& __x,
+                        const normal_distribution& __y)
+        {return __x.__p_ == __y.__p_ && __x._V_hot_ == __y._V_hot_ &&
+                (!__x._V_hot_ || __x._V_ == __y._V_);}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const normal_distribution& __x,
+                        const normal_distribution& __y)
+        {return !(__x == __y);}
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const normal_distribution<_RT>& __x);
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               normal_distribution<_RT>& __x);
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    result_type _Up;
+    if (_V_hot_)
+    {
+        _V_hot_ = false;
+        _Up = _V_;
+    }
+    else
+    {
+        uniform_real_distribution<result_type> _Uni(-1, 1);
+        result_type __u;
+        result_type __v;
+        result_type __s;
+        do
+        {
+            __u = _Uni(__g);
+            __v = _Uni(__g);
+            __s = __u * __u + __v * __v;
+        } while (__s > 1 || __s == 0);
+        result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s);
+        _V_ = __v * _Fp;
+        _V_hot_ = true;
+        _Up = __u * _Fp;
+    }
+    return _Up * __p.stddev() + __p.mean();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const normal_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_;
+    if (__x._V_hot_)
+        __os << __sp << __x._V_;
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           normal_distribution<_RT>& __x)
+{
+    typedef normal_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);
+    result_type __mean;
+    result_type __stddev;
+    result_type _Vp = 0;
+    bool _V_hot = false;
+    __is >> __mean >> __stddev >> _V_hot;
+    if (_V_hot)
+        __is >> _Vp;
+    if (!__is.fail())
+    {
+        __x.param(param_type(__mean, __stddev));
+        __x._V_hot_ = _V_hot;
+        __x._V_ = _Vp;
+    }
+    return __is;
+}
+
+// lognormal_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY lognormal_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        normal_distribution<result_type> __nd_;
+    public:
+        typedef lognormal_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __m = 0, result_type __s = 1)
+            : __nd_(__m, __s) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type m() const {return __nd_.mean();}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type s() const {return __nd_.stddev();}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__nd_ == __y.__nd_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+        friend class lognormal_distribution;
+
+        template <class _CharT, class _Traits, class _RT>
+        friend
+        basic_ostream<_CharT, _Traits>&
+        operator<<(basic_ostream<_CharT, _Traits>& __os,
+                   const lognormal_distribution<_RT>& __x);
+
+        template <class _CharT, class _Traits, class _RT>
+        friend
+        basic_istream<_CharT, _Traits>&
+        operator>>(basic_istream<_CharT, _Traits>& __is,
+                   lognormal_distribution<_RT>& __x);
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit lognormal_distribution(result_type __m = 0, result_type __s = 1)
+        : __p_(param_type(__m, __s)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit lognormal_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {__p_.__nd_.reset();}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g, const param_type& __p)
+        {return _VSTD::exp(const_cast<normal_distribution<result_type>&>(__p.__nd_)(__g));}
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type m() const {return __p_.m();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type s() const {return __p_.s();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const lognormal_distribution& __x,
+                        const lognormal_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const lognormal_distribution& __x,
+                        const lognormal_distribution& __y)
+        {return !(__x == __y);}
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const lognormal_distribution<_RT>& __x);
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               lognormal_distribution<_RT>& __x);
+};
+
+template <class _CharT, class _Traits, class _RT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const lognormal_distribution<_RT>& __x)
+{
+    return __os << __x.__p_.__nd_;
+}
+
+template <class _CharT, class _Traits, class _RT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           lognormal_distribution<_RT>& __x)
+{
+    return __is >> __x.__p_.__nd_;
+}
+
+// poisson_distribution
+
+template<class _IntType = int>
+class _LIBCPP_TYPE_VIS_ONLY poisson_distribution
+{
+public:
+    // types
+    typedef _IntType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        double __mean_;
+        double __s_;
+        double __d_;
+        double __l_;
+        double __omega_;
+        double __c0_;
+        double __c1_;
+        double __c2_;
+        double __c3_;
+        double __c_;
+
+    public:
+        typedef poisson_distribution distribution_type;
+
+        explicit param_type(double __mean = 1.0);
+
+        _LIBCPP_INLINE_VISIBILITY
+        double mean() const {return __mean_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__mean_ == __y.__mean_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+
+        friend class poisson_distribution;
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit poisson_distribution(double __mean = 1.0) : __p_(__mean) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit poisson_distribution(const param_type& __p) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    double mean() const {return __p_.mean();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::max();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const poisson_distribution& __x,
+                        const poisson_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const poisson_distribution& __x,
+                        const poisson_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template<class _IntType>
+poisson_distribution<_IntType>::param_type::param_type(double __mean)
+    : __mean_(__mean)
+{
+    if (__mean_ < 10)
+    {
+        __s_ = 0;
+        __d_ = 0;
+        __l_ = _VSTD::exp(-__mean_);
+        __omega_ = 0;
+        __c3_ = 0;
+        __c2_ = 0;
+        __c1_ = 0;
+        __c0_ = 0;
+        __c_ = 0;
+    }
+    else
+    {
+        __s_ = _VSTD::sqrt(__mean_);
+        __d_ = 6 * __mean_ * __mean_;
+        __l_ = static_cast<result_type>(__mean_ - 1.1484);
+        __omega_ = .3989423 / __s_;
+        double __b1_ = .4166667E-1 / __mean_;
+        double __b2_ = .3 * __b1_ * __b1_;
+        __c3_ = .1428571 * __b1_ * __b2_;
+        __c2_ = __b2_ - 15. * __c3_;
+        __c1_ = __b1_ - 6. * __b2_ + 45. * __c3_;
+        __c0_ = 1. - __b1_ + 3. * __b2_ - 15. * __c3_;
+        __c_ = .1069 / __mean_;
+    }
+}
+
+template <class _IntType>
+template<class _URNG>
+_IntType
+poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
+{
+    result_type __x;
+    uniform_real_distribution<double> __urd;
+    if (__pr.__mean_ < 10)
+    {
+         __x = 0;
+        for (double __p = __urd(__urng); __p > __pr.__l_; ++__x)
+            __p *= __urd(__urng);
+    }
+    else
+    {
+        double __difmuk;
+        double __g = __pr.__mean_ + __pr.__s_ * normal_distribution<double>()(__urng);
+        double __u;
+        if (__g > 0)
+        {
+            __x = static_cast<result_type>(__g);
+            if (__x >= __pr.__l_)
+                return __x;
+            __difmuk = __pr.__mean_ - __x;
+            __u = __urd(__urng);
+            if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk)
+                return __x;
+        }
+        exponential_distribution<double> __edist;
+        for (bool __using_exp_dist = false; true; __using_exp_dist = true)
+        {
+            double __e;
+            if (__using_exp_dist || __g < 0)
+            {
+                double __t;
+                do
+                {
+                    __e = __edist(__urng);
+                    __u = __urd(__urng);
+                    __u += __u - 1;
+                    __t = 1.8 + (__u < 0 ? -__e : __e);
+                } while (__t <= -.6744);
+                __x = __pr.__mean_ + __pr.__s_ * __t;
+                __difmuk = __pr.__mean_ - __x;
+                __using_exp_dist = true;
+            }
+            double __px;
+            double __py;
+            if (__x < 10)
+            {
+                const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
+                                             40320, 362880};
+                __px = -__pr.__mean_;
+                __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x];
+            }
+            else
+            {
+                double __del = .8333333E-1 / __x;
+                __del -= 4.8 * __del * __del * __del;
+                double __v = __difmuk / __x;
+                if (_VSTD::abs(__v) > 0.25)
+                    __px = __x * _VSTD::log(1 + __v) - __difmuk - __del;
+                else
+                    __px = __x * __v * __v * (((((((.1250060 * __v + -.1384794) *
+                           __v + .1421878) * __v + -.1661269) * __v + .2000118) *
+                           __v + -.2500068) * __v + .3333333) * __v + -.5) - __del;
+                __py = .3989423 / _VSTD::sqrt(__x);
+            }
+            double __r = (0.5 - __difmuk) / __pr.__s_;
+            double __r2 = __r * __r;
+            double __fx = -0.5 * __r2;
+            double __fy = __pr.__omega_ * (((__pr.__c3_ * __r2 + __pr.__c2_) *
+                                        __r2 + __pr.__c1_) * __r2 + __pr.__c0_);
+            if (__using_exp_dist)
+            {
+                if (__pr.__c_ * _VSTD::abs(__u) <= __py * _VSTD::exp(__px + __e) -
+                                                   __fy * _VSTD::exp(__fx + __e))
+                    break;
+            }
+            else
+            {
+                if (__fy - __u * __fy <= __py * _VSTD::exp(__px - __fx))
+                    break;
+            }
+        }
+    }
+    return __x;
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const poisson_distribution<_IntType>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    return __os << __x.mean();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           poisson_distribution<_IntType>& __x)
+{
+    typedef poisson_distribution<_IntType> _Eng;
+    typedef typename _Eng::param_type param_type;
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    double __mean;
+    __is >> __mean;
+    if (!__is.fail())
+        __x.param(param_type(__mean));
+    return __is;
+}
+
+// weibull_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY weibull_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __a_;
+        result_type __b_;
+    public:
+        typedef weibull_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __a = 1, result_type __b = 1)
+            : __a_(__a), __b_(__b) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type a() const {return __a_;}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type b() const {return __b_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit weibull_distribution(result_type __a = 1, result_type __b = 1)
+        : __p_(param_type(__a, __b)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit weibull_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g, const param_type& __p)
+        {return __p.b() *
+            _VSTD::pow(exponential_distribution<result_type>()(__g), 1/__p.a());}
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type a() const {return __p_.a();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type b() const {return __p_.b();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const weibull_distribution& __x,
+                        const weibull_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const weibull_distribution& __x,
+                        const weibull_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const weibull_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.a() << __sp << __x.b();
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           weibull_distribution<_RT>& __x)
+{
+    typedef weibull_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);
+    result_type __a;
+    result_type __b;
+    __is >> __a >> __b;
+    if (!__is.fail())
+        __x.param(param_type(__a, __b));
+    return __is;
+}
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY extreme_value_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __a_;
+        result_type __b_;
+    public:
+        typedef extreme_value_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __a = 0, result_type __b = 1)
+            : __a_(__a), __b_(__b) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type a() const {return __a_;}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type b() const {return __b_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit extreme_value_distribution(result_type __a = 0, result_type __b = 1)
+        : __p_(param_type(__a, __b)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit extreme_value_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type a() const {return __p_.a();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type b() const {return __p_.b();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return -numeric_limits<result_type>::infinity();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const extreme_value_distribution& __x,
+                        const extreme_value_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const extreme_value_distribution& __x,
+                        const extreme_value_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template<class _RealType>
+template<class _URNG>
+_RealType
+extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    return __p.a() - __p.b() *
+         _VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g)));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const extreme_value_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.a() << __sp << __x.b();
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           extreme_value_distribution<_RT>& __x)
+{
+    typedef extreme_value_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);
+    result_type __a;
+    result_type __b;
+    __is >> __a >> __b;
+    if (!__is.fail())
+        __x.param(param_type(__a, __b));
+    return __is;
+}
+
+// gamma_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY gamma_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __alpha_;
+        result_type __beta_;
+    public:
+        typedef gamma_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __alpha = 1, result_type __beta = 1)
+            : __alpha_(__alpha), __beta_(__beta) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type alpha() const {return __alpha_;}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type beta() const {return __beta_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__alpha_ == __y.__alpha_ && __x.__beta_ == __y.__beta_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit gamma_distribution(result_type __alpha = 1, result_type __beta = 1)
+        : __p_(param_type(__alpha, __beta)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit gamma_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type alpha() const {return __p_.alpha();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type beta() const {return __p_.beta();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const gamma_distribution& __x,
+                        const gamma_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const gamma_distribution& __x,
+                        const gamma_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    result_type __a = __p.alpha();
+    uniform_real_distribution<result_type> __gen(0, 1);
+    exponential_distribution<result_type> __egen;
+    result_type __x;
+    if (__a == 1)
+        __x = __egen(__g);
+    else if (__a > 1)
+    {
+        const result_type __b = __a - 1;
+        const result_type __c = 3 * __a - result_type(0.75);
+        while (true)
+        {
+            const result_type __u = __gen(__g);
+            const result_type __v = __gen(__g);
+            const result_type __w = __u * (1 - __u);
+            if (__w != 0)
+            {
+                const result_type __y = _VSTD::sqrt(__c / __w) *
+                                        (__u - result_type(0.5));
+                __x = __b + __y;
+                if (__x >= 0)
+                {
+                    const result_type __z = 64 * __w * __w * __w * __v * __v;
+                    if (__z <= 1 - 2 * __y * __y / __x)
+                        break;
+                    if (_VSTD::log(__z) <= 2 * (__b * _VSTD::log(__x / __b) - __y))
+                        break;
+                }
+            }
+        }
+    }
+    else  // __a < 1
+    {
+        while (true)
+        {
+            const result_type __u = __gen(__g);
+            const result_type __es = __egen(__g);
+            if (__u <= 1 - __a)
+            {
+                __x = _VSTD::pow(__u, 1 / __a);
+                if (__x <= __es)
+                    break;
+            }
+            else
+            {
+                const result_type __e = -_VSTD::log((1-__u)/__a);
+                __x = _VSTD::pow(1 - __a + __a * __e, 1 / __a);
+                if (__x <= __e + __es)
+                    break;
+            }
+        }
+    }
+    return __x * __p.beta();
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const gamma_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.alpha() << __sp << __x.beta();
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           gamma_distribution<_RT>& __x)
+{
+    typedef gamma_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);
+    result_type __alpha;
+    result_type __beta;
+    __is >> __alpha >> __beta;
+    if (!__is.fail())
+        __x.param(param_type(__alpha, __beta));
+    return __is;
+}
+
+// negative_binomial_distribution
+
+template<class _IntType = int>
+class _LIBCPP_TYPE_VIS_ONLY negative_binomial_distribution
+{
+public:
+    // types
+    typedef _IntType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __k_;
+        double __p_;
+    public:
+        typedef negative_binomial_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __k = 1, double __p = 0.5)
+            : __k_(__k), __p_(__p) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type k() const {return __k_;}
+        _LIBCPP_INLINE_VISIBILITY
+        double p() const {return __p_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__k_ == __y.__k_ && __x.__p_ == __y.__p_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit negative_binomial_distribution(result_type __k = 1, double __p = 0.5)
+        : __p_(__k, __p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit negative_binomial_distribution(const param_type& __p) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type k() const {return __p_.k();}
+    _LIBCPP_INLINE_VISIBILITY
+    double p() const {return __p_.p();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::max();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const negative_binomial_distribution& __x,
+                        const negative_binomial_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const negative_binomial_distribution& __x,
+                        const negative_binomial_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _IntType>
+template<class _URNG>
+_IntType
+negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
+{
+    result_type __k = __pr.k();
+    double __p = __pr.p();
+    if (__k <= 21 * __p)
+    {
+        bernoulli_distribution __gen(__p);
+        result_type __f = 0;
+        result_type __s = 0;
+        while (__s < __k)
+        {
+            if (__gen(__urng))
+                ++__s;
+            else
+                ++__f;
+        }
+        return __f;
+    }
+    return poisson_distribution<result_type>(gamma_distribution<double>
+                                            (__k, (1-__p)/__p)(__urng))(__urng);
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const negative_binomial_distribution<_IntType>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    return __os << __x.k() << __sp << __x.p();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           negative_binomial_distribution<_IntType>& __x)
+{
+    typedef negative_binomial_distribution<_IntType> _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);
+    result_type __k;
+    double __p;
+    __is >> __k >> __p;
+    if (!__is.fail())
+        __x.param(param_type(__k, __p));
+    return __is;
+}
+
+// geometric_distribution
+
+template<class _IntType = int>
+class _LIBCPP_TYPE_VIS_ONLY geometric_distribution
+{
+public:
+    // types
+    typedef _IntType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        double __p_;
+    public:
+        typedef geometric_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(double __p = 0.5) : __p_(__p) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        double p() const {return __p_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__p_ == __y.__p_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructors and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit geometric_distribution(double __p = 0.5) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit geometric_distribution(const param_type& __p) : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g, const param_type& __p)
+        {return negative_binomial_distribution<result_type>(1, __p.p())(__g);}
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    double p() const {return __p_.p();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::max();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const geometric_distribution& __x,
+                        const geometric_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const geometric_distribution& __x,
+                        const geometric_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const geometric_distribution<_IntType>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    return __os << __x.p();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           geometric_distribution<_IntType>& __x)
+{
+    typedef geometric_distribution<_IntType> _Eng;
+    typedef typename _Eng::param_type param_type;
+    __save_flags<_CharT, _Traits> __lx(__is);
+    __is.flags(ios_base::dec | ios_base::skipws);
+    double __p;
+    __is >> __p;
+    if (!__is.fail())
+        __x.param(param_type(__p));
+    return __is;
+}
+
+// chi_squared_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY chi_squared_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __n_;
+    public:
+        typedef chi_squared_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __n = 1) : __n_(__n) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type n() const {return __n_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__n_ == __y.__n_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit chi_squared_distribution(result_type __n = 1)
+        : __p_(param_type(__n)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit chi_squared_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g, const param_type& __p)
+        {return gamma_distribution<result_type>(__p.n() / 2, 2)(__g);}
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type n() const {return __p_.n();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const chi_squared_distribution& __x,
+                        const chi_squared_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const chi_squared_distribution& __x,
+                        const chi_squared_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const chi_squared_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    __os << __x.n();
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           chi_squared_distribution<_RT>& __x)
+{
+    typedef chi_squared_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);
+    result_type __n;
+    __is >> __n;
+    if (!__is.fail())
+        __x.param(param_type(__n));
+    return __is;
+}
+
+// cauchy_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY cauchy_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __a_;
+        result_type __b_;
+    public:
+        typedef cauchy_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __a = 0, result_type __b = 1)
+            : __a_(__a), __b_(__b) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type a() const {return __a_;}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type b() const {return __b_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit cauchy_distribution(result_type __a = 0, result_type __b = 1)
+        : __p_(param_type(__a, __b)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit cauchy_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type a() const {return __p_.a();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type b() const {return __p_.b();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return -numeric_limits<result_type>::infinity();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const cauchy_distribution& __x,
+                        const cauchy_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const cauchy_distribution& __x,
+                        const cauchy_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+inline _LIBCPP_INLINE_VISIBILITY
+_RealType
+cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    uniform_real_distribution<result_type> __gen;
+    // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite
+    return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const cauchy_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.a() << __sp << __x.b();
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           cauchy_distribution<_RT>& __x)
+{
+    typedef cauchy_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);
+    result_type __a;
+    result_type __b;
+    __is >> __a >> __b;
+    if (!__is.fail())
+        __x.param(param_type(__a, __b));
+    return __is;
+}
+
+// fisher_f_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY fisher_f_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __m_;
+        result_type __n_;
+    public:
+        typedef fisher_f_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __m = 1, result_type __n = 1)
+            : __m_(__m), __n_(__n) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type m() const {return __m_;}
+        _LIBCPP_INLINE_VISIBILITY
+        result_type n() const {return __n_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__m_ == __y.__m_ && __x.__n_ == __y.__n_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1)
+        : __p_(param_type(__m, __n)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit fisher_f_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type m() const {return __p_.m();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type n() const {return __p_.n();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const fisher_f_distribution& __x,
+                        const fisher_f_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const fisher_f_distribution& __x,
+                        const fisher_f_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    gamma_distribution<result_type> __gdm(__p.m() * result_type(.5));
+    gamma_distribution<result_type> __gdn(__p.n() * result_type(.5));
+    return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const fisher_f_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    __os << __x.m() << __sp << __x.n();
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           fisher_f_distribution<_RT>& __x)
+{
+    typedef fisher_f_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);
+    result_type __m;
+    result_type __n;
+    __is >> __m >> __n;
+    if (!__is.fail())
+        __x.param(param_type(__m, __n));
+    return __is;
+}
+
+// student_t_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY student_t_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        result_type __n_;
+    public:
+        typedef student_t_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        explicit param_type(result_type __n = 1) : __n_(__n) {}
+
+        _LIBCPP_INLINE_VISIBILITY
+        result_type n() const {return __n_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__n_ == __y.__n_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+    };
+
+private:
+    param_type __p_;
+    normal_distribution<result_type> __nd_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    explicit student_t_distribution(result_type __n = 1)
+        : __p_(param_type(__n)) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit student_t_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {__nd_.reset();}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    result_type n() const {return __p_.n();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return -numeric_limits<result_type>::infinity();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return numeric_limits<result_type>::infinity();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const student_t_distribution& __x,
+                        const student_t_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const student_t_distribution& __x,
+                        const student_t_distribution& __y)
+        {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    gamma_distribution<result_type> __gd(__p.n() * .5, 2);
+    return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const student_t_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    __os << __x.n();
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           student_t_distribution<_RT>& __x)
+{
+    typedef student_t_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);
+    result_type __n;
+    __is >> __n;
+    if (!__is.fail())
+        __x.param(param_type(__n));
+    return __is;
+}
+
+// discrete_distribution
+
+template<class _IntType = int>
+class _LIBCPP_TYPE_VIS_ONLY discrete_distribution
+{
+public:
+    // types
+    typedef _IntType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        vector<double> __p_;
+    public:
+        typedef discrete_distribution distribution_type;
+
+        _LIBCPP_INLINE_VISIBILITY
+        param_type() {}
+        template<class _InputIterator>
+            _LIBCPP_INLINE_VISIBILITY
+            param_type(_InputIterator __f, _InputIterator __l)
+            : __p_(__f, __l) {__init();}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+        _LIBCPP_INLINE_VISIBILITY
+        param_type(initializer_list<double> __wl)
+            : __p_(__wl.begin(), __wl.end()) {__init();}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+        template<class _UnaryOperation>
+            param_type(size_t __nw, double __xmin, double __xmax,
+                       _UnaryOperation __fw);
+
+        vector<double> probabilities() const;
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__p_ == __y.__p_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+
+    private:
+        void __init();
+
+        friend class discrete_distribution;
+
+        template <class _CharT, class _Traits, class _IT>
+        friend
+        basic_ostream<_CharT, _Traits>&
+        operator<<(basic_ostream<_CharT, _Traits>& __os,
+                   const discrete_distribution<_IT>& __x);
+
+        template <class _CharT, class _Traits, class _IT>
+        friend
+        basic_istream<_CharT, _Traits>&
+        operator>>(basic_istream<_CharT, _Traits>& __is,
+                   discrete_distribution<_IT>& __x);
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    discrete_distribution() {}
+    template<class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        discrete_distribution(_InputIterator __f, _InputIterator __l)
+            : __p_(__f, __l) {}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    discrete_distribution(initializer_list<double> __wl)
+        : __p_(__wl) {}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    template<class _UnaryOperation>
+        _LIBCPP_INLINE_VISIBILITY
+        discrete_distribution(size_t __nw, double __xmin, double __xmax,
+                              _UnaryOperation __fw)
+        : __p_(__nw, __xmin, __xmax, __fw) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit discrete_distribution(const param_type& __p)
+        : __p_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    vector<double> probabilities() const {return __p_.probabilities();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return __p_.__p_.size();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const discrete_distribution& __x,
+                        const discrete_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const discrete_distribution& __x,
+                        const discrete_distribution& __y)
+        {return !(__x == __y);}
+
+    template <class _CharT, class _Traits, class _IT>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const discrete_distribution<_IT>& __x);
+
+    template <class _CharT, class _Traits, class _IT>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               discrete_distribution<_IT>& __x);
+};
+
+template<class _IntType>
+template<class _UnaryOperation>
+discrete_distribution<_IntType>::param_type::param_type(size_t __nw,
+                                                        double __xmin,
+                                                        double __xmax,
+                                                        _UnaryOperation __fw)
+{
+    if (__nw > 1)
+    {
+        __p_.reserve(__nw - 1);
+        double __d = (__xmax - __xmin) / __nw;
+        double __d2 = __d / 2;
+        for (size_t __k = 0; __k < __nw; ++__k)
+            __p_.push_back(__fw(__xmin + __k * __d + __d2));
+        __init();
+    }
+}
+
+template<class _IntType>
+void
+discrete_distribution<_IntType>::param_type::__init()
+{
+    if (!__p_.empty())
+    {
+        if (__p_.size() > 1)
+        {
+            double __s = _VSTD::accumulate(__p_.begin(), __p_.end(), 0.0);
+            for (_VSTD::vector<double>::iterator __i = __p_.begin(), __e = __p_.end();
+                                                                       __i < __e; ++__i)
+                *__i /= __s;
+            vector<double> __t(__p_.size() - 1);
+            _VSTD::partial_sum(__p_.begin(), __p_.end() - 1, __t.begin());
+            swap(__p_, __t);
+        }
+        else
+        {
+            __p_.clear();
+            __p_.shrink_to_fit();
+        }
+    }
+}
+
+template<class _IntType>
+vector<double>
+discrete_distribution<_IntType>::param_type::probabilities() const
+{
+    size_t __n = __p_.size();
+    _VSTD::vector<double> __p(__n+1);
+    _VSTD::adjacent_difference(__p_.begin(), __p_.end(), __p.begin());
+    if (__n > 0)
+        __p[__n] = 1 - __p_[__n-1];
+    else
+        __p[0] = 1;
+    return __p;
+}
+
+template<class _IntType>
+template<class _URNG>
+_IntType
+discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p)
+{
+    uniform_real_distribution<double> __gen;
+    return static_cast<_IntType>(
+           _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) -
+                                                              __p.__p_.begin());
+}
+
+template <class _CharT, class _Traits, class _IT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const discrete_distribution<_IT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    size_t __n = __x.__p_.__p_.size();
+    __os << __n;
+    for (size_t __i = 0; __i < __n; ++__i)
+        __os << __sp << __x.__p_.__p_[__i];
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _IT>
+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;
+    __is >> __n;
+    vector<double> __p(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __is >> __p[__i];
+    if (!__is.fail())
+        swap(__x.__p_.__p_, __p);
+    return __is;
+}
+
+// piecewise_constant_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY piecewise_constant_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        vector<result_type> __b_;
+        vector<result_type> __densities_;
+        vector<result_type> __areas_;
+    public:
+        typedef piecewise_constant_distribution distribution_type;
+
+        param_type();
+        template<class _InputIteratorB, class _InputIteratorW>
+            param_type(_InputIteratorB __fB, _InputIteratorB __lB,
+                       _InputIteratorW __fW);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+        template<class _UnaryOperation>
+            param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+        template<class _UnaryOperation>
+            param_type(size_t __nw, result_type __xmin, result_type __xmax,
+                       _UnaryOperation __fw);
+        param_type & operator=(const param_type& __rhs);
+
+        _LIBCPP_INLINE_VISIBILITY
+        vector<result_type> intervals() const {return __b_;}
+        _LIBCPP_INLINE_VISIBILITY
+        vector<result_type> densities() const {return __densities_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+
+    private:
+        void __init();
+
+        friend class piecewise_constant_distribution;
+
+        template <class _CharT, class _Traits, class _RT>
+        friend
+        basic_ostream<_CharT, _Traits>&
+        operator<<(basic_ostream<_CharT, _Traits>& __os,
+                   const piecewise_constant_distribution<_RT>& __x);
+
+        template <class _CharT, class _Traits, class _RT>
+        friend
+        basic_istream<_CharT, _Traits>&
+        operator>>(basic_istream<_CharT, _Traits>& __is,
+                   piecewise_constant_distribution<_RT>& __x);
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    piecewise_constant_distribution() {}
+    template<class _InputIteratorB, class _InputIteratorW>
+        _LIBCPP_INLINE_VISIBILITY
+        piecewise_constant_distribution(_InputIteratorB __fB,
+                                        _InputIteratorB __lB,
+                                        _InputIteratorW __fW)
+        : __p_(__fB, __lB, __fW) {}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    template<class _UnaryOperation>
+        _LIBCPP_INLINE_VISIBILITY
+        piecewise_constant_distribution(initializer_list<result_type> __bl,
+                                        _UnaryOperation __fw)
+        : __p_(__bl, __fw) {}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template<class _UnaryOperation>
+        _LIBCPP_INLINE_VISIBILITY
+        piecewise_constant_distribution(size_t __nw, result_type __xmin,
+                                        result_type __xmax, _UnaryOperation __fw)
+        : __p_(__nw, __xmin, __xmax, __fw) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit piecewise_constant_distribution(const param_type& __p)
+        : __p_(__p) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    vector<result_type> intervals() const {return __p_.intervals();}
+    _LIBCPP_INLINE_VISIBILITY
+    vector<result_type> densities() const {return __p_.densities();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return __p_.__b_.front();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return __p_.__b_.back();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const piecewise_constant_distribution& __x,
+                        const piecewise_constant_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const piecewise_constant_distribution& __x,
+                           const piecewise_constant_distribution& __y)
+        {return !(__x == __y);}
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const piecewise_constant_distribution<_RT>& __x);
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               piecewise_constant_distribution<_RT>& __x);
+};
+
+template<class _RealType>
+typename piecewise_constant_distribution<_RealType>::param_type &
+piecewise_constant_distribution<_RealType>::param_type::operator=
+                                                       (const param_type& __rhs)
+{
+//  These can throw
+    __b_.reserve        (__rhs.__b_.size ());
+    __densities_.reserve(__rhs.__densities_.size());
+    __areas_.reserve    (__rhs.__areas_.size());
+
+//  These can not throw
+    __b_         = __rhs.__b_;
+    __densities_ = __rhs.__densities_;
+    __areas_     =  __rhs.__areas_;
+    return *this;
+}
+
+template<class _RealType>
+void
+piecewise_constant_distribution<_RealType>::param_type::__init()
+{
+    // __densities_ contains non-normalized areas
+    result_type __total_area = _VSTD::accumulate(__densities_.begin(),
+                                                __densities_.end(),
+                                                result_type());
+    for (size_t __i = 0; __i < __densities_.size(); ++__i)
+        __densities_[__i] /= __total_area;
+    // __densities_ contains normalized areas
+    __areas_.assign(__densities_.size(), result_type());
+    _VSTD::partial_sum(__densities_.begin(), __densities_.end() - 1,
+                                                          __areas_.begin() + 1);
+    // __areas_ contains partial sums of normalized areas: [0, __densities_ - 1]
+    __densities_.back() = 1 - __areas_.back();  // correct round off error
+    for (size_t __i = 0; __i < __densities_.size(); ++__i)
+        __densities_[__i] /= (__b_[__i+1] - __b_[__i]);
+    // __densities_ now contains __densities_
+}
+
+template<class _RealType>
+piecewise_constant_distribution<_RealType>::param_type::param_type()
+    : __b_(2),
+      __densities_(1, 1.0),
+      __areas_(1, 0.0)
+{
+    __b_[1] = 1;
+}
+
+template<class _RealType>
+template<class _InputIteratorB, class _InputIteratorW>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+        _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)
+    : __b_(__fB, __lB)
+{
+    if (__b_.size() < 2)
+    {
+        __b_.resize(2);
+        __b_[0] = 0;
+        __b_[1] = 1;
+        __densities_.assign(1, 1.0);
+        __areas_.assign(1, 0.0);
+    }
+    else
+    {
+        __densities_.reserve(__b_.size() - 1);
+        for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW)
+            __densities_.push_back(*__fW);
+        __init();
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+        initializer_list<result_type> __bl, _UnaryOperation __fw)
+    : __b_(__bl.begin(), __bl.end())
+{
+    if (__b_.size() < 2)
+    {
+        __b_.resize(2);
+        __b_[0] = 0;
+        __b_[1] = 1;
+        __densities_.assign(1, 1.0);
+        __areas_.assign(1, 0.0);
+    }
+    else
+    {
+        __densities_.reserve(__b_.size() - 1);
+        for (size_t __i = 0; __i < __b_.size() - 1; ++__i)
+            __densities_.push_back(__fw((__b_[__i+1] + __b_[__i])*.5));
+        __init();
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+        size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw)
+    : __b_(__nw == 0 ? 2 : __nw + 1)
+{
+    size_t __n = __b_.size() - 1;
+    result_type __d = (__xmax - __xmin) / __n;
+    __densities_.reserve(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+    {
+        __b_[__i] = __xmin + __i * __d;
+        __densities_.push_back(__fw(__b_[__i] + __d*.5));
+    }
+    __b_[__n] = __xmax;
+    __init();
+}
+
+template<class _RealType>
+template<class _URNG>
+_RealType
+piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    typedef uniform_real_distribution<result_type> _Gen;
+    result_type __u = _Gen()(__g);
+    ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
+                                      __u) - __p.__areas_.begin() - 1;
+    return (__u - __p.__areas_[__k]) / __p.__densities_[__k] + __p.__b_[__k];
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const piecewise_constant_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    size_t __n = __x.__p_.__b_.size();
+    __os << __n;
+    for (size_t __i = 0; __i < __n; ++__i)
+        __os << __sp << __x.__p_.__b_[__i];
+    __n = __x.__p_.__densities_.size();
+    __os << __sp << __n;
+    for (size_t __i = 0; __i < __n; ++__i)
+        __os << __sp << __x.__p_.__densities_[__i];
+    __n = __x.__p_.__areas_.size();
+    __os << __sp << __n;
+    for (size_t __i = 0; __i < __n; ++__i)
+        __os << __sp << __x.__p_.__areas_[__i];
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           piecewise_constant_distribution<_RT>& __x)
+{
+    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;
+    __is >> __n;
+    vector<result_type> __b(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __is >> __b[__i];
+    __is >> __n;
+    vector<result_type> __densities(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __is >> __densities[__i];
+    __is >> __n;
+    vector<result_type> __areas(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __is >> __areas[__i];
+    if (!__is.fail())
+    {
+        swap(__x.__p_.__b_, __b);
+        swap(__x.__p_.__densities_, __densities);
+        swap(__x.__p_.__areas_, __areas);
+    }
+    return __is;
+}
+
+// piecewise_linear_distribution
+
+template<class _RealType = double>
+class _LIBCPP_TYPE_VIS_ONLY piecewise_linear_distribution
+{
+public:
+    // types
+    typedef _RealType result_type;
+
+    class _LIBCPP_TYPE_VIS_ONLY param_type
+    {
+        vector<result_type> __b_;
+        vector<result_type> __densities_;
+        vector<result_type> __areas_;
+    public:
+        typedef piecewise_linear_distribution distribution_type;
+
+        param_type();
+        template<class _InputIteratorB, class _InputIteratorW>
+            param_type(_InputIteratorB __fB, _InputIteratorB __lB,
+                       _InputIteratorW __fW);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+        template<class _UnaryOperation>
+            param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+        template<class _UnaryOperation>
+            param_type(size_t __nw, result_type __xmin, result_type __xmax,
+                       _UnaryOperation __fw);
+        param_type & operator=(const param_type& __rhs);
+        
+        _LIBCPP_INLINE_VISIBILITY
+        vector<result_type> intervals() const {return __b_;}
+        _LIBCPP_INLINE_VISIBILITY
+        vector<result_type> densities() const {return __densities_;}
+
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator==(const param_type& __x, const param_type& __y)
+            {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;}
+        friend _LIBCPP_INLINE_VISIBILITY
+            bool operator!=(const param_type& __x, const param_type& __y)
+            {return !(__x == __y);}
+
+    private:
+        void __init();
+
+        friend class piecewise_linear_distribution;
+
+        template <class _CharT, class _Traits, class _RT>
+        friend
+        basic_ostream<_CharT, _Traits>&
+        operator<<(basic_ostream<_CharT, _Traits>& __os,
+                   const piecewise_linear_distribution<_RT>& __x);
+
+        template <class _CharT, class _Traits, class _RT>
+        friend
+        basic_istream<_CharT, _Traits>&
+        operator>>(basic_istream<_CharT, _Traits>& __is,
+                   piecewise_linear_distribution<_RT>& __x);
+    };
+
+private:
+    param_type __p_;
+
+public:
+    // constructor and reset functions
+    _LIBCPP_INLINE_VISIBILITY
+    piecewise_linear_distribution() {}
+    template<class _InputIteratorB, class _InputIteratorW>
+        _LIBCPP_INLINE_VISIBILITY
+        piecewise_linear_distribution(_InputIteratorB __fB,
+                                      _InputIteratorB __lB,
+                                      _InputIteratorW __fW)
+        : __p_(__fB, __lB, __fW) {}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    template<class _UnaryOperation>
+        _LIBCPP_INLINE_VISIBILITY
+        piecewise_linear_distribution(initializer_list<result_type> __bl,
+                                      _UnaryOperation __fw)
+        : __p_(__bl, __fw) {}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template<class _UnaryOperation>
+        _LIBCPP_INLINE_VISIBILITY
+        piecewise_linear_distribution(size_t __nw, result_type __xmin,
+                                      result_type __xmax, _UnaryOperation __fw)
+        : __p_(__nw, __xmin, __xmax, __fw) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit piecewise_linear_distribution(const param_type& __p)
+        : __p_(__p) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void reset() {}
+
+    // generating functions
+    template<class _URNG>
+        _LIBCPP_INLINE_VISIBILITY
+        result_type operator()(_URNG& __g)
+        {return (*this)(__g, __p_);}
+    template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+    // property functions
+    _LIBCPP_INLINE_VISIBILITY
+    vector<result_type> intervals() const {return __p_.intervals();}
+    _LIBCPP_INLINE_VISIBILITY
+    vector<result_type> densities() const {return __p_.densities();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    param_type param() const {return __p_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void param(const param_type& __p) {__p_ = __p;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const {return __p_.__b_.front();}
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const {return __p_.__b_.back();}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const piecewise_linear_distribution& __x,
+                        const piecewise_linear_distribution& __y)
+        {return __x.__p_ == __y.__p_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const piecewise_linear_distribution& __x,
+                        const piecewise_linear_distribution& __y)
+        {return !(__x == __y);}
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os,
+               const piecewise_linear_distribution<_RT>& __x);
+
+    template <class _CharT, class _Traits, class _RT>
+    friend
+    basic_istream<_CharT, _Traits>&
+    operator>>(basic_istream<_CharT, _Traits>& __is,
+               piecewise_linear_distribution<_RT>& __x);
+};
+
+template<class _RealType>
+typename piecewise_linear_distribution<_RealType>::param_type &
+piecewise_linear_distribution<_RealType>::param_type::operator=
+                                                       (const param_type& __rhs)
+{
+//  These can throw
+    __b_.reserve        (__rhs.__b_.size ());
+    __densities_.reserve(__rhs.__densities_.size());
+    __areas_.reserve    (__rhs.__areas_.size());
+
+//  These can not throw
+    __b_         = __rhs.__b_;
+    __densities_ = __rhs.__densities_;
+    __areas_     =  __rhs.__areas_;
+    return *this;
+}
+
+
+template<class _RealType>
+void
+piecewise_linear_distribution<_RealType>::param_type::__init()
+{
+    __areas_.assign(__densities_.size() - 1, result_type());
+    result_type _Sp = 0;
+    for (size_t __i = 0; __i < __areas_.size(); ++__i)
+    {
+        __areas_[__i] = (__densities_[__i+1] + __densities_[__i]) *
+                        (__b_[__i+1] - __b_[__i]) * .5;
+        _Sp += __areas_[__i];
+    }
+    for (size_t __i = __areas_.size(); __i > 1;)
+    {
+        --__i;
+        __areas_[__i] = __areas_[__i-1] / _Sp;
+    }
+    __areas_[0] = 0;
+    for (size_t __i = 1; __i < __areas_.size(); ++__i)
+        __areas_[__i] += __areas_[__i-1];
+    for (size_t __i = 0; __i < __densities_.size(); ++__i)
+        __densities_[__i] /= _Sp;
+}
+
+template<class _RealType>
+piecewise_linear_distribution<_RealType>::param_type::param_type()
+    : __b_(2),
+      __densities_(2, 1.0),
+      __areas_(1, 0.0)
+{
+    __b_[1] = 1;
+}
+
+template<class _RealType>
+template<class _InputIteratorB, class _InputIteratorW>
+piecewise_linear_distribution<_RealType>::param_type::param_type(
+        _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)
+    : __b_(__fB, __lB)
+{
+    if (__b_.size() < 2)
+    {
+        __b_.resize(2);
+        __b_[0] = 0;
+        __b_[1] = 1;
+        __densities_.assign(2, 1.0);
+        __areas_.assign(1, 0.0);
+    }
+    else
+    {
+        __densities_.reserve(__b_.size());
+        for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW)
+            __densities_.push_back(*__fW);
+        __init();
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_linear_distribution<_RealType>::param_type::param_type(
+        initializer_list<result_type> __bl, _UnaryOperation __fw)
+    : __b_(__bl.begin(), __bl.end())
+{
+    if (__b_.size() < 2)
+    {
+        __b_.resize(2);
+        __b_[0] = 0;
+        __b_[1] = 1;
+        __densities_.assign(2, 1.0);
+        __areas_.assign(1, 0.0);
+    }
+    else
+    {
+        __densities_.reserve(__b_.size());
+        for (size_t __i = 0; __i < __b_.size(); ++__i)
+            __densities_.push_back(__fw(__b_[__i]));
+        __init();
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_linear_distribution<_RealType>::param_type::param_type(
+        size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw)
+    : __b_(__nw == 0 ? 2 : __nw + 1)
+{
+    size_t __n = __b_.size() - 1;
+    result_type __d = (__xmax - __xmin) / __n;
+    __densities_.reserve(__b_.size());
+    for (size_t __i = 0; __i < __n; ++__i)
+    {
+        __b_[__i] = __xmin + __i * __d;
+        __densities_.push_back(__fw(__b_[__i]));
+    }
+    __b_[__n] = __xmax;
+    __densities_.push_back(__fw(__b_[__n]));
+    __init();
+}
+
+template<class _RealType>
+template<class _URNG>
+_RealType
+piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+    typedef uniform_real_distribution<result_type> _Gen;
+    result_type __u = _Gen()(__g);
+    ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(),
+                                      __u) - __p.__areas_.begin() - 1;
+    __u -= __p.__areas_[__k];
+    const result_type __dk = __p.__densities_[__k];
+    const result_type __dk1 = __p.__densities_[__k+1];
+    const result_type __deltad = __dk1 - __dk;
+    const result_type __bk = __p.__b_[__k];
+    if (__deltad == 0)
+        return __u / __dk + __bk;
+    const result_type __bk1 = __p.__b_[__k+1];
+    const result_type __deltab = __bk1 - __bk;
+    return (__bk * __dk1 - __bk1 * __dk +
+        _VSTD::sqrt(__deltab * (__deltab * __dk * __dk + 2 * __deltad * __u))) /
+        __deltad;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const piecewise_linear_distribution<_RT>& __x)
+{
+    __save_flags<_CharT, _Traits> __lx(__os);
+    __os.flags(ios_base::dec | ios_base::left | ios_base::fixed |
+               ios_base::scientific);
+    _CharT __sp = __os.widen(' ');
+    __os.fill(__sp);
+    size_t __n = __x.__p_.__b_.size();
+    __os << __n;
+    for (size_t __i = 0; __i < __n; ++__i)
+        __os << __sp << __x.__p_.__b_[__i];
+    __n = __x.__p_.__densities_.size();
+    __os << __sp << __n;
+    for (size_t __i = 0; __i < __n; ++__i)
+        __os << __sp << __x.__p_.__densities_[__i];
+    __n = __x.__p_.__areas_.size();
+    __os << __sp << __n;
+    for (size_t __i = 0; __i < __n; ++__i)
+        __os << __sp << __x.__p_.__areas_[__i];
+    return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           piecewise_linear_distribution<_RT>& __x)
+{
+    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;
+    __is >> __n;
+    vector<result_type> __b(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __is >> __b[__i];
+    __is >> __n;
+    vector<result_type> __densities(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __is >> __densities[__i];
+    __is >> __n;
+    vector<result_type> __areas(__n);
+    for (size_t __i = 0; __i < __n; ++__i)
+        __is >> __areas[__i];
+    if (!__is.fail())
+    {
+        swap(__x.__p_.__b_, __b);
+        swap(__x.__p_.__densities_, __densities);
+        swap(__x.__p_.__areas_, __areas);
+    }
+    return __is;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_RANDOM
diff --git a/final/include/ratio b/final/include/ratio
new file mode 100644
index 0000000..48dcd81
--- /dev/null
+++ b/final/include/ratio
@@ -0,0 +1,487 @@
+// -*- C++ -*-
+//===---------------------------- ratio -----------------------------------===//
+//
+//                     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_RATIO
+#define _LIBCPP_RATIO
+
+/*
+    ratio synopsis
+
+namespace std
+{
+
+template <intmax_t N, intmax_t D = 1>
+class ratio
+{
+public:
+    static const intmax_t num;
+    static const intmax_t den;
+    typedef ratio<num, den> type;
+};
+
+// ratio arithmetic
+template <class R1, class R2> using ratio_add = ...;
+template <class R1, class R2> using ratio_subtract = ...;
+template <class R1, class R2> using ratio_multiply = ...;
+template <class R1, class R2> using ratio_divide = ...;
+
+// ratio comparison
+template <class R1, class R2> struct ratio_equal;
+template <class R1, class R2> struct ratio_not_equal;
+template <class R1, class R2> struct ratio_less;
+template <class R1, class R2> struct ratio_less_equal;
+template <class R1, class R2> struct ratio_greater;
+template <class R1, class R2> struct ratio_greater_equal;
+
+// convenience SI typedefs
+typedef ratio<1, 1000000000000000000000000> yocto;  // not supported
+typedef ratio<1,    1000000000000000000000> zepto;  // not supported
+typedef ratio<1,       1000000000000000000> atto;
+typedef ratio<1,          1000000000000000> femto;
+typedef ratio<1,             1000000000000> pico;
+typedef ratio<1,                1000000000> nano;
+typedef ratio<1,                   1000000> micro;
+typedef ratio<1,                      1000> milli;
+typedef ratio<1,                       100> centi;
+typedef ratio<1,                        10> deci;
+typedef ratio<                       10, 1> deca;
+typedef ratio<                      100, 1> hecto;
+typedef ratio<                     1000, 1> kilo;
+typedef ratio<                  1000000, 1> mega;
+typedef ratio<               1000000000, 1> giga;
+typedef ratio<            1000000000000, 1> tera;
+typedef ratio<         1000000000000000, 1> peta;
+typedef ratio<      1000000000000000000, 1> exa;
+typedef ratio<   1000000000000000000000, 1> zetta;  // not supported
+typedef ratio<1000000000000000000000000, 1> yotta;  // not supported
+
+}
+*/
+
+#include <__config>
+#include <cstdint>
+#include <climits>
+#include <type_traits>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __static_gcd
+
+template <intmax_t _Xp, intmax_t _Yp>
+struct __static_gcd
+{
+    static const intmax_t value = __static_gcd<_Yp, _Xp % _Yp>::value;
+};
+
+template <intmax_t _Xp>
+struct __static_gcd<_Xp, 0>
+{
+    static const intmax_t value = _Xp;
+};
+
+template <>
+struct __static_gcd<0, 0>
+{
+    static const intmax_t value = 1;
+};
+
+// __static_lcm
+
+template <intmax_t _Xp, intmax_t _Yp>
+struct __static_lcm
+{
+    static const intmax_t value = _Xp / __static_gcd<_Xp, _Yp>::value * _Yp;
+};
+
+template <intmax_t _Xp>
+struct __static_abs
+{
+    static const intmax_t value = _Xp < 0 ? -_Xp : _Xp;
+};
+
+template <intmax_t _Xp>
+struct __static_sign
+{
+    static const intmax_t value = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1);
+};
+
+template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
+class __ll_add;
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_add<_Xp, _Yp, 1>
+{
+    static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+    static const intmax_t max = -min;
+
+    static_assert(_Xp <= max - _Yp, "overflow in __ll_add");
+public:
+    static const intmax_t value = _Xp + _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_add<_Xp, _Yp, 0>
+{
+public:
+    static const intmax_t value = _Xp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_add<_Xp, _Yp, -1>
+{
+    static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+    static const intmax_t max = -min;
+
+    static_assert(min - _Yp <= _Xp, "overflow in __ll_add");
+public:
+    static const intmax_t value = _Xp + _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
+class __ll_sub;
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_sub<_Xp, _Yp, 1>
+{
+    static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+    static const intmax_t max = -min;
+
+    static_assert(min + _Yp <= _Xp, "overflow in __ll_sub");
+public:
+    static const intmax_t value = _Xp - _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_sub<_Xp, _Yp, 0>
+{
+public:
+    static const intmax_t value = _Xp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_sub<_Xp, _Yp, -1>
+{
+    static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
+    static const intmax_t max = -min;
+
+    static_assert(_Xp <= max + _Yp, "overflow in __ll_sub");
+public:
+    static const intmax_t value = _Xp - _Yp;
+};
+
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_mul
+{
+    static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
+    static const intmax_t min = nan + 1;
+    static const intmax_t max = -min;
+    static const intmax_t __a_x = __static_abs<_Xp>::value;
+    static const intmax_t __a_y = __static_abs<_Yp>::value;
+
+    static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, "overflow in __ll_mul");
+public:
+    static const intmax_t value = _Xp * _Yp;
+};
+
+template <intmax_t _Yp>
+class __ll_mul<0, _Yp>
+{
+public:
+    static const intmax_t value = 0;
+};
+
+template <intmax_t _Xp>
+class __ll_mul<_Xp, 0>
+{
+public:
+    static const intmax_t value = 0;
+};
+
+template <>
+class __ll_mul<0, 0>
+{
+public:
+    static const intmax_t value = 0;
+};
+
+// Not actually used but left here in case needed in future maintenance
+template <intmax_t _Xp, intmax_t _Yp>
+class __ll_div
+{
+    static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
+    static const intmax_t min = nan + 1;
+    static const intmax_t max = -min;
+
+    static_assert(_Xp != nan && _Yp != nan && _Yp != 0, "overflow in __ll_div");
+public:
+    static const intmax_t value = _Xp / _Yp;
+};
+
+template <intmax_t _Num, intmax_t _Den = 1>
+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;
+public:
+    static const intmax_t num = __s * __na / __gcd;
+    static 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 <class _Tp>                    struct __is_ratio                     : false_type {};
+template <intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den> > : true_type  {};
+
+typedef ratio<1LL, 1000000000000000000LL> atto;
+typedef ratio<1LL,    1000000000000000LL> femto;
+typedef ratio<1LL,       1000000000000LL> pico;
+typedef ratio<1LL,          1000000000LL> nano;
+typedef ratio<1LL,             1000000LL> micro;
+typedef ratio<1LL,                1000LL> milli;
+typedef ratio<1LL,                 100LL> centi;
+typedef ratio<1LL,                  10LL> deci;
+typedef ratio<                 10LL, 1LL> deca;
+typedef ratio<                100LL, 1LL> hecto;
+typedef ratio<               1000LL, 1LL> kilo;
+typedef ratio<            1000000LL, 1LL> mega;
+typedef ratio<         1000000000LL, 1LL> giga;
+typedef ratio<      1000000000000LL, 1LL> tera;
+typedef ratio<   1000000000000000LL, 1LL> peta;
+typedef ratio<1000000000000000000LL, 1LL> exa;
+
+template <class _R1, class _R2>
+struct __ratio_multiply
+{
+private:
+    static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value;
+    static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value;
+public:
+    typedef typename ratio
+        <
+            __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value,
+            __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value
+        >::type type;
+};
+
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2> using ratio_multiply
+                                    = typename __ratio_multiply<_R1, _R2>::type;
+
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2>
+struct _LIBCPP_TYPE_VIS_ONLY ratio_multiply
+    : public __ratio_multiply<_R1, _R2>::type {};
+
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2>
+struct __ratio_divide
+{
+private:
+    static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+    static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+public:
+    typedef typename ratio
+        <
+            __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
+            __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
+        >::type type;
+};
+
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2> using ratio_divide
+                                      = typename __ratio_divide<_R1, _R2>::type;
+
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2>
+struct _LIBCPP_TYPE_VIS_ONLY ratio_divide
+    : public __ratio_divide<_R1, _R2>::type {};
+
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2>
+struct __ratio_add
+{
+private:
+    static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+    static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+public:
+    typedef typename ratio_multiply
+        <
+            ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
+            ratio
+            <
+                __ll_add
+                <
+                    __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
+                    __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
+                >::value,
+                _R2::den
+            >
+        >::type type;
+};
+
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2> using ratio_add
+                                         = typename __ratio_add<_R1, _R2>::type;
+
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2>
+struct _LIBCPP_TYPE_VIS_ONLY ratio_add
+    : public __ratio_add<_R1, _R2>::type {};
+
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2>
+struct __ratio_subtract
+{
+private:
+    static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
+    static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
+public:
+    typedef typename ratio_multiply
+        <
+            ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
+            ratio
+            <
+                __ll_sub
+                <
+                    __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
+                    __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
+                >::value,
+                _R2::den
+            >
+        >::type type;
+};
+
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2> using ratio_subtract
+                                    = typename __ratio_subtract<_R1, _R2>::type;
+
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+template <class _R1, class _R2>
+struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract
+    : public __ratio_subtract<_R1, _R2>::type {};
+
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+
+// ratio_equal
+
+template <class _R1, class _R2>
+struct _LIBCPP_TYPE_VIS_ONLY ratio_equal
+    : public integral_constant<bool, _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> {};
+
+// ratio_less
+
+template <class _R1, class _R2, bool _Odd = false,
+          intmax_t _Q1 = _R1::num / _R1::den, intmax_t _M1 = _R1::num % _R1::den,
+          intmax_t _Q2 = _R2::num / _R2::den, intmax_t _M2 = _R2::num % _R2::den>
+struct __ratio_less1
+{
+    static const bool value = _Odd ? _Q2 < _Q1 : _Q1 < _Q2;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, 0, _Qp, 0>
+{
+    static const bool value = false;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M2>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, 0, _Qp, _M2>
+{
+    static const bool value = !_Odd;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M1>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, 0>
+{
+    static const bool value = _Odd;
+};
+
+template <class _R1, class _R2, bool _Odd, intmax_t _Qp, intmax_t _M1,
+                                                        intmax_t _M2>
+struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, _M2>
+{
+    static const bool value = __ratio_less1<ratio<_R1::den, _M1>,
+                                            ratio<_R2::den, _M2>, !_Odd>::value;
+};
+
+template <class _R1, class _R2, intmax_t _S1 = __static_sign<_R1::num>::value,
+                                intmax_t _S2 = __static_sign<_R2::num>::value>
+struct __ratio_less
+{
+    static const bool value = _S1 < _S2;
+};
+
+template <class _R1, class _R2>
+struct __ratio_less<_R1, _R2, 1LL, 1LL>
+{
+    static const bool value = __ratio_less1<_R1, _R2>::value;
+};
+
+template <class _R1, class _R2>
+struct __ratio_less<_R1, _R2, -1LL, -1LL>
+{
+    static const bool value = __ratio_less1<ratio<-_R2::num, _R2::den>, ratio<-_R1::num, _R1::den> >::value;
+};
+
+template <class _R1, class _R2>
+struct _LIBCPP_TYPE_VIS_ONLY ratio_less
+    : public integral_constant<bool, __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> {};
+
+template <class _R1, class _R2>
+struct _LIBCPP_TYPE_VIS_ONLY ratio_greater
+    : public integral_constant<bool, 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> {};
+
+template <class _R1, class _R2>
+struct __ratio_gcd
+{
+    typedef ratio<__static_gcd<_R1::num, _R2::num>::value,
+                  __static_lcm<_R1::den, _R2::den>::value> type;
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_RATIO
diff --git a/final/include/regex b/final/include/regex
new file mode 100644
index 0000000..bebbaf0
--- /dev/null
+++ b/final/include/regex
@@ -0,0 +1,6590 @@
+// -*- C++ -*-
+//===--------------------------- regex ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_REGEX
+#define _LIBCPP_REGEX
+
+/*
+    regex synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+namespace regex_constants
+{
+
+emum syntax_option_type
+{
+    icase      = unspecified,
+    nosubs     = unspecified,
+    optimize   = unspecified,
+    collate    = unspecified,
+    ECMAScript = unspecified,
+    basic      = unspecified,
+    extended   = unspecified,
+    awk        = unspecified,
+    grep       = unspecified,
+    egrep      = unspecified
+};
+
+constexpr syntax_option_type operator~(syntax_option_type f);
+constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs);
+constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs);
+
+enum match_flag_type
+{
+    match_default     = 0,
+    match_not_bol     = unspecified,
+    match_not_eol     = unspecified,
+    match_not_bow     = unspecified,
+    match_not_eow     = unspecified,
+    match_any         = unspecified,
+    match_not_null    = unspecified,
+    match_continuous  = unspecified,
+    match_prev_avail  = unspecified,
+    format_default    = 0,
+    format_sed        = unspecified,
+    format_no_copy    = unspecified,
+    format_first_only = unspecified
+};
+
+constexpr match_flag_type operator~(match_flag_type f);
+constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs);
+constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs);
+
+enum error_type
+{
+    error_collate    = unspecified,
+    error_ctype      = unspecified,
+    error_escape     = unspecified,
+    error_backref    = unspecified,
+    error_brack      = unspecified,
+    error_paren      = unspecified,
+    error_brace      = unspecified,
+    error_badbrace   = unspecified,
+    error_range      = unspecified,
+    error_space      = unspecified,
+    error_badrepeat  = unspecified,
+    error_complexity = unspecified,
+    error_stack      = unspecified
+};
+
+}  // regex_constants
+
+class regex_error
+    : public runtime_error
+{
+public:
+    explicit regex_error(regex_constants::error_type ecode);
+    regex_constants::error_type code() const;
+};
+
+template <class charT>
+struct regex_traits
+{
+public:
+    typedef charT                   char_type;
+    typedef basic_string<char_type> string_type;
+    typedef locale                  locale_type;
+    typedef /bitmask_type/          char_class_type;
+
+    regex_traits();
+
+    static size_t length(const char_type* p);
+    charT translate(charT c) const;
+    charT translate_nocase(charT c) const;
+    template <class ForwardIterator>
+        string_type
+        transform(ForwardIterator first, ForwardIterator last) const;
+    template <class ForwardIterator>
+        string_type
+        transform_primary( ForwardIterator first, ForwardIterator last) const;
+    template <class ForwardIterator>
+        string_type
+        lookup_collatename(ForwardIterator first, ForwardIterator last) const;
+    template <class ForwardIterator>
+        char_class_type
+        lookup_classname(ForwardIterator first, ForwardIterator last,
+                         bool icase = false) const;
+    bool isctype(charT c, char_class_type f) const;
+    int value(charT ch, int radix) const;
+    locale_type imbue(locale_type l);
+    locale_type getloc()const;
+};
+
+template <class charT, class traits = regex_traits<charT>>
+class basic_regex
+{
+public:
+    // types:
+    typedef charT                               value_type;
+    typedef regex_constants::syntax_option_type flag_type;
+    typedef typename traits::locale_type        locale_type;
+
+    // constants:
+    static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
+    static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+    static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
+    static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
+    static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+    static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
+    static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
+    static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
+    static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
+    static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
+
+    // construct/copy/destroy:
+    basic_regex();
+    explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
+    basic_regex(const charT* p, size_t len, flag_type f);
+    basic_regex(const basic_regex&);
+    basic_regex(basic_regex&&) noexcept;
+    template <class ST, class SA>
+        explicit basic_regex(const basic_string<charT, ST, SA>& p,
+                             flag_type f = regex_constants::ECMAScript);
+    template <class ForwardIterator>
+        basic_regex(ForwardIterator first, ForwardIterator last,
+                    flag_type f = regex_constants::ECMAScript);
+    basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
+
+    ~basic_regex();
+
+    basic_regex& operator=(const basic_regex&);
+    basic_regex& operator=(basic_regex&&) noexcept;
+    basic_regex& operator=(const charT* ptr);
+    basic_regex& operator=(initializer_list<charT> il);
+    template <class ST, class SA>
+        basic_regex& operator=(const basic_string<charT, ST, SA>& p);
+
+    // assign:
+    basic_regex& assign(const basic_regex& that);
+    basic_regex& assign(basic_regex&& that) noexcept;
+    basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
+    basic_regex& assign(const charT* p, size_t len, flag_type f);
+    template <class string_traits, class A>
+        basic_regex& assign(const basic_string<charT, string_traits, A>& s,
+                            flag_type f = regex_constants::ECMAScript);
+    template <class InputIterator>
+        basic_regex& assign(InputIterator first, InputIterator last,
+                            flag_type f = regex_constants::ECMAScript);
+    basic_regex& assign(initializer_list<charT>, flag_type = regex_constants::ECMAScript);
+
+    // const operations:
+    unsigned mark_count() const;
+    flag_type flags() const;
+
+    // locale:
+    locale_type imbue(locale_type loc);
+    locale_type getloc() const;
+
+    // swap:
+    void swap(basic_regex&);
+};
+
+typedef basic_regex<char>    regex;
+typedef basic_regex<wchar_t> wregex;
+
+template <class charT, class traits>
+    void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);
+
+template <class BidirectionalIterator>
+class sub_match
+    : public pair<BidirectionalIterator, BidirectionalIterator>
+{
+public:
+    typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
+    typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
+    typedef BidirectionalIterator                                      iterator;
+    typedef basic_string<value_type>                                string_type;
+
+    bool matched;
+
+    constexpr sub_match();
+
+    difference_type length() const;
+    operator string_type() const;
+    string_type str() const;
+
+    int compare(const sub_match& s) const;
+    int compare(const string_type& s) const;
+    int compare(const value_type* s) const;
+};
+
+typedef sub_match<const char*>             csub_match;
+typedef sub_match<const wchar_t*>          wcsub_match;
+typedef sub_match<string::const_iterator>  ssub_match;
+typedef sub_match<wstring::const_iterator> wssub_match;
+
+template <class BiIter>
+    bool
+    operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+              const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+              const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+                    const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator==(const sub_match<BiIter>& lhs,
+               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator!=(const sub_match<BiIter>& lhs,
+               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator<(const sub_match<BiIter>& lhs,
+              const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool operator>(const sub_match<BiIter>& lhs,
+                   const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator>=(const sub_match<BiIter>& lhs,
+               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter, class ST, class SA>
+    bool
+    operator<=(const sub_match<BiIter>& lhs,
+               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+
+template <class BiIter>
+    bool
+    operator==(typename iterator_traits<BiIter>::value_type const* lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator<(typename iterator_traits<BiIter>::value_type const* lhs,
+              const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator>(typename iterator_traits<BiIter>::value_type const* lhs,
+              const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator==(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+    bool
+    operator!=(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+    bool
+    operator<(const sub_match<BiIter>& lhs,
+              typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+    bool
+    operator>(const sub_match<BiIter>& lhs,
+              typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+    bool
+    operator>=(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+    bool
+    operator<=(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const* rhs);
+
+template <class BiIter>
+    bool
+    operator==(typename iterator_traits<BiIter>::value_type const& lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator<(typename iterator_traits<BiIter>::value_type const& lhs,
+              const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator>(typename iterator_traits<BiIter>::value_type const& lhs,
+              const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
+               const sub_match<BiIter>& rhs);
+
+template <class BiIter>
+    bool
+    operator==(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+    bool
+    operator!=(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+    bool
+    operator<(const sub_match<BiIter>& lhs,
+              typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+    bool
+    operator>(const sub_match<BiIter>& lhs,
+              typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+    bool
+    operator>=(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class BiIter>
+    bool
+    operator<=(const sub_match<BiIter>& lhs,
+               typename iterator_traits<BiIter>::value_type const& rhs);
+
+template <class charT, class ST, class BiIter>
+    basic_ostream<charT, ST>&
+    operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
+
+template <class BidirectionalIterator,
+          class Allocator = allocator<sub_match<BidirectionalIterator>>>
+class match_results
+{
+public:
+    typedef sub_match<BidirectionalIterator>                  value_type;
+    typedef const value_type&                                 const_reference;
+    typedef value_type&                                       reference;
+    typedef /implementation-defined/                          const_iterator;
+    typedef const_iterator                                    iterator;
+    typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
+    typedef typename allocator_traits<Allocator>::size_type   size_type;
+    typedef Allocator                                         allocator_type;
+    typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
+    typedef basic_string<char_type>                           string_type;
+
+    // construct/copy/destroy:
+    explicit match_results(const Allocator& a = Allocator());
+    match_results(const match_results& m);
+    match_results(match_results&& m) noexcept;
+    match_results& operator=(const match_results& m);
+    match_results& operator=(match_results&& m);
+    ~match_results();
+
+    bool ready() const;
+
+    // size:
+    size_type size() const;
+    size_type max_size() const;
+    bool empty() const;
+
+    // element access:
+    difference_type length(size_type sub = 0) const;
+    difference_type position(size_type sub = 0) const;
+    string_type str(size_type sub = 0) const;
+    const_reference operator[](size_type n) const;
+
+    const_reference prefix() const;
+    const_reference suffix() const;
+
+    const_iterator begin() const;
+    const_iterator end() const;
+    const_iterator cbegin() const;
+    const_iterator cend() const;
+
+    // format:
+    template <class OutputIter>
+        OutputIter
+        format(OutputIter out, const char_type* fmt_first,
+               const char_type* fmt_last,
+               regex_constants::match_flag_type flags = regex_constants::format_default) const;
+    template <class OutputIter, class ST, class SA>
+        OutputIter
+        format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
+               regex_constants::match_flag_type flags = regex_constants::format_default) const;
+    template <class ST, class SA>
+        basic_string<char_type, ST, SA>
+        format(const basic_string<char_type, ST, SA>& fmt,
+               regex_constants::match_flag_type flags = regex_constants::format_default) const;
+    string_type
+        format(const char_type* fmt,
+               regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+    // allocator:
+    allocator_type get_allocator() const;
+
+    // swap:
+    void swap(match_results& that);
+};
+
+typedef match_results<const char*>             cmatch;
+typedef match_results<const wchar_t*>          wcmatch;
+typedef match_results<string::const_iterator>  smatch;
+typedef match_results<wstring::const_iterator> wsmatch;
+
+template <class BidirectionalIterator, class Allocator>
+    bool
+    operator==(const match_results<BidirectionalIterator, Allocator>& m1,
+               const match_results<BidirectionalIterator, Allocator>& m2);
+
+template <class BidirectionalIterator, class Allocator>
+    bool
+    operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
+               const match_results<BidirectionalIterator, Allocator>& m2);
+
+template <class BidirectionalIterator, class Allocator>
+    void
+    swap(match_results<BidirectionalIterator, Allocator>& m1,
+         match_results<BidirectionalIterator, Allocator>& m2);
+
+template <class BidirectionalIterator, class Allocator, class charT, class traits>
+    bool
+    regex_match(BidirectionalIterator first, BidirectionalIterator last,
+                match_results<BidirectionalIterator, Allocator>& m,
+                const basic_regex<charT, traits>& e,
+                regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator, class charT, class traits>
+    bool
+    regex_match(BidirectionalIterator first, BidirectionalIterator last,
+                const basic_regex<charT, traits>& e,
+                regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class charT, class Allocator, class traits>
+    bool
+    regex_match(const charT* str, match_results<const charT*, Allocator>& m,
+                const basic_regex<charT, traits>& e,
+                regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+    bool
+    regex_match(const basic_string<charT, ST, SA>& s,
+                match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+                const basic_regex<charT, traits>& e,
+                regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+    bool
+    regex_match(const basic_string<charT, ST, SA>&& s,
+                match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+                const basic_regex<charT, traits>& e,
+                regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
+
+template <class charT, class traits>
+    bool
+    regex_match(const charT* str, const basic_regex<charT, traits>& e,
+                regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class charT, class traits>
+    bool
+    regex_match(const basic_string<charT, ST, SA>& s,
+                const basic_regex<charT, traits>& e,
+                regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator, class Allocator, class charT, class traits>
+    bool
+    regex_search(BidirectionalIterator first, BidirectionalIterator last,
+                 match_results<BidirectionalIterator, Allocator>& m,
+                 const basic_regex<charT, traits>& e,
+                 regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator, class charT, class traits>
+    bool
+    regex_search(BidirectionalIterator first, BidirectionalIterator last,
+                 const basic_regex<charT, traits>& e,
+                 regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class charT, class Allocator, class traits>
+    bool
+    regex_search(const charT* str, match_results<const charT*, Allocator>& m,
+                 const basic_regex<charT, traits>& e,
+                 regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class charT, class traits>
+    bool
+    regex_search(const charT* str, const basic_regex<charT, traits>& e,
+                 regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class charT, class traits>
+    bool
+    regex_search(const basic_string<charT, ST, SA>& s,
+                 const basic_regex<charT, traits>& e,
+                 regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+    bool
+    regex_search(const basic_string<charT, ST, SA>& s,
+                 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+                 const basic_regex<charT, traits>& e,
+                 regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class ST, class SA, class Allocator, class charT, class traits>
+    bool
+    regex_search(const basic_string<charT, ST, SA>&& s,
+                 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
+                 const basic_regex<charT, traits>& e,
+                 regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14
+
+template <class OutputIterator, class BidirectionalIterator,
+          class traits, class charT, class ST, class SA>
+    OutputIterator
+    regex_replace(OutputIterator out,
+                  BidirectionalIterator first, BidirectionalIterator last,
+                  const basic_regex<charT, traits>& e,
+                  const basic_string<charT, ST, SA>& fmt,
+                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class OutputIterator, class BidirectionalIterator,
+          class traits, class charT>
+    OutputIterator
+    regex_replace(OutputIterator out,
+                  BidirectionalIterator first, BidirectionalIterator last,
+                  const basic_regex<charT, traits>& e, const charT* fmt,
+                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT, class ST, class SA, class FST, class FSA>>
+    basic_string<charT, ST, SA>
+    regex_replace(const basic_string<charT, ST, SA>& s,
+                  const basic_regex<charT, traits>& e,
+                  const basic_string<charT, FST, FSA>& fmt,
+                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT, class ST, class SA>
+    basic_string<charT, ST, SA>
+    regex_replace(const basic_string<charT, ST, SA>& s,
+                  const basic_regex<charT, traits>& e, const charT* fmt,
+                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT, class ST, class SA>
+    basic_string<charT>
+    regex_replace(const charT* s,
+                  const basic_regex<charT, traits>& e,
+                  const basic_string<charT, ST, SA>& fmt,
+                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class traits, class charT>
+    basic_string<charT>
+    regex_replace(const charT* s,
+                  const basic_regex<charT, traits>& e,
+                  const charT* fmt,
+                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+template <class BidirectionalIterator,
+          class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+          class traits = regex_traits<charT>>
+class regex_iterator
+{
+public:
+    typedef basic_regex<charT, traits>           regex_type;
+    typedef match_results<BidirectionalIterator> value_type;
+    typedef ptrdiff_t                            difference_type;
+    typedef const value_type*                    pointer;
+    typedef const value_type&                    reference;
+    typedef forward_iterator_tag                 iterator_category;
+
+    regex_iterator();
+    regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                   const regex_type& re,
+                   regex_constants::match_flag_type m = regex_constants::match_default);
+    regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                   const regex_type&& __re,
+                   regex_constants::match_flag_type __m 
+                                     = regex_constants::match_default) = delete; // C++14
+    regex_iterator(const regex_iterator&);
+    regex_iterator& operator=(const regex_iterator&);
+
+    bool operator==(const regex_iterator&) const;
+    bool operator!=(const regex_iterator&) const;
+
+    const value_type& operator*() const;
+    const value_type* operator->() const;
+
+    regex_iterator& operator++();
+    regex_iterator operator++(int);
+};
+
+typedef regex_iterator<const char*>             cregex_iterator;
+typedef regex_iterator<const wchar_t*>          wcregex_iterator;
+typedef regex_iterator<string::const_iterator>  sregex_iterator;
+typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+
+template <class BidirectionalIterator,
+          class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+          class traits = regex_traits<charT>>
+class regex_token_iterator
+{
+public:
+    typedef basic_regex<charT, traits>       regex_type;
+    typedef sub_match<BidirectionalIterator> value_type;
+    typedef ptrdiff_t                        difference_type;
+    typedef const value_type*                pointer;
+    typedef const value_type&                reference;
+    typedef forward_iterator_tag             iterator_category;
+
+    regex_token_iterator();
+    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                         const regex_type& re, int submatch = 0,
+                         regex_constants::match_flag_type m = regex_constants::match_default);
+    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                         const regex_type&& re, int submatch = 0,
+                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                         const regex_type& re, const vector<int>& submatches,
+                         regex_constants::match_flag_type m = regex_constants::match_default);
+    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                         const regex_type&& re, const vector<int>& submatches,
+                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                         const regex_type& re, initializer_list<int> submatches,
+                         regex_constants::match_flag_type m = regex_constants::match_default);
+    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                         const regex_type&& re, initializer_list<int> submatches,
+                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14
+    template <size_t N>
+        regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                             const regex_type& re, const int (&submatches)[N],
+                             regex_constants::match_flag_type m = regex_constants::match_default);
+    template <size_t N>
+        regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+                             const regex_type& re, const int (&submatches)[N],
+                             regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14;
+    regex_token_iterator(const regex_token_iterator&);
+    regex_token_iterator& operator=(const regex_token_iterator&);
+
+    bool operator==(const regex_token_iterator&) const;
+    bool operator!=(const regex_token_iterator&) const;
+
+    const value_type& operator*() const;
+    const value_type* operator->() const;
+
+    regex_token_iterator& operator++();
+    regex_token_iterator operator++(int);
+};
+
+typedef regex_token_iterator<const char*>             cregex_token_iterator;
+typedef regex_token_iterator<const wchar_t*>          wcregex_token_iterator;
+typedef regex_token_iterator<string::const_iterator>  sregex_token_iterator;
+typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+
+} // std
+*/
+
+#include <__config>
+#include <stdexcept>
+#include <__locale>
+#include <initializer_list>
+#include <utility>
+#include <iterator>
+#include <string>
+#include <memory>
+#include <vector>
+#include <deque>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace regex_constants
+{
+
+// syntax_option_type
+
+enum syntax_option_type
+{
+    icase      = 1 << 0,
+    nosubs     = 1 << 1,
+    optimize   = 1 << 2,
+    collate    = 1 << 3,
+    ECMAScript = 0,
+    basic      = 1 << 4,
+    extended   = 1 << 5,
+    awk        = 1 << 6,
+    grep       = 1 << 7,
+    egrep      = 1 << 8
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator~(syntax_option_type __x)
+{
+    return syntax_option_type(~int(__x) & 0x1FF);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator&(syntax_option_type __x, syntax_option_type __y)
+{
+    return syntax_option_type(int(__x) & int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator|(syntax_option_type __x, syntax_option_type __y)
+{
+    return syntax_option_type(int(__x) | int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+syntax_option_type
+operator^(syntax_option_type __x, syntax_option_type __y)
+{
+    return syntax_option_type(int(__x) ^ int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+syntax_option_type&
+operator&=(syntax_option_type& __x, syntax_option_type __y)
+{
+    __x = __x & __y;
+    return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+syntax_option_type&
+operator|=(syntax_option_type& __x, syntax_option_type __y)
+{
+    __x = __x | __y;
+    return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+syntax_option_type&
+operator^=(syntax_option_type& __x, syntax_option_type __y)
+{
+    __x = __x ^ __y;
+    return __x;
+}
+
+// match_flag_type
+
+enum match_flag_type
+{
+    match_default     = 0,
+    match_not_bol     = 1 << 0,
+    match_not_eol     = 1 << 1,
+    match_not_bow     = 1 << 2,
+    match_not_eow     = 1 << 3,
+    match_any         = 1 << 4,
+    match_not_null    = 1 << 5,
+    match_continuous  = 1 << 6,
+    match_prev_avail  = 1 << 7,
+    format_default    = 0,
+    format_sed        = 1 << 8,
+    format_no_copy    = 1 << 9,
+    format_first_only = 1 << 10,
+    __no_update_pos   = 1 << 11
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator~(match_flag_type __x)
+{
+    return match_flag_type(~int(__x) & 0x0FFF);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator&(match_flag_type __x, match_flag_type __y)
+{
+    return match_flag_type(int(__x) & int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator|(match_flag_type __x, match_flag_type __y)
+{
+    return match_flag_type(int(__x) | int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_CONSTEXPR
+match_flag_type
+operator^(match_flag_type __x, match_flag_type __y)
+{
+    return match_flag_type(int(__x) ^ int(__y));
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+match_flag_type&
+operator&=(match_flag_type& __x, match_flag_type __y)
+{
+    __x = __x & __y;
+    return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+match_flag_type&
+operator|=(match_flag_type& __x, match_flag_type __y)
+{
+    __x = __x | __y;
+    return __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+match_flag_type&
+operator^=(match_flag_type& __x, match_flag_type __y)
+{
+    __x = __x ^ __y;
+    return __x;
+}
+
+enum error_type
+{
+    error_collate = 1,
+    error_ctype,
+    error_escape,
+    error_backref,
+    error_brack,
+    error_paren,
+    error_brace,
+    error_badbrace,
+    error_range,
+    error_space,
+    error_badrepeat,
+    error_complexity,
+    error_stack,
+    __re_err_grammar,
+    __re_err_empty,
+    __re_err_unknown
+};
+
+}  // regex_constants
+
+class _LIBCPP_EXCEPTION_ABI regex_error
+    : public runtime_error
+{
+    regex_constants::error_type __code_;
+public:
+    explicit regex_error(regex_constants::error_type __ecode);
+    virtual ~regex_error() throw();
+     _LIBCPP_INLINE_VISIBILITY
+    regex_constants::error_type code() const {return __code_;}
+};
+
+template <class _CharT>
+struct _LIBCPP_TYPE_VIS_ONLY regex_traits
+{
+public:
+    typedef _CharT                  char_type;
+    typedef basic_string<char_type> string_type;
+    typedef locale                  locale_type;
+    typedef ctype_base::mask        char_class_type;
+
+    static const char_class_type __regex_word = 0x80;
+private:
+    locale __loc_;
+    const ctype<char_type>* __ct_;
+    const collate<char_type>* __col_;
+
+public:
+    regex_traits();
+
+    _LIBCPP_INLINE_VISIBILITY
+    static size_t length(const char_type* __p)
+        {return char_traits<char_type>::length(__p);}
+    _LIBCPP_INLINE_VISIBILITY
+    char_type translate(char_type __c) const {return __c;}
+    char_type translate_nocase(char_type __c) const;
+    template <class _ForwardIterator>
+        string_type
+        transform(_ForwardIterator __f, _ForwardIterator __l) const;
+    template <class _ForwardIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        string_type
+        transform_primary( _ForwardIterator __f, _ForwardIterator __l) const
+            {return __transform_primary(__f, __l, char_type());}
+    template <class _ForwardIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        string_type
+        lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const
+            {return __lookup_collatename(__f, __l, char_type());}
+    template <class _ForwardIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        char_class_type
+        lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
+                         bool __icase = false) const
+            {return __lookup_classname(__f, __l, __icase, char_type());}
+    bool isctype(char_type __c, char_class_type __m) const;
+    _LIBCPP_INLINE_VISIBILITY
+    int value(char_type __ch, int __radix) const
+        {return __regex_traits_value(__ch, __radix);}
+    locale_type imbue(locale_type __l);
+    _LIBCPP_INLINE_VISIBILITY
+    locale_type getloc()const {return __loc_;}
+
+private:
+    void __init();
+
+    template <class _ForwardIterator>
+        string_type
+        __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
+    template <class _ForwardIterator>
+        string_type
+        __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
+
+    template <class _ForwardIterator>
+        string_type
+        __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
+    template <class _ForwardIterator>
+        string_type
+        __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
+
+    template <class _ForwardIterator>
+        char_class_type
+        __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
+                           bool __icase, char) const;
+    template <class _ForwardIterator>
+        char_class_type
+        __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,
+                           bool __icase, wchar_t) const;
+
+    static int __regex_traits_value(unsigned char __ch, int __radix);
+    _LIBCPP_INLINE_VISIBILITY
+    int __regex_traits_value(char __ch, int __radix) const
+        {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}
+    int __regex_traits_value(wchar_t __ch, int __radix) const;
+};
+
+template <class _CharT>
+const typename regex_traits<_CharT>::char_class_type
+regex_traits<_CharT>::__regex_word;
+
+template <class _CharT>
+regex_traits<_CharT>::regex_traits()
+{
+    __init();
+}
+
+template <class _CharT>
+typename regex_traits<_CharT>::char_type
+regex_traits<_CharT>::translate_nocase(char_type __c) const
+{
+    return __ct_->tolower(__c);
+}
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const
+{
+    string_type __s(__f, __l);
+    return __col_->transform(__s.data(), __s.data() + __s.size());
+}
+
+template <class _CharT>
+void
+regex_traits<_CharT>::__init()
+{
+    __ct_ = &use_facet<ctype<char_type> >(__loc_);
+    __col_ = &use_facet<collate<char_type> >(__loc_);
+}
+
+template <class _CharT>
+typename regex_traits<_CharT>::locale_type
+regex_traits<_CharT>::imbue(locale_type __l)
+{
+    locale __r = __loc_;
+    __loc_ = __l;
+    __init();
+    return __r;
+}
+
+// transform_primary is very FreeBSD-specific
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
+                                          _ForwardIterator __l, char) const
+{
+    const string_type __s(__f, __l);
+    string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
+    switch (__d.size())
+    {
+    case 1:
+        break;
+    case 12:
+        __d[11] = __d[3];
+        break;
+    default:
+        __d.clear();
+        break;
+    }
+    return __d;
+}
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,
+                                          _ForwardIterator __l, wchar_t) const
+{
+    const string_type __s(__f, __l);
+    string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());
+    switch (__d.size())
+    {
+    case 1:
+        break;
+    case 3:
+        __d[2] = __d[0];
+        break;
+    default:
+        __d.clear();
+        break;
+    }
+    return __d;
+}
+
+// lookup_collatename is very FreeBSD-specific
+
+_LIBCPP_FUNC_VIS string __get_collation_name(const char* __s);
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
+                                           _ForwardIterator __l, char) const
+{
+    string_type __s(__f, __l);
+    string_type __r;
+    if (!__s.empty())
+    {
+        __r = __get_collation_name(__s.c_str());
+        if (__r.empty() && __s.size() <= 2)
+        {
+            __r = __col_->transform(__s.data(), __s.data() + __s.size());
+            if (__r.size() == 1 || __r.size() == 12)
+                __r = __s;
+            else
+                __r.clear();
+        }
+    }
+    return __r;
+}
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::string_type
+regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,
+                                           _ForwardIterator __l, wchar_t) const
+{
+    string_type __s(__f, __l);
+    string __n;
+    __n.reserve(__s.size());
+    for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
+                                                              __i != __e; ++__i)
+    {
+        if (static_cast<unsigned>(*__i) >= 127)
+            return string_type();
+        __n.push_back(char(*__i));
+    }
+    string_type __r;
+    if (!__s.empty())
+    {
+        __n = __get_collation_name(__n.c_str());
+        if (!__n.empty())
+            __r.assign(__n.begin(), __n.end());
+        else if (__s.size() <= 2)
+        {
+            __r = __col_->transform(__s.data(), __s.data() + __s.size());
+            if (__r.size() == 1 || __r.size() == 3)
+                __r = __s;
+            else
+                __r.clear();
+        }
+    }
+    return __r;
+}
+
+// lookup_classname
+
+ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase);
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::char_class_type
+regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
+                                         _ForwardIterator __l,
+                                         bool __icase, char) const
+{
+    string_type __s(__f, __l);
+    __ct_->tolower(&__s[0], &__s[0] + __s.size());
+    return __get_classname(__s.c_str(), __icase);
+}
+
+template <class _CharT>
+template <class _ForwardIterator>
+typename regex_traits<_CharT>::char_class_type
+regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f,
+                                         _ForwardIterator __l,
+                                         bool __icase, wchar_t) const
+{
+    string_type __s(__f, __l);
+    __ct_->tolower(&__s[0], &__s[0] + __s.size());
+    string __n;
+    __n.reserve(__s.size());
+    for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end();
+                                                              __i != __e; ++__i)
+    {
+        if (static_cast<unsigned>(*__i) >= 127)
+            return char_class_type();
+        __n.push_back(char(*__i));
+    }
+    return __get_classname(__n.c_str(), __icase);
+}
+
+template <class _CharT>
+bool
+regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const
+{
+    if (__ct_->is(__m, __c))
+        return true;
+    return (__c == '_' && (__m & __regex_word));
+}
+
+template <class _CharT>
+int
+regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
+{
+    if ((__ch & 0xF8u) == 0x30)  // '0' <= __ch && __ch <= '7'
+        return __ch - '0';
+    if (__radix != 8)
+    {
+        if ((__ch & 0xFEu) == 0x38)  // '8' <= __ch && __ch <= '9'
+            return __ch - '0';
+        if (__radix == 16)
+        {
+            __ch |= 0x20;  // tolower
+            if ('a' <= __ch && __ch <= 'f')
+                return __ch - ('a' - 10);
+        }
+    }
+    return -1;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+int
+regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const
+{
+    return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
+}
+
+template <class _CharT> class __node;
+
+template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS_ONLY sub_match;
+
+template <class _BidirectionalIterator,
+          class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
+class _LIBCPP_TYPE_VIS_ONLY match_results;
+
+template <class _CharT>
+struct __state
+{
+    enum
+    {
+        __end_state = -1000,
+        __consume_input,  // -999
+        __begin_marked_expr, // -998
+        __end_marked_expr,   // -997
+        __pop_state,           // -996
+        __accept_and_consume,  // -995
+        __accept_but_not_consume,  // -994
+        __reject,                  // -993
+        __split,
+        __repeat
+    };
+
+    int __do_;
+    const _CharT* __first_;
+    const _CharT* __current_;
+    const _CharT* __last_;
+    vector<sub_match<const _CharT*> > __sub_matches_;
+    vector<pair<size_t, const _CharT*> > __loop_data_;
+    const __node<_CharT>* __node_;
+    regex_constants::match_flag_type __flags_;
+    bool __at_first_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __state()
+        : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr),
+          __node_(nullptr), __flags_() {}
+};
+
+// __node
+
+template <class _CharT>
+class __node
+{
+    __node(const __node&);
+    __node& operator=(const __node&);
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __node() {}
+    _LIBCPP_INLINE_VISIBILITY
+    virtual ~__node() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    virtual void __exec(__state&) const {};
+    _LIBCPP_INLINE_VISIBILITY
+    virtual void __exec_split(bool, __state&) const {};
+};
+
+// __end_state
+
+template <class _CharT>
+class __end_state
+    : public __node<_CharT>
+{
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __end_state() {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__end_state<_CharT>::__exec(__state& __s) const
+{
+    __s.__do_ = __state::__end_state;
+}
+
+// __has_one_state
+
+template <class _CharT>
+class __has_one_state
+    : public __node<_CharT>
+{
+    __node<_CharT>* __first_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __has_one_state(__node<_CharT>* __s)
+        : __first_(__s) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __node<_CharT>*  first() const {return __first_;}
+    _LIBCPP_INLINE_VISIBILITY
+    __node<_CharT>*& first()       {return __first_;}
+};
+
+// __owns_one_state
+
+template <class _CharT>
+class __owns_one_state
+    : public __has_one_state<_CharT>
+{
+    typedef __has_one_state<_CharT> base;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __owns_one_state(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual ~__owns_one_state();
+};
+
+template <class _CharT>
+__owns_one_state<_CharT>::~__owns_one_state()
+{
+    delete this->first();
+}
+
+// __empty_state
+
+template <class _CharT>
+class __empty_state
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __empty_state(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__empty_state<_CharT>::__exec(__state& __s) const
+{
+    __s.__do_ = __state::__accept_but_not_consume;
+    __s.__node_ = this->first();
+}
+
+// __empty_non_own_state
+
+template <class _CharT>
+class __empty_non_own_state
+    : public __has_one_state<_CharT>
+{
+    typedef __has_one_state<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __empty_non_own_state(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__empty_non_own_state<_CharT>::__exec(__state& __s) const
+{
+    __s.__do_ = __state::__accept_but_not_consume;
+    __s.__node_ = this->first();
+}
+
+// __repeat_one_loop
+
+template <class _CharT>
+class __repeat_one_loop
+    : public __has_one_state<_CharT>
+{
+    typedef __has_one_state<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __repeat_one_loop(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__repeat_one_loop<_CharT>::__exec(__state& __s) const
+{
+    __s.__do_ = __state::__repeat;
+    __s.__node_ = this->first();
+}
+
+// __owns_two_states
+
+template <class _CharT>
+class __owns_two_states
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    base* __second_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __owns_two_states(__node<_CharT>* __s1, base* __s2)
+        : base(__s1), __second_(__s2) {}
+
+    virtual ~__owns_two_states();
+
+    _LIBCPP_INLINE_VISIBILITY
+    base*  second() const {return __second_;}
+    _LIBCPP_INLINE_VISIBILITY
+    base*& second()       {return __second_;}
+};
+
+template <class _CharT>
+__owns_two_states<_CharT>::~__owns_two_states()
+{
+    delete __second_;
+}
+
+// __loop
+
+template <class _CharT>
+class __loop
+    : public __owns_two_states<_CharT>
+{
+    typedef __owns_two_states<_CharT> base;
+
+    size_t __min_;
+    size_t __max_;
+    unsigned __loop_id_;
+    unsigned __mexp_begin_;
+    unsigned __mexp_end_;
+    bool __greedy_;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __loop(unsigned __loop_id,
+                          __node<_CharT>* __s1, __owns_one_state<_CharT>* __s2,
+                          unsigned __mexp_begin, unsigned __mexp_end,
+                          bool __greedy = true,
+                          size_t __min = 0,
+                          size_t __max = numeric_limits<size_t>::max())
+        : base(__s1, __s2), __min_(__min), __max_(__max), __loop_id_(__loop_id),
+          __mexp_begin_(__mexp_begin), __mexp_end_(__mexp_end),
+          __greedy_(__greedy) {}
+
+    virtual void __exec(__state& __s) const;
+    virtual void __exec_split(bool __second, __state& __s) const;
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    void __init_repeat(__state& __s) const
+    {
+        __s.__loop_data_[__loop_id_].second = __s.__current_;
+        for (size_t __i = __mexp_begin_-1; __i != __mexp_end_-1; ++__i)
+        {
+            __s.__sub_matches_[__i].first = __s.__last_;
+            __s.__sub_matches_[__i].second = __s.__last_;
+            __s.__sub_matches_[__i].matched = false;
+        }
+    }
+};
+
+template <class _CharT>
+void
+__loop<_CharT>::__exec(__state& __s) const
+{
+    if (__s.__do_ == __state::__repeat)
+    {
+        bool __do_repeat = ++__s.__loop_data_[__loop_id_].first < __max_;
+        bool __do_alt = __s.__loop_data_[__loop_id_].first >= __min_;
+        if (__do_repeat && __do_alt &&
+                               __s.__loop_data_[__loop_id_].second == __s.__current_)
+            __do_repeat = false;
+        if (__do_repeat && __do_alt)
+            __s.__do_ = __state::__split;
+        else if (__do_repeat)
+        {
+            __s.__do_ = __state::__accept_but_not_consume;
+            __s.__node_ = this->first();
+            __init_repeat(__s);
+        }
+        else
+        {
+            __s.__do_ = __state::__accept_but_not_consume;
+            __s.__node_ = this->second();
+        }
+    }
+    else
+    {
+        __s.__loop_data_[__loop_id_].first = 0;
+        bool __do_repeat = 0 < __max_;
+        bool __do_alt = 0 >= __min_;
+        if (__do_repeat && __do_alt)
+            __s.__do_ = __state::__split;
+        else if (__do_repeat)
+        {
+            __s.__do_ = __state::__accept_but_not_consume;
+            __s.__node_ = this->first();
+            __init_repeat(__s);
+        }
+        else
+        {
+            __s.__do_ = __state::__accept_but_not_consume;
+            __s.__node_ = this->second();
+        }
+    }
+}
+
+template <class _CharT>
+void
+__loop<_CharT>::__exec_split(bool __second, __state& __s) const
+{
+    __s.__do_ = __state::__accept_but_not_consume;
+    if (__greedy_ != __second)
+    {
+        __s.__node_ = this->first();
+        __init_repeat(__s);
+    }
+    else
+        __s.__node_ = this->second();
+}
+
+// __alternate
+
+template <class _CharT>
+class __alternate
+    : public __owns_two_states<_CharT>
+{
+    typedef __owns_two_states<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __alternate(__owns_one_state<_CharT>* __s1,
+                         __owns_one_state<_CharT>* __s2)
+        : base(__s1, __s2) {}
+
+    virtual void __exec(__state& __s) const;
+    virtual void __exec_split(bool __second, __state& __s) const;
+};
+
+template <class _CharT>
+void
+__alternate<_CharT>::__exec(__state& __s) const
+{
+    __s.__do_ = __state::__split;
+}
+
+template <class _CharT>
+void
+__alternate<_CharT>::__exec_split(bool __second, __state& __s) const
+{
+    __s.__do_ = __state::__accept_but_not_consume;
+    if (__second)
+        __s.__node_ = this->second();
+    else
+        __s.__node_ = this->first();
+}
+
+// __begin_marked_subexpression
+
+template <class _CharT>
+class __begin_marked_subexpression
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    unsigned __mexp_;
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __begin_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
+        : base(__s), __mexp_(__mexp) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__begin_marked_subexpression<_CharT>::__exec(__state& __s) const
+{
+    __s.__do_ = __state::__accept_but_not_consume;
+    __s.__sub_matches_[__mexp_-1].first = __s.__current_;
+    __s.__node_ = this->first();
+}
+
+// __end_marked_subexpression
+
+template <class _CharT>
+class __end_marked_subexpression
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    unsigned __mexp_;
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __end_marked_subexpression(unsigned __mexp, __node<_CharT>* __s)
+        : base(__s), __mexp_(__mexp) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__end_marked_subexpression<_CharT>::__exec(__state& __s) const
+{
+    __s.__do_ = __state::__accept_but_not_consume;
+    __s.__sub_matches_[__mexp_-1].second = __s.__current_;
+    __s.__sub_matches_[__mexp_-1].matched = true;
+    __s.__node_ = this->first();
+}
+
+// __back_ref
+
+template <class _CharT>
+class __back_ref
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    unsigned __mexp_;
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __back_ref(unsigned __mexp, __node<_CharT>* __s)
+        : base(__s), __mexp_(__mexp) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__back_ref<_CharT>::__exec(__state& __s) const
+{
+    sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
+    if (__sm.matched)
+    {
+        ptrdiff_t __len = __sm.second - __sm.first;
+        if (__s.__last_ - __s.__current_ >= __len &&
+            _VSTD::equal(__sm.first, __sm.second, __s.__current_))
+        {
+            __s.__do_ = __state::__accept_but_not_consume;
+            __s.__current_ += __len;
+            __s.__node_ = this->first();
+        }
+        else
+        {
+            __s.__do_ = __state::__reject;
+            __s.__node_ = nullptr;
+        }
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __back_ref_icase
+
+template <class _CharT, class _Traits>
+class __back_ref_icase
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    _Traits __traits_;
+    unsigned __mexp_;
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __back_ref_icase(const _Traits& __traits, unsigned __mexp,
+                              __node<_CharT>* __s)
+        : base(__s), __traits_(__traits), __mexp_(__mexp) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__back_ref_icase<_CharT, _Traits>::__exec(__state& __s) const
+{
+    sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
+    if (__sm.matched)
+    {
+        ptrdiff_t __len = __sm.second - __sm.first;
+        if (__s.__last_ - __s.__current_ >= __len)
+        {
+            for (ptrdiff_t __i = 0; __i < __len; ++__i)
+            {
+                if (__traits_.translate_nocase(__sm.first[__i]) !=
+                                __traits_.translate_nocase(__s.__current_[__i]))
+                    goto __not_equal;
+            }
+            __s.__do_ = __state::__accept_but_not_consume;
+            __s.__current_ += __len;
+            __s.__node_ = this->first();
+        }
+        else
+        {
+            __s.__do_ = __state::__reject;
+            __s.__node_ = nullptr;
+        }
+    }
+    else
+    {
+__not_equal:
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __back_ref_collate
+
+template <class _CharT, class _Traits>
+class __back_ref_collate
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    _Traits __traits_;
+    unsigned __mexp_;
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __back_ref_collate(const _Traits& __traits, unsigned __mexp,
+                              __node<_CharT>* __s)
+        : base(__s), __traits_(__traits), __mexp_(__mexp) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__back_ref_collate<_CharT, _Traits>::__exec(__state& __s) const
+{
+    sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_-1];
+    if (__sm.matched)
+    {
+        ptrdiff_t __len = __sm.second - __sm.first;
+        if (__s.__last_ - __s.__current_ >= __len)
+        {
+            for (ptrdiff_t __i = 0; __i < __len; ++__i)
+            {
+                if (__traits_.translate(__sm.first[__i]) !=
+                                       __traits_.translate(__s.__current_[__i]))
+                    goto __not_equal;
+            }
+            __s.__do_ = __state::__accept_but_not_consume;
+            __s.__current_ += __len;
+            __s.__node_ = this->first();
+        }
+        else
+        {
+            __s.__do_ = __state::__reject;
+            __s.__node_ = nullptr;
+        }
+    }
+    else
+    {
+__not_equal:
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __word_boundary
+
+template <class _CharT, class _Traits>
+class __word_boundary
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    _Traits __traits_;
+    bool __invert_;
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __word_boundary(const _Traits& __traits, bool __invert,
+                             __node<_CharT>* __s)
+        : base(__s), __traits_(__traits), __invert_(__invert) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__word_boundary<_CharT, _Traits>::__exec(__state& __s) const
+{
+    bool __is_word_b = false;
+    if (__s.__first_ != __s.__last_)
+    {
+        if (__s.__current_ == __s.__last_)
+        {
+            if (!(__s.__flags_ & regex_constants::match_not_eow))
+            {
+                _CharT __c = __s.__current_[-1];
+                __is_word_b = __c == '_' ||
+                              __traits_.isctype(__c, ctype_base::alnum);
+            }
+        }
+        else if (__s.__current_ == __s.__first_ &&
+                !(__s.__flags_ & regex_constants::match_prev_avail))
+        {
+            if (!(__s.__flags_ & regex_constants::match_not_bow))
+            {
+                _CharT __c = *__s.__current_;
+                __is_word_b = __c == '_' ||
+                              __traits_.isctype(__c, ctype_base::alnum);
+            }
+        }
+        else
+        {
+            _CharT __c1 = __s.__current_[-1];
+            _CharT __c2 = *__s.__current_;
+            bool __is_c1_b = __c1 == '_' ||
+                             __traits_.isctype(__c1, ctype_base::alnum);
+            bool __is_c2_b = __c2 == '_' ||
+                             __traits_.isctype(__c2, ctype_base::alnum);
+            __is_word_b = __is_c1_b != __is_c2_b;
+        }
+    }
+    if (__is_word_b != __invert_)
+    {
+        __s.__do_ = __state::__accept_but_not_consume;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __l_anchor
+
+template <class _CharT>
+class __l_anchor
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __l_anchor(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__l_anchor<_CharT>::__exec(__state& __s) const
+{
+    if (__s.__at_first_ && __s.__current_ == __s.__first_)
+    {
+        __s.__do_ = __state::__accept_but_not_consume;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __r_anchor
+
+template <class _CharT>
+class __r_anchor
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __r_anchor(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__r_anchor<_CharT>::__exec(__state& __s) const
+{
+    if (__s.__current_ == __s.__last_)
+    {
+        __s.__do_ = __state::__accept_but_not_consume;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __match_any
+
+template <class _CharT>
+class __match_any
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __match_any(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__match_any<_CharT>::__exec(__state& __s) const
+{
+    if (__s.__current_ != __s.__last_ && *__s.__current_ != 0)
+    {
+        __s.__do_ = __state::__accept_and_consume;
+        ++__s.__current_;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __match_any_but_newline
+
+template <class _CharT>
+class __match_any_but_newline
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __match_any_but_newline(__node<_CharT>* __s)
+        : base(__s) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const;
+template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const;
+
+// __match_char
+
+template <class _CharT>
+class __match_char
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    _CharT __c_;
+
+    __match_char(const __match_char&);
+    __match_char& operator=(const __match_char&);
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __match_char(_CharT __c, __node<_CharT>* __s)
+        : base(__s), __c_(__c) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT>
+void
+__match_char<_CharT>::__exec(__state& __s) const
+{
+    if (__s.__current_ != __s.__last_ && *__s.__current_ == __c_)
+    {
+        __s.__do_ = __state::__accept_and_consume;
+        ++__s.__current_;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __match_char_icase
+
+template <class _CharT, class _Traits>
+class __match_char_icase
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    _Traits __traits_;
+    _CharT __c_;
+
+    __match_char_icase(const __match_char_icase&);
+    __match_char_icase& operator=(const __match_char_icase&);
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
+        : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__match_char_icase<_CharT, _Traits>::__exec(__state& __s) const
+{
+    if (__s.__current_ != __s.__last_ &&
+        __traits_.translate_nocase(*__s.__current_) == __c_)
+    {
+        __s.__do_ = __state::__accept_and_consume;
+        ++__s.__current_;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __match_char_collate
+
+template <class _CharT, class _Traits>
+class __match_char_collate
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    _Traits __traits_;
+    _CharT __c_;
+
+    __match_char_collate(const __match_char_collate&);
+    __match_char_collate& operator=(const __match_char_collate&);
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
+        : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__match_char_collate<_CharT, _Traits>::__exec(__state& __s) const
+{
+    if (__s.__current_ != __s.__last_ &&
+        __traits_.translate(*__s.__current_) == __c_)
+    {
+        __s.__do_ = __state::__accept_and_consume;
+        ++__s.__current_;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+// __bracket_expression
+
+template <class _CharT, class _Traits>
+class __bracket_expression
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+    typedef typename _Traits::string_type string_type;
+
+    _Traits __traits_;
+    vector<_CharT> __chars_;
+    vector<_CharT> __neg_chars_;
+    vector<pair<string_type, string_type> > __ranges_;
+    vector<pair<_CharT, _CharT> > __digraphs_;
+    vector<string_type> __equivalences_;
+    ctype_base::mask __mask_;
+    ctype_base::mask __neg_mask_;
+    bool __negate_;
+    bool __icase_;
+    bool __collate_;
+    bool __might_have_digraph_;
+
+    __bracket_expression(const __bracket_expression&);
+    __bracket_expression& operator=(const __bracket_expression&);
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __bracket_expression(const _Traits& __traits, __node<_CharT>* __s,
+                                 bool __negate, bool __icase, bool __collate)
+        : base(__s), __traits_(__traits), __mask_(), __neg_mask_(),
+          __negate_(__negate), __icase_(__icase), __collate_(__collate),
+          __might_have_digraph_(__traits_.getloc().name() != "C") {}
+
+    virtual void __exec(__state&) const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool __negated() const {return __negate_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __add_char(_CharT __c)
+        {
+            if (__icase_)
+                __chars_.push_back(__traits_.translate_nocase(__c));
+            else if (__collate_)
+                __chars_.push_back(__traits_.translate(__c));
+            else
+                __chars_.push_back(__c);
+        }
+    _LIBCPP_INLINE_VISIBILITY
+    void __add_neg_char(_CharT __c)
+        {
+            if (__icase_)
+                __neg_chars_.push_back(__traits_.translate_nocase(__c));
+            else if (__collate_)
+                __neg_chars_.push_back(__traits_.translate(__c));
+            else
+                __neg_chars_.push_back(__c);
+        }
+    _LIBCPP_INLINE_VISIBILITY
+    void __add_range(string_type __b, string_type __e)
+        {
+            if (__collate_)
+            {
+                if (__icase_)
+                {
+                    for (size_t __i = 0; __i < __b.size(); ++__i)
+                        __b[__i] = __traits_.translate_nocase(__b[__i]);
+                    for (size_t __i = 0; __i < __e.size(); ++__i)
+                        __e[__i] = __traits_.translate_nocase(__e[__i]);
+                }
+                else
+                {
+                    for (size_t __i = 0; __i < __b.size(); ++__i)
+                        __b[__i] = __traits_.translate(__b[__i]);
+                    for (size_t __i = 0; __i < __e.size(); ++__i)
+                        __e[__i] = __traits_.translate(__e[__i]);
+                }
+                __ranges_.push_back(make_pair(
+                                  __traits_.transform(__b.begin(), __b.end()),
+                                  __traits_.transform(__e.begin(), __e.end())));
+            }
+            else
+            {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (__b.size() != 1 || __e.size() != 1)
+                    throw regex_error(regex_constants::error_collate);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                if (__icase_)
+                {
+                    __b[0] = __traits_.translate_nocase(__b[0]);
+                    __e[0] = __traits_.translate_nocase(__e[0]);
+                }
+                __ranges_.push_back(make_pair(_VSTD::move(__b), _VSTD::move(__e)));
+            }
+        }
+    _LIBCPP_INLINE_VISIBILITY
+    void __add_digraph(_CharT __c1, _CharT __c2)
+        {
+            if (__icase_)
+                __digraphs_.push_back(make_pair(__traits_.translate_nocase(__c1),
+                                                __traits_.translate_nocase(__c2)));
+            else if (__collate_)
+                __digraphs_.push_back(make_pair(__traits_.translate(__c1),
+                                                __traits_.translate(__c2)));
+            else
+                __digraphs_.push_back(make_pair(__c1, __c2));
+        }
+    _LIBCPP_INLINE_VISIBILITY
+    void __add_equivalence(const string_type& __s)
+        {__equivalences_.push_back(__s);}
+    _LIBCPP_INLINE_VISIBILITY
+    void __add_class(ctype_base::mask __mask)
+        {__mask_ |= __mask;}
+    _LIBCPP_INLINE_VISIBILITY
+    void __add_neg_class(ctype_base::mask __mask)
+        {__neg_mask_ |= __mask;}
+};
+
+template <class _CharT, class _Traits>
+void
+__bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
+{
+    bool __found = false;
+    unsigned __consumed = 0;
+    if (__s.__current_ != __s.__last_)
+    {
+        ++__consumed;
+        if (__might_have_digraph_)
+        {
+            const _CharT* __next = _VSTD::next(__s.__current_);
+            if (__next != __s.__last_)
+            {
+                pair<_CharT, _CharT> __ch2(*__s.__current_, *__next);
+                if (__icase_)
+                {
+                    __ch2.first = __traits_.translate_nocase(__ch2.first);
+                    __ch2.second = __traits_.translate_nocase(__ch2.second);
+                }
+                else if (__collate_)
+                {
+                    __ch2.first = __traits_.translate(__ch2.first);
+                    __ch2.second = __traits_.translate(__ch2.second);
+                }
+                if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first+2).empty())
+                {
+                    // __ch2 is a digraph in this locale
+                    ++__consumed;
+                    for (size_t __i = 0; __i < __digraphs_.size(); ++__i)
+                    {
+                        if (__ch2 == __digraphs_[__i])
+                        {
+                            __found = true;
+                            goto __exit;
+                        }
+                    }
+                    if (__collate_ && !__ranges_.empty())
+                    {
+                        string_type __s2 = __traits_.transform(&__ch2.first,
+                                                               &__ch2.first + 2);
+                        for (size_t __i = 0; __i < __ranges_.size(); ++__i)
+                        {
+                            if (__ranges_[__i].first <= __s2 &&
+                                __s2 <= __ranges_[__i].second)
+                            {
+                                __found = true;
+                                goto __exit;
+                            }
+                        }
+                    }
+                    if (!__equivalences_.empty())
+                    {
+                        string_type __s2 = __traits_.transform_primary(&__ch2.first,
+                                                                       &__ch2.first + 2);
+                        for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
+                        {
+                            if (__s2 == __equivalences_[__i])
+                            {
+                                __found = true;
+                                goto __exit;
+                            }
+                        }
+                    }
+                    if (__traits_.isctype(__ch2.first, __mask_) &&
+                        __traits_.isctype(__ch2.second, __mask_))
+                    {
+                        __found = true;
+                        goto __exit;
+                    }
+                    if (!__traits_.isctype(__ch2.first, __neg_mask_) &&
+                        !__traits_.isctype(__ch2.second, __neg_mask_))
+                    {
+                        __found = true;
+                        goto __exit;
+                    }
+                    goto __exit;
+                }
+            }
+        }
+        // test *__s.__current_ as not a digraph
+        _CharT __ch = *__s.__current_;
+        if (__icase_)
+            __ch = __traits_.translate_nocase(__ch);
+        else if (__collate_)
+            __ch = __traits_.translate(__ch);
+        for (size_t __i = 0; __i < __chars_.size(); ++__i)
+        {
+            if (__ch == __chars_[__i])
+            {
+                __found = true;
+                goto __exit;
+            }
+        }
+        if (!__neg_chars_.empty())
+        {
+            for (size_t __i = 0; __i < __neg_chars_.size(); ++__i)
+            {
+                if (__ch == __neg_chars_[__i])
+                    goto __is_neg_char;
+            }
+            __found = true;
+            goto __exit;
+        }
+__is_neg_char:
+        if (!__ranges_.empty())
+        {
+            string_type __s2 = __collate_ ?
+                                   __traits_.transform(&__ch, &__ch + 1) :
+                                   string_type(1, __ch);
+            for (size_t __i = 0; __i < __ranges_.size(); ++__i)
+            {
+                if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second)
+                {
+                    __found = true;
+                    goto __exit;
+                }
+            }
+        }
+        if (!__equivalences_.empty())
+        {
+            string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);
+            for (size_t __i = 0; __i < __equivalences_.size(); ++__i)
+            {
+                if (__s2 == __equivalences_[__i])
+                {
+                    __found = true;
+                    goto __exit;
+                }
+            }
+        }
+        if (__traits_.isctype(__ch, __mask_))
+        {
+            __found = true;
+            goto __exit;
+        }
+        if (__neg_mask_ && !__traits_.isctype(__ch, __neg_mask_))
+        {
+            __found = true;
+            goto __exit;
+        }
+    }
+    else
+        __found = __negate_;  // force reject
+__exit:
+    if (__found != __negate_)
+    {
+        __s.__do_ = __state::__accept_and_consume;
+        __s.__current_ += __consumed;
+        __s.__node_ = this->first();
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+template <class _CharT, class _Traits> class __lookahead;
+
+template <class _CharT, class _Traits = regex_traits<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY basic_regex
+{
+public:
+    // types:
+    typedef _CharT                              value_type;
+    typedef regex_constants::syntax_option_type flag_type;
+    typedef typename _Traits::locale_type       locale_type;
+
+private:
+    _Traits   __traits_;
+    flag_type __flags_;
+    unsigned __marked_count_;
+    unsigned __loop_count_;
+    int __open_count_;
+    shared_ptr<__empty_state<_CharT> > __start_;
+    __owns_one_state<_CharT>* __end_;
+
+    typedef _VSTD::__state<_CharT> __state;
+    typedef _VSTD::__node<_CharT> __node;
+
+public:
+    // constants:
+    static const regex_constants::syntax_option_type icase = regex_constants::icase;
+    static const regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+    static const regex_constants::syntax_option_type optimize = regex_constants::optimize;
+    static const regex_constants::syntax_option_type collate = regex_constants::collate;
+    static const regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+    static const regex_constants::syntax_option_type basic = regex_constants::basic;
+    static const regex_constants::syntax_option_type extended = regex_constants::extended;
+    static const regex_constants::syntax_option_type awk = regex_constants::awk;
+    static const regex_constants::syntax_option_type grep = regex_constants::grep;
+    static const regex_constants::syntax_option_type egrep = regex_constants::egrep;
+
+    // construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex()
+        : __flags_(), __marked_count_(0), __loop_count_(0), __open_count_(0),
+          __end_(0)
+        {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit basic_regex(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
+        : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+          __end_(0)
+        {__parse(__p, __p + __traits_.length(__p));}
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex(const value_type* __p, size_t __len, flag_type __f)
+        : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+          __end_(0)
+        {__parse(__p, __p + __len);}
+//     basic_regex(const basic_regex&) = default;
+//     basic_regex(basic_regex&&) = default;
+    template <class _ST, class _SA>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit basic_regex(const basic_string<value_type, _ST, _SA>& __p,
+                             flag_type __f = regex_constants::ECMAScript)
+        : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+          __end_(0)
+        {__parse(__p.begin(), __p.end());}
+    template <class _ForwardIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        basic_regex(_ForwardIterator __first, _ForwardIterator __last,
+                    flag_type __f = regex_constants::ECMAScript)
+        : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+          __end_(0)
+        {__parse(__first, __last);}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex(initializer_list<value_type> __il,
+                flag_type __f = regex_constants::ECMAScript)
+        : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0),
+          __end_(0)
+        {__parse(__il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+//    ~basic_regex() = default;
+
+//     basic_regex& operator=(const basic_regex&) = default;
+//     basic_regex& operator=(basic_regex&&) = default;
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex& operator=(const value_type* __p)
+        {return assign(__p);}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex& operator=(initializer_list<value_type> __il)
+        {return assign(__il);}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    template <class _ST, class _SA>
+        _LIBCPP_INLINE_VISIBILITY
+        basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p)
+        {return assign(__p);}
+
+    // assign:
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex& assign(const basic_regex& __that)
+        {return *this = __that;}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex& assign(basic_regex&& __that) _NOEXCEPT
+        {return *this = _VSTD::move(__that);}
+#endif
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript)
+        {return assign(__p, __p + __traits_.length(__p), __f);}
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex& assign(const value_type* __p, size_t __len, flag_type __f)
+        {return assign(__p, __p + __len, __f);}
+    template <class _ST, class _SA>
+        _LIBCPP_INLINE_VISIBILITY
+        basic_regex& assign(const basic_string<value_type, _ST, _SA>& __s,
+                            flag_type __f = regex_constants::ECMAScript)
+            {return assign(__s.begin(), __s.end(), __f);}
+
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+             __is_input_iterator  <_InputIterator>::value &&
+            !__is_forward_iterator<_InputIterator>::value,
+            basic_regex&
+        >::type
+        assign(_InputIterator __first, _InputIterator __last,
+                            flag_type __f = regex_constants::ECMAScript)
+        {
+            basic_string<_CharT> __t(__first, __last);
+            return assign(__t.begin(), __t.end(), __f);
+        }
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    void __member_init(flag_type __f)
+    {
+        __flags_ = __f;
+        __marked_count_ = 0;
+        __loop_count_ = 0;
+        __open_count_ = 0;
+        __end_ = nullptr;
+    }
+public:
+
+    template <class _ForwardIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            basic_regex&
+        >::type
+        assign(_ForwardIterator __first, _ForwardIterator __last,
+                            flag_type __f = regex_constants::ECMAScript)
+        {
+            __member_init(__f);
+            __parse(__first, __last);
+            return *this;
+        }
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    basic_regex& assign(initializer_list<value_type> __il,
+                        flag_type __f = regex_constants::ECMAScript)
+        {return assign(__il.begin(), __il.end(), __f);}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    // const operations:
+    _LIBCPP_INLINE_VISIBILITY
+    unsigned mark_count() const {return __marked_count_;}
+    _LIBCPP_INLINE_VISIBILITY
+    flag_type flags() const {return __flags_;}
+
+    // locale:
+    _LIBCPP_INLINE_VISIBILITY
+    locale_type imbue(locale_type __loc)
+    {
+        __member_init(ECMAScript);
+        __start_.reset();
+        return __traits_.imbue(__loc);
+    }
+    _LIBCPP_INLINE_VISIBILITY
+    locale_type getloc() const {return __traits_.getloc();}
+
+    // swap:
+    void swap(basic_regex& __r);
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    unsigned __loop_count() const {return __loop_count_;}
+
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_basic_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_RE_expression(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_simple_RE(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_nondupl_RE(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_one_char_or_coll_elem_RE(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_Back_open_paren(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_Back_close_paren(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_Back_open_brace(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_Back_close_brace(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_BACKREF(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_ORD_CHAR(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_QUOTED_CHAR(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_RE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
+                               __owns_one_state<_CharT>* __s,
+                               unsigned __mexp_begin, unsigned __mexp_end);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_ERE_dupl_symbol(_ForwardIterator __first, _ForwardIterator __last,
+                                __owns_one_state<_CharT>* __s,
+                                unsigned __mexp_begin, unsigned __mexp_end);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_bracket_expression(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_follow_list(_ForwardIterator __first, _ForwardIterator __last,
+                            __bracket_expression<_CharT, _Traits>* __ml);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_expression_term(_ForwardIterator __first, _ForwardIterator __last,
+                                __bracket_expression<_CharT, _Traits>* __ml);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_equivalence_class(_ForwardIterator __first, _ForwardIterator __last,
+                                  __bracket_expression<_CharT, _Traits>* __ml);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_character_class(_ForwardIterator __first, _ForwardIterator __last,
+                                __bracket_expression<_CharT, _Traits>* __ml);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_collating_symbol(_ForwardIterator __first, _ForwardIterator __last,
+                                 basic_string<_CharT>& __col_sym);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_DUP_COUNT(_ForwardIterator __first, _ForwardIterator __last, int& __c);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_extended_reg_exp(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_ERE_expression(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_one_char_or_coll_elem_ERE(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_ORD_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_QUOTED_CHAR_ERE(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_ecma_exp(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_alternative(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_term(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_assertion(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_atom(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_atom_escape(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_decimal_escape(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_character_class_escape(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_character_escape(_ForwardIterator __first, _ForwardIterator __last,
+                                 basic_string<_CharT>* __str = nullptr);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_pattern_character(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_grep(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_egrep(_ForwardIterator __first, _ForwardIterator __last);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_class_escape(_ForwardIterator __first, _ForwardIterator __last,
+                          basic_string<_CharT>& __str,
+                          __bracket_expression<_CharT, _Traits>* __ml);
+    template <class _ForwardIterator>
+        _ForwardIterator
+        __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last,
+                          basic_string<_CharT>* __str = nullptr);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __push_l_anchor();
+    void __push_r_anchor();
+    void __push_match_any();
+    void __push_match_any_but_newline();
+    _LIBCPP_INLINE_VISIBILITY
+    void __push_greedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
+                                  unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
+        {__push_loop(__min, numeric_limits<size_t>::max(), __s,
+                     __mexp_begin, __mexp_end);}
+    _LIBCPP_INLINE_VISIBILITY
+    void __push_nongreedy_inf_repeat(size_t __min, __owns_one_state<_CharT>* __s,
+                                  unsigned __mexp_begin = 0, unsigned __mexp_end = 0)
+        {__push_loop(__min, numeric_limits<size_t>::max(), __s,
+                     __mexp_begin, __mexp_end, false);}
+    void __push_loop(size_t __min, size_t __max, __owns_one_state<_CharT>* __s,
+                     size_t __mexp_begin = 0, size_t __mexp_end = 0,
+                     bool __greedy = true);
+    __bracket_expression<_CharT, _Traits>* __start_matching_list(bool __negate);
+    void __push_char(value_type __c);
+    void __push_back_ref(int __i);
+    void __push_alternation(__owns_one_state<_CharT>* __sa,
+                            __owns_one_state<_CharT>* __sb);
+    void __push_begin_marked_subexpression();
+    void __push_end_marked_subexpression(unsigned);
+    void __push_empty();
+    void __push_word_boundary(bool);
+    void __push_lookahead(const basic_regex&, bool, unsigned);
+
+    template <class _Allocator>
+        bool
+        __search(const _CharT* __first, const _CharT* __last,
+                 match_results<const _CharT*, _Allocator>& __m,
+                 regex_constants::match_flag_type __flags) const;
+
+    template <class _Allocator>
+        bool
+        __match_at_start(const _CharT* __first, const _CharT* __last,
+                 match_results<const _CharT*, _Allocator>& __m,
+                 regex_constants::match_flag_type __flags, bool) const;
+    template <class _Allocator>
+        bool
+        __match_at_start_ecma(const _CharT* __first, const _CharT* __last,
+                 match_results<const _CharT*, _Allocator>& __m,
+                 regex_constants::match_flag_type __flags, bool) const;
+    template <class _Allocator>
+        bool
+        __match_at_start_posix_nosubs(const _CharT* __first, const _CharT* __last,
+                 match_results<const _CharT*, _Allocator>& __m,
+                 regex_constants::match_flag_type __flags, bool) const;
+    template <class _Allocator>
+        bool
+        __match_at_start_posix_subs(const _CharT* __first, const _CharT* __last,
+                 match_results<const _CharT*, _Allocator>& __m,
+                 regex_constants::match_flag_type __flags, bool) const;
+
+    template <class _Bp, class _Ap, class _Cp, class _Tp>
+    friend
+    bool
+    regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
+                 regex_constants::match_flag_type);
+
+    template <class _Ap, class _Cp, class _Tp>
+    friend
+    bool
+    regex_search(const _Cp*, const _Cp*, match_results<const _Cp*, _Ap>&,
+                 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
+
+    template <class _Bp, class _Cp, class _Tp>
+    friend
+    bool
+    regex_search(_Bp, _Bp, const basic_regex<_Cp, _Tp>&,
+                 regex_constants::match_flag_type);
+
+    template <class _Cp, class _Tp>
+    friend
+    bool
+    regex_search(const _Cp*, const _Cp*,
+                 const basic_regex<_Cp, _Tp>&, regex_constants::match_flag_type);
+
+    template <class _Cp, class _Ap, class _Tp>
+    friend
+    bool
+    regex_search(const _Cp*, match_results<const _Cp*, _Ap>&, const basic_regex<_Cp, _Tp>&,
+                 regex_constants::match_flag_type);
+
+    template <class _ST, class _SA, class _Cp, class _Tp>
+    friend
+    bool
+    regex_search(const basic_string<_Cp, _ST, _SA>& __s,
+                 const basic_regex<_Cp, _Tp>& __e,
+                 regex_constants::match_flag_type __flags);
+
+    template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
+    friend
+    bool
+    regex_search(const basic_string<_Cp, _ST, _SA>& __s,
+                 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
+                 const basic_regex<_Cp, _Tp>& __e,
+                 regex_constants::match_flag_type __flags);
+
+    template <class _Iter, class _Ap, class _Cp, class _Tp>
+    friend
+    bool
+    regex_search(__wrap_iter<_Iter> __first,
+                 __wrap_iter<_Iter> __last,
+                 match_results<__wrap_iter<_Iter>, _Ap>& __m,
+                 const basic_regex<_Cp, _Tp>& __e,
+                 regex_constants::match_flag_type __flags);
+
+    template <class, class> friend class __lookahead;
+};
+
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::nosubs;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::optimize;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::collate;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::ECMAScript;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::basic;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::extended;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::awk;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::grep;
+template <class _CharT, class _Traits>
+    const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::egrep;
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::swap(basic_regex& __r)
+{
+    using _VSTD::swap;
+    swap(__traits_, __r.__traits_);
+    swap(__flags_, __r.__flags_);
+    swap(__marked_count_, __r.__marked_count_);
+    swap(__loop_count_, __r.__loop_count_);
+    swap(__open_count_, __r.__open_count_);
+    swap(__start_, __r.__start_);
+    swap(__end_, __r.__end_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_regex<_CharT, _Traits>& __x, basic_regex<_CharT, _Traits>& __y)
+{
+    return __x.swap(__y);
+}
+
+// __lookahead
+
+template <class _CharT, class _Traits>
+class __lookahead
+    : public __owns_one_state<_CharT>
+{
+    typedef __owns_one_state<_CharT> base;
+
+    basic_regex<_CharT, _Traits> __exp_;
+    unsigned __mexp_;
+    bool __invert_;
+
+    __lookahead(const __lookahead&);
+    __lookahead& operator=(const __lookahead&);
+public:
+    typedef _VSTD::__state<_CharT> __state;
+
+    _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) {}
+
+    virtual void __exec(__state&) const;
+};
+
+template <class _CharT, class _Traits>
+void
+__lookahead<_CharT, _Traits>::__exec(__state& __s) const
+{
+    match_results<const _CharT*> __m;
+    __m.__init(1 + __exp_.mark_count(), __s.__current_, __s.__last_);
+    bool __matched = __exp_.__match_at_start_ecma(__s.__current_, __s.__last_,
+                                                  __m,
+                                                  __s.__flags_ | regex_constants::match_continuous,
+                                                  __s.__at_first_ && __s.__current_ == __s.__first_);
+    if (__matched != __invert_)
+    {
+        __s.__do_ = __state::__accept_but_not_consume;
+        __s.__node_ = this->first();
+        for (unsigned __i = 1; __i < __m.size(); ++__i) {
+            __s.__sub_matches_[__mexp_ + __i - 1] = __m.__matches_[__i];
+        }
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
+                                      _ForwardIterator __last)
+{
+    {
+        unique_ptr<__node> __h(new __end_state<_CharT>);
+        __start_.reset(new __empty_state<_CharT>(__h.get()));
+        __h.release();
+        __end_ = __start_.get();
+    }
+    switch (__flags_ & 0x1F0)
+    {
+    case ECMAScript:
+        __first = __parse_ecma_exp(__first, __last);
+        break;
+    case basic:
+        __first = __parse_basic_reg_exp(__first, __last);
+        break;
+    case extended:
+    case awk:
+        __first = __parse_extended_reg_exp(__first, __last);
+        break;
+    case grep:
+        __first = __parse_grep(__first, __last);
+        break;
+    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
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
+                                                    _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        if (*__first == '^')
+        {
+            __push_l_anchor();
+            ++__first;
+        }
+        if (__first != __last)
+        {
+            __first = __parse_RE_expression(__first, __last);
+            if (__first != __last)
+            {
+                _ForwardIterator __temp = _VSTD::next(__first);
+                if (__temp == __last && *__first == '$')
+                {
+                    __push_r_anchor();
+                    ++__first;
+                }
+            }
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (__first != __last)
+            throw regex_error(regex_constants::__re_err_empty);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
+                                                       _ForwardIterator __last)
+{
+    __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
+    __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
+        __push_alternation(__sa, __sb);
+        __first = __temp;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+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
+    do
+    {
+        __first = __temp;
+        __temp = __parse_ERE_expression(__first, __last);
+    } while (__temp != __first);
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
+                                                     _ForwardIterator __last)
+{
+    __owns_one_state<_CharT>* __e = __end_;
+    unsigned __mexp_begin = __marked_count_;
+    _ForwardIterator __temp = __parse_one_char_or_coll_elem_ERE(__first, __last);
+    if (__temp == __first && __temp != __last)
+    {
+        switch (*__temp)
+        {
+        case '^':
+            __push_l_anchor();
+            ++__temp;
+            break;
+        case '$':
+            __push_r_anchor();
+            ++__temp;
+            break;
+        case '(':
+            __push_begin_marked_subexpression();
+            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
+            __push_end_marked_subexpression(__temp_count);
+            --__open_count_;
+            ++__temp;
+            break;
+        }
+    }
+    if (__temp != __first)
+        __temp = __parse_ERE_dupl_symbol(__temp, __last, __e, __mexp_begin+1,
+                                         __marked_count_+1);
+    __first = __temp;
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_RE_expression(_ForwardIterator __first,
+                                                    _ForwardIterator __last)
+{
+    while (true)
+    {
+        _ForwardIterator __temp = __parse_simple_RE(__first, __last);
+        if (__temp == __first)
+            break;
+        __first = __temp;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_simple_RE(_ForwardIterator __first,
+                                                _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        __owns_one_state<_CharT>* __e = __end_;
+        unsigned __mexp_begin = __marked_count_;
+        _ForwardIterator __temp = __parse_nondupl_RE(__first, __last);
+        if (__temp != __first)
+            __first = __parse_RE_dupl_symbol(__temp, __last, __e,
+                                             __mexp_begin+1, __marked_count_+1);
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
+                                                 _ForwardIterator __last)
+{
+    _ForwardIterator __temp = __first;
+    __first = __parse_one_char_or_coll_elem_RE(__first, __last);
+    if (__temp == __first)
+    {
+        __temp = __parse_Back_open_paren(__first, __last);
+        if (__temp != __first)
+        {
+            __push_begin_marked_subexpression();
+            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
+            __push_end_marked_subexpression(__temp_count);
+            __first = __temp;
+        }
+        else
+            __first = __parse_BACKREF(__first, __last);
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_RE(
+                                                       _ForwardIterator __first,
+                                                       _ForwardIterator __last)
+{
+    _ForwardIterator __temp = __parse_ORD_CHAR(__first, __last);
+    if (__temp == __first)
+    {
+        __temp = __parse_QUOTED_CHAR(__first, __last);
+        if (__temp == __first)
+        {
+            if (__temp != __last && *__temp == '.')
+            {
+                __push_match_any();
+                ++__temp;
+            }
+            else
+                __temp = __parse_bracket_expression(__first, __last);
+        }
+    }
+    __first = __temp;
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_one_char_or_coll_elem_ERE(
+                                                       _ForwardIterator __first,
+                                                       _ForwardIterator __last)
+{
+    _ForwardIterator __temp = __parse_ORD_CHAR_ERE(__first, __last);
+    if (__temp == __first)
+    {
+        __temp = __parse_QUOTED_CHAR_ERE(__first, __last);
+        if (__temp == __first)
+        {
+            if (__temp != __last && *__temp == '.')
+            {
+                __push_match_any();
+                ++__temp;
+            }
+            else
+                __temp = __parse_bracket_expression(__first, __last);
+        }
+    }
+    __first = __temp;
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_open_paren(_ForwardIterator __first,
+                                                      _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp != __last)
+        {
+            if (*__first == '\\' && *__temp == '(')
+                __first = ++__temp;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_close_paren(_ForwardIterator __first,
+                                                       _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp != __last)
+        {
+            if (*__first == '\\' && *__temp == ')')
+                __first = ++__temp;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_open_brace(_ForwardIterator __first,
+                                                      _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp != __last)
+        {
+            if (*__first == '\\' && *__temp == '{')
+                __first = ++__temp;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_Back_close_brace(_ForwardIterator __first,
+                                                       _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp != __last)
+        {
+            if (*__first == '\\' && *__temp == '}')
+                __first = ++__temp;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_BACKREF(_ForwardIterator __first,
+                                              _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp != __last)
+        {
+            if (*__first == '\\')
+            { 
+                int __val = __traits_.value(*__temp, 10);
+                if (__val >= 1 && __val <= 9)
+                {
+                    __push_back_ref(__val);
+                    __first = ++__temp;
+                }
+            }
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ORD_CHAR(_ForwardIterator __first,
+                                               _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp == __last && *__first == '$')
+            return __first;
+        // Not called inside a bracket
+        if (*__first == '.' || *__first == '\\' || *__first == '[')
+            return __first;
+        __push_char(*__first);
+        ++__first;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ORD_CHAR_ERE(_ForwardIterator __first,
+                                                   _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        switch (*__first)
+        {
+        case '^':
+        case '.':
+        case '[':
+        case '$':
+        case '(':
+        case '|':
+        case '*':
+        case '+':
+        case '?':
+        case '{':
+        case '\\':
+            break;
+        case ')':
+            if (__open_count_ == 0)
+            {
+                __push_char(*__first);
+                ++__first;
+            }
+            break;
+        default:
+            __push_char(*__first);
+            ++__first;
+            break;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR(_ForwardIterator __first,
+                                                  _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp != __last)
+        {
+            if (*__first == '\\')
+            {
+                switch (*__temp)
+                {
+                case '^':
+                case '.':
+                case '*':
+                case '[':
+                case '$':
+                case '\\':
+                    __push_char(*__temp);
+                    __first = ++__temp;
+                    break;
+                }
+            }
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_QUOTED_CHAR_ERE(_ForwardIterator __first,
+                                                      _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        if (__temp != __last)
+        {
+            if (*__first == '\\')
+            {
+                switch (*__temp)
+                {
+                case '^':
+                case '.':
+                case '*':
+                case '[':
+                case '$':
+                case '\\':
+                case '(':
+                case ')':
+                case '|':
+                case '+':
+                case '?':
+                case '{':
+                case '}':
+                    __push_char(*__temp);
+                    __first = ++__temp;
+                    break;
+                default:
+                    if ((__flags_ & 0x1F0) == awk)
+                        __first = __parse_awk_escape(++__first, __last);
+                    break;
+                }
+            }
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
+                                                     _ForwardIterator __last,
+                                                     __owns_one_state<_CharT>* __s,
+                                                     unsigned __mexp_begin,
+                                                     unsigned __mexp_end)
+{
+    if (__first != __last)
+    {
+        if (*__first == '*')
+        {
+            __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
+            ++__first;
+        }
+        else
+        {
+            _ForwardIterator __temp = __parse_Back_open_brace(__first, __last);
+            if (__temp != __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
+                __first = __temp;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (__first == __last)
+                    throw regex_error(regex_constants::error_brace);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                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
+                    __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
+                                    true);
+                    __first = __temp;
+                }
+                else
+                {
+                    ++__first;  // consume ','
+                    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
+                    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
+                        __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
+                                    true);
+                    }
+                    __first = __temp;
+                }
+            }
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
+                                                      _ForwardIterator __last,
+                                                      __owns_one_state<_CharT>* __s,
+                                                      unsigned __mexp_begin,
+                                                      unsigned __mexp_end)
+{
+    if (__first != __last)
+    {
+        unsigned __grammar = __flags_ & 0x1F0;
+        switch (*__first)
+        {
+        case '*':
+            ++__first;
+            if (__grammar == ECMAScript && __first != __last && *__first == '?')
+            {
+                ++__first;
+                __push_nongreedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
+            }
+            else
+                __push_greedy_inf_repeat(0, __s, __mexp_begin, __mexp_end);
+            break;
+        case '+':
+            ++__first;
+            if (__grammar == ECMAScript && __first != __last && *__first == '?')
+            {
+                ++__first;
+                __push_nongreedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
+            }
+            else
+                __push_greedy_inf_repeat(1, __s, __mexp_begin, __mexp_end);
+            break;
+        case '?':
+            ++__first;
+            if (__grammar == ECMAScript && __first != __last && *__first == '?')
+            {
+                ++__first;
+                __push_loop(0, 1, __s, __mexp_begin, __mexp_end, false);
+            }
+            else
+                __push_loop(0, 1, __s, __mexp_begin, __mexp_end);
+            break;
+        case '{':
+            {
+                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
+                __first = __temp;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (__first == __last)
+                    throw regex_error(regex_constants::error_brace);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                switch (*__first)
+                {
+                case '}':
+                    ++__first;
+                    if (__grammar == ECMAScript && __first != __last && *__first == '?')
+                    {
+                        ++__first;
+                        __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, false);
+                    }
+                    else
+                        __push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
+                    break;
+                case ',':
+                    ++__first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                    if (__first == __last)
+                        throw regex_error(regex_constants::error_badbrace);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                    if (*__first == '}')
+                    {
+                        ++__first;
+                        if (__grammar == ECMAScript && __first != __last && *__first == '?')
+                        {
+                            ++__first;
+                            __push_nongreedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
+                        }
+                        else
+                            __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
+                    }
+                    else
+                    {
+                        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
+                        __first = __temp;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                        if (__first == __last || *__first != '}')
+                            throw regex_error(regex_constants::error_brace);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                        ++__first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                        if (__max < __min)
+                            throw regex_error(regex_constants::error_badbrace);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                        if (__grammar == ECMAScript && __first != __last && *__first == '?')
+                        {
+                            ++__first;
+                            __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
+                        }
+                        else
+                            __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
+                }
+            }
+            break;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __first,
+                                                         _ForwardIterator __last)
+{
+    if (__first != __last && *__first == '[')
+    {
+        ++__first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (__first == __last)
+            throw regex_error(regex_constants::error_brack);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        bool __negate = false;
+        if (*__first == '^')
+        {
+            ++__first;
+            __negate = true;
+        }
+        __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
+        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
+        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
+        ++__first;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_follow_list(_ForwardIterator __first,
+                                    _ForwardIterator __last,
+                                    __bracket_expression<_CharT, _Traits>* __ml)
+{
+    if (__first != __last)
+    {
+        while (true)
+        {
+            _ForwardIterator __temp = __parse_expression_term(__first, __last,
+                                                              __ml);
+            if (__temp == __first)
+                break;
+            __first = __temp;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first,
+                                    _ForwardIterator __last,
+                                    __bracket_expression<_CharT, _Traits>* __ml)
+{
+    if (__first != __last && *__first != ']')
+    {
+        _ForwardIterator __temp = _VSTD::next(__first);
+        basic_string<_CharT> __start_range;
+        if (__temp != __last && *__first == '[')
+        {
+            if (*__temp == '=')
+                return __parse_equivalence_class(++__temp, __last, __ml);
+            else if (*__temp == ':')
+                return __parse_character_class(++__temp, __last, __ml);
+            else if (*__temp == '.')
+                __first = __parse_collating_symbol(++__temp, __last, __start_range);
+        }
+        unsigned __grammar = __flags_ & 0x1F0;
+        if (__start_range.empty())
+        {
+            if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
+            {
+                if (__grammar == ECMAScript)
+                    __first = __parse_class_escape(++__first, __last, __start_range, __ml);
+                else
+                    __first = __parse_awk_escape(++__first, __last, &__start_range);
+            }
+            else
+            {
+                __start_range = *__first;
+                ++__first;
+            }
+        }
+        if (__first != __last && *__first != ']')
+        {
+            __temp = _VSTD::next(__first);
+            if (__temp != __last && *__first == '-' && *__temp != ']')
+            {
+                // parse a range
+                basic_string<_CharT> __end_range;
+                __first = __temp;
+                ++__temp;
+                if (__temp != __last && *__first == '[' && *__temp == '.')
+                    __first = __parse_collating_symbol(++__temp, __last, __end_range);
+                else
+                {
+                    if ((__grammar == ECMAScript || __grammar == awk) && *__first == '\\')
+                    {
+                        if (__grammar == ECMAScript)
+                            __first = __parse_class_escape(++__first, __last,
+                                                           __end_range, __ml);
+                        else
+                            __first = __parse_awk_escape(++__first, __last,
+                                                         &__end_range);
+                    }
+                    else
+                    {
+                        __end_range = *__first;
+                        ++__first;
+                    }
+                }
+                __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range));
+            }
+            else if (!__start_range.empty())
+            {
+                if (__start_range.size() == 1)
+                    __ml->__add_char(__start_range[0]);
+                else
+                    __ml->__add_digraph(__start_range[0], __start_range[1]);
+            }
+        }
+        else if (!__start_range.empty())
+        {
+            if (__start_range.size() == 1)
+                __ml->__add_char(__start_range[0]);
+            else
+                __ml->__add_digraph(__start_range[0], __start_range[1]);
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
+                          _ForwardIterator __last,
+                          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
+    switch (*__first)
+    {
+    case 0:
+        __str = *__first;
+        return ++__first;
+    case 'b':
+        __str = _CharT(8);
+        return ++__first;
+    case 'd':
+        __ml->__add_class(ctype_base::digit);
+        return ++__first;
+    case 'D':
+        __ml->__add_neg_class(ctype_base::digit);
+        return ++__first;
+    case 's':
+        __ml->__add_class(ctype_base::space);
+        return ++__first;
+    case 'S':
+        __ml->__add_neg_class(ctype_base::space);
+        return ++__first;
+    case 'w':
+        __ml->__add_class(ctype_base::alnum);
+        __ml->__add_char('_');
+        return ++__first;
+    case 'W':
+        __ml->__add_neg_class(ctype_base::alnum);
+        __ml->__add_neg_char('_');
+        return ++__first;
+    }
+    __first = __parse_character_escape(__first, __last, &__str);
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+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
+    switch (*__first)
+    {
+    case '\\':
+    case '"':
+    case '/':
+        if (__str)
+            *__str = *__first;
+        else
+            __push_char(*__first);
+        return ++__first;
+    case 'a':
+        if (__str)
+            *__str = _CharT(7);
+        else
+            __push_char(_CharT(7));
+        return ++__first;
+    case 'b':
+        if (__str)
+            *__str = _CharT(8);
+        else
+            __push_char(_CharT(8));
+        return ++__first;
+    case 'f':
+        if (__str)
+            *__str = _CharT(0xC);
+        else
+            __push_char(_CharT(0xC));
+        return ++__first;
+    case 'n':
+        if (__str)
+            *__str = _CharT(0xA);
+        else
+            __push_char(_CharT(0xA));
+        return ++__first;
+    case 'r':
+        if (__str)
+            *__str = _CharT(0xD);
+        else
+            __push_char(_CharT(0xD));
+        return ++__first;
+    case 't':
+        if (__str)
+            *__str = _CharT(0x9);
+        else
+            __push_char(_CharT(0x9));
+        return ++__first;
+    case 'v':
+        if (__str)
+            *__str = _CharT(0xB);
+        else
+            __push_char(_CharT(0xB));
+        return ++__first;
+    }
+    if ('0' <= *__first && *__first <= '7')
+    {
+        unsigned __val = *__first - '0';
+        if (++__first != __last && ('0' <= *__first && *__first <= '7'))
+        {
+            __val = 8 * __val + *__first - '0';
+            if (++__first != __last && ('0' <= *__first && *__first <= '7'))
+                __val = 8 * __val + *__first++ - '0';
+        }
+        if (__str)
+            *__str = _CharT(__val);
+        else
+            __push_char(_CharT(__val));
+    }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    else
+        throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first,
+                                    _ForwardIterator __last,
+                                    __bracket_expression<_CharT, _Traits>* __ml)
+{
+    // Found [=
+    //   This means =] must exist
+    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
+    // [__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
+    string_type __equiv_name =
+        __traits_.transform_primary(__collate_name.begin(),
+                                    __collate_name.end());
+    if (!__equiv_name.empty())
+        __ml->__add_equivalence(__equiv_name);
+    else
+    {
+        switch (__collate_name.size())
+        {
+        case 1:
+            __ml->__add_char(__collate_name[0]);
+            break;
+        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
+        }
+    }
+    __first = _VSTD::next(__temp, 2);
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
+                                    _ForwardIterator __last,
+                                    __bracket_expression<_CharT, _Traits>* __ml)
+{
+    // Found [:
+    //   This means :] must exist
+    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
+    // [__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
+    __ml->__add_class(__class_type);
+    __first = _VSTD::next(__temp, 2);
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
+                                                _ForwardIterator __last,
+                                                basic_string<_CharT>& __col_sym)
+{
+    // Found [.
+    //   This means .] must exist
+    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
+    // [__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
+    }
+    __first = _VSTD::next(__temp, 2);
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
+                                                _ForwardIterator __last,
+                                                int& __c)
+{
+    if (__first != __last )
+    {
+        int __val = __traits_.value(*__first, 10);
+        if ( __val != -1 )
+        {
+            __c = __val;
+            for (++__first; 
+                 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
+                 ++__first)
+            {
+                __c *= 10;
+                __c += __val;
+            }
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_ecma_exp(_ForwardIterator __first,
+                                               _ForwardIterator __last)
+{
+    __owns_one_state<_CharT>* __sa = __end_;
+    _ForwardIterator __temp = __parse_alternative(__first, __last);
+    if (__temp == __first)
+        __push_empty();
+    __first = __temp;
+    while (__first != __last && *__first == '|')
+    {
+        __owns_one_state<_CharT>* __sb = __end_;
+        __temp = __parse_alternative(++__first, __last);
+        if (__temp == __first)
+            __push_empty();
+        __push_alternation(__sa, __sb);
+        __first = __temp;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_alternative(_ForwardIterator __first,
+                                                  _ForwardIterator __last)
+{
+    while (true)
+    {
+        _ForwardIterator __temp = __parse_term(__first, __last);
+        if (__temp == __first)
+            break;
+        __first = __temp;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_term(_ForwardIterator __first,
+                                           _ForwardIterator __last)
+{
+    _ForwardIterator __temp = __parse_assertion(__first, __last);
+    if (__temp == __first)
+    {
+        __owns_one_state<_CharT>* __e = __end_;
+        unsigned __mexp_begin = __marked_count_;
+        __temp = __parse_atom(__first, __last);
+        if (__temp != __first)
+            __first = __parse_ERE_dupl_symbol(__temp, __last, __e,
+                                              __mexp_begin+1, __marked_count_+1);
+    }
+    else
+        __first = __temp;
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
+                                                _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        switch (*__first)
+        {
+        case '^':
+            __push_l_anchor();
+            ++__first;
+            break;
+        case '$':
+            __push_r_anchor();
+            ++__first;
+            break;
+        case '\\':
+            {
+                _ForwardIterator __temp = _VSTD::next(__first);
+                if (__temp != __last)
+                {
+                    if (*__temp == 'b')
+                    {
+                        __push_word_boundary(false);
+                        __first = ++__temp;
+                    }
+                    else if (*__temp == 'B')
+                    {
+                        __push_word_boundary(true);
+                        __first = ++__temp;
+                    }
+                }
+            }
+            break;
+        case '(':
+            {
+                _ForwardIterator __temp = _VSTD::next(__first);
+                if (__temp != __last && *__temp == '?')
+                {
+                    if (++__temp != __last)
+                    {
+                        switch (*__temp)
+                        {
+                        case '=':
+                            {
+                                basic_regex __exp;
+                                __exp.__flags_ = __flags_;
+                                __temp = __exp.__parse(++__temp, __last);
+                                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
+                                __first = ++__temp;
+                            }
+                            break;
+                        case '!':
+                            {
+                                basic_regex __exp;
+                                __exp.__flags_ = __flags_;
+                                __temp = __exp.__parse(++__temp, __last);
+                                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
+                                __first = ++__temp;
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+            break;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
+                                           _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        switch (*__first)
+        {
+        case '.':
+            __push_match_any_but_newline();
+            ++__first;
+            break;
+        case '\\':
+            __first = __parse_atom_escape(__first, __last);
+            break;
+        case '[':
+            __first = __parse_bracket_expression(__first, __last);
+            break;
+        case '(':
+            {
+                ++__first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                if (__first == __last)
+                    throw regex_error(regex_constants::error_paren);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                _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
+                    --__open_count_;
+                    ++__first;
+                }
+                else
+                {
+                    __push_begin_marked_subexpression();
+                    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
+                    __push_end_marked_subexpression(__temp_count);
+                    --__open_count_;
+                    ++__first;
+                }
+            }
+            break;
+        default:
+            __first = __parse_pattern_character(__first, __last);
+            break;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first,
+                                                  _ForwardIterator __last)
+{
+    if (__first != __last && *__first == '\\')
+    {
+        _ForwardIterator __t1 = _VSTD::next(__first);
+        _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
+        if (__t2 != __t1)
+            __first = __t2;
+        else
+        {
+            __t2 = __parse_character_class_escape(__t1, __last);
+            if (__t2 != __t1)
+                __first = __t2;
+            else
+            {
+                __t2 = __parse_character_escape(__t1, __last);
+                if (__t2 != __t1)
+                    __first = __t2;
+            }
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
+                                                     _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        if (*__first == '0')
+        {
+            __push_char(_CharT());
+            ++__first;
+        }
+        else if ('1' <= *__first && *__first <= '9')
+        {
+            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
+            __push_back_ref(__v);
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __first,
+                                                             _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        __bracket_expression<_CharT, _Traits>* __ml;
+        switch (*__first)
+        {
+        case 'd':
+            __ml = __start_matching_list(false);
+            __ml->__add_class(ctype_base::digit);
+            ++__first;
+            break;
+        case 'D':
+            __ml = __start_matching_list(true);
+            __ml->__add_class(ctype_base::digit);
+            ++__first;
+            break;
+        case 's':
+            __ml = __start_matching_list(false);
+            __ml->__add_class(ctype_base::space);
+            ++__first;
+            break;
+        case 'S':
+            __ml = __start_matching_list(true);
+            __ml->__add_class(ctype_base::space);
+            ++__first;
+            break;
+        case 'w':
+            __ml = __start_matching_list(false);
+            __ml->__add_class(ctype_base::alnum);
+            __ml->__add_char('_');
+            ++__first;
+            break;
+        case 'W':
+            __ml = __start_matching_list(true);
+            __ml->__add_class(ctype_base::alnum);
+            __ml->__add_char('_');
+            ++__first;
+            break;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
+                                                    _ForwardIterator __last,
+                                                    basic_string<_CharT>* __str)
+{
+    if (__first != __last)
+    {
+        _ForwardIterator __t;
+        unsigned __sum = 0;
+        int __hd;
+        switch (*__first)
+        {
+        case 'f':
+            if (__str)
+                *__str = _CharT(0xC);
+            else
+                __push_char(_CharT(0xC));
+            ++__first;
+            break;
+        case 'n':
+            if (__str)
+                *__str = _CharT(0xA);
+            else
+                __push_char(_CharT(0xA));
+            ++__first;
+            break;
+        case 'r':
+            if (__str)
+                *__str = _CharT(0xD);
+            else
+                __push_char(_CharT(0xD));
+            ++__first;
+            break;
+        case 't':
+            if (__str)
+                *__str = _CharT(0x9);
+            else
+                __push_char(_CharT(0x9));
+            ++__first;
+            break;
+        case 'v':
+            if (__str)
+                *__str = _CharT(0xB);
+            else
+                __push_char(_CharT(0xB));
+            ++__first;
+            break;
+        case 'c':
+            if ((__t = _VSTD::next(__first)) != __last)
+            {
+                if (('A' <= *__t && *__t <= 'Z') || 
+                    ('a' <= *__t && *__t <= 'z'))
+                {
+                    if (__str)
+                        *__str = _CharT(*__t % 32);
+                    else
+                        __push_char(_CharT(*__t % 32));
+                    __first = ++__t;
+                }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                else 
+                    throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            else
+                throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            break;
+        case 'u':
+            ++__first;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            if (__first == __last)
+                throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __hd = __traits_.value(*__first, 16);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            if (__hd == -1)
+                throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __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
+            __hd = __traits_.value(*__first, 16);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            if (__hd == -1)
+                throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __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
+            __hd = __traits_.value(*__first, 16);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            if (__hd == -1)
+                throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __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
+            __hd = __traits_.value(*__first, 16);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            if (__hd == -1)
+                throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __sum = 16 * __sum + static_cast<unsigned>(__hd);
+            if (__str)
+                *__str = _CharT(__sum);
+            else
+                __push_char(_CharT(__sum));
+            ++__first;
+            break;
+        case '0':
+            if (__str)
+                *__str = _CharT(0);
+            else
+                __push_char(_CharT(0));
+            ++__first;
+            break;
+        default:
+            if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum))
+            {
+                if (__str)
+                    *__str = *__first;
+                else
+                    __push_char(*__first);
+                ++__first;
+            }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            else
+                throw regex_error(regex_constants::error_escape);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            break;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_pattern_character(_ForwardIterator __first,
+                                                        _ForwardIterator __last)
+{
+    if (__first != __last)
+    {
+        switch (*__first)
+        {
+        case '^':
+        case '$':
+        case '\\':
+        case '.':
+        case '*':
+        case '+':
+        case '?':
+        case '(':
+        case ')':
+        case '[':
+        case ']':
+        case '{':
+        case '}':
+        case '|':
+            break;
+        default:
+            __push_char(*__first);
+            ++__first;
+            break;
+        }
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_grep(_ForwardIterator __first,
+                                           _ForwardIterator __last)
+{
+    __owns_one_state<_CharT>* __sa = __end_;
+    _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+    if (__t1 != __first)
+        __parse_basic_reg_exp(__first, __t1);
+    else
+        __push_empty();
+    __first = __t1;
+    if (__first != __last)
+        ++__first;
+    while (__first != __last)
+    {
+        __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+        __owns_one_state<_CharT>* __sb = __end_;
+        if (__t1 != __first)
+            __parse_basic_reg_exp(__first, __t1);
+        else
+            __push_empty();
+        __push_alternation(__sa, __sb);
+        __first = __t1;
+        if (__first != __last)
+            ++__first;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+template <class _ForwardIterator>
+_ForwardIterator
+basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first,
+                                            _ForwardIterator __last)
+{
+    __owns_one_state<_CharT>* __sa = __end_;
+    _ForwardIterator __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+    if (__t1 != __first)
+        __parse_extended_reg_exp(__first, __t1);
+    else
+        __push_empty();
+    __first = __t1;
+    if (__first != __last)
+        ++__first;
+    while (__first != __last)
+    {
+        __t1 = _VSTD::find(__first, __last, _CharT('\n'));
+        __owns_one_state<_CharT>* __sb = __end_;
+        if (__t1 != __first)
+            __parse_extended_reg_exp(__first, __t1);
+        else
+            __push_empty();
+        __push_alternation(__sa, __sb);
+        __first = __t1;
+        if (__first != __last)
+            ++__first;
+    }
+    return __first;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_loop(size_t __min, size_t __max,
+        __owns_one_state<_CharT>* __s, size_t __mexp_begin, size_t __mexp_end,
+        bool __greedy)
+{
+    unique_ptr<__empty_state<_CharT> > __e1(new __empty_state<_CharT>(__end_->first()));
+    __end_->first() = nullptr;
+    unique_ptr<__loop<_CharT> > __e2(new __loop<_CharT>(__loop_count_,
+                __s->first(), __e1.get(), __mexp_begin, __mexp_end, __greedy,
+                __min, __max));
+    __s->first() = nullptr;
+    __e1.release();
+    __end_->first() = new __repeat_one_loop<_CharT>(__e2.get());
+    __end_ = __e2->second();
+    __s->first() = __e2.release();
+    ++__loop_count_;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_char(value_type __c)
+{
+    if (flags() & icase)
+        __end_->first() = new __match_char_icase<_CharT, _Traits>
+                                              (__traits_, __c, __end_->first());
+    else if (flags() & collate)
+        __end_->first() = new __match_char_collate<_CharT, _Traits>
+                                              (__traits_, __c, __end_->first());
+    else
+        __end_->first() = new __match_char<_CharT>(__c, __end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_begin_marked_subexpression()
+{
+    if (!(__flags_ & nosubs))
+    {
+        __end_->first() =
+                new __begin_marked_subexpression<_CharT>(++__marked_count_,
+                                                         __end_->first());
+        __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+    }
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_end_marked_subexpression(unsigned __sub)
+{
+    if (!(__flags_ & nosubs))
+    {
+        __end_->first() =
+                new __end_marked_subexpression<_CharT>(__sub, __end_->first());
+        __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+    }
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_l_anchor()
+{
+    __end_->first() = new __l_anchor<_CharT>(__end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_r_anchor()
+{
+    __end_->first() = new __r_anchor<_CharT>(__end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_match_any()
+{
+    __end_->first() = new __match_any<_CharT>(__end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_match_any_but_newline()
+{
+    __end_->first() = new __match_any_but_newline<_CharT>(__end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_empty()
+{
+    __end_->first() = new __empty_state<_CharT>(__end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_word_boundary(bool __invert)
+{
+    __end_->first() = new __word_boundary<_CharT, _Traits>(__traits_, __invert,
+                                                           __end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_back_ref(int __i)
+{
+    if (flags() & icase)
+        __end_->first() = new __back_ref_icase<_CharT, _Traits>
+                                              (__traits_, __i, __end_->first());
+    else if (flags() & collate)
+        __end_->first() = new __back_ref_collate<_CharT, _Traits>
+                                              (__traits_, __i, __end_->first());
+    else
+        __end_->first() = new __back_ref<_CharT>(__i, __end_->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_alternation(__owns_one_state<_CharT>* __sa,
+                                                 __owns_one_state<_CharT>* __ea)
+{
+    __sa->first() = new __alternate<_CharT>(
+                         static_cast<__owns_one_state<_CharT>*>(__sa->first()),
+                         static_cast<__owns_one_state<_CharT>*>(__ea->first()));
+    __ea->first() = nullptr;
+    __ea->first() = new __empty_state<_CharT>(__end_->first());
+    __end_->first() = nullptr;
+    __end_->first() = new __empty_non_own_state<_CharT>(__ea->first());
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__ea->first());
+}
+
+template <class _CharT, class _Traits>
+__bracket_expression<_CharT, _Traits>*
+basic_regex<_CharT, _Traits>::__start_matching_list(bool __negate)
+{
+    __bracket_expression<_CharT, _Traits>* __r =
+        new __bracket_expression<_CharT, _Traits>(__traits_, __end_->first(),
+                                                  __negate, __flags_ & icase,
+                                                  __flags_ & collate);
+    __end_->first() = __r;
+    __end_ = __r;
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp,
+                                               bool __invert,
+                                               unsigned __mexp)
+{
+    __end_->first() = new __lookahead<_CharT, _Traits>(__exp, __invert,
+                                                           __end_->first(), __mexp);
+    __end_ = static_cast<__owns_one_state<_CharT>*>(__end_->first());
+}
+
+typedef basic_regex<char>    regex;
+typedef basic_regex<wchar_t> wregex;
+
+// sub_match
+
+template <class _BidirectionalIterator>
+class _LIBCPP_TYPE_VIS_ONLY sub_match
+    : public pair<_BidirectionalIterator, _BidirectionalIterator>
+{
+public:
+    typedef _BidirectionalIterator                              iterator;
+    typedef typename iterator_traits<iterator>::value_type      value_type;
+    typedef typename iterator_traits<iterator>::difference_type difference_type;
+    typedef basic_string<value_type>                            string_type;
+
+    bool matched;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR sub_match() : matched() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    difference_type length() const
+        {return matched ? _VSTD::distance(this->first, this->second) : 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    string_type str() const
+        {return matched ? string_type(this->first, this->second) : string_type();}
+    _LIBCPP_INLINE_VISIBILITY
+    operator string_type() const
+        {return str();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    int compare(const sub_match& __s) const
+        {return str().compare(__s.str());}
+    _LIBCPP_INLINE_VISIBILITY
+    int compare(const string_type& __s) const
+        {return str().compare(__s);}
+    _LIBCPP_INLINE_VISIBILITY
+    int compare(const value_type* __s) const
+        {return str().compare(__s);}
+};
+
+typedef sub_match<const char*>             csub_match;
+typedef sub_match<const wchar_t*>          wcsub_match;
+typedef sub_match<string::const_iterator>  ssub_match;
+typedef sub_match<wstring::const_iterator> wssub_match;
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+    return __x.compare(__y) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+    return __x.compare(__y) < 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y)
+{
+    return __y < __x;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+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;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+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;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+          const sub_match<_BiIter>& __y)
+{
+    return __y < __x;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator>=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+                const sub_match<_BiIter>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+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;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x,
+           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+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;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator>(const sub_match<_BiIter>& __x,
+               const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+    return __y < __x;
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x,
+           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _BiIter, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x,
+           const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(typename iterator_traits<_BiIter>::value_type const* __x,
+           const sub_match<_BiIter>& __y)
+{
+    return __y.compare(__x) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(typename iterator_traits<_BiIter>::value_type const* __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(typename iterator_traits<_BiIter>::value_type const* __x,
+          const sub_match<_BiIter>& __y)
+{
+    return __y.compare(__x) > 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(typename iterator_traits<_BiIter>::value_type const* __x,
+          const sub_match<_BiIter>& __y)
+{
+    return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(typename iterator_traits<_BiIter>::value_type const* __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(typename iterator_traits<_BiIter>::value_type const* __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const* __y)
+{
+    return __x.compare(__y) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const* __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const sub_match<_BiIter>& __x,
+          typename iterator_traits<_BiIter>::value_type const* __y)
+{
+    return __x.compare(__y) < 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const sub_match<_BiIter>& __x,
+          typename iterator_traits<_BiIter>::value_type const* __y)
+{
+    return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const* __y)
+{
+    return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const* __y)
+{
+    return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(typename iterator_traits<_BiIter>::value_type const& __x,
+           const sub_match<_BiIter>& __y)
+{
+    typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+    return __y.compare(string_type(1, __x)) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(typename iterator_traits<_BiIter>::value_type const& __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(typename iterator_traits<_BiIter>::value_type const& __x,
+          const sub_match<_BiIter>& __y)
+{
+    typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+    return __y.compare(string_type(1, __x)) > 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(typename iterator_traits<_BiIter>::value_type const& __x,
+          const sub_match<_BiIter>& __y)
+{
+    return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(typename iterator_traits<_BiIter>::value_type const& __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(typename iterator_traits<_BiIter>::value_type const& __x,
+           const sub_match<_BiIter>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const& __y)
+{
+    typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+    return __x.compare(string_type(1, __y)) == 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const sub_match<_BiIter>& __x,
+          typename iterator_traits<_BiIter>::value_type const& __y)
+{
+    typedef basic_string<typename iterator_traits<_BiIter>::value_type> string_type;
+    return __x.compare(string_type(1, __y)) < 0;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>(const sub_match<_BiIter>& __x,
+          typename iterator_traits<_BiIter>::value_type const& __y)
+{
+    return __y < __x;
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const sub_match<_BiIter>& __x,
+           typename iterator_traits<_BiIter>::value_type const& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _CharT, class _ST, class _BiIter>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostream<_CharT, _ST>&
+operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m)
+{
+    return __os << __m.str();
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+class _LIBCPP_TYPE_VIS_ONLY match_results
+{
+public:
+    typedef _Allocator                                        allocator_type;
+    typedef sub_match<_BidirectionalIterator>                 value_type;
+private:
+    typedef vector<value_type, allocator_type>                __container_type;
+
+    __container_type  __matches_;
+    value_type __unmatched_;
+    value_type __prefix_;
+    value_type __suffix_;
+    bool       __ready_;
+public:
+    _BidirectionalIterator __position_start_;
+    typedef const value_type&                                 const_reference;
+    typedef value_type&                                       reference;
+    typedef typename __container_type::const_iterator         const_iterator;
+    typedef const_iterator                                    iterator;
+    typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
+    typedef typename allocator_traits<allocator_type>::size_type size_type;
+    typedef typename iterator_traits<_BidirectionalIterator>::value_type char_type;
+    typedef basic_string<char_type>                           string_type;
+
+    // construct/copy/destroy:
+    explicit match_results(const allocator_type& __a = allocator_type());
+//    match_results(const match_results&) = default;
+//    match_results& operator=(const match_results&) = default;
+//    match_results(match_results&& __m) = default;
+//    match_results& operator=(match_results&& __m) = default;
+//    ~match_results() = default;
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool ready() const {return __ready_;}
+
+    // size:
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const {return __matches_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const {return __matches_.max_size();}
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const {return size() == 0;}
+
+    // element access:
+    _LIBCPP_INLINE_VISIBILITY
+    difference_type length(size_type __sub = 0) const
+        {return (*this)[__sub].length();}
+    _LIBCPP_INLINE_VISIBILITY
+    difference_type position(size_type __sub = 0) const
+        {return _VSTD::distance(__position_start_, (*this)[__sub].first);}
+    _LIBCPP_INLINE_VISIBILITY
+    string_type str(size_type __sub = 0) const
+        {return (*this)[__sub].str();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference operator[](size_type __n) const
+        {return __n < __matches_.size() ? __matches_[__n] : __unmatched_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference prefix() const {return __prefix_;}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference suffix() const {return __suffix_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const {return empty() ? __matches_.end() : __matches_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const {return __matches_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const {return empty() ? __matches_.end() : __matches_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const {return __matches_.end();}
+
+    // format:
+    template <class _OutputIter>
+        _OutputIter
+        format(_OutputIter __out, const char_type* __fmt_first,
+               const char_type* __fmt_last,
+               regex_constants::match_flag_type __flags = regex_constants::format_default) const;
+    template <class _OutputIter, class _ST, class _SA>
+        _LIBCPP_INLINE_VISIBILITY
+        _OutputIter
+        format(_OutputIter __out, const basic_string<char_type, _ST, _SA>& __fmt,
+               regex_constants::match_flag_type __flags = regex_constants::format_default) const
+            {return format(__out, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
+    template <class _ST, class _SA>
+        _LIBCPP_INLINE_VISIBILITY
+        basic_string<char_type, _ST, _SA>
+        format(const basic_string<char_type, _ST, _SA>& __fmt,
+               regex_constants::match_flag_type __flags = regex_constants::format_default) const
+        {
+            basic_string<char_type, _ST, _SA> __r;
+            format(back_inserter(__r), __fmt.data(), __fmt.data() + __fmt.size(),
+                   __flags);
+            return __r;
+        }
+    _LIBCPP_INLINE_VISIBILITY
+    string_type
+        format(const char_type* __fmt,
+               regex_constants::match_flag_type __flags = regex_constants::format_default) const
+        {
+            string_type __r;
+            format(back_inserter(__r), __fmt,
+                   __fmt + char_traits<char_type>::length(__fmt), __flags);
+            return __r;
+        }
+
+    // allocator:
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const {return __matches_.get_allocator();}
+
+    // swap:
+    void swap(match_results& __m);
+
+    template <class _Bp, class _Ap>
+        _LIBCPP_INLINE_VISIBILITY
+        void __assign(_BidirectionalIterator __f, _BidirectionalIterator __l,
+                      const match_results<_Bp, _Ap>& __m, bool __no_update_pos)
+    {
+        _Bp __mf = __m.prefix().first;
+        __matches_.resize(__m.size());
+        for (size_type __i = 0; __i < __matches_.size(); ++__i)
+        {
+            __matches_[__i].first = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].first));
+            __matches_[__i].second = _VSTD::next(__f, _VSTD::distance(__mf, __m[__i].second));
+            __matches_[__i].matched = __m[__i].matched;
+        }
+        __unmatched_.first   = __l;
+        __unmatched_.second  = __l;
+        __unmatched_.matched = false;
+        __prefix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().first));
+        __prefix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.prefix().second));
+        __prefix_.matched = __m.prefix().matched;
+        __suffix_.first = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().first));
+        __suffix_.second = _VSTD::next(__f, _VSTD::distance(__mf, __m.suffix().second));
+        __suffix_.matched = __m.suffix().matched;
+        if (!__no_update_pos)
+            __position_start_ = __prefix_.first;
+        __ready_ = __m.ready();
+    }
+
+private:
+    void __init(unsigned __s,
+                _BidirectionalIterator __f, _BidirectionalIterator __l,
+                bool __no_update_pos = false);
+
+    template <class, class> friend class basic_regex;
+
+    template <class _Bp, class _Ap, class _Cp, class _Tp>
+    friend
+    bool
+    regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&, const basic_regex<_Cp, _Tp>&,
+                regex_constants::match_flag_type);
+
+    template <class _Bp, class _Ap>
+    friend
+    bool
+    operator==(const match_results<_Bp, _Ap>&, const match_results<_Bp, _Ap>&);
+
+    template <class, class> friend class __lookahead;
+};
+
+template <class _BidirectionalIterator, class _Allocator>
+match_results<_BidirectionalIterator, _Allocator>::match_results(
+        const allocator_type& __a)
+    : __matches_(__a),
+      __unmatched_(),
+      __prefix_(),
+      __suffix_(),
+      __position_start_(),
+      __ready_(false)
+{
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+void
+match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
+                         _BidirectionalIterator __f, _BidirectionalIterator __l,
+                         bool __no_update_pos)
+{
+    __unmatched_.first   = __l;
+    __unmatched_.second  = __l;
+    __unmatched_.matched = false;
+    __matches_.assign(__s, __unmatched_);
+    __prefix_.first      = __f;
+    __prefix_.second     = __f;
+    __prefix_.matched    = false;
+    __suffix_ = __unmatched_;
+    if (!__no_update_pos)
+        __position_start_ = __prefix_.first;
+    __ready_ = true;
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+template <class _OutputIter>
+_OutputIter
+match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out,
+        const char_type* __fmt_first, const char_type* __fmt_last,
+        regex_constants::match_flag_type __flags) const
+{
+    if (__flags & regex_constants::format_sed)
+    {
+        for (; __fmt_first != __fmt_last; ++__fmt_first)
+        {
+            if (*__fmt_first == '&')
+                __out = _VSTD::copy(__matches_[0].first, __matches_[0].second,
+                                   __out);
+            else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
+            {
+                ++__fmt_first;
+                if ('0' <= *__fmt_first && *__fmt_first <= '9')
+                {
+                    size_t __i = *__fmt_first - '0';
+                    __out = _VSTD::copy(__matches_[__i].first,
+                                       __matches_[__i].second, __out);
+                }
+                else
+                {
+                    *__out = *__fmt_first;
+                    ++__out;
+                }
+            }
+            else
+            {
+                *__out = *__fmt_first;
+                ++__out;
+            }
+        }
+    }
+    else
+    {
+        for (; __fmt_first != __fmt_last; ++__fmt_first)
+        {
+            if (*__fmt_first == '$' && __fmt_first + 1 != __fmt_last)
+            {
+                switch (__fmt_first[1])
+                {
+                case '$':
+                    *__out = *++__fmt_first;
+                    ++__out;
+                    break;
+                case '&':
+                    ++__fmt_first;
+                    __out = _VSTD::copy(__matches_[0].first, __matches_[0].second,
+                                       __out);
+                    break;
+                case '`':
+                    ++__fmt_first;
+                    __out = _VSTD::copy(__prefix_.first, __prefix_.second, __out);
+                    break;
+                case '\'':
+                    ++__fmt_first;
+                    __out = _VSTD::copy(__suffix_.first, __suffix_.second, __out);
+                    break;
+                default:
+                    if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
+                    {
+                        ++__fmt_first;
+                        size_t __i = *__fmt_first - '0';
+                        if (__fmt_first + 1 != __fmt_last &&
+                            '0' <= __fmt_first[1] && __fmt_first[1] <= '9')
+                        {
+                            ++__fmt_first;
+                            __i = 10 * __i + *__fmt_first - '0';
+                        }
+                        __out = _VSTD::copy(__matches_[__i].first,
+                                           __matches_[__i].second, __out);
+                    }
+                    else
+                    {
+                        *__out = *__fmt_first;
+                        ++__out;
+                    }
+                    break;
+                }
+            }
+            else
+            {
+                *__out = *__fmt_first;
+                ++__out;
+            }
+        }
+    }
+    return __out;
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+void
+match_results<_BidirectionalIterator, _Allocator>::swap(match_results& __m)
+{
+    using _VSTD::swap;
+    swap(__matches_, __m.__matches_);
+    swap(__unmatched_, __m.__unmatched_);
+    swap(__prefix_, __m.__prefix_);
+    swap(__suffix_, __m.__suffix_);
+    swap(__position_start_, __m.__position_start_);
+    swap(__ready_, __m.__ready_);
+}
+
+typedef match_results<const char*>             cmatch;
+typedef match_results<const wchar_t*>          wcmatch;
+typedef match_results<string::const_iterator>  smatch;
+typedef match_results<wstring::const_iterator> wsmatch;
+
+template <class _BidirectionalIterator, class _Allocator>
+bool
+operator==(const match_results<_BidirectionalIterator, _Allocator>& __x,
+           const match_results<_BidirectionalIterator, _Allocator>& __y)
+{
+    if (__x.__ready_ != __y.__ready_)
+        return false;
+    if (!__x.__ready_)
+        return true;
+    return __x.__matches_ == __y.__matches_ &&
+           __x.__prefix_ == __y.__prefix_ &&
+           __x.__suffix_ == __y.__suffix_;
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
+           const match_results<_BidirectionalIterator, _Allocator>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _BidirectionalIterator, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(match_results<_BidirectionalIterator, _Allocator>& __x,
+     match_results<_BidirectionalIterator, _Allocator>& __y)
+{
+    __x.swap(__y);
+}
+
+// regex_search
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start_ecma(
+        const _CharT* __first, const _CharT* __last,
+        match_results<const _CharT*, _Allocator>& __m,
+        regex_constants::match_flag_type __flags, bool __at_first) const
+{
+    vector<__state> __states;
+    __node* __st = __start_.get();
+    if (__st)
+    {
+        __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().__loop_data_.resize(__loop_count());
+        __states.back().__node_ = __st;
+        __states.back().__flags_ = __flags;
+        __states.back().__at_first_ = __at_first;
+        do
+        {
+            __state& __s = __states.back();
+            if (__s.__node_)
+                __s.__node_->__exec(__s);
+            switch (__s.__do_)
+            {
+            case __state::__end_state:
+                __m.__matches_[0].first = __first;
+                __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first);
+                __m.__matches_[0].matched = true;
+                for (unsigned __i = 0; __i < __s.__sub_matches_.size(); ++__i)
+                    __m.__matches_[__i+1] = __s.__sub_matches_[__i];
+                return true;
+            case __state::__accept_and_consume:
+            case __state::__repeat:
+            case __state::__accept_but_not_consume:
+                break;
+            case __state::__split:
+                {
+                __state __snext = __s;
+                __s.__node_->__exec_split(true, __s);
+                __snext.__node_->__exec_split(false, __snext);
+                __states.push_back(_VSTD::move(__snext));
+                }
+                break;
+            case __state::__reject:
+                __states.pop_back();
+                break;
+            default:
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                throw regex_error(regex_constants::__re_err_unknown);
+#endif
+                break;
+
+            }
+        } while (!__states.empty());
+    }
+    return false;
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
+        const _CharT* __first, const _CharT* __last,
+        match_results<const _CharT*, _Allocator>& __m,
+        regex_constants::match_flag_type __flags, bool __at_first) const
+{
+    deque<__state> __states;
+    ptrdiff_t __highest_j = 0;
+    ptrdiff_t _Np = _VSTD::distance(__first, __last);
+    __node* __st = __start_.get();
+    if (__st)
+    {
+        __states.push_back(__state());
+        __states.back().__do_ = 0;
+        __states.back().__first_ = __first;
+        __states.back().__current_ = __first;
+        __states.back().__last_ = __last;
+        __states.back().__loop_data_.resize(__loop_count());
+        __states.back().__node_ = __st;
+        __states.back().__flags_ = __flags;
+        __states.back().__at_first_ = __at_first;
+        bool __matched = false;
+        do
+        {
+            __state& __s = __states.back();
+            if (__s.__node_)
+                __s.__node_->__exec(__s);
+            switch (__s.__do_)
+            {
+            case __state::__end_state:
+                if (!__matched || __highest_j < __s.__current_ - __s.__first_)
+                    __highest_j = __s.__current_ - __s.__first_;
+                __matched = true;
+                if (__highest_j == _Np)
+                    __states.clear();
+                else
+                    __states.pop_back();
+                break;
+            case __state::__consume_input:
+                break;
+            case __state::__accept_and_consume:
+                __states.push_front(_VSTD::move(__s));
+                __states.pop_back();
+                break;
+            case __state::__repeat:
+            case __state::__accept_but_not_consume:
+                break;
+            case __state::__split:
+                {
+                __state __snext = __s;
+                __s.__node_->__exec_split(true, __s);
+                __snext.__node_->__exec_split(false, __snext);
+                __states.push_back(_VSTD::move(__snext));
+                }
+                break;
+            case __state::__reject:
+                __states.pop_back();
+                break;
+            default:
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                throw regex_error(regex_constants::__re_err_unknown);
+#endif
+                break;
+            }
+        } while (!__states.empty());
+        if (__matched)
+        {
+            __m.__matches_[0].first = __first;
+            __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
+            __m.__matches_[0].matched = true;
+            return true;
+        }
+    }
+    return false;
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
+        const _CharT* __first, const _CharT* __last,
+        match_results<const _CharT*, _Allocator>& __m,
+        regex_constants::match_flag_type __flags, bool __at_first) const
+{
+    vector<__state> __states;
+    __state __best_state;
+    ptrdiff_t __j = 0;
+    ptrdiff_t __highest_j = 0;
+    ptrdiff_t _Np = _VSTD::distance(__first, __last);
+    __node* __st = __start_.get();
+    if (__st)
+    {
+        __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().__loop_data_.resize(__loop_count());
+        __states.back().__node_ = __st;
+        __states.back().__flags_ = __flags;
+        __states.back().__at_first_ = __at_first;
+        const _CharT* __current = __first;
+        bool __matched = false;
+        do
+        {
+            __state& __s = __states.back();
+            if (__s.__node_)
+                __s.__node_->__exec(__s);
+            switch (__s.__do_)
+            {
+            case __state::__end_state:
+                if (!__matched || __highest_j < __s.__current_ - __s.__first_)
+                {
+                    __highest_j = __s.__current_ - __s.__first_;
+                    __best_state = __s;
+                }
+                __matched = true;
+                if (__highest_j == _Np)
+                    __states.clear();
+                else
+                    __states.pop_back();
+                break;
+            case __state::__accept_and_consume:
+                __j += __s.__current_ - __current;
+                __current = __s.__current_;
+                break;
+            case __state::__repeat:
+            case __state::__accept_but_not_consume:
+                break;
+            case __state::__split:
+                {
+                __state __snext = __s;
+                __s.__node_->__exec_split(true, __s);
+                __snext.__node_->__exec_split(false, __snext);
+                __states.push_back(_VSTD::move(__snext));
+                }
+                break;
+            case __state::__reject:
+                __states.pop_back();
+                break;
+            default:
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                throw regex_error(regex_constants::__re_err_unknown);
+#endif
+                break;
+            }
+        } while (!__states.empty());
+        if (__matched)
+        {
+            __m.__matches_[0].first = __first;
+            __m.__matches_[0].second = _VSTD::next(__first, __highest_j);
+            __m.__matches_[0].matched = true;
+            for (unsigned __i = 0; __i < __best_state.__sub_matches_.size(); ++__i)
+                __m.__matches_[__i+1] = __best_state.__sub_matches_[__i];
+            return true;
+        }
+    }
+    return false;
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__match_at_start(
+        const _CharT* __first, const _CharT* __last,
+        match_results<const _CharT*, _Allocator>& __m,
+        regex_constants::match_flag_type __flags, bool __at_first) const
+{
+    if ((__flags_ & 0x1F0) == ECMAScript)
+        return __match_at_start_ecma(__first, __last, __m, __flags, __at_first);
+    if (mark_count() == 0)
+        return __match_at_start_posix_nosubs(__first, __last, __m, __flags, __at_first);
+    return __match_at_start_posix_subs(__first, __last, __m, __flags, __at_first);
+}
+
+template <class _CharT, class _Traits>
+template <class _Allocator>
+bool
+basic_regex<_CharT, _Traits>::__search(
+        const _CharT* __first, const _CharT* __last,
+        match_results<const _CharT*, _Allocator>& __m,
+        regex_constants::match_flag_type __flags) const
+{
+    __m.__init(1 + mark_count(), __first, __last,
+                                    __flags & regex_constants::__no_update_pos);
+    if (__match_at_start(__first, __last, __m, __flags, 
+                                    !(__flags & regex_constants::__no_update_pos)))
+    {
+        __m.__prefix_.second = __m[0].first;
+        __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
+        __m.__suffix_.first = __m[0].second;
+        __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
+        return true;
+    }
+    if (__first != __last && !(__flags & regex_constants::match_continuous))
+    {
+        __flags |= regex_constants::match_prev_avail;
+        for (++__first; __first != __last; ++__first)
+        {
+            __m.__matches_.assign(__m.size(), __m.__unmatched_);
+            if (__match_at_start(__first, __last, __m, __flags, false))
+            {
+                __m.__prefix_.second = __m[0].first;
+                __m.__prefix_.matched = __m.__prefix_.first != __m.__prefix_.second;
+                __m.__suffix_.first = __m[0].second;
+                __m.__suffix_.matched = __m.__suffix_.first != __m.__suffix_.second;
+                return true;
+            }
+            __m.__matches_.assign(__m.size(), __m.__unmatched_);
+        }
+    }
+    __m.__matches_.clear();
+    return false;
+}
+
+template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
+             match_results<_BidirectionalIterator, _Allocator>& __m,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    int __offset = (__flags & regex_constants::match_prev_avail) ? 1 : 0;
+    basic_string<_CharT> __s(_VSTD::prev(__first, __offset), __last);
+    match_results<const _CharT*> __mc;
+    bool __r = __e.__search(__s.data() + __offset, __s.data() + __s.size(), __mc, __flags);
+    __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
+    return __r;
+}
+
+template <class _Iter, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(__wrap_iter<_Iter> __first,
+             __wrap_iter<_Iter> __last,
+             match_results<__wrap_iter<_Iter>, _Allocator>& __m,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    match_results<const _CharT*> __mc;
+    bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
+    __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
+    return __r;
+}
+
+template <class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __first, const _CharT* __last,
+             match_results<const _CharT*, _Allocator>& __m,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    return __e.__search(__first, __last, __m, __flags);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(_BidirectionalIterator __first, _BidirectionalIterator __last,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    basic_string<_CharT> __s(__first, __last);
+    match_results<const _CharT*> __mc;
+    return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __first, const _CharT* __last,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    match_results<const _CharT*> __mc;
+    return __e.__search(__first, __last, __mc, __flags);
+}
+
+template <class _CharT, class _Allocator, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    return __e.__search(__str, __str + _Traits::length(__str), __m, __flags);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    match_results<const _CharT*> __m;
+    return _VSTD::regex_search(__str, __m, __e, __flags);
+}
+
+template <class _ST, class _SA, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const basic_string<_CharT, _ST, _SA>& __s,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    match_results<const _CharT*> __mc;
+    return __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
+}
+
+template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_search(const basic_string<_CharT, _ST, _SA>& __s,
+             match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
+             const basic_regex<_CharT, _Traits>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    match_results<const _CharT*> __mc;
+    bool __r = __e.__search(__s.data(), __s.data() + __s.size(), __mc, __flags);
+    __m.__assign(__s.begin(), __s.end(), __mc, __flags & regex_constants::__no_update_pos);
+    return __r;
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
+bool
+regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
+             match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
+             const basic_regex<_Cp, _Tp>& __e,
+             regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; 
+#endif
+
+// regex_match
+
+template <class _BidirectionalIterator, class _Allocator, class _CharT, class _Traits>
+bool
+regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
+            match_results<_BidirectionalIterator, _Allocator>& __m,
+            const basic_regex<_CharT, _Traits>& __e,
+            regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    bool __r = _VSTD::regex_search(__first, __last, __m, __e,
+                            __flags | regex_constants::match_continuous);
+    if (__r)
+    {
+        __r = !__m.suffix().matched;
+        if (!__r)
+            __m.__matches_.clear();
+    }
+    return __r;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(_BidirectionalIterator __first, _BidirectionalIterator __last,
+            const basic_regex<_CharT, _Traits>& __e,
+            regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    match_results<_BidirectionalIterator> __m;
+    return _VSTD::regex_match(__first, __last, __m, __e, __flags);
+}
+
+template <class _CharT, class _Allocator, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const _CharT* __str, match_results<const _CharT*, _Allocator>& __m,
+            const basic_regex<_CharT, _Traits>& __e,
+            regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    return _VSTD::regex_match(__str, __str + _Traits::length(__str), __m, __e, __flags);
+}
+
+template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const basic_string<_CharT, _ST, _SA>& __s,
+            match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
+            const basic_regex<_CharT, _Traits>& __e,
+            regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    return _VSTD::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
+            match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
+            const basic_regex<_CharT, _Traits>& __e,
+            regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; 
+#endif
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const _CharT* __str, const basic_regex<_CharT, _Traits>& __e,
+            regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    return _VSTD::regex_match(__str, __str + _Traits::length(__str), __e, __flags);
+}
+
+template <class _ST, class _SA, class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+regex_match(const basic_string<_CharT, _ST, _SA>& __s,
+            const basic_regex<_CharT, _Traits>& __e,
+            regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    return _VSTD::regex_match(__s.begin(), __s.end(), __e, __flags);
+}
+
+// regex_iterator
+
+template <class _BidirectionalIterator,
+          class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
+          class _Traits = regex_traits<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY regex_iterator
+{
+public:
+    typedef basic_regex<_CharT, _Traits>          regex_type;
+    typedef match_results<_BidirectionalIterator> value_type;
+    typedef ptrdiff_t                             difference_type;
+    typedef const value_type*                     pointer;
+    typedef const value_type&                     reference;
+    typedef forward_iterator_tag                  iterator_category;
+
+private:
+    _BidirectionalIterator           __begin_;
+    _BidirectionalIterator           __end_;
+    const regex_type*                __pregex_;
+    regex_constants::match_flag_type __flags_;
+    value_type                       __match_;
+
+public:
+    regex_iterator();
+    regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                   const regex_type& __re,
+                   regex_constants::match_flag_type __m
+                                              = regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+    regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                   const regex_type&& __re,
+                   regex_constants::match_flag_type __m 
+                                     = regex_constants::match_default) = delete;
+#endif
+
+    bool operator==(const regex_iterator& __x) const;
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const regex_iterator& __x) const {return !(*this == __x);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return  __match_;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const  {return &__match_;}
+
+    regex_iterator& operator++();
+    _LIBCPP_INLINE_VISIBILITY
+    regex_iterator operator++(int)
+    {
+        regex_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+};
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_iterator()
+    : __begin_(), __end_(), __pregex_(nullptr), __flags_(), __match_()
+{
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                   const regex_type& __re, regex_constants::match_flag_type __m)
+    : __begin_(__a),
+      __end_(__b),
+      __pregex_(&__re),
+      __flags_(__m)
+{
+    _VSTD::regex_search(__begin_, __end_, __match_, *__pregex_, __flags_);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+bool
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    operator==(const regex_iterator& __x) const
+{
+    if (__match_.empty() && __x.__match_.empty())
+        return true;
+    if (__match_.empty() || __x.__match_.empty())
+        return false;
+    return __begin_ == __x.__begin_       &&
+           __end_ == __x.__end_           &&
+           __pregex_ == __x.__pregex_     &&
+           __flags_ == __x.__flags_       &&
+           __match_[0] == __x.__match_[0];
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
+regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
+{
+    __flags_ |= regex_constants::__no_update_pos;
+    _BidirectionalIterator __start = __match_[0].second;
+    if (__match_.empty())
+    {
+        if (__start == __end_)
+        {
+            __match_ = value_type();
+            return *this;
+        }
+        else if (_VSTD::regex_search(__start, __end_, __match_, *__pregex_,
+                                    __flags_ | regex_constants::match_not_null |
+                                    regex_constants::match_continuous))
+            return *this;
+        else
+            ++__start;
+    }
+    __flags_ |= regex_constants::match_prev_avail;
+    if (!_VSTD::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
+        __match_ = value_type();
+    return *this;
+}
+
+typedef regex_iterator<const char*>             cregex_iterator;
+typedef regex_iterator<const wchar_t*>          wcregex_iterator;
+typedef regex_iterator<string::const_iterator>  sregex_iterator;
+typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
+
+// regex_token_iterator
+
+template <class _BidirectionalIterator,
+          class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
+          class _Traits = regex_traits<_CharT> >
+class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator
+{
+public:
+    typedef basic_regex<_CharT, _Traits>      regex_type;
+    typedef sub_match<_BidirectionalIterator> value_type;
+    typedef ptrdiff_t                         difference_type;
+    typedef const value_type*                 pointer;
+    typedef const value_type&                 reference;
+    typedef forward_iterator_tag              iterator_category;
+
+private:
+    typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
+
+    _Position         __position_;
+    const value_type* __result_;
+    value_type        __suffix_;
+    ptrdiff_t         _N_;
+    vector<int>       __subs_;
+
+public:
+    regex_token_iterator();
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type& __re, int __submatch = 0,
+                         regex_constants::match_flag_type __m =
+                                                regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type&& __re, int __submatch = 0,
+                         regex_constants::match_flag_type __m =
+                                       regex_constants::match_default) = delete;
+#endif
+
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type& __re, const vector<int>& __submatches,
+                         regex_constants::match_flag_type __m =
+                                                regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type&& __re, const vector<int>& __submatches,
+                         regex_constants::match_flag_type __m =
+                                     regex_constants::match_default) = delete;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type& __re,
+                         initializer_list<int> __submatches,
+                         regex_constants::match_flag_type __m =
+                                                regex_constants::match_default);
+
+#if _LIBCPP_STD_VER > 11
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type&& __re,
+                         initializer_list<int> __submatches,
+                         regex_constants::match_flag_type __m =
+                                       regex_constants::match_default) = delete;
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    template <size_t _Np>
+        regex_token_iterator(_BidirectionalIterator __a,
+                             _BidirectionalIterator __b,
+                             const regex_type& __re,
+                             const int (&__submatches)[_Np],
+                             regex_constants::match_flag_type __m =
+                                                regex_constants::match_default);
+#if _LIBCPP_STD_VER > 11
+    template <std::size_t _Np>
+        regex_token_iterator(_BidirectionalIterator __a,
+                             _BidirectionalIterator __b,
+                             const regex_type&& __re,
+                             const int (&__submatches)[_Np],
+                             regex_constants::match_flag_type __m =
+                                      regex_constants::match_default) = delete;
+#endif
+
+    regex_token_iterator(const regex_token_iterator&);
+    regex_token_iterator& operator=(const regex_token_iterator&);
+
+    bool operator==(const regex_token_iterator& __x) const;
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const regex_token_iterator& __x) const {return !(*this == __x);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const value_type& operator*() const {return *__result_;}
+    _LIBCPP_INLINE_VISIBILITY
+    const value_type* operator->() const {return __result_;}
+
+    regex_token_iterator& operator++();
+    _LIBCPP_INLINE_VISIBILITY
+    regex_token_iterator operator++(int)
+    {
+        regex_token_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+private:
+    void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
+    void __establish_result () {
+        if (__subs_[_N_] == -1)
+            __result_ = &__position_->prefix();
+        else
+            __result_ = &(*__position_)[__subs_[_N_]];
+        }       
+};
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    regex_token_iterator()
+    : __result_(nullptr),
+      __suffix_(),
+      _N_(0)
+{
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+void
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    __init(_BidirectionalIterator __a, _BidirectionalIterator __b)
+{
+    if (__position_ != _Position())
+        __establish_result ();
+    else if (__subs_[_N_] == -1)
+    {
+        __suffix_.matched = true;
+        __suffix_.first = __a;
+        __suffix_.second = __b;
+        __result_ = &__suffix_;
+    }
+    else
+        __result_ = nullptr;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type& __re, int __submatch,
+                         regex_constants::match_flag_type __m)
+    : __position_(__a, __b, __re, __m),
+      _N_(0),
+      __subs_(1, __submatch)
+{
+    __init(__a, __b);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type& __re, const vector<int>& __submatches,
+                         regex_constants::match_flag_type __m)
+    : __position_(__a, __b, __re, __m),
+      _N_(0),
+      __subs_(__submatches)
+{
+    __init(__a, __b);
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                         const regex_type& __re,
+                         initializer_list<int> __submatches,
+                         regex_constants::match_flag_type __m)
+    : __position_(__a, __b, __re, __m),
+      _N_(0),
+      __subs_(__submatches)
+{
+    __init(__a, __b);
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+template <size_t _Np>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    regex_token_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,
+                             const regex_type& __re,
+                             const int (&__submatches)[_Np],
+                             regex_constants::match_flag_type __m)
+    : __position_(__a, __b, __re, __m),
+      _N_(0),
+      __subs_(__submatches, __submatches + _Np)
+{
+    __init(__a, __b);
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    regex_token_iterator(const regex_token_iterator& __x)
+    : __position_(__x.__position_),
+      __result_(__x.__result_),
+      __suffix_(__x.__suffix_),
+      _N_(__x._N_),
+      __subs_(__x.__subs_)
+{
+    if (__x.__result_ == &__x.__suffix_)
+        __result_ = &__suffix_;
+    else if ( __result_ != nullptr )
+        __establish_result ();
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    operator=(const regex_token_iterator& __x)
+{
+    if (this != &__x)
+    {
+        __position_ = __x.__position_;
+        if (__x.__result_ == &__x.__suffix_)
+            __result_ = &__suffix_;
+        else
+            __result_ = __x.__result_;
+        __suffix_ = __x.__suffix_;
+        _N_ = __x._N_;
+        __subs_ = __x.__subs_;
+
+        if ( __result_ != nullptr && __result_ != &__suffix_ )
+            __establish_result();
+    }
+    return *this;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+bool
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::
+    operator==(const regex_token_iterator& __x) const
+{
+    if (__result_ == nullptr && __x.__result_ == nullptr)
+        return true;
+    if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ &&
+            __suffix_ == __x.__suffix_)
+        return true;
+    if (__result_ == nullptr || __x.__result_ == nullptr)
+        return false;
+    if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)
+        return false;
+    return __position_ == __x.__position_ && _N_ == __x._N_ &&
+           __subs_ == __x.__subs_;
+}
+
+template <class _BidirectionalIterator, class _CharT, class _Traits>
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
+regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
+{
+    _Position __prev = __position_;
+    if (__result_ == &__suffix_)
+        __result_ = nullptr;
+    else if (_N_ + 1 < __subs_.size())
+    {
+        ++_N_;
+        __establish_result();
+    }
+    else
+    {
+        _N_ = 0;
+        ++__position_;
+        if (__position_ != _Position())
+            __establish_result();
+        else
+        {
+            if (_VSTD::find(__subs_.begin(), __subs_.end(), -1) != __subs_.end()
+                && __prev->suffix().length() != 0)
+            {
+                __suffix_.matched = true;
+                __suffix_.first = __prev->suffix().first;
+                __suffix_.second = __prev->suffix().second;
+                __result_ = &__suffix_;
+            }
+            else
+                __result_ = nullptr;
+        }
+    }
+    return *this;
+}
+
+typedef regex_token_iterator<const char*>             cregex_token_iterator;
+typedef regex_token_iterator<const wchar_t*>          wcregex_token_iterator;
+typedef regex_token_iterator<string::const_iterator>  sregex_token_iterator;
+typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
+
+// regex_replace
+
+template <class _OutputIterator, class _BidirectionalIterator,
+          class _Traits, class _CharT>
+_OutputIterator
+regex_replace(_OutputIterator __out,
+              _BidirectionalIterator __first, _BidirectionalIterator __last,
+              const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
+              regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Iter;
+    _Iter __i(__first, __last, __e, __flags);
+    _Iter __eof;
+    if (__i == __eof)
+    {
+        if (!(__flags & regex_constants::format_no_copy))
+            __out = _VSTD::copy(__first, __last, __out);
+    }
+    else
+    {
+        sub_match<_BidirectionalIterator> __lm;
+        for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
+        {
+            if (!(__flags & regex_constants::format_no_copy))
+                __out = _VSTD::copy(__i->prefix().first, __i->prefix().second, __out);
+            __out = __i->format(__out, __fmt, __fmt + __len, __flags);
+            __lm = __i->suffix();
+            if (__flags & regex_constants::format_first_only)
+                break;
+        }
+        if (!(__flags & regex_constants::format_no_copy))
+            __out = _VSTD::copy(__lm.first, __lm.second, __out);
+    }
+    return __out;
+}
+
+template <class _OutputIterator, class _BidirectionalIterator,
+          class _Traits, class _CharT, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+_OutputIterator
+regex_replace(_OutputIterator __out,
+              _BidirectionalIterator __first, _BidirectionalIterator __last,
+              const basic_regex<_CharT, _Traits>& __e,
+              const basic_string<_CharT, _ST, _SA>& __fmt,
+              regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    return _VSTD::regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags);
+}
+
+template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
+          class _FSA>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _ST, _SA>
+regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
+              const basic_regex<_CharT, _Traits>& __e,
+              const basic_string<_CharT, _FST, _FSA>& __fmt,
+              regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    basic_string<_CharT, _ST, _SA> __r;
+    _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
+                        __fmt.c_str(), __flags);
+    return __r;
+}
+
+template <class _Traits, class _CharT, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _ST, _SA>
+regex_replace(const basic_string<_CharT, _ST, _SA>& __s,
+              const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
+              regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    basic_string<_CharT, _ST, _SA> __r;
+    _VSTD::regex_replace(back_inserter(__r), __s.begin(), __s.end(), __e,
+                        __fmt, __flags);
+    return __r;
+}
+
+template <class _Traits, class _CharT, class _ST, class _SA>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT>
+regex_replace(const _CharT* __s,
+              const basic_regex<_CharT, _Traits>& __e,
+              const basic_string<_CharT, _ST, _SA>& __fmt,
+              regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    basic_string<_CharT> __r;
+    _VSTD::regex_replace(back_inserter(__r), __s,
+                        __s + char_traits<_CharT>::length(__s), __e,
+                        __fmt.c_str(), __flags);
+    return __r;
+}
+
+template <class _Traits, class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT>
+regex_replace(const _CharT* __s,
+              const basic_regex<_CharT, _Traits>& __e,
+              const _CharT* __fmt,
+              regex_constants::match_flag_type __flags = regex_constants::match_default)
+{
+    basic_string<_CharT> __r;
+    _VSTD::regex_replace(back_inserter(__r), __s,
+                        __s + char_traits<_CharT>::length(__s), __e,
+                        __fmt, __flags);
+    return __r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_REGEX
diff --git a/final/include/scoped_allocator b/final/include/scoped_allocator
new file mode 100644
index 0000000..aa8bece
--- /dev/null
+++ b/final/include/scoped_allocator
@@ -0,0 +1,578 @@
+// -*- C++ -*-
+//===-------------------------- scoped_allocator --------------------------===//
+//
+//                     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_SCOPED_ALLOCATOR
+#define _LIBCPP_SCOPED_ALLOCATOR
+
+/*
+    scoped_allocator synopsis
+
+namespace std
+{
+
+template <class OuterAlloc, class... InnerAllocs>
+class scoped_allocator_adaptor : public OuterAlloc
+{
+    typedef allocator_traits<OuterAlloc> OuterTraits; // exposition only
+    scoped_allocator_adaptor<InnerAllocs...> inner;   // exposition only
+public:
+
+    typedef OuterAlloc outer_allocator_type;
+    typedef see below inner_allocator_type;
+
+    typedef typename OuterTraits::value_type value_type;
+    typedef typename OuterTraits::size_type size_type;
+    typedef typename OuterTraits::difference_type difference_type;
+    typedef typename OuterTraits::pointer pointer;
+    typedef typename OuterTraits::const_pointer const_pointer;
+    typedef typename OuterTraits::void_pointer void_pointer;
+    typedef typename OuterTraits::const_void_pointer const_void_pointer;
+
+    typedef see below propagate_on_container_copy_assignment;
+    typedef see below propagate_on_container_move_assignment;
+    typedef see below propagate_on_container_swap;
+
+    template <class Tp>
+        struct rebind
+        {
+            typedef scoped_allocator_adaptor<
+                OuterTraits::template rebind_alloc<Tp>, InnerAllocs...> other;
+        };
+
+    scoped_allocator_adaptor();
+    template <class OuterA2>
+        scoped_allocator_adaptor(OuterA2&& outerAlloc,
+                                 const InnerAllocs&... innerAllocs) noexcept;
+    scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;
+    scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept;
+    template <class OuterA2>
+        scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept;
+    template <class OuterA2>
+        scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
+
+    ~scoped_allocator_adaptor();
+
+    inner_allocator_type& inner_allocator() noexcept;
+    const inner_allocator_type& inner_allocator() const noexcept;
+
+    outer_allocator_type& outer_allocator() noexcept;
+    const outer_allocator_type& outer_allocator() const noexcept;
+
+    pointer allocate(size_type n);
+    pointer allocate(size_type n, const_void_pointer hint);
+    void deallocate(pointer p, size_type n) noexcept;
+
+    size_type max_size() const;
+    template <class T, class... Args> void construct(T* p, Args&& args);
+    template <class T1, class T2, class... Args1, class... Args2>
+        void construct(pair<T1, T2>* p, piecewise_construct t, tuple<Args1...> x,
+                       tuple<Args2...> y);
+    template <class T1, class T2>
+        void construct(pair<T1, T2>* p);
+    template <class T1, class T2, class U, class V>
+        void construct(pair<T1, T2>* p, U&& x, V&& y);
+    template <class T1, class T2, class U, class V>
+        void construct(pair<T1, T2>* p, const pair<U, V>& x);
+    template <class T1, class T2, class U, class V>
+        void construct(pair<T1, T2>* p, pair<U, V>&& x);
+    template <class T> void destroy(T* p);
+
+    template <class T> void destroy(T* p) noexcept;
+
+    scoped_allocator_adaptor select_on_container_copy_construction() const noexcept;
+};
+
+template <class OuterA1, class OuterA2, class... InnerAllocs>
+    bool
+    operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+               const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
+
+template <class OuterA1, class OuterA2, class... InnerAllocs>
+    bool
+    operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+               const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <memory>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE)
+
+// scoped_allocator_adaptor
+
+template <class ..._Allocs>
+class scoped_allocator_adaptor;
+
+template <class ..._Allocs> struct __get_poc_copy_assignment;
+
+template <class _A0>
+struct __get_poc_copy_assignment<_A0>
+{
+    static const bool value = allocator_traits<_A0>::
+                              propagate_on_container_copy_assignment::value;
+};
+
+template <class _A0, class ..._Allocs>
+struct __get_poc_copy_assignment<_A0, _Allocs...>
+{
+    static const bool value =
+        allocator_traits<_A0>::propagate_on_container_copy_assignment::value ||
+        __get_poc_copy_assignment<_Allocs...>::value;
+};
+
+template <class ..._Allocs> struct __get_poc_move_assignment;
+
+template <class _A0>
+struct __get_poc_move_assignment<_A0>
+{
+    static const bool value = allocator_traits<_A0>::
+                              propagate_on_container_move_assignment::value;
+};
+
+template <class _A0, class ..._Allocs>
+struct __get_poc_move_assignment<_A0, _Allocs...>
+{
+    static const bool value =
+        allocator_traits<_A0>::propagate_on_container_move_assignment::value ||
+        __get_poc_move_assignment<_Allocs...>::value;
+};
+
+template <class ..._Allocs> struct __get_poc_swap;
+
+template <class _A0>
+struct __get_poc_swap<_A0>
+{
+    static const bool value = allocator_traits<_A0>::
+                              propagate_on_container_swap::value;
+};
+
+template <class _A0, class ..._Allocs>
+struct __get_poc_swap<_A0, _Allocs...>
+{
+    static const bool value =
+        allocator_traits<_A0>::propagate_on_container_swap::value ||
+        __get_poc_swap<_Allocs...>::value;
+};
+
+template <class ..._Allocs>
+class __scoped_allocator_storage;
+
+template <class _OuterAlloc, class... _InnerAllocs>
+class __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
+    : public _OuterAlloc
+{
+    typedef _OuterAlloc outer_allocator_type;
+protected:
+    typedef scoped_allocator_adaptor<_InnerAllocs...> inner_allocator_type;
+
+private:
+    inner_allocator_type __inner_;
+
+protected:
+
+    _LIBCPP_INLINE_VISIBILITY
+    __scoped_allocator_storage() _NOEXCEPT {}
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        __scoped_allocator_storage(_OuterA2&& __outerAlloc,
+                                   const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
+            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)),
+              __inner_(__innerAllocs...) {}
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, const _OuterA2&>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        __scoped_allocator_storage(
+            const __scoped_allocator_storage<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
+            : outer_allocator_type(__other.outer_allocator()),
+              __inner_(__other.inner_allocator()) {}
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        __scoped_allocator_storage(
+            __scoped_allocator_storage<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
+            : outer_allocator_type(_VSTD::move(__other.outer_allocator())),
+              __inner_(_VSTD::move(__other.inner_allocator())) {}
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        __scoped_allocator_storage(_OuterA2&& __o,
+                                   const inner_allocator_type& __i) _NOEXCEPT
+            : outer_allocator_type(_VSTD::forward<_OuterA2>(__o)),
+              __inner_(__i)
+        {
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    inner_allocator_type& inner_allocator() _NOEXCEPT             {return __inner_;}
+    _LIBCPP_INLINE_VISIBILITY
+    const inner_allocator_type& inner_allocator() const _NOEXCEPT {return __inner_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    outer_allocator_type& outer_allocator() _NOEXCEPT
+        {return static_cast<outer_allocator_type&>(*this);}
+    _LIBCPP_INLINE_VISIBILITY
+    const outer_allocator_type& outer_allocator() const _NOEXCEPT
+        {return static_cast<const outer_allocator_type&>(*this);}
+
+    scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
+    _LIBCPP_INLINE_VISIBILITY
+    select_on_container_copy_construction() const _NOEXCEPT
+        {
+            return scoped_allocator_adaptor<outer_allocator_type, _InnerAllocs...>
+            (
+                allocator_traits<outer_allocator_type>::
+                    select_on_container_copy_construction(outer_allocator()),
+                allocator_traits<inner_allocator_type>::
+                    select_on_container_copy_construction(inner_allocator())
+            );
+        }
+
+    template <class...> friend class __scoped_allocator_storage;
+};
+
+template <class _OuterAlloc>
+class __scoped_allocator_storage<_OuterAlloc>
+    : public _OuterAlloc
+{
+    typedef _OuterAlloc outer_allocator_type;
+protected:
+    typedef scoped_allocator_adaptor<_OuterAlloc> inner_allocator_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __scoped_allocator_storage() _NOEXCEPT {}
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT
+            : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {}
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, const _OuterA2&>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        __scoped_allocator_storage(
+            const __scoped_allocator_storage<_OuterA2>& __other) _NOEXCEPT
+            : outer_allocator_type(__other.outer_allocator()) {}
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        __scoped_allocator_storage(
+            __scoped_allocator_storage<_OuterA2>&& __other) _NOEXCEPT
+            : outer_allocator_type(_VSTD::move(__other.outer_allocator())) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    inner_allocator_type& inner_allocator() _NOEXCEPT
+        {return static_cast<inner_allocator_type&>(*this);}
+    _LIBCPP_INLINE_VISIBILITY
+    const inner_allocator_type& inner_allocator() const _NOEXCEPT
+        {return static_cast<const inner_allocator_type&>(*this);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    outer_allocator_type& outer_allocator() _NOEXCEPT
+        {return static_cast<outer_allocator_type&>(*this);}
+    _LIBCPP_INLINE_VISIBILITY
+    const outer_allocator_type& outer_allocator() const _NOEXCEPT
+        {return static_cast<const outer_allocator_type&>(*this);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    scoped_allocator_adaptor<outer_allocator_type>
+    select_on_container_copy_construction() const _NOEXCEPT
+        {return scoped_allocator_adaptor<outer_allocator_type>(
+            allocator_traits<outer_allocator_type>::
+                select_on_container_copy_construction(outer_allocator())
+        );}
+
+    __scoped_allocator_storage(const outer_allocator_type& __o,
+                               const inner_allocator_type& __i) _NOEXCEPT;
+
+    template <class...> friend class __scoped_allocator_storage;
+};
+
+// __outermost
+
+template <class _Alloc>
+decltype(declval<_Alloc>().outer_allocator(), true_type())
+__has_outer_allocator_test(_Alloc&& __a);
+
+template <class _Alloc>
+false_type
+__has_outer_allocator_test(const volatile _Alloc& __a);
+
+template <class _Alloc>
+struct __has_outer_allocator
+    : public common_type
+             <
+                 decltype(__has_outer_allocator_test(declval<_Alloc&>()))
+             >::type
+{
+};
+
+template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>
+struct __outermost
+{
+    typedef _Alloc type;
+    _LIBCPP_INLINE_VISIBILITY
+    type& operator()(type& __a) const _NOEXCEPT {return __a;}
+};
+
+template <class _Alloc>
+struct __outermost<_Alloc, true>
+{
+    typedef typename remove_reference
+                     <
+                        decltype(_VSTD::declval<_Alloc>().outer_allocator())
+                     >::type                                    _OuterAlloc;
+    typedef typename __outermost<_OuterAlloc>::type             type;
+    _LIBCPP_INLINE_VISIBILITY
+    type& operator()(_Alloc& __a) const _NOEXCEPT
+        {return __outermost<_OuterAlloc>()(__a.outer_allocator());}
+};
+
+template <class _OuterAlloc, class... _InnerAllocs>
+class _LIBCPP_TYPE_VIS_ONLY scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
+    : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...>
+{
+    typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;
+    typedef allocator_traits<_OuterAlloc>             _OuterTraits;
+public:
+    typedef _OuterAlloc                               outer_allocator_type;
+    typedef typename base::inner_allocator_type       inner_allocator_type;
+    typedef typename _OuterTraits::size_type          size_type;
+    typedef typename _OuterTraits::difference_type    difference_type;
+    typedef typename _OuterTraits::pointer            pointer;
+    typedef typename _OuterTraits::const_pointer      const_pointer;
+    typedef typename _OuterTraits::void_pointer       void_pointer;
+    typedef typename _OuterTraits::const_void_pointer const_void_pointer;
+
+    typedef integral_constant
+            <
+                bool,
+                __get_poc_copy_assignment<outer_allocator_type,
+                                          _InnerAllocs...>::value
+            > propagate_on_container_copy_assignment;
+    typedef integral_constant
+            <
+                bool,
+                __get_poc_move_assignment<outer_allocator_type,
+                                          _InnerAllocs...>::value
+            > propagate_on_container_move_assignment;
+    typedef integral_constant
+            <
+                bool,
+                __get_poc_swap<outer_allocator_type, _InnerAllocs...>::value
+            > propagate_on_container_swap;
+
+    template <class _Tp>
+    struct rebind
+    {
+        typedef scoped_allocator_adaptor
+        <
+            typename _OuterTraits::template rebind_alloc<_Tp>, _InnerAllocs...
+        > other;
+    };
+
+    _LIBCPP_INLINE_VISIBILITY
+    scoped_allocator_adaptor() _NOEXCEPT {}
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        scoped_allocator_adaptor(_OuterA2&& __outerAlloc,
+                                 const _InnerAllocs& ...__innerAllocs) _NOEXCEPT
+            : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {}
+    // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, const _OuterA2&>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        scoped_allocator_adaptor(
+            const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
+                : base(__other) {}
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+        _LIBCPP_INLINE_VISIBILITY
+        scoped_allocator_adaptor(
+            scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
+                : base(_VSTD::move(__other)) {}
+
+    // ~scoped_allocator_adaptor() = default;
+
+    _LIBCPP_INLINE_VISIBILITY
+    inner_allocator_type& inner_allocator() _NOEXCEPT
+        {return base::inner_allocator();}
+    _LIBCPP_INLINE_VISIBILITY
+    const inner_allocator_type& inner_allocator() const _NOEXCEPT
+        {return base::inner_allocator();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    outer_allocator_type& outer_allocator() _NOEXCEPT
+        {return base::outer_allocator();}
+    _LIBCPP_INLINE_VISIBILITY
+    const outer_allocator_type& outer_allocator() const _NOEXCEPT
+        {return base::outer_allocator();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    pointer allocate(size_type __n)
+        {return allocator_traits<outer_allocator_type>::
+            allocate(outer_allocator(), __n);}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer allocate(size_type __n, const_void_pointer __hint)
+        {return allocator_traits<outer_allocator_type>::
+            allocate(outer_allocator(), __n, __hint);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void deallocate(pointer __p, size_type __n) _NOEXCEPT
+        {allocator_traits<outer_allocator_type>::
+            deallocate(outer_allocator(), __p, __n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const
+        {return allocator_traits<outer_allocator_type>::max_size(outer_allocator());}
+
+    template <class _Tp, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void construct(_Tp* __p, _Args&& ...__args)
+            {__construct(__uses_alloc_ctor<_Tp, inner_allocator_type, _Args...>(),
+                         __p, _VSTD::forward<_Args>(__args)...);}
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        void destroy(_Tp* __p)
+            {
+                typedef __outermost<outer_allocator_type> _OM;
+                allocator_traits<typename _OM::type>::
+                                         destroy(_OM()(outer_allocator()), __p);
+            }
+
+    _LIBCPP_INLINE_VISIBILITY
+    scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT
+        {return base::select_on_container_copy_construction();}
+
+private:
+
+    template <class _OuterA2,
+              class = typename enable_if<
+                        is_constructible<outer_allocator_type, _OuterA2>::value
+                      >::type>
+    _LIBCPP_INLINE_VISIBILITY
+    scoped_allocator_adaptor(_OuterA2&& __o,
+                             const inner_allocator_type& __i) _NOEXCEPT
+        : base(_VSTD::forward<_OuterA2>(__o), __i) {}
+
+    template <class _Tp, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void __construct(integral_constant<int, 0>, _Tp* __p, _Args&& ...__args)
+            {
+                typedef __outermost<outer_allocator_type> _OM;
+                allocator_traits<typename _OM::type>::construct
+                (
+                    _OM()(outer_allocator()),
+                    __p,
+                    _VSTD::forward<_Args>(__args)...
+                );
+            }
+
+    template <class _Tp, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void __construct(integral_constant<int, 1>, _Tp* __p, _Args&& ...__args)
+            {
+                typedef __outermost<outer_allocator_type> _OM;
+                allocator_traits<typename _OM::type>::construct
+                (
+                    _OM()(outer_allocator()),
+                    __p,
+                    allocator_arg,
+                    inner_allocator(),
+                    _VSTD::forward<_Args>(__args)...
+                );
+            }
+
+    template <class _Tp, class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void __construct(integral_constant<int, 2>, _Tp* __p, _Args&& ...__args)
+            {
+                typedef __outermost<outer_allocator_type> _OM;
+                allocator_traits<typename _OM::type>::construct
+                (
+                    _OM()(outer_allocator()),
+                    __p,
+                    _VSTD::forward<_Args>(__args)...,
+                    inner_allocator()
+                );
+            }
+
+    template <class...> friend class __scoped_allocator_storage;
+};
+
+template <class _OuterA1, class _OuterA2>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const scoped_allocator_adaptor<_OuterA1>& __a,
+           const scoped_allocator_adaptor<_OuterA2>& __b) _NOEXCEPT
+{
+    return __a.outer_allocator() == __b.outer_allocator();
+}
+
+template <class _OuterA1, class _OuterA2, class _InnerA0, class... _InnerAllocs>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& __a,
+           const scoped_allocator_adaptor<_OuterA2, _InnerA0, _InnerAllocs...>& __b) _NOEXCEPT
+{
+    return __a.outer_allocator() == __b.outer_allocator() &&
+           __a.inner_allocator() == __b.inner_allocator();
+}
+
+template <class _OuterA1, class _OuterA2, class... _InnerAllocs>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a,
+           const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __b) _NOEXCEPT
+{
+    return !(__a == __b);
+}
+
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_SCOPED_ALLOCATOR
diff --git a/final/include/set b/final/include/set
new file mode 100644
index 0000000..b9e776d
--- /dev/null
+++ b/final/include/set
@@ -0,0 +1,1205 @@
+// -*- C++ -*-
+//===---------------------------- set -------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SET
+#define _LIBCPP_SET
+
+/*
+
+    set synopsis
+
+namespace std
+{
+
+template <class Key, class Compare = less<Key>,
+          class Allocator = allocator<Key>>
+class set
+{
+public:
+    // types:
+    typedef Key                                      key_type;
+    typedef key_type                                 value_type;
+    typedef Compare                                  key_compare;
+    typedef key_compare                              value_compare;
+    typedef Allocator                                allocator_type;
+    typedef typename allocator_type::reference       reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef typename allocator_type::size_type       size_type;
+    typedef typename allocator_type::difference_type difference_type;
+    typedef typename allocator_type::pointer         pointer;
+    typedef typename allocator_type::const_pointer   const_pointer;
+
+    typedef implementation-defined                   iterator;
+    typedef implementation-defined                   const_iterator;
+    typedef std::reverse_iterator<iterator>          reverse_iterator;
+    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+
+    // construct/copy/destroy:
+    set()
+        noexcept(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value);
+    explicit set(const value_compare& comp);
+    set(const value_compare& comp, const allocator_type& a);
+    template <class InputIterator>
+        set(InputIterator first, InputIterator last,
+            const value_compare& comp = value_compare());
+    template <class InputIterator>
+        set(InputIterator first, InputIterator last, const value_compare& comp,
+            const allocator_type& a);
+    set(const set& s);
+    set(set&& s)
+        noexcept(
+            is_nothrow_move_constructible<allocator_type>::value &&
+            is_nothrow_move_constructible<key_compare>::value);
+    explicit set(const allocator_type& a);
+    set(const set& s, const allocator_type& a);
+    set(set&& s, const allocator_type& a);
+    set(initializer_list<value_type> il, const value_compare& comp = value_compare());
+    set(initializer_list<value_type> il, const value_compare& comp,
+        const allocator_type& a);
+    template <class InputIterator>
+        set(InputIterator first, InputIterator last, const allocator_type& a)
+            : set(first, last, Compare(), a) {}  // C++14
+    set(initializer_list<value_type> il, const allocator_type& a)
+        : set(il, Compare(), a) {}  // C++14
+    ~set();
+
+    set& operator=(const set& s);
+    set& operator=(set&& s)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<key_compare>::value);
+    set& operator=(initializer_list<value_type> il);
+
+    // iterators:
+          iterator begin() noexcept;
+    const_iterator begin() const noexcept;
+          iterator end() noexcept;
+    const_iterator end()   const noexcept;
+
+          reverse_iterator rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+          reverse_iterator rend() noexcept;
+    const_reverse_iterator rend()   const noexcept;
+
+    const_iterator         cbegin()  const noexcept;
+    const_iterator         cend()    const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend()   const noexcept;
+
+    // capacity:
+    bool      empty()    const noexcept;
+    size_type size()     const noexcept;
+    size_type max_size() const noexcept;
+
+    // modifiers:
+    template <class... Args>
+        pair<iterator, bool> emplace(Args&&... args);
+    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);
+    iterator insert(const_iterator position, const value_type& v);
+    iterator insert(const_iterator position, value_type&& v);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+    void insert(initializer_list<value_type> il);
+
+    iterator  erase(const_iterator position);
+    size_type erase(const key_type& k);
+    iterator  erase(const_iterator first, const_iterator last);
+    void clear() noexcept;
+
+    void swap(set& s)
+        noexcept(
+            __is_nothrow_swappable<key_compare>::value &&
+            (!allocator_type::propagate_on_container_swap::value ||
+             __is_nothrow_swappable<allocator_type>::value));
+
+    // observers:
+    allocator_type get_allocator() const noexcept;
+    key_compare    key_comp()      const;
+    value_compare  value_comp()    const;
+
+    // set operations:
+          iterator find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    template<typename K>
+        iterator find(const K& x);
+    template<typename K>
+        const_iterator find(const K& x) const;  // C++14
+    template<typename K>
+      size_type count(const K& x) const;        // C++14
+
+    size_type      count(const key_type& k) const;
+          iterator lower_bound(const key_type& k);
+    const_iterator lower_bound(const key_type& k) const;
+    template<typename K>
+        iterator lower_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator lower_bound(const K& x) const;  // C++14
+
+          iterator upper_bound(const key_type& k);
+    const_iterator upper_bound(const key_type& k) const;
+    template<typename K>
+        iterator upper_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator upper_bound(const K& x) const;  // C++14
+    pair<iterator,iterator>             equal_range(const key_type& k);
+    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+    template<typename K>
+        pair<iterator,iterator>             equal_range(const K& x);        // C++14
+    template<typename K>
+        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
+};
+
+template <class Key, class Compare, class Allocator>
+bool
+operator==(const set<Key, Compare, Allocator>& x,
+           const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator< (const set<Key, Compare, Allocator>& x,
+           const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator!=(const set<Key, Compare, Allocator>& x,
+           const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator> (const set<Key, Compare, Allocator>& x,
+           const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator>=(const set<Key, Compare, Allocator>& x,
+           const set<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator<=(const set<Key, Compare, Allocator>& x,
+           const set<Key, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class Compare, class Allocator>
+void
+swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
+    noexcept(noexcept(x.swap(y)));
+
+template <class Key, class Compare = less<Key>,
+          class Allocator = allocator<Key>>
+class multiset
+{
+public:
+    // types:
+    typedef Key                                      key_type;
+    typedef key_type                                 value_type;
+    typedef Compare                                  key_compare;
+    typedef key_compare                              value_compare;
+    typedef Allocator                                allocator_type;
+    typedef typename allocator_type::reference       reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef typename allocator_type::size_type       size_type;
+    typedef typename allocator_type::difference_type difference_type;
+    typedef typename allocator_type::pointer         pointer;
+    typedef typename allocator_type::const_pointer   const_pointer;
+
+    typedef implementation-defined                   iterator;
+    typedef implementation-defined                   const_iterator;
+    typedef std::reverse_iterator<iterator>          reverse_iterator;
+    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+
+    // construct/copy/destroy:
+    multiset()
+        noexcept(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value);
+    explicit multiset(const value_compare& comp);
+    multiset(const value_compare& comp, const allocator_type& a);
+    template <class InputIterator>
+        multiset(InputIterator first, InputIterator last,
+                 const value_compare& comp = value_compare());
+    template <class InputIterator>
+        multiset(InputIterator first, InputIterator last,
+                 const value_compare& comp, const allocator_type& a);
+    multiset(const multiset& s);
+    multiset(multiset&& s)
+        noexcept(
+            is_nothrow_move_constructible<allocator_type>::value &&
+            is_nothrow_move_constructible<key_compare>::value);
+    explicit multiset(const allocator_type& a);
+    multiset(const multiset& s, const allocator_type& a);
+    multiset(multiset&& s, const allocator_type& a);
+    multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
+    multiset(initializer_list<value_type> il, const value_compare& comp,
+             const allocator_type& a);
+    template <class InputIterator>
+        multiset(InputIterator first, InputIterator last, const allocator_type& a)
+            : set(first, last, Compare(), a) {}  // C++14
+    multiset(initializer_list<value_type> il, const allocator_type& a)
+        : set(il, Compare(), a) {}  // C++14
+    ~multiset();
+
+    multiset& operator=(const multiset& s);
+    multiset& operator=(multiset&& s)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<key_compare>::value);
+    multiset& operator=(initializer_list<value_type> il);
+
+    // iterators:
+          iterator begin() noexcept;
+    const_iterator begin() const noexcept;
+          iterator end() noexcept;
+    const_iterator end()   const noexcept;
+
+          reverse_iterator rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+          reverse_iterator rend() noexcept;
+    const_reverse_iterator rend()   const noexcept;
+
+    const_iterator         cbegin()  const noexcept;
+    const_iterator         cend()    const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend()   const noexcept;
+
+    // capacity:
+    bool      empty()    const noexcept;
+    size_type size()     const noexcept;
+    size_type max_size() const noexcept;
+
+    // modifiers:
+    template <class... Args>
+        iterator emplace(Args&&... args);
+    template <class... Args>
+        iterator emplace_hint(const_iterator position, Args&&... args);
+    iterator insert(const value_type& v);
+    iterator insert(value_type&& v);
+    iterator insert(const_iterator position, const value_type& v);
+    iterator insert(const_iterator position, value_type&& v);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+    void insert(initializer_list<value_type> il);
+
+    iterator  erase(const_iterator position);
+    size_type erase(const key_type& k);
+    iterator  erase(const_iterator first, const_iterator last);
+    void clear() noexcept;
+
+    void swap(multiset& s)
+        noexcept(
+            __is_nothrow_swappable<key_compare>::value &&
+            (!allocator_type::propagate_on_container_swap::value ||
+             __is_nothrow_swappable<allocator_type>::value));
+
+    // observers:
+    allocator_type get_allocator() const noexcept;
+    key_compare    key_comp()      const;
+    value_compare  value_comp()    const;
+
+    // set operations:
+          iterator find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    template<typename K>
+        iterator find(const K& x);
+    template<typename K>
+        const_iterator find(const K& x) const;  // C++14
+
+    size_type      count(const key_type& k) const;
+          iterator lower_bound(const key_type& k);
+    const_iterator lower_bound(const key_type& k) const;
+    template<typename K>
+        iterator lower_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator lower_bound(const K& x) const;  // C++14
+
+          iterator upper_bound(const key_type& k);
+    const_iterator upper_bound(const key_type& k) const;
+    template<typename K>
+        iterator upper_bound(const K& x);              // C++14
+    template<typename K>
+        const_iterator upper_bound(const K& x) const;  // C++14
+
+    pair<iterator,iterator>             equal_range(const key_type& k);
+    pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+    template<typename K>
+        pair<iterator,iterator>             equal_range(const K& x);        // C++14
+    template<typename K>
+        pair<const_iterator,const_iterator> equal_range(const K& x) const;  // C++14
+};
+
+template <class Key, class Compare, class Allocator>
+bool
+operator==(const multiset<Key, Compare, Allocator>& x,
+           const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator< (const multiset<Key, Compare, Allocator>& x,
+           const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator!=(const multiset<Key, Compare, Allocator>& x,
+           const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator> (const multiset<Key, Compare, Allocator>& x,
+           const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator>=(const multiset<Key, Compare, Allocator>& x,
+           const multiset<Key, Compare, Allocator>& y);
+
+template <class Key, class Compare, class Allocator>
+bool
+operator<=(const multiset<Key, Compare, Allocator>& x,
+           const multiset<Key, Compare, Allocator>& y);
+
+// specialized algorithms:
+template <class Key, class Compare, class Allocator>
+void
+swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
+    noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__tree>
+#include <functional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Key, class _Compare = less<_Key>,
+          class _Allocator = allocator<_Key> >
+class _LIBCPP_TYPE_VIS_ONLY set
+{
+public:
+    // types:
+    typedef _Key                                     key_type;
+    typedef key_type                                 value_type;
+    typedef _Compare                                 key_compare;
+    typedef key_compare                              value_compare;
+    typedef _Allocator                               allocator_type;
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+
+private:
+    typedef __tree<value_type, value_compare, allocator_type> __base;
+    typedef allocator_traits<allocator_type>                  __alloc_traits;
+    typedef typename __base::__node_holder                    __node_holder;
+
+    __base __tree_;
+
+public:
+    typedef typename __base::pointer               pointer;
+    typedef typename __base::const_pointer         const_pointer;
+    typedef typename __base::size_type             size_type;
+    typedef typename __base::difference_type       difference_type;
+    typedef typename __base::const_iterator        iterator;
+    typedef typename __base::const_iterator        const_iterator;
+    typedef _VSTD::reverse_iterator<iterator>       reverse_iterator;
+    typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    set()
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(value_compare()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit set(const value_compare& __comp)
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(__comp) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit set(const value_compare& __comp, const allocator_type& __a)
+        : __tree_(__comp, __a) {}
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        set(_InputIterator __f, _InputIterator __l,
+            const value_compare& __comp = value_compare())
+        : __tree_(__comp)
+        {
+            insert(__f, __l);
+        }
+
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
+            const allocator_type& __a)
+        : __tree_(__comp, __a)
+        {
+            insert(__f, __l);
+        }
+
+#if _LIBCPP_STD_VER > 11
+        template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY 
+        set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+            : set(__f, __l, key_compare(), __a) {}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    set(const set& __s)
+        : __tree_(__s.__tree_)
+        {
+            insert(__s.begin(), __s.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    set& operator=(const set& __s)
+        {
+            __tree_ = __s.__tree_;
+            return *this;
+        }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    set(set&& __s)
+        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+        : __tree_(_VSTD::move(__s.__tree_)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit set(const allocator_type& __a)
+        : __tree_(__a) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    set(const set& __s, const allocator_type& __a)
+        : __tree_(__s.__tree_.value_comp(), __a)
+        {
+            insert(__s.begin(), __s.end());
+        }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    set(set&& __s, const allocator_type& __a);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
+        : __tree_(__comp)
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    set(initializer_list<value_type> __il, const value_compare& __comp,
+        const allocator_type& __a)
+        : __tree_(__comp, __a)
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+#if _LIBCPP_STD_VER > 11
+    _LIBCPP_INLINE_VISIBILITY 
+    set(initializer_list<value_type> __il, const allocator_type& __a)
+        : set(__il, key_compare(), __a) {}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    set& operator=(initializer_list<value_type> __il)
+        {
+            __tree_.__assign_unique(__il.begin(), __il.end());
+            return *this;
+        }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    set& operator=(set&& __s)
+        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+        {
+            __tree_ = _VSTD::move(__s.__tree_);
+            return *this;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+          iterator begin() _NOEXCEPT       {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+          iterator end() _NOEXCEPT         {return __tree_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()   const _NOEXCEPT {return __tree_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rbegin() _NOEXCEPT
+            {return reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rend() _NOEXCEPT
+            {return reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend() const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin()  const _NOEXCEPT {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT {return __tree_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+    // modifiers:
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> emplace(_Args&&... __args)
+            {return __tree_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator emplace_hint(const_iterator __p, _Args&&... __args)
+            {return __tree_.__emplace_hint_unique(__p, _VSTD::forward<_Args>(__args)...);}
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator,bool> insert(const value_type& __v)
+        {return __tree_.__insert_unique(__v);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator,bool> insert(value_type&& __v)
+        {return __tree_.__insert_unique(_VSTD::move(__v));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, const value_type& __v)
+        {return __tree_.__insert_unique(__p, __v);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, value_type&& __v)
+        {return __tree_.__insert_unique(__p, _VSTD::move(__v));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        void insert(_InputIterator __f, _InputIterator __l)
+        {
+            for (const_iterator __e = cend(); __f != __l; ++__f)
+                __tree_.__insert_unique(__e, *__f);
+        }
+
+#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
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator  erase(const_iterator __p) {return __tree_.erase(__p);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type erase(const key_type& __k)
+        {return __tree_.__erase_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator  erase(const_iterator __f, const_iterator __l)
+        {return __tree_.erase(__f, __l);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__tree_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+        {__tree_.swap(__s.__tree_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_compare    key_comp()      const {return __tree_.value_comp();}
+    _LIBCPP_INLINE_VISIBILITY
+    value_compare  value_comp()    const {return __tree_.value_comp();}
+
+    // set operations:
+    _LIBCPP_INLINE_VISIBILITY
+    iterator find(const key_type& __k)             {return __tree_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    find(const _K2& __k)                           {return __tree_.find(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    find(const _K2& __k) const                     {return __tree_.find(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type      count(const key_type& __k) const
+        {return __tree_.__count_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator lower_bound(const key_type& __k)
+        {return __tree_.lower_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator lower_bound(const key_type& __k) const
+        {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
+
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator upper_bound(const key_type& __k)
+        {return __tree_.upper_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator upper_bound(const key_type& __k) const
+        {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type
+    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator,iterator> equal_range(const key_type& __k)
+        {return __tree_.__equal_range_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+        {return __tree_.__equal_range_unique(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+    equal_range(const _K2& __k)       {return __tree_.__equal_range_unique(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+    equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);}
+#endif
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Compare, class _Allocator>
+set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
+    : __tree_(_VSTD::move(__s.__tree_), __a)
+{
+    if (__a != __s.get_allocator())
+    {
+        const_iterator __e = cend();
+        while (!__s.empty())
+            insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const set<_Key, _Compare, _Allocator>& __x,
+           const set<_Key, _Compare, _Allocator>& __y)
+{
+    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const set<_Key, _Compare, _Allocator>& __x,
+           const set<_Key, _Compare, _Allocator>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const set<_Key, _Compare, _Allocator>& __x,
+           const set<_Key, _Compare, _Allocator>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const set<_Key, _Compare, _Allocator>& __x,
+           const set<_Key, _Compare, _Allocator>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const set<_Key, _Compare, _Allocator>& __x,
+           const set<_Key, _Compare, _Allocator>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const set<_Key, _Compare, _Allocator>& __x,
+           const set<_Key, _Compare, _Allocator>& __y)
+{
+    return !(__y < __x);
+}
+
+// specialized algorithms:
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(set<_Key, _Compare, _Allocator>& __x,
+     set<_Key, _Compare, _Allocator>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Key, class _Compare = less<_Key>,
+          class _Allocator = allocator<_Key> >
+class _LIBCPP_TYPE_VIS_ONLY multiset
+{
+public:
+    // types:
+    typedef _Key                                      key_type;
+    typedef key_type                                 value_type;
+    typedef _Compare                                  key_compare;
+    typedef key_compare                              value_compare;
+    typedef _Allocator                                allocator_type;
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+
+private:
+    typedef __tree<value_type, value_compare, allocator_type> __base;
+    typedef allocator_traits<allocator_type>                  __alloc_traits;
+    typedef typename __base::__node_holder                    __node_holder;
+
+    __base __tree_;
+
+public:
+    typedef typename __base::pointer               pointer;
+    typedef typename __base::const_pointer         const_pointer;
+    typedef typename __base::size_type             size_type;
+    typedef typename __base::difference_type       difference_type;
+    typedef typename __base::const_iterator        iterator;
+    typedef typename __base::const_iterator        const_iterator;
+    typedef _VSTD::reverse_iterator<iterator>       reverse_iterator;
+    typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+
+    // construct/copy/destroy:
+    _LIBCPP_INLINE_VISIBILITY
+    multiset()
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_default_constructible<key_compare>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(value_compare()) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit multiset(const value_compare& __comp)
+        _NOEXCEPT_(
+            is_nothrow_default_constructible<allocator_type>::value &&
+            is_nothrow_copy_constructible<key_compare>::value)
+        : __tree_(__comp) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit multiset(const value_compare& __comp, const allocator_type& __a)
+        : __tree_(__comp, __a) {}
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        multiset(_InputIterator __f, _InputIterator __l,
+                 const value_compare& __comp = value_compare())
+        : __tree_(__comp)
+        {
+            insert(__f, __l);
+        }
+
+#if _LIBCPP_STD_VER > 11
+        template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY 
+        multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+            : multiset(__f, __l, key_compare(), __a) {}
+#endif
+
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        multiset(_InputIterator __f, _InputIterator __l,
+                 const value_compare& __comp, const allocator_type& __a)
+        : __tree_(__comp, __a)
+        {
+            insert(__f, __l);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    multiset(const multiset& __s)
+        : __tree_(__s.__tree_.value_comp(),
+          __alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
+        {
+            insert(__s.begin(), __s.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    multiset& operator=(const multiset& __s)
+        {
+            __tree_ = __s.__tree_;
+            return *this;
+        }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    multiset(multiset&& __s)
+        _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
+        : __tree_(_VSTD::move(__s.__tree_)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit multiset(const allocator_type& __a)
+        : __tree_(__a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    multiset(const multiset& __s, const allocator_type& __a)
+        : __tree_(__s.__tree_.value_comp(), __a)
+        {
+            insert(__s.begin(), __s.end());
+        }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    multiset(multiset&& __s, const allocator_type& __a);
+#endif
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
+        : __tree_(__comp)
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    multiset(initializer_list<value_type> __il, const value_compare& __comp,
+        const allocator_type& __a)
+        : __tree_(__comp, __a)
+        {
+            insert(__il.begin(), __il.end());
+        }
+
+#if _LIBCPP_STD_VER > 11
+    _LIBCPP_INLINE_VISIBILITY 
+    multiset(initializer_list<value_type> __il, const allocator_type& __a)
+        : multiset(__il, key_compare(), __a) {}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    multiset& operator=(initializer_list<value_type> __il)
+        {
+            __tree_.__assign_multi(__il.begin(), __il.end());
+            return *this;
+        }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    multiset& operator=(multiset&& __s)
+        _NOEXCEPT_(is_nothrow_move_assignable<__base>::value)
+        {
+            __tree_ = _VSTD::move(__s.__tree_);
+            return *this;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+          iterator begin() _NOEXCEPT       {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+          iterator end() _NOEXCEPT         {return __tree_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()   const _NOEXCEPT {return __tree_.end();}
+
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rbegin() _NOEXCEPT
+            {return reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+          reverse_iterator rend() _NOEXCEPT
+            {return       reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend() const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin()  const _NOEXCEPT {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend() const _NOEXCEPT {return rend();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT {return __tree_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
+
+    // modifiers:
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator emplace(_Args&&... __args)
+            {return __tree_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator emplace_hint(const_iterator __p, _Args&&... __args)
+            {return __tree_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const value_type& __v)
+        {return __tree_.__insert_multi(__v);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(value_type&& __v)
+        {return __tree_.__insert_multi(_VSTD::move(__v));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, const value_type& __v)
+        {return __tree_.__insert_multi(__p, __v);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, value_type&& __v)
+        {return __tree_.__insert_multi(_VSTD::move(__v));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        void insert(_InputIterator __f, _InputIterator __l)
+        {
+            for (const_iterator __e = cend(); __f != __l; ++__f)
+                __tree_.__insert_multi(__e, *__f);
+        }
+
+#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
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator  erase(const_iterator __p) {return __tree_.erase(__p);}
+    _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)
+        {return __tree_.erase(__f, __l);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__tree_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(multiset& __s)
+        _NOEXCEPT_(__is_nothrow_swappable<__base>::value)
+        {__tree_.swap(__s.__tree_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_compare    key_comp()      const {return __tree_.value_comp();}
+    _LIBCPP_INLINE_VISIBILITY
+    value_compare  value_comp()    const {return __tree_.value_comp();}
+
+    // set operations:
+    _LIBCPP_INLINE_VISIBILITY
+    iterator find(const key_type& __k)             {return __tree_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+    find(const _K2& __k)                           {return __tree_.find(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    find(const _K2& __k) const                     {return __tree_.find(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type      count(const key_type& __k) const
+        {return __tree_.__count_multi(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator lower_bound(const key_type& __k)
+        {return __tree_.lower_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator lower_bound(const key_type& __k) const
+            {return __tree_.lower_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+    lower_bound(const _K2& __k)       {return __tree_.lower_bound(__k);}
+
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator upper_bound(const key_type& __k)
+            {return __tree_.upper_bound(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator upper_bound(const key_type& __k) const
+            {return __tree_.upper_bound(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type
+    upper_bound(const _K2& __k)       {return __tree_.upper_bound(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type
+    upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator,iterator>             equal_range(const key_type& __k)
+            {return __tree_.__equal_range_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
+            {return __tree_.__equal_range_multi(__k);}
+#if _LIBCPP_STD_VER > 11
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type
+    equal_range(const _K2& __k)       {return __tree_.__equal_range_multi(__k);}
+    template <typename _K2>
+    _LIBCPP_INLINE_VISIBILITY
+    typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type
+    equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);}
+#endif
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Compare, class _Allocator>
+multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
+    : __tree_(_VSTD::move(__s.__tree_), __a)
+{
+    if (__a != __s.get_allocator())
+    {
+        const_iterator __e = cend();
+        while (!__s.empty())
+            insert(__e, _VSTD::move(__s.__tree_.remove(__s.begin())->__value_));
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const multiset<_Key, _Compare, _Allocator>& __x,
+           const multiset<_Key, _Compare, _Allocator>& __y)
+{
+    return __x.size() == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const multiset<_Key, _Compare, _Allocator>& __x,
+           const multiset<_Key, _Compare, _Allocator>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
+           const multiset<_Key, _Compare, _Allocator>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const multiset<_Key, _Compare, _Allocator>& __x,
+           const multiset<_Key, _Compare, _Allocator>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
+           const multiset<_Key, _Compare, _Allocator>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
+           const multiset<_Key, _Compare, _Allocator>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Key, class _Compare, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(multiset<_Key, _Compare, _Allocator>& __x,
+     multiset<_Key, _Compare, _Allocator>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_SET
diff --git a/final/include/shared_mutex b/final/include/shared_mutex
new file mode 100644
index 0000000..7661054
--- /dev/null
+++ b/final/include/shared_mutex
@@ -0,0 +1,419 @@
+// -*- C++ -*-
+//===------------------------ shared_mutex --------------------------------===//
+//
+//                     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_SHARED_MUTEX
+#define _LIBCPP_SHARED_MUTEX
+
+/*
+    shared_mutex synopsis
+
+// C++1y
+
+namespace std
+{
+
+class shared_timed_mutex
+{
+public:
+    shared_timed_mutex();
+    ~shared_timed_mutex();
+
+    shared_timed_mutex(const shared_timed_mutex&) = delete;
+    shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+    // Exclusive ownership
+    void lock(); // blocking
+    bool try_lock();
+    template <class Rep, class Period>
+        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+    template <class Clock, class Duration>
+        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+    void unlock();
+
+    // Shared ownership
+    void lock_shared(); // blocking
+    bool try_lock_shared();
+    template <class Rep, class Period>
+        bool
+        try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
+    template <class Clock, class Duration>
+        bool
+        try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
+    void unlock_shared();
+};
+
+template <class Mutex>
+class shared_lock
+{
+public:
+    typedef Mutex mutex_type;
+
+    // Shared locking
+    shared_lock() noexcept;
+    explicit shared_lock(mutex_type& m); // blocking
+    shared_lock(mutex_type& m, defer_lock_t) noexcept;
+    shared_lock(mutex_type& m, try_to_lock_t);
+    shared_lock(mutex_type& m, adopt_lock_t);
+    template <class Clock, class Duration>
+        shared_lock(mutex_type& m,
+                    const chrono::time_point<Clock, Duration>& abs_time);
+    template <class Rep, class Period>
+        shared_lock(mutex_type& m,
+                    const chrono::duration<Rep, Period>& rel_time);
+    ~shared_lock();
+
+    shared_lock(shared_lock const&) = delete;
+    shared_lock& operator=(shared_lock const&) = delete;
+
+    shared_lock(shared_lock&& u) noexcept;
+    shared_lock& operator=(shared_lock&& u) noexcept;
+
+    void lock(); // blocking
+    bool try_lock();
+    template <class Rep, class Period>
+        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+    template <class Clock, class Duration>
+        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+    void unlock();
+
+    // Setters
+    void swap(shared_lock& u) noexcept;
+    mutex_type* release() noexcept;
+
+    // Getters
+    bool owns_lock() const noexcept;
+    explicit operator bool () const noexcept;
+    mutex_type* mutex() const noexcept;
+};
+
+template <class Mutex>
+    void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept;
+
+}  // std
+
+*/
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11 || defined(_LIBCPP_BUILDING_SHARED_MUTEX)
+
+#include <__mutex_base>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS shared_timed_mutex
+{
+    mutex               __mut_;
+    condition_variable  __gate1_;
+    condition_variable  __gate2_;
+    unsigned            __state_;
+
+    static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
+    static const unsigned __n_readers_ = ~__write_entered_;
+public:
+    shared_timed_mutex();
+    _LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
+
+    shared_timed_mutex(const shared_timed_mutex&) = delete;
+    shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+    // Exclusive ownership
+    void lock();
+    bool try_lock();
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        bool
+        try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
+        {
+            return try_lock_until(chrono::steady_clock::now() + __rel_time);
+        }
+    template <class _Clock, class _Duration>
+        bool
+        try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time);
+    void unlock();
+
+    // Shared ownership
+    void lock_shared();
+    bool try_lock_shared();
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        bool
+        try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time)
+        {
+            return try_lock_shared_until(chrono::steady_clock::now() + __rel_time);
+        }
+    template <class _Clock, class _Duration>
+        bool
+        try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time);
+    void unlock_shared();
+};
+
+template <class _Clock, class _Duration>
+bool
+shared_timed_mutex::try_lock_until(
+                        const chrono::time_point<_Clock, _Duration>& __abs_time)
+{
+    unique_lock<mutex> __lk(__mut_);
+    if (__state_ & __write_entered_)
+    {
+        while (true)
+        {
+            cv_status __status = __gate1_.wait_until(__lk, __abs_time);
+            if ((__state_ & __write_entered_) == 0)
+                break;
+            if (__status == cv_status::timeout)
+                return false;
+        }
+    }
+    __state_ |= __write_entered_;
+    if (__state_ & __n_readers_)
+    {
+        while (true)
+        {
+            cv_status __status = __gate2_.wait_until(__lk, __abs_time);
+            if ((__state_ & __n_readers_) == 0)
+                break;
+            if (__status == cv_status::timeout)
+            {
+                __state_ &= ~__write_entered_;
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+template <class _Clock, class _Duration>
+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_)
+    {
+        while (true)
+        {
+            cv_status status = __gate1_.wait_until(__lk, __abs_time);
+            if ((__state_ & __write_entered_) == 0 &&
+                                       (__state_ & __n_readers_) < __n_readers_)
+                break;
+            if (status == cv_status::timeout)
+                return false;
+        }
+    }
+    unsigned __num_readers = (__state_ & __n_readers_) + 1;
+    __state_ &= ~__n_readers_;
+    __state_ |= __num_readers;
+    return true;
+}
+
+template <class _Mutex>
+class shared_lock
+{
+public:
+    typedef _Mutex mutex_type;
+
+private:
+    mutex_type* __m_;
+    bool __owns_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    shared_lock() noexcept
+        : __m_(nullptr),
+          __owns_(false)
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit shared_lock(mutex_type& __m)
+        : __m_(&__m),
+          __owns_(true)
+        {__m_->lock_shared();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    shared_lock(mutex_type& __m, defer_lock_t) noexcept
+        : __m_(&__m),
+          __owns_(false)
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    shared_lock(mutex_type& __m, try_to_lock_t)
+        : __m_(&__m),
+          __owns_(__m.try_lock_shared())
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    shared_lock(mutex_type& __m, adopt_lock_t)
+        : __m_(&__m),
+          __owns_(true)
+        {}
+
+    template <class _Clock, class _Duration>
+        _LIBCPP_INLINE_VISIBILITY
+        shared_lock(mutex_type& __m,
+                    const chrono::time_point<_Clock, _Duration>& __abs_time)
+            : __m_(&__m),
+              __owns_(__m.try_lock_shared_until(__abs_time))
+            {}
+
+    template <class _Rep, class _Period>
+        _LIBCPP_INLINE_VISIBILITY
+        shared_lock(mutex_type& __m,
+                    const chrono::duration<_Rep, _Period>& __rel_time)
+            : __m_(&__m),
+              __owns_(__m.try_lock_shared_for(__rel_time))
+            {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~shared_lock()
+    {
+        if (__owns_)
+            __m_->unlock_shared();
+    }
+
+    shared_lock(shared_lock const&) = delete;
+    shared_lock& operator=(shared_lock const&) = delete;
+
+    _LIBCPP_INLINE_VISIBILITY
+    shared_lock(shared_lock&& __u) noexcept
+        : __m_(__u.__m_),
+          __owns_(__u.__owns_)
+        {
+            __u.__m_ = nullptr;
+            __u.__owns_ = false;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    shared_lock& operator=(shared_lock&& __u) noexcept
+    {
+        if (__owns_)
+            __m_->unlock_shared();
+        __m_ = nullptr;
+        __owns_ = false;
+        __m_ = __u.__m_;
+        __owns_ = __u.__owns_;
+        __u.__m_ = nullptr;
+        __u.__owns_ = false;
+        return *this;
+    }
+
+    void lock();
+    bool try_lock();
+    template <class Rep, class Period>
+        bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+    template <class Clock, class Duration>
+        bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+    void unlock();
+
+    // Setters
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(shared_lock& __u) noexcept
+    {
+        _VSTD::swap(__m_, __u.__m_);
+        _VSTD::swap(__owns_, __u.__owns_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    mutex_type* release() noexcept
+    {
+        mutex_type* __m = __m_;
+        __m_ = nullptr;
+        __owns_ = false;
+        return __m;
+    }
+
+    // Getters
+    _LIBCPP_INLINE_VISIBILITY
+    bool owns_lock() const noexcept {return __owns_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit operator bool () const noexcept {return __owns_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    mutex_type* mutex() const noexcept {return __m_;}
+};
+
+template <class _Mutex>
+void
+shared_lock<_Mutex>::lock()
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "shared_lock::lock: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "shared_lock::lock: already locked");
+    __m_->lock_shared();
+    __owns_ = true;
+}
+
+template <class _Mutex>
+bool
+shared_lock<_Mutex>::try_lock()
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "shared_lock::try_lock: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "shared_lock::try_lock: already locked");
+    __owns_ = __m_->try_lock_shared();
+    return __owns_;
+}
+
+template <class _Mutex>
+template <class _Rep, class _Period>
+bool
+shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d)
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked");
+    __owns_ = __m_->try_lock_shared_for(__d);
+    return __owns_;
+}
+
+template <class _Mutex>
+template <class _Clock, class _Duration>
+bool
+shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+    if (__m_ == nullptr)
+        __throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex");
+    if (__owns_)
+        __throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked");
+    __owns_ = __m_->try_lock_shared_until(__t);
+    return __owns_;
+}
+
+template <class _Mutex>
+void
+shared_lock<_Mutex>::unlock()
+{
+    if (!__owns_)
+        __throw_system_error(EPERM, "shared_lock::unlock: not locked");
+    __m_->unlock_shared();
+    __owns_ = false;
+}
+
+template <class _Mutex>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
+    {__x.swap(__y);}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_STD_VER > 11
+
+#endif  // _LIBCPP_SHARED_MUTEX
diff --git a/final/include/sstream b/final/include/sstream
new file mode 100644
index 0000000..f90d446
--- /dev/null
+++ b/final/include/sstream
@@ -0,0 +1,972 @@
+// -*- C++ -*-
+//===--------------------------- sstream ----------------------------------===//
+//
+//                     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_SSTREAM
+#define _LIBCPP_SSTREAM
+
+/*
+    sstream synopsis
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_stringbuf
+    : public basic_streambuf<charT, traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef Allocator                      allocator_type;
+
+    // 27.8.1.1 Constructors:
+    explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
+    explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    basic_stringbuf(basic_stringbuf&& rhs);
+
+    // 27.8.1.2 Assign and swap:
+    basic_stringbuf& operator=(basic_stringbuf&& rhs);
+    void swap(basic_stringbuf& rhs);
+
+    // 27.8.1.3 Get and set:
+    basic_string<char_type, traits_type, allocator_type> str() const;
+    void str(const basic_string<char_type, traits_type, allocator_type>& s);
+
+protected:
+    // 27.8.1.4 Overridden virtual functions:
+    virtual int_type underflow();
+    virtual int_type pbackfail(int_type c = traits_type::eof());
+    virtual int_type overflow (int_type c = traits_type::eof());
+    virtual basic_streambuf<char_type, traits_type>* setbuf(char_type*, streamsize);
+    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type sp,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+};
+
+template <class charT, class traits, class Allocator>
+  void swap(basic_stringbuf<charT, traits, Allocator>& x,
+            basic_stringbuf<charT, traits, Allocator>& y);
+
+typedef basic_stringbuf<char>    stringbuf;
+typedef basic_stringbuf<wchar_t> wstringbuf;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_istringstream
+    : public basic_istream<charT, traits>
+{
+public:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef Allocator                      allocator_type;
+
+    // 27.8.2.1 Constructors:
+    explicit basic_istringstream(ios_base::openmode which = ios_base::in);
+    explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str,
+                                 ios_base::openmode which = ios_base::in);
+    basic_istringstream(basic_istringstream&& rhs);
+
+    // 27.8.2.2 Assign and swap:
+    basic_istringstream& operator=(basic_istringstream&& rhs);
+    void swap(basic_istringstream& rhs);
+
+    // 27.8.2.3 Members:
+    basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+    basic_string<char_type, traits_type, allocator_type> str() const;
+    void str(const basic_string<char_type, traits_type, allocator_type>& s);
+};
+
+template <class charT, class traits, class Allocator>
+  void swap(basic_istringstream<charT, traits, Allocator>& x,
+            basic_istringstream<charT, traits, Allocator>& y);
+
+typedef basic_istringstream<char>    istringstream;
+typedef basic_istringstream<wchar_t> wistringstream;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_ostringstream
+    : public basic_ostream<charT, traits>
+{
+public:
+    // types:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef Allocator                      allocator_type;
+
+    // 27.8.3.1 Constructors/destructor:
+    explicit basic_ostringstream(ios_base::openmode which = ios_base::out);
+    explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str,
+                                 ios_base::openmode which = ios_base::out);
+    basic_ostringstream(basic_ostringstream&& rhs);
+
+    // 27.8.3.2 Assign/swap:
+    basic_ostringstream& operator=(basic_ostringstream&& rhs);
+    void swap(basic_ostringstream& rhs);
+
+    // 27.8.3.3 Members:
+    basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+    basic_string<char_type, traits_type, allocator_type> str() const;
+    void str(const basic_string<char_type, traits_type, allocator_type>& s);
+};
+
+template <class charT, class traits, class Allocator>
+  void swap(basic_ostringstream<charT, traits, Allocator>& x,
+            basic_ostringstream<charT, traits, Allocator>& y);
+
+typedef basic_ostringstream<char>    ostringstream;
+typedef basic_ostringstream<wchar_t> wostringstream;
+
+template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_stringstream
+    : public basic_iostream<charT, traits>
+{
+public:
+    // types:
+    typedef charT                          char_type;
+    typedef traits                         traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef Allocator                      allocator_type;
+
+    // constructors/destructor
+    explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
+    explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str,
+                                ios_base::openmode which = ios_base::out|ios_base::in);
+    basic_stringstream(basic_stringstream&& rhs);
+
+    // 27.8.5.1 Assign/swap:
+    basic_stringstream& operator=(basic_stringstream&& rhs);
+    void swap(basic_stringstream& rhs);
+
+    // Members:
+    basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+    basic_string<char_type, traits_type, allocator_type> str() const;
+    void str(const basic_string<char_type, traits_type, allocator_type>& str);
+};
+
+template <class charT, class traits, class Allocator>
+  void swap(basic_stringstream<charT, traits, Allocator>& x,
+            basic_stringstream<charT, traits, Allocator>& y);
+
+typedef basic_stringstream<char>    stringstream;
+typedef basic_stringstream<wchar_t> wstringstream;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <ostream>
+#include <istream>
+#include <string>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// basic_stringbuf
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf
+    : public basic_streambuf<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef _Allocator                     allocator_type;
+
+    typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+
+    string_type __str_;
+    mutable char_type* __hm_;
+    ios_base::openmode __mode_;
+
+public:
+    // 27.8.1.1 Constructors:
+    explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
+    explicit basic_stringbuf(const string_type& __s,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_stringbuf(basic_stringbuf&& __rhs);
+#endif
+
+    // 27.8.1.2 Assign and swap:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_stringbuf& operator=(basic_stringbuf&& __rhs);
+#endif
+    void swap(basic_stringbuf& __rhs);
+
+    // 27.8.1.3 Get and set:
+    string_type str() const;
+    void str(const string_type& __s);
+
+protected:
+    // 27.8.1.4 Overridden virtual functions:
+    virtual int_type underflow();
+    virtual int_type pbackfail(int_type __c = traits_type::eof());
+    virtual int_type overflow (int_type __c = traits_type::eof());
+    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type __sp,
+                             ios_base::openmode __wch = ios_base::in | ios_base::out);
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
+    : __hm_(0),
+      __mode_(__wch)
+{
+    str(string_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
+                             ios_base::openmode __wch)
+    : __hm_(0),
+      __mode_(__wch)
+{
+    str(__s);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
+    : __mode_(__rhs.__mode_)
+{
+    char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
+    ptrdiff_t __binp = -1;
+    ptrdiff_t __ninp = -1;
+    ptrdiff_t __einp = -1;
+    if (__rhs.eback() != nullptr)
+    {
+        __binp = __rhs.eback() - __p;
+        __ninp = __rhs.gptr() - __p;
+        __einp = __rhs.egptr() - __p;
+    }
+    ptrdiff_t __bout = -1;
+    ptrdiff_t __nout = -1;
+    ptrdiff_t __eout = -1;
+    if (__rhs.pbase() != nullptr)
+    {
+        __bout = __rhs.pbase() - __p;
+        __nout = __rhs.pptr() - __p;
+        __eout = __rhs.epptr() - __p;
+    }
+    ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
+    __str_ = _VSTD::move(__rhs.__str_);
+    __p = const_cast<char_type*>(__str_.data());
+    if (__binp != -1)
+        this->setg(__p + __binp, __p + __ninp, __p + __einp);
+    if (__bout != -1)
+    {
+        this->setp(__p + __bout, __p + __eout);
+        this->pbump(__nout);
+    }
+    __hm_ = __hm == -1 ? nullptr : __p + __hm;
+    __p = const_cast<char_type*>(__rhs.__str_.data());
+    __rhs.setg(__p, __p, __p);
+    __rhs.setp(__p, __p);
+    __rhs.__hm_ = __p;
+    this->pubimbue(__rhs.getloc());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_stringbuf<_CharT, _Traits, _Allocator>&
+basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
+{
+    char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
+    ptrdiff_t __binp = -1;
+    ptrdiff_t __ninp = -1;
+    ptrdiff_t __einp = -1;
+    if (__rhs.eback() != nullptr)
+    {
+        __binp = __rhs.eback() - __p;
+        __ninp = __rhs.gptr() - __p;
+        __einp = __rhs.egptr() - __p;
+    }
+    ptrdiff_t __bout = -1;
+    ptrdiff_t __nout = -1;
+    ptrdiff_t __eout = -1;
+    if (__rhs.pbase() != nullptr)
+    {
+        __bout = __rhs.pbase() - __p;
+        __nout = __rhs.pptr() - __p;
+        __eout = __rhs.epptr() - __p;
+    }
+    ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
+    __str_ = _VSTD::move(__rhs.__str_);
+    __p = const_cast<char_type*>(__str_.data());
+    if (__binp != -1)
+        this->setg(__p + __binp, __p + __ninp, __p + __einp);
+    if (__bout != -1)
+    {
+        this->setp(__p + __bout, __p + __eout);
+        this->pbump(__nout);
+    }
+    __hm_ = __hm == -1 ? nullptr : __p + __hm;
+    __mode_ = __rhs.__mode_;
+    __p = const_cast<char_type*>(__rhs.__str_.data());
+    __rhs.setg(__p, __p, __p);
+    __rhs.setp(__p, __p);
+    __rhs.__hm_ = __p;
+    this->pubimbue(__rhs.getloc());
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
+{
+    char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
+    ptrdiff_t __rbinp = -1;
+    ptrdiff_t __rninp = -1;
+    ptrdiff_t __reinp = -1;
+    if (__rhs.eback() != nullptr)
+    {
+        __rbinp = __rhs.eback() - __p;
+        __rninp = __rhs.gptr() - __p;
+        __reinp = __rhs.egptr() - __p;
+    }
+    ptrdiff_t __rbout = -1;
+    ptrdiff_t __rnout = -1;
+    ptrdiff_t __reout = -1;
+    if (__rhs.pbase() != nullptr)
+    {
+        __rbout = __rhs.pbase() - __p;
+        __rnout = __rhs.pptr() - __p;
+        __reout = __rhs.epptr() - __p;
+    }
+    ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p;
+    __p = const_cast<char_type*>(__str_.data());
+    ptrdiff_t __lbinp = -1;
+    ptrdiff_t __lninp = -1;
+    ptrdiff_t __leinp = -1;
+    if (this->eback() != nullptr)
+    {
+        __lbinp = this->eback() - __p;
+        __lninp = this->gptr() - __p;
+        __leinp = this->egptr() - __p;
+    }
+    ptrdiff_t __lbout = -1;
+    ptrdiff_t __lnout = -1;
+    ptrdiff_t __leout = -1;
+    if (this->pbase() != nullptr)
+    {
+        __lbout = this->pbase() - __p;
+        __lnout = this->pptr() - __p;
+        __leout = this->epptr() - __p;
+    }
+    ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p;
+    _VSTD::swap(__mode_, __rhs.__mode_);
+    __str_.swap(__rhs.__str_);
+    __p = const_cast<char_type*>(__str_.data());
+    if (__rbinp != -1)
+        this->setg(__p + __rbinp, __p + __rninp, __p + __reinp);
+    else
+        this->setg(nullptr, nullptr, nullptr);
+    if (__rbout != -1)
+    {
+        this->setp(__p + __rbout, __p + __reout);
+        this->pbump(__rnout);
+    }
+    else
+        this->setp(nullptr, nullptr);
+    __hm_ = __rhm == -1 ? nullptr : __p + __rhm;
+    __p = const_cast<char_type*>(__rhs.__str_.data());
+    if (__lbinp != -1)
+        __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp);
+    else
+        __rhs.setg(nullptr, nullptr, nullptr);
+    if (__lbout != -1)
+    {
+        __rhs.setp(__p + __lbout, __p + __leout);
+        __rhs.pbump(__lnout);
+    }
+    else
+        __rhs.setp(nullptr, nullptr);
+    __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm;
+    locale __tl = __rhs.getloc();
+    __rhs.pubimbue(this->getloc());
+    this->pubimbue(__tl);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
+     basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
+{
+    if (__mode_ & ios_base::out)
+    {
+        if (__hm_ < this->pptr())
+            __hm_ = this->pptr();
+        return string_type(this->pbase(), __hm_, __str_.get_allocator());
+    }
+    else if (__mode_ & ios_base::in)
+        return string_type(this->eback(), this->egptr(), __str_.get_allocator());
+    return string_type(__str_.get_allocator());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
+{
+    __str_ = __s;
+    __hm_ = 0;
+    if (__mode_ & ios_base::in)
+    {
+        __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
+        this->setg(const_cast<char_type*>(__str_.data()),
+                   const_cast<char_type*>(__str_.data()),
+                   __hm_);
+    }
+    if (__mode_ & ios_base::out)
+    {
+        typename string_type::size_type __sz = __str_.size();
+        __hm_ = const_cast<char_type*>(__str_.data()) + __sz;
+        __str_.resize(__str_.capacity());
+        this->setp(const_cast<char_type*>(__str_.data()),
+                   const_cast<char_type*>(__str_.data()) + __str_.size());
+        if (__mode_ & (ios_base::app | ios_base::ate))
+            this->pbump(__sz);
+    }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
+{
+    if (__hm_ < this->pptr())
+        __hm_ = this->pptr();
+    if (__mode_ & ios_base::in)
+    {
+        if (this->egptr() < __hm_)
+            this->setg(this->eback(), this->gptr(), __hm_);
+        if (this->gptr() < this->egptr())
+            return traits_type::to_int_type(*this->gptr());
+    }
+    return traits_type::eof();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c)
+{
+    if (__hm_ < this->pptr())
+        __hm_ = this->pptr();
+    if (this->eback() < this->gptr())
+    {
+        if (traits_type::eq_int_type(__c, traits_type::eof()))
+        {
+            this->setg(this->eback(), this->gptr()-1, __hm_);
+            return traits_type::not_eof(__c);
+        }
+        if ((__mode_ & ios_base::out) ||
+            traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
+        {
+            this->setg(this->eback(), this->gptr()-1, __hm_);
+            *this->gptr() = traits_type::to_char_type(__c);
+            return __c;
+        }
+    }
+    return traits_type::eof();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
+{
+    if (!traits_type::eq_int_type(__c, traits_type::eof()))
+    {
+        ptrdiff_t __ninp = this->gptr()  - this->eback();
+        if (this->pptr() == this->epptr())
+        {
+            if (!(__mode_ & ios_base::out))
+                return traits_type::eof();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            try
+            {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+                ptrdiff_t __nout = this->pptr()  - this->pbase();
+                ptrdiff_t __hm = __hm_ - this->pbase();
+                __str_.push_back(char_type());
+                __str_.resize(__str_.capacity());
+                char_type* __p = const_cast<char_type*>(__str_.data());
+                this->setp(__p, __p + __str_.size());
+                this->pbump(__nout);
+                __hm_ = this->pbase() + __hm;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            }
+            catch (...)
+            {
+                return traits_type::eof();
+            }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        }
+        __hm_ = _VSTD::max(this->pptr() + 1, __hm_);
+        if (__mode_ & ios_base::in)
+        {
+            char_type* __p = const_cast<char_type*>(__str_.data());
+            this->setg(__p, __p + __ninp, __hm_);
+        }
+        return this->sputc(__c);
+    }
+    return traits_type::not_eof(__c);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
+                                                      ios_base::seekdir __way,
+                                                      ios_base::openmode __wch)
+{
+    if (__hm_ < this->pptr())
+        __hm_ = this->pptr();
+    if ((__wch & (ios_base::in | ios_base::out)) == 0)
+        return pos_type(-1);
+    if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
+        && __way == ios_base::cur)
+        return pos_type(-1);
+    off_type __noff;
+    switch (__way)
+    {
+    case ios_base::beg:
+        __noff = 0;
+        break;
+    case ios_base::cur:
+        if (__wch & ios_base::in)
+            __noff = this->gptr() - this->eback();
+        else
+            __noff = this->pptr() - this->pbase();
+        break;
+    case ios_base::end:
+        __noff = __hm_ - __str_.data();
+        break;
+    default:
+        return pos_type(-1);
+    }
+    __noff += __off;
+    if (__noff < 0 || __hm_ - __str_.data() < __noff)
+        return pos_type(-1);
+    if (__noff != 0)
+    {
+        if ((__wch & ios_base::in) && this->gptr() == 0)
+            return pos_type(-1);
+        if ((__wch & ios_base::out) && this->pptr() == 0)
+            return pos_type(-1);
+    }
+    if (__wch & ios_base::in)
+        this->setg(this->eback(), this->eback() + __noff, __hm_);
+    if (__wch & ios_base::out)
+    {
+        this->setp(this->pbase(), this->epptr());
+        this->pbump(__noff);
+    }
+    return pos_type(__noff);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
+basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
+                                                      ios_base::openmode __wch)
+{
+    return seekoff(__sp, ios_base::beg, __wch);
+}
+
+// basic_istringstream
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TYPE_VIS_ONLY basic_istringstream
+    : public basic_istream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef _Allocator                     allocator_type;
+
+    typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+    basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
+
+public:
+    // 27.8.2.1 Constructors:
+    explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
+    explicit basic_istringstream(const string_type& __s,
+                                 ios_base::openmode __wch = ios_base::in);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_istringstream(basic_istringstream&& __rhs);
+
+    // 27.8.2.2 Assign and swap:
+    basic_istringstream& operator=(basic_istringstream&& __rhs);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void swap(basic_istringstream& __rhs);
+
+    // 27.8.2.3 Members:
+    basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+    string_type str() const;
+    void str(const string_type& __s);
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
+    : basic_istream<_CharT, _Traits>(&__sb_),
+      __sb_(__wch | ios_base::in)
+{
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
+                                                                      ios_base::openmode __wch)
+    : basic_istream<_CharT, _Traits>(&__sb_),
+      __sb_(__s, __wch | ios_base::in)
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
+    : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_istringstream<_CharT, _Traits, _Allocator>&
+basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
+{
+    basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
+{
+    basic_istream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
+     basic_istringstream<_CharT, _Traits, _Allocator>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringbuf<_CharT, _Traits, _Allocator>*
+basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
+{
+    return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+basic_istringstream<_CharT, _Traits, _Allocator>::str() const
+{
+    return __sb_.str();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
+{
+    __sb_.str(__s);
+}
+
+// basic_ostringstream
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream
+    : public basic_ostream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef _Allocator                     allocator_type;
+
+    typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+    basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
+
+public:
+    // 27.8.2.1 Constructors:
+    explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
+    explicit basic_ostringstream(const string_type& __s,
+                                 ios_base::openmode __wch = ios_base::out);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_ostringstream(basic_ostringstream&& __rhs);
+
+    // 27.8.2.2 Assign and swap:
+    basic_ostringstream& operator=(basic_ostringstream&& __rhs);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void swap(basic_ostringstream& __rhs);
+
+    // 27.8.2.3 Members:
+    basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+    string_type str() const;
+    void str(const string_type& __s);
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
+    : basic_ostream<_CharT, _Traits>(&__sb_),
+      __sb_(__wch | ios_base::out)
+{
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
+                                                                      ios_base::openmode __wch)
+    : basic_ostream<_CharT, _Traits>(&__sb_),
+      __sb_(__s, __wch | ios_base::out)
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
+    : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_ostringstream<_CharT, _Traits, _Allocator>&
+basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
+{
+    basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
+{
+    basic_ostream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
+     basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringbuf<_CharT, _Traits, _Allocator>*
+basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
+{
+    return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
+{
+    return __sb_.str();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
+{
+    __sb_.str(__s);
+}
+
+// basic_stringstream
+
+template <class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TYPE_VIS_ONLY basic_stringstream
+    : public basic_iostream<_CharT, _Traits>
+{
+public:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+    typedef _Allocator                     allocator_type;
+
+    typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+private:
+    basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
+
+public:
+    // 27.8.2.1 Constructors:
+    explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
+    explicit basic_stringstream(const string_type& __s,
+                                ios_base::openmode __wch = ios_base::in | ios_base::out);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    basic_stringstream(basic_stringstream&& __rhs);
+
+    // 27.8.2.2 Assign and swap:
+    basic_stringstream& operator=(basic_stringstream&& __rhs);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void swap(basic_stringstream& __rhs);
+
+    // 27.8.2.3 Members:
+    basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
+    string_type str() const;
+    void str(const string_type& __s);
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
+    : basic_iostream<_CharT, _Traits>(&__sb_),
+      __sb_(__wch)
+{
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
+                                                                    ios_base::openmode __wch)
+    : basic_iostream<_CharT, _Traits>(&__sb_),
+      __sb_(__s, __wch)
+{
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
+    : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
+      __sb_(_VSTD::move(__rhs.__sb_))
+{
+    basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_stringstream<_CharT, _Traits, _Allocator>&
+basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
+{
+    basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
+    __sb_ = _VSTD::move(__rhs.__sb_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
+{
+    basic_iostream<char_type, traits_type>::swap(__rhs);
+    __sb_.swap(__rhs.__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
+     basic_stringstream<_CharT, _Traits, _Allocator>& __y)
+{
+    __x.swap(__y);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_stringbuf<_CharT, _Traits, _Allocator>*
+basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
+{
+    return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+basic_stringstream<_CharT, _Traits, _Allocator>::str() const
+{
+    return __sb_.str();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
+{
+    __sb_.str(__s);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_SSTREAM
diff --git a/final/include/stack b/final/include/stack
new file mode 100644
index 0000000..30909c1
--- /dev/null
+++ b/final/include/stack
@@ -0,0 +1,292 @@
+// -*- C++ -*-
+//===---------------------------- stack -----------------------------------===//
+//
+//                     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_STACK
+#define _LIBCPP_STACK
+
+/*
+    stack synopsis
+
+namespace std
+{
+
+template <class T, class Container = deque<T>>
+class stack
+{
+public:
+    typedef Container                                container_type;
+    typedef typename container_type::value_type      value_type;
+    typedef typename container_type::reference       reference;
+    typedef typename container_type::const_reference const_reference;
+    typedef typename container_type::size_type       size_type;
+
+protected:
+    container_type c;
+
+public:
+    stack() = default;
+    ~stack() = default;
+
+    stack(const stack& q) = default;
+    stack(stack&& q) = default;
+
+    stack& operator=(const stack& q) = default;
+    stack& operator=(stack&& q) = default;
+
+    explicit stack(const container_type& c);
+    explicit stack(container_type&& c);
+    template <class Alloc> explicit stack(const Alloc& a);
+    template <class Alloc> stack(const container_type& c, const Alloc& a);
+    template <class Alloc> stack(container_type&& c, const Alloc& a);
+    template <class Alloc> stack(const stack& c, const Alloc& a);
+    template <class Alloc> stack(stack&& c, const Alloc& a);
+
+    bool empty() const;
+    size_type size() const;
+    reference top();
+    const_reference top() const;
+
+    void push(const value_type& x);
+    void push(value_type&& x);
+    template <class... Args> void emplace(Args&&... args);
+    void pop();
+
+    void swap(stack& c) noexcept(noexcept(swap(c, q.c)));
+};
+
+template <class T, class Container>
+  bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+  bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+  bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+  bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+  bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
+template <class T, class Container>
+  bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
+
+template <class T, class Container>
+  void swap(stack<T, Container>& x, stack<T, Container>& y)
+  noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+#include <deque>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS_ONLY stack;
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container>
+_LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
+
+template <class _Tp, class _Container = deque<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY stack
+{
+public:
+    typedef _Container                               container_type;
+    typedef typename container_type::value_type      value_type;
+    typedef typename container_type::reference       reference;
+    typedef typename container_type::const_reference const_reference;
+    typedef typename container_type::size_type       size_type;
+
+protected:
+    container_type c;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    stack()
+        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
+        : c() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    stack(const stack& __q) : c(__q.c) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    stack(stack&& __q)
+        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
+        : c(_VSTD::move(__q.c)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    stack& operator=(const stack& __q) {c = __q.c; return *this;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    stack& operator=(stack&& __q)
+        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
+        {c = _VSTD::move(__q.c); return *this;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit stack(const container_type& __c) : c(__c) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    explicit stack(container_type&& __c) : c(_VSTD::move(__c)) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit stack(const _Alloc& __a,
+                       typename enable_if<uses_allocator<container_type,
+                                                         _Alloc>::value>::type* = 0)
+            : c(__a) {}
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        stack(const container_type& __c, const _Alloc& __a,
+              typename enable_if<uses_allocator<container_type,
+                                                _Alloc>::value>::type* = 0)
+            : c(__c, __a) {}
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        stack(const stack& __s, const _Alloc& __a,
+              typename enable_if<uses_allocator<container_type,
+                                                _Alloc>::value>::type* = 0)
+            : c(__s.c, __a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        stack(container_type&& __c, const _Alloc& __a,
+              typename enable_if<uses_allocator<container_type,
+                                                _Alloc>::value>::type* = 0)
+            : c(_VSTD::move(__c), __a) {}
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        stack(stack&& __s, const _Alloc& __a,
+              typename enable_if<uses_allocator<container_type,
+                                                _Alloc>::value>::type* = 0)
+            : c(_VSTD::move(__s.c), __a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty()     const      {return c.empty();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const      {return c.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    reference top()             {return c.back();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference top() const {return c.back();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void push(const value_type& __v) {c.push_back(__v);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        void emplace(_Args&&... __args)
+        {c.emplace_back(_VSTD::forward<_Args>(__args)...);}
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void pop() {c.pop_back();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(stack& __s)
+        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
+    {
+        using _VSTD::swap;
+        swap(c, __s.c);
+    }
+
+    template <class T1, class _C1>
+    friend
+    bool
+    operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
+
+    template <class T1, class _C1>
+    friend
+    bool
+    operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
+};
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+    return __x.c == __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+    return __x.c < __y.c;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Tp, class _Container>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Tp, class _Container, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<stack<_Tp, _Container>, _Alloc>
+    : public uses_allocator<_Container, _Alloc>
+{
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_STACK
diff --git a/final/include/stdexcept b/final/include/stdexcept
new file mode 100644
index 0000000..5fc912a
--- /dev/null
+++ b/final/include/stdexcept
@@ -0,0 +1,170 @@
+// -*- C++ -*-
+//===--------------------------- stdexcept --------------------------------===//
+//
+//                     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_STDEXCEPT
+#define _LIBCPP_STDEXCEPT
+
+/*
+    stdexcept synopsis
+
+namespace std
+{
+
+class logic_error;
+    class domain_error;
+    class invalid_argument;
+    class length_error;
+    class out_of_range;
+class runtime_error;
+    class range_error;
+    class overflow_error;
+    class underflow_error;
+
+for each class xxx_error:
+
+class xxx_error : public exception // at least indirectly
+{
+public:
+    explicit xxx_error(const string& what_arg);
+    explicit xxx_error(const char*   what_arg);
+
+    virtual const char* what() const noexcept // returns what_arg
+};
+
+}  // std
+
+*/
+
+#include <__config>
+#include <exception>
+#include <iosfwd>  // for string forward decl
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#ifndef _LIBCPP___REFSTRING
+_LIBCPP_BEGIN_NAMESPACE_STD
+class _LIBCPP_HIDDEN __libcpp_refstring {
+    const char *__imp_;
+};
+_LIBCPP_END_NAMESPACE_STD
+#endif
+
+namespace std  // purposefully not using versioning namespace
+{
+
+class _LIBCPP_EXCEPTION_ABI logic_error
+    : public exception
+{
+private:
+    _VSTD::__libcpp_refstring __imp_;
+public:
+    explicit logic_error(const string&);
+    explicit logic_error(const char*);
+
+    logic_error(const logic_error&) _NOEXCEPT;
+    logic_error& operator=(const logic_error&) _NOEXCEPT;
+
+    virtual ~logic_error() _NOEXCEPT;
+
+    virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI runtime_error
+    : public exception
+{
+private:
+    _VSTD::__libcpp_refstring __imp_;
+public:
+    explicit runtime_error(const string&);
+    explicit runtime_error(const char*);
+
+    runtime_error(const runtime_error&) _NOEXCEPT;
+    runtime_error& operator=(const runtime_error&) _NOEXCEPT;
+
+    virtual ~runtime_error() _NOEXCEPT;
+
+    virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI domain_error
+    : public logic_error
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {}
+    _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s)   : logic_error(__s) {}
+
+    virtual ~domain_error() _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI invalid_argument
+    : public logic_error
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {}
+    _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s)   : logic_error(__s) {}
+
+    virtual ~invalid_argument() _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI length_error
+    : public logic_error
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {}
+    _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s)   : logic_error(__s) {}
+
+    virtual ~length_error() _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI out_of_range
+    : public logic_error
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {}
+    _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s)   : logic_error(__s) {}
+
+    virtual ~out_of_range() _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI range_error
+    : public runtime_error
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {}
+    _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s)   : runtime_error(__s) {}
+
+    virtual ~range_error() _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI overflow_error
+    : public runtime_error
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {}
+    _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s)   : runtime_error(__s) {}
+
+    virtual ~overflow_error() _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI underflow_error
+    : public runtime_error
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {}
+    _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s)   : runtime_error(__s) {}
+
+    virtual ~underflow_error() _NOEXCEPT;
+};
+
+}  // std
+
+#endif  // _LIBCPP_STDEXCEPT
diff --git a/final/include/streambuf b/final/include/streambuf
new file mode 100644
index 0000000..6adfc92
--- /dev/null
+++ b/final/include/streambuf
@@ -0,0 +1,564 @@
+// -*- C++ -*-
+//===------------------------- streambuf ----------------------------------===//
+//
+//                     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_STEAMBUF
+#define _LIBCPP_STEAMBUF
+
+/*
+    streambuf synopsis
+
+namespace std
+{
+
+template <class charT, class traits = char_traits<charT> >
+class basic_streambuf
+{
+public:
+    // types:
+    typedef charT char_type;
+    typedef traits traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    virtual ~basic_streambuf();
+
+    // 27.6.2.2.1 locales:
+    locale pubimbue(const locale& loc);
+    locale getloc() const;
+
+    // 27.6.2.2.2 buffer and positioning:
+    basic_streambuf* pubsetbuf(char_type* s, streamsize n);
+    pos_type pubseekoff(off_type off, ios_base::seekdir way,
+                        ios_base::openmode which = ios_base::in | ios_base::out);
+    pos_type pubseekpos(pos_type sp,
+                        ios_base::openmode which = ios_base::in | ios_base::out);
+    int pubsync();
+
+    // Get and put areas:
+    // 27.6.2.2.3 Get area:
+    streamsize in_avail();
+    int_type snextc();
+    int_type sbumpc();
+    int_type sgetc();
+    streamsize sgetn(char_type* s, streamsize n);
+
+    // 27.6.2.2.4 Putback:
+    int_type sputbackc(char_type c);
+    int_type sungetc();
+
+    // 27.6.2.2.5 Put area:
+    int_type sputc(char_type c);
+    streamsize sputn(const char_type* s, streamsize n);
+
+protected:
+    basic_streambuf();
+    basic_streambuf(const basic_streambuf& rhs);
+    basic_streambuf& operator=(const basic_streambuf& rhs);
+    void swap(basic_streambuf& rhs);
+
+    // 27.6.2.3.2 Get area:
+    char_type* eback() const;
+    char_type* gptr() const;
+    char_type* egptr() const;
+    void gbump(int n);
+    void setg(char_type* gbeg, char_type* gnext, char_type* gend);
+
+    // 27.6.2.3.3 Put area:
+    char_type* pbase() const;
+    char_type* pptr() const;
+    char_type* epptr() const;
+    void pbump(int n);
+    void setp(char_type* pbeg, char_type* pend);
+
+    // 27.6.2.4 virtual functions:
+    // 27.6.2.4.1 Locales:
+    virtual void imbue(const locale& loc);
+
+    // 27.6.2.4.2 Buffer management and positioning:
+    virtual basic_streambuf* setbuf(char_type* s, streamsize n);
+    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type sp,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual int sync();
+
+    // 27.6.2.4.3 Get area:
+    virtual streamsize showmanyc();
+    virtual streamsize xsgetn(char_type* s, streamsize n);
+    virtual int_type underflow();
+    virtual int_type uflow();
+
+    // 27.6.2.4.4 Putback:
+    virtual int_type pbackfail(int_type c = traits_type::eof());
+
+    // 27.6.2.4.5 Put area:
+    virtual streamsize xsputn(const char_type* s, streamsize n);
+    virtual int_type overflow (int_type c = traits_type::eof());
+};
+
+}  // std
+
+*/
+
+#include <__config>
+#include <iosfwd>
+#include <ios>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _CharT, class _Traits>
+class _LIBCPP_TYPE_VIS_ONLY basic_streambuf
+{
+public:
+    // types:
+    typedef _CharT                         char_type;
+    typedef _Traits                        traits_type;
+    typedef typename traits_type::int_type int_type;
+    typedef typename traits_type::pos_type pos_type;
+    typedef typename traits_type::off_type off_type;
+
+    virtual ~basic_streambuf();
+
+    // 27.6.2.2.1 locales:
+    locale pubimbue(const locale& __loc);
+    locale getloc() const;
+
+    // 27.6.2.2.2 buffer and positioning:
+    basic_streambuf* pubsetbuf(char_type* __s, streamsize __n);
+    pos_type pubseekoff(off_type __off, ios_base::seekdir __way,
+                        ios_base::openmode __which = ios_base::in | ios_base::out);
+    pos_type pubseekpos(pos_type __sp,
+                        ios_base::openmode __which = ios_base::in | ios_base::out);
+    int pubsync();
+
+    // Get and put areas:
+    // 27.6.2.2.3 Get area:
+    streamsize in_avail();
+    int_type snextc();
+    int_type sbumpc();
+    int_type sgetc();
+    streamsize sgetn(char_type* __s, streamsize __n);
+
+    // 27.6.2.2.4 Putback:
+    int_type sputbackc(char_type __c);
+    int_type sungetc();
+
+    // 27.6.2.2.5 Put area:
+    int_type sputc(char_type __c);
+    streamsize sputn(const char_type* __s, streamsize __n);
+
+protected:
+    basic_streambuf();
+    basic_streambuf(const basic_streambuf& __rhs);
+    basic_streambuf& operator=(const basic_streambuf& __rhs);
+    void swap(basic_streambuf& __rhs);
+
+    // 27.6.2.3.2 Get area:
+    _LIBCPP_ALWAYS_INLINE char_type* eback() const {return __binp_;}
+    _LIBCPP_ALWAYS_INLINE char_type* gptr()  const {return __ninp_;}
+    _LIBCPP_ALWAYS_INLINE char_type* egptr() const {return __einp_;}
+    void gbump(int __n);
+    void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend);
+
+    // 27.6.2.3.3 Put area:
+    _LIBCPP_ALWAYS_INLINE char_type* pbase() const {return __bout_;}
+    _LIBCPP_ALWAYS_INLINE char_type* pptr()  const {return __nout_;}
+    _LIBCPP_ALWAYS_INLINE char_type* epptr() const {return __eout_;}
+    void pbump(int __n);
+    void setp(char_type* __pbeg, char_type* __pend);
+
+    // 27.6.2.4 virtual functions:
+    // 27.6.2.4.1 Locales:
+    virtual void imbue(const locale& __loc);
+
+    // 27.6.2.4.2 Buffer management and positioning:
+    virtual basic_streambuf* setbuf(char_type* __s, streamsize __n);
+    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+                             ios_base::openmode __which = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type __sp,
+                             ios_base::openmode __which = ios_base::in | ios_base::out);
+    virtual int sync();
+
+    // 27.6.2.4.3 Get area:
+    virtual streamsize showmanyc();
+    virtual streamsize xsgetn(char_type* __s, streamsize __n);
+    virtual int_type underflow();
+    virtual int_type uflow();
+
+    // 27.6.2.4.4 Putback:
+    virtual int_type pbackfail(int_type __c = traits_type::eof());
+
+    // 27.6.2.4.5 Put area:
+    virtual streamsize xsputn(const char_type* __s, streamsize __n);
+    virtual int_type overflow(int_type __c = traits_type::eof());
+
+private:
+    locale __loc_;
+    char_type* __binp_;
+    char_type* __ninp_;
+    char_type* __einp_;
+    char_type* __bout_;
+    char_type* __nout_;
+    char_type* __eout_;
+};
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>::~basic_streambuf()
+{
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+locale
+basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc)
+{
+    imbue(__loc);
+    locale __r = __loc_;
+    __loc_ = __loc;
+    return __r;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+locale
+basic_streambuf<_CharT, _Traits>::getloc() const
+{
+    return __loc_;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_streambuf<_CharT, _Traits>*
+basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n)
+{
+    return setbuf(__s, __n);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::pos_type
+basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off,
+                                             ios_base::seekdir __way,
+                                             ios_base::openmode __which)
+{
+    return seekoff(__off, __way, __which);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::pos_type
+basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp,
+                                             ios_base::openmode __which)
+{
+    return seekpos(__sp, __which);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+int
+basic_streambuf<_CharT, _Traits>::pubsync()
+{
+    return sync();
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+basic_streambuf<_CharT, _Traits>::in_avail()
+{
+    if (__ninp_ < __einp_)
+        return static_cast<streamsize>(__einp_ - __ninp_);
+    return showmanyc();
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::snextc()
+{
+    if (sbumpc() == traits_type::eof())
+        return traits_type::eof();
+    return sgetc();
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::sbumpc()
+{
+    if (__ninp_ == __einp_)
+        return uflow();
+    return traits_type::to_int_type(*__ninp_++);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::sgetc()
+{
+    if (__ninp_ == __einp_)
+        return underflow();
+    return traits_type::to_int_type(*__ninp_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n)
+{
+    return xsgetn(__s, __n);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c)
+{
+    if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1]))
+        return pbackfail(traits_type::to_int_type(__c));
+    return traits_type::to_int_type(*--__ninp_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::sungetc()
+{
+    if (__binp_ == __ninp_)
+        return pbackfail();
+    return traits_type::to_int_type(*--__ninp_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::sputc(char_type __c)
+{
+    if (__nout_ == __eout_)
+        return overflow(traits_type::to_int_type(__c));
+    *__nout_++ = __c;
+    return traits_type::to_int_type(__c);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+streamsize
+basic_streambuf<_CharT, _Traits>::sputn(const char_type* __s, streamsize __n)
+{
+    return xsputn(__s, __n);
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>::basic_streambuf()
+    : __binp_(0),
+      __ninp_(0),
+      __einp_(0),
+      __bout_(0),
+      __nout_(0),
+      __eout_(0)
+{
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb)
+    : __loc_(__sb.__loc_),
+      __binp_(__sb.__binp_),
+      __ninp_(__sb.__ninp_),
+      __einp_(__sb.__einp_),
+      __bout_(__sb.__bout_),
+      __nout_(__sb.__nout_),
+      __eout_(__sb.__eout_)
+{
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>&
+basic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb)
+{
+    __loc_ = __sb.__loc_;
+    __binp_ = __sb.__binp_;
+    __ninp_ = __sb.__ninp_;
+    __einp_ = __sb.__einp_;
+    __bout_ = __sb.__bout_;
+    __nout_ = __sb.__nout_;
+    __eout_ = __sb.__eout_;
+    return *this;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb)
+{
+    _VSTD::swap(__loc_, __sb.__loc_);
+    _VSTD::swap(__binp_, __sb.__binp_);
+    _VSTD::swap(__ninp_, __sb.__ninp_);
+    _VSTD::swap(__einp_, __sb.__einp_);
+    _VSTD::swap(__bout_, __sb.__bout_);
+    _VSTD::swap(__nout_, __sb.__nout_);
+    _VSTD::swap(__eout_, __sb.__eout_);
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_streambuf<_CharT, _Traits>::gbump(int __n)
+{
+    __ninp_ += __n;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext,
+                                                          char_type* __gend)
+{
+    __binp_ = __gbeg;
+    __ninp_ = __gnext;
+    __einp_ = __gend;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_streambuf<_CharT, _Traits>::pbump(int __n)
+{
+    __nout_ += __n;
+}
+
+template <class _CharT, class _Traits>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_streambuf<_CharT, _Traits>::setp(char_type* __pbeg, char_type* __pend)
+{
+    __bout_ = __nout_ = __pbeg;
+    __eout_ = __pend;
+}
+
+template <class _CharT, class _Traits>
+void
+basic_streambuf<_CharT, _Traits>::imbue(const locale&)
+{
+}
+
+template <class _CharT, class _Traits>
+basic_streambuf<_CharT, _Traits>*
+basic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize)
+{
+    return this;
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::pos_type
+basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir,
+                                          ios_base::openmode)
+{
+    return pos_type(off_type(-1));
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::pos_type
+basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode)
+{
+    return pos_type(off_type(-1));
+}
+
+template <class _CharT, class _Traits>
+int
+basic_streambuf<_CharT, _Traits>::sync()
+{
+    return 0;
+}
+
+template <class _CharT, class _Traits>
+streamsize
+basic_streambuf<_CharT, _Traits>::showmanyc()
+{
+    return 0;
+}
+
+template <class _CharT, class _Traits>
+streamsize
+basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n)
+{
+    const int_type __eof = traits_type::eof();
+    int_type __c;
+    streamsize __i = 0;
+    for (;__i < __n; ++__i, ++__s)
+    {
+        if (__ninp_ < __einp_)
+            *__s = *__ninp_++;
+        else if ((__c = uflow()) != __eof)
+            *__s = traits_type::to_char_type(__c);
+        else
+            break;
+    }
+    return __i;
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::underflow()
+{
+    return traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::uflow()
+{
+    if (underflow() == traits_type::eof())
+        return traits_type::eof();
+    return traits_type::to_int_type(*__ninp_++);
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::pbackfail(int_type)
+{
+    return traits_type::eof();
+}
+
+template <class _CharT, class _Traits>
+streamsize
+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)
+    {
+        if (__nout_ < __eout_)
+            *__nout_++ = *__s;
+        else if (overflow(traits_type::to_int_type(*__s)) == __eof)
+            break;
+    }
+    return __i;
+}
+
+template <class _CharT, class _Traits>
+typename basic_streambuf<_CharT, _Traits>::int_type
+basic_streambuf<_CharT, _Traits>::overflow(int_type)
+{
+    return traits_type::eof();
+}
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<wchar_t>)
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<wchar_t>)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_STEAMBUF
diff --git a/final/include/string b/final/include/string
new file mode 100644
index 0000000..d6c148a
--- /dev/null
+++ b/final/include/string
@@ -0,0 +1,4299 @@
+// -*- C++ -*-
+//===--------------------------- string -----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_STRING
+#define _LIBCPP_STRING
+
+/*
+    string synopsis
+
+namespace std
+{
+
+template <class stateT>
+class fpos
+{
+private:
+    stateT st;
+public:
+    fpos(streamoff = streamoff());
+
+    operator streamoff() const;
+
+    stateT state() const;
+    void state(stateT);
+
+    fpos& operator+=(streamoff);
+    fpos  operator+ (streamoff) const;
+    fpos& operator-=(streamoff);
+    fpos  operator- (streamoff) const;
+};
+
+template <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y);
+
+template <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y);
+template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y);
+
+template <class charT>
+struct char_traits
+{
+    typedef charT     char_type;
+    typedef ...       int_type;
+    typedef streamoff off_type;
+    typedef streampos pos_type;
+    typedef mbstate_t state_type;
+
+    static void assign(char_type& c1, const char_type& c2) noexcept;
+    static constexpr bool eq(char_type c1, char_type c2) noexcept;
+    static constexpr bool lt(char_type c1, char_type c2) noexcept;
+
+    static int              compare(const char_type* s1, const char_type* s2, size_t n);
+    static size_t           length(const char_type* s);
+    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);
+    static char_type*       copy(char_type* s1, const char_type* s2, size_t n);
+    static char_type*       assign(char_type* s, size_t n, char_type a);
+
+    static constexpr int_type  not_eof(int_type c) noexcept;
+    static constexpr char_type to_char_type(int_type c) noexcept;
+    static constexpr int_type  to_int_type(char_type c) noexcept;
+    static constexpr bool      eq_int_type(int_type c1, int_type c2) noexcept;
+    static constexpr int_type  eof() noexcept;
+};
+
+template <> struct char_traits<char>;
+template <> struct char_traits<wchar_t>;
+
+template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+class basic_string
+{
+public:
+// types:
+    typedef traits traits_type;
+    typedef typename traits_type::char_type value_type;
+    typedef Allocator allocator_type;
+    typedef typename allocator_type::size_type size_type;
+    typedef typename allocator_type::difference_type difference_type;
+    typedef typename allocator_type::reference reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef typename allocator_type::pointer pointer;
+    typedef typename allocator_type::const_pointer const_pointer;
+    typedef implementation-defined iterator;
+    typedef implementation-defined const_iterator;
+    typedef std::reverse_iterator<iterator> reverse_iterator;
+    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+    static const size_type npos = -1;
+
+    basic_string()
+        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+    explicit basic_string(const allocator_type& a);
+    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,
+                 const allocator_type& a = allocator_type());
+    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());
+    template<class InputIterator>
+        basic_string(InputIterator begin, InputIterator end,
+                     const allocator_type& a = allocator_type());
+    basic_string(initializer_list<value_type>, const Allocator& = Allocator());
+    basic_string(const basic_string&, const Allocator&);
+    basic_string(basic_string&&, const Allocator&);
+
+    ~basic_string();
+
+    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);
+    basic_string& operator=(const value_type* s);
+    basic_string& operator=(value_type c);
+    basic_string& operator=(initializer_list<value_type>);
+
+    iterator       begin() noexcept;
+    const_iterator begin() const noexcept;
+    iterator       end() noexcept;
+    const_iterator end() const noexcept;
+
+    reverse_iterator       rbegin() noexcept;
+    const_reverse_iterator rbegin() const noexcept;
+    reverse_iterator       rend() noexcept;
+    const_reverse_iterator rend() const noexcept;
+
+    const_iterator         cbegin() const noexcept;
+    const_iterator         cend() const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend() const noexcept;
+
+    size_type size() const noexcept;
+    size_type length() const noexcept;
+    size_type max_size() const noexcept;
+    size_type capacity() const noexcept;
+
+    void resize(size_type n, value_type c);
+    void resize(size_type n);
+
+    void reserve(size_type res_arg = 0);
+    void shrink_to_fit();
+    void clear() noexcept;
+    bool empty() const noexcept;
+
+    const_reference operator[](size_type pos) const;
+    reference       operator[](size_type pos);
+
+    const_reference at(size_type n) const;
+    reference       at(size_type n);
+
+    basic_string& operator+=(const basic_string& str);
+    basic_string& operator+=(const value_type* s);
+    basic_string& operator+=(value_type c);
+    basic_string& operator+=(initializer_list<value_type>);
+
+    basic_string& append(const basic_string& str);
+    basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14
+    basic_string& append(const value_type* s, size_type n);
+    basic_string& append(const value_type* s);
+    basic_string& append(size_type n, value_type c);
+    template<class InputIterator>
+        basic_string& append(InputIterator first, InputIterator last);
+    basic_string& append(initializer_list<value_type>);
+
+    void push_back(value_type c);
+    void pop_back();
+    reference       front();
+    const_reference front() const;
+    reference       back();
+    const_reference back() const;
+
+    basic_string& assign(const basic_string& str);
+    basic_string& assign(basic_string&& str);
+    basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14
+    basic_string& assign(const value_type* s, size_type n);
+    basic_string& assign(const value_type* s);
+    basic_string& assign(size_type n, value_type c);
+    template<class InputIterator>
+        basic_string& assign(InputIterator first, InputIterator last);
+    basic_string& assign(initializer_list<value_type>);
+
+    basic_string& insert(size_type pos1, const basic_string& str);
+    basic_string& insert(size_type pos1, const basic_string& str,
+                         size_type pos2, size_type n);
+    basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14
+    basic_string& insert(size_type pos, const value_type* s);
+    basic_string& insert(size_type pos, size_type n, value_type c);
+    iterator      insert(const_iterator p, value_type c);
+    iterator      insert(const_iterator p, size_type n, value_type c);
+    template<class InputIterator>
+        iterator insert(const_iterator p, InputIterator first, InputIterator last);
+    iterator      insert(const_iterator p, initializer_list<value_type>);
+
+    basic_string& erase(size_type pos = 0, size_type n = npos);
+    iterator      erase(const_iterator position);
+    iterator      erase(const_iterator first, const_iterator last);
+
+    basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
+    basic_string& replace(size_type pos1, size_type n1, const basic_string& str,
+                          size_type pos2, size_type n2=npos); // C++14
+    basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2);
+    basic_string& replace(size_type pos, size_type n1, const value_type* s);
+    basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c);
+    basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str);
+    basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n);
+    basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s);
+    basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c);
+    template<class InputIterator>
+        basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
+    basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>);
+
+    size_type copy(value_type* s, size_type n, size_type pos = 0) const;
+    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)
+
+    const value_type* c_str() const noexcept;
+    const value_type* data() const noexcept;
+
+    allocator_type get_allocator() const noexcept;
+
+    size_type find(const basic_string& str, size_type pos = 0) const noexcept;
+    size_type find(const value_type* s, size_type pos, size_type n) const noexcept;
+    size_type find(const value_type* s, size_type pos = 0) const noexcept;
+    size_type find(value_type c, size_type pos = 0) const noexcept;
+
+    size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
+    size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
+    size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
+    size_type rfind(value_type c, size_type pos = npos) const noexcept;
+
+    size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept;
+    size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept;
+    size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept;
+    size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
+
+    size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
+    size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
+    size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
+    size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
+
+    size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept;
+    size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
+    size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept;
+    size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
+
+    size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
+    size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
+    size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
+    size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
+
+    int compare(const basic_string& str) const noexcept;
+    int compare(size_type pos1, size_type n1, const basic_string& str) const;
+    int compare(size_type pos1, size_type n1, const basic_string& str,
+                size_type pos2, size_type n2=npos) const; // C++14
+    int compare(const value_type* s) const noexcept;
+    int compare(size_type pos1, size_type n1, const value_type* s) const;
+    int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
+
+    bool __invariants() const;
+};
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const basic_string<charT, traits, Allocator>& lhs,
+          const basic_string<charT, traits, Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
+
+template<class charT, class traits, class Allocator>
+basic_string<charT, traits, Allocator>
+operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs);
+
+template<class charT, class traits, class Allocator>
+bool operator==(const basic_string<charT, traits, Allocator>& lhs,
+                const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+                const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator< (const basic_string<charT, traits, Allocator>& lhs,
+                const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator> (const basic_string<charT, traits, Allocator>& lhs,
+                const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator<=(const basic_string<charT, traits, Allocator>& lhs,
+                const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator>=(const basic_string<charT, traits, Allocator>& lhs,
+                const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept;
+
+template<class charT, class traits, class Allocator>
+void swap(basic_string<charT, traits, Allocator>& lhs,
+          basic_string<charT, traits, Allocator>& rhs)
+            noexcept(noexcept(lhs.swap(rhs)));
+
+template<class charT, class traits, class Allocator>
+basic_istream<charT, traits>&
+operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
+
+template<class charT, class traits, class Allocator>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str);
+
+template<class charT, class traits, class Allocator>
+basic_istream<charT, traits>&
+getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str,
+        charT delim);
+
+template<class charT, class traits, class Allocator>
+basic_istream<charT, traits>&
+getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
+
+typedef basic_string<char>    string;
+typedef basic_string<wchar_t> wstring;
+typedef basic_string<char16_t> u16string;
+typedef basic_string<char32_t> u32string;
+
+int                stoi  (const string& str, size_t* idx = 0, int base = 10);
+long               stol  (const string& str, size_t* idx = 0, int base = 10);
+unsigned long      stoul (const string& str, size_t* idx = 0, int base = 10);
+long long          stoll (const string& str, size_t* idx = 0, int base = 10);
+unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10);
+
+float       stof (const string& str, size_t* idx = 0);
+double      stod (const string& str, size_t* idx = 0);
+long double stold(const string& str, size_t* idx = 0);
+
+string to_string(int val);
+string to_string(unsigned val);
+string to_string(long val);
+string to_string(unsigned long val);
+string to_string(long long val);
+string to_string(unsigned long long val);
+string to_string(float val);
+string to_string(double val);
+string to_string(long double val);
+
+int                stoi  (const wstring& str, size_t* idx = 0, int base = 10);
+long               stol  (const wstring& str, size_t* idx = 0, int base = 10);
+unsigned long      stoul (const wstring& str, size_t* idx = 0, int base = 10);
+long long          stoll (const wstring& str, size_t* idx = 0, int base = 10);
+unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10);
+
+float       stof (const wstring& str, size_t* idx = 0);
+double      stod (const wstring& str, size_t* idx = 0);
+long double stold(const wstring& str, size_t* idx = 0);
+
+wstring to_wstring(int val);
+wstring to_wstring(unsigned val);
+wstring to_wstring(long val);
+wstring to_wstring(unsigned long val);
+wstring to_wstring(long long val);
+wstring to_wstring(unsigned long long val);
+wstring to_wstring(float val);
+wstring to_wstring(double val);
+wstring to_wstring(long double val);
+
+template <> struct hash<string>;
+template <> struct hash<u16string>;
+template <> struct hash<u32string>;
+template <> struct hash<wstring>;
+
+basic_string<char>     operator "" s( const char *str,     size_t len ); // C++14
+basic_string<wchar_t>  operator "" s( const wchar_t *str,  size_t len ); // C++14
+basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14
+basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14
+
+}  // std
+
+*/
+
+#include <__config>
+#include <iosfwd>
+#include <cstring>
+#include <cstdio>  // For EOF.
+#include <cwchar>
+#include <algorithm>
+#include <iterator>
+#include <utility>
+#include <memory>
+#include <stdexcept>
+#include <type_traits>
+#include <initializer_list>
+#include <__functional_base>
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#include <cstdint>
+#endif
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+#include <cassert>
+#endif
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// fpos
+
+template <class _StateT>
+class _LIBCPP_TYPE_VIS_ONLY fpos
+{
+private:
+    _StateT __st_;
+    streamoff __off_;
+public:
+    _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {}
+
+    _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;}
+
+    _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;}
+    _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;}
+
+    _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;}
+    _LIBCPP_INLINE_VISIBILITY fpos  operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;}
+    _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;}
+    _LIBCPP_INLINE_VISIBILITY fpos  operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;}
+};
+
+template <class _StateT>
+inline _LIBCPP_INLINE_VISIBILITY
+streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
+    {return streamoff(__x) - streamoff(__y);}
+
+template <class _StateT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
+    {return streamoff(__x) == streamoff(__y);}
+
+template <class _StateT>
+inline _LIBCPP_INLINE_VISIBILITY
+bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
+    {return streamoff(__x) != streamoff(__y);}
+
+// char_traits
+
+template <class _CharT>
+struct _LIBCPP_TYPE_VIS_ONLY char_traits
+{
+    typedef _CharT    char_type;
+    typedef int       int_type;
+    typedef streamoff off_type;
+    typedef streampos pos_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
+        {__c1 = __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 < __c2;}
+
+    static int              compare(const char_type* __s1, const char_type* __s2, size_t __n);
+    static size_t           length(const char_type* __s);
+    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);
+    static char_type*       copy(char_type* __s1, const char_type* __s2, size_t __n);
+    static char_type*       assign(char_type* __s, size_t __n, char_type __a);
+
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
+        {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+        {return char_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  to_int_type(char_type __c) _NOEXCEPT
+        {return int_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool      eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  eof() _NOEXCEPT
+        {return int_type(EOF);}
+};
+
+template <class _CharT>
+int
+char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+{
+    for (; __n; --__n, ++__s1, ++__s2)
+    {
+        if (lt(*__s1, *__s2))
+            return -1;
+        if (lt(*__s2, *__s1))
+            return 1;
+    }
+    return 0;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+char_traits<_CharT>::length(const char_type* __s)
+{
+    size_t __len = 0;
+    for (; !eq(*__s, char_type(0)); ++__s)
+        ++__len;
+    return __len;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+const _CharT*
+char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
+{
+    for (; __n; --__n)
+    {
+        if (eq(*__s, __a))
+            return __s;
+        ++__s;
+    }
+    return 0;
+}
+
+template <class _CharT>
+_CharT*
+char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    char_type* __r = __s1;
+    if (__s1 < __s2)
+    {
+        for (; __n; --__n, ++__s1, ++__s2)
+            assign(*__s1, *__s2);
+    }
+    else if (__s2 < __s1)
+    {
+        __s1 += __n;
+        __s2 += __n;
+        for (; __n; --__n)
+            assign(*--__s1, *--__s2);
+    }
+    return __r;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT*
+char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+    char_type* __r = __s1;
+    for (; __n; --__n, ++__s1, ++__s2)
+        assign(*__s1, *__s2);
+    return __r;
+}
+
+template <class _CharT>
+inline _LIBCPP_INLINE_VISIBILITY
+_CharT*
+char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
+{
+    char_type* __r = __s;
+    for (; __n; --__n, ++__s)
+        assign(*__s, __a);
+    return __r;
+}
+
+// char_traits<char>
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY char_traits<char>
+{
+    typedef char      char_type;
+    typedef int       int_type;
+    typedef streamoff off_type;
+    typedef streampos pos_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
+        {__c1 = __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+            {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+        {return (unsigned char)__c1 < (unsigned char)__c2;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    static int compare(const char_type* __s1, const char_type* __s2, size_t __n)
+        {return memcmp(__s1, __s2, __n);}
+    _LIBCPP_INLINE_VISIBILITY
+    static size_t length(const char_type* __s) {return strlen(__s);}
+    _LIBCPP_INLINE_VISIBILITY
+    static 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);}
+    _LIBCPP_INLINE_VISIBILITY
+    static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
+        {return (char_type*)memmove(__s1, __s2, __n);}
+    _LIBCPP_INLINE_VISIBILITY
+    static 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);
+        }
+    _LIBCPP_INLINE_VISIBILITY
+    static char_type* assign(char_type* __s, size_t __n, char_type __a)
+        {return (char_type*)memset(__s, to_int_type(__a), __n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
+        {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+        {return char_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+        {return int_type((unsigned char)__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  eof() _NOEXCEPT
+        {return int_type(EOF);}
+};
+
+// char_traits<wchar_t>
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t>
+{
+    typedef wchar_t   char_type;
+    typedef wint_t    int_type;
+    typedef streamoff off_type;
+    typedef streampos pos_type;
+    typedef mbstate_t state_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
+        {__c1 = __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _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)
+        {return wmemcmp(__s1, __s2, __n);}
+    _LIBCPP_INLINE_VISIBILITY
+    static size_t length(const char_type* __s)
+        {return wcslen(__s);}
+    _LIBCPP_INLINE_VISIBILITY
+    static const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
+        {return (const char_type*)wmemchr(__s, __a, __n);}
+    _LIBCPP_INLINE_VISIBILITY
+    static char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
+        {return (char_type*)wmemmove(__s1, __s2, __n);}
+    _LIBCPP_INLINE_VISIBILITY
+    static 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);
+        }
+    _LIBCPP_INLINE_VISIBILITY
+    static char_type* assign(char_type* __s, size_t __n, char_type __a)
+        {return (char_type*)wmemset(__s, __a, __n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
+        {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+        {return char_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+        {return int_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+        {return int_type(WEOF);}
+};
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
+{
+    typedef char16_t       char_type;
+    typedef uint_least16_t int_type;
+    typedef streamoff      off_type;
+    typedef u16streampos   pos_type;
+    typedef mbstate_t      state_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
+        {__c1 = __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 < __c2;}
+
+    static int              compare(const char_type* __s1, const char_type* __s2, size_t __n);
+    static size_t           length(const char_type* __s);
+    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);
+    static char_type*       copy(char_type* __s1, const char_type* __s2, size_t __n);
+    static char_type*       assign(char_type* __s, size_t __n, char_type __a);
+
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
+        {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+        {return char_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+        {return int_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+        {return int_type(0xDFFF);}
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+{
+    for (; __n; --__n, ++__s1, ++__s2)
+    {
+        if (lt(*__s1, *__s2))
+            return -1;
+        if (lt(*__s2, *__s1))
+            return 1;
+    }
+    return 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+char_traits<char16_t>::length(const char_type* __s)
+{
+    size_t __len = 0;
+    for (; !eq(*__s, char_type(0)); ++__s)
+        ++__len;
+    return __len;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+const char16_t*
+char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a)
+{
+    for (; __n; --__n)
+    {
+        if (eq(*__s, __a))
+            return __s;
+        ++__s;
+    }
+    return 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t*
+char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    char_type* __r = __s1;
+    if (__s1 < __s2)
+    {
+        for (; __n; --__n, ++__s1, ++__s2)
+            assign(*__s1, *__s2);
+    }
+    else if (__s2 < __s1)
+    {
+        __s1 += __n;
+        __s2 += __n;
+        for (; __n; --__n)
+            assign(*--__s1, *--__s2);
+    }
+    return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t*
+char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+    char_type* __r = __s1;
+    for (; __n; --__n, ++__s1, ++__s2)
+        assign(*__s1, *__s2);
+    return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char16_t*
+char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a)
+{
+    char_type* __r = __s;
+    for (; __n; --__n, ++__s)
+        assign(*__s, __a);
+    return __r;
+}
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
+{
+    typedef char32_t       char_type;
+    typedef uint_least32_t int_type;
+    typedef streamoff      off_type;
+    typedef u32streampos   pos_type;
+    typedef mbstate_t      state_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
+        {__c1 = __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 < __c2;}
+
+    static int              compare(const char_type* __s1, const char_type* __s2, size_t __n);
+    static size_t           length(const char_type* __s);
+    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);
+    static char_type*       copy(char_type* __s1, const char_type* __s2, size_t __n);
+    static char_type*       assign(char_type* __s, size_t __n, char_type __a);
+
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
+        {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+        {return char_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
+        {return int_type(__c);}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+    _LIBCPP_INLINE_VISIBILITY
+    static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
+        {return int_type(0xFFFFFFFF);}
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+{
+    for (; __n; --__n, ++__s1, ++__s2)
+    {
+        if (lt(*__s1, *__s2))
+            return -1;
+        if (lt(*__s2, *__s1))
+            return 1;
+    }
+    return 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+size_t
+char_traits<char32_t>::length(const char_type* __s)
+{
+    size_t __len = 0;
+    for (; !eq(*__s, char_type(0)); ++__s)
+        ++__len;
+    return __len;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+const char32_t*
+char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a)
+{
+    for (; __n; --__n)
+    {
+        if (eq(*__s, __a))
+            return __s;
+        ++__s;
+    }
+    return 0;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t*
+char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    char_type* __r = __s1;
+    if (__s1 < __s2)
+    {
+        for (; __n; --__n, ++__s1, ++__s2)
+            assign(*__s1, *__s2);
+    }
+    else if (__s2 < __s1)
+    {
+        __s1 += __n;
+        __s2 += __n;
+        for (; __n; --__n)
+            assign(*--__s1, *--__s2);
+    }
+    return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t*
+char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+    char_type* __r = __s1;
+    for (; __n; --__n, ++__s1, ++__s2)
+        assign(*__s1, *__s2);
+    return __r;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+char32_t*
+char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a)
+{
+    char_type* __r = __s;
+    for (; __n; --__n, ++__s)
+        assign(*__s, __a);
+    return __r;
+}
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+// helper fns for basic_string
+
+// __str_find
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find(const _CharT *__p, _SizeT __sz, 
+             _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+    if (__pos >= __sz)
+        return __npos;
+    const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
+    if (__r == 0)
+        return __npos;
+    return static_cast<_SizeT>(__r - __p);
+}
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find(const _CharT *__p, _SizeT __sz, 
+       const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+{
+    if (__pos > __sz || __sz - __pos < __n)
+        return __npos;
+    if (__n == 0)
+        return __pos;
+    const _CharT* __r = 
+        _VSTD::__search(__p + __pos, __p + __sz,
+                        __s, __s + __n, _Traits::eq,
+                        random_access_iterator_tag(), random_access_iterator_tag());
+    if (__r == __p + __sz)
+        return __npos;
+    return static_cast<_SizeT>(__r - __p);
+}
+
+
+// __str_rfind
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_rfind(const _CharT *__p, _SizeT __sz, 
+              _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+    if (__sz < 1)
+        return __npos;
+    if (__pos < __sz)
+        ++__pos;
+    else
+        __pos = __sz;
+    for (const _CharT* __ps = __p + __pos; __ps != __p;)
+    {
+        if (_Traits::eq(*--__ps, __c))
+            return static_cast<_SizeT>(__ps - __p);
+    }
+    return __npos;
+}
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_rfind(const _CharT *__p, _SizeT __sz, 
+        const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
+{
+    __pos = _VSTD::min(__pos, __sz);
+    if (__n < __sz - __pos)
+        __pos += __n;
+    else
+        __pos = __sz;
+    const _CharT* __r = _VSTD::__find_end(
+                  __p, __p + __pos, __s, __s + __n, _Traits::eq, 
+                        random_access_iterator_tag(), random_access_iterator_tag());
+    if (__n > 0 && __r == __p + __pos)
+        return __npos;
+    return static_cast<_SizeT>(__r - __p);
+}
+
+// __str_find_first_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_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
+{
+    if (__pos >= __sz || __n == 0)
+        return __npos;
+    const _CharT* __r = _VSTD::__find_first_of_ce
+        (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq );
+    if (__r == __p + __sz)
+        return __npos;
+    return static_cast<_SizeT>(__r - __p);
+}
+
+
+// __str_find_last_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_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
+    {
+    if (__n != 0)
+    {
+        if (__pos < __sz)
+            ++__pos;
+        else
+            __pos = __sz;
+        for (const _CharT* __ps = __p + __pos; __ps != __p;)
+        {
+            const _CharT* __r = _Traits::find(__s, __n, *--__ps);
+            if (__r)
+                return static_cast<_SizeT>(__ps - __p);
+        }
+    }
+    return __npos;
+}
+
+
+// __str_find_first_not_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_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
+{
+    if (__pos < __sz)
+    {
+        const _CharT* __pe = __p + __sz;
+        for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
+            if (_Traits::find(__s, __n, *__ps) == 0)
+                return static_cast<_SizeT>(__ps - __p);
+    }
+    return __npos;
+}
+
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
+                          _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+    if (__pos < __sz)
+    {
+        const _CharT* __pe = __p + __sz;
+        for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
+            if (!_Traits::eq(*__ps, __c))
+                return static_cast<_SizeT>(__ps - __p);
+    }
+    return __npos;
+}
+
+
+// __str_find_last_not_of
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_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
+{
+    if (__pos < __sz)
+        ++__pos;
+    else
+        __pos = __sz;
+    for (const _CharT* __ps = __p + __pos; __ps != __p;)
+        if (_Traits::find(__s, __n, *--__ps) == 0)
+            return static_cast<_SizeT>(__ps - __p);
+    return __npos;
+}
+
+
+template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
+_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
+__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
+                         _CharT __c, _SizeT __pos) _NOEXCEPT
+{
+    if (__pos < __sz)
+        ++__pos;
+    else
+        __pos = __sz;
+    for (const _CharT* __ps = __p + __pos; __ps != __p;)
+        if (!_Traits::eq(*--__ps, __c))
+            return static_cast<_SizeT>(__ps - __p);
+    return __npos;
+}
+
+template<class _Ptr>
+size_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e)
+{
+    typedef typename iterator_traits<_Ptr>::value_type value_type;
+    return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type));
+}
+
+// basic_string
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __x,
+          const basic_string<_CharT, _Traits, _Allocator>& __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
+
+template <bool>
+class _LIBCPP_TYPE_VIS_ONLY __basic_string_common
+{
+protected:
+    void __throw_length_error() const;
+    void __throw_out_of_range() const;
+};
+
+template <bool __b>
+void
+__basic_string_common<__b>::__throw_length_error() const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw length_error("basic_string");
+#else
+    assert(!"basic_string length_error");
+#endif
+}
+
+template <bool __b>
+void
+__basic_string_common<__b>::__throw_out_of_range() const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw out_of_range("basic_string");
+#else
+    assert(!"basic_string out_of_range");
+#endif
+}
+
+#ifdef _LIBCPP_MSVC
+#pragma warning( push )
+#pragma warning( disable: 4231 )
+#endif // _LIBCPP_MSVC
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common<true>)
+#ifdef _LIBCPP_MSVC
+#pragma warning( pop )
+#endif // _LIBCPP_MSVC
+
+#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+
+template <class _CharT, size_t = sizeof(_CharT)>
+struct __padding
+{
+    unsigned char __xx[sizeof(_CharT)-1];
+};
+
+template <class _CharT>
+struct __padding<_CharT, 1>
+{
+};
+
+#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+
+template<class _CharT, class _Traits, class _Allocator>
+class _LIBCPP_TYPE_VIS_ONLY basic_string
+    : private __basic_string_common<true>
+{
+public:
+    typedef basic_string                                 __self;
+    typedef _Traits                                      traits_type;
+    typedef typename traits_type::char_type              value_type;
+    typedef _Allocator                                   allocator_type;
+    typedef allocator_traits<allocator_type>             __alloc_traits;
+    typedef typename __alloc_traits::size_type           size_type;
+    typedef typename __alloc_traits::difference_type     difference_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;
+
+    static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD");
+    static_assert((is_same<_CharT, value_type>::value),
+                  "traits_type::char_type must be the same type as CharT");
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+#if defined(_LIBCPP_RAW_ITERATORS)
+    typedef pointer                                      iterator;
+    typedef const_pointer                                const_iterator;
+#else  // defined(_LIBCPP_RAW_ITERATORS)
+    typedef __wrap_iter<pointer>                         iterator;
+    typedef __wrap_iter<const_pointer>                   const_iterator;
+#endif  // defined(_LIBCPP_RAW_ITERATORS)
+    typedef _VSTD::reverse_iterator<iterator>             reverse_iterator;
+    typedef _VSTD::reverse_iterator<const_iterator>       const_reverse_iterator;
+
+private:
+
+#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+
+    struct __long
+    {
+        pointer   __data_;
+        size_type __size_;
+        size_type __cap_;
+    };
+
+#if _LIBCPP_BIG_ENDIAN
+    enum {__short_mask = 0x01};
+    enum {__long_mask  = 0x1ul};
+#else  // _LIBCPP_BIG_ENDIAN
+    enum {__short_mask = 0x80};
+    enum {__long_mask  = ~(size_type(~0) >> 1)};
+#endif  // _LIBCPP_BIG_ENDIAN
+
+    enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
+                      (sizeof(__long) - 1)/sizeof(value_type) : 2};
+
+    struct __short
+    {
+        value_type __data_[__min_cap];
+        struct
+            : __padding<value_type>
+        {
+            unsigned char __size_;
+        };
+    };
+
+#else
+
+    struct __long
+    {
+        size_type __cap_;
+        size_type __size_;
+        pointer   __data_;
+    };
+
+#if _LIBCPP_BIG_ENDIAN
+    enum {__short_mask = 0x80};
+    enum {__long_mask  = ~(size_type(~0) >> 1)};
+#else  // _LIBCPP_BIG_ENDIAN
+    enum {__short_mask = 0x01};
+    enum {__long_mask  = 0x1ul};
+#endif  // _LIBCPP_BIG_ENDIAN
+
+    enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
+                      (sizeof(__long) - 1)/sizeof(value_type) : 2};
+
+    struct __short
+    {
+        union
+        {
+            unsigned char __size_;
+            value_type __lx;
+        };
+        value_type __data_[__min_cap];
+    };
+
+#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+
+    union __ulx{__long __lx; __short __lxx;};
+
+    enum {__n_words = sizeof(__ulx) / sizeof(size_type)};
+
+    struct __raw
+    {
+        size_type __words[__n_words];
+    };
+
+    struct __rep
+    {
+        union
+        {
+            __long  __l;
+            __short __s;
+            __raw   __r;
+        };
+    };
+
+    __compressed_pair<__rep, allocator_type> __r_;
+
+public:
+    static const size_type npos = -1;
+
+    _LIBCPP_INLINE_VISIBILITY basic_string()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+    _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a);
+    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)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string(basic_string&& __str, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string(const value_type* __s, const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string(const value_type* __s, size_type __n);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string(const value_type* __s, size_type __n, const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
+    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,
+                 const allocator_type& __a = allocator_type());
+    template<class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        basic_string(_InputIterator __first, _InputIterator __last);
+    template<class _InputIterator>
+        _LIBCPP_INLINE_VISIBILITY
+        basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string(initializer_list<value_type> __il);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string(initializer_list<value_type> __il, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    ~basic_string();
+
+    basic_string& operator=(const basic_string& __str);
+#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);
+#endif
+    _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
+    basic_string& operator=(value_type __c);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    iterator begin() _NOEXCEPT
+        {return iterator(this, __get_pointer());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT
+        {return const_iterator(this, __get_pointer());}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator end() _NOEXCEPT
+        {return iterator(this, __get_pointer() + size());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT
+        {return const_iterator(this, __get_pointer() + size());}
+#else
+    _LIBCPP_INLINE_VISIBILITY
+    iterator begin() _NOEXCEPT
+        {return iterator(__get_pointer());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT
+        {return const_iterator(__get_pointer());}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator end() _NOEXCEPT
+        {return iterator(__get_pointer() + size());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end() const _NOEXCEPT
+        {return const_iterator(__get_pointer() + size());}
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rbegin() _NOEXCEPT
+        {return reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rend() _NOEXCEPT
+        {return reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend() const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT
+        {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend() const _NOEXCEPT
+        {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT
+        {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend() const _NOEXCEPT
+        {return rend();}
+
+    _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT
+        {return __is_long() ? __get_long_size() : __get_short_size();}
+    _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;}
+
+    void resize(size_type __n, value_type __c);
+    _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());}
+
+    void reserve(size_type res_arg = 0);
+    _LIBCPP_INLINE_VISIBILITY
+    void shrink_to_fit() _NOEXCEPT {reserve();}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return size() == 0;}
+
+    _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const;
+    _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __pos);
+
+    const_reference at(size_type __n) const;
+    reference       at(size_type __n);
+
+    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);}
+    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s)         {return append(__s);}
+    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c)            {push_back(__c); return *this;}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& append(const basic_string& __str);
+    basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos);
+    basic_string& append(const value_type* __s, size_type __n);
+    basic_string& append(const value_type* __s);
+    basic_string& append(size_type __n, value_type __c);
+    template<class _InputIterator>
+        typename enable_if
+        <
+             __is_input_iterator  <_InputIterator>::value &&
+            !__is_forward_iterator<_InputIterator>::value,
+            basic_string&
+        >::type
+        append(_InputIterator __first, _InputIterator __last);
+    template<class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            basic_string&
+        >::type
+        append(_ForwardIterator __first, _ForwardIterator __last);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    void push_back(value_type __c);
+    _LIBCPP_INLINE_VISIBILITY
+    void pop_back();
+    _LIBCPP_INLINE_VISIBILITY reference       front();
+    _LIBCPP_INLINE_VISIBILITY const_reference front() const;
+    _LIBCPP_INLINE_VISIBILITY reference       back();
+    _LIBCPP_INLINE_VISIBILITY const_reference back() const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& assign(const basic_string& __str);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& assign(basic_string&& str)
+        {*this = _VSTD::move(str); return *this;}
+#endif
+    basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos);
+    basic_string& assign(const value_type* __s, size_type __n);
+    basic_string& assign(const value_type* __s);
+    basic_string& assign(size_type __n, value_type __c);
+    template<class _InputIterator>
+        typename enable_if
+        <
+             __is_input_iterator  <_InputIterator>::value &&
+            !__is_forward_iterator<_InputIterator>::value,
+            basic_string&
+        >::type
+        assign(_InputIterator __first, _InputIterator __last);
+    template<class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            basic_string&
+        >::type
+        assign(_ForwardIterator __first, _ForwardIterator __last);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& insert(size_type __pos1, const basic_string& __str);
+    basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos);
+    basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
+    basic_string& insert(size_type __pos, const value_type* __s);
+    basic_string& insert(size_type __pos, size_type __n, value_type __c);
+    iterator      insert(const_iterator __pos, value_type __c);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator      insert(const_iterator __pos, size_type __n, value_type __c);
+    template<class _InputIterator>
+        typename enable_if
+        <
+             __is_input_iterator  <_InputIterator>::value &&
+            !__is_forward_iterator<_InputIterator>::value,
+            iterator
+        >::type
+        insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);
+    template<class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            iterator
+        >::type
+        insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __pos, initializer_list<value_type> __il)
+                    {return insert(__pos, __il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    basic_string& erase(size_type __pos = 0, size_type __n = npos);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator      erase(const_iterator __pos);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator      erase(const_iterator __first, const_iterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str);
+    basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos);
+    basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
+    basic_string& replace(size_type __pos, size_type __n1, const value_type* __s);
+    basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s);
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c);
+    template<class _InputIterator>
+        typename enable_if
+        <
+            __is_input_iterator<_InputIterator>::value,
+            basic_string&
+        >::type
+        replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il)
+        {return replace(__i1, __i2, __il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const;
+    _LIBCPP_INLINE_VISIBILITY
+    basic_string substr(size_type __pos = 0, size_type __n = npos) const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(basic_string& __str)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<allocator_type>::value);
+
+    _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());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT {return __alloc();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
+    size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
+    size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
+    size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
+    size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
+    size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
+    size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;
+    size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
+    size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    int compare(const basic_string& __str) const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    int compare(size_type __pos1, size_type __n1, const basic_string& __str) const;
+    int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const;
+    int compare(const value_type* __s) const _NOEXCEPT;
+    int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
+    int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
+
+    _LIBCPP_INLINE_VISIBILITY bool __invariants() const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool __is_long() const _NOEXCEPT
+        {return bool(__r_.first().__s.__size_ & __short_mask);}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const;
+    bool __decrementable(const const_iterator* __i) const;
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type& __alloc() _NOEXCEPT
+        {return __r_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const allocator_type& __alloc() const _NOEXCEPT
+        {return __r_.second();}
+
+#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_short_size(size_type __s) _NOEXCEPT
+#   if _LIBCPP_BIG_ENDIAN
+        {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
+#   else
+        {__r_.first().__s.__size_ = (unsigned char)(__s);}
+#   endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type __get_short_size() const _NOEXCEPT
+#   if _LIBCPP_BIG_ENDIAN
+        {return __r_.first().__s.__size_ >> 1;}
+#   else
+        {return __r_.first().__s.__size_;}
+#   endif
+
+#else  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_short_size(size_type __s) _NOEXCEPT
+#   if _LIBCPP_BIG_ENDIAN
+        {__r_.first().__s.__size_ = (unsigned char)(__s);}
+#   else
+        {__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
+#   endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type __get_short_size() const _NOEXCEPT
+#   if _LIBCPP_BIG_ENDIAN
+        {return __r_.first().__s.__size_;}
+#   else
+        {return __r_.first().__s.__size_ >> 1;}
+#   endif
+
+#endif  // _LIBCPP_ALTERNATE_STRING_LAYOUT
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_long_size(size_type __s) _NOEXCEPT
+        {__r_.first().__l.__size_ = __s;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type __get_long_size() const _NOEXCEPT
+        {return __r_.first().__l.__size_;}
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_size(size_type __s) _NOEXCEPT
+        {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_long_cap(size_type __s) _NOEXCEPT
+        {__r_.first().__l.__cap_  = __long_mask | __s;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type __get_long_cap() const _NOEXCEPT
+        {return __r_.first().__l.__cap_ & size_type(~__long_mask);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __set_long_pointer(pointer __p) _NOEXCEPT
+        {__r_.first().__l.__data_ = __p;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer __get_long_pointer() _NOEXCEPT
+        {return __r_.first().__l.__data_;}
+    _LIBCPP_INLINE_VISIBILITY
+    const_pointer __get_long_pointer() const _NOEXCEPT
+        {return __r_.first().__l.__data_;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer __get_short_pointer() _NOEXCEPT
+        {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_pointer __get_short_pointer() const _NOEXCEPT
+        {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer __get_pointer() _NOEXCEPT
+        {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_pointer __get_pointer() const _NOEXCEPT
+        {return __is_long() ? __get_long_pointer() : __get_short_pointer();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __zero() _NOEXCEPT
+        {
+            size_type (&__a)[__n_words] = __r_.first().__r.__words;
+            for (unsigned __i = 0; __i < __n_words; ++__i)
+                __a[__i] = 0;
+        }
+
+    template <size_type __a> static
+        _LIBCPP_INLINE_VISIBILITY
+        size_type __align_it(size_type __s) _NOEXCEPT
+            {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 :
+                 __align_it<sizeof(value_type) < __alignment ?
+                            __alignment/sizeof(value_type) : 1 > (__s+1)) - 1;}
+
+    void __init(const value_type* __s, size_type __sz, size_type __reserve);
+    void __init(const value_type* __s, size_type __sz);
+    void __init(size_type __n, value_type __c);
+
+    template <class _InputIterator>
+    typename enable_if
+    <
+         __is_input_iterator  <_InputIterator>::value &&
+        !__is_forward_iterator<_InputIterator>::value,
+        void
+    >::type
+    __init(_InputIterator __first, _InputIterator __last);
+
+    template <class _ForwardIterator>
+    typename enable_if
+    <
+        __is_forward_iterator<_ForwardIterator>::value,
+        void
+    >::type
+    __init(_ForwardIterator __first, _ForwardIterator __last);
+
+    void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+                   size_type __n_copy,  size_type __n_del,     size_type __n_add = 0);
+    void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+                               size_type __n_copy,  size_type __n_del,
+                               size_type __n_add, const value_type* __p_new_stuff);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __erase_to_end(size_type __pos);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const basic_string& __str)
+        {__copy_assign_alloc(__str, integral_constant<bool,
+                      __alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const basic_string& __str, true_type)
+        {
+            if (__alloc() != __str.__alloc())
+            {
+                clear();
+                shrink_to_fit();
+            }
+            __alloc() = __str.__alloc();
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT
+        {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign(basic_string& __str, false_type);
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign(basic_string& __str, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    void
+    __move_assign_alloc(basic_string& __str)
+        _NOEXCEPT_(
+            !__alloc_traits::propagate_on_container_move_assignment::value ||
+            is_nothrow_move_assignable<allocator_type>::value)
+    {__move_assign_alloc(__str, integral_constant<bool,
+                      __alloc_traits::propagate_on_container_move_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(basic_string& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+        {
+            __alloc() = _VSTD::move(__c.__alloc());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(basic_string&, 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
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
+    _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
+
+    friend basic_string operator+<>(const basic_string&, const basic_string&);
+    friend basic_string operator+<>(const value_type*, const basic_string&);
+    friend basic_string operator+<>(value_type, const basic_string&);
+    friend basic_string operator+<>(const basic_string&, const value_type*);
+    friend basic_string operator+<>(const basic_string&, value_type);
+};
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__invalidate_all(this);
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
+#if _LIBCPP_DEBUG_LEVEL >= 2
+                                                                        __pos
+#endif
+                                                                      )
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __c_node* __c = __get_db()->__find_c_and_lock(this);
+    if (__c)
+    {
+        const_pointer __new_last = __get_pointer() + __pos;
+        for (__i_node** __p = __c->end_; __p != __c->beg_; )
+        {
+            --__p;
+            const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
+            if (__i->base() > __new_last)
+            {
+                (*__p)->__c_ = nullptr;
+                if (--__c->end_ != __p)
+                    memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+            }
+        }
+        __get_db()->unlock();
+    }
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string()
+    _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __zero();
+}
+
+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_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __zero();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve)
+{
+    if (__reserve > max_size())
+        this->__throw_length_error();
+    pointer __p;
+    if (__reserve < __min_cap)
+    {
+        __set_short_size(__sz);
+        __p = __get_short_pointer();
+    }
+    else
+    {
+        size_type __cap = __recommend(__reserve);
+        __p = __alloc_traits::allocate(__alloc(), __cap+1);
+        __set_long_pointer(__p);
+        __set_long_cap(__cap+1);
+        __set_long_size(__sz);
+    }
+    traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz);
+    traits_type::assign(__p[__sz], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz)
+{
+    if (__sz > max_size())
+        this->__throw_length_error();
+    pointer __p;
+    if (__sz < __min_cap)
+    {
+        __set_short_size(__sz);
+        __p = __get_short_pointer();
+    }
+    else
+    {
+        size_type __cap = __recommend(__sz);
+        __p = __alloc_traits::allocate(__alloc(), __cap+1);
+        __set_long_pointer(__p);
+        __set_long_cap(__cap+1);
+        __set_long_size(__sz);
+    }
+    traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz);
+    traits_type::assign(__p[__sz], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s)
+{
+    _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
+    __init(__s, traits_type::length(__s));
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, const allocator_type& __a)
+    : __r_(__a)
+{
+    _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
+    __init(__s, traits_type::length(__s));
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n)
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
+    __init(__s, __n);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n, const allocator_type& __a)
+    : __r_(__a)
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
+    __init(__s, __n);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str)
+    : __r_(__alloc_traits::select_on_container_copy_construction(__str.__alloc()))
+{
+    if (!__str.__is_long())
+        __r_.first().__r = __str.__r_.first().__r;
+    else
+        __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, const allocator_type& __a)
+    : __r_(__a)
+{
+    if (!__str.__is_long())
+        __r_.first().__r = __str.__r_.first().__r;
+    else
+        __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+    : __r_(_VSTD::move(__str.__r_))
+{
+    __str.__zero();
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+    if (__is_long())
+        __get_db()->swap(this, &__str);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a)
+    : __r_(__a)
+{
+    if (__str.__is_long() && __a != __str.__alloc()) // copy, not move
+        __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size());
+    else
+    {
+        __r_.first().__r = __str.__r_.first().__r;
+        __str.__zero();
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+    if (__is_long())
+        __get_db()->swap(this, &__str);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c)
+{
+    if (__n > max_size())
+        this->__throw_length_error();
+    pointer __p;
+    if (__n < __min_cap)
+    {
+        __set_short_size(__n);
+        __p = __get_short_pointer();
+    }
+    else
+    {
+        size_type __cap = __recommend(__n);
+        __p = __alloc_traits::allocate(__alloc(), __cap+1);
+        __set_long_pointer(__p);
+        __set_long_cap(__cap+1);
+        __set_long_size(__n);
+    }
+    traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c);
+    traits_type::assign(__p[__n], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c)
+{
+    __init(__n, __c);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c, const allocator_type& __a)
+    : __r_(__a)
+{
+    __init(__n, __c);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, size_type __n,
+                                                        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, _VSTD::min(__n, __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,
+    void
+>::type
+basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last)
+{
+    __zero();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    for (; __first != __last; ++__first)
+        push_back(*__first);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        if (__is_long())
+            __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    void
+>::type
+basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last)
+{
+    size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__sz > max_size())
+        this->__throw_length_error();
+    pointer __p;
+    if (__sz < __min_cap)
+    {
+        __set_short_size(__sz);
+        __p = __get_short_pointer();
+    }
+    else
+    {
+        size_type __cap = __recommend(__sz);
+        __p = __alloc_traits::allocate(__alloc(), __cap+1);
+        __set_long_pointer(__p);
+        __set_long_cap(__cap+1);
+        __set_long_size(__sz);
+    }
+    for (; __first != __last; ++__first, ++__p)
+        traits_type::assign(*__p, *__first);
+    traits_type::assign(*__p, value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last)
+{
+    __init(__first, __last);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last,
+                                                        const allocator_type& __a)
+    : __r_(__a)
+{
+    __init(__first, __last);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il)
+{
+    __init(__il.begin(), __il.end());
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il, const allocator_type& __a)
+    : __r_(__a)
+{
+    __init(__il.begin(), __il.end());
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::~basic_string()
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__erase_c(this);
+#endif
+    if (__is_long())
+        __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
+    (size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+     size_type __n_copy,  size_type __n_del,     size_type __n_add, const value_type* __p_new_stuff)
+{
+    size_type __ms = max_size();
+    if (__delta_cap > __ms - __old_cap - 1)
+        this->__throw_length_error();
+    pointer __old_p = __get_pointer();
+    size_type __cap = __old_cap < __ms / 2 - __alignment ?
+                          __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
+                          __ms - 1;
+    pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
+    __invalidate_all_iterators();
+    if (__n_copy != 0)
+        traits_type::copy(_VSTD::__to_raw_pointer(__p),
+                          _VSTD::__to_raw_pointer(__old_p), __n_copy);
+    if (__n_add != 0)
+        traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add);
+    size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
+    if (__sec_cp_sz != 0)
+        traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add,
+                          _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz);
+    if (__old_cap+1 != __min_cap)
+        __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
+    __set_long_pointer(__p);
+    __set_long_cap(__cap+1);
+    __old_sz = __n_copy + __n_add + __sec_cp_sz;
+    __set_long_size(__old_sz);
+    traits_type::assign(__p[__old_sz], value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz,
+                                                     size_type __n_copy,  size_type __n_del,     size_type __n_add)
+{
+    size_type __ms = max_size();
+    if (__delta_cap > __ms - __old_cap)
+        this->__throw_length_error();
+    pointer __old_p = __get_pointer();
+    size_type __cap = __old_cap < __ms / 2 - __alignment ?
+                          __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) :
+                          __ms - 1;
+    pointer __p = __alloc_traits::allocate(__alloc(), __cap+1);
+    __invalidate_all_iterators();
+    if (__n_copy != 0)
+        traits_type::copy(_VSTD::__to_raw_pointer(__p),
+                          _VSTD::__to_raw_pointer(__old_p), __n_copy);
+    size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
+    if (__sec_cp_sz != 0)
+        traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add,
+                          _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del,
+                          __sec_cp_sz);
+    if (__old_cap+1 != __min_cap)
+        __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1);
+    __set_long_pointer(__p);
+    __set_long_cap(__cap+1);
+}
+
+// assign
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n)
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr");
+    size_type __cap = capacity();
+    if (__cap >= __n)
+    {
+        value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+        traits_type::move(__p, __s, __n);
+        traits_type::assign(__p[__n], value_type());
+        __set_size(__n);
+        __invalidate_iterators_past(__n);
+    }
+    else
+    {
+        size_type __sz = size();
+        __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s);
+    }
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
+{
+    size_type __cap = capacity();
+    if (__cap < __n)
+    {
+        size_type __sz = size();
+        __grow_by(__cap, __n - __cap, __sz, 0, __sz);
+    }
+    else
+        __invalidate_iterators_past(__n);
+    value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+    traits_type::assign(__p, __n, __c);
+    traits_type::assign(__p[__n], value_type());
+    __set_size(__n);
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c)
+{
+    pointer __p;
+    if (__is_long())
+    {
+        __p = __get_long_pointer();
+        __set_long_size(1);
+    }
+    else
+    {
+        __p = __get_short_pointer();
+        __set_short_size(1);
+    }
+    traits_type::assign(*__p, __c);
+    traits_type::assign(*++__p, value_type());
+    __invalidate_iterators_past(1);
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
+{
+    if (this != &__str)
+    {
+        __copy_assign_alloc(__str);
+        assign(__str);
+    }
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
+{
+    if (__alloc() != __str.__alloc())
+        assign(__str);
+    else
+        __move_assign(__str, true_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
+    _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+    clear();
+    shrink_to_fit();
+    __r_.first() = __str.__r_.first();
+    __move_assign_alloc(__str);
+    __str.__zero();
+}
+
+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)
+{
+    __move_assign(__str, integral_constant<bool,
+          __alloc_traits::propagate_on_container_move_assignment::value>());
+    return *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,
+    basic_string<_CharT, _Traits, _Allocator>&
+>::type
+basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
+{
+    clear();
+    for (; __first != __last; ++__first)
+        push_back(*__first);
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    basic_string<_CharT, _Traits, _Allocator>&
+>::type
+basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
+{
+    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+    size_type __cap = capacity();
+    if (__cap < __n)
+    {
+        size_type __sz = size();
+        __grow_by(__cap, __n - __cap, __sz, 0, __sz);
+    }
+    else
+        __invalidate_iterators_past(__n);
+    pointer __p = __get_pointer();
+    for (; __first != __last; ++__first, ++__p)
+        traits_type::assign(*__p, *__first);
+    traits_type::assign(*__p, value_type());
+    __set_size(__n);
+    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)
+{
+    size_type __sz = __str.size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s)
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr");
+    return assign(__s, traits_type::length(__s));
+}
+
+// append
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n)
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr");
+    size_type __cap = capacity();
+    size_type __sz = size();
+    if (__cap - __sz >= __n)
+    {
+        if (__n)
+        {
+            value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+            traits_type::copy(__p + __sz, __s, __n);
+            __sz += __n;
+            __set_size(__sz);
+            traits_type::assign(__p[__sz], value_type());
+        }
+    }
+    else
+        __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s);
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
+{
+    if (__n)
+    {
+        size_type __cap = capacity();
+        size_type __sz = size();
+        if (__cap - __sz < __n)
+            __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
+        pointer __p = __get_pointer();
+        traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c);
+        __sz += __n;
+        __set_size(__sz);
+        traits_type::assign(__p[__sz], value_type());
+    }
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c)
+{
+    bool __is_short = !__is_long();
+    size_type __cap;
+    size_type __sz;
+    if (__is_short)
+    {
+        __cap = __min_cap - 1;
+        __sz = __get_short_size();
+    }
+    else
+    {
+        __cap = __get_long_cap() - 1;
+        __sz = __get_long_size();
+    }
+    if (__sz == __cap)
+    {
+        __grow_by(__cap, 1, __sz, __sz, 0);
+        __is_short = !__is_long();
+    }
+    pointer __p;
+    if (__is_short)
+    {
+        __p = __get_short_pointer() + __sz;
+        __set_short_size(__sz+1);
+    }
+    else
+    {
+        __p = __get_long_pointer() + __sz;
+        __set_long_size(__sz+1);
+    }
+    traits_type::assign(*__p, __c);
+    traits_type::assign(*++__p, value_type());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator>
+typename enable_if
+<
+     __is_input_iterator  <_InputIterator>::value &&
+    !__is_forward_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);
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    basic_string<_CharT, _Traits, _Allocator>&
+>::type
+basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last)
+{
+    size_type __sz = size();
+    size_type __cap = capacity();
+    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__n)
+    {
+        if (__cap - __sz < __n)
+            __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0);
+        pointer __p = __get_pointer() + __sz;
+        for (; __first != __last; ++__p, ++__first)
+            traits_type::assign(*__p, *__first);
+        traits_type::assign(*__p, value_type());
+        __set_size(__sz + __n);
+    }
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str)
+{
+    return append(__str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n)
+{
+    size_type __sz = __str.size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s)
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr");
+    return append(__s, traits_type::length(__s));
+}
+
+// insert
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n)
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr");
+    size_type __sz = size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    size_type __cap = capacity();
+    if (__cap - __sz >= __n)
+    {
+        if (__n)
+        {
+            value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+            size_type __n_move = __sz - __pos;
+            if (__n_move != 0)
+            {
+                if (__p + __pos <= __s && __s < __p + __sz)
+                    __s += __n;
+                traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
+            }
+            traits_type::move(__p + __pos, __s, __n);
+            __sz += __n;
+            __set_size(__sz);
+            traits_type::assign(__p[__sz], value_type());
+        }
+    }
+    else
+        __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s);
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c)
+{
+    size_type __sz = size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    if (__n)
+    {
+        size_type __cap = capacity();
+        value_type* __p;
+        if (__cap - __sz >= __n)
+        {
+            __p = _VSTD::__to_raw_pointer(__get_pointer());
+            size_type __n_move = __sz - __pos;
+            if (__n_move != 0)
+                traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
+        }
+        else
+        {
+            __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n);
+            __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+        }
+        traits_type::assign(__p + __pos, __n, __c);
+        __sz += __n;
+        __set_size(__sz);
+        traits_type::assign(__p[__sz], value_type());
+    }
+    return *this;
+}
+
+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
+>::type
+basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+        "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
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    typename basic_string<_CharT, _Traits, _Allocator>::iterator
+>::type
+basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+        "string::insert(iterator, range) called with an iterator not"
+        " referring to this string");
+#endif
+    size_type __ip = static_cast<size_type>(__pos - begin());
+    size_type __sz = size();
+    size_type __cap = capacity();
+    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__n)
+    {
+        value_type* __p;
+        if (__cap - __sz >= __n)
+        {
+            __p = _VSTD::__to_raw_pointer(__get_pointer());
+            size_type __n_move = __sz - __ip;
+            if (__n_move != 0)
+                traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
+        }
+        else
+        {
+            __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
+            __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+        }
+        __sz += __n;
+        __set_size(__sz);
+        traits_type::assign(__p[__sz], value_type());
+        for (__p += __ip; __first != __last; ++__p, ++__first)
+            traits_type::assign(*__p, *__first);
+    }
+    return begin() + __ip;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str)
+{
+    return insert(__pos1, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str,
+                                                  size_type __pos2, size_type __n)
+{
+    size_type __str_sz = __str.size();
+    if (__pos2 > __str_sz)
+        this->__throw_out_of_range();
+    return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s)
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr");
+    return insert(__pos, __s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c)
+{
+    size_type __ip = static_cast<size_type>(__pos - begin());
+    size_type __sz = size();
+    size_type __cap = capacity();
+    value_type* __p;
+    if (__cap == __sz)
+    {
+        __grow_by(__cap, 1, __sz, __ip, 0, 1);
+        __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+    }
+    else
+    {
+        __p = _VSTD::__to_raw_pointer(__get_pointer());
+        size_type __n_move = __sz - __ip;
+        if (__n_move != 0)
+            traits_type::move(__p + __ip + 1, __p + __ip, __n_move);
+    }
+    traits_type::assign(__p[__ip], __c);
+    traits_type::assign(__p[++__sz], value_type());
+    __set_size(__sz);
+    return begin() + static_cast<difference_type>(__ip);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+        "string::insert(iterator, n, value) called with an iterator not"
+        " referring to this string");
+#endif
+    difference_type __p = __pos - begin();
+    insert(static_cast<size_type>(__p), __n, __c);
+    return begin() + __p;
+}
+
+// replace
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2)
+{
+    _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr");
+    size_type __sz = size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    __n1 = _VSTD::min(__n1, __sz - __pos);
+    size_type __cap = capacity();
+    if (__cap - __sz + __n1 >= __n2)
+    {
+        value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+        if (__n1 != __n2)
+        {
+            size_type __n_move = __sz - __pos - __n1;
+            if (__n_move != 0)
+            {
+                if (__n1 > __n2)
+                {
+                    traits_type::move(__p + __pos, __s, __n2);
+                    traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
+                    goto __finish;
+                }
+                if (__p + __pos < __s && __s < __p + __sz)
+                {
+                    if (__p + __pos + __n1 <= __s)
+                        __s += __n2 - __n1;
+                    else // __p + __pos < __s < __p + __pos + __n1
+                    {
+                        traits_type::move(__p + __pos, __s, __n1);
+                        __pos += __n1;
+                        __s += __n2;
+                        __n2 -= __n1;
+                        __n1 = 0;
+                    }
+                }
+                traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
+            }
+        }
+        traits_type::move(__p + __pos, __s, __n2);
+__finish:
+        __sz += __n2 - __n1;
+        __set_size(__sz);
+        __invalidate_iterators_past(__sz);
+        traits_type::assign(__p[__sz], value_type());
+    }
+    else
+        __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s);
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c)
+{
+    size_type __sz = size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    __n1 = _VSTD::min(__n1, __sz - __pos);
+    size_type __cap = capacity();
+    value_type* __p;
+    if (__cap - __sz + __n1 >= __n2)
+    {
+        __p = _VSTD::__to_raw_pointer(__get_pointer());
+        if (__n1 != __n2)
+        {
+            size_type __n_move = __sz - __pos - __n1;
+            if (__n_move != 0)
+                traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move);
+        }
+    }
+    else
+    {
+        __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2);
+        __p = _VSTD::__to_raw_pointer(__get_long_pointer());
+    }
+    traits_type::assign(__p + __pos, __n2, __c);
+    __sz += __n2 - __n1;
+    __set_size(__sz);
+    __invalidate_iterators_past(__sz);
+    traits_type::assign(__p[__sz], value_type());
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+template<class _InputIterator>
+typename enable_if
+<
+    __is_input_iterator<_InputIterator>::value,
+    basic_string<_CharT, _Traits, _Allocator>&
+>::type
+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;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str)
+{
+    return replace(__pos1, __n1, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str,
+                                                   size_type __pos2, size_type __n2)
+{
+    size_type __str_sz = __str.size();
+    if (__pos2 > __str_sz)
+        this->__throw_out_of_range();
+    return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s)
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr");
+    return replace(__pos, __n1, __s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str)
+{
+    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1),
+                   __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n)
+{
+    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s)
+{
+    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c)
+{
+    return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c);
+}
+
+// erase
+
+template <class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>&
+basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n)
+{
+    size_type __sz = size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    if (__n)
+    {
+        value_type* __p = _VSTD::__to_raw_pointer(__get_pointer());
+        __n = _VSTD::min(__n, __sz - __pos);
+        size_type __n_move = __sz - __pos - __n;
+        if (__n_move != 0)
+            traits_type::move(__p + __pos, __p + __pos + __n, __n_move);
+        __sz -= __n;
+        __set_size(__sz);
+        __invalidate_iterators_past(__sz);
+        traits_type::assign(__p[__sz], value_type());
+    }
+    return *this;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+        "string::erase(iterator) called with an iterator not"
+        " referring to this string");
+#endif
+    _LIBCPP_ASSERT(__pos != end(),
+        "string::erase(iterator) called with a non-dereferenceable iterator");
+    iterator __b = begin();
+    size_type __r = static_cast<size_type>(__pos - __b);
+    erase(__r, 1);
+    return __b + static_cast<difference_type>(__r);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::iterator
+basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
+        "string::erase(iterator,  iterator) called with an iterator not"
+        " referring to this string");
+#endif
+    _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range");
+    iterator __b = begin();
+    size_type __r = static_cast<size_type>(__first - __b);
+    erase(__r, static_cast<size_type>(__last - __first));
+    return __b + static_cast<difference_type>(__r);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_string<_CharT, _Traits, _Allocator>::pop_back()
+{
+    _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty");
+    size_type __sz;
+    if (__is_long())
+    {
+        __sz = __get_long_size() - 1;
+        __set_long_size(__sz);
+        traits_type::assign(*(__get_long_pointer() + __sz), value_type());
+    }
+    else
+    {
+        __sz = __get_short_size() - 1;
+        __set_short_size(__sz);
+        traits_type::assign(*(__get_short_pointer() + __sz), value_type());
+    }
+    __invalidate_iterators_past(__sz);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
+{
+    __invalidate_all_iterators();
+    if (__is_long())
+    {
+        traits_type::assign(*__get_long_pointer(), value_type());
+        __set_long_size(0);
+    }
+    else
+    {
+        traits_type::assign(*__get_short_pointer(), value_type());
+        __set_short_size(0);
+    }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos)
+{
+    if (__is_long())
+    {
+        traits_type::assign(*(__get_long_pointer() + __pos), value_type());
+        __set_long_size(__pos);
+    }
+    else
+    {
+        traits_type::assign(*(__get_short_pointer() + __pos), value_type());
+        __set_short_size(__pos);
+    }
+    __invalidate_iterators_past(__pos);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c)
+{
+    size_type __sz = size();
+    if (__n > __sz)
+        append(__n - __sz, __c);
+    else
+        __erase_to_end(__n);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
+{
+    size_type __m = __alloc_traits::max_size(__alloc());
+#if _LIBCPP_BIG_ENDIAN
+    return (__m <= ~__long_mask ? __m : __m/2) - __alignment;
+#else
+    return __m - __alignment;
+#endif
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+void
+basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg)
+{
+    if (__res_arg > max_size())
+        this->__throw_length_error();
+    size_type __cap = capacity();
+    size_type __sz = size();
+    __res_arg = _VSTD::max(__res_arg, __sz);
+    __res_arg = __recommend(__res_arg);
+    if (__res_arg != __cap)
+    {
+        pointer __new_data, __p;
+        bool __was_long, __now_long;
+        if (__res_arg == __min_cap - 1)
+        {
+            __was_long = true;
+            __now_long = false;
+            __new_data = __get_short_pointer();
+            __p = __get_long_pointer();
+        }
+        else
+        {
+            if (__res_arg > __cap)
+                __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);
+            else
+            {
+            #ifndef _LIBCPP_NO_EXCEPTIONS
+                try
+                {
+            #endif  // _LIBCPP_NO_EXCEPTIONS
+                    __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1);
+            #ifndef _LIBCPP_NO_EXCEPTIONS
+                }
+                catch (...)
+                {
+                    return;
+                }
+            #else  // _LIBCPP_NO_EXCEPTIONS
+                if (__new_data == nullptr)
+                    return;
+            #endif  // _LIBCPP_NO_EXCEPTIONS
+            }
+            __now_long = true;
+            __was_long = __is_long();
+            __p = __get_pointer();
+        }
+        traits_type::copy(_VSTD::__to_raw_pointer(__new_data),
+                          _VSTD::__to_raw_pointer(__p), size()+1);
+        if (__was_long)
+            __alloc_traits::deallocate(__alloc(), __p, __cap+1);
+        if (__now_long)
+        {
+            __set_long_cap(__res_arg+1);
+            __set_long_size(__sz);
+            __set_long_pointer(__new_data);
+        }
+        else
+            __set_short_size(__sz);
+        __invalidate_all_iterators();
+    }
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const
+{
+    _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
+    return *(data() + __pos);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos)
+{
+    _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds");
+    return *(__get_pointer() + __pos);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const
+{
+    if (__n >= size())
+        this->__throw_out_of_range();
+    return (*this)[__n];
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::at(size_type __n)
+{
+    if (__n >= size())
+        this->__throw_out_of_range();
+    return (*this)[__n];
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::front()
+{
+    _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
+    return *__get_pointer();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::front() const
+{
+    _LIBCPP_ASSERT(!empty(), "string::front(): string is empty");
+    return *data();
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::reference
+basic_string<_CharT, _Traits, _Allocator>::back()
+{
+    _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
+    return *(__get_pointer() + size() - 1);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::const_reference
+basic_string<_CharT, _Traits, _Allocator>::back() const
+{
+    _LIBCPP_ASSERT(!empty(), "string::back(): string is empty");
+    return *(data() + size() - 1);
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const
+{
+    size_type __sz = size();
+    if (__pos > __sz)
+        this->__throw_out_of_range();
+    size_type __rlen = _VSTD::min(__n, __sz - __pos);
+    traits_type::copy(__s, data() + __pos, __rlen);
+    return __rlen;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const
+{
+    return basic_string(*this, __pos, __n, __alloc());
+}
+
+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_DEBUG_LEVEL >= 2
+    if (!__is_long())
+        __get_db()->__invalidate_all(this);
+    if (!__str.__is_long())
+        __get_db()->__invalidate_all(&__str);
+    __get_db()->swap(this, &__str);
+#endif
+    _VSTD::swap(__r_.first(), __str.__r_.first());
+    __swap_alloc(__alloc(), __str.__alloc());
+}
+
+// find
+
+template <class _Traits>
+struct _LIBCPP_HIDDEN __traits_eq
+{
+    typedef typename _Traits::char_type char_type;
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT
+        {return _Traits::eq(__x, __y);}
+};
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
+                                                size_type __pos,
+                                                size_type __n) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr");
+    return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str,
+                                                size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+        (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s,
+                                                size_type __pos) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr");
+    return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find(value_type __c,
+                                                size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find<value_type, size_type, traits_type, npos>
+        (data(), size(), __c, __pos);
+}
+
+// rfind
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
+                                                 size_type __pos,
+                                                 size_type __n) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
+    return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str,
+                                                 size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+        (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s,
+                                                 size_type __pos) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr");
+    return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c,
+                                                 size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
+        (data(), size(), __c, __pos);
+}
+
+// find_first_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
+                                                         size_type __pos,
+                                                         size_type __n) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
+    return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str,
+                                                         size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s,
+                                                         size_type __pos) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr");
+    return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c,
+                                                         size_type __pos) const _NOEXCEPT
+{
+    return find(__c, __pos);
+}
+
+// find_last_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
+                                                        size_type __pos,
+                                                        size_type __n) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
+    return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str,
+                                                        size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s,
+                                                        size_type __pos) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr");
+    return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c,
+                                                        size_type __pos) const _NOEXCEPT
+{
+    return rfind(__c, __pos);
+}
+
+// find_first_not_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
+                                                             size_type __pos,
+                                                             size_type __n) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
+    return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str,
+                                                             size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s,
+                                                             size_type __pos) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr");
+    return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c,
+                                                             size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __c, __pos);
+}
+
+// find_last_not_of
+
+template<class _CharT, class _Traits, class _Allocator>
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
+                                                            size_type __pos,
+                                                            size_type __n) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
+    return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, __n);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str,
+                                                            size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __str.data(), __pos, __str.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s,
+                                                            size_type __pos) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr");
+    return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __s, __pos, traits_type::length(__s));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename basic_string<_CharT, _Traits, _Allocator>::size_type
+basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c,
+                                                            size_type __pos) const _NOEXCEPT
+{
+    return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
+        (data(), size(), __c, __pos);
+}
+
+// compare
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT
+{
+    size_t __lhs_sz = size();
+    size_t __rhs_sz = __str.size();
+    int __result = traits_type::compare(data(), __str.data(),
+                                        _VSTD::min(__lhs_sz, __rhs_sz));
+    if (__result != 0)
+        return __result;
+    if (__lhs_sz < __rhs_sz)
+        return -1;
+    if (__lhs_sz > __rhs_sz)
+        return 1;
+    return 0;
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+                                                   size_type __n1,
+                                                   const basic_string& __str) const
+{
+    return compare(__pos1, __n1, __str.data(), __str.size());
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+                                                   size_type __n1,
+                                                   const basic_string& __str,
+                                                   size_type __pos2,
+                                                   size_type __n2) const
+{
+    size_type __sz = __str.size();
+    if (__pos2 > __sz)
+        this->__throw_out_of_range();
+    return compare(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2,
+                                                                  __sz - __pos2));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
+    return compare(0, npos, __s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+                                                   size_type __n1,
+                                                   const value_type* __s) const
+{
+    _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr");
+    return compare(__pos1, __n1, __s, traits_type::length(__s));
+}
+
+template <class _CharT, class _Traits, class _Allocator>
+int
+basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
+                                                   size_type __n1,
+                                                   const value_type* __s,
+                                                   size_type __n2) const
+{
+    _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");
+    size_type __sz = size();
+    if (__pos1 > __sz || __n2 == npos)
+        this->__throw_out_of_range();
+    size_type __rlen = _VSTD::min(__n1, __sz - __pos1);
+    int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2));
+    if (__r == 0)
+    {
+        if (__rlen < __n2)
+            __r = -1;
+        else if (__rlen > __n2)
+            __r = 1;
+    }
+    return __r;
+}
+
+// __invariants
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+basic_string<_CharT, _Traits, _Allocator>::__invariants() const
+{
+    if (size() > capacity())
+        return false;
+    if (capacity() < __min_cap - 1)
+        return false;
+    if (data() == 0)
+        return false;
+    if (data()[size()] != value_type(0))
+        return false;
+    return true;
+}
+
+// operator==
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    size_t __lhs_sz = __lhs.size();
+    return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),
+                                                        __rhs.data(),
+                                                        __lhs_sz) == 0;
+}
+
+template<class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
+           const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
+{
+    size_t __lhs_sz = __lhs.size();
+    if (__lhs_sz != __rhs.size())
+        return false;
+    const char* __lp = __lhs.data();
+    const char* __rp = __rhs.data();
+    if (__lhs.__is_long())
+        return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0;
+    for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp)
+        if (*__lp != *__rp)
+            return false;
+    return true;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const _CharT* __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return __rhs.compare(__lhs) == 0;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
+           const _CharT* __rhs) _NOEXCEPT
+{
+    return __lhs.compare(__rhs) == 0;
+}
+
+// operator!=
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return !(__lhs == __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const _CharT* __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return !(__lhs == __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const _CharT* __rhs) _NOEXCEPT
+{
+    return !(__lhs == __rhs);
+}
+
+// operator<
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return __lhs.compare(__rhs) < 0;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const _CharT* __rhs) _NOEXCEPT
+{
+    return __lhs.compare(__rhs) < 0;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const _CharT* __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return __rhs.compare(__lhs) > 0;
+}
+
+// operator>
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return __rhs < __lhs;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const _CharT* __rhs) _NOEXCEPT
+{
+    return __rhs < __lhs;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const _CharT* __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return __rhs < __lhs;
+}
+
+// operator<=
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return !(__rhs < __lhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const _CharT* __rhs) _NOEXCEPT
+{
+    return !(__rhs < __lhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const _CharT* __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return !(__rhs < __lhs);
+}
+
+// operator>=
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return !(__lhs < __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+           const _CharT* __rhs) _NOEXCEPT
+{
+    return !(__lhs < __rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const _CharT* __lhs,
+           const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
+{
+    return !(__lhs < __rhs);
+}
+
+// operator +
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
+          const basic_string<_CharT, _Traits, _Allocator>& __rhs)
+{
+    basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
+    __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
+    __r.append(__rhs.data(), __rhs_sz);
+    return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs)
+{
+    basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs);
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
+    __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz);
+    __r.append(__rhs.data(), __rhs_sz);
+    return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs)
+{
+    basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator());
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size();
+    __r.__init(&__lhs, 1, 1 + __rhs_sz);
+    __r.append(__rhs.data(), __rhs_sz);
+    return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs)
+{
+    basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs);
+    __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz);
+    __r.append(__rhs, __rhs_sz);
+    return __r;
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs)
+{
+    basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator());
+    typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size();
+    __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1);
+    __r.push_back(__rhs);
+    return __r;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs)
+{
+    return _VSTD::move(__lhs.append(__rhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
+{
+    return _VSTD::move(__rhs.insert(0, __lhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs)
+{
+    return _VSTD::move(__lhs.append(__rhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs)
+{
+    return _VSTD::move(__rhs.insert(0, __lhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs)
+{
+    __rhs.insert(__rhs.begin(), __lhs);
+    return _VSTD::move(__rhs);
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs)
+{
+    return _VSTD::move(__lhs.append(__rhs));
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>
+operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs)
+{
+    __lhs.push_back(__rhs);
+    return _VSTD::move(__lhs);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+// swap
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
+     basic_string<_CharT, _Traits, _Allocator>& __rhs)
+     _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs)))
+{
+    __lhs.swap(__rhs);
+}
+
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef basic_string<char16_t> u16string;
+typedef basic_string<char32_t> u32string;
+
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+
+_LIBCPP_FUNC_VIS int                stoi  (const string& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS long               stol  (const string& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long      stoul (const string& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS long long          stoll (const string& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10);
+
+_LIBCPP_FUNC_VIS float       stof (const string& __str, size_t* __idx = 0);
+_LIBCPP_FUNC_VIS double      stod (const string& __str, size_t* __idx = 0);
+_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0);
+
+_LIBCPP_FUNC_VIS string to_string(int __val);
+_LIBCPP_FUNC_VIS string to_string(unsigned __val);
+_LIBCPP_FUNC_VIS string to_string(long __val);
+_LIBCPP_FUNC_VIS string to_string(unsigned long __val);
+_LIBCPP_FUNC_VIS string to_string(long long __val);
+_LIBCPP_FUNC_VIS string to_string(unsigned long long __val);
+_LIBCPP_FUNC_VIS string to_string(float __val);
+_LIBCPP_FUNC_VIS string to_string(double __val);
+_LIBCPP_FUNC_VIS string to_string(long double __val);
+
+_LIBCPP_FUNC_VIS int                stoi  (const wstring& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS long               stol  (const wstring& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long      stoul (const wstring& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS long long          stoll (const wstring& __str, size_t* __idx = 0, int __base = 10);
+_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10);
+
+_LIBCPP_FUNC_VIS float       stof (const wstring& __str, size_t* __idx = 0);
+_LIBCPP_FUNC_VIS double      stod (const wstring& __str, size_t* __idx = 0);
+_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0);
+
+_LIBCPP_FUNC_VIS wstring to_wstring(int __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(long long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(float __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(double __val);
+_LIBCPP_FUNC_VIS wstring to_wstring(long double __val);
+
+template<class _CharT, class _Traits, class _Allocator>
+    const typename basic_string<_CharT, _Traits, _Allocator>::size_type
+                   basic_string<_CharT, _Traits, _Allocator>::npos;
+
+template<class _CharT, class _Traits, class _Allocator>
+struct _LIBCPP_TYPE_VIS_ONLY hash<basic_string<_CharT, _Traits, _Allocator> >
+    : public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t>
+{
+    size_t
+        operator()(const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT;
+};
+
+template<class _CharT, class _Traits, class _Allocator>
+size_t
+hash<basic_string<_CharT, _Traits, _Allocator> >::operator()(
+        const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT
+{
+    return __do_string_hash(__val.data(), __val.data() + __val.size());
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+           const basic_string<_CharT, _Traits, _Allocator>& __str);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+           basic_string<_CharT, _Traits, _Allocator>& __str);
+
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm);
+
+template<class _CharT, class _Traits, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+basic_istream<_CharT, _Traits>&
+getline(basic_istream<_CharT, _Traits>&& __is,
+        basic_string<_CharT, _Traits, _Allocator>& __str);
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const
+{
+    return this->data() <= _VSTD::__to_raw_pointer(__i->base()) &&
+           _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size();
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const
+{
+    return this->data() < _VSTD::__to_raw_pointer(__i->base()) &&
+           _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size();
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
+{
+    const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n;
+    return this->data() <= __p && __p <= this->data() + this->size();
+}
+
+template<class _CharT, class _Traits, class _Allocator>
+bool
+basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+{
+    const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n;
+    return this->data() <= __p && __p < this->data() + this->size();
+}
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+#if _LIBCPP_STD_VER > 11 
+// Literal suffixes for basic_string [basic.string.literals]
+inline namespace literals
+{
+  inline namespace string_literals
+  {
+    inline _LIBCPP_INLINE_VISIBILITY
+    basic_string<char> operator "" s( const char *__str, size_t __len )
+    {
+        return basic_string<char> (__str, __len);
+    }
+
+    inline _LIBCPP_INLINE_VISIBILITY
+    basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
+    {
+        return basic_string<wchar_t> (__str, __len);
+    }
+
+    inline _LIBCPP_INLINE_VISIBILITY
+    basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
+    {
+        return basic_string<char16_t> (__str, __len);
+    }
+
+    inline _LIBCPP_INLINE_VISIBILITY
+    basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
+    {
+        return basic_string<char32_t> (__str, __len);
+    }
+  }
+}
+#endif
+
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<char>)
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<wchar_t>)
+_LIBCPP_EXTERN_TEMPLATE(string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_STRING
diff --git a/final/include/strstream b/final/include/strstream
new file mode 100644
index 0000000..81eef2a
--- /dev/null
+++ b/final/include/strstream
@@ -0,0 +1,400 @@
+// -*- C++ -*-
+//===--------------------------- strstream --------------------------------===//
+//
+//                     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_STRSTREAM
+#define _LIBCPP_STRSTREAM
+
+/*
+    strstream synopsis
+
+class strstreambuf
+    : public basic_streambuf<char>
+{
+public:
+    explicit strstreambuf(streamsize alsize_arg = 0);
+    strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
+    strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
+    strstreambuf(const char* gnext_arg, streamsize n);
+
+    strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
+    strstreambuf(const signed char* gnext_arg, streamsize n);
+    strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
+    strstreambuf(const unsigned char* gnext_arg, streamsize n);
+
+    strstreambuf(strstreambuf&& rhs);
+    strstreambuf& operator=(strstreambuf&& rhs);
+
+    virtual ~strstreambuf();
+
+    void swap(strstreambuf& rhs);
+
+    void freeze(bool freezefl = true);
+    char* str();
+    int pcount() const;
+
+protected:
+    virtual int_type overflow (int_type c = EOF);
+    virtual int_type pbackfail(int_type c = EOF);
+    virtual int_type underflow();
+    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type sp,
+                             ios_base::openmode which = ios_base::in | ios_base::out);
+    virtual streambuf* setbuf(char* s, streamsize n);
+
+private:
+    typedef T1 strstate;                // exposition only
+    static const strstate allocated;    // exposition only
+    static const strstate constant;     // exposition only
+    static const strstate dynamic;      // exposition only
+    static const strstate frozen;       // exposition only
+    strstate strmode;                   // exposition only
+    streamsize alsize;                  // exposition only
+    void* (*palloc)(size_t);            // exposition only
+    void (*pfree)(void*);               // exposition only
+};
+
+class istrstream
+    : public basic_istream<char>
+{
+public:
+    explicit istrstream(const char* s);
+    explicit istrstream(char* s);
+    istrstream(const char* s, streamsize n);
+    istrstream(char* s, streamsize n);
+
+    virtual ~istrstream();
+
+    strstreambuf* rdbuf() const;
+    char *str();
+
+private:
+    strstreambuf sb; // exposition only
+};
+
+class ostrstream
+    : public basic_ostream<char>
+{
+public:
+    ostrstream();
+    ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
+
+    virtual ~ostrstream();
+
+    strstreambuf* rdbuf() const;
+    void freeze(bool freezefl = true);
+    char* str();
+    int pcount() const;
+
+private:
+    strstreambuf sb; // exposition only
+};
+
+class strstream
+    : public basic_iostream<char>
+{
+public:
+    // Types
+    typedef char                        char_type;
+    typedef char_traits<char>::int_type int_type;
+    typedef char_traits<char>::pos_type pos_type;
+    typedef char_traits<char>::off_type off_type;
+
+    // constructors/destructor
+    strstream();
+    strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+    virtual ~strstream();
+
+    // Members:
+    strstreambuf* rdbuf() const;
+    void freeze(bool freezefl = true);
+    int pcount() const;
+    char* str();
+
+private:
+    strstreambuf sb; // exposition only
+};
+
+}  // std
+
+*/
+
+#include <__config>
+#include <ostream>
+#include <istream>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS strstreambuf
+    : public streambuf
+{
+public:
+    explicit strstreambuf(streamsize __alsize = 0);
+    strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
+    strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);
+    strstreambuf(const char* __gnext, streamsize __n);
+
+    strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);
+    strstreambuf(const signed char* __gnext, streamsize __n);
+    strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);
+    strstreambuf(const unsigned char* __gnext, streamsize __n);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    strstreambuf(strstreambuf&& __rhs);
+    _LIBCPP_INLINE_VISIBILITY
+    strstreambuf& operator=(strstreambuf&& __rhs);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    virtual ~strstreambuf();
+
+    void swap(strstreambuf& __rhs);
+
+    void freeze(bool __freezefl = true);
+    char* str();
+    int pcount() const;
+
+protected:
+    virtual int_type overflow (int_type __c = EOF);
+    virtual int_type pbackfail(int_type __c = EOF);
+    virtual int_type underflow();
+    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
+                             ios_base::openmode __which = ios_base::in | ios_base::out);
+    virtual pos_type seekpos(pos_type __sp,
+                             ios_base::openmode __which = ios_base::in | ios_base::out);
+
+private:
+    typedef unsigned __mode_type;
+    static const __mode_type __allocated = 0x01;
+    static const __mode_type __constant  = 0x02;
+    static const __mode_type __dynamic   = 0x04;
+    static const __mode_type __frozen    = 0x08;
+    static const streamsize    __default_alsize = 4096;
+
+    __mode_type __strmode_;
+    streamsize __alsize_;
+    void* (*__palloc_)(size_t);
+    void (*__pfree_)(void*);
+
+    void __init(char* __gnext, streamsize __n, char* __pbeg);
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+inline _LIBCPP_INLINE_VISIBILITY
+strstreambuf::strstreambuf(strstreambuf&& __rhs)
+    : streambuf(__rhs),
+      __strmode_(__rhs.__strmode_),
+      __alsize_(__rhs.__alsize_),
+      __palloc_(__rhs.__palloc_),
+      __pfree_(__rhs.__pfree_)
+{
+    __rhs.setg(nullptr, nullptr, nullptr);
+    __rhs.setp(nullptr, nullptr);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+strstreambuf&
+strstreambuf::operator=(strstreambuf&& __rhs)
+{
+    if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
+    {
+        if (__pfree_)
+            __pfree_(eback());
+        else
+            delete [] eback();
+    }
+    streambuf::operator=(__rhs);
+    __strmode_ = __rhs.__strmode_;
+    __alsize_ = __rhs.__alsize_;
+    __palloc_ = __rhs.__palloc_;
+    __pfree_ = __rhs.__pfree_;
+    __rhs.setg(nullptr, nullptr, nullptr);
+    __rhs.setp(nullptr, nullptr);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class _LIBCPP_TYPE_VIS istrstream
+    : public istream
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit istrstream(const char* __s)
+        : istream(&__sb_), __sb_(__s, 0) {}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit istrstream(char* __s)
+        : istream(&__sb_), __sb_(__s, 0) {}
+    _LIBCPP_INLINE_VISIBILITY
+    istrstream(const char* __s, streamsize __n)
+        : istream(&__sb_), __sb_(__s, __n) {}
+    _LIBCPP_INLINE_VISIBILITY
+    istrstream(char* __s, streamsize __n)
+        : istream(&__sb_), __sb_(__s, __n) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    istrstream(istrstream&& __rhs)
+        : istream(_VSTD::move(__rhs)),
+          __sb_(_VSTD::move(__rhs.__sb_))
+    {
+        istream::set_rdbuf(&__sb_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    istrstream& operator=(istrstream&& __rhs)
+    {
+        istream::operator=(_VSTD::move(__rhs));
+        __sb_ = _VSTD::move(__rhs.__sb_);
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    virtual ~istrstream();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(istrstream& __rhs)
+    {
+        istream::swap(__rhs);
+        __sb_.swap(__rhs.__sb_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
+    _LIBCPP_INLINE_VISIBILITY
+    char *str() {return __sb_.str();}
+
+private:
+    strstreambuf __sb_;
+};
+
+class _LIBCPP_TYPE_VIS ostrstream
+    : public ostream
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    ostrstream()
+        : ostream(&__sb_) {}
+    _LIBCPP_INLINE_VISIBILITY
+    ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
+        : ostream(&__sb_),
+          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
+        {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    ostrstream(ostrstream&& __rhs)
+        : ostream(_VSTD::move(__rhs)),
+          __sb_(_VSTD::move(__rhs.__sb_))
+    {
+        ostream::set_rdbuf(&__sb_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    ostrstream& operator=(ostrstream&& __rhs)
+    {
+        ostream::operator=(_VSTD::move(__rhs));
+        __sb_ = _VSTD::move(__rhs.__sb_);
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    virtual ~ostrstream();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(ostrstream& __rhs)
+    {
+        ostream::swap(__rhs);
+        __sb_.swap(__rhs.__sb_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
+    _LIBCPP_INLINE_VISIBILITY
+    char* str()         {return __sb_.str();}
+    _LIBCPP_INLINE_VISIBILITY
+    int pcount() const  {return __sb_.pcount();}
+
+private:
+    strstreambuf __sb_; // exposition only
+};
+
+class _LIBCPP_TYPE_VIS strstream
+    : public iostream
+{
+public:
+    // Types
+    typedef char                        char_type;
+    typedef char_traits<char>::int_type int_type;
+    typedef char_traits<char>::pos_type pos_type;
+    typedef char_traits<char>::off_type off_type;
+
+    // constructors/destructor
+    _LIBCPP_INLINE_VISIBILITY
+    strstream()
+        : iostream(&__sb_) {}
+    _LIBCPP_INLINE_VISIBILITY
+    strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
+        : iostream(&__sb_),
+          __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
+        {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    strstream(strstream&& __rhs)
+        : iostream(_VSTD::move(__rhs)),
+          __sb_(_VSTD::move(__rhs.__sb_))
+    {
+        iostream::set_rdbuf(&__sb_);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    strstream& operator=(strstream&& __rhs)
+    {
+        iostream::operator=(_VSTD::move(__rhs));
+        __sb_ = _VSTD::move(__rhs.__sb_);
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    virtual ~strstream();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(strstream& __rhs)
+    {
+        iostream::swap(__rhs);
+        __sb_.swap(__rhs.__sb_);
+    }
+
+    // Members:
+    _LIBCPP_INLINE_VISIBILITY
+    strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
+    _LIBCPP_INLINE_VISIBILITY
+    int pcount() const {return __sb_.pcount();}
+    _LIBCPP_INLINE_VISIBILITY
+    char* str()        {return __sb_.str();}
+
+private:
+    strstreambuf __sb_; // exposition only
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_STRSTREAM
diff --git a/final/include/support/android/locale_bionic.h b/final/include/support/android/locale_bionic.h
new file mode 100644
index 0000000..354fcfe
--- /dev/null
+++ b/final/include/support/android/locale_bionic.h
@@ -0,0 +1,192 @@
+// -*- C++ -*-
+//===------------------- support/android/locale_bionic.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_ANDROID_LOCALE_BIONIC_H
+#define _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
+
+#if defined(__ANDROID__)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <xlocale.h>
+
+static inline int isalnum_l(int c, locale_t) {
+  return isalnum(c);
+}
+
+static inline int isalpha_l(int c, locale_t) {
+  return isalpha(c);
+}
+
+static inline int isblank_l(int c, locale_t) {
+  return isblank(c);
+}
+
+static inline int iscntrl_l(int c, locale_t) {
+  return iscntrl(c);
+}
+
+static inline int isdigit_l(int c, locale_t) {
+  return isdigit(c);
+}
+
+static inline int isgraph_l(int c, locale_t) {
+  return isgraph(c);
+}
+
+static inline int islower_l(int c, locale_t) {
+  return islower(c);
+}
+
+static inline int isprint_l(int c, locale_t) {
+  return isprint(c);
+}
+
+static inline int ispunct_l(int c, locale_t) {
+  return ispunct(c);
+}
+
+static inline int isspace_l(int c, locale_t) {
+  return isspace(c);
+}
+
+static inline int isupper_l(int c, locale_t) {
+  return isupper(c);
+}
+
+static inline int isxdigit_l(int c, locale_t) {
+  return isxdigit(c);
+}
+
+static inline int iswalnum_l(wint_t c, locale_t) {
+  return iswalnum(c);
+}
+
+static inline int iswalpha_l(wint_t c, locale_t) {
+  return iswalpha(c);
+}
+
+static inline int iswblank_l(wint_t c, locale_t) {
+  return iswblank(c);
+}
+
+static inline int iswcntrl_l(wint_t c, locale_t) {
+  return iswcntrl(c);
+}
+
+static inline int iswdigit_l(wint_t c, locale_t) {
+  return iswdigit(c);
+}
+
+static inline int iswgraph_l(wint_t c, locale_t) {
+  return iswgraph(c);
+}
+
+static inline int iswlower_l(wint_t c, locale_t) {
+  return iswlower(c);
+}
+
+static inline int iswprint_l(wint_t c, locale_t) {
+  return iswprint(c);
+}
+
+static inline int iswpunct_l(wint_t c, locale_t) {
+  return iswpunct(c);
+}
+
+static inline int iswspace_l(wint_t c, locale_t) {
+  return iswspace(c);
+}
+
+static inline int iswupper_l(wint_t c, locale_t) {
+  return iswupper(c);
+}
+
+static inline int iswxdigit_l(wint_t c, locale_t) {
+  return iswxdigit(c);
+}
+
+static inline int toupper_l(int c, locale_t) {
+  return toupper(c);
+}
+
+static inline int tolower_l(int c, locale_t) {
+  return tolower(c);
+}
+
+static inline int towupper_l(int c, locale_t) {
+  return towupper(c);
+}
+
+static inline int towlower_l(int c, locale_t) {
+  return towlower(c);
+}
+
+static inline int strcoll_l(const char *s1, const char *s2, locale_t) {
+  return strcoll(s1, s2);
+}
+
+static inline size_t strxfrm_l(char *dest, const char *src, size_t n,
+                               locale_t) {
+  return strxfrm(dest, src, n);
+}
+
+static inline size_t strftime_l(char *s, size_t max, const char *format,
+                                const struct tm *tm, locale_t) {
+  return strftime(s, max, format, tm);
+}
+
+static inline int wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t) {
+  return wcscoll(ws1, ws2);
+}
+
+static inline size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n,
+                               locale_t) {
+  return wcsxfrm(dest, src, n);
+}
+
+static inline long double strtold_l(const char *nptr, char **endptr, locale_t) {
+  return strtold(nptr, endptr);
+}
+
+static inline long long strtoll_l(const char *nptr, char **endptr, size_t base,
+                                  locale_t) {
+  return strtoll(nptr, endptr, base);
+}
+
+static inline unsigned long long strtoull_l(const char *nptr, char **endptr,
+                                            size_t base, locale_t) {
+  return strtoull(nptr, endptr, base);
+}
+
+static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr,
+                                  size_t base, locale_t) {
+  return wcstoll(nptr, endptr, base);
+}
+
+static inline unsigned long long wcstoull_l(const wchar_t *nptr,
+                                            wchar_t **endptr, size_t 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 // defined(__ANDROID__)
+#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
diff --git a/final/include/support/ibm/limits.h b/final/include/support/ibm/limits.h
new file mode 100644
index 0000000..efdb359
--- /dev/null
+++ b/final/include/support/ibm/limits.h
@@ -0,0 +1,99 @@
+// -*- C++ -*-
+//===--------------------- support/ibm/limits.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_LIMITS_H
+#define _LIBCPP_SUPPORT_IBM_LIMITS_H
+
+#if !defined(_AIX) // Linux
+#include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN
+
+static const unsigned int _QNAN_F = 0x7fc00000;
+#define NANF (*((float *)(&_QNAN_F)))
+static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0};
+#define NANL (*((long double *)(&_QNAN_LDBL128)))
+static const unsigned int _SNAN_F= 0x7f855555;
+#define NANSF (*((float *)(&_SNAN_F)))
+static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555};
+#define NANS (*((double *)(&_SNAN_D)))
+static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0};
+#define NANSL (*((long double *)(&_SNAN_LDBL128)))
+
+#define __builtin_huge_val()     HUGE_VAL
+#define __builtin_huge_valf()    HUGE_VALF
+#define __builtin_huge_vall()    HUGE_VALL
+#define __builtin_nan(__dummy)   NAN
+#define __builtin_nanf(__dummy)  NANF
+#define __builtin_nanl(__dummy)  NANL
+#define __builtin_nans(__dummy)  NANS
+#define __builtin_nansf(__dummy) NANSF
+#define __builtin_nansl(__dummy) NANSL
+
+#else
+
+#include <math.h>
+#include <float.h> // limit constants
+
+#define __builtin_huge_val()     HUGE_VAL  //0x7ff0000000000000
+#define __builtin_huge_valf()    HUGE_VALF //0x7f800000
+#define __builtin_huge_vall()    HUGE_VALL //0x7ff0000000000000
+#define __builtin_nan(__dummy)   nan(__dummy) //0x7ff8000000000000
+#define __builtin_nanf(__dummy)  nanf(__dummy) // 0x7ff80000
+#define __builtin_nanl(__dummy)  nanl(__dummy) //0x7ff8000000000000
+#define __builtin_nans(__dummy)  DBL_SNAN //0x7ff5555555555555
+#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555
+#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555
+
+#define __FLT_MANT_DIG__   FLT_MANT_DIG
+#define __FLT_DIG__        FLT_DIG
+#define __FLT_RADIX__      FLT_RADIX
+#define __FLT_MIN_EXP__    FLT_MIN_EXP
+#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
+#define __FLT_MAX_EXP__    FLT_MAX_EXP
+#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
+#define __FLT_MIN__        FLT_MIN
+#define __FLT_MAX__        FLT_MAX
+#define __FLT_EPSILON__    FLT_EPSILON
+// predefined by XLC on LoP
+#define __FLT_DENORM_MIN__ 1.40129846e-45F
+
+#define __DBL_MANT_DIG__   DBL_MANT_DIG
+#define __DBL_DIG__        DBL_DIG
+#define __DBL_MIN_EXP__    DBL_MIN_EXP
+#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
+#define __DBL_MAX_EXP__    DBL_MAX_EXP
+#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
+#define __DBL_MIN__        DBL_MIN
+#define __DBL_MAX__        DBL_MAX
+#define __DBL_EPSILON__    DBL_EPSILON
+// predefined by XLC on LoP
+#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+
+#define __LDBL_MANT_DIG__   LDBL_MANT_DIG
+#define __LDBL_DIG__        LDBL_DIG
+#define __LDBL_MIN_EXP__    LDBL_MIN_EXP
+#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
+#define __LDBL_MAX_EXP__    LDBL_MAX_EXP
+#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
+#define __LDBL_MIN__        LDBL_MIN
+#define __LDBL_MAX__        LDBL_MAX
+#define __LDBL_EPSILON__    LDBL_EPSILON
+// predefined by XLC on LoP
+#if __LONGDOUBLE128
+#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+#else
+#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
+#endif
+
+// predefined by XLC on LoP
+#define __CHAR_BIT__    8
+
+#endif // _AIX
+
+#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H
diff --git a/final/include/support/ibm/support.h b/final/include/support/ibm/support.h
new file mode 100644
index 0000000..0abfa7f
--- /dev/null
+++ b/final/include/support/ibm/support.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//===----------------------- support/ibm/support.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_SUPPORT_H
+#define _LIBCPP_SUPPORT_IBM_SUPPORT_H
+
+extern "builtin" int __popcnt4(unsigned int);
+extern "builtin" int __popcnt8(unsigned long long);
+extern "builtin" unsigned int __cnttz4(unsigned int);
+extern "builtin" unsigned int __cnttz8(unsigned long long);
+extern "builtin" unsigned int __cntlz4(unsigned int);
+extern "builtin" unsigned int __cntlz8(unsigned long long);
+
+// Builtin functions for counting population
+#define __builtin_popcount(x) __popcnt4(x)
+#define __builtin_popcountll(x) __popcnt8(x)
+#if defined(__64BIT__)
+#define __builtin_popcountl(x) __builtin_popcountll(x)
+#else
+#define __builtin_popcountl(x) __builtin_popcount(x)
+#endif
+
+// Builtin functions for counting trailing zeros
+#define __builtin_ctz(x) __cnttz4(x)
+#define __builtin_ctzll(x) __cnttz8(x)
+#if defined(__64BIT__)
+#define __builtin_ctzl(x) __builtin_ctzll(x)
+#else
+#define __builtin_ctzl(x) __builtin_ctz(x)
+#endif
+
+// Builtin functions for counting leading zeros
+#define __builtin_clz(x) __cntlz4(x)
+#define __builtin_clzll(x) __cntlz8(x)
+#if defined(__64BIT__)
+#define __builtin_clzl(x) __builtin_clzll(x)
+#else
+#define __builtin_clzl(x) __builtin_clz(x)
+#endif
+
+#if defined(__64BIT__)
+#define __SIZE_WIDTH__ 64
+#else
+#define __SIZE_WIDTH__ 32
+#endif
+
+#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H
diff --git a/final/include/support/ibm/xlocale.h b/final/include/support/ibm/xlocale.h
new file mode 100644
index 0000000..8d99a5c
--- /dev/null
+++ b/final/include/support/ibm/xlocale.h
@@ -0,0 +1,326 @@
+// -*- C++ -*-
+//===--------------------- support/ibm/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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H
+#define _LIBCPP_SUPPORT_IBM_XLOCALE_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;
+}
+
+static inline
+int isalnum_l(int c, locale_t locale)
+{
+  return __xisalnum(locale, c);
+}
+static inline
+int isalpha_l(int c, locale_t locale)
+{
+  return __xisalpha(locale, c);
+}
+static inline
+int isblank_l(int c, locale_t locale)
+{
+  return __xisblank(locale, c);
+}
+static inline
+int iscntrl_l(int c, locale_t locale)
+{
+  return __xiscntrl(locale, c);
+}
+static inline
+int isdigit_l(int c, locale_t locale)
+{
+  return __xisdigit(locale, c);
+}
+static inline
+int isgraph_l(int c, locale_t locale)
+{
+  return __xisgraph(locale, c);
+}
+static inline
+int islower_l(int c, locale_t locale)
+{
+  return __xislower(locale, c);
+}
+static inline
+int isprint_l(int c, locale_t locale)
+{
+  return __xisprint(locale, c);
+}
+
+static inline
+int ispunct_l(int c, locale_t locale)
+{
+  return __xispunct(locale, c);
+}
+static inline
+int isspace_l(int c, locale_t locale)
+{
+  return __xisspace(locale, c);
+}
+static inline
+int isupper_l(int c, locale_t locale)
+{
+  return __xisupper(locale, c);
+}
+
+static inline
+int isxdigit_l(int c, locale_t locale)
+{
+  return __xisxdigit(locale, c);
+}
+
+static inline
+int iswalnum_l(wchar_t wc, locale_t locale)
+{
+  return __xiswalnum(locale, wc); 
+}
+
+static inline
+int iswalpha_l(wchar_t wc, locale_t locale)
+{
+  return __xiswalpha(locale, wc);
+}
+
+static inline
+int iswblank_l(wchar_t wc, locale_t locale)
+{
+  return __xiswblank(locale, wc);
+}
+
+static inline
+int iswcntrl_l(wchar_t wc, locale_t locale)
+{
+  return __xiswcntrl(locale, wc);
+}
+
+static inline
+int iswdigit_l(wchar_t wc, locale_t locale)
+{
+  return __xiswdigit(locale, wc);
+}
+
+static inline
+int iswgraph_l(wchar_t wc, locale_t locale)
+{
+  return __xiswgraph(locale, wc);
+}
+
+static inline
+int iswlower_l(wchar_t wc, locale_t locale)
+{
+  return __xiswlower(locale, wc);
+}
+
+static inline
+int iswprint_l(wchar_t wc, locale_t locale)
+{
+  return __xiswprint(locale, wc);
+}
+
+static inline
+int iswpunct_l(wchar_t wc, locale_t locale)
+{
+  return __xiswpunct(locale, wc);
+}
+
+static inline
+int iswspace_l(wchar_t wc, locale_t locale)
+{
+  return __xiswspace(locale, wc);
+}
+
+static inline
+int iswupper_l(wchar_t wc, locale_t locale)
+{
+  return __xiswupper(locale, wc);
+}
+
+static inline
+int iswxdigit_l(wchar_t wc, locale_t locale)
+{
+  return __xiswxdigit(locale, wc);
+}
+
+static inline
+int iswctype_l(wint_t wc, wctype_t desc, locale_t locale)
+{
+  return __xiswctype(locale, wc, desc); 
+}
+
+static inline
+int toupper_l(int c, locale_t locale)
+{
+  return __xtoupper(locale, c);
+}
+static inline
+int tolower_l(int c, locale_t locale)
+{
+  return __xtolower(locale, c);
+}
+static inline
+wint_t towupper_l(wint_t wc, locale_t locale)
+{
+  return __xtowupper(locale, wc);
+}
+static inline
+wint_t towlower_l(wint_t wc, locale_t locale)
+{
+  return __xtowlower(locale, wc);
+}
+
+static inline
+int strcoll_l(const char *__s1, const char *__s2, locale_t locale)
+{
+  return __xstrcoll(locale, __s1, __s2);
+}
+static inline
+int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t locale)
+{
+  return __xwcscoll(locale, __s1, __s2);
+}
+static inline
+size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t locale)
+{
+  return __xstrxfrm(locale, __s1, __s2, __n);
+}
+
+static inline
+size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n,
+    locale_t locale)
+{
+  return __xwcsxfrm(locale, __ws1, __ws2, __n);
+}
+#endif // !defined(_AIX71)
+
+// strftime_l() is defined by POSIX. However, AIX 7.1 does not have it
+// implemented yet.
+static inline
+size_t strftime_l(char *__s, size_t __size, const char *__fmt,
+                  const struct tm *__tm, locale_t locale) {
+  return __xstrftime(locale, __s, __size, __fmt, __tm);
+}
+
+// The following are not POSIX routines.  These are quick-and-dirty hacks
+// to make things pretend to work
+static inline
+long long strtoll_l(const char *__nptr, char **__endptr,
+    int __base, locale_t locale) {
+  return strtoll(__nptr, __endptr, __base);
+}
+static inline
+long strtol_l(const char *__nptr, char **__endptr,
+    int __base, locale_t locale) {
+  return strtol(__nptr, __endptr, __base);
+}
+static inline
+long double strtold_l(const char *__nptr, char **__endptr,
+    locale_t locale) {
+  return strtold(__nptr, __endptr);
+}
+static inline
+unsigned long long strtoull_l(const char *__nptr, char **__endptr,
+    int __base, locale_t locale) {
+  return strtoull(__nptr, __endptr, __base);
+}
+static inline
+unsigned long strtoul_l(const char *__nptr, char **__endptr,
+    int __base, locale_t locale) {
+  return strtoul(__nptr, __endptr, __base);
+}
+
+static inline
+int vasprintf(char **strp, const char *fmt, va_list ap)
+{
+  const size_t buff_size = 256;
+  int str_size;
+  if ((*strp = (char *)malloc(buff_size)) == NULL)
+  {
+    return -1;
+  }
+  if ((str_size = vsnprintf(*strp, buff_size, fmt,  ap)) >= buff_size)
+  {
+    if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL)
+    {
+      return -1;
+    }
+    str_size = vsnprintf(*strp, str_size + 1, fmt,  ap);
+  }
+  return str_size;
+}  
+
+#ifdef __cplusplus
+}
+#endif
+#endif // defined(_AIX)
+#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H
diff --git a/final/include/support/solaris/floatingpoint.h b/final/include/support/solaris/floatingpoint.h
new file mode 100644
index 0000000..999d144
--- /dev/null
+++ b/final/include/support/solaris/floatingpoint.h
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#define atof sun_atof
+#define strtod sun_strtod
+#include_next "floatingpoint.h"
+#undef atof
+#undef strtod
diff --git a/final/include/support/solaris/wchar.h b/final/include/support/solaris/wchar.h
new file mode 100644
index 0000000..0e8e660
--- /dev/null
+++ b/final/include/support/solaris/wchar.h
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+#define iswalpha sun_iswalpha
+#define iswupper sun_iswupper
+#define iswlower sun_iswlower
+#define iswdigit sun_iswdigit
+#define iswxdigit sun_iswxdigit
+#define iswalnum sun_iswalnum
+#define iswspace sun_iswspace
+#define iswpunct sun_iswpunct
+#define iswprint sun_iswprint
+#define iswgraph sun_iswgraph
+#define iswcntrl sun_iswcntrl
+#define iswctype sun_iswctype
+#define towlower sun_towlower
+#define towupper sun_towupper
+#define wcswcs sun_wcswcs
+#define wcswidth sun_wcswidth
+#define wcwidth sun_wcwidth
+#define wctype sun_wctype
+#define _WCHAR_T 1
+#include_next "wchar.h"
+#undef iswalpha 
+#undef iswupper
+#undef iswlower
+#undef iswdigit
+#undef iswxdigit
+#undef iswalnum
+#undef iswspace
+#undef iswpunct
+#undef iswprint
+#undef iswgraph
+#undef iswcntrl
+#undef iswctype
+#undef towlower
+#undef towupper
+#undef wcswcs
+#undef wcswidth
+#undef wcwidth
+#undef wctype
diff --git a/final/include/support/solaris/xlocale.h b/final/include/support/solaris/xlocale.h
new file mode 100644
index 0000000..875a39a
--- /dev/null
+++ b/final/include/support/solaris/xlocale.h
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+////////////////////////////////////////////////////////////////////////////////
+// Minimal xlocale implementation for Solaris.  This implements the subset of
+// the xlocale APIs that libc++ depends on.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef __XLOCALE_H_INCLUDED
+#define __XLOCALE_H_INCLUDED
+
+#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);
+
+// FIXME: These are quick-and-dirty hacks to make things pretend to work
+static inline
+long long strtoll_l(const char *__nptr, char **__endptr,
+    int __base, locale_t __loc) {
+  return strtoll(__nptr, __endptr, __base);
+}
+static inline
+long strtol_l(const char *__nptr, char **__endptr,
+    int __base, locale_t __loc) {
+  return strtol(__nptr, __endptr, __base);
+}
+static inline
+long double strtold_l(const char *__nptr, char **__endptr,
+    locale_t __loc) {
+  return strtold(__nptr, __endptr);
+}
+static inline
+unsigned long long strtoull_l(const char *__nptr, char **__endptr,
+    int __base, locale_t __loc) {
+  return strtoull(__nptr, __endptr, __base);
+}
+static inline
+unsigned long strtoul_l(const char *__nptr, char **__endptr,
+    int __base, locale_t __loc) {
+  return strtoul(__nptr, __endptr, __base);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/final/include/support/win32/limits_win32.h b/final/include/support/win32/limits_win32.h
new file mode 100644
index 0000000..406cd30
--- /dev/null
+++ b/final/include/support/win32/limits_win32.h
@@ -0,0 +1,79 @@
+// -*- C++ -*-
+//===--------------------- support/win32/limits_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_LIMITS_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
+
+#if !defined(_LIBCPP_MSVCRT)
+#error "This header complements the Microsoft C Runtime library, and should not be included otherwise."
+#else
+
+#include <limits.h> // CHAR_BIT
+#include <float.h> // limit constants
+
+#if ! defined(__clang__)
+#define __CHAR_BIT__       CHAR_BIT
+
+#define __FLT_MANT_DIG__   FLT_MANT_DIG
+#define __FLT_DIG__        FLT_DIG
+#define __FLT_RADIX__      FLT_RADIX
+#define __FLT_MIN_EXP__    FLT_MIN_EXP
+#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
+#define __FLT_MAX_EXP__    FLT_MAX_EXP
+#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
+#define __FLT_MIN__        FLT_MIN
+#define __FLT_MAX__        FLT_MAX
+#define __FLT_EPSILON__    FLT_EPSILON
+// predefined by MinGW GCC
+#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F
+
+#define __DBL_MANT_DIG__   DBL_MANT_DIG
+#define __DBL_DIG__        DBL_DIG
+#define __DBL_RADIX__      DBL_RADIX
+#define __DBL_MIN_EXP__    DBL_MIN_EXP
+#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
+#define __DBL_MAX_EXP__    DBL_MAX_EXP
+#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
+#define __DBL_MIN__        DBL_MIN
+#define __DBL_MAX__        DBL_MAX
+#define __DBL_EPSILON__    DBL_EPSILON
+// predefined by MinGW GCC
+#define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L)
+
+#define __LDBL_MANT_DIG__   LDBL_MANT_DIG
+#define __LDBL_DIG__        LDBL_DIG
+#define __LDBL_RADIX__      LDBL_RADIX
+#define __LDBL_MIN_EXP__    LDBL_MIN_EXP
+#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
+#define __LDBL_MAX_EXP__    LDBL_MAX_EXP
+#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
+#define __LDBL_MIN__        LDBL_MIN
+#define __LDBL_MAX__        LDBL_MAX
+#define __LDBL_EPSILON__    LDBL_EPSILON
+// predefined by MinGW GCC
+#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+
+// __builtin replacements/workarounds
+#include <math.h> // HUGE_VAL
+#include <ymath.h> // internal MSVC header providing the needed functionality
+#define __builtin_huge_val()     HUGE_VAL
+#define __builtin_huge_valf()    _FInf._Float
+#define __builtin_huge_vall()    _LInf._Long_double
+#define __builtin_nan(__dummy)   _Nan._Double
+#define __builtin_nanf(__dummy)  _FNan._Float
+#define __builtin_nanl(__dummmy) _LNan._Long_double
+#define __builtin_nans(__dummy)  _Snan._Double
+#define __builtin_nansf(__dummy) _FSnan._Float
+#define __builtin_nansl(__dummy) _LSnan._Long_double
+#endif // ! defined(__clang__)
+
+#endif // _LIBCPP_MSVCRT
+
+#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
diff --git a/final/include/support/win32/locale_win32.h b/final/include/support/win32/locale_win32.h
new file mode 100644
index 0000000..f728d23
--- /dev/null
+++ b/final/include/support/win32/locale_win32.h
@@ -0,0 +1,129 @@
+// -*- C++ -*-
+//===--------------------- support/win32/locale_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_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
+
+// ctype mask table defined in msvcrt.dll
+extern "C" unsigned short  __declspec(dllimport) _ctype[];
+
+#include "support/win32/support.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);
+size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
+                    size_t len, mbstate_t *__restrict ps, locale_t loc );
+size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
+                  locale_t loc);
+size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
+                  size_t n, mbstate_t *__restrict ps, locale_t loc);
+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);
+wint_t btowc_l( int c, locale_t loc );
+int wctob_l( wint_t c, locale_t loc );
+typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
+typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
+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;
+}
+
+// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
+#define mbtowc_l _mbtowc_l
+#define strtoll_l _strtoi64_l
+#define strtoull_l _strtoui64_l
+// FIXME: current msvcrt does not know about long double
+#define strtold_l _strtod_l
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+islower_l(int c, _locale_t loc)
+{
+ return _islower_l((int)c, loc);
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+int
+isupper_l(int c, _locale_t loc)
+{
+ return _isupper_l((int)c, loc);
+}
+
+#define isdigit_l _isdigit_l
+#define isxdigit_l _isxdigit_l
+#define strcoll_l _strcoll_l
+#define strxfrm_l _strxfrm_l
+#define wcscoll_l _wcscoll_l
+#define wcsxfrm_l _wcsxfrm_l
+#define toupper_l _toupper_l
+#define tolower_l _tolower_l
+#define iswspace_l _iswspace_l
+#define iswprint_l _iswprint_l
+#define iswcntrl_l _iswcntrl_l
+#define iswupper_l _iswupper_l
+#define iswlower_l _iswlower_l
+#define iswalpha_l _iswalpha_l
+#define iswdigit_l _iswdigit_l
+#define iswpunct_l _iswpunct_l
+#define iswxdigit_l _iswxdigit_l
+#define towupper_l _towupper_l
+#define towlower_l _towlower_l
+#define strftime_l _strftime_l
+#define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
+#define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
+#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
+#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
+#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
+int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...);
+int asprintf_l( char **ret, locale_t loc, const char *format, ... );
+int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
+
+
+// not-so-pressing FIXME: use locale to determine blank characters
+inline int isblank_l( int c, locale_t /*loc*/ )
+{
+    return ( c == ' ' || c == '\t' );
+}
+inline int iswblank_l( wint_t c, locale_t /*loc*/ )
+{
+    return ( c == L' ' || c == L'\t' );
+}
+
+#if defined(_LIBCPP_MSVCRT)
+inline int isblank( int c, locale_t /*loc*/ )
+{ return ( c == ' ' || c == '\t' ); }
+inline int iswblank( wint_t c, locale_t /*loc*/ )
+{ return ( c == L' ' || c == L'\t' ); }
+#endif // _LIBCPP_MSVCRT
+#endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H
diff --git a/final/include/support/win32/math_win32.h b/final/include/support/win32/math_win32.h
new file mode 100644
index 0000000..c62c54e
--- /dev/null
+++ b/final/include/support/win32/math_win32.h
@@ -0,0 +1,115 @@
+// -*- C++ -*-
+//===---------------------- support/win32/math_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_MATH_WIN32_H
+#define _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
+
+#if !defined(_LIBCPP_MSVCRT)
+#error "This header complements Microsoft's C Runtime library, and should not be included otherwise."
+#else
+
+#include <math.h>
+#include <float.h> // _FPCLASS_PN etc.
+
+// Necessary?
+typedef float float_t;
+typedef double double_t;
+
+_LIBCPP_ALWAYS_INLINE bool isfinite( double num )
+{
+    return _finite(num) != 0;
+}
+_LIBCPP_ALWAYS_INLINE bool isinf( double num )
+{
+    return !isfinite(num) && !_isnan(num);
+}
+_LIBCPP_ALWAYS_INLINE bool isnan( double num )
+{
+    return _isnan(num) != 0;
+}
+_LIBCPP_ALWAYS_INLINE bool isnormal( double num )
+{
+    int class_ = _fpclass(num);
+    return class_ == _FPCLASS_NN || class_ == _FPCLASS_PN;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isgreater( double x, double y )
+{
+    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x > y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isgreaterequal( double x, double y )
+{
+    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x >= y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isless( double x, double y )
+{
+    if(_fpclass(x) == _FPCLASS_SNAN || _fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x < y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool islessequal( double x, double y )
+{
+    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x <= y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool islessgreater( double x, double y )
+{
+    if(::_fpclass(x) == _FPCLASS_SNAN || ::_fpclass(y) == _FPCLASS_SNAN) return false;
+    else return x < y || x > y;
+}
+
+_LIBCPP_ALWAYS_INLINE bool isunordered( double x, double y )
+{
+    return isnan(x) || isnan(y);
+}
+_LIBCPP_ALWAYS_INLINE bool signbit( double num )
+{
+    switch(_fpclass(num))
+    {
+        case _FPCLASS_SNAN:
+        case _FPCLASS_QNAN:
+        case _FPCLASS_NINF:
+        case _FPCLASS_NN:
+        case _FPCLASS_ND:
+        case _FPCLASS_NZ:
+            return true;
+        case _FPCLASS_PZ:
+        case _FPCLASS_PD:
+        case _FPCLASS_PN:
+        case _FPCLASS_PINF:
+            return false;
+    }
+    return false;
+}
+_LIBCPP_ALWAYS_INLINE float copysignf( float x, float y )
+{
+    return (signbit (x) != signbit (y) ? - x : x);
+}
+_LIBCPP_ALWAYS_INLINE double copysign( double x, double y )
+{
+    return ::_copysign(x,y);
+}
+_LIBCPP_ALWAYS_INLINE double copysignl( long double x, long double y )
+{
+    return ::_copysignl(x,y);
+}
+_LIBCPP_ALWAYS_INLINE int fpclassify( double num )
+{
+    return _fpclass(num);
+}
+
+#endif // _LIBCPP_MSVCRT
+
+#endif // _LIBCPP_SUPPORT_WIN32_MATH_WIN32_H
diff --git a/final/include/support/win32/support.h b/final/include/support/win32/support.h
new file mode 100644
index 0000000..bc96587
--- /dev/null
+++ b/final/include/support/win32/support.h
@@ -0,0 +1,203 @@
+// -*- C++ -*-
+//===----------------------- support/win32/support.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_SUPPORT_H
+#define _LIBCPP_SUPPORT_WIN32_SUPPORT_H
+
+// Functions and constants used in libc++ that
+// are missing from the Windows C library.
+
+#include <wchar.h> // mbstate_t
+#include <cstdarg> // va_ macros
+// "builtins" not implemented here for Clang or GCC as they provide
+// implementations. Assuming required for elsewhere else, certainly MSVC.
+#if defined(_LIBCPP_MSVC)
+#include <intrin.h>
+#endif
+#if defined(_LIBCPP_MSVCRT)
+#include <xlocinfo.h>
+#endif
+#define swprintf _snwprintf
+#define vswprintf _vsnwprintf
+
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+
+extern "C" {
+
+int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
+int asprintf(char **sptr, const char *__restrict fmt, ...);
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+                  size_t nmc, size_t len, mbstate_t *__restrict ps);
+size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
+                  size_t nwc, size_t len, mbstate_t *__restrict ps);
+}
+
+#if defined(_LIBCPP_MSVCRT)
+#define snprintf _snprintf
+#define atoll _atoi64
+#define strtoll _strtoi64
+#define strtoull _strtoui64
+#define wcstoll _wcstoi64
+#define wcstoull _wcstoui64
+_LIBCPP_ALWAYS_INLINE float strtof(const char *nptr, char **endptr)
+{
+  return _Stof(nptr, endptr, 0);
+}
+_LIBCPP_ALWAYS_INLINE double strtod(const char *nptr, char **endptr)
+{
+  return _Stod(nptr, endptr, 0);
+}
+_LIBCPP_ALWAYS_INLINE long double strtold(const char *nptr, char **endptr)
+{
+  return _Stold(nptr, endptr, 0);
+}
+
+#define _Exit _exit
+#endif
+
+#if defined(_LIBCPP_MSVC)
+
+// Bit builtin's make these assumptions when calling _BitScanForward/Reverse
+// etc. These assumptions are expected to be true for Win32/Win64 which this
+// file supports.
+static_assert(sizeof(unsigned long long) == 8, "");
+static_assert(sizeof(unsigned long) == 4, "");
+static_assert(sizeof(unsigned int) == 4, "");
+
+_LIBCPP_ALWAYS_INLINE int __builtin_popcount(unsigned int x)
+{
+  // Binary: 0101...
+  static const unsigned int m1 = 0x55555555;
+  // Binary: 00110011..
+  static const unsigned int m2 = 0x33333333;
+  // Binary:  4 zeros,  4 ones ...
+  static const unsigned int m4 = 0x0f0f0f0f;
+  // The sum of 256 to the power of 0,1,2,3...
+  static const unsigned int h01 = 0x01010101;
+  // Put count of each 2 bits into those 2 bits.
+  x -= (x >> 1) & m1;
+  // Put count of each 4 bits into those 4 bits.
+  x = (x & m2) + ((x >> 2) & m2);
+  // Put count of each 8 bits into those 8 bits.
+  x = (x + (x >> 4)) & m4;
+  // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24).
+  return (x * h01) >> 24;
+}
+
+_LIBCPP_ALWAYS_INLINE int __builtin_popcountl(unsigned long x)
+{
+  return __builtin_popcount(static_cast<int>(x));
+}
+
+_LIBCPP_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x)
+{
+  // Binary: 0101...
+  static const unsigned long long m1 = 0x5555555555555555;
+  // Binary: 00110011..
+  static const unsigned long long m2 = 0x3333333333333333;
+  // Binary:  4 zeros,  4 ones ...
+  static const unsigned long long m4 = 0x0f0f0f0f0f0f0f0f;
+  // The sum of 256 to the power of 0,1,2,3...
+  static const unsigned long long h01 = 0x0101010101010101;
+  // Put count of each 2 bits into those 2 bits.
+  x -= (x >> 1) & m1;
+  // Put count of each 4 bits into those 4 bits.
+  x = (x & m2) + ((x >> 2) & m2);
+  // Put count of each 8 bits into those 8 bits.
+  x = (x + (x >> 4)) & m4;
+  // Returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ...
+  return static_cast<int>((x * h01) >> 56);
+}
+
+// Returns the number of trailing 0-bits in x, starting at the least significant
+// bit position. If x is 0, the result is undefined.
+_LIBCPP_ALWAYS_INLINE int __builtin_ctzll(unsigned long long mask)
+{
+  unsigned long where;
+// Search from LSB to MSB for first set bit.
+// Returns zero if no set bit is found.
+#if defined(_WIN64)
+  if (_BitScanForward64(&where, mask))
+    return static_cast<int>(where);
+#elif defined(_WIN32)
+  // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
+  // Scan the Low Word.
+  if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
+    return static_cast<int>(where);
+  // Scan the High Word.
+  if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
+    return static_cast<int>(where + 32); // Create a bit offset from the LSB.
+#else
+#error "Implementation of __builtin_ctzll required"
+#endif
+  return 64;
+}
+
+_LIBCPP_ALWAYS_INLINE int __builtin_ctzl(unsigned long mask)
+{
+  unsigned long where;
+  // Search from LSB to MSB for first set bit.
+  // Returns zero if no set bit is found.
+  if (_BitScanForward(&where, mask))
+    return static_cast<int>(where);
+  return 32;
+}
+
+_LIBCPP_ALWAYS_INLINE int __builtin_ctz(unsigned int mask)
+{
+  // Win32 and Win64 expectations.
+  static_assert(sizeof(mask) == 4, "");
+  static_assert(sizeof(unsigned long) == 4, "");
+  return __builtin_ctzl(static_cast<unsigned long>(mask));
+}
+
+// Returns the number of leading 0-bits in x, starting at the most significant
+// bit position. If x is 0, the result is undefined.
+_LIBCPP_ALWAYS_INLINE int __builtin_clzll(unsigned long long mask)
+{
+  unsigned long where;
+// BitScanReverse scans from MSB to LSB for first set bit.
+// Returns 0 if no set bit is found.
+#if defined(_WIN64)
+  if (_BitScanReverse64(&where, mask))
+    return static_cast<int>(63 - where);
+#elif defined(_WIN32)
+  // Scan the high 32 bits.
+  if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
+    return static_cast<int>(63 -
+                            (where + 32)); // Create a bit offset from the MSB.
+  // Scan the low 32 bits.
+  if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
+    return static_cast<int>(63 - where);
+#else
+#error "Implementation of __builtin_clzll required"
+#endif
+  return 64; // Undefined Behavior.
+}
+
+_LIBCPP_ALWAYS_INLINE int __builtin_clzl(unsigned long mask)
+{
+  unsigned long where;
+  // Search from LSB to MSB for first set bit.
+  // Returns zero if no set bit is found.
+  if (_BitScanReverse(&where, mask))
+    return static_cast<int>(31 - where);
+  return 32; // Undefined Behavior.
+}
+
+_LIBCPP_ALWAYS_INLINE int __builtin_clz(unsigned int x)
+{
+  return __builtin_clzl(x);
+}
+#endif // _LIBCPP_MSVC
+
+#endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H
diff --git a/final/include/system_error b/final/include/system_error
new file mode 100644
index 0000000..66bf6d6
--- /dev/null
+++ b/final/include/system_error
@@ -0,0 +1,642 @@
+// -*- 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_SYSTEM_ERROR
+#define _LIBCPP_SYSTEM_ERROR
+
+/*
+    system_error synopsis
+
+namespace std
+{
+
+class error_category
+{
+public:
+    virtual ~error_category() noexcept;
+
+    constexpr error_category();
+    error_category(const error_category&) = delete;
+    error_category& operator=(const error_category&) = delete;
+
+    virtual const char* name() const noexcept = 0;
+    virtual error_condition default_error_condition(int ev) const noexcept;
+    virtual bool equivalent(int code, const error_condition& condition) const noexcept;
+    virtual bool equivalent(const error_code& code, int condition) const noexcept;
+    virtual string message(int ev) const = 0;
+
+    bool operator==(const error_category& rhs) const noexcept;
+    bool operator!=(const error_category& rhs) const noexcept;
+    bool operator<(const error_category& rhs) const noexcept;
+};
+
+const error_category& generic_category() noexcept;
+const error_category& system_category() noexcept;
+
+template <class T> struct is_error_code_enum
+    : public false_type {};
+
+template <class T> struct is_error_condition_enum
+    : public false_type {};
+
+class error_code
+{
+public:
+    // constructors:
+    error_code() noexcept;
+    error_code(int val, const error_category& cat) noexcept;
+    template <class ErrorCodeEnum>
+        error_code(ErrorCodeEnum e) noexcept;
+
+    // modifiers:
+    void assign(int val, const error_category& cat) noexcept;
+    template <class ErrorCodeEnum>
+        error_code& operator=(ErrorCodeEnum e) noexcept;
+    void clear() noexcept;
+
+    // observers:
+    int value() const noexcept;
+    const error_category& category() const noexcept;
+    error_condition default_error_condition() const noexcept;
+    string message() const;
+    explicit operator bool() const noexcept;
+};
+
+// non-member functions:
+bool operator<(const error_code& lhs, const error_code& rhs) noexcept;
+template <class charT, class traits>
+    basic_ostream<charT,traits>&
+    operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
+
+class error_condition
+{
+public:
+    // constructors:
+    error_condition() noexcept;
+    error_condition(int val, const error_category& cat) noexcept;
+    template <class ErrorConditionEnum>
+        error_condition(ErrorConditionEnum e) noexcept;
+
+    // modifiers:
+    void assign(int val, const error_category& cat) noexcept;
+    template <class ErrorConditionEnum>
+        error_condition& operator=(ErrorConditionEnum e) noexcept;
+    void clear() noexcept;
+
+    // observers:
+    int value() const noexcept;
+    const error_category& category() const noexcept;
+    string message() const noexcept;
+    explicit operator bool() const noexcept;
+};
+
+bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
+
+class system_error
+    : public runtime_error
+{
+public:
+    system_error(error_code ec, const string& what_arg);
+    system_error(error_code ec, const char* what_arg);
+    system_error(error_code ec);
+    system_error(int ev, const error_category& ecat, const string& what_arg);
+    system_error(int ev, const error_category& ecat, const char* what_arg);
+    system_error(int ev, const error_category& ecat);
+
+    const error_code& code() const noexcept;
+    const char* what() const noexcept;
+};
+
+enum class errc
+{
+    address_family_not_supported,       // EAFNOSUPPORT
+    address_in_use,                     // EADDRINUSE
+    address_not_available,              // EADDRNOTAVAIL
+    already_connected,                  // EISCONN
+    argument_list_too_long,             // E2BIG
+    argument_out_of_domain,             // EDOM
+    bad_address,                        // EFAULT
+    bad_file_descriptor,                // EBADF
+    bad_message,                        // EBADMSG
+    broken_pipe,                        // EPIPE
+    connection_aborted,                 // ECONNABORTED
+    connection_already_in_progress,     // EALREADY
+    connection_refused,                 // ECONNREFUSED
+    connection_reset,                   // ECONNRESET
+    cross_device_link,                  // EXDEV
+    destination_address_required,       // EDESTADDRREQ
+    device_or_resource_busy,            // EBUSY
+    directory_not_empty,                // ENOTEMPTY
+    executable_format_error,            // ENOEXEC
+    file_exists,                        // EEXIST
+    file_too_large,                     // EFBIG
+    filename_too_long,                  // ENAMETOOLONG
+    function_not_supported,             // ENOSYS
+    host_unreachable,                   // EHOSTUNREACH
+    identifier_removed,                 // EIDRM
+    illegal_byte_sequence,              // EILSEQ
+    inappropriate_io_control_operation, // ENOTTY
+    interrupted,                        // EINTR
+    invalid_argument,                   // EINVAL
+    invalid_seek,                       // ESPIPE
+    io_error,                           // EIO
+    is_a_directory,                     // EISDIR
+    message_size,                       // EMSGSIZE
+    network_down,                       // ENETDOWN
+    network_reset,                      // ENETRESET
+    network_unreachable,                // ENETUNREACH
+    no_buffer_space,                    // ENOBUFS
+    no_child_process,                   // ECHILD
+    no_link,                            // ENOLINK
+    no_lock_available,                  // ENOLCK
+    no_message_available,               // ENODATA
+    no_message,                         // ENOMSG
+    no_protocol_option,                 // ENOPROTOOPT
+    no_space_on_device,                 // ENOSPC
+    no_stream_resources,                // ENOSR
+    no_such_device_or_address,          // ENXIO
+    no_such_device,                     // ENODEV
+    no_such_file_or_directory,          // ENOENT
+    no_such_process,                    // ESRCH
+    not_a_directory,                    // ENOTDIR
+    not_a_socket,                       // ENOTSOCK
+    not_a_stream,                       // ENOSTR
+    not_connected,                      // ENOTCONN
+    not_enough_memory,                  // ENOMEM
+    not_supported,                      // ENOTSUP
+    operation_canceled,                 // ECANCELED
+    operation_in_progress,              // EINPROGRESS
+    operation_not_permitted,            // EPERM
+    operation_not_supported,            // EOPNOTSUPP
+    operation_would_block,              // EWOULDBLOCK
+    owner_dead,                         // EOWNERDEAD
+    permission_denied,                  // EACCES
+    protocol_error,                     // EPROTO
+    protocol_not_supported,             // EPROTONOSUPPORT
+    read_only_file_system,              // EROFS
+    resource_deadlock_would_occur,      // EDEADLK
+    resource_unavailable_try_again,     // EAGAIN
+    result_out_of_range,                // ERANGE
+    state_not_recoverable,              // ENOTRECOVERABLE
+    stream_timeout,                     // ETIME
+    text_file_busy,                     // ETXTBSY
+    timed_out,                          // ETIMEDOUT
+    too_many_files_open_in_system,      // ENFILE
+    too_many_files_open,                // EMFILE
+    too_many_links,                     // EMLINK
+    too_many_symbolic_link_levels,      // ELOOP
+    value_too_large,                    // EOVERFLOW
+    wrong_protocol_type                 // EPROTOTYPE
+};
+
+template <> struct is_error_condition_enum<errc>
+    : true_type { }
+
+error_code make_error_code(errc e) noexcept;
+error_condition make_error_condition(errc e) noexcept;
+
+// Comparison operators:
+bool operator==(const error_code& lhs, const error_code& rhs) noexcept;
+bool operator==(const error_code& lhs, const error_condition& rhs) noexcept;
+bool operator==(const error_condition& lhs, const error_code& rhs) noexcept;
+bool operator==(const error_condition& lhs, const error_condition& rhs) noexcept;
+bool operator!=(const error_code& lhs, const error_code& rhs) noexcept;
+bool operator!=(const error_code& lhs, const error_condition& rhs) noexcept;
+bool operator!=(const error_condition& lhs, const error_code& rhs) noexcept;
+bool operator!=(const error_condition& lhs, const error_condition& rhs) noexcept;
+
+template <> struct hash<std::error_code>;
+
+}  // std
+
+*/
+
+#include <__config>
+#include <cerrno>
+#include <type_traits>
+#include <stdexcept>
+#include <__functional_base>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// is_error_code_enum
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum
+    : public false_type {};
+
+// is_error_condition_enum
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum
+    : public false_type {};
+
+// Some error codes are not present on all platforms, so we provide equivalents
+// for them:
+
+//enum class errc
+_LIBCPP_DECLARE_STRONG_ENUM(errc)
+{
+    address_family_not_supported        = EAFNOSUPPORT,
+    address_in_use                      = EADDRINUSE,
+    address_not_available               = EADDRNOTAVAIL,
+    already_connected                   = EISCONN,
+    argument_list_too_long              = E2BIG,
+    argument_out_of_domain              = EDOM,
+    bad_address                         = EFAULT,
+    bad_file_descriptor                 = EBADF,
+    bad_message                         = EBADMSG,
+    broken_pipe                         = EPIPE,
+    connection_aborted                  = ECONNABORTED,
+    connection_already_in_progress      = EALREADY,
+    connection_refused                  = ECONNREFUSED,
+    connection_reset                    = ECONNRESET,
+    cross_device_link                   = EXDEV,
+    destination_address_required        = EDESTADDRREQ,
+    device_or_resource_busy             = EBUSY,
+    directory_not_empty                 = ENOTEMPTY,
+    executable_format_error             = ENOEXEC,
+    file_exists                         = EEXIST,
+    file_too_large                      = EFBIG,
+    filename_too_long                   = ENAMETOOLONG,
+    function_not_supported              = ENOSYS,
+    host_unreachable                    = EHOSTUNREACH,
+    identifier_removed                  = EIDRM,
+    illegal_byte_sequence               = EILSEQ,
+    inappropriate_io_control_operation  = ENOTTY,
+    interrupted                         = EINTR,
+    invalid_argument                    = EINVAL,
+    invalid_seek                        = ESPIPE,
+    io_error                            = EIO,
+    is_a_directory                      = EISDIR,
+    message_size                        = EMSGSIZE,
+    network_down                        = ENETDOWN,
+    network_reset                       = ENETRESET,
+    network_unreachable                 = ENETUNREACH,
+    no_buffer_space                     = ENOBUFS,
+    no_child_process                    = ECHILD,
+    no_link                             = ENOLINK,
+    no_lock_available                   = ENOLCK,
+#ifdef ENODATA
+    no_message_available                = ENODATA,
+#else
+    no_message_available                = ENOMSG,
+#endif
+    no_message                          = ENOMSG,
+    no_protocol_option                  = ENOPROTOOPT,
+    no_space_on_device                  = ENOSPC,
+#ifdef ENOSR
+    no_stream_resources                 = ENOSR,
+#else
+    no_stream_resources                 = ENOMEM,
+#endif
+    no_such_device_or_address           = ENXIO,
+    no_such_device                      = ENODEV,
+    no_such_file_or_directory           = ENOENT,
+    no_such_process                     = ESRCH,
+    not_a_directory                     = ENOTDIR,
+    not_a_socket                        = ENOTSOCK,
+#ifdef ENOSTR
+    not_a_stream                        = ENOSTR,
+#else
+    not_a_stream                        = EINVAL,
+#endif
+    not_connected                       = ENOTCONN,
+    not_enough_memory                   = ENOMEM,
+    not_supported                       = ENOTSUP,
+    operation_canceled                  = ECANCELED,
+    operation_in_progress               = EINPROGRESS,
+    operation_not_permitted             = EPERM,
+    operation_not_supported             = EOPNOTSUPP,
+    operation_would_block               = EWOULDBLOCK,
+    owner_dead                          = EOWNERDEAD,
+    permission_denied                   = EACCES,
+    protocol_error                      = EPROTO,
+    protocol_not_supported              = EPROTONOSUPPORT,
+    read_only_file_system               = EROFS,
+    resource_deadlock_would_occur       = EDEADLK,
+    resource_unavailable_try_again      = EAGAIN,
+    result_out_of_range                 = ERANGE,
+    state_not_recoverable               = ENOTRECOVERABLE,
+#ifdef ETIME
+    stream_timeout                      = ETIME,
+#else
+    stream_timeout                      = ETIMEDOUT,
+#endif
+    text_file_busy                      = ETXTBSY,
+    timed_out                           = ETIMEDOUT,
+    too_many_files_open_in_system       = ENFILE,
+    too_many_files_open                 = EMFILE,
+    too_many_links                      = EMLINK,
+    too_many_symbolic_link_levels       = ELOOP,
+    value_too_large                     = EOVERFLOW,
+    wrong_protocol_type                 = EPROTOTYPE
+};
+_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc>
+    : true_type { };
+
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc::__lx>
+    : true_type { };
+#endif
+
+class _LIBCPP_TYPE_VIS error_condition;
+class _LIBCPP_TYPE_VIS error_code;
+
+// class error_category
+
+class _LIBCPP_HIDDEN __do_message;
+
+class _LIBCPP_TYPE_VIS error_category
+{
+public:
+    virtual ~error_category() _NOEXCEPT;
+
+#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR
+    error_category() _NOEXCEPT;
+#else
+    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT;
+#endif
+private:
+    error_category(const error_category&);// = delete;
+    error_category& operator=(const error_category&);// = delete;
+
+public:
+    virtual const char* name() const _NOEXCEPT = 0;
+    virtual error_condition default_error_condition(int __ev) const _NOEXCEPT;
+    virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT;
+    virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT;
+    virtual string message(int __ev) const = 0;
+
+    _LIBCPP_ALWAYS_INLINE
+    bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
+
+    _LIBCPP_ALWAYS_INLINE
+    bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
+
+    _LIBCPP_ALWAYS_INLINE
+    bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
+
+    friend class _LIBCPP_HIDDEN __do_message;
+};
+
+class _LIBCPP_HIDDEN __do_message
+    : public error_category
+{
+public:
+    virtual string message(int ev) const;
+};
+
+_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
+_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT;
+
+class _LIBCPP_TYPE_VIS error_condition
+{
+    int __val_;
+    const error_category* __cat_;
+public:
+    _LIBCPP_ALWAYS_INLINE
+    error_condition() _NOEXCEPT : __val_(0), __cat_(&generic_category()) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    error_condition(int __val, const error_category& __cat) _NOEXCEPT
+        : __val_(__val), __cat_(&__cat) {}
+
+    template <class _Ep>
+        _LIBCPP_ALWAYS_INLINE
+        error_condition(_Ep __e,
+              typename enable_if<is_error_condition_enum<_Ep>::value>::type* = 0
+                                                                     ) _NOEXCEPT
+            {*this = make_error_condition(__e);}
+
+    _LIBCPP_ALWAYS_INLINE
+    void assign(int __val, const error_category& __cat) _NOEXCEPT
+    {
+        __val_ = __val;
+        __cat_ = &__cat;
+    }
+
+    template <class _Ep>
+        _LIBCPP_ALWAYS_INLINE
+        typename enable_if
+        <
+            is_error_condition_enum<_Ep>::value,
+            error_condition&
+        >::type
+        operator=(_Ep __e) _NOEXCEPT
+            {*this = make_error_condition(__e); return *this;}
+
+    _LIBCPP_ALWAYS_INLINE
+    void clear() _NOEXCEPT
+    {
+        __val_ = 0;
+        __cat_ = &generic_category();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int value() const _NOEXCEPT {return __val_;}
+
+    _LIBCPP_ALWAYS_INLINE
+    const error_category& category() const _NOEXCEPT {return *__cat_;}
+    string message() const;
+
+    _LIBCPP_ALWAYS_INLINE
+        _LIBCPP_EXPLICIT
+        operator bool() const _NOEXCEPT {return __val_ != 0;}
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_condition
+make_error_condition(errc __e) _NOEXCEPT
+{
+    return error_condition(static_cast<int>(__e), generic_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const error_condition& __x, const error_condition& __y) _NOEXCEPT
+{
+    return __x.category() < __y.category()
+        || (__x.category() == __y.category() && __x.value() < __y.value());
+}
+
+// error_code
+
+class _LIBCPP_TYPE_VIS error_code
+{
+    int __val_;
+    const error_category* __cat_;
+public:
+    _LIBCPP_ALWAYS_INLINE
+    error_code() _NOEXCEPT : __val_(0), __cat_(&system_category()) {}
+
+    _LIBCPP_ALWAYS_INLINE
+    error_code(int __val, const error_category& __cat) _NOEXCEPT
+        : __val_(__val), __cat_(&__cat) {}
+
+    template <class _Ep>
+        _LIBCPP_ALWAYS_INLINE
+        error_code(_Ep __e,
+                   typename enable_if<is_error_code_enum<_Ep>::value>::type* = 0
+                                                                     ) _NOEXCEPT
+            {*this = make_error_code(__e);}
+
+    _LIBCPP_ALWAYS_INLINE
+    void assign(int __val, const error_category& __cat) _NOEXCEPT
+    {
+        __val_ = __val;
+        __cat_ = &__cat;
+    }
+
+    template <class _Ep>
+        _LIBCPP_ALWAYS_INLINE
+        typename enable_if
+        <
+            is_error_code_enum<_Ep>::value,
+            error_code&
+        >::type
+        operator=(_Ep __e) _NOEXCEPT
+            {*this = make_error_code(__e); return *this;}
+
+    _LIBCPP_ALWAYS_INLINE
+    void clear() _NOEXCEPT
+    {
+        __val_ = 0;
+        __cat_ = &system_category();
+    }
+
+    _LIBCPP_ALWAYS_INLINE
+    int value() const _NOEXCEPT {return __val_;}
+
+    _LIBCPP_ALWAYS_INLINE
+    const error_category& category() const _NOEXCEPT {return *__cat_;}
+
+    _LIBCPP_ALWAYS_INLINE
+    error_condition default_error_condition() const _NOEXCEPT
+        {return __cat_->default_error_condition(__val_);}
+
+    string message() const;
+
+    _LIBCPP_ALWAYS_INLINE
+        _LIBCPP_EXPLICIT
+        operator bool() const _NOEXCEPT {return __val_ != 0;}
+};
+
+inline _LIBCPP_INLINE_VISIBILITY
+error_code
+make_error_code(errc __e) _NOEXCEPT
+{
+    return error_code(static_cast<int>(__e), generic_category());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<(const error_code& __x, const error_code& __y) _NOEXCEPT
+{
+    return __x.category() < __y.category()
+        || (__x.category() == __y.category() && __x.value() < __y.value());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_code& __x, const error_code& __y) _NOEXCEPT
+{
+    return __x.category() == __y.category() && __x.value() == __y.value();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_code& __x, const error_condition& __y) _NOEXCEPT
+{
+    return __x.category().equivalent(__x.value(), __y)
+        || __y.category().equivalent(__x, __y.value());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
+{
+    return __y == __x;
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
+{
+    return __x.category() == __y.category() && __x.value() == __y.value();
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_code& __x, const error_condition& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_condition& __x, const error_code& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT
+{return !(__x == __y);}
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<error_code>
+    : public unary_function<error_code, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const error_code& __ec) const _NOEXCEPT
+    {
+        return static_cast<size_t>(__ec.value());
+    }
+};
+
+// system_error
+
+class _LIBCPP_TYPE_VIS system_error
+    : public runtime_error
+{
+    error_code __ec_;
+public:
+    system_error(error_code __ec, const string& __what_arg);
+    system_error(error_code __ec, const char* __what_arg);
+    system_error(error_code __ec);
+    system_error(int __ev, const error_category& __ecat, const string& __what_arg);
+    system_error(int __ev, const error_category& __ecat, const char* __what_arg);
+    system_error(int __ev, const error_category& __ecat);
+    ~system_error() _NOEXCEPT;
+
+    _LIBCPP_ALWAYS_INLINE
+    const error_code& code() const _NOEXCEPT {return __ec_;}
+
+private:
+    static string __init(const error_code&, string);
+};
+
+_LIBCPP_FUNC_VIS void __throw_system_error(int ev, const char* what_arg);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_SYSTEM_ERROR
diff --git a/final/include/tgmath.h b/final/include/tgmath.h
new file mode 100644
index 0000000..fbe1e82
--- /dev/null
+++ b/final/include/tgmath.h
@@ -0,0 +1,29 @@
+// -*- C++ -*-
+//===-------------------------- tgmath.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_TGMATH_H
+#define _LIBCPP_TGMATH_H
+
+/*
+    tgmath.h synopsis
+
+#include <complex.h>
+#include <math.h>
+
+*/
+
+#include <complex.h>
+#include <math.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#endif  // _LIBCPP_TGMATH_H
diff --git a/final/include/thread b/final/include/thread
new file mode 100644
index 0000000..1f1e4a2
--- /dev/null
+++ b/final/include/thread
@@ -0,0 +1,458 @@
+// -*- C++ -*-
+//===--------------------------- thread -----------------------------------===//
+//
+//                     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_THREAD
+#define _LIBCPP_THREAD
+
+/*
+
+    thread synopsis
+
+#define __STDCPP_THREADS__ __cplusplus
+
+namespace std
+{
+
+class thread
+{
+public:
+    class id;
+    typedef pthread_t native_handle_type;
+
+    thread() noexcept;
+    template <class F, class ...Args> explicit thread(F&& f, Args&&... args);
+    ~thread();
+
+    thread(const thread&) = delete;
+    thread(thread&& t) noexcept;
+
+    thread& operator=(const thread&) = delete;
+    thread& operator=(thread&& t) noexcept;
+
+    void swap(thread& t) noexcept;
+
+    bool joinable() const noexcept;
+    void join();
+    void detach();
+    id get_id() const noexcept;
+    native_handle_type native_handle();
+
+    static unsigned hardware_concurrency() noexcept;
+};
+
+void swap(thread& x, thread& y) noexcept;
+
+class thread::id
+{
+public:
+    id() noexcept;
+};
+
+bool operator==(thread::id x, thread::id y) noexcept;
+bool operator!=(thread::id x, thread::id y) noexcept;
+bool operator< (thread::id x, thread::id y) noexcept;
+bool operator<=(thread::id x, thread::id y) noexcept;
+bool operator> (thread::id x, thread::id y) noexcept;
+bool operator>=(thread::id x, thread::id y) noexcept;
+
+template<class charT, class traits>
+basic_ostream<charT, traits>&
+operator<<(basic_ostream<charT, traits>& out, thread::id id);
+
+namespace this_thread
+{
+
+thread::id get_id() noexcept;
+
+void yield() noexcept;
+
+template <class Clock, class Duration>
+void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+template <class Rep, class Period>
+void sleep_for(const chrono::duration<Rep, Period>& rel_time);
+
+}  // this_thread
+
+}  // std
+
+*/
+
+#include <__config>
+#include <iosfwd>
+#include <__functional_base>
+#include <type_traits>
+#include <cstddef>
+#include <functional>
+#include <memory>
+#include <system_error>
+#include <chrono>
+#include <__mutex_base>
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+#include <tuple>
+#endif
+#include <pthread.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#define __STDCPP_THREADS__ __cplusplus
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+class __thread_specific_ptr
+{
+    pthread_key_t __key_;
+
+    __thread_specific_ptr(const __thread_specific_ptr&);
+    __thread_specific_ptr& operator=(const __thread_specific_ptr&);
+
+    static void __at_thread_exit(void*);
+public:
+    typedef _Tp* pointer;
+
+    __thread_specific_ptr();
+    ~__thread_specific_ptr();
+
+    _LIBCPP_INLINE_VISIBILITY
+    pointer get() const {return static_cast<_Tp*>(pthread_getspecific(__key_));}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator*() const {return *get();}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return get();}
+    pointer release();
+    void reset(pointer __p = nullptr);
+};
+
+template <class _Tp>
+void
+__thread_specific_ptr<_Tp>::__at_thread_exit(void* __p)
+{
+    delete static_cast<pointer>(__p);
+}
+
+template <class _Tp>
+__thread_specific_ptr<_Tp>::__thread_specific_ptr()
+{
+    int __ec = pthread_key_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__ec)
+        throw system_error(error_code(__ec, system_category()),
+                           "__thread_specific_ptr construction failed");
+#endif
+}
+
+template <class _Tp>
+__thread_specific_ptr<_Tp>::~__thread_specific_ptr()
+{
+    pthread_key_delete(__key_);
+}
+
+template <class _Tp>
+typename __thread_specific_ptr<_Tp>::pointer
+__thread_specific_ptr<_Tp>::release()
+{
+    pointer __p = get();
+    pthread_setspecific(__key_, 0);
+    return __p;
+}
+
+template <class _Tp>
+void
+__thread_specific_ptr<_Tp>::reset(pointer __p)
+{
+    pointer __p_old = get();
+    pthread_setspecific(__key_, __p);
+    delete __p_old;
+}
+
+class _LIBCPP_TYPE_VIS thread;
+class _LIBCPP_TYPE_VIS __thread_id;
+
+namespace this_thread
+{
+
+_LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT;
+
+}  // this_thread
+
+template<> struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>;
+
+class _LIBCPP_TYPE_VIS_ONLY __thread_id
+{
+    // FIXME: pthread_t is a pointer on Darwin but a long on Linux.
+    // NULL is the no-thread value on Darwin.  Someone needs to check
+    // on other platforms.  We assume 0 works everywhere for now.
+    pthread_t __id_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __thread_id() _NOEXCEPT : __id_(0) {}
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT
+        {return __x.__id_ == __y.__id_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(__thread_id __x, __thread_id __y) _NOEXCEPT
+        {return !(__x == __y);}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator< (__thread_id __x, __thread_id __y) _NOEXCEPT
+        {return __x.__id_ < __y.__id_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator<=(__thread_id __x, __thread_id __y) _NOEXCEPT
+        {return !(__y < __x);}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator> (__thread_id __x, __thread_id __y) _NOEXCEPT
+        {return   __y < __x ;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator>=(__thread_id __x, __thread_id __y) _NOEXCEPT
+        {return !(__x < __y);}
+
+    template<class _CharT, class _Traits>
+    friend
+    _LIBCPP_INLINE_VISIBILITY
+    basic_ostream<_CharT, _Traits>&
+    operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id)
+        {return __os << __id.__id_;}
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    __thread_id(pthread_t __id) : __id_(__id) {}
+
+    friend __thread_id this_thread::get_id() _NOEXCEPT;
+    friend class _LIBCPP_TYPE_VIS thread;
+    friend struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>;
+};
+
+template<>
+struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>
+    : public unary_function<__thread_id, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(__thread_id __v) const
+    {
+        return hash<pthread_t>()(__v.__id_);
+    }
+};
+
+namespace this_thread
+{
+
+inline _LIBCPP_INLINE_VISIBILITY
+__thread_id
+get_id() _NOEXCEPT
+{
+    return pthread_self();
+}
+
+}  // this_thread
+
+class _LIBCPP_TYPE_VIS thread
+{
+    pthread_t __t_;
+
+    thread(const thread&);
+    thread& operator=(const thread&);
+public:
+    typedef __thread_id id;
+    typedef pthread_t native_handle_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    thread() _NOEXCEPT : __t_(0) {}
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class _Fp, class ..._Args,
+              class = typename enable_if
+              <
+                   !is_same<typename decay<_Fp>::type, thread>::value
+              >::type
+             >
+        explicit thread(_Fp&& __f, _Args&&... __args);
+#else  // _LIBCPP_HAS_NO_VARIADICS
+    template <class _Fp> explicit thread(_Fp __f);
+#endif
+    ~thread();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = 0;}
+    thread& operator=(thread&& __t) _NOEXCEPT;
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(thread& __t) _NOEXCEPT {_VSTD::swap(__t_, __t.__t_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool joinable() const _NOEXCEPT {return __t_ != 0;}
+    void join();
+    void detach();
+    _LIBCPP_INLINE_VISIBILITY
+    id get_id() const _NOEXCEPT {return __t_;}
+    _LIBCPP_INLINE_VISIBILITY
+    native_handle_type native_handle() _NOEXCEPT {return __t_;}
+
+    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>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__thread_execute(tuple<_Fp, _Args...>& __t, __tuple_indices<_Indices...>)
+{
+    __invoke(_VSTD::move(_VSTD::get<0>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
+}
+
+template <class _Fp>
+void*
+__thread_proxy(void* __vp)
+{
+    __thread_local_data().reset(new __thread_struct);
+    std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+    typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index;
+    __thread_execute(*__p, _Index());
+    return nullptr;
+}
+
+template <class _Fp, class ..._Args,
+          class
+         >
+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))...));
+    int __ec = pthread_create(&__t_, 0, &__thread_proxy<_Gp>, __p.get());
+    if (__ec == 0)
+        __p.release();
+    else
+        __throw_system_error(__ec, "thread constructor failed");
+}
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Fp>
+void*
+__thread_proxy(void* __vp)
+{
+    __thread_local_data().reset(new __thread_struct);
+    std::unique_ptr<_Fp> __p(static_cast<_Fp*>(__vp));
+    (*__p)();
+    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());
+    if (__ec == 0)
+        __p.release();
+    else
+        __throw_system_error(__ec, "thread constructor failed");
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+inline _LIBCPP_INLINE_VISIBILITY
+thread&
+thread::operator=(thread&& __t) _NOEXCEPT
+{
+    if (__t_ != 0)
+        terminate();
+    __t_ = __t.__t_;
+    __t.__t_ = 0;
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+inline _LIBCPP_INLINE_VISIBILITY
+void swap(thread& __x, thread& __y) _NOEXCEPT {__x.swap(__y);}
+
+namespace this_thread
+{
+
+_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& ns);
+
+template <class _Rep, class _Period>
+void
+sleep_for(const chrono::duration<_Rep, _Period>& __d)
+{
+    using namespace chrono;
+    if (__d > duration<_Rep, _Period>::zero())
+    {
+        _LIBCPP_CONSTEXPR duration<long double> _Max = nanoseconds::max();
+        nanoseconds __ns;
+        if (__d < _Max)
+        {
+            __ns = duration_cast<nanoseconds>(__d);
+            if (__ns < __d)
+                ++__ns;
+        }
+        else
+            __ns = nanoseconds::max();
+        sleep_for(__ns);
+    }
+}
+
+template <class _Clock, class _Duration>
+void
+sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
+{
+    using namespace chrono;
+    mutex __mut;
+    condition_variable __cv;
+    unique_lock<mutex> __lk(__mut);
+    while (_Clock::now() < __t)
+        __cv.wait_until(__lk, __t);
+}
+
+template <class _Duration>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t)
+{
+    using namespace chrono;
+    sleep_for(__t - steady_clock::now());
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+void yield() _NOEXCEPT {sched_yield();}
+
+}  // this_thread
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_THREAD
diff --git a/final/include/tuple b/final/include/tuple
new file mode 100644
index 0000000..e98ae72
--- /dev/null
+++ b/final/include/tuple
@@ -0,0 +1,1100 @@
+// -*- C++ -*-
+//===--------------------------- tuple ------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_TUPLE
+#define _LIBCPP_TUPLE
+
+/*
+    tuple synopsis
+
+namespace std
+{
+
+template <class... T>
+class tuple {
+public:
+    constexpr tuple();
+    explicit tuple(const T&...);  // constexpr in C++14
+    template <class... U>
+        explicit tuple(U&&...);  // constexpr in C++14
+    tuple(const tuple&) = default;
+    tuple(tuple&&) = default;
+    template <class... U>
+        tuple(const tuple<U...>&);  // constexpr in C++14
+    template <class... U>
+        tuple(tuple<U...>&&);  // constexpr in C++14
+    template <class U1, class U2>
+        tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
+    template <class U1, class U2>
+        tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2  // constexpr in C++14
+
+    // allocator-extended constructors
+    template <class Alloc>
+        tuple(allocator_arg_t, const Alloc& a);
+    template <class Alloc>
+        tuple(allocator_arg_t, const Alloc& a, const T&...);
+    template <class Alloc, class... U>
+        tuple(allocator_arg_t, const Alloc& a, U&&...);
+    template <class Alloc>
+        tuple(allocator_arg_t, const Alloc& a, const tuple&);
+    template <class Alloc>
+        tuple(allocator_arg_t, const Alloc& a, tuple&&);
+    template <class Alloc, class... U>
+        tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
+    template <class Alloc, class... U>
+        tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
+    template <class Alloc, class U1, class U2>
+        tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
+    template <class Alloc, class U1, class U2>
+        tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
+
+    tuple& operator=(const tuple&);
+    tuple&
+        operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
+    template <class... U>
+        tuple& operator=(const tuple<U...>&);
+    template <class... U>
+        tuple& operator=(tuple<U...>&&);
+    template <class U1, class U2>
+        tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
+    template <class U1, class U2>
+        tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
+
+    void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
+};
+
+const unspecified ignore;
+
+template <class... T> tuple<V...>  make_tuple(T&&...); // constexpr in C++14
+template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
+template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
+template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
+  
+// 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
+
+// 20.4.1.5, element access:
+template <intsize_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 &
+    get(const tuple<T...>&) noexcept; // constexpr in C++14
+template <intsize_t I, class... T>
+    typename tuple_element<I, tuple<T...>>::type&&
+    get(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
+template <class T1, class... T>
+    constexpr T1&& get(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
+template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
+template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
+template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);  // constexpr in C++14
+template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
+template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
+
+template <class... Types, class Alloc>
+  struct uses_allocator<tuple<Types...>, Alloc>;
+
+template <class... Types>
+  void
+  swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__tuple>
+#include <cstddef>
+#include <type_traits>
+#include <__functional_base>
+#include <utility>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+// tuple_size
+
+template <class ..._Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
+    : public integral_constant<size_t, sizeof...(_Tp)>
+{
+};
+
+// tuple_element
+
+template <size_t _Ip, class ..._Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
+{
+public:
+    typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Ip, class ..._Tp>
+using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
+#endif
+
+// __tuple_leaf
+
+template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
+#if __has_feature(is_final)
+                                 && !__is_final(_Hp)
+#endif
+         >
+class __tuple_leaf;
+
+template <size_t _Ip, class _Hp, bool _Ep>
+inline _LIBCPP_INLINE_VISIBILITY
+void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
+    _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
+{
+    swap(__x.get(), __y.get());
+}
+
+template <size_t _Ip, class _Hp, bool>
+class __tuple_leaf
+{
+    _Hp value;
+
+    __tuple_leaf& operator=(const __tuple_leaf&);
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
+             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
+       {static_assert(!is_reference<_Hp>::value,
+              "Attempted to default construct a reference element in a tuple");}
+
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf(integral_constant<int, 0>, const _Alloc&)
+            : value()
+        {static_assert(!is_reference<_Hp>::value,
+              "Attempted to default construct a reference element in a tuple");}
+
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
+            : value(allocator_arg_t(), __a)
+        {static_assert(!is_reference<_Hp>::value,
+              "Attempted to default construct a reference element in a tuple");}
+
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
+            : value(__a)
+        {static_assert(!is_reference<_Hp>::value,
+              "Attempted to default construct a reference element in a tuple");}
+
+    template <class _Tp,
+              class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
+            : value(_VSTD::forward<_Tp>(__t))
+        {static_assert(!is_reference<_Hp>::value ||
+                       (is_lvalue_reference<_Hp>::value &&
+                        (is_lvalue_reference<_Tp>::value ||
+                         is_same<typename remove_reference<_Tp>::type,
+                                 reference_wrapper<
+                                    typename remove_reference<_Hp>::type
+                                 >
+                                >::value)) ||
+                        (is_rvalue_reference<_Hp>::value &&
+                         !is_lvalue_reference<_Tp>::value),
+       "Attempted to construct a reference element in a tuple with an rvalue");}
+
+    template <class _Tp, class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
+            : value(_VSTD::forward<_Tp>(__t))
+        {static_assert(!is_lvalue_reference<_Hp>::value ||
+                       (is_lvalue_reference<_Hp>::value &&
+                        (is_lvalue_reference<_Tp>::value ||
+                         is_same<typename remove_reference<_Tp>::type,
+                                 reference_wrapper<
+                                    typename remove_reference<_Hp>::type
+                                 >
+                                >::value)),
+       "Attempted to construct a reference element in a tuple with an rvalue");}
+
+    template <class _Tp, class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
+            : value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
+        {static_assert(!is_lvalue_reference<_Hp>::value ||
+                       (is_lvalue_reference<_Hp>::value &&
+                        (is_lvalue_reference<_Tp>::value ||
+                         is_same<typename remove_reference<_Tp>::type,
+                                 reference_wrapper<
+                                    typename remove_reference<_Hp>::type
+                                 >
+                                >::value)),
+       "Attempted to construct a reference element in a tuple with an rvalue");}
+
+    template <class _Tp, class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
+            : value(_VSTD::forward<_Tp>(__t), __a)
+        {static_assert(!is_lvalue_reference<_Hp>::value ||
+                       (is_lvalue_reference<_Hp>::value &&
+                        (is_lvalue_reference<_Tp>::value ||
+                         is_same<typename remove_reference<_Tp>::type,
+                                 reference_wrapper<
+                                    typename remove_reference<_Hp>::type
+                                 >
+                                >::value)),
+       "Attempted to construct a reference element in a tuple with an rvalue");}
+
+    __tuple_leaf(const __tuple_leaf& __t) = default;
+    __tuple_leaf(__tuple_leaf&& __t) = default;
+
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf&
+        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
+        {
+            value = _VSTD::forward<_Tp>(__t);
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
+    {
+        _VSTD::swap(*this, __t);
+        return 0;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return value;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
+};
+
+template <size_t _Ip, class _Hp>
+class __tuple_leaf<_Ip, _Hp, true>
+    : private _Hp
+{
+
+    __tuple_leaf& operator=(const __tuple_leaf&);
+public:
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
+             _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
+
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
+
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
+            : _Hp(allocator_arg_t(), __a) {}
+
+    template <class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
+            : _Hp(__a) {}
+
+    template <class _Tp,
+              class = typename enable_if<is_constructible<_Hp, _Tp>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
+            : _Hp(_VSTD::forward<_Tp>(__t)) {}
+
+    template <class _Tp, class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
+            : _Hp(_VSTD::forward<_Tp>(__t)) {}
+
+    template <class _Tp, class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
+            : _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
+
+    template <class _Tp, class _Alloc>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
+            : _Hp(_VSTD::forward<_Tp>(__t), __a) {}
+
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_leaf&
+        operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
+        {
+            _Hp::operator=(_VSTD::forward<_Tp>(__t));
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    int
+    swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
+    {
+        _VSTD::swap(*this, __t);
+        return 0;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11       _Hp& get()       _NOEXCEPT {return static_cast<_Hp&>(*this);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
+};
+
+template <class ..._Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __swallow(_Tp&&...) _NOEXCEPT {}
+
+template <bool ...> struct __all;
+
+template <>
+struct __all<>
+{
+    static const bool value = true;
+};
+
+template <bool _B0, bool ... _Bp>
+struct __all<_B0, _Bp...>
+{
+    static const bool value = _B0 && __all<_Bp...>::value;
+};
+
+// __tuple_impl
+
+template<class _Indx, class ..._Tp> struct __tuple_impl;
+
+template<size_t ..._Indx, class ..._Tp>
+struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
+    : public __tuple_leaf<_Indx, _Tp>...
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR __tuple_impl()
+        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
+
+    template <size_t ..._Uf, class ..._Tf,
+              size_t ..._Ul, class ..._Tl, class ..._Up>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        explicit
+        __tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
+                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
+                     _Up&&... __u)
+                     _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
+                                 __all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
+            __tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
+            __tuple_leaf<_Ul, _Tl>()...
+            {}
+
+    template <class _Alloc, size_t ..._Uf, class ..._Tf,
+              size_t ..._Ul, class ..._Tl, class ..._Up>
+        _LIBCPP_INLINE_VISIBILITY
+        explicit
+        __tuple_impl(allocator_arg_t, const _Alloc& __a,
+                     __tuple_indices<_Uf...>, __tuple_types<_Tf...>,
+                     __tuple_indices<_Ul...>, __tuple_types<_Tl...>,
+                     _Up&&... __u) :
+            __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
+            _VSTD::forward<_Up>(__u))...,
+            __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
+            {}
+
+    template <class _Tuple,
+              class = typename enable_if
+                      <
+                         __tuple_constructible<_Tuple, tuple<_Tp...> >::value
+                      >::type
+             >
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
+                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
+            : __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
+                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
+            {}
+
+    template <class _Alloc, class _Tuple,
+              class = typename enable_if
+                      <
+                         __tuple_convertible<_Tuple, tuple<_Tp...> >::value
+                      >::type
+             >
+        _LIBCPP_INLINE_VISIBILITY
+        __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
+            : __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
+                                       typename __make_tuple_types<_Tuple>::type>::type>(), __a,
+                                       _VSTD::forward<typename tuple_element<_Indx,
+                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
+            {}
+
+    template <class _Tuple>
+        _LIBCPP_INLINE_VISIBILITY
+        typename enable_if
+        <
+            __tuple_assignable<_Tuple, tuple<_Tp...> >::value,
+            __tuple_impl&
+        >::type
+        operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
+                                       typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
+        {
+            __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
+                                       typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
+            return *this;
+        }
+
+    __tuple_impl(const __tuple_impl&) = default;
+    __tuple_impl(__tuple_impl&&) = default;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __tuple_impl&
+    operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
+    {
+        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __tuple_impl&
+    operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
+    {
+        __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
+        return *this;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(__tuple_impl& __t)
+        _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
+    {
+        __swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
+    }
+};
+
+template <class ..._Tp>
+class _LIBCPP_TYPE_VIS_ONLY tuple
+{
+    typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
+
+    base base_;
+
+    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;
+public:
+
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR tuple()
+        _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
+
+    _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>
+      _LIBCPP_INLINE_VISIBILITY
+      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,
+                         bool
+                      >::type = false
+             >
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        tuple(_Up&&... __u)
+            _NOEXCEPT_((
+                is_nothrow_constructible<
+                    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,
+                    _Up...
+                >::value
+            ))
+            : base_(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 ..._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,
+                         bool
+                      >::type =false
+             >
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        explicit
+        tuple(_Up&&... __u)
+            _NOEXCEPT_((
+                is_nothrow_constructible<
+                    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,
+                    _Up...
+                >::value
+            ))
+            : base_(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 _Alloc, class ..._Up,
+              class = 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
+             >
+        _LIBCPP_INLINE_VISIBILITY
+        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,
+                         bool
+                      >::type = false
+             >
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
+            : base_(_VSTD::forward<_Tuple>(__t)) {}
+
+    template <class _Tuple,
+              typename enable_if
+                      <
+                         __tuple_constructible<_Tuple, tuple>::value &&
+                         !__tuple_convertible<_Tuple, tuple>::value,
+                         bool
+                      >::type = false
+             >
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        explicit
+        tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
+            : base_(_VSTD::forward<_Tuple>(__t)) {}
+
+    template <class _Alloc, class _Tuple,
+              class = typename enable_if
+                      <
+                         __tuple_convertible<_Tuple, tuple>::value
+                      >::type
+             >
+        _LIBCPP_INLINE_VISIBILITY
+        tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
+            : base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
+
+    template <class _Tuple,
+              class = typename enable_if
+                      <
+                         __tuple_assignable<_Tuple, tuple>::value
+                      >::type
+             >
+        _LIBCPP_INLINE_VISIBILITY
+        tuple&
+        operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
+        {
+            base_.operator=(_VSTD::forward<_Tuple>(__t));
+            return *this;
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
+        {base_.swap(__t.base_);}
+};
+
+template <>
+class _LIBCPP_TYPE_VIS_ONLY tuple<>
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
+    template <class _Alloc>
+    _LIBCPP_INLINE_VISIBILITY
+        tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
+    template <class _Alloc>
+    _LIBCPP_INLINE_VISIBILITY
+        tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
+    template <class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+        tuple(array<_Up, 0>) _NOEXCEPT {}
+    template <class _Alloc, class _Up>
+    _LIBCPP_INLINE_VISIBILITY
+        tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(tuple&) _NOEXCEPT {}
+};
+
+template <class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __all<__is_swappable<_Tp>::value...>::value,
+    void
+>::type
+swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
+                 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
+    {__t.swap(__u);}
+
+// get
+
+template <size_t _Ip, class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, tuple<_Tp...> >::type&
+get(tuple<_Tp...>& __t) _NOEXCEPT
+{
+    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
+    return 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 __tuple_leaf<_Ip, type>&>(__t.base_).get();
+}
+
+template <size_t _Ip, class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, tuple<_Tp...> >::type&&
+get(tuple<_Tp...>&& __t) _NOEXCEPT
+{
+    typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
+    return static_cast<type&&>(
+             static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
+}
+
+#if _LIBCPP_STD_VER > 11
+// get by type
+template <typename _T1, size_t _Idx, typename... _Args>
+struct __find_exactly_one_t_helper;
+
+// -- find exactly one
+template <typename _T1, size_t _Idx, typename... _Args>
+struct __find_exactly_one_t_checker {
+    static constexpr size_t value = _Idx;
+//  Check the rest of the list to make sure there's only one
+    static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
+    };
+
+
+template <typename _T1, size_t _Idx>
+struct __find_exactly_one_t_helper <_T1, _Idx> {
+    static constexpr size_t value = -1;
+    };
+
+template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
+struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
+    static constexpr size_t value =
+        std::conditional<
+            std::is_same<_T1, _Head>::value,
+            __find_exactly_one_t_checker<_T1, _Idx,   _Args...>,
+            __find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
+        >::type::value;
+    };
+
+template <typename _T1, typename... _Args>
+struct __find_exactly_one_t {
+    static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
+    static_assert ( value != -1, "type not found in type list" );
+    };
+
+template <class _T1, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1& get(tuple<_Args...>& __tup) noexcept
+{
+    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__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>(__tup);
+}
+
+template <class _T1, class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
+{
+    return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
+}
+
+#endif
+
+// tie
+
+template <class ..._Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<_Tp&...>
+tie(_Tp&... __t) _NOEXCEPT
+{
+    return tuple<_Tp&...>(__t...);
+}
+
+template <class _Up>
+struct __ignore_t
+{
+    template <class _Tp>
+        _LIBCPP_INLINE_VISIBILITY
+        const __ignore_t& operator=(_Tp&&) const {return *this;}
+};
+
+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
+{
+    typedef _Tp type;
+};
+
+template <class _Tp>
+struct __make_tuple_return_impl<reference_wrapper<_Tp> >
+{
+    typedef _Tp& type;
+};
+
+template <class _Tp>
+struct __make_tuple_return
+{
+    typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
+};
+
+template <class... _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<typename __make_tuple_return<_Tp>::type...>
+make_tuple(_Tp&&... __t)
+{
+    return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
+}
+
+template <class... _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<_Tp&&...>
+forward_as_tuple(_Tp&&... __t) _NOEXCEPT
+{
+    return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
+}
+
+template <size_t _Ip>
+struct __tuple_equal
+{
+    template <class _Tp, class _Up>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _Tp& __x, const _Up& __y)
+    {
+        return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
+    }
+};
+
+template <>
+struct __tuple_equal<0>
+{
+    template <class _Tp, class _Up>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _Tp&, const _Up&)
+    {
+        return true;
+    }
+};
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+    return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
+}
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+    return !(__x == __y);
+}
+
+template <size_t _Ip>
+struct __tuple_less
+{
+    template <class _Tp, class _Up>
+    _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));
+    }
+};
+
+template <>
+struct __tuple_less<0>
+{
+    template <class _Tp, class _Up>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    bool operator()(const _Tp&, const _Up&)
+    {
+        return false;
+    }
+};
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+    return __tuple_less<sizeof...(_Tp)>()(__x, __y);
+}
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+    return __y < __x;
+}
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class ..._Tp, class ..._Up>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
+{
+    return !(__y < __x);
+}
+
+// tuple_cat
+
+template <class _Tp, class _Up> struct __tuple_cat_type;
+
+template <class ..._Ttypes, class ..._Utypes>
+struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
+{
+    typedef tuple<_Ttypes..., _Utypes...> type;
+};
+
+template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
+struct __tuple_cat_return_1
+{
+};
+
+template <class ..._Types, class _Tuple0>
+struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
+{
+    typedef typename __tuple_cat_type<tuple<_Types...>,
+            typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
+                                                                           type;
+};
+
+template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
+struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
+    : public __tuple_cat_return_1<
+                 typename __tuple_cat_type<
+                     tuple<_Types...>,
+                     typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
+                 >::type,
+                 __tuple_like<typename remove_reference<_Tuple1>::type>::value,
+                 _Tuple1, _Tuples...>
+{
+};
+
+template <class ..._Tuples> struct __tuple_cat_return;
+
+template <class _Tuple0, class ..._Tuples>
+struct __tuple_cat_return<_Tuple0, _Tuples...>
+    : public __tuple_cat_return_1<tuple<>,
+         __tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
+                                                                     _Tuples...>
+{
+};
+
+template <>
+struct __tuple_cat_return<>
+{
+    typedef tuple<> type;
+};
+
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+tuple<>
+tuple_cat()
+{
+    return tuple<>();
+}
+
+template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
+struct __tuple_cat_return_ref_imp;
+
+template <class ..._Types, size_t ..._I0, class _Tuple0>
+struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
+{
+    typedef typename remove_reference<_Tuple0>::type _T0;
+    typedef tuple<_Types..., typename __apply_cv<_Tuple0,
+                          typename tuple_element<_I0, _T0>::type>::type&&...> type;
+};
+
+template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
+struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
+                                  _Tuple0, _Tuple1, _Tuples...>
+    : public __tuple_cat_return_ref_imp<
+         tuple<_Types..., typename __apply_cv<_Tuple0,
+               typename tuple_element<_I0,
+                  typename remove_reference<_Tuple0>::type>::type>::type&&...>,
+         typename __make_tuple_indices<tuple_size<typename
+                                 remove_reference<_Tuple1>::type>::value>::type,
+         _Tuple1, _Tuples...>
+{
+};
+
+template <class _Tuple0, class ..._Tuples>
+struct __tuple_cat_return_ref
+    : public __tuple_cat_return_ref_imp<tuple<>,
+               typename __make_tuple_indices<
+                        tuple_size<typename remove_reference<_Tuple0>::type>::value
+               >::type, _Tuple0, _Tuples...>
+{
+};
+
+template <class _Types, class _I0, class _J0>
+struct __tuple_cat;
+
+template <class ..._Types, size_t ..._I0, size_t ..._J0>
+struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
+{
+    template <class _Tuple0>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
+    operator()(tuple<_Types...> __t, _Tuple0&& __t0)
+    {
+        return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
+                                      _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
+    }
+
+    template <class _Tuple0, class _Tuple1, class ..._Tuples>
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
+    operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
+    {
+        typedef typename remove_reference<_Tuple0>::type _T0;
+        typedef typename remove_reference<_Tuple1>::type _T1;
+        return __tuple_cat<
+           tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
+           typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
+           typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
+                           (forward_as_tuple(
+                              _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
+                              _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
+                            ),
+                            _VSTD::forward<_Tuple1>(__t1),
+                            _VSTD::forward<_Tuples>(__tpls)...);
+    }
+};
+
+template <class _Tuple0, class... _Tuples>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename __tuple_cat_return<_Tuple0, _Tuples...>::type
+tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
+{
+    typedef typename remove_reference<_Tuple0>::type _T0;
+    return __tuple_cat<tuple<>, __tuple_indices<>,
+                  typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
+                  (tuple<>(), _VSTD::forward<_Tuple0>(__t0),
+                                            _VSTD::forward<_Tuples>(__tpls)...);
+}
+
+template <class ..._Tp, class _Alloc>
+struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
+    : true_type {};
+
+template <class _T1, class _T2>
+template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_T1, _T2>::pair(piecewise_construct_t,
+                     tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
+                     __tuple_indices<_I1...>, __tuple_indices<_I2...>)
+    :  first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
+      second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
+{
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_TUPLE
diff --git a/final/include/type_traits b/final/include/type_traits
new file mode 100644
index 0000000..371a15e
--- /dev/null
+++ b/final/include/type_traits
@@ -0,0 +1,3428 @@
+// -*- 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_TYPE_TRAITS
+#define _LIBCPP_TYPE_TRAITS
+
+/*
+    type_traits synopsis
+
+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;
+
+    // helper traits
+    template <bool, class T = void> struct enable_if;
+    template <bool, class T, class F> struct conditional;
+
+    // Primary classification traits:
+    template <class T> struct is_void;
+    template <class T> struct is_null_pointer;  // C++14
+    template <class T> struct is_integral;
+    template <class T> struct is_floating_point;
+    template <class T> struct is_array;
+    template <class T> struct is_pointer;
+    template <class T> struct is_lvalue_reference;
+    template <class T> struct is_rvalue_reference;
+    template <class T> struct is_member_object_pointer;
+    template <class T> struct is_member_function_pointer;
+    template <class T> struct is_enum;
+    template <class T> struct is_union;
+    template <class T> struct is_class;
+    template <class T> struct is_function;
+
+    // Secondary classification traits:
+    template <class T> struct is_reference;
+    template <class T> struct is_arithmetic;
+    template <class T> struct is_fundamental;
+    template <class T> struct is_member_pointer;
+    template <class T> struct is_scalar;
+    template <class T> struct is_object;
+    template <class T> struct is_compound;
+
+    // Const-volatile properties and transformations:
+    template <class T> struct is_const;
+    template <class T> struct is_volatile;
+    template <class T> struct remove_const;
+    template <class T> struct remove_volatile;
+    template <class T> struct remove_cv;
+    template <class T> struct add_const;
+    template <class T> struct add_volatile;
+    template <class T> struct add_cv;
+
+    // Reference transformations:
+    template <class T> struct remove_reference;
+    template <class T> struct add_lvalue_reference;
+    template <class T> struct add_rvalue_reference;
+
+    // Pointer transformations:
+    template <class T> struct remove_pointer;
+    template <class T> struct add_pointer;
+
+    // Integral properties:
+    template <class T> struct is_signed;
+    template <class T> struct is_unsigned;
+    template <class T> struct make_signed;
+    template <class T> struct make_unsigned;
+
+    // Array properties and transformations:
+    template <class T> struct rank;
+    template <class T, unsigned I = 0> struct extent;
+    template <class T> struct remove_extent;
+    template <class T> struct remove_all_extents;
+
+    // Member introspection:
+    template <class T> struct is_pod;
+    template <class T> struct is_trivial;
+    template <class T> struct is_trivially_copyable;
+    template <class T> struct is_standard_layout;
+    template <class T> struct is_literal_type;
+    template <class T> struct is_empty;
+    template <class T> struct is_polymorphic;
+    template <class T> struct is_abstract;
+    template <class T> struct is_final; // C++14
+
+    template <class T, class... Args> struct is_constructible;
+    template <class T>                struct is_default_constructible;
+    template <class T>                struct is_copy_constructible;
+    template <class T>                struct is_move_constructible;
+    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>                struct is_destructible;
+
+    template <class T, class... Args> struct is_trivially_constructible;
+    template <class T>                struct is_trivially_default_constructible;
+    template <class T>                struct is_trivially_copy_constructible;
+    template <class T>                struct is_trivially_move_constructible;
+    template <class T, class U>       struct is_trivially_assignable;
+    template <class T>                struct is_trivially_copy_assignable;
+    template <class T>                struct is_trivially_move_assignable;
+    template <class T>                struct is_trivially_destructible;
+
+    template <class T, class... Args> struct is_nothrow_constructible;
+    template <class T>                struct is_nothrow_default_constructible;
+    template <class T>                struct is_nothrow_copy_constructible;
+    template <class T>                struct is_nothrow_move_constructible;
+    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>                struct is_nothrow_destructible;
+
+    template <class T> struct has_virtual_destructor;
+
+    // Relationships between types:
+    template <class T, class U> struct is_same;
+    template <class Base, class Derived> struct is_base_of;
+    template <class From, class To> struct is_convertible;
+
+    // Alignment properties and transformations:
+    template <class T> struct alignment_of;
+    template <size_t Len, size_t Align = most_stringent_alignment_requirement>
+        struct aligned_storage;
+    template <size_t Len, class... Types> struct aligned_union;
+
+    template <class T> struct decay;
+    template <class... T> struct common_type;
+    template <class T> struct underlying_type;
+    template <class> class result_of; // undefined
+    template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
+
+    // const-volatile modifications:
+    template <class T>
+      using remove_const_t    = typename remove_const<T>::type;  // C++14
+    template <class T>
+      using remove_volatile_t = typename remove_volatile<T>::type;  // C++14
+    template <class T>
+      using remove_cv_t       = typename remove_cv<T>::type;  // C++14
+    template <class T>
+      using add_const_t       = typename add_const<T>::type;  // C++14
+    template <class T>
+      using add_volatile_t    = typename add_volatile<T>::type;  // C++14
+    template <class T>
+      using add_cv_t          = typename add_cv<T>::type;  // C++14
+  
+    // reference modifications:
+    template <class T>
+      using remove_reference_t     = typename remove_reference<T>::type;  // C++14
+    template <class T>
+      using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;  // C++14
+    template <class T>
+      using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;  // C++14
+  
+    // sign modifications:
+    template <class T>
+      using make_signed_t   = typename make_signed<T>::type;  // C++14
+    template <class T>
+      using make_unsigned_t = typename make_unsigned<T>::type;  // C++14
+  
+    // array modifications:
+    template <class T>
+      using remove_extent_t      = typename remove_extent<T>::type;  // C++14
+    template <class T>
+      using remove_all_extents_t = typename remove_all_extents<T>::type;  // C++14
+
+    // pointer modifications:
+    template <class T>
+      using remove_pointer_t = typename remove_pointer<T>::type;  // C++14
+    template <class T>
+      using add_pointer_t    = typename add_pointer<T>::type;  // C++14
+
+    // other transformations:
+    template <size_t Len, std::size_t Align=default-alignment>
+      using aligned_storage_t = typename aligned_storage<Len,Align>::type;  // C++14
+    template <std::size_t Len, class... Types>
+      using aligned_union_t   = typename aligned_union<Len,Types...>::type;  // C++14
+    template <class T>
+      using decay_t           = typename decay<T>::type;  // C++14
+    template <bool b, class T=void>
+      using enable_if_t       = typename enable_if<b,T>::type;  // C++14
+    template <bool b, class T, class F>
+      using conditional_t     = typename conditional<b,T,F>::type;  // C++14
+    template <class... T>
+      using common_type_t     = typename common_type<T...>::type;  // C++14
+    template <class T>
+      using underlying_type_t = typename underlying_type<T>::type;  // C++14
+    template <class F, class... ArgTypes>
+      using result_of_t       = typename result_of<F(ArgTypes...)>::type;  // C++14
+
+}  // std
+
+*/
+#include <__config>
+#include <cstddef>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <bool _Bp, class _If, class _Then>
+    struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;};
+template <class _If, class _Then>
+    struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;};
+
+#if _LIBCPP_STD_VER > 11
+template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type;
+#endif
+
+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;};
+
+#if _LIBCPP_STD_VER > 11
+template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type;
+#endif
+
+
+struct __two {char __lx[2];};
+
+// helper class:
+
+template <class _Tp, _Tp __v>
+struct _LIBCPP_TYPE_VIS_ONLY integral_constant
+{
+    static _LIBCPP_CONSTEXPR const _Tp      value = __v;
+    typedef _Tp               value_type;
+    typedef integral_constant type;
+    _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;}
+#if _LIBCPP_STD_VER > 11
+    _LIBCPP_INLINE_VISIBILITY
+         constexpr value_type operator ()() const _NOEXCEPT {return value;}
+#endif
+};
+
+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;
+
+// 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 {};
+
+// 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 {};
+
+// remove_const
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const            {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type;
+#endif
+
+// remove_volatile
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile               {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type;
+#endif
+
+// remove_cv
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv
+{typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type;
+#endif
+
+// is_void
+
+template <class _Tp> struct __libcpp_is_void       : public false_type {};
+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> {};
+
+// __is_nullptr_t
+
+template <class _Tp> struct __is_nullptr_t_impl       : public false_type {};
+template <>          struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t
+    : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {};
+
+#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> {};
+#endif
+
+// is_integral
+
+template <class _Tp> struct __libcpp_is_integral                     : public false_type {};
+template <>          struct __libcpp_is_integral<bool>               : public true_type {};
+template <>          struct __libcpp_is_integral<char>               : public true_type {};
+template <>          struct __libcpp_is_integral<signed char>        : public true_type {};
+template <>          struct __libcpp_is_integral<unsigned char>      : public true_type {};
+template <>          struct __libcpp_is_integral<wchar_t>            : public true_type {};
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+template <>          struct __libcpp_is_integral<char16_t>           : public true_type {};
+template <>          struct __libcpp_is_integral<char32_t>           : public true_type {};
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+template <>          struct __libcpp_is_integral<short>              : public true_type {};
+template <>          struct __libcpp_is_integral<unsigned short>     : public true_type {};
+template <>          struct __libcpp_is_integral<int>                : public true_type {};
+template <>          struct __libcpp_is_integral<unsigned int>       : public true_type {};
+template <>          struct __libcpp_is_integral<long>               : public true_type {};
+template <>          struct __libcpp_is_integral<unsigned long>      : public true_type {};
+template <>          struct __libcpp_is_integral<long long>          : public true_type {};
+template <>          struct __libcpp_is_integral<unsigned long long> : public true_type {};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <>          struct __libcpp_is_integral<__int128_t>         : public true_type {};
+template <>          struct __libcpp_is_integral<__uint128_t>        : public true_type {};
+#endif
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral
+    : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
+
+// is_floating_point
+
+template <class _Tp> struct __libcpp_is_floating_point              : public false_type {};
+template <>          struct __libcpp_is_floating_point<float>       : public true_type {};
+template <>          struct __libcpp_is_floating_point<double>      : public true_type {};
+template <>          struct __libcpp_is_floating_point<long double> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point
+    : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
+
+// is_array
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array
+    : public false_type {};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]>
+    : public true_type {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]>
+    : public true_type {};
+
+// is_pointer
+
+template <class _Tp> struct __libcpp_is_pointer       : public false_type {};
+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> {};
+
+// is_reference
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference       : public false_type {};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference        : public false_type {};
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {};
+#endif
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference        : public false_type {};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&>  : public true_type {};
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {};
+#endif
+
+// is_union
+
+#if __has_feature(is_union) || (_GNUC_VER >= 403)
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
+    : public integral_constant<bool, __is_union(_Tp)> {};
+
+#else
+
+template <class _Tp> struct __libcpp_union : public false_type {};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union
+    : public __libcpp_union<typename remove_cv<_Tp>::type> {};
+
+#endif
+
+// is_class
+
+#if __has_feature(is_class) || (_GNUC_VER >= 403)
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
+    : public integral_constant<bool, __is_class(_Tp)> {};
+
+#else
+
+namespace __is_class_imp
+{
+template <class _Tp> char  __test(int _Tp::*);
+template <class _Tp> __two __test(...);
+}
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class
+    : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_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 {};
+
+// is_function
+
+namespace __libcpp_is_function_imp
+{
+template <class _Tp> char  __test(_Tp*);
+template <class _Tp> __two __test(...);
+template <class _Tp> _Tp&  __source();
+}
+
+template <class _Tp, bool = is_class<_Tp>::value ||
+                            is_union<_Tp>::value ||
+                            is_void<_Tp>::value  ||
+                            is_reference<_Tp>::value ||
+                            __is_nullptr_t<_Tp>::value >
+struct __libcpp_is_function
+    : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>())) == 1>
+    {};
+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> {};
+
+// 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>
+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> {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
+    : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
+
+// is_member_pointer
+
+template <class _Tp>            struct __libcpp_is_member_pointer             : public false_type {};
+template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : public true_type {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer
+    : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {};
+
+// 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> {};
+
+// is_enum
+
+#if __has_feature(is_enum) || (_GNUC_VER >= 403)
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
+    : public integral_constant<bool, __is_enum(_Tp)> {};
+
+#else
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum
+    : public integral_constant<bool, !is_void<_Tp>::value             &&
+                                     !is_integral<_Tp>::value         &&
+                                     !is_floating_point<_Tp>::value   &&
+                                     !is_array<_Tp>::value            &&
+                                     !is_pointer<_Tp>::value          &&
+                                     !is_reference<_Tp>::value        &&
+                                     !is_member_pointer<_Tp>::value   &&
+                                     !is_union<_Tp>::value            &&
+                                     !is_class<_Tp>::value            &&
+                                     !is_function<_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> {};
+
+// is_fundamental
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental
+    : public integral_constant<bool, is_void<_Tp>::value        ||
+                                     __is_nullptr_t<_Tp>::value ||
+                                     is_arithmetic<_Tp>::value> {};
+
+// is_scalar
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar
+    : public integral_constant<bool, is_arithmetic<_Tp>::value     ||
+                                     is_member_pointer<_Tp>::value ||
+                                     is_pointer<_Tp>::value        ||
+                                     __is_nullptr_t<_Tp>::value    ||
+                                     is_enum<_Tp>::value           > {};
+
+template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {};
+
+// is_object
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object
+    : public integral_constant<bool, is_scalar<_Tp>::value ||
+                                     is_array<_Tp>::value  ||
+                                     is_union<_Tp>::value  ||
+                                     is_class<_Tp>::value  > {};
+
+// is_compound
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound
+    : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
+
+// add_const
+
+template <class _Tp, bool = is_reference<_Tp>::value ||
+                            is_function<_Tp>::value  ||
+                            is_const<_Tp>::value     >
+struct __add_const             {typedef _Tp type;};
+
+template <class _Tp>
+struct __add_const<_Tp, false> {typedef const _Tp type;};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const
+    {typedef typename __add_const<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_const_t = typename add_const<_Tp>::type;
+#endif
+
+// add_volatile
+
+template <class _Tp, bool = is_reference<_Tp>::value ||
+                            is_function<_Tp>::value  ||
+                            is_volatile<_Tp>::value  >
+struct __add_volatile             {typedef _Tp type;};
+
+template <class _Tp>
+struct __add_volatile<_Tp, false> {typedef volatile _Tp type;};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile
+    {typedef typename __add_volatile<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type;
+#endif
+
+// add_cv
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv
+    {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type;
+#endif
+
+// remove_reference
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference        {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&>  {typedef _Tp type;};
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;};
+#endif
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type;
+#endif
+
+// 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;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
+#endif
+
+#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;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
+#endif
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+typename add_rvalue_reference<_Tp>::type
+declval() _NOEXCEPT;
+
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+typename add_lvalue_reference<_Tp>::type
+declval();
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct __any
+{
+    __any(...);
+};
+
+// remove_pointer
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer                      {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*>                {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const>          {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile>       {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type;
+#endif
+
+// add_pointer
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer
+    {typedef typename remove_reference<_Tp>::type* type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
+#endif
+
+// is_signed
+
+template <class _Tp, bool = is_integral<_Tp>::value>
+struct __libcpp_is_signed_impl : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
+
+template <class _Tp>
+struct __libcpp_is_signed_impl<_Tp, false> : public true_type {};  // floating point
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};
+
+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> {};
+
+// is_unsigned
+
+template <class _Tp, bool = is_integral<_Tp>::value>
+struct __libcpp_is_unsigned_impl : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
+
+template <class _Tp>
+struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {};  // floating point
+
+template <class _Tp, bool = is_arithmetic<_Tp>::value>
+struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
+
+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> {};
+
+// rank
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank
+    : public integral_constant<size_t, 0> {};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]>
+    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]>
+    : public integral_constant<size_t, rank<_Tp>::value + 1> {};
+
+// extent
+
+template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent
+    : public integral_constant<size_t, 0> {};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0>
+    : public integral_constant<size_t, 0> {};
+template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip>
+    : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {};
+template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0>
+    : public integral_constant<size_t, _Np> {};
+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> {};
+
+// remove_extent
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent
+    {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]>
+    {typedef _Tp type;};
+template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]>
+    {typedef _Tp type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type;
+#endif
+
+// remove_all_extents
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents
+    {typedef _Tp type;};
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]>
+    {typedef typename remove_all_extents<_Tp>::type type;};
+template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]>
+    {typedef typename remove_all_extents<_Tp>::type type;};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
+#endif
+
+// decay
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY decay
+{
+private:
+    typedef typename remove_reference<_Tp>::type _Up;
+public:
+    typedef typename conditional
+                     <
+                         is_array<_Up>::value,
+                         typename remove_extent<_Up>::type*,
+                         typename conditional
+                         <
+                              is_function<_Up>::value,
+                              typename add_pointer<_Up>::type,
+                              typename remove_cv<_Up>::type
+                         >::type
+                     >::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using decay_t = typename decay<_Tp>::type;
+#endif
+
+// is_abstract
+
+namespace __is_abstract_imp
+{
+template <class _Tp> char  __test(_Tp (*)[1]);
+template <class _Tp> __two __test(...);
+}
+
+template <class _Tp, bool = is_class<_Tp>::value>
+struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_imp::__test<_Tp>(0)) != 1> {};
+
+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> {};
+
+// is_final
+
+#if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY 
+is_final : public integral_constant<bool, __is_final(_Tp)> {};
+#endif
+
+// is_base_of
+
+#ifdef _LIBCPP_HAS_IS_BASE_OF
+
+template <class _Bp, class _Dp>
+struct _LIBCPP_TYPE_VIS_ONLY is_base_of
+    : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
+
+#else  // _LIBCPP_HAS_IS_BASE_OF
+
+namespace __is_base_of_imp
+{
+template <class _Tp>
+struct _Dst
+{
+    _Dst(const volatile _Tp &);
+};
+template <class _Tp>
+struct _Src
+{
+    operator const volatile _Tp &();
+    template <class _Up> operator const _Dst<_Up> &();
+};
+template <size_t> struct __one { typedef char type; };
+template <class _Bp, class _Dp> typename __one<sizeof(_Dst<_Bp>(declval<_Src<_Dp> >()))>::type __test(int);
+template <class _Bp, class _Dp> __two __test(...);
+}
+
+template <class _Bp, class _Dp>
+struct _LIBCPP_TYPE_VIS_ONLY is_base_of
+    : public integral_constant<bool, is_class<_Bp>::value &&
+                                     sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {};
+
+#endif  // _LIBCPP_HAS_IS_BASE_OF
+
+// is_convertible
+
+#if __has_feature(is_convertible_to)
+
+template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
+    : public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
+                                     !is_abstract<_T2>::value> {};
+
+#else  // __has_feature(is_convertible_to)
+
+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, bool _IsArray =    is_array<_Tp>::value,
+                     bool _IsFunction = is_function<_Tp>::value,
+                     bool _IsVoid =     is_void<_Tp>::value>
+                     struct __is_array_function_or_void                          {enum {value = 0};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};};
+template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};};
+}
+
+template <class _Tp,
+    unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value>
+struct __is_convertible_check
+{
+    static const size_t __v = 0;
+};
+
+template <class _Tp>
+struct __is_convertible_check<_Tp, 0>
+{
+    static const size_t __v = sizeof(_Tp);
+};
+
+template <class _T1, class _T2,
+    unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value,
+    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_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)
+                  && (is_same<typename remove_cv<_T1>::type,
+                              typename remove_cv<typename remove_reference<_T2>::type>::type>::value
+                      || is_base_of<typename remove_reference<_T2>::type, _T1>::value))
+#endif
+    >
+{};
+
+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 {};
+#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 {};
+template <class _T1> struct __is_convertible<_T1, volatile _T1&&, 1, 0> : true_type {};
+template <class _T1> struct __is_convertible<_T1, const volatile _T1&&, 1, 0> : true_type {};
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2*, 1, 0>
+    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*>::value> {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const, 1, 0>
+    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const>::value> {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2* volatile, 1, 0>
+    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*volatile>::value> {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2* const volatile, 1, 0>
+    : public integral_constant<bool, __is_convertible<typename remove_all_extents<_T1>::type*, _T2*const volatile>::value> {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 0>                : public false_type {};
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+template <class _T1>            struct __is_convertible<_T1, _T1&&, 2, 0>               : public true_type {};
+#endif
+template <class _T1>            struct __is_convertible<_T1, _T1&, 2, 0>               : public true_type {};
+template <class _T1>            struct __is_convertible<_T1, _T1*, 2, 0>               : public true_type {};
+template <class _T1>            struct __is_convertible<_T1, _T1*const, 2, 0>          : public true_type {};
+template <class _T1>            struct __is_convertible<_T1, _T1*volatile, 2, 0>       : public true_type {};
+template <class _T1>            struct __is_convertible<_T1, _T1*const volatile, 2, 0> : public true_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 0> : public false_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {};
+
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {};
+template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {};
+
+template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
+    : public __is_convertible<_T1, _T2>
+{
+    static const size_t __complete_check1 = __is_convertible_check<_T1>::__v;
+    static const size_t __complete_check2 = __is_convertible_check<_T2>::__v;
+};
+
+#endif  // __has_feature(is_convertible_to)
+
+// is_empty
+
+#if __has_feature(is_empty) || (_GNUC_VER >= 407)
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_empty
+    : public integral_constant<bool, __is_empty(_Tp)> {};
+
+#else  // __has_feature(is_empty)
+
+template <class _Tp>
+struct __is_empty1
+    : public _Tp
+{
+    double __lx;
+};
+
+struct __is_empty2
+{
+    double __lx;
+};
+
+template <class _Tp, bool = is_class<_Tp>::value>
+struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {};
+
+template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {};
+
+#endif  // __has_feature(is_empty)
+
+// is_polymorphic
+
+#if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC)
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
+    : public integral_constant<bool, __is_polymorphic(_Tp)> {};
+
+#else
+
+template<typename _Tp> char &__is_polymorphic_impl(
+    typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0,
+                       int>::type);
+template<typename _Tp> __two &__is_polymorphic_impl(...);
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic
+    : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {};
+
+#endif // __has_feature(is_polymorphic)
+
+// has_virtual_destructor
+
+#if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403)
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
+    : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
+
+#else
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor
+    : public false_type {};
+
+#endif
+
+// alignment_of
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of
+    : public integral_constant<size_t, __alignof__(_Tp)> {};
+
+// aligned_storage
+
+template <class _Hp, class _Tp>
+struct __type_list
+{
+    typedef _Hp _Head;
+    typedef _Tp _Tail;
+};
+
+struct __nat
+{
+#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
+    __nat() = delete;
+    __nat(const __nat&) = delete;
+    __nat& operator=(const __nat&) = delete;
+    ~__nat() = delete;
+#endif
+};
+
+template <class _Tp>
+struct __align_type
+{
+    static const size_t value = alignment_of<_Tp>::value;
+    typedef _Tp type;
+};
+
+struct __struct_double {long double __lx;};
+struct __struct_double4 {double __lx[4];};
+
+typedef
+    __type_list<__align_type<unsigned char>,
+    __type_list<__align_type<unsigned short>,
+    __type_list<__align_type<unsigned int>,
+    __type_list<__align_type<unsigned long>,
+    __type_list<__align_type<unsigned long long>,
+    __type_list<__align_type<double>,
+    __type_list<__align_type<long double>,
+    __type_list<__align_type<__struct_double>,
+    __type_list<__align_type<__struct_double4>,
+    __type_list<__align_type<int*>,
+    __nat
+    > > > > > > > > > > __all_types;
+
+template <class _TL, size_t _Align> struct __find_pod;
+
+template <class _Hp, size_t _Align>
+struct __find_pod<__type_list<_Hp, __nat>, _Align>
+{
+    typedef typename conditional<
+                             _Align == _Hp::value,
+                             typename _Hp::type,
+                             void
+                         >::type type;
+};
+
+template <class _Hp, class _Tp, size_t _Align>
+struct __find_pod<__type_list<_Hp, _Tp>, _Align>
+{
+    typedef typename conditional<
+                             _Align == _Hp::value,
+                             typename _Hp::type,
+                             typename __find_pod<_Tp, _Align>::type
+                         >::type type;
+};
+
+template <class _TL, size_t _Len> struct __find_max_align;
+
+template <class _Hp, size_t _Len>
+struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {};
+
+template <size_t _Len, size_t _A1, size_t _A2>
+struct __select_align
+{
+private:
+    static const size_t __min = _A2 < _A1 ? _A2 : _A1;
+    static const size_t __max = _A1 < _A2 ? _A2 : _A1;
+public:
+    static const size_t value = _Len < __max ? __min : __max;
+};
+
+template <class _Hp, class _Tp, size_t _Len>
+struct __find_max_align<__type_list<_Hp, _Tp>, _Len>
+    : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {};
+
+template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
+struct _LIBCPP_TYPE_VIS_ONLY aligned_storage
+{
+    typedef typename __find_pod<__all_types, _Align>::type _Aligner;
+    static_assert(!is_void<_Aligner>::value, "");
+    union type
+    {
+        _Aligner __align;
+        unsigned char __data[_Len];
+    };
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
+    using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
+#endif
+
+#define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \
+template <size_t _Len>\
+struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\
+{\
+    struct _ALIGNAS(n) type\
+    {\
+        unsigned char __lx[_Len];\
+    };\
+}
+
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
+// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
+#if !defined(_LIBCPP_MSVC)
+_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
+#endif // !_LIBCPP_MSVC
+
+#undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+// aligned_union
+
+template <size_t _I0, size_t ..._In>
+struct __static_max;
+
+template <size_t _I0>
+struct __static_max<_I0>
+{
+    static const size_t value = _I0;
+};
+
+template <size_t _I0, size_t _I1, size_t ..._In>
+struct __static_max<_I0, _I1, _In...>
+{
+    static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value :
+                                             __static_max<_I1, _In...>::value;
+};
+
+template <size_t _Len, class _Type0, class ..._Types>
+struct aligned_union
+{
+    static const size_t alignment_value = __static_max<__alignof__(_Type0),
+                                                       __alignof__(_Types)...>::value;
+    static const size_t __len = __static_max<_Len, sizeof(_Type0),
+                                             sizeof(_Types)...>::value;
+    typedef typename aligned_storage<__len, alignment_value>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
+#endif
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp>
+struct __numeric_type
+{
+   static void __test(...);
+   static float __test(float);
+   static double __test(char);
+   static double __test(int);
+   static double __test(unsigned);
+   static double __test(long);
+   static double __test(unsigned long);
+   static double __test(long long);
+   static double __test(unsigned long long);
+   static double __test(double);
+   static long double __test(long double);
+
+   typedef decltype(__test(declval<_Tp>())) type;
+   static const bool value = !is_same<type, void>::value;
+};
+
+template <>
+struct __numeric_type<void>
+{
+   static const bool value = true;
+};
+
+// __promote
+
+template <class _A1, class _A2 = void, class _A3 = void,
+          bool = __numeric_type<_A1>::value &&
+                 __numeric_type<_A2>::value &&
+                 __numeric_type<_A3>::value>
+class __promote
+{
+    static const bool value = false;
+};
+
+template <class _A1, class _A2, class _A3>
+class __promote<_A1, _A2, _A3, true>
+{
+private:
+    typedef typename __promote<_A1>::type __type1;
+    typedef typename __promote<_A2>::type __type2;
+    typedef typename __promote<_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>
+{
+private:
+    typedef typename __promote<_A1>::type __type1;
+    typedef typename __promote<_A2>::type __type2;
+public:
+    typedef decltype(__type1() + __type2()) type;
+    static const bool value = true;
+};
+
+template <class _A1>
+class __promote<_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
+
+// make_signed / make_unsigned
+
+typedef
+    __type_list<signed char,
+    __type_list<signed short,
+    __type_list<signed int,
+    __type_list<signed long,
+    __type_list<signed long long,
+#ifndef _LIBCPP_HAS_NO_INT128
+    __type_list<__int128_t,
+#endif
+    __nat
+#ifndef _LIBCPP_HAS_NO_INT128
+    >
+#endif
+    > > > > > __signed_types;
+
+typedef
+    __type_list<unsigned char,
+    __type_list<unsigned short,
+    __type_list<unsigned int,
+    __type_list<unsigned long,
+    __type_list<unsigned long long,
+#ifndef _LIBCPP_HAS_NO_INT128
+    __type_list<__uint128_t,
+#endif
+    __nat
+#ifndef _LIBCPP_HAS_NO_INT128
+    >
+#endif
+    > > > > > __unsigned_types;
+
+template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first;
+
+template <class _Hp, class _Tp, size_t _Size>
+struct __find_first<__type_list<_Hp, _Tp>, _Size, true>
+{
+    typedef _Hp type;
+};
+
+template <class _Hp, class _Tp, size_t _Size>
+struct __find_first<__type_list<_Hp, _Tp>, _Size, false>
+{
+    typedef typename __find_first<_Tp, _Size>::type type;
+};
+
+template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value,
+                             bool = is_volatile<typename remove_reference<_Tp>::type>::value>
+struct __apply_cv
+{
+    typedef _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, true, false>
+{
+    typedef const _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, false, true>
+{
+    typedef volatile _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp, _Up, true, true>
+{
+    typedef const volatile _Up type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, false, false>
+{
+    typedef _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, true, false>
+{
+    typedef const _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, false, true>
+{
+    typedef volatile _Up& type;
+};
+
+template <class _Tp, class _Up>
+struct __apply_cv<_Tp&, _Up, true, true>
+{
+    typedef const volatile _Up& type;
+};
+
+template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
+struct __make_signed {};
+
+template <class _Tp>
+struct __make_signed<_Tp, true>
+{
+    typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type;
+};
+
+template <> struct __make_signed<bool,               true> {};
+template <> struct __make_signed<  signed short,     true> {typedef short     type;};
+template <> struct __make_signed<unsigned short,     true> {typedef short     type;};
+template <> struct __make_signed<  signed int,       true> {typedef int       type;};
+template <> struct __make_signed<unsigned int,       true> {typedef int       type;};
+template <> struct __make_signed<  signed long,      true> {typedef long      type;};
+template <> struct __make_signed<unsigned long,      true> {typedef long      type;};
+template <> struct __make_signed<  signed long long, true> {typedef long long type;};
+template <> struct __make_signed<unsigned long long, true> {typedef long long type;};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __make_signed<__int128_t,         true> {typedef __int128_t type;};
+template <> struct __make_signed<__uint128_t,        true> {typedef __int128_t type;};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY make_signed
+{
+    typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type;
+#endif
+
+template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value>
+struct __make_unsigned {};
+
+template <class _Tp>
+struct __make_unsigned<_Tp, true>
+{
+    typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type;
+};
+
+template <> struct __make_unsigned<bool,               true> {};
+template <> struct __make_unsigned<  signed short,     true> {typedef unsigned short     type;};
+template <> struct __make_unsigned<unsigned short,     true> {typedef unsigned short     type;};
+template <> struct __make_unsigned<  signed int,       true> {typedef unsigned int       type;};
+template <> struct __make_unsigned<unsigned int,       true> {typedef unsigned int       type;};
+template <> struct __make_unsigned<  signed long,      true> {typedef unsigned long      type;};
+template <> struct __make_unsigned<unsigned long,      true> {typedef unsigned long      type;};
+template <> struct __make_unsigned<  signed long long, true> {typedef unsigned long long type;};
+template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;};
+#ifndef _LIBCPP_HAS_NO_INT128
+template <> struct __make_unsigned<__int128_t,         true> {typedef __uint128_t        type;};
+template <> struct __make_unsigned<__uint128_t,        true> {typedef __uint128_t        type;};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY make_unsigned
+{
+    typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type;
+#endif
+
+#ifdef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Up = void, class V = void>
+struct _LIBCPP_TYPE_VIS_ONLY common_type
+{
+public:
+    typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type;
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void>
+{
+public:
+    typedef typename decay<_Tp>::type type;
+};
+
+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;
+};
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class ..._Tp> struct common_type;
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp>
+{
+    typedef typename decay<_Tp>::type type;
+};
+
+template <class _Tp, class _Up>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up>
+{
+private:
+    static _Tp&& __t();
+    static _Up&& __u();
+    static bool __f();
+public:
+    typedef typename decay<decltype(__f() ? __t() : __u())>::type type;
+};
+
+template <class _Tp, class _Up, class ..._Vp>
+struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...>
+{
+    typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type;
+#endif
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+// is_assignable
+
+template<typename, typename _Tp> struct __select_2nd { typedef _Tp type; };
+
+template <class _Tp, class _Arg>
+typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__is_assignable_test(_Tp&&, _Arg&&);
+#else
+__is_assignable_test(_Tp, _Arg&);
+#endif
+
+template <class _Arg>
+false_type
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__is_assignable_test(__any, _Arg&&);
+#else
+__is_assignable_test(__any, _Arg&);
+#endif
+
+template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value>
+struct __is_assignable_imp
+    : public common_type
+        <
+            decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
+        >::type {};
+
+template <class _Tp, class _Arg>
+struct __is_assignable_imp<_Tp, _Arg, true>
+    : public false_type
+{
+};
+
+template <class _Tp, class _Arg>
+struct is_assignable
+    : public __is_assignable_imp<_Tp, _Arg> {};
+
+// is_copy_assignable
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable
+    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
+                     const typename add_lvalue_reference<_Tp>::type> {};
+
+// is_move_assignable
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    : public is_assignable<typename add_lvalue_reference<_Tp>::type,
+                     const typename add_rvalue_reference<_Tp>::type> {};
+#else
+    : public is_copy_assignable<_Tp> {};
+#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
+//    where _Up is remove_all_extents<_Tp>::type
+
+template <class>
+struct __is_destructible_apply { typedef int type; };
+
+template <typename _Tp>
+struct __is_destructor_wellformed {
+	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 <class _Tp, bool>
+struct __destructible_imp;
+
+template <class _Tp>
+struct __destructible_imp<_Tp, false> 
+   : public _VSTD::integral_constant<bool, 
+        __is_destructor_wellformed<typename _VSTD::remove_all_extents<_Tp>::type>::value> {};
+
+template <class _Tp>
+struct __destructible_imp<_Tp, true>
+    : public _VSTD::true_type {};
+
+template <class _Tp, bool>
+struct __destructible_false;
+
+template <class _Tp>
+struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, _VSTD::is_reference<_Tp>::value> {};
+
+template <class _Tp>
+struct __destructible_false<_Tp, true> : public _VSTD::false_type {};
+
+template <class _Tp>
+struct is_destructible
+    : public __destructible_false<_Tp, _VSTD::is_function<_Tp>::value> {};
+
+template <class _Tp>
+struct is_destructible<_Tp[]>
+    : public _VSTD::false_type {};
+
+template <>
+struct is_destructible<void>
+    : public _VSTD::false_type {};
+
+// move
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename remove_reference<_Tp>::type&&
+move(_Tp&& __t) _NOEXCEPT
+{
+    typedef typename remove_reference<_Tp>::type _Up;
+    return static_cast<_Up&&>(__t);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&&
+forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
+{
+    return static_cast<_Tp&&>(__t);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp&&
+forward(typename std::remove_reference<_Tp>::type&& __t) _NOEXCEPT
+{
+    static_assert(!std::is_lvalue_reference<_Tp>::value,
+                  "Can not forward an rvalue as an lvalue.");
+    return static_cast<_Tp&&>(__t);
+}
+
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp&
+move(_Tp& __t)
+{
+    return __t;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Tp&
+move(const _Tp& __t)
+{
+    return __t;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp&
+forward(typename std::remove_reference<_Tp>::type& __t) _NOEXCEPT
+{
+    return __t;
+}
+
+
+template <class _Tp>
+class __rv
+{
+    typedef typename remove_reference<_Tp>::type _Trr;
+    _Trr& t_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    _Trr* operator->() {return &t_;}
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __rv(_Trr& __t) : t_(__t) {}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename decay<_Tp>::type
+__decay_copy(_Tp&& __t)
+{
+    return _VSTD::forward<_Tp>(__t);
+}
+
+#else
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+typename decay<_Tp>::type
+__decay_copy(const _Tp& __t)
+{
+    return _VSTD::forward<_Tp>(__t);
+}
+
+#endif
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false>
+{
+    typedef _Class _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false>
+{
+    typedef _Class const _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false>
+{
+    typedef _Class volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false>
+{
+    typedef _Class const volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+#if __has_feature(cxx_reference_qualified_functions)
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
+{
+    typedef _Class& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false>
+{
+    typedef _Class const& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false>
+{
+    typedef _Class volatile& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false>
+{
+    typedef _Class const volatile& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false>
+{
+    typedef _Class&& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false>
+{
+    typedef _Class const&& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false>
+{
+    typedef _Class volatile&& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false>
+{
+    typedef _Class const volatile&& _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_Param...);
+};
+
+#endif  // __has_feature(cxx_reference_qualified_functions)
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Rp, class _Class>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(), true, false>
+{
+    typedef _Class _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) ();
+};
+
+template <class _Rp, class _Class, class _P0>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0), true, false>
+{
+    typedef _Class _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1), true, false>
+{
+    typedef _Class _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1, class _P2>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2), true, false>
+{
+    typedef _Class _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1, _P2);
+};
+
+template <class _Rp, class _Class>
+struct __member_pointer_traits_imp<_Rp (_Class::*)() const, true, false>
+{
+    typedef _Class const _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) ();
+};
+
+template <class _Rp, class _Class, class _P0>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const, true, false>
+{
+    typedef _Class const _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const, true, false>
+{
+    typedef _Class const _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1, class _P2>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const, true, false>
+{
+    typedef _Class const _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1, _P2);
+};
+
+template <class _Rp, class _Class>
+struct __member_pointer_traits_imp<_Rp (_Class::*)() volatile, true, false>
+{
+    typedef _Class volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) ();
+};
+
+template <class _Rp, class _Class, class _P0>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) volatile, true, false>
+{
+    typedef _Class volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) volatile, true, false>
+{
+    typedef _Class volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1, class _P2>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) volatile, true, false>
+{
+    typedef _Class volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1, _P2);
+};
+
+template <class _Rp, class _Class>
+struct __member_pointer_traits_imp<_Rp (_Class::*)() const volatile, true, false>
+{
+    typedef _Class const volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) ();
+};
+
+template <class _Rp, class _Class, class _P0>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0) const volatile, true, false>
+{
+    typedef _Class const volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1) const volatile, true, false>
+{
+    typedef _Class const volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1);
+};
+
+template <class _Rp, class _Class, class _P0, class _P1, class _P2>
+struct __member_pointer_traits_imp<_Rp (_Class::*)(_P0, _P1, _P2) const volatile, true, false>
+{
+    typedef _Class const volatile _ClassType;
+    typedef _Rp _ReturnType;
+    typedef _Rp (_FnType) (_P0, _P1, _P2);
+};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Rp, class _Class>
+struct __member_pointer_traits_imp<_Rp _Class::*, false, true>
+{
+    typedef _Class _ClassType;
+    typedef _Rp _ReturnType;
+};
+
+template <class _MP>
+struct __member_pointer_traits
+    : public __member_pointer_traits_imp<typename remove_cv<_MP>::type,
+                    is_member_function_pointer<_MP>::value,
+                    is_member_object_pointer<_MP>::value>
+{
+//     typedef ... _ClassType;
+//     typedef ... _ReturnType;
+//     typedef ... _FnType;
+};
+
+// result_of
+
+template <class _Callable> class result_of;
+
+#ifdef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Fn, bool, bool>
+class __result_of
+{
+};
+
+template <class _Fn>
+class __result_of<_Fn(), true, false>
+{
+public:
+    typedef decltype(declval<_Fn>()()) type;
+};
+
+template <class _Fn, class _A0>
+class __result_of<_Fn(_A0), true, false>
+{
+public:
+    typedef decltype(declval<_Fn>()(declval<_A0>())) type;
+};
+
+template <class _Fn, class _A0, class _A1>
+class __result_of<_Fn(_A0, _A1), true, false>
+{
+public:
+    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>())) type;
+};
+
+template <class _Fn, class _A0, class _A1, class _A2>
+class __result_of<_Fn(_A0, _A1, _A2), true, false>
+{
+public:
+    typedef decltype(declval<_Fn>()(declval<_A0>(), declval<_A1>(), declval<_A2>())) type;
+};
+
+template <class _MP, class _Tp, bool _IsMemberFunctionPtr>
+struct __result_of_mp;
+
+// member function pointer
+
+template <class _MP, class _Tp>
+struct __result_of_mp<_MP, _Tp, true>
+    : public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
+{
+};
+
+// member data pointer
+
+template <class _MP, class _Tp, bool>
+struct __result_of_mdp;
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mdp<_Rp _Class::*, _Tp, false>
+{
+    typedef typename __apply_cv<decltype(*_VSTD::declval<_Tp>()), _Rp>::type& type;
+};
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mdp<_Rp _Class::*, _Tp, true>
+{
+    typedef typename __apply_cv<_Tp, _Rp>::type& type;
+};
+
+template <class _Rp, class _Class, class _Tp>
+struct __result_of_mp<_Rp _Class::*, _Tp, false>
+    : public __result_of_mdp<_Rp _Class::*, _Tp,
+            is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
+{
+};
+
+
+
+template <class _Fn, class _Tp>
+class __result_of<_Fn(_Tp), false, true>  // _Fn must be member pointer
+    : public __result_of_mp<typename remove_reference<_Fn>::type,
+                            _Tp,
+                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp, class _A0>
+class __result_of<_Fn(_Tp, _A0), false, true>  // _Fn must be member pointer
+    : public __result_of_mp<typename remove_reference<_Fn>::type,
+                            _Tp,
+                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp, class _A0, class _A1>
+class __result_of<_Fn(_Tp, _A0, _A1), false, true>  // _Fn must be member pointer
+    : public __result_of_mp<typename remove_reference<_Fn>::type,
+                            _Tp,
+                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp, class _A0, class _A1, class _A2>
+class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true>  // _Fn must be member pointer
+    : public __result_of_mp<typename remove_reference<_Fn>::type,
+                            _Tp,
+                            is_member_function_pointer<typename remove_reference<_Fn>::type>::value>
+{
+};
+
+// result_of
+
+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_member_pointer<typename remove_reference<_Fn>::type>::value
+                        >
+{
+};
+
+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_member_pointer<typename remove_reference<_Fn>::type>::value
+                        >
+{
+};
+
+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_member_pointer<typename remove_reference<_Fn>::type>::value
+                        >
+{
+};
+
+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_member_pointer<typename remove_reference<_Fn>::type>::value
+                        >
+{
+};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+// template <class T, class... Args> struct is_constructible;
+
+namespace __is_construct
+{
+struct __nat {};
+}
+
+#if __has_feature(is_constructible)
+
+template <class _Tp, class ..._Args>
+struct _LIBCPP_TYPE_VIS_ONLY is_constructible
+    : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
+    {};
+
+#else
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+//      main is_constructible test
+
+template <class _Tp, class ..._Args>
+typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type
+__is_constructible_test(_Tp&&, _Args&& ...);
+
+template <class ..._Args>
+false_type
+__is_constructible_test(__any, _Args&& ...);
+
+template <bool, class _Tp, class... _Args>
+struct __libcpp_is_constructible // false, _Tp is not a scalar
+    : public common_type
+             <
+                 decltype(__is_constructible_test(declval<_Tp>(), declval<_Args>()...))
+             >::type
+    {};
+
+//      function types are not constructible
+
+template <class _Rp, class... _A1, class... _A2>
+struct __libcpp_is_constructible<false, _Rp(_A1...), _A2...>
+    : public false_type
+    {};
+
+//      handle scalars and reference types
+
+//      Scalars are default constructible, references are not
+
+template <class _Tp>
+struct __libcpp_is_constructible<true, _Tp>
+    : public is_scalar<_Tp>
+    {};
+
+//      Scalars and references are constructible from one arg if that arg is
+//          implicitly convertible to the scalar or reference.
+
+template <class _Tp>
+struct __is_constructible_ref
+{
+    true_type static __lxx(_Tp);
+    false_type static __lxx(...);
+};
+
+template <class _Tp, class _A0>
+struct __libcpp_is_constructible<true, _Tp, _A0>
+    : public common_type
+             <
+                 decltype(__is_constructible_ref<_Tp>::__lxx(declval<_A0>()))
+             >::type
+    {};
+
+//      Scalars and references are not constructible from multiple args.
+
+template <class _Tp, class _A0, class ..._Args>
+struct __libcpp_is_constructible<true, _Tp, _A0, _Args...>
+    : public false_type
+    {};
+
+//      Treat scalars and reference types separately
+
+template <bool, class _Tp, class... _Args>
+struct __is_constructible_void_check
+    : public __libcpp_is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value,
+                                _Tp, _Args...>
+    {};
+
+//      If any of T or Args is void, is_constructible should be false
+
+template <class _Tp, class... _Args>
+struct __is_constructible_void_check<true, _Tp, _Args...>
+    : public false_type
+    {};
+
+template <class ..._Args> struct __contains_void;
+
+template <> struct __contains_void<> : false_type {};
+
+template <class _A0, class ..._Args>
+struct __contains_void<_A0, _Args...>
+{
+    static const bool value = is_void<_A0>::value ||
+                              __contains_void<_Args...>::value;
+};
+
+//      is_constructible entry point
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TYPE_VIS_ONLY is_constructible
+    : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value
+                                        || is_abstract<_Tp>::value,
+                                           _Tp, _Args...>
+    {};
+
+//      Array types are default constructible if their element type
+//      is default constructible
+
+template <class _Ap, size_t _Np>
+struct __libcpp_is_constructible<false, _Ap[_Np]>
+    : public is_constructible<typename remove_all_extents<_Ap>::type>
+    {};
+
+//      Otherwise array types are not constructible by this syntax
+
+template <class _Ap, size_t _Np, class ..._Args>
+struct __libcpp_is_constructible<false, _Ap[_Np], _Args...>
+    : public false_type
+    {};
+
+//      Incomplete array types are not constructible
+
+template <class _Ap, class ..._Args>
+struct __libcpp_is_constructible<false, _Ap[], _Args...>
+    : public false_type
+    {};
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+// template <class T> struct is_constructible0;
+
+//      main is_constructible0 test
+
+template <class _Tp>
+decltype((_Tp(), true_type()))
+__is_constructible0_test(_Tp&);
+
+false_type
+__is_constructible0_test(__any);
+
+template <class _Tp, class _A0>
+decltype((_Tp(_VSTD::declval<_A0>()), true_type()))
+__is_constructible1_test(_Tp&, _A0&);
+
+template <class _A0>
+false_type
+__is_constructible1_test(__any, _A0&);
+
+template <class _Tp, class _A0, class _A1>
+decltype((_Tp(_VSTD::declval<_A0>(), _VSTD::declval<_A1>()), true_type()))
+__is_constructible2_test(_Tp&, _A0&, _A1&);
+
+template <class _A0, class _A1>
+false_type
+__is_constructible2_test(__any, _A0&, _A1&);
+
+template <bool, class _Tp>
+struct __is_constructible0_imp // false, _Tp is not a scalar
+    : public common_type
+             <
+                 decltype(__is_constructible0_test(declval<_Tp&>()))
+             >::type
+    {};
+
+template <bool, class _Tp, class _A0>
+struct __is_constructible1_imp // false, _Tp is not a scalar
+    : public common_type
+             <
+                 decltype(__is_constructible1_test(declval<_Tp&>(), declval<_A0&>()))
+             >::type
+    {};
+
+template <bool, class _Tp, class _A0, class _A1>
+struct __is_constructible2_imp // false, _Tp is not a scalar
+    : public common_type
+             <
+                 decltype(__is_constructible2_test(declval<_Tp&>(), declval<_A0>(), declval<_A1>()))
+             >::type
+    {};
+
+//      handle scalars and reference types
+
+//      Scalars are default constructible, references are not
+
+template <class _Tp>
+struct __is_constructible0_imp<true, _Tp>
+    : public is_scalar<_Tp>
+    {};
+
+template <class _Tp, class _A0>
+struct __is_constructible1_imp<true, _Tp, _A0>
+    : public is_convertible<_A0, _Tp>
+    {};
+
+template <class _Tp, class _A0, class _A1>
+struct __is_constructible2_imp<true, _Tp, _A0, _A1>
+    : public false_type
+    {};
+
+//      Treat scalars and reference types separately
+
+template <bool, class _Tp>
+struct __is_constructible0_void_check
+    : public __is_constructible0_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
+                                _Tp>
+    {};
+
+template <bool, class _Tp, class _A0>
+struct __is_constructible1_void_check
+    : public __is_constructible1_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
+                                _Tp, _A0>
+    {};
+
+template <bool, class _Tp, class _A0, class _A1>
+struct __is_constructible2_void_check
+    : public __is_constructible2_imp<is_scalar<_Tp>::value || is_reference<_Tp>::value,
+                                _Tp, _A0, _A1>
+    {};
+
+//      If any of T or Args is void, is_constructible should be false
+
+template <class _Tp>
+struct __is_constructible0_void_check<true, _Tp>
+    : public false_type
+    {};
+
+template <class _Tp, class _A0>
+struct __is_constructible1_void_check<true, _Tp, _A0>
+    : public false_type
+    {};
+
+template <class _Tp, class _A0, class _A1>
+struct __is_constructible2_void_check<true, _Tp, _A0, _A1>
+    : public false_type
+    {};
+
+//      is_constructible entry point
+
+template <class _Tp, class _A0 = __is_construct::__nat,
+                     class _A1 = __is_construct::__nat>
+struct _LIBCPP_TYPE_VIS_ONLY is_constructible
+    : public __is_constructible2_void_check<is_void<_Tp>::value
+                                        || is_abstract<_Tp>::value
+                                        || is_function<_Tp>::value
+                                        || is_void<_A0>::value
+                                        || is_void<_A1>::value,
+                                           _Tp, _A0, _A1>
+    {};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat>
+    : public __is_constructible0_void_check<is_void<_Tp>::value
+                                        || is_abstract<_Tp>::value
+                                        || is_function<_Tp>::value,
+                                           _Tp>
+    {};
+
+template <class _Tp, class _A0>
+struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat>
+    : public __is_constructible1_void_check<is_void<_Tp>::value
+                                        || is_abstract<_Tp>::value
+                                        || is_function<_Tp>::value
+                                        || is_void<_A0>::value,
+                                           _Tp, _A0>
+    {};
+
+//      Array types are default constructible if their element type
+//      is default constructible
+
+template <class _Ap, size_t _Np>
+struct __is_constructible0_imp<false, _Ap[_Np]>
+    : public is_constructible<typename remove_all_extents<_Ap>::type>
+    {};
+
+template <class _Ap, size_t _Np, class _A0>
+struct __is_constructible1_imp<false, _Ap[_Np], _A0>
+    : public false_type
+    {};
+
+template <class _Ap, size_t _Np, class _A0, class _A1>
+struct __is_constructible2_imp<false, _Ap[_Np], _A0, _A1>
+    : public false_type
+    {};
+
+//      Incomplete array types are not constructible
+
+template <class _Ap>
+struct __is_constructible0_imp<false, _Ap[]>
+    : public false_type
+    {};
+
+template <class _Ap, class _A0>
+struct __is_constructible1_imp<false, _Ap[], _A0>
+    : public false_type
+    {};
+
+template <class _Ap, class _A0, class _A1>
+struct __is_constructible2_imp<false, _Ap[], _A0, _A1>
+    : public false_type
+    {};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // __has_feature(is_constructible)
+
+// is_default_constructible
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible
+    : public is_constructible<_Tp>
+    {};
+
+// is_copy_constructible
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible
+    : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
+    {};
+
+// is_move_constructible
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+#else
+    : public is_copy_constructible<_Tp>
+#endif
+    {};
+
+// is_trivially_constructible
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#if __has_feature(is_trivially_constructible)
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
+    : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)>
+{
+};
+
+#else  // !__has_feature(is_trivially_constructible)
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
+    : false_type
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp>
+#if __has_feature(has_trivial_constructor) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_trivial_constructor(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+template <class _Tp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&>
+#else
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp>
+#endif
+    : integral_constant<bool, is_scalar<_Tp>::value>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&>
+    : integral_constant<bool, is_scalar<_Tp>::value>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&>
+    : integral_constant<bool, is_scalar<_Tp>::value>
+{
+};
+
+#endif  // !__has_feature(is_trivially_constructible)
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _A0 = __is_construct::__nat,
+                     class _A1 = __is_construct::__nat>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
+    : false_type
+{
+};
+
+#if __has_feature(is_trivially_constructible)
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, __is_trivially_constructible(_Tp)>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)>
+{
+};
+
+#else  // !__has_feature(is_trivially_constructible)
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, is_scalar<_Tp>::value>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, is_scalar<_Tp>::value>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, is_scalar<_Tp>::value>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&,
+                                                       __is_construct::__nat>
+    : integral_constant<bool, is_scalar<_Tp>::value>
+{
+};
+
+#endif  // !__has_feature(is_trivially_constructible)
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+// is_trivially_default_constructible
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible
+    : public is_trivially_constructible<_Tp>
+    {};
+
+// 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>
+    {};
+
+// is_trivially_move_constructible
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+#else
+    : public is_trivially_copy_constructible<_Tp>
+#endif
+    {};
+
+// is_trivially_assignable
+
+#if __has_feature(is_trivially_assignable)
+
+template <class _Tp, class _Arg>
+struct is_trivially_assignable
+    : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)>
+{
+};
+
+#else  // !__has_feature(is_trivially_assignable)
+
+template <class _Tp, class _Arg>
+struct is_trivially_assignable
+    : public false_type {};
+
+template <class _Tp>
+struct is_trivially_assignable<_Tp&, _Tp>
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+
+template <class _Tp>
+struct is_trivially_assignable<_Tp&, _Tp&>
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+
+template <class _Tp>
+struct is_trivially_assignable<_Tp&, const _Tp&>
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+struct is_trivially_assignable<_Tp&, _Tp&&>
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif  // !__has_feature(is_trivially_assignable)
+
+// 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,
+                               const typename add_lvalue_reference<_Tp>::type>
+    {};
+
+// is_trivially_move_assignable
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable
+    : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type,
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+                                     typename add_rvalue_reference<_Tp>::type>
+#else
+                                     typename add_lvalue_reference<_Tp>::type>
+#endif
+    {};
+
+// is_trivially_destructible
+
+#if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403)
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
+    : public integral_constant<bool, __has_trivial_destructor(_Tp)> {};
+
+#else
+
+template <class _Tp> struct __libcpp_trivial_destructor
+    : public integral_constant<bool, is_scalar<_Tp>::value ||
+                                     is_reference<_Tp>::value> {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
+    : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
+
+#endif
+
+// is_nothrow_constructible
+
+#if 0
+template <class _Tp, class... _Args>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
+    : public integral_constant<bool, __is_nothrow_constructible(_Tp(_Args...))>
+{
+};
+
+#else
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
+
+template <bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible;
+
+template <class _Tp, class... _Args>
+struct __libcpp_is_nothrow_constructible<true, _Tp, _Args...>
+    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
+{
+};
+
+template <class _Tp, class... _Args>
+struct __libcpp_is_nothrow_constructible<false, _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...>
+{
+};
+
+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>
+{
+};
+
+#else  // __has_feature(cxx_noexcept)
+
+template <class _Tp, class... _Args>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
+    : false_type
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp>
+#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+template <class _Tp>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&>
+#else
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp>
+#endif
+#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_copy(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&>
+#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_copy(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&>
+#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_copy(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+#endif  // __has_feature(cxx_noexcept)
+
+#else  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _A0 = __is_construct::__nat,
+                     class _A1 = __is_construct::__nat>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible
+    : false_type
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat,
+                                                       __is_construct::__nat>
+#if __has_feature(has_nothrow_constructor) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_constructor(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp,
+                                                       __is_construct::__nat>
+#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_copy(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&,
+                                                       __is_construct::__nat>
+#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_copy(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&,
+                                                       __is_construct::__nat>
+#if __has_feature(has_nothrow_copy) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_copy(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value>
+#endif
+{
+};
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // __has_feature(is_nothrow_constructible)
+
+// is_nothrow_default_constructible
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible
+    : public is_nothrow_constructible<_Tp>
+    {};
+
+// is_nothrow_copy_constructible
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible
+    : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type>
+    {};
+
+// is_nothrow_move_constructible
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
+#else
+    : public is_nothrow_copy_constructible<_Tp>
+#endif
+    {};
+
+// is_nothrow_assignable
+
+#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
+
+template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable;
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg>
+    : public false_type
+{
+};
+
+template <class _Tp, class _Arg>
+struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg>
+    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>()) >
+{
+};
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
+    : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg>
+{
+};
+
+#else  // __has_feature(cxx_noexcept)
+
+template <class _Tp, class _Arg>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable
+    : public false_type {};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp>
+#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&>
+#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+#endif
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&>
+#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+#endif
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+struct is_nothrow_assignable<_Tp&, _Tp&&>
+#if __has_feature(has_nothrow_assign) || (_GNUC_VER >= 403)
+    : integral_constant<bool, __has_nothrow_assign(_Tp)> {};
+#else
+    : integral_constant<bool, is_scalar<_Tp>::value> {};
+#endif
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif  // __has_feature(cxx_noexcept)
+
+// 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,
+                               const typename add_lvalue_reference<_Tp>::type>
+    {};
+
+// is_nothrow_move_assignable
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable
+    : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type,
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+                                     typename add_rvalue_reference<_Tp>::type>
+#else
+                                     typename add_lvalue_reference<_Tp>::type>
+#endif
+    {};
+
+// is_nothrow_destructible
+
+#if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L)
+
+template <bool, class _Tp> struct __libcpp_is_nothrow_destructible;
+
+template <class _Tp>
+struct __libcpp_is_nothrow_destructible<false, _Tp>
+    : public false_type
+{
+};
+
+template <class _Tp>
+struct __libcpp_is_nothrow_destructible<true, _Tp>
+    : public integral_constant<bool, noexcept(_VSTD::declval<_Tp>().~_Tp()) >
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
+    : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp>
+{
+};
+
+template <class _Tp, size_t _Ns>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]>
+    : public is_nothrow_destructible<_Tp>
+{
+};
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&>
+    : public true_type
+{
+};
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&>
+    : public true_type
+{
+};
+
+#endif
+
+#else
+
+template <class _Tp> struct __libcpp_nothrow_destructor
+    : public integral_constant<bool, is_scalar<_Tp>::value ||
+                                     is_reference<_Tp>::value> {};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
+    : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
+
+#endif
+
+// is_pod
+
+#if __has_feature(is_pod) || (_GNUC_VER >= 403)
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
+    : public integral_constant<bool, __is_pod(_Tp)> {};
+
+#else
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod
+    : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value   &&
+                                     is_trivially_copy_constructible<_Tp>::value      &&
+                                     is_trivially_copy_assignable<_Tp>::value    &&
+                                     is_trivially_destructible<_Tp>::value> {};
+
+#endif
+
+// is_literal_type;
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type
+#ifdef _LIBCPP_IS_LITERAL
+    : public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
+                              is_reference<typename remove_all_extents<_Tp>::type>::value>
+#endif
+    {};
+    
+// is_standard_layout;
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
+#if __has_feature(is_standard_layout) || (_GNUC_VER >= 407)
+    : public integral_constant<bool, __is_standard_layout(_Tp)>
+#else
+    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::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)>
+#else
+    : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
+#endif
+    {};
+    
+// is_trivial;
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
+#if __has_feature(is_trivial) || (_GNUC_VER >= 407)
+    : public integral_constant<bool, __is_trivial(_Tp)>
+#else
+    : integral_constant<bool, is_trivially_copyable<_Tp>::value &&
+                                 is_trivially_default_constructible<_Tp>::value>
+#endif
+    {};
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+// Check for complete types
+
+template <class ..._Tp> struct __check_complete;
+
+template <>
+struct __check_complete<>
+{
+};
+
+template <class _Hp, class _T0, class ..._Tp>
+struct __check_complete<_Hp, _T0, _Tp...>
+    : private __check_complete<_Hp>,
+      private __check_complete<_T0, _Tp...>
+{
+};
+
+template <class _Hp>
+struct __check_complete<_Hp, _Hp>
+    : private __check_complete<_Hp>
+{
+};
+
+template <class _Tp>
+struct __check_complete<_Tp>
+{
+    static_assert(sizeof(_Tp) > 0, "Type must be complete.");
+};
+
+template <class _Tp>
+struct __check_complete<_Tp&>
+    : private __check_complete<_Tp>
+{
+};
+
+template <class _Tp>
+struct __check_complete<_Tp&&>
+    : private __check_complete<_Tp>
+{
+};
+
+template <class _Rp, class ..._Param>
+struct __check_complete<_Rp (*)(_Param...)>
+    : private __check_complete<_Rp>
+{
+};
+
+template <class ..._Param>
+struct __check_complete<void (*)(_Param...)>
+{
+};
+
+template <class _Rp, class ..._Param>
+struct __check_complete<_Rp (_Param...)>
+    : private __check_complete<_Rp>
+{
+};
+
+template <class ..._Param>
+struct __check_complete<void (_Param...)>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...)>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) const>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) volatile>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) const volatile>
+    : private __check_complete<_Class>
+{
+};
+
+#if __has_feature(cxx_reference_qualified_functions)
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) &>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) const&>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) volatile&>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) &&>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) const&&>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) volatile&&>
+    : private __check_complete<_Class>
+{
+};
+
+template <class _Rp, class _Class, class ..._Param>
+struct __check_complete<_Rp (_Class::*)(_Param...) const volatile&&>
+    : private __check_complete<_Class>
+{
+};
+
+#endif
+
+template <class _Rp, class _Class>
+struct __check_complete<_Rp _Class::*>
+    : private __check_complete<_Class>
+{
+};
+
+// __invoke forward declarations
+
+// fall back - none of the bullets
+
+template <class ..._Args>
+auto
+__invoke(__any, _Args&& ...__args)
+    -> __nat;
+
+// bullets 1 and 2
+
+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
+auto
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+    -> decltype((_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
+auto
+__invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args)
+    -> decltype(((*_VSTD::forward<_A0>(__a0)).*__f)(_VSTD::forward<_Args>(__args)...));
+
+// bullets 3 and 4
+
+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
+auto
+__invoke(_Fp&& __f, _A0&& __a0)
+    -> decltype(_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
+auto
+__invoke(_Fp&& __f, _A0&& __a0)
+    -> decltype((*_VSTD::forward<_A0>(__a0)).*__f);
+
+// bullet 5
+
+template <class _Fp, class ..._Args>
+_LIBCPP_INLINE_VISIBILITY
+auto
+__invoke(_Fp&& __f, _Args&& ...__args)
+    -> decltype(_VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...));
+
+// __invokable
+
+template <class _Fp, class ..._Args>
+struct __invokable_imp
+    : private __check_complete<_Fp>
+{
+    typedef decltype(
+            __invoke(_VSTD::declval<_Fp>(), _VSTD::declval<_Args>()...)
+                    ) type;
+    static const bool value = !is_same<type, __nat>::value;
+};
+
+template <class _Fp, class ..._Args>
+struct __invokable
+    : public integral_constant<bool,
+          __invokable_imp<_Fp, _Args...>::value>
+{
+};
+
+// __invoke_of
+
+template <bool _Invokable, class _Fp, class ..._Args>
+struct __invoke_of_imp  // false
+{
+};
+
+template <class _Fp, class ..._Args>
+struct __invoke_of_imp<true, _Fp, _Args...>
+{
+    typedef typename __invokable_imp<_Fp, _Args...>::type type;
+};
+
+template <class _Fp, class ..._Args>
+struct __invoke_of
+    : public __invoke_of_imp<__invokable<_Fp, _Args...>::value, _Fp, _Args...>
+{
+};
+
+template <class _Fp, class ..._Args>
+class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)>
+    : public __invoke_of<_Fp, _Args...>
+{
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
+#endif
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+typename enable_if
+<
+    is_move_constructible<_Tp>::value &&
+    is_move_assignable<_Tp>::value
+>::type
+#else
+void
+#endif
+swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value &&
+                                    is_nothrow_move_assignable<_Tp>::value)
+{
+    _Tp __t(_VSTD::move(__x));
+    __x = _VSTD::move(__y);
+    __y = _VSTD::move(__t);
+}
+
+template <class _ForwardIterator1, class _ForwardIterator2>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b)
+    //                                  _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
+               _NOEXCEPT_(_NOEXCEPT_(swap(*_VSTD::declval<_ForwardIterator1>(),
+                                          *_VSTD::declval<_ForwardIterator2>())))
+{
+    swap(*__a, *__b);
+}
+
+// __swappable
+
+namespace __detail
+{
+
+using _VSTD::swap;
+__nat swap(__any, __any);
+
+template <class _Tp>
+struct __swappable
+{
+    typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
+    static const bool value = !is_same<type, __nat>::value;
+};
+
+}  // __detail
+
+template <class _Tp>
+struct __is_swappable
+    : public integral_constant<bool, __detail::__swappable<_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_imp<false, _Tp>
+    : public false_type
+{
+};
+
+template <class _Tp>
+struct __is_nothrow_swappable
+    : public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
+{
+};
+
+#else  // __has_feature(cxx_noexcept)
+
+template <class _Tp>
+struct __is_nothrow_swappable
+    : public false_type
+{
+};
+
+#endif  // __has_feature(cxx_noexcept)
+
+#ifdef _LIBCPP_UNDERLYING_TYPE
+
+template <class _Tp>
+struct underlying_type
+{
+    typedef _LIBCPP_UNDERLYING_TYPE(_Tp) type;
+};
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type;
+#endif
+
+#else  // _LIBCPP_UNDERLYING_TYPE
+
+template <class _Tp, bool _Support = false>
+struct underlying_type
+{
+    static_assert(_Support, "The underyling_type trait requires compiler "
+                            "support. Either no such support exists or "
+                            "libc++ does not know how to use it.");
+};
+
+#endif // _LIBCPP_UNDERLYING_TYPE
+
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+template <class _Tp>
+struct __has_operator_addressof_imp
+{
+    template <class>
+        static auto __test(__any) -> false_type;
+    template <class _Up>
+        static auto __test(_Up* __u)
+            -> typename __select_2nd<decltype(__u->operator&()), true_type>::type;
+
+    static const bool value = decltype(__test<_Tp>(nullptr))::value;
+};
+
+template <class _Tp>
+struct __has_operator_addressof
+    : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value>
+{};
+
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_TYPE_TRAITS
diff --git a/final/include/typeindex b/final/include/typeindex
new file mode 100644
index 0000000..d4d6ca9
--- /dev/null
+++ b/final/include/typeindex
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+//===-------------------------- typeindex ---------------------------------===//
+//
+//                     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_TYPEINDEX
+#define _LIBCPP_TYPEINDEX
+
+/*
+
+    typeindex synopsis
+
+namespace std
+{
+
+class type_index
+{
+public:
+    type_index(const type_info& rhs) noexcept;
+
+    bool operator==(const type_index& rhs) const noexcept;
+    bool operator!=(const type_index& rhs) const noexcept;
+    bool operator< (const type_index& rhs) const noexcept;
+    bool operator<=(const type_index& rhs) const noexcept;
+    bool operator> (const type_index& rhs) const noexcept;
+    bool operator>=(const type_index& rhs) const noexcept;
+
+    size_t hash_code() const noexcept;
+    const char* name() const noexcept;
+};
+
+template <>
+struct hash<type_index>
+    : public unary_function<type_index, size_t>
+{
+    size_t operator()(type_index index) const noexcept;
+};
+
+}  // std
+
+*/
+
+#include <__config>
+#include <typeinfo>
+#include <__functional_base>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_TYPE_VIS_ONLY type_index
+{
+    const type_info* __t_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const type_index& __y) const _NOEXCEPT
+        {return *__t_ == *__y.__t_;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const type_index& __y) const _NOEXCEPT
+        {return *__t_ != *__y.__t_;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator< (const type_index& __y) const _NOEXCEPT
+        {return  __t_->before(*__y.__t_);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator<=(const type_index& __y) const _NOEXCEPT
+        {return !__y.__t_->before(*__t_);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator> (const type_index& __y) const _NOEXCEPT
+        {return  __y.__t_->before(*__t_);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator>=(const type_index& __y) const _NOEXCEPT
+        {return !__t_->before(*__y.__t_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
+    _LIBCPP_INLINE_VISIBILITY
+    const char* name() const _NOEXCEPT {return __t_->name();}
+};
+
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
+
+template <>
+struct _LIBCPP_TYPE_VIS_ONLY hash<type_index>
+    : public unary_function<type_index, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(type_index __index) const _NOEXCEPT
+        {return __index.hash_code();}
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_TYPEINDEX
diff --git a/final/include/typeinfo b/final/include/typeinfo
new file mode 100644
index 0000000..14ef77b
--- /dev/null
+++ b/final/include/typeinfo
@@ -0,0 +1,168 @@
+// -*- C++ -*-
+//===-------------------------- typeinfo ----------------------------------===//
+//
+//                     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_TYPEINFO
+#define __LIBCPP_TYPEINFO
+
+/*
+
+    typeinfo synopsis
+
+namespace std {
+
+class type_info
+{
+public:
+    virtual ~type_info();
+
+    bool operator==(const type_info& rhs) const noexcept;
+    bool operator!=(const type_info& rhs) const noexcept;
+
+    bool before(const type_info& rhs) const noexcept;
+    size_t hash_code() const noexcept;
+    const char* name() const noexcept;
+
+    type_info(const type_info& rhs) = delete;
+    type_info& operator=(const type_info& rhs) = delete;
+};
+
+class bad_cast
+    : public exception
+{
+public:
+    bad_cast() noexcept;
+    bad_cast(const bad_cast&) noexcept;
+    bad_cast& operator=(const bad_cast&) noexcept;
+    virtual const char* what() const noexcept;
+};
+
+class bad_typeid
+    : public exception
+{
+public:
+    bad_typeid() noexcept;
+    bad_typeid(const bad_typeid&) noexcept;
+    bad_typeid& operator=(const bad_typeid&) noexcept;
+    virtual const char* what() const noexcept;
+};
+
+}  // std
+
+*/
+
+#include <__config>
+#include <exception>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+namespace std  // purposefully not using versioning namespace
+{
+
+class _LIBCPP_EXCEPTION_ABI type_info
+{
+    type_info& operator=(const type_info&);
+    type_info(const type_info&);
+protected:
+#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
+    const char* __type_name;
+#else
+    // A const char* with the non-unique RTTI bit possibly set.
+    uintptr_t __type_name;
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit type_info(const char* __n)
+#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
+        : __type_name(__n) {}
+#else
+        : __type_name(reinterpret_cast<uintptr_t>(__n)) {}
+#endif
+
+public:
+    virtual ~type_info();
+
+    _LIBCPP_INLINE_VISIBILITY
+    const char* name() const _NOEXCEPT
+#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
+        {return __type_name;}
+#else
+        {return reinterpret_cast<const char*>(__type_name & ~_LIBCPP_NONUNIQUE_RTTI_BIT);}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool before(const type_info& __arg) const _NOEXCEPT
+#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
+        {return __type_name < __arg.__type_name;}
+#else
+        {if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
+           return __type_name < __arg.__type_name;
+         return __compare_nonunique_names(__arg) < 0;}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t hash_code() const _NOEXCEPT
+#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
+        {return *reinterpret_cast<const size_t*>(&__type_name);}
+#else
+        {if (!(__type_name & _LIBCPP_NONUNIQUE_RTTI_BIT)) return __type_name;
+         const char *__ptr = name();
+         size_t __hash = 5381;
+         while (unsigned char __c = static_cast<unsigned char>(*__ptr++))
+           __hash = (__hash * 33) ^ __c;
+         return __hash;}
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator==(const type_info& __arg) const _NOEXCEPT
+#ifndef _LIBCPP_NONUNIQUE_RTTI_BIT
+        {return __type_name == __arg.__type_name;}
+#else
+        {if (__type_name == __arg.__type_name) return true;
+         if (!((__type_name & __arg.__type_name) & _LIBCPP_NONUNIQUE_RTTI_BIT))
+           return false;
+         return __compare_nonunique_names(__arg) == 0;}
+#endif
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator!=(const type_info& __arg) const _NOEXCEPT
+        {return !operator==(__arg);}
+
+#ifdef _LIBCPP_NONUNIQUE_RTTI_BIT
+  private:
+    _LIBCPP_INLINE_VISIBILITY
+    int __compare_nonunique_names(const type_info &__arg) const _NOEXCEPT
+        {return __builtin_strcmp(name(), __arg.name());}
+#endif
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_cast
+    : public exception
+{
+public:
+    bad_cast() _NOEXCEPT;
+    virtual ~bad_cast() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_typeid
+    : public exception
+{
+public:
+    bad_typeid() _NOEXCEPT;
+    virtual ~bad_typeid() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+}  // std
+
+#endif  // __LIBCPP_TYPEINFO
diff --git a/final/include/unordered_map b/final/include/unordered_map
new file mode 100644
index 0000000..4e2298b
--- /dev/null
+++ b/final/include/unordered_map
@@ -0,0 +1,2082 @@
+// -*- C++ -*-
+//===-------------------------- unordered_map -----------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_UNORDERED_MAP
+#define _LIBCPP_UNORDERED_MAP
+
+/*
+
+    unordered_map synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+          class Alloc = allocator<pair<const Key, T>>>
+class unordered_map
+{
+public:
+    // types
+    typedef Key                                                        key_type;
+    typedef T                                                          mapped_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef pair<const key_type, mapped_type>                          value_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+    typedef /unspecified/ local_iterator;
+    typedef /unspecified/ const_local_iterator;
+
+    unordered_map()
+        noexcept(
+            is_nothrow_default_constructible<hasher>::value &&
+            is_nothrow_default_constructible<key_equal>::value &&
+            is_nothrow_default_constructible<allocator_type>::value);
+    explicit unordered_map(size_type n, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        unordered_map(InputIterator f, InputIterator l,
+                      size_type n = 0, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    explicit unordered_map(const allocator_type&);
+    unordered_map(const unordered_map&);
+    unordered_map(const unordered_map&, const Allocator&);
+    unordered_map(unordered_map&&)
+        noexcept(
+            is_nothrow_move_constructible<hasher>::value &&
+            is_nothrow_move_constructible<key_equal>::value &&
+            is_nothrow_move_constructible<allocator_type>::value);
+    unordered_map(unordered_map&&, const Allocator&);
+    unordered_map(initializer_list<value_type>, size_type n = 0,
+                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+                  const allocator_type& a = allocator_type());
+    unordered_map(size_type n, const allocator_type& a)
+      : unordered_map(n, hasher(), key_equal(), a) {}  // C++14
+    unordered_map(size_type n, const hasher& hf, const allocator_type& a)
+      : unordered_map(n, hf, key_equal(), a) {}  // C++14
+    template <class InputIterator>
+      unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
+      : unordered_map(f, l, n, hasher(), key_equal(), a) {}  // C++14
+    template <class InputIterator>
+      unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, 
+        const allocator_type& a)
+      : unordered_map(f, l, n, hf, key_equal(), a) {}  // C++14
+    unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
+      : unordered_map(il, n, hasher(), key_equal(), a) {}  // C++14
+    unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, 
+      const allocator_type& a)
+      : unordered_map(il, n, hf, key_equal(), a) {}  // C++14
+    ~unordered_map();
+    unordered_map& operator=(const unordered_map&);
+    unordered_map& operator=(unordered_map&&)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<hasher>::value &&
+            is_nothrow_move_assignable<key_equal>::value);
+    unordered_map& operator=(initializer_list<value_type>);
+
+    allocator_type get_allocator() const noexcept;
+
+    bool      empty() const noexcept;
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+
+    iterator       begin() noexcept;
+    iterator       end() noexcept;
+    const_iterator begin()  const noexcept;
+    const_iterator end()    const noexcept;
+    const_iterator cbegin() const noexcept;
+    const_iterator cend()   const noexcept;
+
+    template <class... Args>
+        pair<iterator, bool> emplace(Args&&... args);
+    template <class... Args>
+        iterator emplace_hint(const_iterator position, Args&&... args);
+    pair<iterator, bool> insert(const value_type& obj);
+    template <class P>
+        pair<iterator, bool> insert(P&& obj);
+    iterator insert(const_iterator hint, const value_type& obj);
+    template <class P>
+        iterator insert(const_iterator hint, P&& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+    void insert(initializer_list<value_type>);
+
+    iterator erase(const_iterator position);
+    size_type erase(const key_type& k);
+    iterator erase(const_iterator first, const_iterator last);
+    void clear() noexcept;
+
+    void swap(unordered_map&)
+        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);
+
+    hasher hash_function() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    mapped_type& operator[](const key_type& k);
+    mapped_type& operator[](key_type&& k);
+
+    mapped_type&       at(const key_type& k);
+    const mapped_type& at(const key_type& k) const;
+
+    size_type bucket_count() const noexcept;
+    size_type max_bucket_count() const noexcept;
+
+    size_type bucket_size(size_type n) const;
+    size_type bucket(const key_type& k) const;
+
+    local_iterator       begin(size_type n);
+    local_iterator       end(size_type n);
+    const_local_iterator begin(size_type n) const;
+    const_local_iterator end(size_type n) const;
+    const_local_iterator cbegin(size_type n) const;
+    const_local_iterator cend(size_type n) const;
+
+    float load_factor() const noexcept;
+    float max_load_factor() const noexcept;
+    void max_load_factor(float z);
+    void rehash(size_type n);
+    void reserve(size_type n);
+};
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x,
+              unordered_map<Key, T, Hash, Pred, Alloc>& y)
+              noexcept(noexcept(x.swap(y)));
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+               const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+          class Alloc = allocator<pair<const Key, T>>>
+class unordered_multimap
+{
+public:
+    // types
+    typedef Key                                                        key_type;
+    typedef T                                                          mapped_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef pair<const key_type, mapped_type>                          value_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+    typedef /unspecified/ local_iterator;
+    typedef /unspecified/ const_local_iterator;
+
+    unordered_multimap()
+        noexcept(
+            is_nothrow_default_constructible<hasher>::value &&
+            is_nothrow_default_constructible<key_equal>::value &&
+            is_nothrow_default_constructible<allocator_type>::value);
+    explicit unordered_multimap(size_type n, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        unordered_multimap(InputIterator f, InputIterator l,
+                      size_type n = 0, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    explicit unordered_multimap(const allocator_type&);
+    unordered_multimap(const unordered_multimap&);
+    unordered_multimap(const unordered_multimap&, const Allocator&);
+    unordered_multimap(unordered_multimap&&)
+        noexcept(
+            is_nothrow_move_constructible<hasher>::value &&
+            is_nothrow_move_constructible<key_equal>::value &&
+            is_nothrow_move_constructible<allocator_type>::value);
+    unordered_multimap(unordered_multimap&&, const Allocator&);
+    unordered_multimap(initializer_list<value_type>, size_type n = 0,
+                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+                  const allocator_type& a = allocator_type());
+    unordered_multimap(size_type n, const allocator_type& a)
+      : unordered_multimap(n, hasher(), key_equal(), a) {}  // C++14
+    unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
+      : unordered_multimap(n, hf, key_equal(), a) {}  // C++14
+    template <class InputIterator>
+      unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
+      : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}  // C++14
+    template <class InputIterator>
+      unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, 
+        const allocator_type& a)
+      : unordered_multimap(f, l, n, hf, key_equal(), a) {}  // C++14
+    unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
+      : unordered_multimap(il, n, hasher(), key_equal(), a) {}  // C++14
+    unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, 
+      const allocator_type& a)
+      : unordered_multimap(il, n, hf, key_equal(), a) {}  // C++14
+    ~unordered_multimap();
+    unordered_multimap& operator=(const unordered_multimap&);
+    unordered_multimap& operator=(unordered_multimap&&)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<hasher>::value &&
+            is_nothrow_move_assignable<key_equal>::value);
+    unordered_multimap& operator=(initializer_list<value_type>);
+
+    allocator_type get_allocator() const noexcept;
+
+    bool      empty() const noexcept;
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+
+    iterator       begin() noexcept;
+    iterator       end() noexcept;
+    const_iterator begin()  const noexcept;
+    const_iterator end()    const noexcept;
+    const_iterator cbegin() const noexcept;
+    const_iterator cend()   const noexcept;
+
+    template <class... Args>
+        iterator emplace(Args&&... args);
+    template <class... Args>
+        iterator emplace_hint(const_iterator position, Args&&... args);
+    iterator insert(const value_type& obj);
+    template <class P>
+        iterator insert(P&& obj);
+    iterator insert(const_iterator hint, const value_type& obj);
+    template <class P>
+        iterator insert(const_iterator hint, P&& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+    void insert(initializer_list<value_type>);
+
+    iterator erase(const_iterator position);
+    size_type erase(const key_type& k);
+    iterator erase(const_iterator first, const_iterator last);
+    void clear() noexcept;
+
+    void swap(unordered_multimap&)
+        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);
+
+    hasher hash_function() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    size_type bucket_count() const noexcept;
+    size_type max_bucket_count() const noexcept;
+
+    size_type bucket_size(size_type n) const;
+    size_type bucket(const key_type& k) const;
+
+    local_iterator       begin(size_type n);
+    local_iterator       end(size_type n);
+    const_local_iterator begin(size_type n) const;
+    const_local_iterator end(size_type n) const;
+    const_local_iterator cbegin(size_type n) const;
+    const_local_iterator cend(size_type n) const;
+
+    float load_factor() const noexcept;
+    float max_load_factor() const noexcept;
+    void max_load_factor(float z);
+    void rehash(size_type n);
+    void reserve(size_type n);
+};
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+              unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
+              noexcept(noexcept(x.swap(y)));
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+template <class Key, class T, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+               const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__hash_table>
+#include <functional>
+#include <stdexcept>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_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
+         >
+class __unordered_map_hasher
+    : private _Hash
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_hasher()
+        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
+        : _Hash() {}
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_hasher(const _Hash& __h)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
+        : _Hash(__h) {}
+    _LIBCPP_INLINE_VISIBILITY
+    const _Hash& hash_function() const _NOEXCEPT {return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const _Cp& __x) const
+        {return static_cast<const _Hash&>(*this)(__x.__cc.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const _Key& __x) const
+        {return static_cast<const _Hash&>(*this)(__x);}
+};
+
+template <class _Key, class _Cp, class _Hash>
+class __unordered_map_hasher<_Key, _Cp, _Hash, false>
+{
+    _Hash __hash_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_hasher()
+        _NOEXCEPT_(is_nothrow_default_constructible<_Hash>::value)
+        : __hash_() {}
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_hasher(const _Hash& __h)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
+        : __hash_(__h) {}
+    _LIBCPP_INLINE_VISIBILITY
+    const _Hash& hash_function() const _NOEXCEPT {return __hash_;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const _Cp& __x) const
+        {return __hash_(__x.__cc.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const _Key& __x) const
+        {return __hash_(__x);}
+};
+
+template <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
+#if __has_feature(is_final)
+                                         && !__is_final(_Pred)
+#endif
+         >
+class __unordered_map_equal
+    : private _Pred
+{
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_equal()
+        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
+        : _Pred() {}
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_equal(const _Pred& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
+        : _Pred(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    const _Pred& key_eq() const _NOEXCEPT {return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Cp& __x, const _Cp& __y) const
+        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y.__cc.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Cp& __x, const _Key& __y) const
+        {return static_cast<const _Pred&>(*this)(__x.__cc.first, __y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Key& __x, const _Cp& __y) const
+        {return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
+};
+
+template <class _Key, class _Cp, class _Pred>
+class __unordered_map_equal<_Key, _Cp, _Pred, false>
+{
+    _Pred __pred_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_equal()
+        _NOEXCEPT_(is_nothrow_default_constructible<_Pred>::value)
+        : __pred_() {}
+    _LIBCPP_INLINE_VISIBILITY
+    __unordered_map_equal(const _Pred& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
+        : __pred_(__p) {}
+    _LIBCPP_INLINE_VISIBILITY
+    const _Pred& key_eq() const _NOEXCEPT {return __pred_;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Cp& __x, const _Cp& __y) const
+        {return __pred_(__x.__cc.first, __y.__cc.first);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Cp& __x, const _Key& __y) const
+        {return __pred_(__x.__cc.first, __y);}
+    _LIBCPP_INLINE_VISIBILITY
+    bool operator()(const _Key& __x, const _Cp& __y) const
+        {return __pred_(__x, __y.__cc.first);}
+};
+
+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;
+private:
+    typedef typename value_type::value_type::first_type     first_type;
+    typedef typename value_type::value_type::second_type    second_type;
+
+    allocator_type& __na_;
+
+    __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
+
+public:
+    bool __first_constructed;
+    bool __second_constructed;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
+        : __na_(__na),
+          __first_constructed(false),
+          __second_constructed(false)
+        {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
+        _NOEXCEPT
+        : __na_(__x.__na_),
+          __first_constructed(__x.__value_constructed),
+          __second_constructed(__x.__value_constructed)
+        {
+            __x.__value_constructed = false;
+        }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
+        : __na_(__x.__na_),
+          __first_constructed(__x.__value_constructed),
+          __second_constructed(__x.__value_constructed)
+        {
+            const_cast<bool&>(__x.__value_constructed) = false;
+        }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    void operator()(pointer __p) _NOEXCEPT
+    {
+        if (__second_constructed)
+            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.second));
+        if (__first_constructed)
+            __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__cc.first));
+        if (__p)
+            __alloc_traits::deallocate(__na_, __p, 1);
+    }
+};
+
+#if __cplusplus >= 201103L
+
+template <class _Key, class _Tp>
+union __hash_value_type
+{
+    typedef _Key                                     key_type;
+    typedef _Tp                                      mapped_type;
+    typedef pair<const key_type, mapped_type>        value_type;
+    typedef pair<key_type, mapped_type>              __nc_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;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    ~__hash_value_type() {__cc.~value_type();}
+};
+
+#else
+
+template <class _Key, class _Tp>
+struct __hash_value_type
+{
+    typedef _Key                                     key_type;
+    typedef _Tp                                      mapped_type;
+    typedef pair<const key_type, mapped_type>        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) {}
+};
+
+#endif
+
+template <class _HashIterator>
+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;
+public:
+    typedef forward_iterator_tag                                 iterator_category;
+    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;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_iterator() _NOEXCEPT {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return __i_->__cc;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_iterator& operator++() {++__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_iterator operator++(int)
+    {
+        __hash_map_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
+        {return __x.__i_ == __y.__i_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
+        {return __x.__i_ != __y.__i_;}
+
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
+};
+
+template <class _HashIterator>
+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;
+public:
+    typedef forward_iterator_tag                                 iterator_category;
+    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;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator() _NOEXCEPT {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator(
+            __hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
+                 _NOEXCEPT
+                : __i_(__i.__i_) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reference operator*() const {return __i_->__cc;}
+    _LIBCPP_INLINE_VISIBILITY
+    pointer operator->() const {return pointer_traits<pointer>::pointer_to(__i_->__cc);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator& operator++() {++__i_; return *this;}
+    _LIBCPP_INLINE_VISIBILITY
+    __hash_map_const_iterator operator++(int)
+    {
+        __hash_map_const_iterator __t(*this);
+        ++(*this);
+        return __t;
+    }
+
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
+        {return __x.__i_ == __y.__i_;}
+    friend _LIBCPP_INLINE_VISIBILITY
+        bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
+        {return __x.__i_ != __y.__i_;}
+
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map;
+    template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator;
+};
+
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
+          class _Alloc = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TYPE_VIS_ONLY unordered_map
+{
+public:
+    // types
+    typedef _Key                                           key_type;
+    typedef _Tp                                            mapped_type;
+    typedef _Hash                                          hasher;
+    typedef _Pred                                          key_equal;
+    typedef _Alloc                                         allocator_type;
+    typedef pair<const key_type, mapped_type>              value_type;
+    typedef pair<key_type, mapped_type>                    __nc_value_type;
+    typedef value_type&                                    reference;
+    typedef const value_type&                              const_reference;
+    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+                  "Invalid allocator::value_type");
+
+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 __hash_table<__value_type, __hasher,
+                         __key_equal,  __allocator_type>   __table;
+
+    __table __table_;
+
+    typedef typename __table::__node_pointer               __node_pointer;
+    typedef typename __table::__node_const_pointer         __node_const_pointer;
+    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;
+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 __hash_map_iterator<typename __table::iterator>       iterator;
+    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
+    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
+    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_map()
+        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            __get_db()->__insert_c(this);
+#endif
+        }
+    explicit unordered_map(size_type __n, const hasher& __hf = hasher(),
+                           const key_equal& __eql = key_equal());
+    unordered_map(size_type __n, const hasher& __hf,
+                  const key_equal& __eql,
+                  const allocator_type& __a);
+    template <class _InputIterator>
+        unordered_map(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        unordered_map(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        unordered_map(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf,
+                      const key_equal& __eql,
+                      const allocator_type& __a);
+    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
+    unordered_map(unordered_map&& __u)
+        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+    unordered_map(unordered_map&& __u, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_map(initializer_list<value_type> __il);
+    unordered_map(initializer_list<value_type> __il, size_type __n,
+                  const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
+    unordered_map(initializer_list<value_type> __il, size_type __n,
+                  const hasher& __hf, const key_equal& __eql,
+                  const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if _LIBCPP_STD_VER > 11
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_map(size_type __n, const allocator_type& __a)
+      : unordered_map(__n, hasher(), key_equal(), __a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
+      : unordered_map(__n, __hf, key_equal(), __a) {}
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY
+      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
+      : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {}
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY
+      unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 
+        const allocator_type& __a)
+      : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
+      : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 
+      const allocator_type& __a)
+      : unordered_map(__il, __n, __hf, key_equal(), __a) {}
+#endif
+    // ~unordered_map() = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_map& operator=(const unordered_map& __u)
+    {
+#if __cplusplus >= 201103L
+        __table_ = __u.__table_;
+#else
+        if (this != &__u) {
+            __table_.clear();
+            __table_.hash_function() = __u.__table_.hash_function();
+            __table_.key_eq() = __u.__table_.key_eq();
+            __table_.max_load_factor() = __u.__table_.max_load_factor();
+            __table_.__copy_assign_alloc(__u.__table_);
+            insert(__u.begin(), __u.end());
+        }
+#endif
+        return *this;
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    unordered_map& operator=(unordered_map&& __u)
+        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
+#endif
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_map& operator=(initializer_list<value_type> __il);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin() _NOEXCEPT        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end() _NOEXCEPT          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const _NOEXCEPT {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+    _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>
+        pair<iterator, bool> emplace(_Args&&... __args);
+
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+#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;}
+#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
+    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)
+        {
+            _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");
+            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
+    _LIBCPP_INLINE_VISIBILITY
+    void insert(initializer_list<value_type> __il)
+        {insert(__il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator erase(const_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)
+        {return __table_.erase(__first.__i_, __last.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(unordered_map& __u)
+        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+        {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_function() const
+        {return __table_.hash_function().hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const
+        {return __table_.key_eq().key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_unique(__k);}
+
+    mapped_type& operator[](const key_type& __k);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    mapped_type& operator[](key_type&& __k);
+#endif
+
+    mapped_type&       at(const key_type& __k);
+    const mapped_type& at(const key_type& __k) const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_size(size_type __n) const
+        {return __table_.bucket_size(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       end(size_type __n)          {return __table_.end(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+    _LIBCPP_INLINE_VISIBILITY
+    void rehash(size_type __n) {__table_.rehash(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const
+        {return __table_.__dereferenceable(&__i->__i_);}
+    bool __decrementable(const const_iterator* __i) const
+        {return __table_.__decrementable(&__i->__i_);}
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(&__i->__i_, __n);}
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(&__i->__i_, __n);}
+
+#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
+    __node_holder __construct_node_with_key(const key_type& __k);
+};
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        size_type __n, const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        size_type __n, const hasher& __hf, const key_equal& __eql,
+        const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        const allocator_type& __a)
+    : __table_(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        _InputIterator __first, _InputIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        const unordered_map& __u)
+    : __table_(__u.__table_)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        const unordered_map& __u, const allocator_type& __a)
+    : __table_(__u.__table_, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        unordered_map&& __u)
+    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+    : __table_(_VSTD::move(__u.__table_))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+    __get_db()->swap(this, &__u);
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        unordered_map&& __u, const allocator_type& __a)
+    : __table_(_VSTD::move(__u.__table_), __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__a != __u.get_allocator())
+    {
+        iterator __i = __u.begin();
+        while (__u.size() != 0)
+            __table_.__insert_unique(
+                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
+                                    );
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    else
+        __get_db()->swap(this, &__u);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        initializer_list<value_type> __il)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+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)
+{
+    __table_ = _VSTD::move(__u.__table_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
+        initializer_list<value_type> __il)
+{
+    __table_.__assign_unique(__il.begin(), __il.end());
+    return *this;
+}
+
+#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
+
+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)
+{
+    __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), __k);
+    __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
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                       _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_unique(*__first);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
+{
+    iterator __i = find(__k);
+    if (__i != end())
+        return __i->second;
+    __node_holder __h = __construct_node_with_key(__k);
+    pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
+    __h.release();
+    return __r.first->second;
+}
+
+#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[](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;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+_Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k)
+{
+    iterator __i = find(__k);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__i == end())
+        throw out_of_range("unordered_map::at: key not found");
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __i->second;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+const _Tp&
+unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const
+{
+    const_iterator __i = find(__k);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__i == end())
+        throw out_of_range("unordered_map::at: key not found");
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return __i->second;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+     unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
+            __i != __ex; ++__i)
+    {
+        const_iterator __j = __y.find(__i->first);
+        if (__j == __ey || !(*__i == *__j))
+            return false;
+    }
+    return true;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
+          class _Alloc = allocator<pair<const _Key, _Tp> > >
+class _LIBCPP_TYPE_VIS_ONLY unordered_multimap
+{
+public:
+    // types
+    typedef _Key                                           key_type;
+    typedef _Tp                                            mapped_type;
+    typedef _Hash                                          hasher;
+    typedef _Pred                                          key_equal;
+    typedef _Alloc                                         allocator_type;
+    typedef pair<const key_type, mapped_type>              value_type;
+    typedef pair<key_type, mapped_type>                    __nc_value_type;
+    typedef value_type&                                    reference;
+    typedef const value_type&                              const_reference;
+    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+                  "Invalid allocator::value_type");
+
+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 __hash_table<__value_type, __hasher,
+                         __key_equal,  __allocator_type>   __table;
+
+    __table __table_;
+
+    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;
+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 __hash_map_iterator<typename __table::iterator>       iterator;
+    typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
+    typedef __hash_map_iterator<typename __table::local_iterator> local_iterator;
+    typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multimap()
+        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            __get_db()->__insert_c(this);
+#endif
+        }
+    explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(),
+                                const key_equal& __eql = key_equal());
+    unordered_multimap(size_type __n, const hasher& __hf,
+                                const key_equal& __eql,
+                                const allocator_type& __a);
+    template <class _InputIterator>
+        unordered_multimap(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        unordered_multimap(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        unordered_multimap(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf,
+                      const key_equal& __eql,
+                      const allocator_type& __a);
+    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
+    unordered_multimap(unordered_multimap&& __u)
+        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+    unordered_multimap(unordered_multimap&& __u, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_multimap(initializer_list<value_type> __il);
+    unordered_multimap(initializer_list<value_type> __il, size_type __n,
+                       const hasher& __hf = hasher(),
+                       const key_equal& __eql = key_equal());
+    unordered_multimap(initializer_list<value_type> __il, size_type __n,
+                       const hasher& __hf, const key_equal& __eql,
+                       const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if _LIBCPP_STD_VER > 11
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multimap(size_type __n, const allocator_type& __a)
+      : unordered_multimap(__n, hasher(), key_equal(), __a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
+      : unordered_multimap(__n, __hf, key_equal(), __a) {}
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY
+      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
+      : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {}
+    template <class _InputIterator>
+    _LIBCPP_INLINE_VISIBILITY
+      unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, 
+        const allocator_type& __a)
+      : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
+      : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, 
+      const allocator_type& __a)
+      : unordered_multimap(__il, __n, __hf, key_equal(), __a) {}
+#endif
+    // ~unordered_multimap() = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multimap& operator=(const unordered_multimap& __u)
+    {
+#if __cplusplus >= 201103L
+        __table_ = __u.__table_;
+#else
+        if (this != &__u) {
+            __table_.clear();
+            __table_.hash_function() = __u.__table_.hash_function();
+            __table_.key_eq() = __u.__table_.key_eq();
+            __table_.max_load_factor() = __u.__table_.max_load_factor();
+            __table_.__copy_assign_alloc(__u.__table_);
+            insert(__u.begin(), __u.end());
+        }
+#endif
+        return *this;
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    unordered_multimap& operator=(unordered_multimap&& __u)
+        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
+#endif
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_multimap& operator=(initializer_list<value_type> __il);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin() _NOEXCEPT        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end() _NOEXCEPT          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const _NOEXCEPT {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+    _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);
+#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
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator erase(const_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)
+        {return __table_.erase(__first.__i_, __last.__i_);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(unordered_multimap& __u)
+        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+        {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_function() const
+        {return __table_.hash_function().hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const
+        {return __table_.key_eq().key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_multi(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const _NOEXCEPT
+        {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_size(size_type __n) const
+        {return __table_.bucket_size(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       end(size_type __n)          {return __table_.end(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+    _LIBCPP_INLINE_VISIBILITY
+    void rehash(size_type __n) {__table_.rehash(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const
+        {return __table_.__dereferenceable(&__i->__i_);}
+    bool __decrementable(const const_iterator* __i) const
+        {return __table_.__decrementable(&__i->__i_);}
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(&__i->__i_, __n);}
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(&__i->__i_, __n);}
+
+#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>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        size_type __n, const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        size_type __n, const hasher& __hf, const key_equal& __eql,
+        const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        _InputIterator __first, _InputIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        const allocator_type& __a)
+    : __table_(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        const unordered_multimap& __u)
+    : __table_(__u.__table_)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        const unordered_multimap& __u, const allocator_type& __a)
+    : __table_(__u.__table_, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        unordered_multimap&& __u)
+    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+    : __table_(_VSTD::move(__u.__table_))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+    __get_db()->swap(this, &__u);
+#endif
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        unordered_multimap&& __u, const allocator_type& __a)
+    : __table_(_VSTD::move(__u.__table_), __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__a != __u.get_allocator())
+    {
+        iterator __i = __u.begin();
+        while (__u.size() != 0)
+        {
+            __table_.__insert_multi(
+                _VSTD::move(__u.__table_.remove((__i++).__i_)->__value_)
+                                   );
+        }
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    else
+        __get_db()->swap(this, &__u);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        initializer_list<value_type> __il)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+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)
+{
+    __table_ = _VSTD::move(__u.__table_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>&
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(
+        initializer_list<value_type> __il)
+{
+    __table_.__assign_multi(__il.begin(), __il.end());
+    return *this;
+}
+
+#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
+void
+unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                            _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_multi(*__first);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+     unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    typedef pair<const_iterator, const_iterator> _EqRng;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
+    {
+        _EqRng __xeq = __x.equal_range(__i->first);
+        _EqRng __yeq = __y.equal_range(__i->first);
+        if (_VSTD::distance(__xeq.first, __xeq.second) !=
+            _VSTD::distance(__yeq.first, __yeq.second) ||
+                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
+            return false;
+        __i = __xeq.second;
+    }
+    return true;
+}
+
+template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
+           const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_UNORDERED_MAP
diff --git a/final/include/unordered_set b/final/include/unordered_set
new file mode 100644
index 0000000..fd378fa
--- /dev/null
+++ b/final/include/unordered_set
@@ -0,0 +1,1379 @@
+// -*- C++ -*-
+//===-------------------------- unordered_set -----------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_UNORDERED_SET
+#define _LIBCPP_UNORDERED_SET
+
+/*
+
+    unordered_set synopsis
+
+#include <initializer_list>
+
+namespace std
+{
+
+template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+          class Alloc = allocator<Value>>
+class unordered_set
+{
+public:
+    // types
+    typedef Value                                                      key_type;
+    typedef key_type                                                   value_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+    typedef /unspecified/ local_iterator;
+    typedef /unspecified/ const_local_iterator;
+
+    unordered_set()
+        noexcept(
+            is_nothrow_default_constructible<hasher>::value &&
+            is_nothrow_default_constructible<key_equal>::value &&
+            is_nothrow_default_constructible<allocator_type>::value);
+    explicit unordered_set(size_type n, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        unordered_set(InputIterator f, InputIterator l,
+                      size_type n = 0, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    explicit unordered_set(const allocator_type&);
+    unordered_set(const unordered_set&);
+    unordered_set(const unordered_set&, const Allocator&);
+    unordered_set(unordered_set&&)
+        noexcept(
+            is_nothrow_move_constructible<hasher>::value &&
+            is_nothrow_move_constructible<key_equal>::value &&
+            is_nothrow_move_constructible<allocator_type>::value);
+    unordered_set(unordered_set&&, const Allocator&);
+    unordered_set(initializer_list<value_type>, size_type n = 0,
+                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+                  const allocator_type& a = allocator_type());
+    unordered_set(size_type n, const allocator_type& a); // C++14
+    unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
+    template <class InputIterator>
+      unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
+    template <class InputIterator>
+      unordered_set(InputIterator f, InputIterator l, size_type n, 
+                    const hasher& hf,  const allocator_type& a); // C++14
+    unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
+    unordered_set(initializer_list<value_type> il, size_type n,
+                  const hasher& hf,  const allocator_type& a); // C++14
+    ~unordered_set();
+    unordered_set& operator=(const unordered_set&);
+    unordered_set& operator=(unordered_set&&)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<hasher>::value &&
+            is_nothrow_move_assignable<key_equal>::value);
+    unordered_set& operator=(initializer_list<value_type>);
+
+    allocator_type get_allocator() const noexcept;
+
+    bool      empty() const noexcept;
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+
+    iterator       begin() noexcept;
+    iterator       end() noexcept;
+    const_iterator begin()  const noexcept;
+    const_iterator end()    const noexcept;
+    const_iterator cbegin() const noexcept;
+    const_iterator cend()   const noexcept;
+
+    template <class... Args>
+        pair<iterator, bool> emplace(Args&&... args);
+    template <class... Args>
+        iterator emplace_hint(const_iterator position, Args&&... args);
+    pair<iterator, bool> insert(const value_type& obj);
+    pair<iterator, bool> insert(value_type&& obj);
+    iterator insert(const_iterator hint, const value_type& obj);
+    iterator insert(const_iterator hint, value_type&& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+    void insert(initializer_list<value_type>);
+
+    iterator erase(const_iterator position);
+    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);
+
+    hasher hash_function() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    size_type bucket_count() const noexcept;
+    size_type max_bucket_count() const noexcept;
+
+    size_type bucket_size(size_type n) const;
+    size_type bucket(const key_type& k) const;
+
+    local_iterator       begin(size_type n);
+    local_iterator       end(size_type n);
+    const_local_iterator begin(size_type n) const;
+    const_local_iterator end(size_type n) const;
+    const_local_iterator cbegin(size_type n) const;
+    const_local_iterator cend(size_type n) const;
+
+    float load_factor() const noexcept;
+    float max_load_factor() const noexcept;
+    void max_load_factor(float z);
+    void rehash(size_type n);
+    void reserve(size_type n);
+};
+
+template <class Value, class Hash, class Pred, class Alloc>
+    void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
+              unordered_set<Value, Hash, Pred, Alloc>& y)
+              noexcept(noexcept(x.swap(y)));
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
+               const unordered_set<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
+               const unordered_set<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+          class Alloc = allocator<Value>>
+class unordered_multiset
+{
+public:
+    // types
+    typedef Value                                                      key_type;
+    typedef key_type                                                   value_type;
+    typedef Hash                                                       hasher;
+    typedef Pred                                                       key_equal;
+    typedef Alloc                                                      allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    typedef typename allocator_traits<allocator_type>::pointer         pointer;
+    typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+    typedef typename allocator_traits<allocator_type>::size_type       size_type;
+    typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+    typedef /unspecified/ iterator;
+    typedef /unspecified/ const_iterator;
+    typedef /unspecified/ local_iterator;
+    typedef /unspecified/ const_local_iterator;
+
+    unordered_multiset()
+        noexcept(
+            is_nothrow_default_constructible<hasher>::value &&
+            is_nothrow_default_constructible<key_equal>::value &&
+            is_nothrow_default_constructible<allocator_type>::value);
+    explicit unordered_multiset(size_type n, const hasher& hf = hasher(),
+                           const key_equal& eql = key_equal(),
+                           const allocator_type& a = allocator_type());
+    template <class InputIterator>
+        unordered_multiset(InputIterator f, InputIterator l,
+                      size_type n = 0, const hasher& hf = hasher(),
+                      const key_equal& eql = key_equal(),
+                      const allocator_type& a = allocator_type());
+    explicit unordered_multiset(const allocator_type&);
+    unordered_multiset(const unordered_multiset&);
+    unordered_multiset(const unordered_multiset&, const Allocator&);
+    unordered_multiset(unordered_multiset&&)
+        noexcept(
+            is_nothrow_move_constructible<hasher>::value &&
+            is_nothrow_move_constructible<key_equal>::value &&
+            is_nothrow_move_constructible<allocator_type>::value);
+    unordered_multiset(unordered_multiset&&, const Allocator&);
+    unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
+                  const hasher& hf = hasher(), const key_equal& eql = key_equal(),
+                  const allocator_type& a = allocator_type());
+    unordered_multiset(size_type n, const allocator_type& a); // C++14
+    unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
+    template <class InputIterator>
+      unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
+    template <class InputIterator>
+      unordered_multiset(InputIterator f, InputIterator l, size_type n,
+                         const hasher& hf, const allocator_type& a); // C++14
+    unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
+    unordered_multiset(initializer_list<value_type> il, size_type n, 
+                       const hasher& hf,  const allocator_type& a); // C++14
+    ~unordered_multiset();
+    unordered_multiset& operator=(const unordered_multiset&);
+    unordered_multiset& operator=(unordered_multiset&&)
+        noexcept(
+            allocator_type::propagate_on_container_move_assignment::value &&
+            is_nothrow_move_assignable<allocator_type>::value &&
+            is_nothrow_move_assignable<hasher>::value &&
+            is_nothrow_move_assignable<key_equal>::value);
+    unordered_multiset& operator=(initializer_list<value_type>);
+
+    allocator_type get_allocator() const noexcept;
+
+    bool      empty() const noexcept;
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+
+    iterator       begin() noexcept;
+    iterator       end() noexcept;
+    const_iterator begin()  const noexcept;
+    const_iterator end()    const noexcept;
+    const_iterator cbegin() const noexcept;
+    const_iterator cend()   const noexcept;
+
+    template <class... Args>
+        iterator emplace(Args&&... args);
+    template <class... Args>
+        iterator emplace_hint(const_iterator position, Args&&... args);
+    iterator insert(const value_type& obj);
+    iterator insert(value_type&& obj);
+    iterator insert(const_iterator hint, const value_type& obj);
+    iterator insert(const_iterator hint, value_type&& obj);
+    template <class InputIterator>
+        void insert(InputIterator first, InputIterator last);
+    void insert(initializer_list<value_type>);
+
+    iterator erase(const_iterator position);
+    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);
+
+    hasher hash_function() const;
+    key_equal key_eq() const;
+
+    iterator       find(const key_type& k);
+    const_iterator find(const key_type& k) const;
+    size_type count(const key_type& k) const;
+    pair<iterator, iterator>             equal_range(const key_type& k);
+    pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+    size_type bucket_count() const noexcept;
+    size_type max_bucket_count() const noexcept;
+
+    size_type bucket_size(size_type n) const;
+    size_type bucket(const key_type& k) const;
+
+    local_iterator       begin(size_type n);
+    local_iterator       end(size_type n);
+    const_local_iterator begin(size_type n) const;
+    const_local_iterator end(size_type n) const;
+    const_local_iterator cbegin(size_type n) const;
+    const_local_iterator cend(size_type n) const;
+
+    float load_factor() const noexcept;
+    float max_load_factor() const noexcept;
+    void max_load_factor(float z);
+    void rehash(size_type n);
+    void reserve(size_type n);
+};
+
+template <class Value, class Hash, class Pred, class Alloc>
+    void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
+              unordered_multiset<Value, Hash, Pred, Alloc>& y)
+              noexcept(noexcept(x.swap(y)));
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
+               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
+
+template <class Value, class Hash, class Pred, class Alloc>
+    bool
+    operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
+               const unordered_multiset<Value, Hash, Pred, Alloc>& y);
+}  // std
+
+*/
+
+#include <__config>
+#include <__hash_table>
+#include <functional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
+          class _Alloc = allocator<_Value> >
+class _LIBCPP_TYPE_VIS_ONLY unordered_set
+{
+public:
+    // types
+    typedef _Value                                                     key_type;
+    typedef key_type                                                   value_type;
+    typedef _Hash                                                      hasher;
+    typedef _Pred                                                      key_equal;
+    typedef _Alloc                                                     allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+                  "Invalid allocator::value_type");
+
+private:
+    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+
+    __table __table_;
+
+public:
+    typedef typename __table::pointer         pointer;
+    typedef typename __table::const_pointer   const_pointer;
+    typedef typename __table::size_type       size_type;
+    typedef typename __table::difference_type difference_type;
+
+    typedef typename __table::const_iterator       iterator;
+    typedef typename __table::const_iterator       const_iterator;
+    typedef typename __table::const_local_iterator local_iterator;
+    typedef typename __table::const_local_iterator const_local_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_set()
+        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            __get_db()->__insert_c(this);
+#endif
+        }
+    explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
+                           const key_equal& __eql = key_equal());
+#if _LIBCPP_STD_VER > 11
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_set(size_type __n, const allocator_type& __a)
+        : unordered_set(__n, hasher(), key_equal(), __a) {}
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
+        : unordered_set(__n, __hf, key_equal(), __a) {}
+#endif
+    unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
+                  const allocator_type& __a);
+    template <class _InputIterator>
+        unordered_set(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        unordered_set(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        unordered_set(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf, const key_equal& __eql,
+                      const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+    template <class _InputIterator>
+    inline _LIBCPP_INLINE_VISIBILITY
+        unordered_set(_InputIterator __first, _InputIterator __last, 
+                    size_type __n, const allocator_type& __a)
+            : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {}
+    template <class _InputIterator>
+        unordered_set(_InputIterator __first, _InputIterator __last, 
+                      size_type __n, const hasher& __hf, const allocator_type& __a)
+            : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
+#endif
+    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
+    unordered_set(unordered_set&& __u)
+        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+    unordered_set(unordered_set&& __u, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_set(initializer_list<value_type> __il);
+    unordered_set(initializer_list<value_type> __il, size_type __n,
+                  const hasher& __hf = hasher(),
+                  const key_equal& __eql = key_equal());
+    unordered_set(initializer_list<value_type> __il, size_type __n,
+                  const hasher& __hf, const key_equal& __eql,
+                  const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_set(initializer_list<value_type> __il, size_type __n,
+                                                      const allocator_type& __a)
+        : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_set(initializer_list<value_type> __il, size_type __n, 
+                                  const hasher& __hf, const allocator_type& __a)
+        : unordered_set(__il, __n, __hf, key_equal(), __a) {}
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    // ~unordered_set() = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_set& operator=(const unordered_set& __u)
+    {
+        __table_ = __u.__table_;
+        return *this;
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    unordered_set& operator=(unordered_set&& __u)
+        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
+#endif
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_set& operator=(initializer_list<value_type> __il);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin() _NOEXCEPT        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end() _NOEXCEPT          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const _NOEXCEPT {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
+
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        pair<iterator, bool> emplace(_Args&&... __args)
+            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);}
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+#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_set::emplace_hint(const_iterator, args...) called with an iterator not"
+                " referring to this unordered_set");
+            return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;
+        }
+#else
+        iterator emplace_hint(const_iterator, _Args&&... __args)
+            {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;}
+#endif
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> insert(const value_type& __x)
+        {return __table_.__insert_unique(__x);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, bool> insert(value_type&& __x)
+        {return __table_.__insert_unique(_VSTD::move(__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_set::insert(const_iterator, const value_type&) called with an iterator not"
+                " referring to this unordered_set");
+            return insert(__x).first;
+        }
+#else
+    iterator insert(const_iterator, const value_type& __x)
+        {return insert(__x).first;}
+#endif
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    iterator insert(const_iterator __p, value_type&& __x)
+        {
+            _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this,
+                "unordered_set::insert(const_iterator, value_type&&) called with an iterator not"
+                " referring to this unordered_set");
+            return insert(_VSTD::move(__x)).first;
+        }
+#else
+    iterator insert(const_iterator, value_type&& __x)
+        {return insert(_VSTD::move(__x)).first;}
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _InputIterator>
+        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
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator erase(const_iterator __p) {return __table_.erase(__p);}
+    _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)
+        {return __table_.erase(__first, __last);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(unordered_set& __u)
+        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+        {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_function() const {return __table_.hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const {return __table_.key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_unique(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_unique(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       end(size_type __n)          {return __table_.end(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+    _LIBCPP_INLINE_VISIBILITY
+    void rehash(size_type __n) {__table_.rehash(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const
+        {return __table_.__dereferenceable(__i);}
+    bool __decrementable(const const_iterator* __i) const
+        {return __table_.__decrementable(__i);}
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(__i, __n);}
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(__i, __n);}
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+};
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        _InputIterator __first, _InputIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        const allocator_type& __a)
+    : __table_(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        const unordered_set& __u)
+    : __table_(__u.__table_)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        const unordered_set& __u, const allocator_type& __a)
+    : __table_(__u.__table_, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        unordered_set&& __u)
+    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+    : __table_(_VSTD::move(__u.__table_))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+    __get_db()->swap(this, &__u);
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        unordered_set&& __u, const allocator_type& __a)
+    : __table_(_VSTD::move(__u.__table_), __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__a != __u.get_allocator())
+    {
+        iterator __i = __u.begin();
+        while (__u.size() != 0)
+            __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_));
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    else
+        __get_db()->swap(this, &__u);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        initializer_list<value_type> __il)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_set<_Value, _Hash, _Pred, _Alloc>&
+unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
+    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
+{
+    __table_ = _VSTD::move(__u.__table_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_set<_Value, _Hash, _Pred, _Alloc>&
+unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
+        initializer_list<value_type> __il)
+{
+    __table_.__assign_unique(__il.begin(), __il.end());
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                    _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_unique(*__first);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
+     unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
+           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
+            __i != __ex; ++__i)
+    {
+        const_iterator __j = __y.find(*__i);
+        if (__j == __ey || !(*__i == *__j))
+            return false;
+    }
+    return true;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
+           const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
+          class _Alloc = allocator<_Value> >
+class _LIBCPP_TYPE_VIS_ONLY unordered_multiset
+{
+public:
+    // types
+    typedef _Value                                                     key_type;
+    typedef key_type                                                   value_type;
+    typedef _Hash                                                      hasher;
+    typedef _Pred                                                      key_equal;
+    typedef _Alloc                                                     allocator_type;
+    typedef value_type&                                                reference;
+    typedef const value_type&                                          const_reference;
+    static_assert((is_same<value_type, typename allocator_type::value_type>::value),
+                  "Invalid allocator::value_type");
+
+private:
+    typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+
+    __table __table_;
+
+public:
+    typedef typename __table::pointer         pointer;
+    typedef typename __table::const_pointer   const_pointer;
+    typedef typename __table::size_type       size_type;
+    typedef typename __table::difference_type difference_type;
+
+    typedef typename __table::const_iterator       iterator;
+    typedef typename __table::const_iterator       const_iterator;
+    typedef typename __table::const_local_iterator local_iterator;
+    typedef typename __table::const_local_iterator const_local_iterator;
+
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset()
+        _NOEXCEPT_(is_nothrow_default_constructible<__table>::value)
+        {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+            __get_db()->__insert_c(this);
+#endif
+        }
+    explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
+                                const key_equal& __eql = key_equal());
+    unordered_multiset(size_type __n, const hasher& __hf,
+                       const key_equal& __eql, const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset(size_type __n, const allocator_type& __a)
+        : unordered_multiset(__n, hasher(), key_equal(), __a) {}
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
+        : unordered_multiset(__n, __hf, key_equal(), __a) {}
+#endif
+    template <class _InputIterator>
+        unordered_multiset(_InputIterator __first, _InputIterator __last);
+    template <class _InputIterator>
+        unordered_multiset(_InputIterator __first, _InputIterator __last,
+                      size_type __n, const hasher& __hf = hasher(),
+                      const key_equal& __eql = key_equal());
+    template <class _InputIterator>
+        unordered_multiset(_InputIterator __first, _InputIterator __last,
+                      size_type __n , const hasher& __hf,
+                      const key_equal& __eql, const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+    template <class _InputIterator>
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset(_InputIterator __first, _InputIterator __last, 
+                       size_type __n, const allocator_type& __a)
+        : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {}
+    template <class _InputIterator>
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset(_InputIterator __first, _InputIterator __last,
+                       size_type __n, const hasher& __hf, const allocator_type& __a)
+        : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
+#endif
+    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
+    unordered_multiset(unordered_multiset&& __u)
+        _NOEXCEPT_(is_nothrow_move_constructible<__table>::value);
+    unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_multiset(initializer_list<value_type> __il);
+    unordered_multiset(initializer_list<value_type> __il, size_type __n,
+                       const hasher& __hf = hasher(),
+                       const key_equal& __eql = key_equal());
+    unordered_multiset(initializer_list<value_type> __il, size_type __n,
+                       const hasher& __hf, const key_equal& __eql,
+                       const allocator_type& __a);
+#if _LIBCPP_STD_VER > 11
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
+      : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
+    inline _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
+      : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    // ~unordered_multiset() = default;
+    _LIBCPP_INLINE_VISIBILITY
+    unordered_multiset& operator=(const unordered_multiset& __u)
+    {
+        __table_ = __u.__table_;
+        return *this;
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    unordered_multiset& operator=(unordered_multiset&& __u)
+        _NOEXCEPT_(is_nothrow_move_assignable<__table>::value);
+#endif
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    unordered_multiset& operator=(initializer_list<value_type> __il);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type get_allocator() const _NOEXCEPT
+        {return allocator_type(__table_.__node_alloc());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    bool      empty() const _NOEXCEPT {return __table_.size() == 0;}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT  {return __table_.size();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_size() const _NOEXCEPT {return __table_.max_size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       begin() _NOEXCEPT        {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       end() _NOEXCEPT          {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin()  const _NOEXCEPT {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()    const _NOEXCEPT {return __table_.end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cbegin() const _NOEXCEPT {return __table_.begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator cend()   const _NOEXCEPT {return __table_.end();}
+
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator emplace(_Args&&... __args)
+            {return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...);}
+    template <class... _Args>
+        _LIBCPP_INLINE_VISIBILITY
+        iterator emplace_hint(const_iterator __p, _Args&&... __args)
+            {return __table_.__emplace_hint_multi(__p, _VSTD::forward<_Args>(__args)...);}
+#endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));}
+#endif
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, const value_type& __x)
+        {return __table_.__insert_multi(__p, __x);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __p, value_type&& __x)
+        {return __table_.__insert_multi(__p, _VSTD::move(__x));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class _InputIterator>
+        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
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator erase(const_iterator __p) {return __table_.erase(__p);}
+    _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)
+        {return __table_.erase(__first, __last);}
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__table_.clear();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void swap(unordered_multiset& __u)
+        _NOEXCEPT_(__is_nothrow_swappable<__table>::value)
+        {__table_.swap(__u.__table_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    hasher hash_function() const {return __table_.hash_function();}
+    _LIBCPP_INLINE_VISIBILITY
+    key_equal key_eq() const {return __table_.key_eq();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       find(const key_type& __k)       {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator find(const key_type& __k) const {return __table_.find(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<iterator, iterator>             equal_range(const key_type& __k)
+        {return __table_.__equal_range_multi(__k);}
+    _LIBCPP_INLINE_VISIBILITY
+    pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+        {return __table_.__equal_range_multi(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type max_bucket_count() const _NOEXCEPT {return __table_.max_bucket_count();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       begin(size_type __n)        {return __table_.begin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    local_iterator       end(size_type __n)          {return __table_.end(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator begin(size_type __n) const  {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator end(size_type __n) const    {return __table_.cend(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_local_iterator cend(size_type __n) const   {return __table_.cend(__n);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    float load_factor() const _NOEXCEPT {return __table_.load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    float max_load_factor() const _NOEXCEPT {return __table_.max_load_factor();}
+    _LIBCPP_INLINE_VISIBILITY
+    void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
+    _LIBCPP_INLINE_VISIBILITY
+    void rehash(size_type __n) {__table_.rehash(__n);}
+    _LIBCPP_INLINE_VISIBILITY
+    void reserve(size_type __n) {__table_.reserve(__n);}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const
+        {return __table_.__dereferenceable(__i);}
+    bool __decrementable(const const_iterator* __i) const
+        {return __table_.__decrementable(__i);}
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(__i, __n);}
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+        {return __table_.__addable(__i, __n);}
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+};
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        size_type __n, const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        size_type __n, const hasher& __hf, const key_equal& __eql,
+        const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        _InputIterator __first, _InputIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        _InputIterator __first, _InputIterator __last, size_type __n,
+        const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__first, __last);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        const allocator_type& __a)
+    : __table_(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        const unordered_multiset& __u)
+    : __table_(__u.__table_)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        const unordered_multiset& __u, const allocator_type& __a)
+    : __table_(__u.__table_, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__u.bucket_count());
+    insert(__u.begin(), __u.end());
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        unordered_multiset&& __u)
+    _NOEXCEPT_(is_nothrow_move_constructible<__table>::value)
+    : __table_(_VSTD::move(__u.__table_))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+    __get_db()->swap(this, &__u);
+#endif
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        unordered_multiset&& __u, const allocator_type& __a)
+    : __table_(_VSTD::move(__u.__table_), __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__a != __u.get_allocator())
+    {
+        iterator __i = __u.begin();
+        while (__u.size() != 0)
+            __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_));
+    }
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    else
+        __get_db()->swap(this, &__u);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        initializer_list<value_type> __il)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql)
+    : __table_(__hf, __eql)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
+        initializer_list<value_type> __il, size_type __n, const hasher& __hf,
+        const key_equal& __eql, const allocator_type& __a)
+    : __table_(__hf, __eql, __a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    __table_.rehash(__n);
+    insert(__il.begin(), __il.end());
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
+        unordered_multiset&& __u)
+    _NOEXCEPT_(is_nothrow_move_assignable<__table>::value)
+{
+    __table_ = _VSTD::move(__u.__table_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
+        initializer_list<value_type> __il)
+{
+    __table_.__assign_multi(__il.begin(), __il.end());
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+template <class _InputIterator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
+                                                         _InputIterator __last)
+{
+    for (; __first != __last; ++__first)
+        __table_.__insert_multi(*__first);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+     unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+bool
+operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    if (__x.size() != __y.size())
+        return false;
+    typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
+                                                                 const_iterator;
+    typedef pair<const_iterator, const_iterator> _EqRng;
+    for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
+    {
+        _EqRng __xeq = __x.equal_range(*__i);
+        _EqRng __yeq = __y.equal_range(*__i);
+        if (_VSTD::distance(__xeq.first, __xeq.second) !=
+            _VSTD::distance(__yeq.first, __yeq.second) ||
+                  !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
+            return false;
+        __i = __xeq.second;
+    }
+    return true;
+}
+
+template <class _Value, class _Hash, class _Pred, class _Alloc>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+           const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
+{
+    return !(__x == __y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_UNORDERED_SET
diff --git a/final/include/utility b/final/include/utility
new file mode 100644
index 0000000..4eafda4
--- /dev/null
+++ b/final/include/utility
@@ -0,0 +1,768 @@
+// -*- C++ -*-
+//===-------------------------- utility -----------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_UTILITY
+#define _LIBCPP_UTILITY
+
+/*
+    utility synopsis
+
+namespace std
+{
+
+template <class T>
+    void
+    swap(T& a, T& b);
+
+namespace rel_ops
+{
+    template<class T> bool operator!=(const T&, const T&);
+    template<class T> bool operator> (const T&, const T&);
+    template<class T> bool operator<=(const T&, const T&);
+    template<class T> bool operator>=(const T&, const T&);
+}
+
+template<class T>
+void
+swap(T& a, T& b) noexcept(is_nothrow_move_constructible<T>::value &&
+                          is_nothrow_move_assignable<T>::value);
+
+template <class T, size_t N>
+void
+swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
+
+template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept;  // constexpr in C++14
+template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14
+
+template <class T> typename remove_reference<T>::type&& move(T&&) noexcept;      // constexpr in C++14
+
+template <class T>
+    typename conditional
+    <
+        !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
+        const T&,
+        T&&
+    >::type
+    move_if_noexcept(T& x) noexcept; // constexpr in C++14
+
+template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
+
+template <class T1, class T2>
+struct pair
+{
+    typedef T1 first_type;
+    typedef T2 second_type;
+
+    T1 first;
+    T2 second;
+
+    pair(const pair&) = default;
+    pair(pair&&) = default;
+    constexpr pair();
+    pair(const T1& x, const T2& y);                          // constexpr in C++14
+    template <class U, class V> pair(U&& x, V&& y);          // constexpr in C++14
+    template <class U, class V> pair(const pair<U, V>& p);   // constexpr in C++14
+    template <class U, class V> pair(pair<U, V>&& p);        // constexpr in C++14
+    template <class... Args1, class... Args2>
+        pair(piecewise_construct_t, tuple<Args1...> first_args,
+             tuple<Args2...> second_args);
+
+    template <class U, class V> pair& operator=(const pair<U, V>& p);
+    pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
+                                       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)));
+};
+
+template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+
+template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);   // constexpr in C++14
+template <class T1, class T2>
+void
+swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
+
+struct piecewise_construct_t { };
+constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+template <class T> class tuple_size;
+template <size_t I, class T> class tuple_element;
+
+template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
+template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
+template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;
+
+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 const 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<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<size_t I, class T1, class T2>
+    constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14
+
+// C++14
+
+template<class T, T... I>
+struct integer_sequence
+{
+    typedef T value_type;
+
+    static constexpr size_t size() noexcept;
+};
+
+template<size_t... I>
+  using index_sequence = integer_sequence<size_t, I...>;
+
+template<class T, T N>
+  using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+template<size_t N>
+  using make_index_sequence = make_integer_sequence<size_t, N>;
+
+template<class... T>
+  using index_sequence_for = make_index_sequence<sizeof...(T)>;
+
+template<class T, class U=T> 
+    T exchange(T& obj, U&& new_value);
+}  // std
+
+*/
+
+#include <__config>
+#include <__tuple>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace rel_ops
+{
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const _Tp& __x, const _Tp& __y)
+{
+    return !(__x == __y);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const _Tp& __x, const _Tp& __y)
+{
+    return __y < __x;
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const _Tp& __x, const _Tp& __y)
+{
+    return !(__y < __x);
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const _Tp& __x, const _Tp& __y)
+{
+    return !(__x < __y);
+}
+
+}  // rel_ops
+
+// 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)
+        swap(*__first1, *__first2);
+    return __first2;
+}
+
+template<class _Tp, size_t _Np>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
+{
+    _VSTD::swap_ranges(__a, __a + _Np, __b);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+typename conditional
+<
+    !is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value,
+    const _Tp&,
+    _Tp&&
+>::type
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+const _Tp&
+#endif
+move_if_noexcept(_Tp& __x) _NOEXCEPT
+{
+    return _VSTD::move(__x);
+}
+
+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();
+#else
+constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+#endif
+
+template <class _T1, class _T2>
+struct _LIBCPP_TYPE_VIS_ONLY pair
+{
+    typedef _T1 first_type;
+    typedef _T2 second_type;
+
+    _T1 first;
+    _T2 second;
+
+    // pair(const pair&) = default;
+    // pair(pair&&) = default;
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
+
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    pair(const _T1& __x, const _T2& __y)
+        : first(__x), second(__y) {}
+
+    template<class _U1, class _U2>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        pair(const pair<_U1, _U2>& __p
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+                 ,typename enable_if<is_convertible<const _U1&, _T1>::value &&
+                                    is_convertible<const _U2&, _T2>::value>::type* = 0
+#endif
+                                      )
+            : first(__p.first), second(__p.second) {}
+
+#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
+    _LIBCPP_INLINE_VISIBILITY
+    pair(const pair& __p) = default;
+#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
+    _LIBCPP_INLINE_VISIBILITY
+    pair(const pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
+                   is_nothrow_copy_constructible<second_type>::value)
+        : first(__p.first),
+          second(__p.second)
+    {
+    }
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair& operator=(const pair& __p)
+        _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
+                   is_nothrow_copy_assignable<second_type>::value)
+    {
+        first = __p.first;
+        second = __p.second;
+        return *this;
+    }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    template <class _U1, class _U2,
+              class = typename enable_if<is_convertible<_U1, first_type>::value &&
+                                         is_convertible<_U2, second_type>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        pair(_U1&& __u1, _U2&& __u2)
+            : first(_VSTD::forward<_U1>(__u1)),
+              second(_VSTD::forward<_U2>(__u2))
+            {}
+
+    template<class _U1, class _U2>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        pair(pair<_U1, _U2>&& __p,
+                 typename enable_if<is_convertible<_U1, _T1>::value &&
+                                    is_convertible<_U2, _T2>::value>::type* = 0)
+            : first(_VSTD::forward<_U1>(__p.first)),
+              second(_VSTD::forward<_U2>(__p.second)) {}
+
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+    _LIBCPP_INLINE_VISIBILITY
+    pair(pair&& __p) = default;
+#else
+    _LIBCPP_INLINE_VISIBILITY
+    pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
+                                is_nothrow_move_constructible<second_type>::value)
+        : first(_VSTD::forward<first_type>(__p.first)),
+          second(_VSTD::forward<second_type>(__p.second))
+    {
+    }
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY
+    pair&
+    operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
+                                     is_nothrow_move_assignable<second_type>::value)
+    {
+        first = _VSTD::forward<first_type>(__p.first);
+        second = _VSTD::forward<second_type>(__p.second);
+        return *this;
+    }
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+    template<class _Tuple,
+             class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+        pair(_Tuple&& __p)
+            : first(_VSTD::forward<typename tuple_element<0,
+                                  typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<0>(__p))),
+              second(_VSTD::forward<typename tuple_element<1,
+                                   typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<1>(__p)))
+            {}
+
+
+
+    template <class... _Args1, class... _Args2>
+        _LIBCPP_INLINE_VISIBILITY
+        pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
+                                    tuple<_Args2...> __second_args)
+            : pair(__pc, __first_args, __second_args,
+                   typename __make_tuple_indices<sizeof...(_Args1)>::type(),
+                   typename __make_tuple_indices<sizeof...(_Args2) >::type())
+            {}
+
+    template <class _Tuple,
+              class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
+        _LIBCPP_INLINE_VISIBILITY
+        pair&
+        operator=(_Tuple&& __p)
+        {
+            typedef typename __make_tuple_types<_Tuple>::type _TupleRef;
+            typedef typename tuple_element<0, _TupleRef>::type _U0;
+            typedef typename tuple_element<1, _TupleRef>::type _U1;
+            first  = _VSTD::forward<_U0>(_VSTD::get<0>(__p));
+            second = _VSTD::forward<_U1>(_VSTD::get<1>(__p));
+            return *this;
+        }
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    void
+    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);
+    }
+private:
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
+        _LIBCPP_INLINE_VISIBILITY
+        pair(piecewise_construct_t,
+             tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
+             __tuple_indices<_I1...>, __tuple_indices<_I2...>);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+};
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+    return __x.first == __y.first && __x.second == __y.second;
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+    return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+    return __y < __x;
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+bool
+operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_swappable<_T1>::value &&
+    __is_swappable<_T2>::value,
+    void
+>::type
+swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
+                     _NOEXCEPT_((__is_nothrow_swappable<_T1>::value &&
+                                 __is_nothrow_swappable<_T2>::value))
+{
+    __x.swap(__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
+{
+    typedef _Tp type;
+};
+
+template <class _Tp>
+struct __make_pair_return_impl<reference_wrapper<_Tp>>
+{
+    typedef _Tp& type;
+};
+
+template <class _Tp>
+struct __make_pair_return
+{
+    typedef typename __make_pair_return_impl<typename decay<_Tp>::type>::type type;
+};
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
+make_pair(_T1&& __t1, _T2&& __t2)
+{
+    return pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
+               (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
+}
+
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+pair<_T1,_T2>
+make_pair(_T1 __x, _T2 __y)
+{
+    return pair<_T1, _T2>(__x, __y);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+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> >
+{
+public:
+    typedef _T1 type;
+};
+
+template <class _T1, class _T2>
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, pair<_T1, _T2> >
+{
+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 <>
+struct __get_pair<0>
+{
+    template <class _T1, class _T2>
+    static
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    _T1&
+    get(pair<_T1, _T2>& __p) _NOEXCEPT {return __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 __p.first;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    template <class _T1, class _T2>
+    static
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    _T1&&
+    get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+};
+
+template <>
+struct __get_pair<1>
+{
+    template <class _T1, class _T2>
+    static
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    _T2&
+    get(pair<_T1, _T2>& __p) _NOEXCEPT {return __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 __p.second;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    template <class _T1, class _T2>
+    static
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+    _T2&&
+    get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+};
+
+template <size_t _Ip, class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&
+get(pair<_T1, _T2>& __p) _NOEXCEPT
+{
+    return __get_pair<_Ip>::get(__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(__p);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <size_t _Ip, class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
+get(pair<_T1, _T2>&& __p) _NOEXCEPT
+{
+    return __get_pair<_Ip>::get(_VSTD::move(__p));
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#if _LIBCPP_STD_VER > 11
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT
+{
+    return __get_pair<0>::get(__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(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+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 & get(pair<_T2, _T1>& __p) _NOEXCEPT
+{
+    return __get_pair<1>::get(__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(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT
+{
+    return __get_pair<1>::get(_VSTD::move(__p));
+}
+
+#endif
+
+#if _LIBCPP_STD_VER > 11
+
+template<class _Tp, _Tp... _Ip>
+struct _LIBCPP_TYPE_VIS_ONLY integer_sequence
+{
+    typedef _Tp value_type;
+    static_assert( is_integral<_Tp>::value,
+                  "std::integer_sequence can only be instantiated with an integral type" );
+    static
+    _LIBCPP_INLINE_VISIBILITY
+    constexpr
+    size_t
+    size() noexcept { return sizeof...(_Ip); }
+};
+
+template<size_t... _Ip>
+    using index_sequence = integer_sequence<size_t, _Ip...>;
+
+namespace __detail {
+
+template<typename _Tp, size_t ..._Extra> struct __repeat;
+template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<integer_sequence<_Tp, _Np...>, _Extra...> {
+  typedef integer_sequence<_Tp,
+                           _Np...,
+                           sizeof...(_Np) + _Np...,
+                           2 * sizeof...(_Np) + _Np...,
+                           3 * sizeof...(_Np) + _Np...,
+                           4 * sizeof...(_Np) + _Np...,
+                           5 * sizeof...(_Np) + _Np...,
+                           6 * sizeof...(_Np) + _Np...,
+                           7 * sizeof...(_Np) + _Np...,
+                           _Extra...> type;
+};
+
+template<size_t _Np> struct __parity;
+template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
+
+template<> struct __make<0> { typedef integer_sequence<size_t> type; };
+template<> struct __make<1> { typedef integer_sequence<size_t, 0> type; };
+template<> struct __make<2> { typedef integer_sequence<size_t, 0, 1> type; };
+template<> struct __make<3> { typedef integer_sequence<size_t, 0, 1, 2> type; };
+template<> struct __make<4> { typedef integer_sequence<size_t, 0, 1, 2, 3> type; };
+template<> struct __make<5> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
+template<> struct __make<6> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
+template<> struct __make<7> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
+
+template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
+template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
+template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
+
+template<typename _Tp, typename _Up> struct __convert {
+  template<typename> struct __result;
+  template<_Tp ..._Np> struct __result<integer_sequence<_Tp, _Np...> > { typedef integer_sequence<_Up, _Np...> type; };
+};
+template<typename _Tp> struct __convert<_Tp, _Tp> { template<typename _Up> struct __result { typedef _Up type; }; };
+
+}
+
+template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked =
+  typename __detail::__convert<size_t, _Tp>::template __result<typename __detail::__make<_Np>::type>::type;
+
+template <class _Tp, _Tp _Ep>
+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;
+};
+
+template<class _Tp, _Tp _Np>
+    using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type;
+
+template<size_t _Np>
+    using make_index_sequence = make_integer_sequence<size_t, _Np>;
+
+template<class... _Tp>
+    using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
+  
+#endif  // _LIBCPP_STD_VER > 11
+
+#if _LIBCPP_STD_VER > 11
+template<class _T1, class _T2 = _T1>
+inline _LIBCPP_INLINE_VISIBILITY
+_T1 exchange(_T1& __obj, _T2 && __new_value)
+{
+    _T1 __old_value = _VSTD::move(__obj);
+    __obj = _VSTD::forward<_T2>(__new_value);
+    return __old_value;
+}    
+#endif  // _LIBCPP_STD_VER > 11
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_UTILITY
diff --git a/final/include/valarray b/final/include/valarray
new file mode 100644
index 0000000..3714350
--- /dev/null
+++ b/final/include/valarray
@@ -0,0 +1,4780 @@
+// -*- C++ -*-
+//===-------------------------- valarray ----------------------------------===//
+//
+//                     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_VALARRAY
+#define _LIBCPP_VALARRAY
+
+/*
+    valarray synopsis
+
+namespace std
+{
+
+template<class T>
+class valarray
+{
+public:
+    typedef T value_type;
+
+    // construct/destroy:
+    valarray();
+    explicit valarray(size_t n);
+    valarray(const value_type& x, size_t n);
+    valarray(const value_type* px, size_t n);
+    valarray(const valarray& v);
+    valarray(valarray&& v) noexcept;
+    valarray(const slice_array<value_type>& sa);
+    valarray(const gslice_array<value_type>& ga);
+    valarray(const mask_array<value_type>& ma);
+    valarray(const indirect_array<value_type>& ia);
+    valarray(initializer_list<value_type> il);
+    ~valarray();
+
+    // assignment:
+    valarray& operator=(const valarray& v);
+    valarray& operator=(valarray&& v) noexcept;
+    valarray& operator=(initializer_list<value_type> il);
+    valarray& operator=(const value_type& x);
+    valarray& operator=(const slice_array<value_type>& sa);
+    valarray& operator=(const gslice_array<value_type>& ga);
+    valarray& operator=(const mask_array<value_type>& ma);
+    valarray& operator=(const indirect_array<value_type>& ia);
+
+    // element access:
+    const value_type& operator[](size_t i) const;
+    value_type&       operator[](size_t i);
+
+    // subset operations:
+    valarray                   operator[](slice s) const;
+    slice_array<value_type>    operator[](slice s);
+    valarray                   operator[](const gslice& gs) const;
+    gslice_array<value_type>   operator[](const gslice& gs);
+    valarray                   operator[](const valarray<bool>& vb) const;
+    mask_array<value_type>     operator[](const valarray<bool>& vb);
+    valarray                   operator[](const valarray<size_t>& vs) const;
+    indirect_array<value_type> operator[](const valarray<size_t>& vs);
+
+    // unary operators:
+    valarray       operator+() const;
+    valarray       operator-() const;
+    valarray       operator~() const;
+    valarray<bool> operator!() const;
+
+    // computed assignment:
+    valarray& operator*= (const value_type& x);
+    valarray& operator/= (const value_type& x);
+    valarray& operator%= (const value_type& x);
+    valarray& operator+= (const value_type& x);
+    valarray& operator-= (const value_type& x);
+    valarray& operator^= (const value_type& x);
+    valarray& operator&= (const value_type& x);
+    valarray& operator|= (const value_type& x);
+    valarray& operator<<=(const value_type& x);
+    valarray& operator>>=(const value_type& x);
+
+    valarray& operator*= (const valarray& v);
+    valarray& operator/= (const valarray& v);
+    valarray& operator%= (const valarray& v);
+    valarray& operator+= (const valarray& v);
+    valarray& operator-= (const valarray& v);
+    valarray& operator^= (const valarray& v);
+    valarray& operator|= (const valarray& v);
+    valarray& operator&= (const valarray& v);
+    valarray& operator<<=(const valarray& v);
+    valarray& operator>>=(const valarray& v);
+
+    // member functions:
+    void swap(valarray& v) noexcept;
+
+    size_t size() const;
+
+    value_type sum() const;
+    value_type min() const;
+    value_type max() const;
+
+    valarray shift (int i) const;
+    valarray cshift(int i) const;
+    valarray apply(value_type f(value_type)) const;
+    valarray apply(value_type f(const value_type&)) const;
+    void resize(size_t n, value_type x = value_type());
+};
+
+class slice
+{
+public:
+    slice();
+    slice(size_t start, size_t size, size_t stride);
+
+    size_t start()  const;
+    size_t size()   const;
+    size_t stride() const;
+};
+
+template <class T>
+class slice_array
+{
+public:
+    typedef T value_type;
+
+    const slice_array& operator=(const slice_array& sa) const;
+    void operator=  (const valarray<value_type>& v) const;
+    void operator*= (const valarray<value_type>& v) const;
+    void operator/= (const valarray<value_type>& v) const;
+    void operator%= (const valarray<value_type>& v) const;
+    void operator+= (const valarray<value_type>& v) const;
+    void operator-= (const valarray<value_type>& v) const;
+    void operator^= (const valarray<value_type>& v) const;
+    void operator&= (const valarray<value_type>& v) const;
+    void operator|= (const valarray<value_type>& v) const;
+    void operator<<=(const valarray<value_type>& v) const;
+    void operator>>=(const valarray<value_type>& v) const;
+
+    void operator=(const value_type& x) const;
+
+    slice_array() = delete;
+};
+
+class gslice
+{
+public:
+    gslice();
+    gslice(size_t start, const valarray<size_t>& size,
+                         const valarray<size_t>& stride);
+
+    size_t           start()  const;
+    valarray<size_t> size()   const;
+    valarray<size_t> stride() const;
+};
+
+template <class T>
+class gslice_array
+{
+public:
+    typedef T value_type;
+
+    void operator=  (const valarray<value_type>& v) const;
+    void operator*= (const valarray<value_type>& v) const;
+    void operator/= (const valarray<value_type>& v) const;
+    void operator%= (const valarray<value_type>& v) const;
+    void operator+= (const valarray<value_type>& v) const;
+    void operator-= (const valarray<value_type>& v) const;
+    void operator^= (const valarray<value_type>& v) const;
+    void operator&= (const valarray<value_type>& v) const;
+    void operator|= (const valarray<value_type>& v) const;
+    void operator<<=(const valarray<value_type>& v) const;
+    void operator>>=(const valarray<value_type>& v) const;
+
+    gslice_array(const gslice_array& ga);
+    ~gslice_array();
+    const gslice_array& operator=(const gslice_array& ga) const;
+    void operator=(const value_type& x) const;
+
+    gslice_array() = delete;
+};
+
+template <class T>
+class mask_array
+{
+public:
+    typedef T value_type;
+
+    void operator=  (const valarray<value_type>& v) const;
+    void operator*= (const valarray<value_type>& v) const;
+    void operator/= (const valarray<value_type>& v) const;
+    void operator%= (const valarray<value_type>& v) const;
+    void operator+= (const valarray<value_type>& v) const;
+    void operator-= (const valarray<value_type>& v) const;
+    void operator^= (const valarray<value_type>& v) const;
+    void operator&= (const valarray<value_type>& v) const;
+    void operator|= (const valarray<value_type>& v) const;
+    void operator<<=(const valarray<value_type>& v) const;
+    void operator>>=(const valarray<value_type>& v) const;
+
+    mask_array(const mask_array& ma);
+    ~mask_array();
+    const mask_array& operator=(const mask_array& ma) const;
+    void operator=(const value_type& x) const;
+
+    mask_array() = delete;
+};
+
+template <class T>
+class indirect_array
+{
+public:
+    typedef T value_type;
+
+    void operator=  (const valarray<value_type>& v) const;
+    void operator*= (const valarray<value_type>& v) const;
+    void operator/= (const valarray<value_type>& v) const;
+    void operator%= (const valarray<value_type>& v) const;
+    void operator+= (const valarray<value_type>& v) const;
+    void operator-= (const valarray<value_type>& v) const;
+    void operator^= (const valarray<value_type>& v) const;
+    void operator&= (const valarray<value_type>& v) const;
+    void operator|= (const valarray<value_type>& v) const;
+    void operator<<=(const valarray<value_type>& v) const;
+    void operator>>=(const valarray<value_type>& v) const;
+
+    indirect_array(const indirect_array& ia);
+    ~indirect_array();
+    const indirect_array& operator=(const indirect_array& ia) const;
+    void operator=(const value_type& x) const;
+
+    indirect_array() = delete;
+};
+
+template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
+
+template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
+template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
+
+template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
+template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> abs (const valarray<T>& x);
+template<class T> valarray<T> acos (const valarray<T>& x);
+template<class T> valarray<T> asin (const valarray<T>& x);
+template<class T> valarray<T> atan (const valarray<T>& x);
+
+template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
+template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> cos (const valarray<T>& x);
+template<class T> valarray<T> cosh (const valarray<T>& x);
+template<class T> valarray<T> exp (const valarray<T>& x);
+template<class T> valarray<T> log (const valarray<T>& x);
+template<class T> valarray<T> log10(const valarray<T>& x);
+
+template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
+template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
+template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
+
+template<class T> valarray<T> sin (const valarray<T>& x);
+template<class T> valarray<T> sinh (const valarray<T>& x);
+template<class T> valarray<T> sqrt (const valarray<T>& x);
+template<class T> valarray<T> tan (const valarray<T>& x);
+template<class T> valarray<T> tanh (const valarray<T>& x);
+
+template <class T> unspecified1 begin(valarray<T>& v);
+template <class T> unspecified2 begin(const valarray<T>& v);
+template <class T> unspecified1 end(valarray<T>& v);
+template <class T> unspecified2 end(const valarray<T>& v);
+
+}  // std
+
+*/
+
+#include <__config>
+#include <cstddef>
+#include <cmath>
+#include <initializer_list>
+#include <algorithm>
+#include <functional>
+#include <new>
+
+#include <__undef_min_max>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY valarray;
+
+class _LIBCPP_TYPE_VIS_ONLY slice
+{
+    size_t __start_;
+    size_t __size_;
+    size_t __stride_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    slice()
+        : __start_(0),
+          __size_(0),
+          __stride_(0)
+          {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    slice(size_t __start, size_t __size, size_t __stride)
+        : __start_(__start),
+          __size_(__size),
+          __stride_(__stride)
+          {}
+
+    _LIBCPP_INLINE_VISIBILITY size_t start()  const {return __start_;}
+    _LIBCPP_INLINE_VISIBILITY size_t size()   const {return __size_;}
+    _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
+};
+
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY slice_array;
+class _LIBCPP_TYPE_VIS gslice;
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY gslice_array;
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY mask_array;
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY indirect_array;
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp*
+begin(valarray<_Tp>& __v);
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+const _Tp*
+begin(const valarray<_Tp>& __v);
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp*
+end(valarray<_Tp>& __v);
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+const _Tp*
+end(const valarray<_Tp>& __v);
+
+template <class _Op, class _A0>
+struct _UnaryOp
+{
+    typedef typename _Op::result_type result_type;
+    typedef typename _A0::value_type value_type;
+
+    _Op __op_;
+    _A0 __a0_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _A0, class _A1>
+struct _BinaryOp
+{
+    typedef typename _Op::result_type result_type;
+    typedef typename _A0::value_type value_type;
+
+    _Op __op_;
+    _A0 __a0_;
+    _A1 __a1_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
+        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __a0_.size();}
+};
+
+template <class _Tp>
+class __scalar_expr
+{
+public:
+    typedef _Tp        value_type;
+    typedef const _Tp& result_type;
+private:
+    const value_type& __t_;
+    size_t __s_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t) const {return __t_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __s_;}
+};
+
+template <class _Tp>
+struct __unary_plus : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return +__x;}
+};
+
+template <class _Tp>
+struct __bit_not  : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return ~__x;}
+};
+
+template <class _Tp>
+struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x << __y;}
+};
+
+template <class _Tp>
+struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return __x >> __y;}
+};
+
+template <class _Tp, class _Fp>
+struct __apply_expr   : unary_function<_Tp, _Tp>
+{
+private:
+    _Fp __f_;
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __apply_expr(_Fp __f) : __f_(__f) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return __f_(__x);}
+};
+
+template <class _Tp>
+struct __abs_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return abs(__x);}
+};
+
+template <class _Tp>
+struct __acos_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return acos(__x);}
+};
+
+template <class _Tp>
+struct __asin_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return asin(__x);}
+};
+
+template <class _Tp>
+struct __atan_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return atan(__x);}
+};
+
+template <class _Tp>
+struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return atan2(__x, __y);}
+};
+
+template <class _Tp>
+struct __cos_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return cos(__x);}
+};
+
+template <class _Tp>
+struct __cosh_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return cosh(__x);}
+};
+
+template <class _Tp>
+struct __exp_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return exp(__x);}
+};
+
+template <class _Tp>
+struct __log_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return log(__x);}
+};
+
+template <class _Tp>
+struct __log10_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return log10(__x);}
+};
+
+template <class _Tp>
+struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x, const _Tp& __y) const
+        {return pow(__x, __y);}
+};
+
+template <class _Tp>
+struct __sin_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return sin(__x);}
+};
+
+template <class _Tp>
+struct __sinh_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return sinh(__x);}
+};
+
+template <class _Tp>
+struct __sqrt_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return sqrt(__x);}
+};
+
+template <class _Tp>
+struct __tan_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return tan(__x);}
+};
+
+template <class _Tp>
+struct __tanh_expr : unary_function<_Tp, _Tp>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    _Tp operator()(const _Tp& __x) const
+        {return tanh(__x);}
+};
+
+template <class _ValExpr>
+class __slice_expr
+{
+    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
+public:
+    typedef typename _RmExpr::value_type value_type;
+    typedef value_type result_type;
+
+private:
+    _ValExpr __expr_;
+    size_t __start_;
+    size_t __size_;
+    size_t __stride_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __slice_expr(const slice& __sl, const _RmExpr& __e)
+        : __expr_(__e),
+          __start_(__sl.start()),
+          __size_(__sl.size()),
+          __stride_(__sl.stride())
+        {}
+public:
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __i) const
+        {return __expr_[__start_ + __i * __stride_];}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __size_;}
+
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
+};
+
+template <class _ValExpr>
+class __mask_expr;
+
+template <class _ValExpr>
+class __indirect_expr;
+
+template <class _ValExpr>
+class __shift_expr
+{
+    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
+public:
+    typedef typename _RmExpr::value_type value_type;
+    typedef value_type result_type;
+
+private:
+    _ValExpr __expr_;
+    size_t __size_;
+    ptrdiff_t __ul_;
+    ptrdiff_t __sn_;
+    ptrdiff_t __n_;
+    static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
+                                    sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
+
+    _LIBCPP_INLINE_VISIBILITY
+    __shift_expr(int __n, const _RmExpr& __e)
+        : __expr_(__e),
+          __size_(__e.size()),
+          __n_(__n)
+        {
+            ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
+            __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
+            __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
+        }
+public:
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __j) const
+        {
+            ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
+            ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
+            return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __size_;}
+
+    template <class> friend class __val_expr;
+};
+
+template <class _ValExpr>
+class __cshift_expr
+{
+    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
+public:
+    typedef typename _RmExpr::value_type value_type;
+    typedef value_type result_type;
+
+private:
+    _ValExpr __expr_;
+    size_t __size_;
+    size_t __m_;
+    size_t __o1_;
+    size_t __o2_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __cshift_expr(int __n, const _RmExpr& __e)
+        : __expr_(__e),
+          __size_(__e.size())
+        {
+            __n %= static_cast<int>(__size_);
+            if (__n >= 0)
+            {
+                __m_ = __size_ - __n;
+                __o1_ = __n;
+                __o2_ = __n - __size_;
+            }
+            else
+            {
+                __m_ = -__n;
+                __o1_ = __n + __size_;
+                __o2_ = __n;
+            }
+        }
+public:
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __i) const
+        {
+            if (__i < __m_)
+                return __expr_[__i + __o1_];
+            return __expr_[__i + __o2_];
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __size_;}
+
+    template <class> friend class __val_expr;
+};
+
+template<class _ValExpr>
+class __val_expr;
+
+template<class _ValExpr>
+struct __is_val_expr : false_type {};
+
+template<class _ValExpr>
+struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
+
+template<class _Tp>
+struct __is_val_expr<valarray<_Tp> > : true_type {};
+
+template<class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY valarray
+{
+public:
+    typedef _Tp value_type;
+    typedef _Tp result_type;
+
+private:
+    value_type* __begin_;
+    value_type* __end_;
+
+public:
+    // construct/destroy:
+    _LIBCPP_INLINE_VISIBILITY
+    valarray() : __begin_(0), __end_(0) {}
+    explicit valarray(size_t __n);
+    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
+    valarray(valarray&& __v) _NOEXCEPT;
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    valarray(initializer_list<value_type> __il);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    valarray(const slice_array<value_type>& __sa);
+    valarray(const gslice_array<value_type>& __ga);
+    valarray(const mask_array<value_type>& __ma);
+    valarray(const indirect_array<value_type>& __ia);
+    ~valarray();
+
+    // assignment:
+    valarray& operator=(const valarray& __v);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    valarray& operator=(valarray&& __v) _NOEXCEPT;
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    valarray& operator=(initializer_list<value_type>);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    valarray& operator=(const value_type& __x);
+    valarray& operator=(const slice_array<value_type>& __sa);
+    valarray& operator=(const gslice_array<value_type>& __ga);
+    valarray& operator=(const mask_array<value_type>& __ma);
+    valarray& operator=(const indirect_array<value_type>& __ia);
+    template <class _ValExpr>
+        valarray& operator=(const __val_expr<_ValExpr>& __v);
+
+    // element access:
+    _LIBCPP_INLINE_VISIBILITY
+    const value_type& operator[](size_t __i) const {return __begin_[__i];}
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type&       operator[](size_t __i)       {return __begin_[__i];}
+
+    // subset operations:
+    __val_expr<__slice_expr<const valarray&> >    operator[](slice __s) const;
+    slice_array<value_type>                       operator[](slice __s);
+    __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
+    gslice_array<value_type>   operator[](const gslice& __gs);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
+    gslice_array<value_type>                      operator[](gslice&& __gs);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __val_expr<__mask_expr<const valarray&> >     operator[](const valarray<bool>& __vb) const;
+    mask_array<value_type>                        operator[](const valarray<bool>& __vb);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __val_expr<__mask_expr<const valarray&> >     operator[](valarray<bool>&& __vb) const;
+    mask_array<value_type>                        operator[](valarray<bool>&& __vb);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
+    indirect_array<value_type>                    operator[](const valarray<size_t>& __vs);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
+    indirect_array<value_type>                    operator[](valarray<size_t>&& __vs);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    // unary operators:
+    valarray       operator+() const;
+    valarray       operator-() const;
+    valarray       operator~() const;
+    valarray<bool> operator!() const;
+
+    // computed assignment:
+    valarray& operator*= (const value_type& __x);
+    valarray& operator/= (const value_type& __x);
+    valarray& operator%= (const value_type& __x);
+    valarray& operator+= (const value_type& __x);
+    valarray& operator-= (const value_type& __x);
+    valarray& operator^= (const value_type& __x);
+    valarray& operator&= (const value_type& __x);
+    valarray& operator|= (const value_type& __x);
+    valarray& operator<<=(const value_type& __x);
+    valarray& operator>>=(const value_type& __x);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator*= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator/= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator%= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator+= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator-= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator^= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator|= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator&= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator<<= (const _Expr& __v);
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        valarray&
+    >::type
+    operator>>= (const _Expr& __v);
+
+    // member functions:
+    void swap(valarray& __v) _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
+
+    value_type sum() const;
+    value_type min() const;
+    value_type max() const;
+
+    valarray shift (int __i) const;
+    valarray cshift(int __i) const;
+    valarray apply(value_type __f(value_type)) const;
+    valarray apply(value_type __f(const value_type&)) const;
+    void     resize(size_t __n, value_type __x = value_type());
+
+private:
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY slice_array;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY gslice_array;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY mask_array;
+    template <class> friend class __mask_expr;
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY indirect_array;
+    template <class> friend class __indirect_expr;
+    template <class> friend class __val_expr;
+
+    template <class _Up>
+    friend
+    _Up*
+    begin(valarray<_Up>& __v);
+
+    template <class _Up>
+    friend
+    const _Up*
+    begin(const valarray<_Up>& __v);
+
+    template <class _Up>
+    friend
+    _Up*
+    end(valarray<_Up>& __v);
+
+    template <class _Up>
+    friend
+    const _Up*
+    end(const valarray<_Up>& __v);
+};
+
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
+_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
+
+template <class _Op, class _Tp>
+struct _UnaryOp<_Op, valarray<_Tp> >
+{
+    typedef typename _Op::result_type result_type;
+    typedef _Tp value_type;
+
+    _Op __op_;
+    const valarray<_Tp>& __a0_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _Tp, class _A1>
+struct _BinaryOp<_Op, valarray<_Tp>, _A1>
+{
+    typedef typename _Op::result_type result_type;
+    typedef _Tp value_type;
+
+    _Op __op_;
+    const valarray<_Tp>& __a0_;
+    _A1 __a1_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
+        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _A0, class _Tp>
+struct _BinaryOp<_Op, _A0, valarray<_Tp> >
+{
+    typedef typename _Op::result_type result_type;
+    typedef _Tp value_type;
+
+    _Op __op_;
+    _A0 __a0_;
+    const valarray<_Tp>& __a1_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
+        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __a0_.size();}
+};
+
+template <class _Op, class _Tp>
+struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
+{
+    typedef typename _Op::result_type result_type;
+    typedef _Tp value_type;
+
+    _Op __op_;
+    const valarray<_Tp>& __a0_;
+    const valarray<_Tp>& __a1_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
+        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __a0_.size();}
+};
+
+// slice_array
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY slice_array
+{
+public:
+    typedef _Tp value_type;
+
+private:
+    value_type* __vp_;
+    size_t __size_;
+    size_t __stride_;
+
+public:
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator*=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator/=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator%=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator+=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator-=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator^=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator&=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator|=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator<<=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator>>=(const _Expr& __v) const;
+
+    const slice_array& operator=(const slice_array& __sa) const;
+
+    void operator=(const value_type& __x) const;
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    slice_array(const slice& __sl, const valarray<value_type>& __v)
+        : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
+          __size_(__sl.size()),
+          __stride_(__sl.stride())
+        {}
+
+    template <class> friend class valarray;
+    template <class> friend class sliceExpr;
+};
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const slice_array<_Tp>&
+slice_array<_Tp>::operator=(const slice_array& __sa) const
+{
+    value_type* __t = __vp_;
+    const value_type* __s = __sa.__vp_;
+    for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
+        *__t = *__s;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t = __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator*=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t *= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator/=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t /= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator%=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t %= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator+=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t += __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator-=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t -= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator^=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t ^= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator&=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t &= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator|=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t |= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t <<= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+slice_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+    value_type* __t = __vp_;
+    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
+        *__t >>= __v[__i];
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+slice_array<_Tp>::operator=(const value_type& __x) const
+{
+    value_type* __t = __vp_;
+    for (size_t __n = __size_; __n; --__n, __t += __stride_)
+        *__t = __x;
+}
+
+// gslice
+
+class _LIBCPP_TYPE_VIS gslice
+{
+    valarray<size_t> __size_;
+    valarray<size_t> __stride_;
+    valarray<size_t> __1d_;
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    gslice() {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    gslice(size_t __start, const valarray<size_t>& __size,
+                           const valarray<size_t>& __stride)
+        : __size_(__size),
+          __stride_(__stride)
+        {__init(__start);}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    gslice(size_t __start, const valarray<size_t>&  __size,
+                                 valarray<size_t>&& __stride)
+        : __size_(__size),
+          __stride_(move(__stride))
+        {__init(__start);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    gslice(size_t __start,       valarray<size_t>&& __size,
+                           const valarray<size_t>&  __stride)
+        : __size_(move(__size)),
+          __stride_(__stride)
+        {__init(__start);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    gslice(size_t __start,       valarray<size_t>&& __size,
+                                 valarray<size_t>&& __stride)
+        : __size_(move(__size)),
+          __stride_(move(__stride))
+        {__init(__start);}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+//  gslice(const gslice&)            = default;
+//  gslice(gslice&&)                 = default;
+//  gslice& operator=(const gslice&) = default;
+//  gslice& operator=(gslice&&)      = default;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t           start()  const {return __1d_.size() ? __1d_[0] : 0;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    valarray<size_t> size()   const {return __size_;}
+
+    _LIBCPP_INLINE_VISIBILITY
+    valarray<size_t> stride() const {return __stride_;}
+
+private:
+    void __init(size_t __start);
+
+    template <class> friend class gslice_array;
+    template <class> friend class valarray;
+    template <class> friend class __val_expr;
+};
+
+// gslice_array
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY gslice_array
+{
+public:
+    typedef _Tp value_type;
+
+private:
+    value_type*      __vp_;
+    valarray<size_t> __1d_;
+
+public:
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator*=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator/=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator%=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator+=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator-=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator^=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator&=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator|=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator<<=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator>>=(const _Expr& __v) const;
+
+    const gslice_array& operator=(const gslice_array& __ga) const;
+
+    void operator=(const value_type& __x) const;
+
+//  gslice_array(const gslice_array&)            = default;
+//  gslice_array(gslice_array&&)                 = default;
+//  gslice_array& operator=(const gslice_array&) = default;
+//  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;
+};
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] = __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator*=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] *= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator/=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] /= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator%=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] %= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator+=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] += __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator-=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] -= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator^=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] ^= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator&=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] &= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator|=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] |= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] <<= __v[__j];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+gslice_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+    typedef const size_t* _Ip;
+    size_t __j = 0;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
+        __vp_[*__i] >>= __v[__j];
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const gslice_array<_Tp>&
+gslice_array<_Tp>::operator=(const gslice_array& __ga) const
+{
+    typedef const size_t* _Ip;
+    const value_type* __s = __ga.__vp_;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
+            __i != __e; ++__i, ++__j)
+        __vp_[*__i] = __s[*__j];
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+gslice_array<_Tp>::operator=(const value_type& __x) const
+{
+    typedef const size_t* _Ip;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
+        __vp_[*__i] = __x;
+}
+
+// mask_array
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY mask_array
+{
+public:
+    typedef _Tp value_type;
+
+private:
+    value_type*      __vp_;
+    valarray<size_t> __1d_;
+
+public:
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator*=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator/=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator%=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator+=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator-=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator^=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator&=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator|=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator<<=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator>>=(const _Expr& __v) const;
+
+    const mask_array& operator=(const mask_array& __ma) const;
+
+    void operator=(const value_type& __x) const;
+
+//  mask_array(const mask_array&)            = default;
+//  mask_array(mask_array&&)                 = default;
+//  mask_array& operator=(const mask_array&) = default;
+//  mask_array& operator=(mask_array&&)      = default;
+
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
+        : __vp_(const_cast<value_type*>(__v.__begin_)),
+          __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
+          {
+              size_t __j = 0;
+              for (size_t __i = 0; __i < __vb.size(); ++__i)
+                  if (__vb[__i])
+                      __1d_[__j++] = __i;
+          }
+
+    template <class> friend class valarray;
+};
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] = __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator*=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] *= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator/=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] /= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator%=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] %= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator+=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] += __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator-=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] -= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator^=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] ^= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator&=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] &= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator|=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] |= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] <<= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+mask_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] >>= __v[__i];
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const mask_array<_Tp>&
+mask_array<_Tp>::operator=(const mask_array& __ma) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+mask_array<_Tp>::operator=(const value_type& __x) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] = __x;
+}
+
+template <class _ValExpr>
+class __mask_expr
+{
+    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
+public:
+    typedef typename _RmExpr::value_type value_type;
+    typedef value_type result_type;
+
+private:
+    _ValExpr __expr_;
+    valarray<size_t> __1d_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
+        : __expr_(__e),
+          __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
+          {
+              size_t __j = 0;
+              for (size_t __i = 0; __i < __vb.size(); ++__i)
+                  if (__vb[__i])
+                      __1d_[__j++] = __i;
+          }
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __i) const
+        {return __expr_[__1d_[__i]];}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __1d_.size();}
+
+    template <class> friend class valarray;
+};
+
+// indirect_array
+
+template <class _Tp>
+class _LIBCPP_TYPE_VIS_ONLY indirect_array
+{
+public:
+    typedef _Tp value_type;
+
+private:
+    value_type*      __vp_;
+    valarray<size_t> __1d_;
+
+public:
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator*=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator/=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator%=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator+=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator-=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator^=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator&=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator|=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator<<=(const _Expr& __v) const;
+
+    template <class _Expr>
+    typename enable_if
+    <
+        __is_val_expr<_Expr>::value,
+        void
+    >::type
+    operator>>=(const _Expr& __v) const;
+
+    const indirect_array& operator=(const indirect_array& __ia) const;
+
+    void operator=(const value_type& __x) const;
+
+//  indirect_array(const indirect_array&)            = default;
+//  indirect_array(indirect_array&&)                 = default;
+//  indirect_array& operator=(const indirect_array&) = default;
+//  indirect_array& operator=(indirect_array&&)      = default;
+
+private:
+     _LIBCPP_INLINE_VISIBILITY
+   indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
+        : __vp_(const_cast<value_type*>(__v.__begin_)),
+          __1d_(__ia)
+        {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
+        : __vp_(const_cast<value_type*>(__v.__begin_)),
+          __1d_(move(__ia))
+        {}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    template <class> friend class valarray;
+};
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] = __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator*=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] *= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator/=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] /= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator%=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] %= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator+=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] += __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator-=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] -= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator^=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] ^= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator&=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] &= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator|=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] |= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator<<=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] <<= __v[__i];
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    void
+>::type
+indirect_array<_Tp>::operator>>=(const _Expr& __v) const
+{
+    size_t __n = __1d_.size();
+    for (size_t __i = 0; __i < __n; ++__i)
+        __vp_[__1d_[__i]] >>= __v[__i];
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const indirect_array<_Tp>&
+indirect_array<_Tp>::operator=(const indirect_array& __ia) const
+{
+    typedef const size_t* _Ip;
+    const value_type* __s = __ia.__vp_;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
+            __i != __e; ++__i, ++__j)
+        __vp_[*__i] = __s[*__j];
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+indirect_array<_Tp>::operator=(const value_type& __x) const
+{
+    typedef const size_t* _Ip;
+    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
+        __vp_[*__i] = __x;
+}
+
+template <class _ValExpr>
+class __indirect_expr
+{
+    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
+public:
+    typedef typename _RmExpr::value_type value_type;
+    typedef value_type result_type;
+
+private:
+    _ValExpr __expr_;
+    valarray<size_t> __1d_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
+        : __expr_(__e),
+          __1d_(__ia)
+          {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    _LIBCPP_INLINE_VISIBILITY
+    __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
+        : __expr_(__e),
+          __1d_(move(__ia))
+          {}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __i) const
+        {return __expr_[__1d_[__i]];}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __1d_.size();}
+
+    template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
+};
+
+template<class _ValExpr>
+class __val_expr
+{
+    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
+
+    _ValExpr __expr_;
+public:
+    typedef typename _RmExpr::value_type value_type;
+    typedef typename _RmExpr::result_type result_type;
+
+    _LIBCPP_INLINE_VISIBILITY
+    explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type operator[](size_t __i) const
+        {return __expr_[__i];}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
+        {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
+        {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
+        {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
+        {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
+    operator+() const
+    {
+        typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
+        return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
+    operator-() const
+    {
+        typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
+        return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
+    operator~() const
+    {
+        typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
+        return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
+    operator!() const
+    {
+        typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
+        return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
+    }
+
+    operator valarray<result_type>() const;
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_t size() const {return __expr_.size();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type sum() const
+    {
+        size_t __n = __expr_.size();
+        result_type __r = __n ? __expr_[0] : result_type();
+        for (size_t __i = 1; __i < __n; ++__i)
+            __r += __expr_[__i];
+        return __r;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type min() const
+    {
+        size_t __n = size();
+        result_type __r = __n ? (*this)[0] : result_type();
+        for (size_t __i = 1; __i < __n; ++__i)
+        {
+            result_type __x = __expr_[__i];
+            if (__x < __r)
+                __r = __x;
+        }
+        return __r;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    result_type max() const
+    {
+        size_t __n = size();
+        result_type __r = __n ? (*this)[0] : result_type();
+        for (size_t __i = 1; __i < __n; ++__i)
+        {
+            result_type __x = __expr_[__i];
+            if (__r < __x)
+                __r = __x;
+        }
+        return __r;
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
+        {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
+        {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
+    apply(value_type __f(value_type)) const
+    {
+        typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
+        typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
+        return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
+    apply(value_type __f(const value_type&)) const
+    {
+        typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
+        typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
+        return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
+    }
+};
+
+template<class _ValExpr>
+__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
+{
+    valarray<result_type> __r;
+    size_t __n = __expr_.size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
+        for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
+            ::new (__r.__end_) result_type(__expr_[__i]);
+    }
+    return __r;
+}
+
+// valarray
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>::valarray(size_t __n)
+    : __begin_(0),
+      __end_(0)
+{
+    resize(__n);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>::valarray(const value_type& __x, size_t __n)
+    : __begin_(0),
+      __end_(0)
+{
+    resize(__n, __x);
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const value_type* __p, size_t __n)
+    : __begin_(0),
+      __end_(0)
+{
+    if (__n)
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __n; ++__end_, ++__p, --__n)
+                ::new (__end_) value_type(*__p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const valarray& __v)
+    : __begin_(0),
+      __end_(0)
+{
+    if (__v.size())
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
+                ::new (__end_) value_type(*__p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
+    : __begin_(__v.__begin_),
+      __end_(__v.__end_)
+{
+    __v.__begin_ = __v.__end_ = nullptr;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp>
+valarray<_Tp>::valarray(initializer_list<value_type> __il)
+    : __begin_(0),
+      __end_(0)
+{
+    size_t __n = __il.size();
+    if (__n)
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
+                ::new (__end_) value_type(*__p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp>
+valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
+    : __begin_(0),
+      __end_(0)
+{
+    size_t __n = __sa.__size_;
+    if (__n)
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
+                ::new (__end_) value_type(*__p);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
+    : __begin_(0),
+      __end_(0)
+{
+    size_t __n = __ga.__1d_.size();
+    if (__n)
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            typedef const size_t* _Ip;
+            const value_type* __s = __ga.__vp_;
+            for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
+                    __i != __e; ++__i, ++__end_)
+                ::new (__end_) value_type(__s[*__i]);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
+    : __begin_(0),
+      __end_(0)
+{
+    size_t __n = __ma.__1d_.size();
+    if (__n)
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            typedef const size_t* _Ip;
+            const value_type* __s = __ma.__vp_;
+            for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
+                    __i != __e; ++__i, ++__end_)
+                ::new (__end_) value_type(__s[*__i]);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Tp>
+valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
+    : __begin_(0),
+      __end_(0)
+{
+    size_t __n = __ia.__1d_.size();
+    if (__n)
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            typedef const size_t* _Ip;
+            const value_type* __s = __ia.__vp_;
+            for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
+                    __i != __e; ++__i, ++__end_)
+                ::new (__end_) value_type(__s[*__i]);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>::~valarray()
+{
+    resize(0);
+}
+
+template <class _Tp>
+valarray<_Tp>&
+valarray<_Tp>::operator=(const valarray& __v)
+{
+    if (this != &__v)
+    {
+        if (size() != __v.size())
+            resize(__v.size());
+        _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
+    }
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
+{
+    resize(0);
+    __begin_ = __v.__begin_;
+    __end_ = __v.__end_;
+    __v.__begin_ = nullptr;
+    __v.__end_ = nullptr;
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(initializer_list<value_type> __il)
+{
+    if (size() != __il.size())
+        resize(__il.size());
+    _VSTD::copy(__il.begin(), __il.end(), __begin_);
+    return *this;
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(const value_type& __x)
+{
+    _VSTD::fill(__begin_, __end_, __x);
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
+{
+    value_type* __t = __begin_;
+    const value_type* __s = __sa.__vp_;
+    for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
+        *__t = *__s;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
+{
+    typedef const size_t* _Ip;
+    value_type* __t = __begin_;
+    const value_type* __s = __ga.__vp_;
+    for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
+                    __i != __e; ++__i, ++__t)
+        *__t = __s[*__i];
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
+{
+    typedef const size_t* _Ip;
+    value_type* __t = __begin_;
+    const value_type* __s = __ma.__vp_;
+    for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
+                    __i != __e; ++__i, ++__t)
+        *__t = __s[*__i];
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
+{
+    typedef const size_t* _Ip;
+    value_type* __t = __begin_;
+    const value_type* __s = __ia.__vp_;
+    for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
+                    __i != __e; ++__i, ++__t)
+        *__t = __s[*__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _ValExpr>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
+{
+    size_t __n = __v.size();
+    if (size() != __n)
+        resize(__n);
+    value_type* __t = __begin_;
+    for (size_t __i = 0; __i != __n; ++__t, ++__i)
+        *__t = result_type(__v[__i]);
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__val_expr<__slice_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](slice __s) const
+{
+    return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+slice_array<_Tp>
+valarray<_Tp>::operator[](slice __s)
+{
+    return slice_array<value_type>(__s, *this);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](const gslice& __gs) const
+{
+    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+gslice_array<_Tp>
+valarray<_Tp>::operator[](const gslice& __gs)
+{
+    return gslice_array<value_type>(__gs, *this);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](gslice&& __gs) const
+{
+    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+gslice_array<_Tp>
+valarray<_Tp>::operator[](gslice&& __gs)
+{
+    return gslice_array<value_type>(move(__gs), *this);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__val_expr<__mask_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](const valarray<bool>& __vb) const
+{
+    return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+mask_array<_Tp>
+valarray<_Tp>::operator[](const valarray<bool>& __vb)
+{
+    return mask_array<value_type>(__vb, *this);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__val_expr<__mask_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](valarray<bool>&& __vb) const
+{
+    return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+mask_array<_Tp>
+valarray<_Tp>::operator[](valarray<bool>&& __vb)
+{
+    return mask_array<value_type>(move(__vb), *this);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
+{
+    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+indirect_array<_Tp>
+valarray<_Tp>::operator[](const valarray<size_t>& __vs)
+{
+    return indirect_array<value_type>(__vs, *this);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+__val_expr<__indirect_expr<const valarray<_Tp>&> >
+valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
+{
+    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+indirect_array<_Tp>
+valarray<_Tp>::operator[](valarray<size_t>&& __vs)
+{
+    return indirect_array<value_type>(move(__vs), *this);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::operator+() const
+{
+    valarray<value_type> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+            ::new (__r.__end_) value_type(+*__p);
+    }
+    return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::operator-() const
+{
+    valarray<value_type> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+            ::new (__r.__end_) value_type(-*__p);
+    }
+    return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::operator~() const
+{
+    valarray<value_type> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+            ::new (__r.__end_) value_type(~*__p);
+    }
+    return __r;
+}
+
+template <class _Tp>
+valarray<bool>
+valarray<_Tp>::operator!() const
+{
+    valarray<bool> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
+        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+            ::new (__r.__end_) bool(!*__p);
+    }
+    return __r;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator*=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p *= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator/=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p /= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator%=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p %= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator+=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p += __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator-=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p -= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator^=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p ^= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator&=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p &= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator|=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p |= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator<<=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p <<= __x;
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+valarray<_Tp>&
+valarray<_Tp>::operator>>=(const value_type& __x)
+{
+    for (value_type* __p = __begin_; __p != __end_; ++__p)
+        *__p >>= __x;
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator*=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t *= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator/=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t /= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator%=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t %= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator+=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t += __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator-=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t -= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator^=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t ^= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator|=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t |= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator&=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t &= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator<<=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t <<= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+template <class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    valarray<_Tp>&
+>::type
+valarray<_Tp>::operator>>=(const _Expr& __v)
+{
+    size_t __i = 0;
+    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
+        *__t >>= __v[__i];
+    return *this;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
+{
+    _VSTD::swap(__begin_, __v.__begin_);
+    _VSTD::swap(__end_, __v.__end_);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+valarray<_Tp>::sum() const
+{
+    if (__begin_ == __end_)
+        return value_type();
+    const value_type* __p = __begin_;
+    _Tp __r = *__p;
+    for (++__p; __p != __end_; ++__p)
+        __r += *__p;
+    return __r;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+valarray<_Tp>::min() const
+{
+    if (__begin_ == __end_)
+        return value_type();
+    return *_VSTD::min_element(__begin_, __end_);
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp
+valarray<_Tp>::max() const
+{
+    if (__begin_ == __end_)
+        return value_type();
+    return *_VSTD::max_element(__begin_, __end_);
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::shift(int __i) const
+{
+    valarray<value_type> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+        const value_type* __sb;
+        value_type* __tb;
+        value_type* __te;
+        if (__i >= 0)
+        {
+            __i = _VSTD::min(__i, static_cast<int>(__n));
+            __sb = __begin_ + __i;
+            __tb = __r.__begin_;
+            __te = __r.__begin_ + (__n - __i);
+        }
+        else
+        {
+            __i = _VSTD::min(-__i, static_cast<int>(__n));
+            __sb = __begin_;
+            __tb = __r.__begin_ + __i;
+            __te = __r.__begin_ + __n;
+        }
+        for (; __r.__end_ != __tb; ++__r.__end_)
+            ::new (__r.__end_) value_type();
+        for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
+            ::new (__r.__end_) value_type(*__sb);
+        for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
+            ::new (__r.__end_) value_type();
+    }
+    return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::cshift(int __i) const
+{
+    valarray<value_type> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+        __i %= static_cast<int>(__n);
+        const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
+        for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
+            ::new (__r.__end_) value_type(*__s);
+        for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
+            ::new (__r.__end_) value_type(*__s);
+    }
+    return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::apply(value_type __f(value_type)) const
+{
+    valarray<value_type> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+            ::new (__r.__end_) value_type(__f(*__p));
+    }
+    return __r;
+}
+
+template <class _Tp>
+valarray<_Tp>
+valarray<_Tp>::apply(value_type __f(const value_type&)) const
+{
+    valarray<value_type> __r;
+    size_t __n = size();
+    if (__n)
+    {
+        __r.__begin_ =
+            __r.__end_ =
+                static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
+            ::new (__r.__end_) value_type(__f(*__p));
+    }
+    return __r;
+}
+
+template <class _Tp>
+void
+valarray<_Tp>::resize(size_t __n, value_type __x)
+{
+    if (__begin_ != nullptr)
+    {
+        while (__end_ != __begin_)
+            (--__end_)->~value_type();
+        _VSTD::__deallocate(__begin_);
+        __begin_ = __end_ = nullptr;
+    }
+    if (__n)
+    {
+        __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            for (; __n; --__n, ++__end_)
+                ::new (__end_) value_type(__x);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            resize(0);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template<class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
+{
+    __x.swap(__y);
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator*(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator*(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(multiplies<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator*(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(multiplies<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator/(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator/(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(divides<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator/(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(divides<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator%(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator%(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(modulus<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator%(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(modulus<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator+(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator+(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(plus<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator+(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(plus<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator-(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator-(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(minus<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator-(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(minus<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator^(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator^(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(bit_xor<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator^(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(bit_xor<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator&(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator&(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(bit_and<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator&(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(bit_and<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator|(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator|(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(bit_or<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator|(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(bit_or<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator<<(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator>>(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator&&(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(logical_and<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(logical_and<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator||(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator||(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(logical_or<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator||(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(logical_or<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator==(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator==(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(equal_to<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator==(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(equal_to<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator!=(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator<(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<less<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator<(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(less<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<less<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator<(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(less<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator>(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator>(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(greater<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator>(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(greater<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator<=(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(less_equal<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(less_equal<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+operator>=(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(greater_equal<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(greater_equal<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
+>::type
+abs(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
+>::type
+acos(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
+>::type
+asin(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
+>::type
+atan(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+atan2(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+atan2(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+atan2(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
+>::type
+cos(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
+>::type
+cosh(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
+>::type
+exp(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
+>::type
+log(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
+>::type
+log10(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
+}
+
+template<class _Expr1, class _Expr2>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
+    __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
+>::type
+pow(const _Expr1& __x, const _Expr2& __y)
+{
+    typedef typename _Expr1::value_type value_type;
+    typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
+    return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
+               _Expr, __scalar_expr<typename _Expr::value_type> > >
+>::type
+pow(const _Expr& __x, const typename _Expr::value_type& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
+    return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
+                           __x, __scalar_expr<value_type>(__y, __x.size())));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
+               __scalar_expr<typename _Expr::value_type>, _Expr> >
+>::type
+pow(const typename _Expr::value_type& __x, const _Expr& __y)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
+                           __scalar_expr<value_type>(__x, __y.size()), __y));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
+>::type
+sin(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
+>::type
+sinh(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
+>::type
+sqrt(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
+>::type
+tan(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
+}
+
+template<class _Expr>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if
+<
+    __is_val_expr<_Expr>::value,
+    __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
+>::type
+tanh(const _Expr& __x)
+{
+    typedef typename _Expr::value_type value_type;
+    typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
+    return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+begin(valarray<_Tp>& __v)
+{
+    return __v.__begin_;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Tp*
+begin(const valarray<_Tp>& __v)
+{
+    return __v.__begin_;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp*
+end(valarray<_Tp>& __v)
+{
+    return __v.__end_;
+}
+
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+const _Tp*
+end(const valarray<_Tp>& __v)
+{
+    return __v.__end_;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_VALARRAY
diff --git a/final/include/vector b/final/include/vector
new file mode 100644
index 0000000..1e638b9
--- /dev/null
+++ b/final/include/vector
@@ -0,0 +1,3301 @@
+// -*- C++ -*-
+//===------------------------------ vector --------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_VECTOR
+#define _LIBCPP_VECTOR
+
+/*
+    vector synopsis
+
+namespace std
+{
+
+template <class T, class Allocator = allocator<T> >
+class vector
+{
+public:
+    typedef T                                        value_type;
+    typedef Allocator                                allocator_type;
+    typedef typename allocator_type::reference       reference;
+    typedef typename allocator_type::const_reference const_reference;
+    typedef implementation-defined                   iterator;
+    typedef implementation-defined                   const_iterator;
+    typedef typename allocator_type::size_type       size_type;
+    typedef typename allocator_type::difference_type difference_type;
+    typedef typename allocator_type::pointer         pointer;
+    typedef typename allocator_type::const_pointer   const_pointer;
+    typedef std::reverse_iterator<iterator>          reverse_iterator;
+    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+
+    vector()
+        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+    explicit vector(const allocator_type&);
+    explicit vector(size_type n);
+    explicit vector(size_type n, const allocator_type&); // C++14
+    vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
+    template <class InputIterator>
+        vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
+    vector(const vector& x);
+    vector(vector&& x)
+        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+    vector(initializer_list<value_type> il);
+    vector(initializer_list<value_type> il, const allocator_type& a);
+    ~vector();
+    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);
+    vector& operator=(initializer_list<value_type> il);
+    template <class InputIterator>
+        void assign(InputIterator first, InputIterator last);
+    void assign(size_type n, const value_type& u);
+    void assign(initializer_list<value_type> il);
+
+    allocator_type get_allocator() const noexcept;
+
+    iterator               begin() noexcept;
+    const_iterator         begin()   const noexcept;
+    iterator               end() noexcept;
+    const_iterator         end()     const noexcept;
+
+    reverse_iterator       rbegin() noexcept;
+    const_reverse_iterator rbegin()  const noexcept;
+    reverse_iterator       rend() noexcept;
+    const_reverse_iterator rend()    const noexcept;
+
+    const_iterator         cbegin()  const noexcept;
+    const_iterator         cend()    const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend()   const noexcept;
+
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+    size_type capacity() const noexcept;
+    bool empty() const noexcept;
+    void reserve(size_type n);
+    void shrink_to_fit() noexcept;
+
+    reference       operator[](size_type n);
+    const_reference operator[](size_type n) const;
+    reference       at(size_type n);
+    const_reference at(size_type n) const;
+
+    reference       front();
+    const_reference front() const;
+    reference       back();
+    const_reference back() const;
+
+    value_type*       data() noexcept;
+    const value_type* data() const noexcept;
+
+    void push_back(const value_type& x);
+    void push_back(value_type&& x);
+    template <class... Args>
+        void emplace_back(Args&&... args);
+    void pop_back();
+
+    template <class... Args> iterator emplace(const_iterator position, Args&&... args);
+    iterator insert(const_iterator position, const value_type& x);
+    iterator insert(const_iterator position, value_type&& x);
+    iterator insert(const_iterator position, size_type n, const value_type& x);
+    template <class InputIterator>
+        iterator insert(const_iterator position, InputIterator first, InputIterator last);
+    iterator insert(const_iterator position, initializer_list<value_type> il);
+
+    iterator erase(const_iterator position);
+    iterator erase(const_iterator first, const_iterator last);
+
+    void clear() noexcept;
+
+    void resize(size_type sz);
+    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);
+
+    bool __invariants() const;
+};
+
+template <class Allocator = allocator<T> >
+class vector<bool, Allocator>
+{
+public:
+    typedef bool                                     value_type;
+    typedef Allocator                                allocator_type;
+    typedef implementation-defined                   iterator;
+    typedef implementation-defined                   const_iterator;
+    typedef typename allocator_type::size_type       size_type;
+    typedef typename allocator_type::difference_type difference_type;
+    typedef iterator                                 pointer;
+    typedef const_iterator                           const_pointer;
+    typedef std::reverse_iterator<iterator>          reverse_iterator;
+    typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+
+    class reference
+    {
+    public:
+        reference(const reference&) noexcept;
+        operator bool() const noexcept;
+        reference& operator=(const bool x) noexcept;
+        reference& operator=(const reference& x) noexcept;
+        iterator operator&() const noexcept;
+        void flip() noexcept;
+    };
+
+    class const_reference
+    {
+    public:
+        const_reference(const reference&) noexcept;
+        operator bool() const noexcept;
+        const_iterator operator&() const noexcept;
+    };
+
+    vector()
+        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+    explicit vector(const allocator_type&);
+    explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14
+    vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
+    template <class InputIterator>
+        vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
+    vector(const vector& x);
+    vector(vector&& x)
+        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+    vector(initializer_list<value_type> il);
+    vector(initializer_list<value_type> il, const allocator_type& a);
+    ~vector();
+    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);
+    vector& operator=(initializer_list<value_type> il);
+    template <class InputIterator>
+        void assign(InputIterator first, InputIterator last);
+    void assign(size_type n, const value_type& u);
+    void assign(initializer_list<value_type> il);
+
+    allocator_type get_allocator() const noexcept;
+
+    iterator               begin() noexcept;
+    const_iterator         begin()   const noexcept;
+    iterator               end() noexcept;
+    const_iterator         end()     const noexcept;
+
+    reverse_iterator       rbegin() noexcept;
+    const_reverse_iterator rbegin()  const noexcept;
+    reverse_iterator       rend() noexcept;
+    const_reverse_iterator rend()    const noexcept;
+
+    const_iterator         cbegin()  const noexcept;
+    const_iterator         cend()    const noexcept;
+    const_reverse_iterator crbegin() const noexcept;
+    const_reverse_iterator crend()   const noexcept;
+
+    size_type size() const noexcept;
+    size_type max_size() const noexcept;
+    size_type capacity() const noexcept;
+    bool empty() const noexcept;
+    void reserve(size_type n);
+    void shrink_to_fit() noexcept;
+
+    reference       operator[](size_type n);
+    const_reference operator[](size_type n) const;
+    reference       at(size_type n);
+    const_reference at(size_type n) const;
+
+    reference       front();
+    const_reference front() const;
+    reference       back();
+    const_reference back() const;
+
+    void push_back(const value_type& x);
+    template <class... Args> void emplace_back(Args&&... args);  // C++14
+    void pop_back();
+
+    template <class... Args> iterator emplace(const_iterator position, Args&&... args);  // C++14
+    iterator insert(const_iterator position, const value_type& x);
+    iterator insert(const_iterator position, size_type n, const value_type& x);
+    template <class InputIterator>
+        iterator insert(const_iterator position, InputIterator first, InputIterator last);
+    iterator insert(const_iterator position, initializer_list<value_type> il);
+
+    iterator erase(const_iterator position);
+    iterator erase(const_iterator first, const_iterator last);
+
+    void clear() noexcept;
+
+    void resize(size_type sz);
+    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);
+    void flip() noexcept;
+
+    bool __invariants() const;
+};
+
+template <class Allocator> struct hash<std::vector<bool, Allocator>>;
+
+template <class T, class Allocator> bool operator==(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator< (const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator!=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator> (const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator>=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+template <class T, class Allocator> bool operator<=(const vector<T,Allocator>& x, const vector<T,Allocator>& y);
+
+template <class T, class Allocator>
+void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
+    noexcept(noexcept(x.swap(y)));
+
+}  // std
+
+*/
+
+#include <__config>
+#include <__bit_reference>
+#include <type_traits>
+#include <climits>
+#include <limits>
+#include <initializer_list>
+#include <memory>
+#include <stdexcept>
+#include <algorithm>
+#include <cstring>
+#include <__split_buffer>
+#include <__functional_base>
+
+#include <__undef_min_max>
+
+#ifdef _LIBCPP_DEBUG
+#   include <__debug>
+#else
+#   define _LIBCPP_ASSERT(x, m) ((void)0)
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <bool>
+class __vector_base_common
+{
+protected:
+    _LIBCPP_ALWAYS_INLINE __vector_base_common() {}
+    void __throw_length_error() const;
+    void __throw_out_of_range() const;
+};
+
+template <bool __b>
+void
+__vector_base_common<__b>::__throw_length_error() const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw length_error("vector");
+#else
+    assert(!"vector length_error");
+#endif
+}
+
+template <bool __b>
+void
+__vector_base_common<__b>::__throw_out_of_range() const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw out_of_range("vector");
+#else
+    assert(!"vector out_of_range");
+#endif
+}
+
+#ifdef _LIBCPP_MSVC
+#pragma warning( push )
+#pragma warning( disable: 4231 )
+#endif // _LIBCPP_MSVC
+_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __vector_base_common<true>)
+#ifdef _LIBCPP_MSVC
+#pragma warning( pop )
+#endif // _LIBCPP_MSVC
+
+template <class _Tp, class _Allocator>
+class __vector_base
+    : protected __vector_base_common<true>
+{
+protected:
+    typedef _Tp                                      value_type;
+    typedef _Allocator                               allocator_type;
+    typedef allocator_traits<allocator_type>         __alloc_traits;
+    typedef value_type&                              reference;
+    typedef const value_type&                        const_reference;
+    typedef typename __alloc_traits::size_type       size_type;
+    typedef typename __alloc_traits::difference_type difference_type;
+    typedef typename __alloc_traits::pointer         pointer;
+    typedef typename __alloc_traits::const_pointer   const_pointer;
+    typedef pointer                                  iterator;
+    typedef const_pointer                            const_iterator;
+
+    pointer                                         __begin_;
+    pointer                                         __end_;
+    __compressed_pair<pointer, allocator_type> __end_cap_;
+
+    _LIBCPP_INLINE_VISIBILITY
+    allocator_type& __alloc() _NOEXCEPT
+        {return __end_cap_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const allocator_type& __alloc() const _NOEXCEPT
+        {return __end_cap_.second();}
+    _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
+    __vector_base()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+    _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a);
+    ~__vector_base();
+
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__destruct_at_end(__begin_);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type capacity() const _NOEXCEPT
+        {return static_cast<size_type>(__end_cap() - __begin_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __destruct_at_end(pointer __new_last) _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __vector_base& __c)
+        {__copy_assign_alloc(__c, integral_constant<bool,
+                      __alloc_traits::propagate_on_container_copy_assignment::value>());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__vector_base& __c)
+        _NOEXCEPT_(
+            !__alloc_traits::propagate_on_container_move_assignment::value ||
+            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)
+        {
+            if (__alloc() != __c.__alloc())
+            {
+                clear();
+                __alloc_traits::deallocate(__alloc(), __begin_, capacity());
+                __begin_ = __end_ = __end_cap() = nullptr;
+            }
+            __alloc() = __c.__alloc();
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const __vector_base&, false_type)
+        {}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(__vector_base& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+        {
+            __alloc() = _VSTD::move(__c.__alloc());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    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>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
+{
+    while (__new_last != __end_)
+        __alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+__vector_base<_Tp, _Allocator>::__vector_base()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+    : __begin_(nullptr),
+      __end_(nullptr),
+      __end_cap_(nullptr)
+{
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+__vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a)
+    : __begin_(nullptr),
+      __end_(nullptr),
+      __end_cap_(nullptr, __a)
+{
+}
+
+template <class _Tp, class _Allocator>
+__vector_base<_Tp, _Allocator>::~__vector_base()
+{
+    if (__begin_ != nullptr)
+    {
+        clear();
+        __alloc_traits::deallocate(__alloc(), __begin_, capacity());
+    }
+}
+
+template <class _Tp, class _Allocator = allocator<_Tp> >
+class _LIBCPP_TYPE_VIS_ONLY vector
+    : private __vector_base<_Tp, _Allocator>
+{
+private:
+    typedef __vector_base<_Tp, _Allocator>           __base;
+    typedef allocator<_Tp>                           __default_allocator_type;
+public:
+    typedef vector                                   __self;
+    typedef _Tp                                      value_type;
+    typedef _Allocator                               allocator_type;
+    typedef typename __base::__alloc_traits          __alloc_traits;
+    typedef typename __base::reference               reference;
+    typedef typename __base::const_reference         const_reference;
+    typedef typename __base::size_type               size_type;
+    typedef typename __base::difference_type         difference_type;
+    typedef typename __base::pointer                 pointer;
+    typedef typename __base::const_pointer           const_pointer;
+    typedef __wrap_iter<pointer>                     iterator;
+    typedef __wrap_iter<const_pointer>               const_iterator;
+    typedef _VSTD::reverse_iterator<iterator>         reverse_iterator;
+    typedef _VSTD::reverse_iterator<const_iterator>   const_reverse_iterator;
+
+    static_assert((is_same<typename allocator_type::value_type, value_type>::value),
+                  "Allocator::value_type must be same type as value_type");
+
+    _LIBCPP_INLINE_VISIBILITY
+    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)
+        : __base(__a)
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->__insert_c(this);
+#endif
+    }
+    explicit vector(size_type __n);
+#if _LIBCPP_STD_VER > 11
+    explicit vector(size_type __n, const allocator_type& __a);
+#endif
+    vector(size_type __n, const_reference __x);
+    vector(size_type __n, const_reference __x, const allocator_type& __a);
+    template <class _InputIterator>
+        vector(_InputIterator __first,
+               typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                                 !__is_forward_iterator<_InputIterator>::value &&
+                                 is_constructible<
+                                    value_type,
+                                    typename iterator_traits<_InputIterator>::reference>::value,
+                                 _InputIterator>::type __last);
+    template <class _InputIterator>
+        vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+               typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                                 !__is_forward_iterator<_InputIterator>::value &&
+                                 is_constructible<
+                                    value_type,
+                                    typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
+    template <class _ForwardIterator>
+        vector(_ForwardIterator __first,
+               typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+                                 is_constructible<
+                                    value_type,
+                                    typename iterator_traits<_ForwardIterator>::reference>::value,
+                                 _ForwardIterator>::type __last);
+    template <class _ForwardIterator>
+        vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+               typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+                                 is_constructible<
+                                    value_type,
+                                    typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    vector(initializer_list<value_type> __il);
+    _LIBCPP_INLINE_VISIBILITY
+    vector(initializer_list<value_type> __il, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_INLINE_VISIBILITY
+    ~vector()
+    {
+        __get_db()->__erase_c(this);
+    }
+#endif
+
+    vector(const vector& __x);
+    vector(const vector& __x, const allocator_type& __a);
+    _LIBCPP_INLINE_VISIBILITY
+    vector& operator=(const vector& __x);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    vector(vector&& __x)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+    _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);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    vector& operator=(initializer_list<value_type> __il)
+        {assign(__il.begin(), __il.end()); return *this;}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template <class _InputIterator>
+        typename enable_if
+        <
+             __is_input_iterator  <_InputIterator>::value &&
+            !__is_forward_iterator<_InputIterator>::value &&
+            is_constructible<
+                 value_type,
+                 typename iterator_traits<_InputIterator>::reference>::value,
+            void
+        >::type
+        assign(_InputIterator __first, _InputIterator __last);
+    template <class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value &&
+            is_constructible<
+                 value_type,
+                 typename iterator_traits<_ForwardIterator>::reference>::value,
+            void
+        >::type
+        assign(_ForwardIterator __first, _ForwardIterator __last);
+
+    void assign(size_type __n, const_reference __u);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    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
+        {return this->__alloc();}
+
+    _LIBCPP_INLINE_VISIBILITY iterator               begin() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY const_iterator         begin()   const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY iterator               end() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY const_iterator         end()     const _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator       rbegin() _NOEXCEPT
+        {return       reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin()  const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator       rend() _NOEXCEPT
+        {return       reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend()    const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator         cbegin()  const _NOEXCEPT
+        {return begin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator         cend()    const _NOEXCEPT
+        {return end();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT
+        {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend()   const _NOEXCEPT
+        {return rend();}
+
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT
+        {return static_cast<size_type>(this->__end_ - this->__begin_);}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type capacity() const _NOEXCEPT
+        {return __base::capacity();}
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT
+        {return this->__begin_ == this->__end_;}
+    size_type max_size() const _NOEXCEPT;
+    void reserve(size_type __n);
+    void shrink_to_fit() _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __n);
+    _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const;
+    reference       at(size_type __n);
+    const_reference at(size_type __n) const;
+
+    _LIBCPP_INLINE_VISIBILITY reference       front()
+    {
+        _LIBCPP_ASSERT(!empty(), "front() called for empty vector");
+        return *this->__begin_;
+    }
+    _LIBCPP_INLINE_VISIBILITY const_reference front() const
+    {
+        _LIBCPP_ASSERT(!empty(), "front() called for empty vector");
+        return *this->__begin_;
+    }
+    _LIBCPP_INLINE_VISIBILITY reference       back()
+    {
+        _LIBCPP_ASSERT(!empty(), "back() called for empty vector");
+        return *(this->__end_ - 1);
+    }
+    _LIBCPP_INLINE_VISIBILITY const_reference back()  const
+    {
+        _LIBCPP_ASSERT(!empty(), "back() called for empty vector");
+        return *(this->__end_ - 1);
+    }
+
+    _LIBCPP_INLINE_VISIBILITY
+    value_type*       data() _NOEXCEPT
+        {return _VSTD::__to_raw_pointer(this->__begin_);}
+    _LIBCPP_INLINE_VISIBILITY
+    const value_type* data() const _NOEXCEPT
+        {return _VSTD::__to_raw_pointer(this->__begin_);}
+
+    _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args>
+        void emplace_back(_Args&&... __args);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void pop_back();
+
+    iterator insert(const_iterator __position, const_reference __x);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    iterator insert(const_iterator __position, value_type&& __x);
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... _Args>
+        iterator emplace(const_iterator __position, _Args&&... __args);
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    iterator insert(const_iterator __position, size_type __n, const_reference __x);
+    template <class _InputIterator>
+        typename enable_if
+        <
+             __is_input_iterator  <_InputIterator>::value &&
+            !__is_forward_iterator<_InputIterator>::value &&
+            is_constructible<
+                 value_type,
+                 typename iterator_traits<_InputIterator>::reference>::value,
+            iterator
+        >::type
+        insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+    template <class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value &&
+            is_constructible<
+                 value_type,
+                 typename iterator_traits<_ForwardIterator>::reference>::value,
+            iterator
+        >::type
+        insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __position, initializer_list<value_type> __il)
+        {return insert(__position, __il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
+    iterator erase(const_iterator __first, const_iterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT
+    {
+        size_type __old_size = size();
+        __base::clear();
+        __annotate_shrink(__old_size);
+        __invalidate_all_iterators();
+    }
+
+    void resize(size_type __sz);
+    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);
+
+    bool __invariants() const;
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+    bool __dereferenceable(const const_iterator* __i) const;
+    bool __decrementable(const const_iterator* __i) const;
+    bool __addable(const const_iterator* __i, ptrdiff_t __n) const;
+    bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const;
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+private:
+    _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
+    void allocate(size_type __n);
+    void deallocate() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
+    void __construct_at_end(size_type __n);
+    void __construct_at_end(size_type __n, const_reference __x);
+    template <class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            void
+        >::type
+        __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+    void __move_construct_at_end(pointer __first, pointer __last);
+    void __append(size_type __n);
+    void __append(size_type __n, const_reference __x);
+    _LIBCPP_INLINE_VISIBILITY
+    iterator       __make_iter(pointer __p) _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
+    void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
+    pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
+    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);
+    _LIBCPP_INLINE_VISIBILITY
+    void __destruct_at_end(pointer __new_last) _NOEXCEPT
+    {
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __c_node* __c = __get_db()->__find_c_and_lock(this);
+        for (__i_node** __p = __c->end_; __p != __c->beg_; )
+        {
+            --__p;
+            const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
+            if (__i->base() > __new_last)
+            {
+                (*__p)->__c_ = nullptr;
+                if (--__c->end_ != __p)
+                    memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
+            }
+        }
+        __get_db()->unlock();
+#endif
+        size_type __old_size = size();
+        __base::__destruct_at_end(__new_last);
+        __annotate_shrink(__old_size);
+    }
+    template <class _Up>
+        void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        __push_back_slow_path(_Up&& __x);
+#else
+        __push_back_slow_path(_Up& __x);
+#endif
+#if !defined(_LIBCPP_HAS_NO_VARIADICS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+    template <class... _Args>
+        void
+        __emplace_back_slow_path(_Args&&... __args);
+#endif
+    // The following functions are no-ops outside of AddressSanitizer mode.
+    // We call annotatations only for the default Allocator because other allocators
+    // may not meet the AddressSanitizer alignment constraints.
+    // See the documentation for __sanitizer_annotate_contiguous_container for more details.
+    void __annotate_contiguous_container
+    (const void *__beg, const void *__end, const void *__old_mid, const void *__new_mid)
+    {
+#ifndef _LIBCPP_HAS_NO_ASAN
+      if (__beg && is_same<allocator_type, __default_allocator_type>::value)
+        __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
+#endif
+    }
+
+    void __annotate_new(size_type __current_size)
+    {
+      __annotate_contiguous_container(data(), data() + capacity(),
+                                      data() + capacity(), data() + __current_size);
+    }
+    void __annotate_delete()
+    {
+      __annotate_contiguous_container(data(), data() + capacity(),
+                                      data() + size(), data() + capacity());
+    }
+    void __annotate_increase(size_type __n)
+    {
+      __annotate_contiguous_container(data(), data() + capacity(),
+                                      data() + size(), data() + size() + __n);
+    }
+    void __annotate_shrink(size_type __old_size)
+    {
+      __annotate_contiguous_container(data(), data() + capacity(),
+                                      data() + __old_size, data() + size());
+    }
+};
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
+{
+    __annotate_delete();
+    __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
+    _VSTD::swap(this->__begin_, __v.__begin_);
+    _VSTD::swap(this->__end_, __v.__end_);
+    _VSTD::swap(this->__end_cap(), __v.__end_cap());
+    __v.__first_ = __v.__begin_;
+    __annotate_new(size());
+    __invalidate_all_iterators();
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::pointer
+vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
+{
+    __annotate_delete();
+    pointer __r = __v.__begin_;
+    __alloc_traits::__construct_backward(this->__alloc(), this->__begin_, __p, __v.__begin_);
+    __alloc_traits::__construct_forward(this->__alloc(), __p, this->__end_, __v.__end_);
+    _VSTD::swap(this->__begin_, __v.__begin_);
+    _VSTD::swap(this->__end_, __v.__end_);
+    _VSTD::swap(this->__end_cap(), __v.__end_cap());
+    __v.__first_ = __v.__begin_;
+    __annotate_new(size());
+    __invalidate_all_iterators();
+    return __r;
+}
+
+//  Allocate space for __n objects
+//  throws length_error if __n > max_size()
+//  throws (probably bad_alloc) if memory run out
+//  Precondition:  __begin_ == __end_ == __end_cap() == 0
+//  Precondition:  __n > 0
+//  Postcondition:  capacity() == __n
+//  Postcondition:  size() == 0
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::allocate(size_type __n)
+{
+    if (__n > max_size())
+        this->__throw_length_error();
+    this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n);
+    this->__end_cap() = this->__begin_ + __n;
+    __annotate_new(0);
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::deallocate() _NOEXCEPT
+{
+    if (this->__begin_ != nullptr)
+    {
+        clear();
+        __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity());
+        this->__begin_ = this->__end_ = this->__end_cap() = nullptr;
+    }
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::size_type
+vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
+{
+    return _VSTD::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<size_type>::max() / 2);  // end() >= begin(), always
+}
+
+//  Precondition:  __new_size > capacity()
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::size_type
+vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
+{
+    const size_type __ms = max_size();
+    if (__new_size > __ms)
+        this->__throw_length_error();
+    const size_type __cap = capacity();
+    if (__cap >= __ms / 2)
+        return __ms;
+    return _VSTD::max<size_type>(2*__cap, __new_size);
+}
+
+//  Default constructs __n objects starting at __end_
+//  throws if construction throws
+//  Precondition:  __n > 0
+//  Precondition:  size() + __n <= capacity()
+//  Postcondition:  size() == size() + __n
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
+{
+    allocator_type& __a = this->__alloc();
+    __annotate_increase(__n);
+    do
+    {
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_));
+        ++this->__end_;
+        --__n;
+    } while (__n > 0);
+}
+
+//  Copy constructs __n objects starting at __end_ from __x
+//  throws if construction throws
+//  Precondition:  __n > 0
+//  Precondition:  size() + __n <= capacity()
+//  Postcondition:  size() == old size() + __n
+//  Postcondition:  [i] == __x for all i in [size() - __n, __n)
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
+{
+    allocator_type& __a = this->__alloc();
+    __annotate_increase(__n);
+    do
+    {
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x);
+        ++this->__end_;
+        --__n;
+    } while (__n > 0);
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    void
+>::type
+vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+{
+    allocator_type& __a = this->__alloc();
+    for (; __first != __last; ++__first)
+    {
+        __annotate_increase(1);
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
+        ++this->__end_;
+    }
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__move_construct_at_end(pointer __first, pointer __last)
+{
+    allocator_type& __a = this->__alloc();
+    for (; __first != __last; ++__first)
+    {
+        __annotate_increase(1);
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_),
+                                  _VSTD::move(*__first));
+        ++this->__end_;
+    }
+}
+
+//  Default constructs __n objects starting at __end_
+//  throws if construction throws
+//  Postcondition:  size() == size() + __n
+//  Exception safety: strong.
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__append(size_type __n)
+{
+    if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
+        this->__construct_at_end(__n);
+    else
+    {
+        allocator_type& __a = this->__alloc();
+        __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
+        __v.__construct_at_end(__n);
+        __swap_out_circular_buffer(__v);
+    }
+}
+
+//  Default constructs __n objects starting at __end_
+//  throws if construction throws
+//  Postcondition:  size() == size() + __n
+//  Exception safety: strong.
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
+{
+    if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n)
+        this->__construct_at_end(__n, __x);
+    else
+    {
+        allocator_type& __a = this->__alloc();
+        __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a);
+        __v.__construct_at_end(__n, __x);
+        __swap_out_circular_buffer(__v);
+    }
+}
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(size_type __n)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n);
+    }
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
+    : __base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n);
+    }
+}
+#endif
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n, __x);
+    }
+}
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const allocator_type& __a)
+    : __base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n, __x);
+    }
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+vector<_Tp, _Allocator>::vector(_InputIterator __first,
+       typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                         !__is_forward_iterator<_InputIterator>::value &&
+                         is_constructible<
+                            value_type,
+                            typename iterator_traits<_InputIterator>::reference>::value,
+                          _InputIterator>::type __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __first != __last; ++__first)
+        push_back(*__first);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+       typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                         !__is_forward_iterator<_InputIterator>::value &&
+                         is_constructible<
+                            value_type,
+                            typename iterator_traits<_InputIterator>::reference>::value>::type*)
+    : __base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    for (; __first != __last; ++__first)
+        push_back(*__first);
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
+                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+                                is_constructible<
+                                   value_type,
+                                   typename iterator_traits<_ForwardIterator>::reference>::value,
+                                                   _ForwardIterator>::type __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__first, __last);
+    }
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value &&
+                                is_constructible<
+                                   value_type,
+                                   typename iterator_traits<_ForwardIterator>::reference>::value>::type*)
+    : __base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__first, __last);
+    }
+}
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(const vector& __x)
+    : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc()))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    size_type __n = __x.size();
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__x.__begin_, __x.__end_);
+    }
+}
+
+template <class _Tp, class _Allocator>
+vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
+    : __base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    size_type __n = __x.size();
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__x.__begin_, __x.__end_);
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(vector&& __x)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+    : __base(_VSTD::move(__x.__alloc()))
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+    __get_db()->swap(this, &__x);
+#endif
+    this->__begin_ = __x.__begin_;
+    this->__end_ = __x.__end_;
+    this->__end_cap() = __x.__end_cap();
+    __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a)
+    : __base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__a == __x.__alloc())
+    {
+        this->__begin_ = __x.__begin_;
+        this->__end_ = __x.__end_;
+        this->__end_cap() = __x.__end_cap();
+        __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+        __get_db()->swap(this, &__x);
+#endif
+    }
+    else
+    {
+        typedef move_iterator<iterator> _Ip;
+        assign(_Ip(__x.begin()), _Ip(__x.end()));
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__il.size() > 0)
+    {
+        allocate(__il.size());
+        __construct_at_end(__il.begin(), __il.end());
+    }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
+    : __base(__a)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__insert_c(this);
+#endif
+    if (__il.size() > 0)
+    {
+        allocate(__il.size());
+        __construct_at_end(__il.begin(), __il.end());
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+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)
+{
+    __move_assign(__x, integral_constant<bool,
+          __alloc_traits::propagate_on_container_move_assignment::value>());
+    return *this;
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
+{
+    if (__base::__alloc() != __c.__alloc())
+    {
+        typedef move_iterator<iterator> _Ip;
+        assign(_Ip(__c.begin()), _Ip(__c.end()));
+    }
+    else
+        __move_assign(__c, true_type());
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
+    _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+    deallocate();
+    __base::__move_assign_alloc(__c); // this can throw
+    this->__begin_ = __c.__begin_;
+    this->__end_ = __c.__end_;
+    this->__end_cap() = __c.__end_cap();
+    __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->swap(this, &__c);
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<_Tp, _Allocator>&
+vector<_Tp, _Allocator>::operator=(const vector& __x)
+{
+    if (this != &__x)
+    {
+        __base::__copy_assign_alloc(__x);
+        assign(__x.__begin_, __x.__end_);
+    }
+    return *this;
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+     __is_input_iterator  <_InputIterator>::value &&
+    !__is_forward_iterator<_InputIterator>::value &&
+    is_constructible<
+       _Tp,
+       typename iterator_traits<_InputIterator>::reference>::value,
+    void
+>::type
+vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
+{
+    clear();
+    for (; __first != __last; ++__first)
+        push_back(*__first);
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value &&
+    is_constructible<
+       _Tp,
+       typename iterator_traits<_ForwardIterator>::reference>::value,
+    void
+>::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())
+    {
+        _ForwardIterator __mid = __last;
+        bool __growing = false;
+        if (static_cast<size_type>(__new_size) > size())
+        {
+            __growing = true;
+            __mid =  __first;
+            _VSTD::advance(__mid, size());
+        }
+        pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
+        if (__growing)
+            __construct_at_end(__mid, __last);
+        else
+            this->__destruct_at_end(__m);
+    }
+    else
+    {
+        deallocate();
+        allocate(__recommend(static_cast<size_type>(__new_size)));
+        __construct_at_end(__first, __last);
+    }
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
+{
+    if (__n <= capacity())
+    {
+        size_type __s = size();
+        _VSTD::fill_n(this->__begin_, _VSTD::min(__n, __s), __u);
+        if (__n > __s)
+            __construct_at_end(__n - __s, __u);
+        else
+            this->__destruct_at_end(this->__begin_ + __n);
+    }
+    else
+    {
+        deallocate();
+        allocate(__recommend(static_cast<size_type>(__n)));
+        __construct_at_end(__n, __u);
+    }
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return iterator(this, __p);
+#else
+    return iterator(__p);
+#endif
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_iterator
+vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    return const_iterator(this, __p);
+#else
+    return const_iterator(__p);
+#endif
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::begin() _NOEXCEPT
+{
+    return __make_iter(this->__begin_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_iterator
+vector<_Tp, _Allocator>::begin() const _NOEXCEPT
+{
+    return __make_iter(this->__begin_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::end() _NOEXCEPT
+{
+    return __make_iter(this->__end_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_iterator
+vector<_Tp, _Allocator>::end() const _NOEXCEPT
+{
+    return __make_iter(this->__end_);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::reference
+vector<_Tp, _Allocator>::operator[](size_type __n)
+{
+    _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
+    return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::const_reference
+vector<_Tp, _Allocator>::operator[](size_type __n) const
+{
+    _LIBCPP_ASSERT(__n < size(), "vector[] index out of bounds");
+    return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::reference
+vector<_Tp, _Allocator>::at(size_type __n)
+{
+    if (__n >= size())
+        this->__throw_out_of_range();
+    return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::const_reference
+vector<_Tp, _Allocator>::at(size_type __n) const
+{
+    if (__n >= size())
+        this->__throw_out_of_range();
+    return this->__begin_[__n];
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::reserve(size_type __n)
+{
+    if (__n > capacity())
+    {
+        allocator_type& __a = this->__alloc();
+        __split_buffer<value_type, allocator_type&> __v(__n, size(), __a);
+        __swap_out_circular_buffer(__v);
+    }
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+    if (capacity() > size())
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            allocator_type& __a = this->__alloc();
+            __split_buffer<value_type, allocator_type&> __v(size(), size(), __a);
+            __swap_out_circular_buffer(__v);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Tp, class _Allocator>
+template <class _Up>
+void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
+#else
+vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
+#endif
+{
+    allocator_type& __a = this->__alloc();
+    __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
+    // __v.push_back(_VSTD::forward<_Up>(__x));
+    __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Up>(__x));
+    __v.__end_++;
+    __swap_out_circular_buffer(__v);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::push_back(const_reference __x)
+{
+    if (this->__end_ != this->__end_cap())
+    {
+        __annotate_increase(1);
+        __alloc_traits::construct(this->__alloc(),
+                                  _VSTD::__to_raw_pointer(this->__end_), __x);
+        ++this->__end_;
+    }
+    else
+        __push_back_slow_path(__x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::push_back(value_type&& __x)
+{
+    if (this->__end_ < this->__end_cap())
+    {
+        __annotate_increase(1);
+        __alloc_traits::construct(this->__alloc(),
+                                  _VSTD::__to_raw_pointer(this->__end_),
+                                  _VSTD::move(__x));
+        ++this->__end_;
+    }
+    else
+        __push_back_slow_path(_VSTD::move(__x));
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+void
+vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
+{
+    allocator_type& __a = this->__alloc();
+    __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
+//    __v.emplace_back(_VSTD::forward<_Args>(__args)...);
+    __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(__v.__end_), _VSTD::forward<_Args>(__args)...);
+    __v.__end_++;
+    __swap_out_circular_buffer(__v);
+}
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
+{
+    if (this->__end_ < this->__end_cap())
+    {
+        __annotate_increase(1);
+        __alloc_traits::construct(this->__alloc(),
+                                  _VSTD::__to_raw_pointer(this->__end_),
+                                  _VSTD::forward<_Args>(__args)...);
+        ++this->__end_;
+    }
+    else
+        __emplace_back_slow_path(_VSTD::forward<_Args>(__args)...);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::pop_back()
+{
+    _LIBCPP_ASSERT(!empty(), "vector::pop_back called for empty vector");
+    this->__destruct_at_end(this->__end_ - 1);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::erase(const_iterator __position)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+        "vector::erase(iterator) called with an iterator not"
+        " referring to this vector");
+#endif
+    _LIBCPP_ASSERT(__position != end(),
+        "vector::erase(iterator) called with a non-dereferenceable iterator");
+    difference_type __ps = __position - cbegin();
+    pointer __p = this->__begin_ + __ps;
+    iterator __r = __make_iter(__p);
+    this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
+    return __r;
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
+        "vector::erase(iterator,  iterator) called with an iterator not"
+        " referring to this vector");
+#endif
+    _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
+    pointer __p = this->__begin_ + (__first - begin());
+    iterator __r = __make_iter(__p);
+    if (__first != __last)
+        this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
+    return __r;
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
+{
+    pointer __old_last = this->__end_;
+    difference_type __n = __old_last - __to;
+    for (pointer __i = __from_s + __n; __i < __from_e; ++__i, ++this->__end_)
+        __alloc_traits::construct(this->__alloc(),
+                                  _VSTD::__to_raw_pointer(this->__end_),
+                                  _VSTD::move(*__i));
+    _VSTD::move_backward(__from_s, __from_s + __n, __old_last);
+}
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+        "vector::insert(iterator, x) called with an iterator not"
+        " referring to this vector");
+#endif
+    pointer __p = this->__begin_ + (__position - begin());
+    if (this->__end_ < this->__end_cap())
+    {
+        __annotate_increase(1);
+        if (__p == this->__end_)
+        {
+            __alloc_traits::construct(this->__alloc(),
+                                      _VSTD::__to_raw_pointer(this->__end_), __x);
+            ++this->__end_;
+        }
+        else
+        {
+            __move_range(__p, this->__end_, __p + 1);
+            const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
+            if (__p <= __xr && __xr < this->__end_)
+                ++__xr;
+            *__p = *__xr;
+        }
+    }
+    else
+    {
+        allocator_type& __a = this->__alloc();
+        __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
+        __v.push_back(__x);
+        __p = __swap_out_circular_buffer(__v, __p);
+    }
+    return __make_iter(__p);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+        "vector::insert(iterator, x) called with an iterator not"
+        " referring to this vector");
+#endif
+    pointer __p = this->__begin_ + (__position - begin());
+    if (this->__end_ < this->__end_cap())
+    {
+        __annotate_increase(1);
+        if (__p == this->__end_)
+        {
+            __alloc_traits::construct(this->__alloc(),
+                                      _VSTD::__to_raw_pointer(this->__end_),
+                                      _VSTD::move(__x));
+            ++this->__end_;
+        }
+        else
+        {
+            __move_range(__p, this->__end_, __p + 1);
+            *__p = _VSTD::move(__x);
+        }
+    }
+    else
+    {
+        allocator_type& __a = this->__alloc();
+        __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
+        __v.push_back(_VSTD::move(__x));
+        __p = __swap_out_circular_buffer(__v, __p);
+    }
+    return __make_iter(__p);
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+template <class _Tp, class _Allocator>
+template <class... _Args>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+        "vector::emplace(iterator, x) called with an iterator not"
+        " referring to this vector");
+#endif
+    pointer __p = this->__begin_ + (__position - begin());
+    if (this->__end_ < this->__end_cap())
+    {
+        __annotate_increase(1);
+        if (__p == this->__end_)
+        {
+            __alloc_traits::construct(this->__alloc(),
+                                      _VSTD::__to_raw_pointer(this->__end_),
+                                      _VSTD::forward<_Args>(__args)...);
+            ++this->__end_;
+        }
+        else
+        {
+            value_type __tmp(_VSTD::forward<_Args>(__args)...);
+            __move_range(__p, this->__end_, __p + 1);
+            *__p = _VSTD::move(__tmp);
+        }
+    }
+    else
+    {
+        allocator_type& __a = this->__alloc();
+        __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a);
+        __v.emplace_back(_VSTD::forward<_Args>(__args)...);
+        __p = __swap_out_circular_buffer(__v, __p);
+    }
+    return __make_iter(__p);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Tp, class _Allocator>
+typename vector<_Tp, _Allocator>::iterator
+vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+        "vector::insert(iterator, n, x) called with an iterator not"
+        " referring to this vector");
+#endif
+    pointer __p = this->__begin_ + (__position - begin());
+    if (__n > 0)
+    {
+        if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))
+        {
+            size_type __old_n = __n;
+            pointer __old_last = this->__end_;
+            if (__n > static_cast<size_type>(this->__end_ - __p))
+            {
+                size_type __cx = __n - (this->__end_ - __p);
+                __construct_at_end(__cx, __x);
+                __n -= __cx;
+            }
+            if (__n > 0)
+            {
+                __annotate_increase(__n);
+                __move_range(__p, __old_last, __p + __old_n);
+                const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
+                if (__p <= __xr && __xr < this->__end_)
+                    __xr += __old_n;
+                _VSTD::fill_n(__p, __n, *__xr);
+            }
+        }
+        else
+        {
+            allocator_type& __a = this->__alloc();
+            __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
+            __v.__construct_at_end(__n, __x);
+            __p = __swap_out_circular_buffer(__v, __p);
+        }
+    }
+    return __make_iter(__p);
+}
+
+template <class _Tp, class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+     __is_input_iterator  <_InputIterator>::value &&
+    !__is_forward_iterator<_InputIterator>::value &&
+    is_constructible<
+       _Tp,
+       typename iterator_traits<_InputIterator>::reference>::value,
+    typename vector<_Tp, _Allocator>::iterator
+>::type
+vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+        "vector::insert(iterator, range) called with an iterator not"
+        " referring to this vector");
+#endif
+    difference_type __off = __position - begin();
+    pointer __p = this->__begin_ + __off;
+    allocator_type& __a = this->__alloc();
+    pointer __old_last = this->__end_;
+    for (; this->__end_ != this->__end_cap() && __first != __last; ++__first)
+    {
+        __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_),
+                                  *__first);
+        ++this->__end_;
+    }
+    __split_buffer<value_type, allocator_type&> __v(__a);
+    if (__first != __last)
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __v.__construct_at_end(__first, __last);
+            difference_type __old_size = __old_last - this->__begin_;
+            difference_type __old_p = __p - this->__begin_;
+            reserve(__recommend(size() + __v.size()));
+            __p = this->__begin_ + __old_p;
+            __old_last = this->__begin_ + __old_size;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            erase(__make_iter(__old_last), end());
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+    __p = _VSTD::rotate(__p, __old_last, this->__end_);
+    insert(__make_iter(__p), make_move_iterator(__v.begin()),
+                                    make_move_iterator(__v.end()));
+    return begin() + __off;
+}
+
+template <class _Tp, class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value &&
+    is_constructible<
+       _Tp,
+       typename iterator_traits<_ForwardIterator>::reference>::value,
+    typename vector<_Tp, _Allocator>::iterator
+>::type
+vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this,
+        "vector::insert(iterator, range) called with an iterator not"
+        " referring to this vector");
+#endif
+    pointer __p = this->__begin_ + (__position - begin());
+    difference_type __n = _VSTD::distance(__first, __last);
+    if (__n > 0)
+    {
+        if (__n <= this->__end_cap() - this->__end_)
+        {
+            size_type __old_n = __n;
+            pointer __old_last = this->__end_;
+            _ForwardIterator __m = __last;
+            difference_type __dx = this->__end_ - __p;
+            if (__n > __dx)
+            {
+                __m = __first;
+                _VSTD::advance(__m, this->__end_ - __p);
+                __construct_at_end(__m, __last);
+                __n = __dx;
+            }
+            if (__n > 0)
+            {
+                __annotate_increase(__n);
+                __move_range(__p, __old_last, __p + __old_n);
+                _VSTD::copy(__first, __m, __p);
+            }
+        }
+        else
+        {
+            allocator_type& __a = this->__alloc();
+            __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a);
+            __v.__construct_at_end(__first, __last);
+            __p = __swap_out_circular_buffer(__v, __p);
+        }
+    }
+    return __make_iter(__p);
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::resize(size_type __sz)
+{
+    size_type __cs = size();
+    if (__cs < __sz)
+        this->__append(__sz - __cs);
+    else if (__cs > __sz)
+        this->__destruct_at_end(this->__begin_ + __sz);
+}
+
+template <class _Tp, class _Allocator>
+void
+vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
+{
+    size_type __cs = size();
+    if (__cs < __sz)
+        this->__append(__sz - __cs, __x);
+    else if (__cs > __sz)
+        this->__destruct_at_end(this->__begin_ + __sz);
+}
+
+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)
+{
+    _LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
+                   this->__alloc() == __x.__alloc(),
+                   "vector::swap: Either propagate_on_container_swap must be true"
+                   " or the allocators must compare equal");
+    _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());
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->swap(this, &__x);
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__invariants() const
+{
+    if (this->__begin_ == nullptr)
+    {
+        if (this->__end_ != nullptr || this->__end_cap() != nullptr)
+            return false;
+    }
+    else
+    {
+        if (this->__begin_ > this->__end_)
+            return false;
+        if (this->__begin_ == this->__end_cap())
+            return false;
+        if (this->__end_ > this->__end_cap())
+            return false;
+    }
+    return true;
+}
+
+#if _LIBCPP_DEBUG_LEVEL >= 2
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__dereferenceable(const const_iterator* __i) const
+{
+    return this->__begin_ <= __i->base() && __i->base() < this->__end_;
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__decrementable(const const_iterator* __i) const
+{
+    return this->__begin_ < __i->base() && __i->base() <= this->__end_;
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const
+{
+    const_pointer __p = __i->base() + __n;
+    return this->__begin_ <= __p && __p <= this->__end_;
+}
+
+template <class _Tp, class _Allocator>
+bool
+vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const
+{
+    const_pointer __p = __i->base() + __n;
+    return this->__begin_ <= __p && __p < this->__end_;
+}
+
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<_Tp, _Allocator>::__invalidate_all_iterators()
+{
+#if _LIBCPP_DEBUG_LEVEL >= 2
+    __get_db()->__invalidate_all(this);
+#endif  // _LIBCPP_DEBUG_LEVEL >= 2
+}
+
+// vector<bool>
+
+template <class _Allocator> class vector<bool, _Allocator>;
+
+template <class _Allocator> struct hash<vector<bool, _Allocator> >;
+
+template <class _Allocator>
+struct __has_storage_type<vector<bool, _Allocator> >
+{
+    static const bool value = true;
+};
+
+template <class _Allocator>
+class _LIBCPP_TYPE_VIS_ONLY vector<bool, _Allocator>
+    : private __vector_base_common<true>
+{
+public:
+    typedef vector                                   __self;
+    typedef bool                                     value_type;
+    typedef _Allocator                               allocator_type;
+    typedef allocator_traits<allocator_type>         __alloc_traits;
+    typedef typename __alloc_traits::size_type       size_type;
+    typedef typename __alloc_traits::difference_type difference_type;
+    typedef size_type __storage_type;
+    typedef __bit_iterator<vector, false>            pointer;
+    typedef __bit_iterator<vector, true>             const_pointer;
+    typedef pointer                                  iterator;
+    typedef const_pointer                            const_iterator;
+    typedef _VSTD::reverse_iterator<iterator>         reverse_iterator;
+    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 allocator_traits<__storage_allocator>    __storage_traits;
+    typedef typename __storage_traits::pointer       __storage_pointer;
+    typedef typename __storage_traits::const_pointer __const_storage_pointer;
+
+    __storage_pointer                                      __begin_;
+    size_type                                              __size_;
+    __compressed_pair<size_type, __storage_allocator> __cap_alloc_;
+public:
+    typedef __bit_reference<vector>                  reference;
+    typedef __bit_const_reference<vector>            const_reference;
+private:
+    _LIBCPP_INLINE_VISIBILITY
+    size_type& __cap() _NOEXCEPT
+        {return __cap_alloc_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+    const size_type& __cap() const _NOEXCEPT
+        {return __cap_alloc_.first();}
+    _LIBCPP_INLINE_VISIBILITY
+    __storage_allocator& __alloc() _NOEXCEPT
+        {return __cap_alloc_.second();}
+    _LIBCPP_INLINE_VISIBILITY
+    const __storage_allocator& __alloc() const _NOEXCEPT
+        {return __cap_alloc_.second();}
+
+    static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
+
+    _LIBCPP_INLINE_VISIBILITY
+    static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
+        {return __n * __bits_per_word;}
+    _LIBCPP_INLINE_VISIBILITY
+    static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
+        {return (__n - 1) / __bits_per_word + 1;}
+
+public:
+    _LIBCPP_INLINE_VISIBILITY
+    vector()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
+    _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a);
+    ~vector();
+    explicit vector(size_type __n);
+#if _LIBCPP_STD_VER > 11
+    explicit vector(size_type __n, const allocator_type& __a);
+#endif
+    vector(size_type __n, const value_type& __v);
+    vector(size_type __n, const value_type& __v, const allocator_type& __a);
+    template <class _InputIterator>
+        vector(_InputIterator __first, _InputIterator __last,
+               typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                                 !__is_forward_iterator<_InputIterator>::value>::type* = 0);
+    template <class _InputIterator>
+        vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+               typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                                 !__is_forward_iterator<_InputIterator>::value>::type* = 0);
+    template <class _ForwardIterator>
+        vector(_ForwardIterator __first, _ForwardIterator __last,
+               typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
+    template <class _ForwardIterator>
+        vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+               typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type* = 0);
+
+    vector(const vector& __v);
+    vector(const vector& __v, const allocator_type& __a);
+    vector& operator=(const vector& __v);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    vector(initializer_list<value_type> __il);
+    vector(initializer_list<value_type> __il, const allocator_type& __a);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    _LIBCPP_INLINE_VISIBILITY
+    vector(vector&& __v)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
+    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);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    vector& operator=(initializer_list<value_type> __il)
+        {assign(__il.begin(), __il.end()); return *this;}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    template <class _InputIterator>
+        typename enable_if
+        <
+            __is_input_iterator<_InputIterator>::value &&
+           !__is_forward_iterator<_InputIterator>::value,
+           void
+        >::type
+        assign(_InputIterator __first, _InputIterator __last);
+    template <class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+           void
+        >::type
+        assign(_ForwardIterator __first, _ForwardIterator __last);
+
+    void assign(size_type __n, const value_type& __x);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    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
+        {return allocator_type(this->__alloc());}
+
+    size_type max_size() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    size_type capacity() const _NOEXCEPT
+        {return __internal_cap_to_external(__cap());}
+    _LIBCPP_INLINE_VISIBILITY
+    size_type size() const _NOEXCEPT
+        {return __size_;}
+    _LIBCPP_INLINE_VISIBILITY
+    bool empty() const _NOEXCEPT
+        {return __size_ == 0;}
+    void reserve(size_type __n);
+    void shrink_to_fit() _NOEXCEPT;
+
+    _LIBCPP_INLINE_VISIBILITY
+    iterator begin() _NOEXCEPT
+        {return __make_iter(0);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator begin() const _NOEXCEPT
+        {return __make_iter(0);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator end() _NOEXCEPT
+        {return __make_iter(__size_);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator end()   const _NOEXCEPT
+        {return __make_iter(__size_);}
+
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rbegin() _NOEXCEPT
+        {return       reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rbegin() const _NOEXCEPT
+        {return const_reverse_iterator(end());}
+    _LIBCPP_INLINE_VISIBILITY
+    reverse_iterator rend() _NOEXCEPT
+        {return       reverse_iterator(begin());}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator rend()   const _NOEXCEPT
+        {return const_reverse_iterator(begin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator         cbegin()  const _NOEXCEPT
+        {return __make_iter(0);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator         cend()    const _NOEXCEPT
+        {return __make_iter(__size_);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crbegin() const _NOEXCEPT
+        {return rbegin();}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reverse_iterator crend()   const _NOEXCEPT
+        {return rend();}
+
+    _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __n)       {return __make_ref(__n);}
+    _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);}
+    reference       at(size_type __n);
+    const_reference at(size_type __n) const;
+
+    _LIBCPP_INLINE_VISIBILITY reference       front()       {return __make_ref(0);}
+    _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);}
+    _LIBCPP_INLINE_VISIBILITY reference       back()        {return __make_ref(__size_ - 1);}
+    _LIBCPP_INLINE_VISIBILITY const_reference back()  const {return __make_ref(__size_ - 1);}
+
+    void push_back(const value_type& __x);
+#if _LIBCPP_STD_VER > 11
+    template <class... _Args>
+    _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args)
+        { push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); }
+#endif
+
+    _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
+
+#if _LIBCPP_STD_VER > 11
+    template <class... _Args>
+   _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args)
+        { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); }
+#endif
+
+    iterator insert(const_iterator __position, const value_type& __x);
+    iterator insert(const_iterator __position, size_type __n, const value_type& __x);
+    iterator insert(const_iterator __position, size_type __n, const_reference __x);
+    template <class _InputIterator>
+        typename enable_if
+        <
+             __is_input_iterator  <_InputIterator>::value &&
+            !__is_forward_iterator<_InputIterator>::value,
+            iterator
+        >::type
+        insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+    template <class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            iterator
+        >::type
+        insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    _LIBCPP_INLINE_VISIBILITY
+    iterator insert(const_iterator __position, initializer_list<value_type> __il)
+        {return insert(__position, __il.begin(), __il.end());}
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+    _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
+    iterator erase(const_iterator __first, const_iterator __last);
+
+    _LIBCPP_INLINE_VISIBILITY
+    void clear() _NOEXCEPT {__size_ = 0;}
+
+    void swap(vector&)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<allocator_type>::value);
+
+    void resize(size_type __sz, value_type __x = false);
+    void flip() _NOEXCEPT;
+
+    bool __invariants() const;
+
+private:
+    _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
+    void allocate(size_type __n);
+    void deallocate() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY
+    static size_type __align_it(size_type __new_size) _NOEXCEPT
+        {return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);};
+    _LIBCPP_INLINE_VISIBILITY  size_type __recommend(size_type __new_size) const;
+    _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
+    template <class _ForwardIterator>
+        typename enable_if
+        <
+            __is_forward_iterator<_ForwardIterator>::value,
+            void
+        >::type
+        __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+    void __append(size_type __n, const_reference __x);
+    _LIBCPP_INLINE_VISIBILITY
+    reference __make_ref(size_type __pos) _NOEXCEPT
+        {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+    _LIBCPP_INLINE_VISIBILITY
+    const_reference __make_ref(size_type __pos) const _NOEXCEPT
+        {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __make_iter(size_type __pos) _NOEXCEPT
+        {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
+    _LIBCPP_INLINE_VISIBILITY
+    const_iterator __make_iter(size_type __pos) const _NOEXCEPT
+        {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
+    _LIBCPP_INLINE_VISIBILITY
+    iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
+        {return begin() + (__p - cbegin());}
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const vector& __v)
+        {__copy_assign_alloc(__v, integral_constant<bool,
+                      __storage_traits::propagate_on_container_copy_assignment::value>());}
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const vector& __c, true_type)
+        {
+            if (__alloc() != __c.__alloc())
+                deallocate();
+            __alloc() = __c.__alloc();
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __copy_assign_alloc(const vector&, false_type)
+        {}
+
+    void __move_assign(vector& __c, false_type);
+    void __move_assign(vector& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(vector& __c)
+        _NOEXCEPT_(
+            !__storage_traits::propagate_on_container_move_assignment::value ||
+            is_nothrow_move_assignable<allocator_type>::value)
+        {__move_assign_alloc(__c, integral_constant<bool,
+                      __storage_traits::propagate_on_container_move_assignment::value>());}
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(vector& __c, true_type)
+        _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+        {
+            __alloc() = _VSTD::move(__c.__alloc());
+        }
+
+    _LIBCPP_INLINE_VISIBILITY
+    void __move_assign_alloc(vector&, false_type)
+        _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>;
+    friend class __bit_const_reference<vector>;
+    friend class __bit_iterator<vector, false>;
+    friend class __bit_iterator<vector, true>;
+    friend struct __bit_array<vector>;
+    friend struct _LIBCPP_TYPE_VIS_ONLY hash<vector>;
+};
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<bool, _Allocator>::__invalidate_all_iterators()
+{
+}
+
+//  Allocate space for __n objects
+//  throws length_error if __n > max_size()
+//  throws (probably bad_alloc) if memory run out
+//  Precondition:  __begin_ == __end_ == __cap() == 0
+//  Precondition:  __n > 0
+//  Postcondition:  capacity() == __n
+//  Postcondition:  size() == 0
+template <class _Allocator>
+void
+vector<bool, _Allocator>::allocate(size_type __n)
+{
+    if (__n > max_size())
+        this->__throw_length_error();
+    __n = __external_cap_to_internal(__n);
+    this->__begin_ = __storage_traits::allocate(this->__alloc(), __n);
+    this->__size_ = 0;
+    this->__cap() = __n;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::deallocate() _NOEXCEPT
+{
+    if (this->__begin_ != nullptr)
+    {
+        __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
+        __invalidate_all_iterators();
+        this->__begin_ = nullptr;
+        this->__size_ = this->__cap() = 0;
+    }
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::size_type
+vector<bool, _Allocator>::max_size() const _NOEXCEPT
+{
+    size_type __amax = __storage_traits::max_size(__alloc());
+    size_type __nmax = numeric_limits<size_type>::max() / 2;  // end() >= begin(), always
+    if (__nmax / __bits_per_word <= __amax)
+        return __nmax;
+    return __internal_cap_to_external(__amax);
+}
+
+//  Precondition:  __new_size > capacity()
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<bool, _Allocator>::size_type
+vector<bool, _Allocator>::__recommend(size_type __new_size) const
+{
+    const size_type __ms = max_size();
+    if (__new_size > __ms)
+        this->__throw_length_error();
+    const size_type __cap = capacity();
+    if (__cap >= __ms / 2)
+        return __ms;
+    return _VSTD::max(2*__cap, __align_it(__new_size));
+}
+
+//  Default constructs __n objects starting at __end_
+//  Precondition:  __n > 0
+//  Precondition:  size() + __n <= capacity()
+//  Postcondition:  size() == size() + __n
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
+{
+    size_type __old_size = this->__size_;
+    this->__size_ += __n;
+    _VSTD::fill_n(__make_iter(__old_size), __n, __x);
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    void
+>::type
+vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
+{
+    size_type __old_size = this->__size_;
+    this->__size_ += _VSTD::distance(__first, __last);
+    _VSTD::copy(__first, __last, __make_iter(__old_size));
+}
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<bool, _Allocator>::vector()
+        _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0)
+{
+}
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<bool, _Allocator>::vector(const allocator_type& __a)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0)
+{
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n, false);
+    }
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n, false);
+    }
+}
+#endif
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0)
+{
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n, __x);
+    }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__n, __x);
+    }
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
+       typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                         !__is_forward_iterator<_InputIterator>::value>::type*)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        for (; __first != __last; ++__first)
+            push_back(*__first);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        if (__begin_ != nullptr)
+            __storage_traits::deallocate(__alloc(), __begin_, __cap());
+        __invalidate_all_iterators();
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+       typename enable_if<__is_input_iterator  <_InputIterator>::value &&
+                         !__is_forward_iterator<_InputIterator>::value>::type*)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        for (; __first != __last; ++__first)
+            push_back(*__first);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        if (__begin_ != nullptr)
+            __storage_traits::deallocate(__alloc(), __begin_, __cap());
+        __invalidate_all_iterators();
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
+                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0)
+{
+    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__first, __last);
+    }
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+                                typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+    size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__first, __last);
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0)
+{
+    size_type __n = static_cast<size_type>(__il.size());
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__il.begin(), __il.end());
+    }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, static_cast<__storage_allocator>(__a))
+{
+    size_type __n = static_cast<size_type>(__il.size());
+    if (__n > 0)
+    {
+        allocate(__n);
+        __construct_at_end(__il.begin(), __il.end());
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+template <class _Allocator>
+vector<bool, _Allocator>::~vector()
+{
+    if (__begin_ != nullptr)
+        __storage_traits::deallocate(__alloc(), __begin_, __cap());
+    __invalidate_all_iterators();
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(const vector& __v)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc()))
+{
+    if (__v.size() > 0)
+    {
+        allocate(__v.size());
+        __construct_at_end(__v.begin(), __v.end());
+    }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, __a)
+{
+    if (__v.size() > 0)
+    {
+        allocate(__v.size());
+        __construct_at_end(__v.begin(), __v.end());
+    }
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>&
+vector<bool, _Allocator>::operator=(const vector& __v)
+{
+    if (this != &__v)
+    {
+        __copy_assign_alloc(__v);
+        if (__v.__size_)
+        {
+            if (__v.__size_ > capacity())
+            {
+                deallocate();
+                allocate(__v.__size_);
+            }
+            _VSTD::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
+        }
+        __size_ = __v.__size_;
+    }
+    return *this;
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+vector<bool, _Allocator>::vector(vector&& __v)
+        _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
+    : __begin_(__v.__begin_),
+      __size_(__v.__size_),
+      __cap_alloc_(__v.__cap_alloc_)
+{
+    __v.__begin_ = nullptr;
+    __v.__size_ = 0;
+    __v.__cap() = 0;
+}
+
+template <class _Allocator>
+vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a)
+    : __begin_(nullptr),
+      __size_(0),
+      __cap_alloc_(0, __a)
+{
+    if (__a == allocator_type(__v.__alloc()))
+    {
+        this->__begin_ = __v.__begin_;
+        this->__size_ = __v.__size_;
+        this->__cap() = __v.__cap();
+        __v.__begin_ = nullptr;
+        __v.__cap() = __v.__size_ = 0;
+    }
+    else if (__v.size() > 0)
+    {
+        allocate(__v.size());
+        __construct_at_end(__v.begin(), __v.end());
+    }
+}
+
+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)
+{
+    __move_assign(__v, integral_constant<bool,
+          __storage_traits::propagate_on_container_move_assignment::value>());
+    return *this;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
+{
+    if (__alloc() != __c.__alloc())
+        assign(__c.begin(), __c.end());
+    else
+        __move_assign(__c, true_type());
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
+    _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
+{
+    deallocate();
+    __move_assign_alloc(__c);
+    this->__begin_ = __c.__begin_;
+    this->__size_ = __c.__size_;
+    this->__cap() = __c.__cap();
+    __c.__begin_ = nullptr;
+    __c.__cap() = __c.__size_ = 0;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
+{
+    __size_ = 0;
+    if (__n > 0)
+    {
+        size_type __c = capacity();
+        if (__n <= __c)
+            __size_ = __n;
+        else
+        {
+            vector __v(__alloc());
+            __v.reserve(__recommend(__n));
+            __v.__size_ = __n;
+            swap(__v);
+        }
+        _VSTD::fill_n(begin(), __n, __x);
+    }
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+    __is_input_iterator<_InputIterator>::value &&
+   !__is_forward_iterator<_InputIterator>::value,
+   void
+>::type
+vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
+{
+    clear();
+    for (; __first != __last; ++__first)
+        push_back(*__first);
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+   void
+>::type
+vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
+{
+    clear();
+    difference_type __n = _VSTD::distance(__first, __last);
+    if (__n)
+    {
+        if (__n > capacity())
+        {
+            deallocate();
+            allocate(__n);
+        }
+        __construct_at_end(__first, __last);
+    }
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::reserve(size_type __n)
+{
+    if (__n > capacity())
+    {
+        vector __v(this->__alloc());
+        __v.allocate(__n);
+        __v.__construct_at_end(this->begin(), this->end());
+        swap(__v);
+        __invalidate_all_iterators();
+    }
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
+{
+    if (__external_cap_to_internal(size()) > __cap())
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            vector(*this, allocator_type(__alloc())).swap(*this);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::reference
+vector<bool, _Allocator>::at(size_type __n)
+{
+    if (__n >= size())
+        this->__throw_out_of_range();
+    return (*this)[__n];
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::const_reference
+vector<bool, _Allocator>::at(size_type __n) const
+{
+    if (__n >= size())
+        this->__throw_out_of_range();
+    return (*this)[__n];
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::push_back(const value_type& __x)
+{
+    if (this->__size_ == this->capacity())
+        reserve(__recommend(this->__size_ + 1));
+    ++this->__size_;
+    back() = __x;
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
+{
+    iterator __r;
+    if (size() < capacity())
+    {
+        const_iterator __old_end = end();
+        ++__size_;
+        _VSTD::copy_backward(__position, __old_end, end());
+        __r = __const_iterator_cast(__position);
+    }
+    else
+    {
+        vector __v(__alloc());
+        __v.reserve(__recommend(__size_ + 1));
+        __v.__size_ = __size_ + 1;
+        __r = _VSTD::copy(cbegin(), __position, __v.begin());
+        _VSTD::copy_backward(__position, cend(), __v.end());
+        swap(__v);
+    }
+    *__r = __x;
+    return __r;
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
+{
+    iterator __r;
+    size_type __c = capacity();
+    if (__n <= __c && size() <= __c - __n)
+    {
+        const_iterator __old_end = end();
+        __size_ += __n;
+        _VSTD::copy_backward(__position, __old_end, end());
+        __r = __const_iterator_cast(__position);
+    }
+    else
+    {
+        vector __v(__alloc());
+        __v.reserve(__recommend(__size_ + __n));
+        __v.__size_ = __size_ + __n;
+        __r = _VSTD::copy(cbegin(), __position, __v.begin());
+        _VSTD::copy_backward(__position, cend(), __v.end());
+        swap(__v);
+    }
+    _VSTD::fill_n(__r, __n, __x);
+    return __r;
+}
+
+template <class _Allocator>
+template <class _InputIterator>
+typename enable_if
+<
+     __is_input_iterator  <_InputIterator>::value &&
+    !__is_forward_iterator<_InputIterator>::value,
+    typename vector<bool, _Allocator>::iterator
+>::type
+vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
+{
+    difference_type __off = __position - begin();
+    iterator __p = __const_iterator_cast(__position);
+    iterator __old_end = end();
+    for (; size() != capacity() && __first != __last; ++__first)
+    {
+        ++this->__size_;
+        back() = *__first;
+    }
+    vector __v(__alloc());
+    if (__first != __last)
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            __v.assign(__first, __last);
+            difference_type __old_size = static_cast<difference_type>(__old_end - begin());
+            difference_type __old_p = __p - begin();
+            reserve(__recommend(size() + __v.size()));
+            __p = begin() + __old_p;
+            __old_end = begin() + __old_size;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            erase(__old_end, end());
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+    __p = _VSTD::rotate(__p, __old_end, end());
+    insert(__p, __v.begin(), __v.end());
+    return begin() + __off;
+}
+
+template <class _Allocator>
+template <class _ForwardIterator>
+typename enable_if
+<
+    __is_forward_iterator<_ForwardIterator>::value,
+    typename vector<bool, _Allocator>::iterator
+>::type
+vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)
+{
+    difference_type __n = _VSTD::distance(__first, __last);
+    iterator __r;
+    size_type __c = capacity();
+    if (__n <= __c && size() <= __c - __n)
+    {
+        const_iterator __old_end = end();
+        __size_ += __n;
+        _VSTD::copy_backward(__position, __old_end, end());
+        __r = __const_iterator_cast(__position);
+    }
+    else
+    {
+        vector __v(__alloc());
+        __v.reserve(__recommend(__size_ + __n));
+        __v.__size_ = __size_ + __n;
+        __r = _VSTD::copy(cbegin(), __position, __v.begin());
+        _VSTD::copy_backward(__position, cend(), __v.end());
+        swap(__v);
+    }
+    _VSTD::copy(__first, __last, __r);
+    return __r;
+}
+
+template <class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::erase(const_iterator __position)
+{
+    iterator __r = __const_iterator_cast(__position);
+    _VSTD::copy(__position + 1, this->cend(), __r);
+    --__size_;
+    return __r;
+}
+
+template <class _Allocator>
+typename vector<bool, _Allocator>::iterator
+vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
+{
+    iterator __r = __const_iterator_cast(__first);
+    difference_type __d = __last - __first;
+    _VSTD::copy(__last, this->cend(), __r);
+    __size_ -= __d;
+    return __r;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::swap(vector& __x)
+        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
+                   __is_nothrow_swappable<allocator_type>::value)
+{
+    _VSTD::swap(this->__begin_, __x.__begin_);
+    _VSTD::swap(this->__size_, __x.__size_);
+    _VSTD::swap(this->__cap(), __x.__cap());
+    __swap_alloc(this->__alloc(), __x.__alloc());
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
+{
+    size_type __cs = size();
+    if (__cs < __sz)
+    {
+        iterator __r;
+        size_type __c = capacity();
+        size_type __n = __sz - __cs;
+        if (__n <= __c && __cs <= __c - __n)
+        {
+            __r = end();
+            __size_ += __n;
+        }
+        else
+        {
+            vector __v(__alloc());
+            __v.reserve(__recommend(__size_ + __n));
+            __v.__size_ = __size_ + __n;
+            __r = _VSTD::copy(cbegin(), cend(), __v.begin());
+            swap(__v);
+        }
+        _VSTD::fill_n(__r, __n, __x);
+    }
+    else
+        __size_ = __sz;
+}
+
+template <class _Allocator>
+void
+vector<bool, _Allocator>::flip() _NOEXCEPT
+{
+    // do middle whole words
+    size_type __n = __size_;
+    __storage_pointer __p = __begin_;
+    for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+        *__p = ~*__p;
+    // do last partial word
+    if (__n > 0)
+    {
+        __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        __storage_type __b = *__p & __m;
+        *__p &= ~__m;
+        *__p |= ~__b & __m;
+    }
+}
+
+template <class _Allocator>
+bool
+vector<bool, _Allocator>::__invariants() const
+{
+    if (this->__begin_ == nullptr)
+    {
+        if (this->__size_ != 0 || this->__cap() != 0)
+            return false;
+    }
+    else
+    {
+        if (this->__cap() == 0)
+            return false;
+        if (this->__size_ > this->capacity())
+            return false;
+    }
+    return true;
+}
+
+template <class _Allocator>
+size_t
+vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
+{
+    size_t __h = 0;
+    // do middle whole words
+    size_type __n = __size_;
+    __storage_pointer __p = __begin_;
+    for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
+        __h ^= *__p;
+    // do last partial word
+    if (__n > 0)
+    {
+        const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+        __h ^= *__p & __m;
+    }
+    return __h;
+}
+
+template <class _Allocator>
+struct _LIBCPP_TYPE_VIS_ONLY hash<vector<bool, _Allocator> >
+    : public unary_function<vector<bool, _Allocator>, size_t>
+{
+    _LIBCPP_INLINE_VISIBILITY
+    size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
+        {return __vec.__hash_code();}
+};
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+    const typename vector<_Tp, _Allocator>::size_type __sz = __x.size();
+    return __sz == __y.size() && _VSTD::equal(__x.begin(), __x.end(), __y.begin());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+    return !(__x == __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+    return _VSTD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+    return __y < __x;
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+    return !(__x < __y);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
+{
+    return !(__y < __x);
+}
+
+template <class _Tp, class _Allocator>
+inline _LIBCPP_INLINE_VISIBILITY
+void
+swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
+    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
+{
+    __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif  // _LIBCPP_VECTOR
diff --git a/final/lib/CMakeLists.txt b/final/lib/CMakeLists.txt
new file mode 100644
index 0000000..70adcb7
--- /dev/null
+++ b/final/lib/CMakeLists.txt
@@ -0,0 +1,101 @@
+# Get sources
+file(GLOB LIBCXX_SOURCES ../src/*.cpp)
+if(WIN32)
+  file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
+  list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
+endif()
+
+# Add all the headers to the project for IDEs.
+if (MSVC_IDE OR XCODE)
+  file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
+  if(WIN32)
+    file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h)
+    list(APPEND LIBCXX_HEADERS ${LIBCXX_WIN32_HEADERS})
+  endif()
+  # Force them all into the headers dir on MSVC, otherwise they end up at
+  # project scope because they don't have extensions.
+  if (MSVC_IDE)
+    source_group("Header Files" FILES ${LIBCXX_HEADERS})
+  endif()
+endif()
+
+if (LIBCXX_ENABLE_SHARED)
+  add_library(cxx SHARED
+    ${LIBCXX_SOURCES}
+    ${LIBCXX_HEADERS}
+    )
+else()
+  add_library(cxx STATIC
+    ${LIBCXX_SOURCES}
+    ${LIBCXX_HEADERS}
+    )
+endif()
+
+if (DEFINED LIBCXX_CXX_ABI_DEPS)
+  add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
+endif()
+
+# Generate library list.
+set(libraries ${LIBCXX_CXX_ABI_LIBRARIES})
+append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
+append_if(libraries LIBCXX_HAS_C_LIB c)
+append_if(libraries LIBCXX_HAS_M_LIB m)
+append_if(libraries LIBCXX_HAS_RT_LIB rt)
+append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
+
+target_link_libraries(cxx ${libraries})
+
+# Setup flags.
+append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC)
+append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
+
+if ( APPLE )
+  if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
+    list(APPEND compile_flags "-U__STRICT_ANSI__")
+    list(APPEND link_flags
+      "-compatibility_version 1"
+      "-current_version ${LIBCXX_VERSION}"
+      "-install_name /usr/lib/libc++.1.dylib"
+      "-Wl,-reexport_library,/usr/lib/libc++abi.dylib"
+      "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
+      "/usr/lib/libSystem.B.dylib")
+  else()
+    if ( ${CMAKE_OSX_SYSROOT} )
+      list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7)
+      if (OSX_HAS_ARMV7)
+        set(OSX_RE_EXPORT_LINE
+          "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib"
+          "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp")
+      else()
+        set(OSX_RE_EXPORT_LINE
+          "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
+      endif()
+    else()
+      set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+    endif()
+
+    list(APPEND link_flags
+      "-compatibility_version 1"
+      "-install_name /usr/lib/libc++.1.dylib"
+      "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
+      "${OSX_RE_EXPORT_LINE}"
+      "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp"
+      "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp")
+  endif()
+endif()
+
+string(REPLACE ";" " " link_flags "${link_flags}")
+
+set_target_properties(cxx
+  PROPERTIES
+    COMPILE_FLAGS "${compile_flags}"
+    LINK_FLAGS    "${link_flags}"
+    OUTPUT_NAME   "c++"
+    VERSION       "1.0"
+    SOVERSION     "1"
+  )
+
+install(TARGETS cxx
+  LIBRARY DESTINATION lib
+  ARCHIVE DESTINATION lib
+  )
diff --git a/final/lib/buildit b/final/lib/buildit
new file mode 100755
index 0000000..7e3bc2e
--- /dev/null
+++ b/final/lib/buildit
@@ -0,0 +1,179 @@
+#! /bin/sh
+#
+# Set the $TRIPLE environment variable to your system's triple before
+# running this script.  If you set $CXX, that will be used to compile
+# the library.  Otherwise we'll use clang++.
+
+set -e
+
+if [ `basename $(pwd)` != "lib" ]
+then
+    echo "current directory must be lib"
+    exit 1
+fi
+
+if [ -z "$CXX" ]
+then
+    CXX=clang++
+fi
+
+if [ -z "$CXX_LANG" ]
+then
+    CXX_LANG=c++11
+fi
+
+if [ -z "$CC" ]
+then
+    CC=clang
+fi
+
+if [ -z "$MACOSX_DEPLOYMENT_TARGET" ]
+then
+    if [ -z "$IPHONEOS_DEPLOYMENT_TARGET" ]
+    then
+        MACOSX_DEPLOYMENT_TARGET=10.7
+    fi
+fi
+
+if [ -z "$RC_ProjectSourceVersion" ]
+then
+  RC_ProjectSourceVersion=1
+fi
+
+EXTRA_FLAGS="-nostdinc++ -std=${CXX_LANG} -fstrict-aliasing -Wall -Wextra -Wshadow -Wconversion \
+             -Wpadded -Wstrict-aliasing=2 -Wstrict-overflow=4 "
+
+case $TRIPLE in
+  *-apple-*)
+    if [ -z $RC_XBS ]
+    then
+      RC_CFLAGS="-arch i386 -arch x86_64"
+    fi
+    SOEXT=dylib
+    if [ "$MACOSX_DEPLOYMENT_TARGET" = "10.6" ]
+    then
+        EXTRA_FLAGS="-nostdinc++ -std=c++11 -U__STRICT_ANSI__"
+        LDSHARED_FLAGS="-o libc++.1.dylib \
+            -dynamiclib -nodefaultlibs -current_version 1 \
+            -compatibility_version 1 \
+            -install_name /usr/lib/libc++.1.dylib \
+            -Wl,-reexport_library,/usr/lib/libc++abi.dylib \
+            -Wl,-unexported_symbols_list,libc++unexp.exp  \
+            /usr/lib/libSystem.B.dylib"
+    else
+        if [ -n "$SDKROOT" ]
+        then
+            EXTRA_FLAGS+="-isysroot ${SDKROOT} "
+            if echo "${RC_ARCHS}" | grep -q "armv7"  
+            then
+                RE_EXPORT_LINE="${SDKROOT}/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++sjlj-abi.exp"
+            else
+                RE_EXPORT_LINE="-Wl,-reexport_library,${SDKROOT}/usr/lib/libc++abi.dylib"
+            fi
+            CXX=`xcrun -sdk "${SDKROOT}"  -find clang++`
+            CC=`xcrun -sdk "${SDKROOT}"  -find clang`
+        else
+            # Check if we have _LIBCPPABI_VERSION, to determine the reexport list to use.
+            if (echo "#include <cxxabi.h>" | $CXX -E -dM -x c++ - | \
+                grep _LIBCPPABI_VERSION > /dev/null)
+            then
+                RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi2.exp"
+            else
+                RE_EXPORT_LINE="/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,libc++abi.exp"
+            fi
+        fi
+        LDSHARED_FLAGS="-o libc++.1.dylib \
+            -dynamiclib -nodefaultlibs  \
+            -current_version ${RC_ProjectSourceVersion} \
+            -compatibility_version 1 \
+            -install_name /usr/lib/libc++.1.dylib \
+            -lSystem  \
+            -Wl,-unexported_symbols_list,libc++unexp.exp  \
+            ${RE_EXPORT_LINE}  \
+            -Wl,-force_symbols_not_weak_list,notweak.exp \
+            -Wl,-force_symbols_weak_list,weak.exp"
+    fi
+    ;;
+  *-*-mingw*)
+    # FIXME: removing libgcc and libsupc++ dependencies means porting libcxxrt and LLVM/compiler-rt
+    SOEXT=dll
+    LDSHARED_FLAGS="-o libc++.dll \
+        -shared -nodefaultlibs -Wl,--export-all-symbols -Wl,--allow-multiple-definition -Wl,--out-implib,libc++.dll.a \
+        -lsupc++ -lpthread -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcr100 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt"
+    ;;
+  *-ibm-*)
+    hostOS=`uname`
+    hostOS=`echo $hostOS | sed -e "s/\s+$//"`
+    hostOS=`echo $hostOS | tr '[A-Z]' '[a-z]'`
+
+    if [ $hostOS = "linux" ]
+    then
+      LDSHARED_FLAGS="-o libc++.so.1 \
+        -qmkshrobj -Wl,-soname,libc++.so.1 \
+        -lpthread -lrt -lc -lstdc++"
+      EXTRA_FLAGS="-qlanglvl=extended0x -D__GLIBCXX__=1"
+    else
+      LDSHARED_FLAGS="-o shr.o -qmkshrobj -lpthread -bnoquiet"
+      EXTRA_FLAGS="-qlanglvl=extended0x"
+    fi
+    RC_CFLAGS="-qpic=large"
+    ;;
+  *)
+    RC_CFLAGS="-fPIC"
+    SOEXT=so
+    LDSHARED_FLAGS="-o libc++.so.1.0 \
+        -shared -nodefaultlibs -Wl,-soname,libc++.so.1 \
+        -lpthread -lrt -lc -lstdc++"
+    ;;
+esac
+
+if [ -z "$RC_XBS" ]
+then
+    rm -f libc++.1.$SOEXT*
+fi
+
+set -x
+
+for FILE in ../src/*.cpp; do
+    $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
+done
+case $TRIPLE in
+  *-*-mingw*)
+  for FILE in ../src/support/win32/*.cpp; do
+    $CXX -c -g -Os $RC_CFLAGS $EXTRA_FLAGS -I../include $FILE
+  done
+  ;;
+esac
+$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
+
+#libtool -static -o libc++.a *.o
+
+# Create the link for the final library name, so that we can use this directory
+# as a link target for the tests.
+case $TRIPLE in
+    *-apple-*)
+        rm -f libc++.dylib
+        ln -s libc++.1.dylib libc++.dylib
+        ;;
+    *-*-mingw*)
+        ;;
+    *-ibm-*)
+        if [ $hostOS = "linux" ]
+        then
+           rm -f libc++.so
+           ln -s libc++.so.1 libc++.so
+        else #AIX
+           rm -f libc++.a
+           ar r libc++.a shr.o
+        fi
+        ;;
+    *)
+        rm -f libc++.so
+        ln -s libc++.so.1 libc++.so
+        ;;
+esac
+
+if [ -z "$RC_XBS" ]
+then
+    rm *.o
+fi
diff --git a/final/lib/libc++abi.exp b/final/lib/libc++abi.exp
new file mode 100644
index 0000000..87035b2
--- /dev/null
+++ b/final/lib/libc++abi.exp
@@ -0,0 +1,159 @@
+___cxa_allocate_exception
+___cxa_end_catch
+___cxa_demangle
+___cxa_current_exception_type
+___cxa_call_unexpected
+___cxa_free_exception
+___cxa_get_exception_ptr
+___cxa_get_globals
+___cxa_get_globals_fast
+___cxa_guard_abort
+___cxa_guard_acquire
+___cxa_guard_release
+___cxa_rethrow
+___cxa_pure_virtual
+___cxa_begin_catch
+___cxa_throw
+___cxa_vec_cctor
+___cxa_vec_cleanup
+___cxa_vec_ctor
+___cxa_vec_delete
+___cxa_vec_delete2
+___cxa_vec_delete3
+___cxa_vec_dtor
+___cxa_vec_new
+___cxa_vec_new2
+___cxa_vec_new3
+___dynamic_cast
+___gxx_personality_v0
+__ZTIDi
+__ZTIDn
+__ZTIDs
+__ZTIPDi
+__ZTIPDn
+__ZTIPDs
+__ZTIPKDi
+__ZTIPKDn
+__ZTIPKDs
+__ZTSPm
+__ZTSPl
+__ZTSPj
+__ZTSPi
+__ZTSPh
+__ZTSPf
+__ZTSPe
+__ZTSPd
+__ZTSPc
+__ZTSPb
+__ZTSPa
+__ZTSPKc
+__ZTSPKy
+__ZTSPKx
+__ZTSPKw
+__ZTSPKv
+__ZTSPKt
+__ZTSPKs
+__ZTSPKm
+__ZTSPKl
+__ZTSPKi
+__ZTSPKh
+__ZTSPs
+__ZTSPt
+__ZTSPv
+__ZTSPw
+__ZTSPKa
+__ZTSPx
+__ZTSPy
+__ZTSPKd
+__ZTSPKe
+__ZTSPKj
+__ZTSPKb
+__ZTSPKf
+__ZTSv
+__ZTSt
+__ZTSs
+__ZTSm
+__ZTSl
+__ZTSj
+__ZTSi
+__ZTSh
+__ZTSf
+__ZTSe
+__ZTSd
+__ZTSc
+__ZTSw
+__ZTSx
+__ZTSy
+__ZTSb
+__ZTSa
+__ZTIPKh
+__ZTIPKf
+__ZTIPKe
+__ZTIPKd
+__ZTIPKc
+__ZTIPKb
+__ZTIPKa
+__ZTIPy
+__ZTIPx
+__ZTIPw
+__ZTIPv
+__ZTIPt
+__ZTIPs
+__ZTIPm
+__ZTIPl
+__ZTIPj
+__ZTIPi
+__ZTIPKi
+__ZTIPKj
+__ZTIPKl
+__ZTIPKm
+__ZTIPKs
+__ZTIPKt
+__ZTIPKv
+__ZTIPKw
+__ZTIPKx
+__ZTIPKy
+__ZTIPa
+__ZTIPb
+__ZTIPc
+__ZTIPd
+__ZTIPe
+__ZTIPf
+__ZTIPh
+__ZTVN10__cxxabiv129__pointer_to_member_type_infoE
+__ZTVN10__cxxabiv116__enum_type_infoE
+__ZTVN10__cxxabiv117__array_type_infoE
+__ZTVN10__cxxabiv117__class_type_infoE
+__ZTVN10__cxxabiv117__pbase_type_infoE
+__ZTVN10__cxxabiv119__pointer_type_infoE
+__ZTVN10__cxxabiv120__function_type_infoE
+__ZTVN10__cxxabiv120__si_class_type_infoE
+__ZTVN10__cxxabiv121__vmi_class_type_infoE
+__ZTVN10__cxxabiv123__fundamental_type_infoE
+__ZTIa
+__ZTIb
+__ZTIc
+__ZTId
+__ZTIe
+__ZTIf
+__ZTIh
+__ZTIi
+__ZTIj
+__ZTIl
+__ZTIm
+__ZTIs
+__ZTIt
+__ZTSN10__cxxabiv129__pointer_to_member_type_infoE
+__ZTSN10__cxxabiv123__fundamental_type_infoE
+__ZTSN10__cxxabiv121__vmi_class_type_infoE
+__ZTSN10__cxxabiv120__si_class_type_infoE
+__ZTSN10__cxxabiv120__function_type_infoE
+__ZTSN10__cxxabiv119__pointer_type_infoE
+__ZTSN10__cxxabiv117__pbase_type_infoE
+__ZTSN10__cxxabiv117__class_type_infoE
+__ZTSN10__cxxabiv117__array_type_infoE
+__ZTSN10__cxxabiv116__enum_type_infoE
+__ZTIy
+__ZTIx
+__ZTIw
+__ZTIv
diff --git a/final/lib/libc++abi2.exp b/final/lib/libc++abi2.exp
new file mode 100644
index 0000000..bdfe99c
--- /dev/null
+++ b/final/lib/libc++abi2.exp
@@ -0,0 +1,310 @@
+___cxa_allocate_exception
+___cxa_end_catch
+___cxa_demangle
+___cxa_current_exception_type
+___cxa_call_unexpected
+___cxa_free_exception
+___cxa_get_exception_ptr
+___cxa_get_globals
+___cxa_get_globals_fast
+___cxa_guard_abort
+___cxa_guard_acquire
+___cxa_guard_release
+___cxa_rethrow
+___cxa_pure_virtual
+___cxa_begin_catch
+___cxa_throw
+___cxa_vec_cctor
+___cxa_vec_cleanup
+___cxa_vec_ctor
+___cxa_vec_delete
+___cxa_vec_delete2
+___cxa_vec_delete3
+___cxa_vec_dtor
+___cxa_vec_new
+___cxa_vec_new2
+___cxa_vec_new3
+___dynamic_cast
+___gxx_personality_v0
+__ZTIDi
+__ZTIDn
+__ZTIDs
+__ZTIPDi
+__ZTIPDn
+__ZTIPDs
+__ZTIPKDi
+__ZTIPKDn
+__ZTIPKDs
+__ZTSPm
+__ZTSPl
+__ZTSPj
+__ZTSPi
+__ZTSPh
+__ZTSPf
+__ZTSPe
+__ZTSPd
+__ZTSPc
+__ZTSPb
+__ZTSPa
+__ZTSPKc
+__ZTSPKy
+__ZTSPKx
+__ZTSPKw
+__ZTSPKv
+__ZTSPKt
+__ZTSPKs
+__ZTSPKm
+__ZTSPKl
+__ZTSPKi
+__ZTSPKh
+__ZTSPs
+__ZTSPt
+__ZTSPv
+__ZTSPw
+__ZTSPKa
+__ZTSPx
+__ZTSPy
+__ZTSPKd
+__ZTSPKe
+__ZTSPKj
+__ZTSPKb
+__ZTSPKf
+__ZTSv
+__ZTSt
+__ZTSs
+__ZTSm
+__ZTSl
+__ZTSj
+__ZTSi
+__ZTSh
+__ZTSf
+__ZTSe
+__ZTSd
+__ZTSc
+__ZTSw
+__ZTSx
+__ZTSy
+__ZTSb
+__ZTSa
+__ZTIPKh
+__ZTIPKf
+__ZTIPKe
+__ZTIPKd
+__ZTIPKc
+__ZTIPKb
+__ZTIPKa
+__ZTIPy
+__ZTIPx
+__ZTIPw
+__ZTIPv
+__ZTIPt
+__ZTIPs
+__ZTIPm
+__ZTIPl
+__ZTIPj
+__ZTIPi
+__ZTIPKi
+__ZTIPKj
+__ZTIPKl
+__ZTIPKm
+__ZTIPKs
+__ZTIPKt
+__ZTIPKv
+__ZTIPKw
+__ZTIPKx
+__ZTIPKy
+__ZTIPa
+__ZTIPb
+__ZTIPc
+__ZTIPd
+__ZTIPe
+__ZTIPf
+__ZTIPh
+__ZTVN10__cxxabiv129__pointer_to_member_type_infoE
+__ZTVN10__cxxabiv116__enum_type_infoE
+__ZTVN10__cxxabiv117__array_type_infoE
+__ZTVN10__cxxabiv117__class_type_infoE
+__ZTVN10__cxxabiv117__pbase_type_infoE
+__ZTVN10__cxxabiv119__pointer_type_infoE
+__ZTVN10__cxxabiv120__function_type_infoE
+__ZTVN10__cxxabiv120__si_class_type_infoE
+__ZTVN10__cxxabiv121__vmi_class_type_infoE
+__ZTVN10__cxxabiv123__fundamental_type_infoE
+__ZTIa
+__ZTIb
+__ZTIc
+__ZTId
+__ZTIe
+__ZTIf
+__ZTIh
+__ZTIi
+__ZTIj
+__ZTIl
+__ZTIm
+__ZTIs
+__ZTIt
+__ZTSN10__cxxabiv129__pointer_to_member_type_infoE
+__ZTSN10__cxxabiv123__fundamental_type_infoE
+__ZTSN10__cxxabiv121__vmi_class_type_infoE
+__ZTSN10__cxxabiv120__si_class_type_infoE
+__ZTSN10__cxxabiv120__function_type_infoE
+__ZTSN10__cxxabiv119__pointer_type_infoE
+__ZTSN10__cxxabiv117__pbase_type_infoE
+__ZTSN10__cxxabiv117__class_type_infoE
+__ZTSN10__cxxabiv117__array_type_infoE
+__ZTSN10__cxxabiv116__enum_type_infoE
+__ZTIy
+__ZTIx
+__ZTIw
+__ZTIv
+__ZSt13get_terminatev
+__ZSt13set_terminatePFvvE
+__ZSt14get_unexpectedv
+__ZSt14set_unexpectedPFvvE
+__ZSt15get_new_handlerv
+__ZSt15set_new_handlerPFvvE
+__ZSt9terminatev
+__ZNSt9bad_allocD1Ev
+__ZTISt9bad_alloc
+__ZNSt9bad_allocC1Ev
+__ZTISt13bad_exception
+__ZTVSt10bad_typeid
+__ZTVSt9exception
+__ZNSt10bad_typeidC1Ev
+__ZNSt10bad_typeidC1Ev
+__ZNKSt10bad_typeid4whatEv
+__ZNSt10bad_typeidD1Ev
+__ZTVSt8bad_cast
+__ZNSt8bad_castC1Ev
+__ZNSt8bad_castC2Ev
+__ZNSt8bad_castD0Ev
+__ZNKSt8bad_cast4whatEv
+__ZNSt8bad_castD1Ev
+__ZNSt8bad_castD2Ev
+__ZTVSt9bad_alloc
+__ZTVSt20bad_array_new_length
+__ZTVSt13bad_exception
+__ZNKSt9exception4whatEv
+__ZNKSt9bad_alloc4whatEv
+__ZNSt9bad_allocC2Ev
+__ZNSt9bad_allocD0Ev
+__ZNSt9bad_allocD2Ev
+__ZNSt9exceptionD0Ev
+__ZNSt20bad_array_new_lengthC1Ev
+__ZNKSt13bad_exception4whatEv
+__ZNSt9exceptionD1Ev
+__ZNKSt20bad_array_new_length4whatEv
+__ZNSt13bad_exceptionD1Ev
+__ZNSt20bad_array_new_lengthD1Ev
+__ZNSt9exceptionD2Ev
+__ZNSt9type_infoD0Ev
+__ZNSt9type_infoD1Ev
+__ZNSt9type_infoD2Ev
+__ZNSt10bad_typeidC2Ev
+__ZNSt10bad_typeidD0Ev
+__ZNSt10bad_typeidD2Ev
+__ZNSt13bad_exceptionD0Ev
+__ZNSt13bad_exceptionD2Ev
+__ZNSt20bad_array_new_lengthC2Ev
+__ZNSt20bad_array_new_lengthD0Ev
+__ZNSt20bad_array_new_lengthD2Ev
+__ZSt10unexpectedv
+# __ZdaPv
+# __ZdlPv
+# __ZdlPvRKSt9nothrow_t
+# __Znam
+# __ZdaPvRKSt9nothrow_t
+# __Znwm
+# __ZnwmRKSt9nothrow_t
+# __ZnamRKSt9nothrow_t
+__ZTISt10bad_typeid
+__ZTISt8bad_cast
+___cxa_bad_typeid
+___cxa_bad_cast
+__ZTISt9exception
+__ZTISt9type_info
+__ZTISt20bad_array_new_length
+
+__ZNKSt11logic_error4whatEv
+__ZNSt11logic_errorD0Ev
+__ZNSt11logic_errorD1Ev
+__ZNSt11logic_errorD2Ev
+__ZTISt11logic_error
+__ZTSSt11logic_error
+__ZTVSt11logic_error
+
+__ZNKSt13runtime_error4whatEv
+__ZNSt13runtime_errorD0Ev
+__ZNSt13runtime_errorD1Ev
+__ZNSt13runtime_errorD2Ev
+__ZTISt13runtime_error
+__ZTSSt13runtime_error
+__ZTVSt13runtime_error
+
+__ZNSt11range_errorD0Ev
+__ZNSt11range_errorD1Ev
+__ZNSt11range_errorD2Ev
+__ZTISt11range_error
+__ZTSSt11range_error
+__ZTVSt11range_error
+
+__ZNSt12domain_errorD0Ev
+__ZNSt12domain_errorD1Ev
+__ZNSt12domain_errorD2Ev
+__ZTISt12domain_error
+__ZTSSt12domain_error
+__ZTVSt12domain_error
+
+__ZNSt12length_errorD0Ev
+__ZNSt12length_errorD1Ev
+__ZNSt12length_errorD2Ev
+__ZTISt12length_error
+__ZTSSt12length_error
+__ZTVSt12length_error
+
+__ZNSt12out_of_rangeD0Ev
+__ZNSt12out_of_rangeD1Ev
+__ZNSt12out_of_rangeD2Ev
+__ZTISt12out_of_range
+__ZTSSt12out_of_range
+__ZTVSt12out_of_range
+
+__ZNSt14overflow_errorD0Ev
+__ZNSt14overflow_errorD1Ev
+__ZNSt14overflow_errorD2Ev
+__ZTISt14overflow_error
+__ZTSSt14overflow_error
+__ZTVSt14overflow_error
+
+__ZNSt15underflow_errorD0Ev
+__ZNSt15underflow_errorD1Ev
+__ZNSt15underflow_errorD2Ev
+__ZTISt15underflow_error
+__ZTSSt15underflow_error
+__ZTVSt15underflow_error
+
+__ZNSt16invalid_argumentD0Ev
+__ZNSt16invalid_argumentD1Ev
+__ZNSt16invalid_argumentD2Ev
+__ZTISt16invalid_argument
+__ZTSSt16invalid_argument
+__ZTVSt16invalid_argument
+
+__ZTSDi
+__ZTSDn
+__ZTSDs
+__ZTSPDi
+__ZTSPDn
+__ZTSPDs
+__ZTSPKDi
+__ZTSPKDn
+__ZTSPKDs
+
+__ZTSSt8bad_cast
+__ZTSSt9bad_alloc
+__ZTSSt9exception
+__ZTSSt9type_info
+__ZTSSt10bad_typeid
+__ZTSSt13bad_exception
+__ZTSSt20bad_array_new_length
+__ZTVSt9type_info
diff --git a/final/lib/libc++sjlj-abi.exp b/final/lib/libc++sjlj-abi.exp
new file mode 100644
index 0000000..e646df1
--- /dev/null
+++ b/final/lib/libc++sjlj-abi.exp
@@ -0,0 +1,159 @@
+___cxa_allocate_exception
+___cxa_end_catch
+___cxa_demangle
+___cxa_current_exception_type
+___cxa_call_unexpected
+___cxa_free_exception
+___cxa_get_exception_ptr
+___cxa_get_globals
+___cxa_get_globals_fast
+___cxa_guard_abort
+___cxa_guard_acquire
+___cxa_guard_release
+___cxa_rethrow
+___cxa_pure_virtual
+___cxa_begin_catch
+___cxa_throw
+___cxa_vec_cctor
+___cxa_vec_cleanup
+___cxa_vec_ctor
+___cxa_vec_delete
+___cxa_vec_delete2
+___cxa_vec_delete3
+___cxa_vec_dtor
+___cxa_vec_new
+___cxa_vec_new2
+___cxa_vec_new3
+___dynamic_cast
+___gxx_personality_sj0
+__ZTIDi
+__ZTIDn
+__ZTIDs
+__ZTIPDi
+__ZTIPDn
+__ZTIPDs
+__ZTIPKDi
+__ZTIPKDn
+__ZTIPKDs
+__ZTSPm
+__ZTSPl
+__ZTSPj
+__ZTSPi
+__ZTSPh
+__ZTSPf
+__ZTSPe
+__ZTSPd
+__ZTSPc
+__ZTSPb
+__ZTSPa
+__ZTSPKc
+__ZTSPKy
+__ZTSPKx
+__ZTSPKw
+__ZTSPKv
+__ZTSPKt
+__ZTSPKs
+__ZTSPKm
+__ZTSPKl
+__ZTSPKi
+__ZTSPKh
+__ZTSPs
+__ZTSPt
+__ZTSPv
+__ZTSPw
+__ZTSPKa
+__ZTSPx
+__ZTSPy
+__ZTSPKd
+__ZTSPKe
+__ZTSPKj
+__ZTSPKb
+__ZTSPKf
+__ZTSv
+__ZTSt
+__ZTSs
+__ZTSm
+__ZTSl
+__ZTSj
+__ZTSi
+__ZTSh
+__ZTSf
+__ZTSe
+__ZTSd
+__ZTSc
+__ZTSw
+__ZTSx
+__ZTSy
+__ZTSb
+__ZTSa
+__ZTIPKh
+__ZTIPKf
+__ZTIPKe
+__ZTIPKd
+__ZTIPKc
+__ZTIPKb
+__ZTIPKa
+__ZTIPy
+__ZTIPx
+__ZTIPw
+__ZTIPv
+__ZTIPt
+__ZTIPs
+__ZTIPm
+__ZTIPl
+__ZTIPj
+__ZTIPi
+__ZTIPKi
+__ZTIPKj
+__ZTIPKl
+__ZTIPKm
+__ZTIPKs
+__ZTIPKt
+__ZTIPKv
+__ZTIPKw
+__ZTIPKx
+__ZTIPKy
+__ZTIPa
+__ZTIPb
+__ZTIPc
+__ZTIPd
+__ZTIPe
+__ZTIPf
+__ZTIPh
+__ZTVN10__cxxabiv129__pointer_to_member_type_infoE
+__ZTVN10__cxxabiv116__enum_type_infoE
+__ZTVN10__cxxabiv117__array_type_infoE
+__ZTVN10__cxxabiv117__class_type_infoE
+__ZTVN10__cxxabiv117__pbase_type_infoE
+__ZTVN10__cxxabiv119__pointer_type_infoE
+__ZTVN10__cxxabiv120__function_type_infoE
+__ZTVN10__cxxabiv120__si_class_type_infoE
+__ZTVN10__cxxabiv121__vmi_class_type_infoE
+__ZTVN10__cxxabiv123__fundamental_type_infoE
+__ZTIa
+__ZTIb
+__ZTIc
+__ZTId
+__ZTIe
+__ZTIf
+__ZTIh
+__ZTIi
+__ZTIj
+__ZTIl
+__ZTIm
+__ZTIs
+__ZTIt
+__ZTSN10__cxxabiv129__pointer_to_member_type_infoE
+__ZTSN10__cxxabiv123__fundamental_type_infoE
+__ZTSN10__cxxabiv121__vmi_class_type_infoE
+__ZTSN10__cxxabiv120__si_class_type_infoE
+__ZTSN10__cxxabiv120__function_type_infoE
+__ZTSN10__cxxabiv119__pointer_type_infoE
+__ZTSN10__cxxabiv117__pbase_type_infoE
+__ZTSN10__cxxabiv117__class_type_infoE
+__ZTSN10__cxxabiv117__array_type_infoE
+__ZTSN10__cxxabiv116__enum_type_infoE
+__ZTIy
+__ZTIx
+__ZTIw
+__ZTIv
diff --git a/final/lib/libc++unexp.exp b/final/lib/libc++unexp.exp
new file mode 100644
index 0000000..9507fc5
--- /dev/null
+++ b/final/lib/libc++unexp.exp
@@ -0,0 +1,19 @@
+# all guard variables
+__ZGVNSt3__*
+# all vtables
+# __ZTV*
+# all VTT
+# __ZTT*
+# all non-virtual thunks
+# __ZTh*
+# all virtual thunks
+# __ZTv*
+# typeinfo for std::__1::__types
+#    There are no std::__types
+# __ZTINSt3__1[0-9][0-9]*__*
+# typeinfo name for std::__1::__types
+__ZTSNSt3__1[0-9][0-9]*__*
+# anything using __hidden_allocator
+*__hidden_allocator*
+# anything using __sso_allocator
+*__sso_allocator*
diff --git a/final/lib/notweak.exp b/final/lib/notweak.exp
new file mode 100644
index 0000000..fafde1c
--- /dev/null
+++ b/final/lib/notweak.exp
@@ -0,0 +1,5 @@
+# Remove the weak-def bit from these external symbols
+__ZT*
+__ZN*
+__ZS*
+
diff --git a/final/lib/weak.exp b/final/lib/weak.exp
new file mode 100644
index 0000000..6bdcc05
--- /dev/null
+++ b/final/lib/weak.exp
@@ -0,0 +1,16 @@
+__ZTISt10bad_typeid
+__ZTISt11logic_error
+__ZTISt11range_error
+__ZTISt12domain_error
+__ZTISt12length_error
+__ZTISt12out_of_range
+__ZTISt13bad_exception
+__ZTISt13runtime_error
+__ZTISt14overflow_error
+__ZTISt15underflow_error
+__ZTISt16invalid_argument
+__ZTISt16nested_exception
+__ZTISt20bad_array_new_length
+__ZTISt8bad_cast
+__ZTISt9bad_alloc
+__ZTISt9exception
diff --git a/final/src/algorithm.cpp b/final/src/algorithm.cpp
new file mode 100644
index 0000000..10c4c33
--- /dev/null
+++ b/final/src/algorithm.cpp
@@ -0,0 +1,84 @@
+//===----------------------- algorithm.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+#include "algorithm"
+#include "random"
+#include "mutex"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
+template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
+template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
+template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
+template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
+template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
+template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
+template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
+template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
+template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
+template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
+template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
+template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
+template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
+template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
+
+template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
+template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
+template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
+template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
+template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
+template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
+template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
+template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
+template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
+template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
+template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
+template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
+template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
+template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
+template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
+
+template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
+
+static pthread_mutex_t __rs_mut = PTHREAD_MUTEX_INITIALIZER;
+unsigned __rs_default::__c_ = 0;
+
+__rs_default::__rs_default()
+{
+    pthread_mutex_lock(&__rs_mut);
+    __c_ = 1;
+}
+
+__rs_default::__rs_default(const __rs_default&)
+{
+    ++__c_;
+}
+
+__rs_default::~__rs_default()
+{
+    if (--__c_ == 0)
+        pthread_mutex_unlock(&__rs_mut);
+}
+
+__rs_default::result_type
+__rs_default::operator()()
+{
+    static mt19937 __rs_g;
+    return __rs_g();
+}
+
+__rs_default
+__rs_get()
+{
+    return __rs_default();
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/bind.cpp b/final/src/bind.cpp
new file mode 100644
index 0000000..cab0b7c
--- /dev/null
+++ b/final/src/bind.cpp
@@ -0,0 +1,30 @@
+//===-------------------------- bind.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 "functional"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace placeholders
+{
+
+__ph<1>   _1;
+__ph<2>   _2;
+__ph<3>   _3;
+__ph<4>   _4;
+__ph<5>   _5;
+__ph<6>   _6;
+__ph<7>   _7;
+__ph<8>   _8;
+__ph<9>   _9;
+__ph<10> _10;
+
+}  // placeholders
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/chrono.cpp b/final/src/chrono.cpp
new file mode 100644
index 0000000..15a6f46
--- /dev/null
+++ b/final/src/chrono.cpp
@@ -0,0 +1,132 @@
+//===------------------------- chrono.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 "chrono"
+#include <sys/time.h>        //for gettimeofday and timeval
+#ifdef __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__
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace chrono
+{
+
+// system_clock
+
+const bool system_clock::is_steady;
+
+system_clock::time_point
+system_clock::now() _NOEXCEPT
+{
+    timeval tv;
+    gettimeofday(&tv, 0);
+    return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+}
+
+time_t
+system_clock::to_time_t(const time_point& t) _NOEXCEPT
+{
+    return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
+}
+
+system_clock::time_point
+system_clock::from_time_t(time_t t) _NOEXCEPT
+{
+    return system_clock::time_point(seconds(t));
+}
+
+// steady_clock
+
+const bool steady_clock::is_steady;
+
+#ifdef __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
+//   to the Gregorian calendar.  It's main use is as a high resolution timer.
+
+// MachInfo.numer / MachInfo.denom is often 1 on the latest equipment.  Specialize
+//   for that case as an optimization.
+
+#pragma GCC visibility push(hidden)
+
+static
+steady_clock::rep
+steady_simplified()
+{
+    return static_cast<steady_clock::rep>(mach_absolute_time());
+}
+
+static
+double
+compute_steady_factor()
+{
+    mach_timebase_info_data_t MachInfo;
+    mach_timebase_info(&MachInfo);
+    return static_cast<double>(MachInfo.numer) / MachInfo.denom;
+}
+
+static
+steady_clock::rep
+steady_full()
+{
+    static const double factor = compute_steady_factor();
+    return static_cast<steady_clock::rep>(mach_absolute_time() * factor);
+}
+
+typedef steady_clock::rep (*FP)();
+
+static
+FP
+init_steady_clock()
+{
+    mach_timebase_info_data_t MachInfo;
+    mach_timebase_info(&MachInfo);
+    if (MachInfo.numer == MachInfo.denom)
+        return &steady_simplified;
+    return &steady_full;
+}
+
+#pragma GCC visibility pop
+
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+    static FP fp = init_steady_clock();
+    return time_point(duration(fp()));
+}
+
+#else  // __APPLE__
+// FIXME: We assume that clock_gettime(CLOCK_MONOTONIC) works on
+// non-apple systems.  Instead, we should check _POSIX_TIMERS and
+// _POSIX_MONOTONIC_CLOCK and fall back to something else if those
+// don't exist.
+
+// 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__
+
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/condition_variable.cpp b/final/src/condition_variable.cpp
new file mode 100644
index 0000000..061d138
--- /dev/null
+++ b/final/src/condition_variable.cpp
@@ -0,0 +1,81 @@
+//===-------------------- condition_variable.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 "condition_variable"
+#include "thread"
+#include "system_error"
+#include "cassert"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+condition_variable::~condition_variable()
+{
+    pthread_cond_destroy(&__cv_);
+}
+
+void
+condition_variable::notify_one() _NOEXCEPT
+{
+    pthread_cond_signal(&__cv_);
+}
+
+void
+condition_variable::notify_all() _NOEXCEPT
+{
+    pthread_cond_broadcast(&__cv_);
+}
+
+void
+condition_variable::wait(unique_lock<mutex>& lk) _NOEXCEPT
+{
+    if (!lk.owns_lock())
+        __throw_system_error(EPERM,
+                                  "condition_variable::wait: mutex not locked");
+    int ec = pthread_cond_wait(&__cv_, lk.mutex()->native_handle());
+    if (ec)
+        __throw_system_error(ec, "condition_variable wait failed");
+}
+
+void
+condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
+     chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) _NOEXCEPT
+{
+    using namespace chrono;
+    if (!lk.owns_lock())
+        __throw_system_error(EPERM,
+                            "condition_variable::timed wait: mutex not locked");
+    nanoseconds d = tp.time_since_epoch();
+    if (d > nanoseconds(0x59682F000000E941))
+        d = nanoseconds(0x59682F000000E941);
+    timespec ts;
+    seconds s = duration_cast<seconds>(d);
+    typedef decltype(ts.tv_sec) ts_sec;
+    _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
+    if (s.count() < ts_sec_max)
+    {
+        ts.tv_sec = static_cast<ts_sec>(s.count());
+        ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
+    }
+    else
+    {
+        ts.tv_sec = ts_sec_max;
+        ts.tv_nsec = giga::num - 1;
+    }
+    int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
+    if (ec != 0 && ec != ETIMEDOUT)
+        __throw_system_error(ec, "condition_variable timed_wait failed");
+}
+
+void
+notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
+{
+    __thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/debug.cpp b/final/src/debug.cpp
new file mode 100644
index 0000000..d0e8679
--- /dev/null
+++ b/final/src/debug.cpp
@@ -0,0 +1,530 @@
+//===-------------------------- debug.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_DEBUG 1
+#include "__config"
+#include "__debug"
+#include "functional"
+#include "algorithm"
+#include "__hash_table"
+#include "mutex"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+_LIBCPP_FUNC_VIS
+__libcpp_db*
+__get_db()
+{
+    static __libcpp_db db;
+    return &db;
+}
+
+_LIBCPP_FUNC_VIS
+const __libcpp_db*
+__get_const_db()
+{
+    return __get_db();
+}
+
+namespace
+{
+
+typedef mutex mutex_type;
+typedef lock_guard<mutex_type> WLock;
+typedef lock_guard<mutex_type> RLock;
+
+mutex_type&
+mut()
+{
+    static mutex_type m;
+    return m;
+}
+
+}  // unnamed namespace
+
+__i_node::~__i_node()
+{
+    if (__next_)
+    {
+        __next_->~__i_node();
+        free(__next_);
+    }
+}
+
+__c_node::~__c_node()
+{
+    free(beg_);
+    if (__next_)
+    {
+        __next_->~__c_node();
+        free(__next_);
+    }
+}
+
+__libcpp_db::__libcpp_db()
+    : __cbeg_(nullptr),
+      __cend_(nullptr),
+      __csz_(0),
+      __ibeg_(nullptr),
+      __iend_(nullptr),
+      __isz_(0)
+{
+}
+
+__libcpp_db::~__libcpp_db()
+{
+    if (__cbeg_)
+    {
+        for (__c_node** p = __cbeg_; p != __cend_; ++p)
+        {
+            if (*p != nullptr)
+            {
+                (*p)->~__c_node();
+                free(*p);
+            }
+        }
+        free(__cbeg_);
+    }
+    if (__ibeg_)
+    {
+        for (__i_node** p = __ibeg_; p != __iend_; ++p)
+        {
+            if (*p != nullptr)
+            {
+                (*p)->~__i_node();
+                free(*p);
+            }
+        }
+        free(__ibeg_);
+    }
+}
+
+void*
+__libcpp_db::__find_c_from_i(void* __i) const
+{
+    RLock _(mut());
+    __i_node* i = __find_iterator(__i);
+    _LIBCPP_ASSERT(i != nullptr, "iterator not found in debug database.");
+    return i->__c_ != nullptr ? i->__c_->__c_ : nullptr;
+}
+
+void
+__libcpp_db::__insert_ic(void* __i, const void* __c)
+{
+    WLock _(mut());
+    if (__cbeg_ == __cend_)
+        return;
+    size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+    __c_node* c = __cbeg_[hc];
+    if (c == nullptr)
+        return;
+    while (c->__c_ != __c)
+    {
+        c = c->__next_;
+        if (c == nullptr)
+            return;
+    }
+    __i_node* i = __insert_iterator(__i);
+    c->__add(i);
+    i->__c_ = c;
+}
+
+__c_node*
+__libcpp_db::__insert_c(void* __c)
+{
+    WLock _(mut());
+    if (__csz_ + 1 > static_cast<size_t>(__cend_ - __cbeg_))
+    {
+        size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1);
+        __c_node** cbeg = static_cast<__c_node**>(calloc(nc, sizeof(void*)));
+        if (cbeg == nullptr)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw bad_alloc();
+#else
+            abort();
+#endif
+        for (__c_node** p = __cbeg_; p != __cend_; ++p)
+        {
+            __c_node* q = *p;
+            while (q != nullptr)
+            {
+                size_t h = hash<void*>()(q->__c_) % nc;
+                __c_node* r = q->__next_;
+                q->__next_ = cbeg[h];
+                cbeg[h] = q;
+                q = r;
+            }
+        }
+        free(__cbeg_);
+        __cbeg_ = cbeg;
+        __cend_ = __cbeg_ + nc;
+    }
+    size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+    __c_node* p = __cbeg_[hc];
+    __c_node* r = __cbeg_[hc] =
+      static_cast<__c_node*>(malloc(sizeof(__c_node)));
+    if (__cbeg_[hc] == nullptr)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw bad_alloc();
+#else
+        abort();
+#endif
+    r->__c_ = __c;
+    r->__next_ = p;
+    ++__csz_;
+    return r;
+}
+
+void
+__libcpp_db::__erase_i(void* __i)
+{
+    WLock _(mut());
+    if (__ibeg_ != __iend_)
+    {
+        size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
+        __i_node* p = __ibeg_[hi];
+        if (p != nullptr)
+        {
+            __i_node* q = nullptr;
+            while (p->__i_ != __i)
+            {
+                q = p;
+                p = p->__next_;
+                if (p == nullptr)
+                    return;
+            }
+            if (q == nullptr)
+                __ibeg_[hi] = p->__next_;
+            else
+                q->__next_ = p->__next_;
+            __c_node* c = p->__c_;
+            free(p);
+            --__isz_;
+            if (c != nullptr)
+                c->__remove(p);
+        }
+    }
+}
+
+void
+__libcpp_db::__invalidate_all(void* __c)
+{
+    WLock _(mut());
+    if (__cend_ != __cbeg_)
+    {
+        size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+        __c_node* p = __cbeg_[hc];
+        if (p == nullptr)
+            return;
+        while (p->__c_ != __c)
+        {
+            p = p->__next_;
+            if (p == nullptr)
+                return;
+        }
+        while (p->end_ != p->beg_)
+        {
+            --p->end_;
+            (*p->end_)->__c_ = nullptr;
+        }
+    }
+}
+
+__c_node*
+__libcpp_db::__find_c_and_lock(void* __c) const
+{
+    mut().lock();
+    if (__cend_ == __cbeg_)
+    {
+        mut().unlock();
+        return nullptr;
+    }
+    size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+    __c_node* p = __cbeg_[hc];
+    if (p == nullptr)
+    {
+        mut().unlock();
+        return nullptr;
+    }
+    while (p->__c_ != __c)
+    {
+        p = p->__next_;
+        if (p == nullptr)
+        {
+            mut().unlock();
+            return nullptr;
+        }
+    }
+    return p;
+}
+
+__c_node*
+__libcpp_db::__find_c(void* __c) const
+{
+    size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+    __c_node* p = __cbeg_[hc];
+    _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c A");
+    while (p->__c_ != __c)
+    {
+        p = p->__next_;
+        _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c B");
+    }
+    return p;
+}
+
+void
+__libcpp_db::unlock() const
+{
+    mut().unlock();
+}
+
+void
+__libcpp_db::__erase_c(void* __c)
+{
+    WLock _(mut());
+    if (__cend_ != __cbeg_)
+    {
+        size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
+        __c_node* p = __cbeg_[hc];
+        if (p == nullptr)
+            return;
+        __c_node* q = nullptr;
+        _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A");
+        while (p->__c_ != __c)
+        {
+            q = p;
+            p = p->__next_;
+            if (p == nullptr)
+                return;
+            _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B");
+        }
+        if (q == nullptr)
+            __cbeg_[hc] = p->__next_;
+        else
+            q->__next_ = p->__next_;
+        while (p->end_ != p->beg_)
+        {
+            --p->end_;
+            (*p->end_)->__c_ = nullptr;
+        }
+        free(p->beg_);
+        free(p);
+        --__csz_;
+    }
+}
+
+void
+__libcpp_db::__iterator_copy(void* __i, const void* __i0)
+{
+    WLock _(mut());
+    __i_node* i = __find_iterator(__i);
+    __i_node* i0 = __find_iterator(__i0);
+    __c_node* c0 = i0 != nullptr ? i0->__c_ : nullptr;
+    if (i == nullptr && i0 != nullptr)
+        i = __insert_iterator(__i);
+    __c_node* c = i != nullptr ? i->__c_ : nullptr;
+    if (c != c0)
+    {
+        if (c != nullptr)
+            c->__remove(i);
+        if (i != nullptr)
+        {
+            i->__c_ = nullptr;
+            if (c0 != nullptr)
+            {
+                i->__c_ = c0;
+                i->__c_->__add(i);
+            }
+        }
+    }
+}
+
+bool
+__libcpp_db::__dereferenceable(const void* __i) const
+{
+    RLock _(mut());
+    __i_node* i = __find_iterator(__i);
+    return i != nullptr && i->__c_ != nullptr && i->__c_->__dereferenceable(__i);
+}
+
+bool
+__libcpp_db::__decrementable(const void* __i) const
+{
+    RLock _(mut());
+    __i_node* i = __find_iterator(__i);
+    return i != nullptr && i->__c_ != nullptr && i->__c_->__decrementable(__i);
+}
+
+bool
+__libcpp_db::__addable(const void* __i, ptrdiff_t __n) const
+{
+    RLock _(mut());
+    __i_node* i = __find_iterator(__i);
+    return i != nullptr && i->__c_ != nullptr && i->__c_->__addable(__i, __n);
+}
+
+bool
+__libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
+{
+    RLock _(mut());
+    __i_node* i = __find_iterator(__i);
+    return i != nullptr && i->__c_ != nullptr && i->__c_->__subscriptable(__i, __n);
+}
+
+bool
+__libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
+{
+    RLock _(mut());
+    __i_node* i = __find_iterator(__i);
+    __i_node* j = __find_iterator(__j);
+    __c_node* ci = i != nullptr ? i->__c_ : nullptr;
+    __c_node* cj = j != nullptr ? j->__c_ : nullptr;
+    return ci != nullptr && ci == cj;
+}
+
+void
+__libcpp_db::swap(void* c1, void* c2)
+{
+    WLock _(mut());
+    size_t hc = hash<void*>()(c1) % static_cast<size_t>(__cend_ - __cbeg_);
+    __c_node* p1 = __cbeg_[hc];
+    _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A");
+    while (p1->__c_ != c1)
+    {
+        p1 = p1->__next_;
+        _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap B");
+    }
+    hc = hash<void*>()(c2) % static_cast<size_t>(__cend_ - __cbeg_);
+    __c_node* p2 = __cbeg_[hc];
+    _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap C");
+    while (p2->__c_ != c2)
+    {
+        p2 = p2->__next_;
+        _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap D");
+    }
+    std::swap(p1->beg_, p2->beg_);
+    std::swap(p1->end_, p2->end_);
+    std::swap(p1->cap_, p2->cap_);
+    for (__i_node** p = p1->beg_; p != p1->end_; ++p)
+        (*p)->__c_ = p1;
+    for (__i_node** p = p2->beg_; p != p2->end_; ++p)
+        (*p)->__c_ = p2;
+}
+
+void
+__libcpp_db::__insert_i(void* __i)
+{
+    WLock _(mut());
+    __insert_iterator(__i);
+}
+
+void
+__c_node::__add(__i_node* i)
+{
+    if (end_ == cap_)
+    {
+        size_t nc = 2*static_cast<size_t>(cap_ - beg_);
+        if (nc == 0)
+            nc = 1;
+        __i_node** beg =
+           static_cast<__i_node**>(malloc(nc * sizeof(__i_node*)));
+        if (beg == nullptr)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw bad_alloc();
+#else
+            abort();
+#endif
+        if (nc > 1)
+            memcpy(beg, beg_, nc/2*sizeof(__i_node*));
+        free(beg_);
+        beg_ = beg;
+        end_ = beg_ + nc/2;
+        cap_ = beg_ + nc;
+    }
+    *end_++ = i;
+}
+
+// private api
+
+_LIBCPP_HIDDEN
+__i_node*
+__libcpp_db::__insert_iterator(void* __i)
+{
+    if (__isz_ + 1 > static_cast<size_t>(__iend_ - __ibeg_))
+    {
+        size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1);
+        __i_node** ibeg = static_cast<__i_node**>(calloc(nc, sizeof(void*)));
+        if (ibeg == nullptr)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw bad_alloc();
+#else
+            abort();
+#endif
+        for (__i_node** p = __ibeg_; p != __iend_; ++p)
+        {
+            __i_node* q = *p;
+            while (q != nullptr)
+            {
+                size_t h = hash<void*>()(q->__i_) % nc;
+                __i_node* r = q->__next_;
+                q->__next_ = ibeg[h];
+                ibeg[h] = q;
+                q = r;
+            }
+        }
+        free(__ibeg_);
+        __ibeg_ = ibeg;
+        __iend_ = __ibeg_ + nc;
+    }
+    size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
+    __i_node* p = __ibeg_[hi];
+    __i_node* r = __ibeg_[hi] =
+      static_cast<__i_node*>(malloc(sizeof(__i_node)));
+    if (r == nullptr)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw bad_alloc();
+#else
+        abort();
+#endif
+    ::new(r) __i_node(__i, p, nullptr);
+    ++__isz_;
+    return r;
+}
+
+_LIBCPP_HIDDEN
+__i_node*
+__libcpp_db::__find_iterator(const void* __i) const
+{
+    __i_node* r = nullptr;
+    if (__ibeg_ != __iend_)
+    {
+        size_t h = hash<const void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
+        for (__i_node* nd = __ibeg_[h]; nd != nullptr; nd = nd->__next_)
+        {
+            if (nd->__i_ == __i)
+            {
+                r = nd;
+                break;
+            }
+        }
+    }
+    return r;
+}
+
+_LIBCPP_HIDDEN
+void
+__c_node::__remove(__i_node* p)
+{
+    __i_node** r = find(beg_, end_, p);
+    _LIBCPP_ASSERT(r != end_, "debug mode internal logic error __c_node::__remove");
+    if (--end_ != r)
+        memmove(r, r+1, static_cast<size_t>(end_ - r)*sizeof(__i_node*));
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/exception.cpp b/final/src/exception.cpp
new file mode 100644
index 0000000..3ce6f2e
--- /dev/null
+++ b/final/src/exception.cpp
@@ -0,0 +1,307 @@
+//===------------------------ exception.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 <stdlib.h>
+#include <stdio.h>
+
+#include "exception"
+#include "new"
+
+#ifndef __has_include
+#define __has_include(inc) 0
+#endif
+
+#ifdef __APPLE__
+  #include <cxxabi.h>
+
+  using namespace __cxxabiv1;
+  #define HAVE_DEPENDENT_EH_ABI 1
+  #ifndef _LIBCPPABI_VERSION
+    using namespace __cxxabiapple;
+    // On Darwin, there are two STL shared libraries and a lower level ABI
+    // shared library.  The globals holding the current terminate handler and
+    // current unexpected handler are in the ABI library.
+    #define __terminate_handler  __cxxabiapple::__cxa_terminate_handler
+    #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler
+  #endif  // _LIBCPPABI_VERSION
+#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
+  #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>)
+  static std::terminate_handler  __terminate_handler;
+  static std::unexpected_handler __unexpected_handler;
+#endif // __has_include(<cxxabi.h>)
+
+namespace std
+{
+
+#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)
+
+// libcxxrt provides implementations of these functions itself.
+unexpected_handler
+set_unexpected(unexpected_handler func) _NOEXCEPT
+{
+    return __sync_lock_test_and_set(&__unexpected_handler, func);
+}
+
+unexpected_handler
+get_unexpected() _NOEXCEPT
+{
+    return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
+}
+
+_LIBCPP_NORETURN
+void
+unexpected()
+{
+    (*get_unexpected())();
+    // unexpected handler should not return
+    terminate();
+}
+
+terminate_handler
+set_terminate(terminate_handler func) _NOEXCEPT
+{
+    return __sync_lock_test_and_set(&__terminate_handler, func);
+}
+
+terminate_handler
+get_terminate() _NOEXCEPT
+{
+    return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
+}
+
+#ifndef __EMSCRIPTEN__ // We provide this in JS
+_LIBCPP_NORETURN
+void
+terminate() _NOEXCEPT
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        (*get_terminate())();
+        // handler should not return
+        printf("terminate_handler unexpectedly returned\n");
+        ::abort();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        // handler should not throw exception
+        printf("terminate_handler unexpectedly threw an exception\n");
+        ::abort();
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+#endif // !__EMSCRIPTEN__
+#endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
+
+#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)
+bool uncaught_exception() _NOEXCEPT
+{
+#if defined(__APPLE__) || defined(_LIBCPPABI_VERSION)
+    // on Darwin, there is a helper function so __cxa_get_globals is private
+    return __cxa_uncaught_exception();
+#else  // __APPLE__
+#   if defined(_MSC_VER) && ! defined(__clang__)
+        _LIBCPP_WARNING("uncaught_exception not yet implemented")
+#   else
+#       warning uncaught_exception not yet implemented
+#   endif
+    printf("uncaught_exception not yet implemented\n");
+    ::abort();
+#endif  // __APPLE__
+}
+
+
+#ifndef _LIBCPPABI_VERSION
+
+exception::~exception() _NOEXCEPT
+{
+}
+
+const char* exception::what() const _NOEXCEPT
+{
+  return "std::exception";
+}
+
+#endif  // _LIBCPPABI_VERSION
+#endif //LIBCXXRT
+#if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)
+
+bad_exception::~bad_exception() _NOEXCEPT
+{
+}
+
+const char* bad_exception::what() const _NOEXCEPT
+{
+  return "std::bad_exception";
+}
+
+#endif
+
+#if defined(__GLIBCXX__)
+
+// libsupc++ does not implement the dependent EH ABI and the functionality
+// it uses to implement std::exception_ptr (which it declares as an alias of
+// std::__exception_ptr::exception_ptr) is not directly exported to clients. So
+// we have little choice but to hijack std::__exception_ptr::exception_ptr's
+// (which fortunately has the same layout as our std::exception_ptr) copy
+// constructor, assignment operator and destructor (which are part of its
+// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
+// function.
+
+namespace __exception_ptr
+{
+
+struct exception_ptr
+{
+    void* __ptr_;
+
+    exception_ptr(const exception_ptr&) _NOEXCEPT;
+    exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
+    ~exception_ptr() _NOEXCEPT;
+};
+
+}
+
+_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);
+
+#endif
+
+exception_ptr::~exception_ptr() _NOEXCEPT
+{
+#if HAVE_DEPENDENT_EH_ABI
+    __cxa_decrement_exception_refcount(__ptr_);
+#elif defined(__GLIBCXX__)
+    reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr();
+#else
+#   if defined(_MSC_VER) && ! defined(__clang__)
+        _LIBCPP_WARNING("exception_ptr not yet implemented")
+#   else
+#       warning exception_ptr not yet implemented
+#   endif
+    printf("exception_ptr not yet implemented\n");
+    ::abort();
+#endif
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
+    : __ptr_(other.__ptr_)
+{
+#if HAVE_DEPENDENT_EH_ABI
+    __cxa_increment_exception_refcount(__ptr_);
+#elif defined(__GLIBCXX__)
+    new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr(
+        reinterpret_cast<const __exception_ptr::exception_ptr&>(other));
+#else
+#   if defined(_MSC_VER) && ! defined(__clang__)
+        _LIBCPP_WARNING("exception_ptr not yet implemented")
+#   else
+#       warning exception_ptr not yet implemented
+#   endif
+    printf("exception_ptr not yet implemented\n");
+    ::abort();
+#endif
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
+{
+#if HAVE_DEPENDENT_EH_ABI
+    if (__ptr_ != other.__ptr_)
+    {
+        __cxa_increment_exception_refcount(other.__ptr_);
+        __cxa_decrement_exception_refcount(__ptr_);
+        __ptr_ = other.__ptr_;
+    }
+    return *this;
+#elif defined(__GLIBCXX__)
+    *reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
+        reinterpret_cast<const __exception_ptr::exception_ptr&>(other);
+    return *this;
+#else
+#   if defined(_MSC_VER) && ! defined(__clang__)
+        _LIBCPP_WARNING("exception_ptr not yet implemented")
+#   else
+#       warning exception_ptr not yet implemented
+#   endif
+    printf("exception_ptr not yet implemented\n");
+    ::abort();
+#endif
+}
+
+nested_exception::nested_exception() _NOEXCEPT
+    : __ptr_(current_exception())
+{
+}
+
+#if !defined(__GLIBCXX__)
+
+nested_exception::~nested_exception() _NOEXCEPT
+{
+}
+
+#endif
+
+_LIBCPP_NORETURN
+void
+nested_exception::rethrow_nested() const
+{
+    if (__ptr_ == nullptr)
+        terminate();
+    rethrow_exception(__ptr_);
+}
+
+#if !defined(__GLIBCXX__)
+
+exception_ptr current_exception() _NOEXCEPT
+{
+#if HAVE_DEPENDENT_EH_ABI
+    // be nicer if there was a constructor that took a ptr, then
+    // this whole function would be just:
+    //    return exception_ptr(__cxa_current_primary_exception());
+    exception_ptr ptr;
+    ptr.__ptr_ = __cxa_current_primary_exception();
+    return ptr;
+#else
+#   if defined(_MSC_VER) && ! defined(__clang__)
+        _LIBCPP_WARNING( "exception_ptr not yet implemented" )
+#   else
+#       warning exception_ptr not yet implemented
+#   endif
+    printf("exception_ptr not yet implemented\n");
+    ::abort();
+#endif
+}
+
+#endif  // !__GLIBCXX__
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p)
+{
+#if HAVE_DEPENDENT_EH_ABI
+    __cxa_rethrow_primary_exception(p.__ptr_);
+    // if p.__ptr_ is NULL, above returns so we terminate
+    terminate();
+#elif defined(__GLIBCXX__)
+    rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));
+#else
+#   if defined(_MSC_VER) && ! defined(__clang__)
+        _LIBCPP_WARNING("exception_ptr not yet implemented")
+#   else
+#       warning exception_ptr not yet implemented
+#   endif
+    printf("exception_ptr not yet implemented\n");
+    ::abort();
+#endif
+}
+} // std
diff --git a/final/src/future.cpp b/final/src/future.cpp
new file mode 100644
index 0000000..c67dc58
--- /dev/null
+++ b/final/src/future.cpp
@@ -0,0 +1,300 @@
+//===------------------------- future.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 "future"
+#include "string"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+class _LIBCPP_HIDDEN __future_error_category
+    : public __do_message
+{
+public:
+    virtual const char* name() const _NOEXCEPT;
+    virtual string message(int ev) const;
+};
+
+const char*
+__future_error_category::name() const _NOEXCEPT
+{
+    return "future";
+}
+
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wswitch"
+#elif defined(__GNUC__) || defined(__GNUG__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+#endif
+
+string
+__future_error_category::message(int ev) const
+{
+    switch (static_cast<future_errc>(ev))
+    {
+    case future_errc(0):  // For backwards compatibility with C++11 (LWG 2056)
+    case future_errc::broken_promise:
+        return string("The associated promise has been destructed prior "
+                      "to the associated state becoming ready.");
+    case future_errc::future_already_retrieved:
+        return string("The future has already been retrieved from "
+                      "the promise or packaged_task.");
+    case future_errc::promise_already_satisfied:
+        return string("The state of the promise has already been set.");
+    case future_errc::no_state:
+        return string("Operation not permitted on an object without "
+                      "an associated state.");
+    }
+    return string("unspecified future_errc value\n");
+}
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#elif defined(__GNUC__) || defined(__GNUG__)
+#pragma GCC diagnostic pop
+#endif
+
+const error_category&
+future_category() _NOEXCEPT
+{
+    static __future_error_category __f;
+    return __f;
+}
+
+future_error::future_error(error_code __ec)
+    : logic_error(__ec.message()),
+      __ec_(__ec)
+{
+}
+
+future_error::~future_error() _NOEXCEPT
+{
+}
+
+void
+__assoc_sub_state::__on_zero_shared() _NOEXCEPT
+{
+    delete this;
+}
+
+void
+__assoc_sub_state::set_value()
+{
+    unique_lock<mutex> __lk(__mut_);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+#endif
+    __state_ |= __constructed | ready;
+    __cv_.notify_all();
+    __lk.unlock();
+}
+
+void
+__assoc_sub_state::set_value_at_thread_exit()
+{
+    unique_lock<mutex> __lk(__mut_);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+#endif
+    __state_ |= __constructed;
+    __thread_local_data()->__make_ready_at_thread_exit(this);
+    __lk.unlock();
+}
+
+void
+__assoc_sub_state::set_exception(exception_ptr __p)
+{
+    unique_lock<mutex> __lk(__mut_);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+#endif
+    __exception_ = __p;
+    __state_ |= ready;
+    __lk.unlock();
+    __cv_.notify_all();
+}
+
+void
+__assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p)
+{
+    unique_lock<mutex> __lk(__mut_);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__has_value())
+        throw future_error(make_error_code(future_errc::promise_already_satisfied));
+#endif
+    __exception_ = __p;
+    __thread_local_data()->__make_ready_at_thread_exit(this);
+    __lk.unlock();
+}
+
+void
+__assoc_sub_state::__make_ready()
+{
+    unique_lock<mutex> __lk(__mut_);
+    __state_ |= ready;
+    __lk.unlock();
+    __cv_.notify_all();
+}
+
+void
+__assoc_sub_state::copy()
+{
+    unique_lock<mutex> __lk(__mut_);
+    __sub_wait(__lk);
+    if (__exception_ != nullptr)
+        rethrow_exception(__exception_);
+}
+
+void
+__assoc_sub_state::wait()
+{
+    unique_lock<mutex> __lk(__mut_);
+    __sub_wait(__lk);
+}
+
+void
+__assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk)
+{
+    if (!__is_ready())
+    {
+        if (__state_ & static_cast<unsigned>(deferred))
+        {
+            __state_ &= ~static_cast<unsigned>(deferred);
+            __lk.unlock();
+            __execute();
+        }
+        else
+            while (!__is_ready())
+                __cv_.wait(__lk);
+    }
+}
+
+void
+__assoc_sub_state::__execute()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw future_error(make_error_code(future_errc::no_state));
+#endif
+}
+
+future<void>::future(__assoc_sub_state* __state)
+    : __state_(__state)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__state_->__has_future_attached())
+        throw future_error(make_error_code(future_errc::future_already_retrieved));
+#endif
+    __state_->__add_shared();
+    __state_->__set_future_attached();
+}
+
+future<void>::~future()
+{
+    if (__state_)
+        __state_->__release_shared();
+}
+
+void
+future<void>::get()
+{
+    unique_ptr<__shared_count, __release_shared_count> __(__state_);
+    __assoc_sub_state* __s = __state_;
+    __state_ = nullptr;
+    __s->copy();
+}
+
+promise<void>::promise()
+    : __state_(new __assoc_sub_state)
+{
+}
+
+promise<void>::~promise()
+{
+    if (__state_)
+    {
+        if (!__state_->__has_value() && __state_->use_count() > 1)
+            __state_->set_exception(make_exception_ptr(
+                      future_error(make_error_code(future_errc::broken_promise))
+                                                      ));
+        __state_->__release_shared();
+    }
+}
+
+future<void>
+promise<void>::get_future()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__state_ == nullptr)
+        throw future_error(make_error_code(future_errc::no_state));
+#endif
+    return future<void>(__state_);
+}
+
+void
+promise<void>::set_value()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__state_ == nullptr)
+        throw future_error(make_error_code(future_errc::no_state));
+#endif
+    __state_->set_value();
+}
+
+void
+promise<void>::set_exception(exception_ptr __p)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__state_ == nullptr)
+        throw future_error(make_error_code(future_errc::no_state));
+#endif
+    __state_->set_exception(__p);
+}
+
+void
+promise<void>::set_value_at_thread_exit()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__state_ == nullptr)
+        throw future_error(make_error_code(future_errc::no_state));
+#endif
+    __state_->set_value_at_thread_exit();
+}
+
+void
+promise<void>::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
+    __state_->set_exception_at_thread_exit(__p);
+}
+
+shared_future<void>::~shared_future()
+{
+    if (__state_)
+        __state_->__release_shared();
+}
+
+shared_future<void>&
+shared_future<void>::operator=(const shared_future& __rhs)
+{
+    if (__rhs.__state_)
+        __rhs.__state_->__add_shared();
+    if (__state_)
+        __state_->__release_shared();
+    __state_ = __rhs.__state_;
+    return *this;
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/hash.cpp b/final/src/hash.cpp
new file mode 100644
index 0000000..dc90f78
--- /dev/null
+++ b/final/src/hash.cpp
@@ -0,0 +1,570 @@
+//===-------------------------- hash.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 "__hash_table"
+#include "algorithm"
+#include "stdexcept"
+#include "type_traits"
+
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace {
+
+// handle all next_prime(i) for i in [1, 210), special case 0
+const unsigned small_primes[] =
+{
+    0,
+    2,
+    3,
+    5,
+    7,
+    11,
+    13,
+    17,
+    19,
+    23,
+    29,
+    31,
+    37,
+    41,
+    43,
+    47,
+    53,
+    59,
+    61,
+    67,
+    71,
+    73,
+    79,
+    83,
+    89,
+    97,
+    101,
+    103,
+    107,
+    109,
+    113,
+    127,
+    131,
+    137,
+    139,
+    149,
+    151,
+    157,
+    163,
+    167,
+    173,
+    179,
+    181,
+    191,
+    193,
+    197,
+    199,
+    211
+};
+
+// potential primes = 210*k + indices[i], k >= 1
+//   these numbers are not divisible by 2, 3, 5 or 7
+//   (or any integer 2 <= j <= 10 for that matter).
+const unsigned indices[] =
+{
+    1,
+    11,
+    13,
+    17,
+    19,
+    23,
+    29,
+    31,
+    37,
+    41,
+    43,
+    47,
+    53,
+    59,
+    61,
+    67,
+    71,
+    73,
+    79,
+    83,
+    89,
+    97,
+    101,
+    103,
+    107,
+    109,
+    113,
+    121,
+    127,
+    131,
+    137,
+    139,
+    143,
+    149,
+    151,
+    157,
+    163,
+    167,
+    169,
+    173,
+    179,
+    181,
+    187,
+    191,
+    193,
+    197,
+    199,
+    209
+};
+
+}
+
+// Returns:  If n == 0, returns 0.  Else returns the lowest prime number that
+// is greater than or equal to n.
+//
+// The algorithm creates a list of small primes, plus an open-ended list of
+// potential primes.  All prime numbers are potential prime numbers.  However
+// some potential prime numbers are not prime.  In an ideal world, all potential
+// prime numbers would be prime.  Candidate prime numbers are chosen as the next
+// highest potential prime.  Then this number is tested for prime by dividing it
+// by all potential prime numbers less than the sqrt of the candidate.
+//
+// This implementation defines potential primes as those numbers not divisible
+// by 2, 3, 5, and 7.  Other (common) implementations define potential primes
+// as those not divisible by 2.  A few other implementations define potential
+// primes as those not divisible by 2 or 3.  By raising the number of small
+// primes which the potential prime is not divisible by, the set of potential
+// primes more closely approximates the set of prime numbers.  And thus there
+// are fewer potential primes to search, and fewer potential primes to divide
+// against.
+
+template <size_t _Sz = sizeof(size_t)>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<_Sz == 4, void>::type
+__check_for_overflow(size_t N)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (N > 0xFFFFFFFB)
+        throw overflow_error("__next_prime overflow");
+#else
+    (void)N;
+#endif
+}
+
+template <size_t _Sz = sizeof(size_t)>
+inline _LIBCPP_INLINE_VISIBILITY
+typename enable_if<_Sz == 8, void>::type
+__check_for_overflow(size_t N)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (N > 0xFFFFFFFFFFFFFFC5ull)
+        throw overflow_error("__next_prime overflow");
+#else
+    (void)N;
+#endif
+}
+
+size_t
+__next_prime(size_t n)
+{
+    const size_t L = 210;
+    const size_t N = sizeof(small_primes) / sizeof(small_primes[0]);
+    // If n is small enough, search in small_primes
+    if (n <= small_primes[N-1])
+        return *std::lower_bound(small_primes, small_primes + N, n);
+    // Else n > largest small_primes
+    // Check for overflow
+    __check_for_overflow(n);
+    // Start searching list of potential primes: L * k0 + indices[in]
+    const size_t M = sizeof(indices) / sizeof(indices[0]);
+    // Select first potential prime >= n
+    //   Known a-priori n >= L
+    size_t k0 = n / L;
+    size_t in = static_cast<size_t>(std::lower_bound(indices, indices + M, n - k0 * L)
+                                    - indices);
+    n = L * k0 + indices[in];
+    while (true)
+    {
+        // Divide n by all primes or potential primes (i) until:
+        //    1.  The division is even, so try next potential prime.
+        //    2.  The i > sqrt(n), in which case n is prime.
+        // It is known a-priori that n is not divisible by 2, 3, 5 or 7,
+        //    so don't test those (j == 5 ->  divide by 11 first).  And the
+        //    potential primes start with 211, so don't test against the last
+        //    small prime.
+        for (size_t j = 5; j < N - 1; ++j)
+        {
+            const std::size_t p = small_primes[j];
+            const std::size_t q = n / p;
+            if (q < p)
+                return n;
+            if (n == q * p)
+                goto next;
+        }
+        // n wasn't divisible by small primes, try potential primes
+        {
+            size_t i = 211;
+            while (true)
+            {
+                std::size_t q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 10;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 8;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 8;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 6;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 4;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 2;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                i += 10;
+                q = n / i;
+                if (q < i)
+                    return n;
+                if (n == q * i)
+                    break;
+
+                // This will loop i to the next "plane" of potential primes
+                i += 2;
+            }
+        }
+next:
+        // n is not prime.  Increment n to next potential prime.
+        if (++in == M)
+        {
+            ++k0;
+            in = 0;
+        }
+        n = L * k0 + indices[in];
+    }
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/ios.cpp b/final/src/ios.cpp
new file mode 100644
index 0000000..e241394
--- /dev/null
+++ b/final/src/ios.cpp
@@ -0,0 +1,471 @@
+//===-------------------------- ios.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+
+#include "ios"
+#include "streambuf"
+#include "istream"
+#include "string"
+#include "__locale"
+#include "algorithm"
+#include "memory"
+#include "new"
+#include "limits"
+#include <stdlib.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template class basic_ios<char>;
+template class basic_ios<wchar_t>;
+
+template class basic_streambuf<char>;
+template class basic_streambuf<wchar_t>;
+
+template class basic_istream<char>;
+template class basic_istream<wchar_t>;
+
+template class basic_ostream<char>;
+template class basic_ostream<wchar_t>;
+
+template class basic_iostream<char>;
+
+class _LIBCPP_HIDDEN __iostream_category
+    : public __do_message
+{
+public:
+    virtual const char* name() const _NOEXCEPT;
+    virtual string message(int ev) const;
+};
+
+const char*
+__iostream_category::name() const _NOEXCEPT
+{
+    return "iostream";
+}
+
+string
+__iostream_category::message(int ev) const
+{
+    if (ev != static_cast<int>(io_errc::stream)
+#ifdef ELAST
+        && ev <= ELAST
+#elif defined(__linux__)
+        && ev <= 4095
+#endif  // ELAST
+        )
+        return __do_message::message(ev);
+    return string("unspecified iostream_category error");
+}
+
+const error_category&
+iostream_category() _NOEXCEPT
+{
+    static __iostream_category s;
+    return s;
+}
+
+// ios_base::failure
+
+ios_base::failure::failure(const string& msg, const error_code& ec)
+    : system_error(ec, msg)
+{
+}
+
+ios_base::failure::failure(const char* msg, const error_code& ec)
+    : system_error(ec, msg)
+{
+}
+
+ios_base::failure::~failure() throw()
+{
+}
+
+// ios_base locale
+
+const ios_base::fmtflags ios_base::boolalpha;
+const ios_base::fmtflags ios_base::dec;
+const ios_base::fmtflags ios_base::fixed;
+const ios_base::fmtflags ios_base::hex;
+const ios_base::fmtflags ios_base::internal;
+const ios_base::fmtflags ios_base::left;
+const ios_base::fmtflags ios_base::oct;
+const ios_base::fmtflags ios_base::right;
+const ios_base::fmtflags ios_base::scientific;
+const ios_base::fmtflags ios_base::showbase;
+const ios_base::fmtflags ios_base::showpoint;
+const ios_base::fmtflags ios_base::showpos;
+const ios_base::fmtflags ios_base::skipws;
+const ios_base::fmtflags ios_base::unitbuf;
+const ios_base::fmtflags ios_base::uppercase;
+const ios_base::fmtflags ios_base::adjustfield;
+const ios_base::fmtflags ios_base::basefield;
+const ios_base::fmtflags ios_base::floatfield;
+
+const ios_base::iostate ios_base::badbit;
+const ios_base::iostate ios_base::eofbit;
+const ios_base::iostate ios_base::failbit;
+const ios_base::iostate ios_base::goodbit;
+
+const ios_base::openmode ios_base::app;
+const ios_base::openmode ios_base::ate;
+const ios_base::openmode ios_base::binary;
+const ios_base::openmode ios_base::in;
+const ios_base::openmode ios_base::out;
+const ios_base::openmode ios_base::trunc;
+
+void
+ios_base::__call_callbacks(event ev)
+{
+    for (size_t i = __event_size_; i;)
+    {
+        --i;
+        __fn_[i](ev, *this, __index_[i]);
+    }
+}
+
+// locale
+
+locale
+ios_base::imbue(const locale& newloc)
+{
+    static_assert(sizeof(locale) == sizeof(__loc_), "");
+    locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
+    locale oldloc = loc_storage;
+    loc_storage = newloc;
+    __call_callbacks(imbue_event);
+    return oldloc;
+}
+
+locale
+ios_base::getloc() const
+{
+    const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
+    return loc_storage;
+}
+
+// xalloc
+#if __has_feature(cxx_atomic)
+atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0);
+#else
+int ios_base::__xindex_ = 0;
+#endif
+
+int
+ios_base::xalloc()
+{
+    return __xindex_++;
+}
+
+long&
+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));
+        if (iarray == 0)
+        {
+            setstate(badbit);
+            static long error;
+            error = 0;
+            return error;
+        }
+        __iarray_ = iarray;
+        for (long* p = __iarray_ + __iarray_size_; __iarray_cap_ < newcap; ++__iarray_cap_, ++p)
+            *p = 0;
+    }
+    __iarray_size_ = max<size_t>(__iarray_size_, req_size);
+    return __iarray_[index];
+}
+
+void*&
+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));
+        if (parray == 0)
+        {
+            setstate(badbit);
+            static void* error;
+            error = 0;
+            return error;
+        }
+        __parray_ = parray;
+        for (void** p = __parray_ + __parray_size_; __parray_cap_ < newcap; ++__parray_cap_, ++p)
+            *p = 0;
+    }
+    __parray_size_ = max<size_t>(__parray_size_, req_size);
+    return __parray_[index];
+}
+
+// register_callback
+
+void
+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));
+        if (fns == 0)
+            setstate(badbit);
+        __fn_ = fns;
+        size_t newisize = newcap * sizeof(int);
+        int* indxs = static_cast<int *>(realloc(__index_, newisize));
+        if (indxs == 0)
+            setstate(badbit);
+        __index_ = indxs;
+    }
+    __fn_[__event_size_] = fn;
+    __index_[__event_size_] = index;
+    ++__event_size_;
+}
+
+ios_base::~ios_base()
+{
+    __call_callbacks(erase_event);
+    locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
+    loc_storage.~locale();
+    free(__fn_);
+    free(__index_);
+    free(__iarray_);
+    free(__parray_);
+}
+
+// iostate
+
+void
+ios_base::clear(iostate state)
+{
+    if (__rdbuf_)
+        __rdstate_ = state;
+    else
+        __rdstate_ = state | badbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
+        throw failure("ios_base::clear");
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+// init
+
+void
+ios_base::init(void* sb)
+{
+    __rdbuf_ = sb;
+    __rdstate_ = __rdbuf_ ? goodbit : badbit;
+    __exceptions_ = goodbit;
+    __fmtflags_ = skipws | dec;
+    __width_ = 0;
+    __precision_ = 6;
+    __fn_ = 0;
+    __index_ = 0;
+    __event_size_ = 0;
+    __event_cap_ = 0;
+    __iarray_ = 0;
+    __iarray_size_ = 0;
+    __iarray_cap_ = 0;
+    __parray_ = 0;
+    __parray_size_ = 0;
+    __parray_cap_ = 0;
+    ::new(&__loc_) locale;
+}
+
+void
+ios_base::copyfmt(const ios_base& rhs)
+{
+    // If we can't acquire the needed resources, throw bad_alloc (can't set badbit)
+    // Don't alter *this until all needed resources are acquired
+    unique_ptr<event_callback, void (*)(void*)> new_callbacks(0, free);
+    unique_ptr<int, void (*)(void*)> new_ints(0, free);
+    unique_ptr<long, void (*)(void*)> new_longs(0, free);
+    unique_ptr<void*, void (*)(void*)> new_pointers(0, free);
+    if (__event_cap_ < rhs.__event_size_)
+    {
+        size_t newesize = sizeof(event_callback) * rhs.__event_size_;
+        new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (!new_callbacks)
+            throw bad_alloc();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+
+        size_t newisize = sizeof(int) * rhs.__event_size_;
+        new_ints.reset(static_cast<int *>(malloc(newisize)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (!new_ints)
+            throw bad_alloc();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+    if (__iarray_cap_ < rhs.__iarray_size_)
+    {
+        size_t newsize = sizeof(long) * rhs.__iarray_size_;
+        new_longs.reset(static_cast<long*>(malloc(newsize)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (!new_longs)
+            throw bad_alloc();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+    if (__parray_cap_ < rhs.__parray_size_)
+    {
+        size_t newsize = sizeof(void*) * rhs.__parray_size_;
+        new_pointers.reset(static_cast<void**>(malloc(newsize)));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (!new_pointers)
+            throw bad_alloc();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+    // Got everything we need.  Copy everything but __rdstate_, __rdbuf_ and __exceptions_
+    __fmtflags_ = rhs.__fmtflags_;
+    __precision_ = rhs.__precision_;
+    __width_ = rhs.__width_;
+    locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+    const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
+    lhs_loc = rhs_loc;
+    if (__event_cap_ < rhs.__event_size_)
+    {
+        free(__fn_);
+        __fn_ = new_callbacks.release();
+        free(__index_);
+        __index_ = new_ints.release();
+        __event_cap_ = rhs.__event_size_;
+    }
+    for (__event_size_ = 0; __event_size_ < rhs.__event_size_; ++__event_size_)
+    {
+        __fn_[__event_size_] = rhs.__fn_[__event_size_];
+        __index_[__event_size_] = rhs.__index_[__event_size_];
+    }
+    if (__iarray_cap_ < rhs.__iarray_size_)
+    {
+        free(__iarray_);
+        __iarray_ = new_longs.release();
+        __iarray_cap_ = rhs.__iarray_size_;
+    }
+    for (__iarray_size_ = 0; __iarray_size_ < rhs.__iarray_size_; ++__iarray_size_)
+        __iarray_[__iarray_size_] = rhs.__iarray_[__iarray_size_];
+    if (__parray_cap_ < rhs.__parray_size_)
+    {
+        free(__parray_);
+        __parray_ = new_pointers.release();
+        __parray_cap_ = rhs.__parray_size_;
+    }
+    for (__parray_size_ = 0; __parray_size_ < rhs.__parray_size_; ++__parray_size_)
+        __parray_[__parray_size_] = rhs.__parray_[__parray_size_];
+}
+
+void
+ios_base::move(ios_base& rhs)
+{
+    // *this is uninitialized
+    __fmtflags_ = rhs.__fmtflags_;
+    __precision_ = rhs.__precision_;
+    __width_ = rhs.__width_;
+    __rdstate_ = rhs.__rdstate_;
+    __exceptions_ = rhs.__exceptions_;
+    __rdbuf_ = 0;
+    locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
+    ::new(&__loc_) locale(rhs_loc);
+    __fn_ = rhs.__fn_;
+    rhs.__fn_ = 0;
+    __index_ = rhs.__index_;
+    rhs.__index_ = 0;
+    __event_size_ = rhs.__event_size_;
+    rhs.__event_size_ = 0;
+    __event_cap_ = rhs.__event_cap_;
+    rhs.__event_cap_ = 0;
+    __iarray_ = rhs.__iarray_;
+    rhs.__iarray_ = 0;
+    __iarray_size_ = rhs.__iarray_size_;
+    rhs.__iarray_size_ = 0;
+    __iarray_cap_ = rhs.__iarray_cap_;
+    rhs.__iarray_cap_ = 0;
+    __parray_ = rhs.__parray_;
+    rhs.__parray_ = 0;
+    __parray_size_ = rhs.__parray_size_;
+    rhs.__parray_size_ = 0;
+    __parray_cap_ = rhs.__parray_cap_;
+    rhs.__parray_cap_ = 0;
+}
+
+void
+ios_base::swap(ios_base& rhs) _NOEXCEPT
+{
+    _VSTD::swap(__fmtflags_, rhs.__fmtflags_);
+    _VSTD::swap(__precision_, rhs.__precision_);
+    _VSTD::swap(__width_, rhs.__width_);
+    _VSTD::swap(__rdstate_, rhs.__rdstate_);
+    _VSTD::swap(__exceptions_, rhs.__exceptions_);
+    locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+    locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
+    _VSTD::swap(lhs_loc, rhs_loc);
+    _VSTD::swap(__fn_, rhs.__fn_);
+    _VSTD::swap(__index_, rhs.__index_);
+    _VSTD::swap(__event_size_, rhs.__event_size_);
+    _VSTD::swap(__event_cap_, rhs.__event_cap_);
+    _VSTD::swap(__iarray_, rhs.__iarray_);
+    _VSTD::swap(__iarray_size_, rhs.__iarray_size_);
+    _VSTD::swap(__iarray_cap_, rhs.__iarray_cap_);
+    _VSTD::swap(__parray_, rhs.__parray_);
+    _VSTD::swap(__parray_size_, rhs.__parray_size_);
+    _VSTD::swap(__parray_cap_, rhs.__parray_cap_);
+}
+
+void
+ios_base::__set_badbit_and_consider_rethrow()
+{
+    __rdstate_ |= badbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__exceptions_ & badbit)
+        throw;
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+void
+ios_base::__set_failbit_and_consider_rethrow()
+{
+    __rdstate_ |= failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__exceptions_ & failbit)
+        throw;
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+bool
+ios_base::sync_with_stdio(bool sync)
+{
+    static bool previous_state = true;
+    bool r = previous_state;
+    previous_state = sync;
+    return r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/iostream.cpp b/final/src/iostream.cpp
new file mode 100644
index 0000000..7102e43
--- /dev/null
+++ b/final/src/iostream.cpp
@@ -0,0 +1,68 @@
+//===------------------------ iostream.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 "__std_stream"
+#include "string"
+#include "new"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static mbstate_t state_types[6] = {};
+
+_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>)];
+_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>)];
+
+_ALIGNAS_TYPE (istream)  _LIBCPP_FUNC_VIS char cin [sizeof(istream)];
+_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 (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)];
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)];
+_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)];
+
+ios_base::Init __start_std_streams;
+
+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));
+                        ::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));
+                          ::new(wclog) wostream(wcerr_ptr->rdbuf());
+    wcin_ptr->tie(wcout_ptr);
+    _VSTD::unitbuf(*wcerr_ptr);
+    wcerr_ptr->tie(wcout_ptr);
+}
+
+ios_base::Init::~Init()
+{
+    ostream* cout_ptr = reinterpret_cast<ostream*>(cout);
+    ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
+    cout_ptr->flush();
+    clog_ptr->flush();
+
+    wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
+    wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
+    wcout_ptr->flush();
+    wclog_ptr->flush();
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/locale.cpp b/final/src/locale.cpp
new file mode 100644
index 0000000..fc314ca
--- /dev/null
+++ b/final/src/locale.cpp
@@ -0,0 +1,6171 @@
+//===------------------------- locale.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+
+// On Solaris, we need to define something to make the C99 parts of localeconv
+// visible.
+#ifdef __sun__
+#define _LCONV_C99
+#endif
+
+#include "string"
+#include "locale"
+#include "codecvt"
+#include "vector"
+#include "algorithm"
+#include "typeinfo"
+#ifndef _LIBCPP_NO_EXCEPTIONS
+#  include "type_traits"
+#endif
+#include "clocale"
+#include "cstring"
+#include "cwctype"
+#include "__sso_allocator"
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#include <support/win32/locale_win32.h>
+#elif !defined(__ANDROID__)
+#include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+
+// On Linux, wint_t and wchar_t have different signed-ness, and this causes
+// lots of noise in the build log, but no bugs that I know of. 
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#ifdef __cloc_defined
+locale_t __cloc() {
+  // In theory this could create a race condition. In practice
+  // the race condition is non-fatal since it will just create
+  // a little resource leak. Better approach would be appreciated.
+  static locale_t result = newlocale(LC_ALL_MASK, "C", 0);
+  return result;
+}
+#endif // __cloc_defined
+
+namespace {
+
+struct release
+{
+    void operator()(locale::facet* p) {p->__release_shared();}
+};
+
+template <class T, class A0>
+inline
+T&
+make(A0 a0)
+{
+    static typename aligned_storage<sizeof(T)>::type buf;
+    ::new (&buf) T(a0);
+    return *reinterpret_cast<T*>(&buf);
+}
+
+template <class T, class A0, class A1>
+inline
+T&
+make(A0 a0, A1 a1)
+{
+    static typename aligned_storage<sizeof(T)>::type buf;
+    ::new (&buf) T(a0, a1);
+    return *reinterpret_cast<T*>(&buf);
+}
+
+template <class T, class A0, class A1, class A2>
+inline
+T&
+make(A0 a0, A1 a1, A2 a2)
+{
+    static typename aligned_storage<sizeof(T)>::type buf;
+    ::new (&buf) T(a0, a1, a2);
+    return *reinterpret_cast<T*>(&buf);
+}
+
+template <typename T, size_t N>
+inline
+_LIBCPP_CONSTEXPR
+size_t
+countof(const T (&)[N])
+{
+    return N;
+}
+
+template <typename T>
+inline
+_LIBCPP_CONSTEXPR
+size_t
+countof(const T * const begin, const T * const end)
+{
+    return static_cast<size_t>(end - begin);
+}
+
+}
+
+#if defined(_AIX)
+// Set priority to INT_MIN + 256 + 150
+# pragma priority ( -2147483242 )
+#endif
+
+const locale::category locale::none;
+const locale::category locale::collate;
+const locale::category locale::ctype;
+const locale::category locale::monetary;
+const locale::category locale::numeric;
+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
+{
+    enum {N = 28};
+#if defined(_LIBCPP_MSVC)
+// FIXME: MSVC doesn't support aligned parameters by value.
+// I can't get the __sso_allocator to work here
+// for MSVC I think for this reason.
+    vector<facet*> facets_;
+#else
+    vector<facet*, __sso_allocator<facet*, N> > facets_;
+#endif
+    string         name_;
+public:
+    explicit __imp(size_t refs = 0);
+    explicit __imp(const string& name, size_t refs = 0);
+    __imp(const __imp&);
+    __imp(const __imp&, const string&, locale::category c);
+    __imp(const __imp& other, const __imp& one, locale::category c);
+    __imp(const __imp&, facet* f, long id);
+    ~__imp();
+
+    const string& name() const {return name_;}
+    bool has_facet(long id) const
+        {return static_cast<size_t>(id) < facets_.size() && facets_[static_cast<size_t>(id)];}
+    const locale::facet* use_facet(long id) const;
+
+    static const locale& make_classic();
+    static       locale& make_global();
+private:
+    void install(facet* f, long id);
+    template <class F> void install(F* f) {install(f, f->id.__get());}
+    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),
+      name_("C")
+{
+    facets_.clear();
+    install(&make<_VSTD::collate<char> >(1u));
+    install(&make<_VSTD::collate<wchar_t> >(1u));
+    install(&make<_VSTD::ctype<char> >(nullptr, false, 1u));
+    install(&make<_VSTD::ctype<wchar_t> >(1u));
+    install(&make<codecvt<char, char, mbstate_t> >(1u));
+    install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
+    install(&make<codecvt<char16_t, char, mbstate_t> >(1u));
+    install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
+    install(&make<numpunct<char> >(1u));
+    install(&make<numpunct<wchar_t> >(1u));
+    install(&make<num_get<char> >(1u));
+    install(&make<num_get<wchar_t> >(1u));
+    install(&make<num_put<char> >(1u));
+    install(&make<num_put<wchar_t> >(1u));
+    install(&make<moneypunct<char, false> >(1u));
+    install(&make<moneypunct<char, true> >(1u));
+    install(&make<moneypunct<wchar_t, false> >(1u));
+    install(&make<moneypunct<wchar_t, true> >(1u));
+    install(&make<money_get<char> >(1u));
+    install(&make<money_get<wchar_t> >(1u));
+    install(&make<money_put<char> >(1u));
+    install(&make<money_put<wchar_t> >(1u));
+    install(&make<time_get<char> >(1u));
+    install(&make<time_get<wchar_t> >(1u));
+    install(&make<time_put<char> >(1u));
+    install(&make<time_put<wchar_t> >(1u));
+    install(&make<_VSTD::messages<char> >(1u));
+    install(&make<_VSTD::messages<wchar_t> >(1u));
+}
+
+locale::__imp::__imp(const string& name, size_t refs)
+    : facet(refs),
+      facets_(N),
+      name_(name)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        facets_ = locale::classic().__locale_->facets_;
+        for (unsigned i = 0; i < facets_.size(); ++i)
+            if (facets_[i])
+                facets_[i]->__add_shared();
+        install(new collate_byname<char>(name_));
+        install(new collate_byname<wchar_t>(name_));
+        install(new ctype_byname<char>(name_));
+        install(new ctype_byname<wchar_t>(name_));
+        install(new codecvt_byname<char, char, mbstate_t>(name_));
+        install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));
+        install(new codecvt_byname<char16_t, char, mbstate_t>(name_));
+        install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
+        install(new numpunct_byname<char>(name_));
+        install(new numpunct_byname<wchar_t>(name_));
+        install(new moneypunct_byname<char, false>(name_));
+        install(new moneypunct_byname<char, true>(name_));
+        install(new moneypunct_byname<wchar_t, false>(name_));
+        install(new moneypunct_byname<wchar_t, true>(name_));
+        install(new time_get_byname<char>(name_));
+        install(new time_get_byname<wchar_t>(name_));
+        install(new time_put_byname<char>(name_));
+        install(new time_put_byname<wchar_t>(name_));
+        install(new messages_byname<char>(name_));
+        install(new messages_byname<wchar_t>(name_));
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        for (unsigned i = 0; i < facets_.size(); ++i)
+            if (facets_[i])
+                facets_[i]->__release_shared();
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+// NOTE avoid the `base class should be explicitly initialized in the
+// copy constructor` warning emitted by GCC
+#if defined(__clang__) || _GNUC_VER >= 406
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wextra"
+#endif
+
+locale::__imp::__imp(const __imp& other)
+    : facets_(max<size_t>(N, other.facets_.size())),
+      name_(other.name_)
+{
+    facets_ = other.facets_;
+    for (unsigned i = 0; i < facets_.size(); ++i)
+        if (facets_[i])
+            facets_[i]->__add_shared();
+}
+
+#if defined(__clang__) || _GNUC_VER >= 406
+#pragma GCC diagnostic pop
+#endif
+
+locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
+    : facets_(N),
+      name_("*")
+{
+    facets_ = other.facets_;
+    for (unsigned i = 0; i < facets_.size(); ++i)
+        if (facets_[i])
+            facets_[i]->__add_shared();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        if (c & locale::collate)
+        {
+            install(new collate_byname<char>(name));
+            install(new collate_byname<wchar_t>(name));
+        }
+        if (c & locale::ctype)
+        {
+            install(new ctype_byname<char>(name));
+            install(new ctype_byname<wchar_t>(name));
+            install(new codecvt_byname<char, char, mbstate_t>(name));
+            install(new codecvt_byname<wchar_t, char, mbstate_t>(name));
+            install(new codecvt_byname<char16_t, char, mbstate_t>(name));
+            install(new codecvt_byname<char32_t, char, mbstate_t>(name));
+        }
+        if (c & locale::monetary)
+        {
+            install(new moneypunct_byname<char, false>(name));
+            install(new moneypunct_byname<char, true>(name));
+            install(new moneypunct_byname<wchar_t, false>(name));
+            install(new moneypunct_byname<wchar_t, true>(name));
+        }
+        if (c & locale::numeric)
+        {
+            install(new numpunct_byname<char>(name));
+            install(new numpunct_byname<wchar_t>(name));
+        }
+        if (c & locale::time)
+        {
+            install(new time_get_byname<char>(name));
+            install(new time_get_byname<wchar_t>(name));
+            install(new time_put_byname<char>(name));
+            install(new time_put_byname<wchar_t>(name));
+        }
+        if (c & locale::messages)
+        {
+            install(new messages_byname<char>(name));
+            install(new messages_byname<wchar_t>(name));
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        for (unsigned i = 0; i < facets_.size(); ++i)
+            if (facets_[i])
+                facets_[i]->__release_shared();
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+template<class F>
+inline
+void
+locale::__imp::install_from(const locale::__imp& one)
+{
+    long id = F::id.__get();
+    install(const_cast<F*>(static_cast<const F*>(one.use_facet(id))), id);
+}
+
+locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
+    : facets_(N),
+      name_("*")
+{
+    facets_ = other.facets_;
+    for (unsigned i = 0; i < facets_.size(); ++i)
+        if (facets_[i])
+            facets_[i]->__add_shared();
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        if (c & locale::collate)
+        {
+            install_from<_VSTD::collate<char> >(one);
+            install_from<_VSTD::collate<wchar_t> >(one);
+        }
+        if (c & locale::ctype)
+        {
+            install_from<_VSTD::ctype<char> >(one);
+            install_from<_VSTD::ctype<wchar_t> >(one);
+            install_from<_VSTD::codecvt<char, char, mbstate_t> >(one);
+            install_from<_VSTD::codecvt<char16_t, char, mbstate_t> >(one);
+            install_from<_VSTD::codecvt<char32_t, char, mbstate_t> >(one);
+            install_from<_VSTD::codecvt<wchar_t, char, mbstate_t> >(one);
+        }
+        if (c & locale::monetary)
+        {
+            install_from<moneypunct<char, false> >(one);
+            install_from<moneypunct<char, true> >(one);
+            install_from<moneypunct<wchar_t, false> >(one);
+            install_from<moneypunct<wchar_t, true> >(one);
+            install_from<money_get<char> >(one);
+            install_from<money_get<wchar_t> >(one);
+            install_from<money_put<char> >(one);
+            install_from<money_put<wchar_t> >(one);
+        }
+        if (c & locale::numeric)
+        {
+            install_from<numpunct<char> >(one);
+            install_from<numpunct<wchar_t> >(one);
+            install_from<num_get<char> >(one);
+            install_from<num_get<wchar_t> >(one);
+            install_from<num_put<char> >(one);
+            install_from<num_put<wchar_t> >(one);
+        }
+        if (c & locale::time)
+        {
+            install_from<time_get<char> >(one);
+            install_from<time_get<wchar_t> >(one);
+            install_from<time_put<char> >(one);
+            install_from<time_put<wchar_t> >(one);
+        }
+        if (c & locale::messages)
+        {
+            install_from<_VSTD::messages<char> >(one);
+            install_from<_VSTD::messages<wchar_t> >(one);
+        }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+        for (unsigned i = 0; i < facets_.size(); ++i)
+            if (facets_[i])
+                facets_[i]->__release_shared();
+        throw;
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+locale::__imp::__imp(const __imp& other, facet* f, long id)
+    : facets_(max<size_t>(N, other.facets_.size()+1)),
+      name_("*")
+{
+    f->__add_shared();
+    unique_ptr<facet, release> hold(f);
+    facets_ = other.facets_;
+    for (unsigned i = 0; i < other.facets_.size(); ++i)
+        if (facets_[i])
+            facets_[i]->__add_shared();
+    install(hold.get(), id);
+}
+
+locale::__imp::~__imp()
+{
+    for (unsigned i = 0; i < facets_.size(); ++i)
+        if (facets_[i])
+            facets_[i]->__release_shared();
+}
+
+void
+locale::__imp::install(facet* f, long id)
+{
+    f->__add_shared();
+    unique_ptr<facet, release> hold(f);
+    if (static_cast<size_t>(id) >= facets_.size())
+        facets_.resize(static_cast<size_t>(id+1));
+    if (facets_[static_cast<size_t>(id)])
+        facets_[static_cast<size_t>(id)]->__release_shared();
+    facets_[static_cast<size_t>(id)] = hold.release();
+}
+
+const locale::facet*
+locale::__imp::use_facet(long id) const
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (!has_facet(id))
+        throw bad_cast();
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return facets_[static_cast<size_t>(id)];
+}
+
+// locale
+
+const locale&
+locale::__imp::make_classic()
+{
+    // only one thread can get in here and it only gets in once
+    static aligned_storage<sizeof(locale)>::type buf;
+    locale* c = reinterpret_cast<locale*>(&buf);
+    c->__locale_ = &make<__imp>(1u);
+    return *c;
+}
+
+const locale&
+locale::classic()
+{
+    static const locale& c = __imp::make_classic();
+    return c;
+}
+
+locale&
+locale::__imp::make_global()
+{
+    // only one thread can get in here and it only gets in once
+    static aligned_storage<sizeof(locale)>::type buf;
+    ::new (&buf) locale(locale::classic());
+    return *reinterpret_cast<locale*>(&buf);
+}
+
+locale&
+locale::__global()
+{
+    static locale& g = __imp::make_global();
+    return g;
+}
+
+locale::locale()  _NOEXCEPT
+    : __locale_(__global().__locale_)
+{
+    __locale_->__add_shared();
+}
+
+locale::locale(const locale& l)  _NOEXCEPT
+    : __locale_(l.__locale_)
+{
+    __locale_->__add_shared();
+}
+
+locale::~locale()
+{
+    __locale_->__release_shared();
+}
+
+const locale&
+locale::operator=(const locale& other)  _NOEXCEPT
+{
+    other.__locale_->__add_shared();
+    __locale_->__release_shared();
+    __locale_ = other.__locale_;
+    return *this;
+}
+
+locale::locale(const char* name)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    : __locale_(name ? new __imp(name)
+                     : throw runtime_error("locale constructed with null"))
+#else  // _LIBCPP_NO_EXCEPTIONS
+    : __locale_(new __imp(name))
+#endif
+{
+    __locale_->__add_shared();
+}
+
+locale::locale(const string& name)
+    : __locale_(new __imp(name))
+{
+    __locale_->__add_shared();
+}
+
+locale::locale(const locale& other, const char* name, category c)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    : __locale_(name ? new __imp(*other.__locale_, name, c)
+                     : throw runtime_error("locale constructed with null"))
+#else  // _LIBCPP_NO_EXCEPTIONS
+    : __locale_(new __imp(*other.__locale_, name, c))
+#endif
+{
+    __locale_->__add_shared();
+}
+
+locale::locale(const locale& other, const string& name, category c)
+    : __locale_(new __imp(*other.__locale_, name, c))
+{
+    __locale_->__add_shared();
+}
+
+locale::locale(const locale& other, const locale& one, category c)
+    : __locale_(new __imp(*other.__locale_, *one.__locale_, c))
+{
+    __locale_->__add_shared();
+}
+
+string
+locale::name() const
+{
+    return __locale_->name();
+}
+
+void
+locale::__install_ctor(const locale& other, facet* f, long id)
+{
+    if (f)
+        __locale_ = new __imp(*other.__locale_, f, id);
+    else
+        __locale_ = other.__locale_;
+    __locale_->__add_shared();
+}
+
+locale
+locale::global(const locale& loc)
+{
+    locale& g = __global();
+    locale r = g;
+    g = loc;
+    if (g.name() != "*")
+        setlocale(LC_ALL, g.name().c_str());
+    return r;
+}
+
+bool
+locale::has_facet(id& x) const
+{
+    return __locale_->has_facet(x.__get());
+}
+
+const locale::facet*
+locale::use_facet(id& x) const
+{
+    return __locale_->use_facet(x.__get());
+}
+
+bool
+locale::operator==(const locale& y) const
+{
+    return (__locale_ == y.__locale_)
+        || (__locale_->name() != "*" && __locale_->name() == y.__locale_->name());
+}
+
+// locale::facet
+
+locale::facet::~facet()
+{
+}
+
+void
+locale::facet::__on_zero_shared() _NOEXCEPT
+{
+    delete this;
+}
+
+// locale::id
+
+int32_t locale::id::__next_id = 0;
+
+namespace
+{
+
+class __fake_bind
+{
+    locale::id* id_;
+    void (locale::id::* pmf_)();
+public:
+    __fake_bind(void (locale::id::* pmf)(), locale::id* id)
+        : id_(id), pmf_(pmf) {}
+
+    void operator()() const
+    {
+        (id_->*pmf_)();
+    }
+};
+
+}
+
+long
+locale::id::__get()
+{
+    call_once(__flag_, __fake_bind(&locale::id::__init, this));
+    return __id_ - 1;
+}
+
+void
+locale::id::__init()
+{
+    __id_ = __sync_add_and_fetch(&__next_id, 1);
+}
+
+// template <> class collate_byname<char>
+
+collate_byname<char>::collate_byname(const char* n, size_t refs)
+    : collate<char>(refs),
+      __l(newlocale(LC_ALL_MASK, n, 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("collate_byname<char>::collate_byname"
+                            " failed to construct for " + string(n));
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+collate_byname<char>::collate_byname(const string& name, size_t refs)
+    : collate<char>(refs),
+      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("collate_byname<char>::collate_byname"
+                            " failed to construct for " + name);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+collate_byname<char>::~collate_byname()
+{
+    freelocale(__l);
+}
+
+int
+collate_byname<char>::do_compare(const char_type* __lo1, const char_type* __hi1,
+                                 const char_type* __lo2, const char_type* __hi2) const
+{
+    string_type lhs(__lo1, __hi1);
+    string_type rhs(__lo2, __hi2);
+    int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l);
+    if (r < 0)
+        return -1;
+    if (r > 0)
+        return 1;
+    return r;
+}
+
+collate_byname<char>::string_type
+collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const
+{
+    const string_type in(lo, hi);
+    string_type out(strxfrm_l(0, in.c_str(), 0, __l), char());
+    strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l);
+    return out;
+}
+
+// template <> class collate_byname<wchar_t>
+
+collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
+    : collate<wchar_t>(refs),
+      __l(newlocale(LC_ALL_MASK, n, 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
+                            " failed to construct for " + string(n));
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
+    : collate<wchar_t>(refs),
+      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
+                            " failed to construct for " + name);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+collate_byname<wchar_t>::~collate_byname()
+{
+    freelocale(__l);
+}
+
+int
+collate_byname<wchar_t>::do_compare(const char_type* __lo1, const char_type* __hi1,
+                                 const char_type* __lo2, const char_type* __hi2) const
+{
+    string_type lhs(__lo1, __hi1);
+    string_type rhs(__lo2, __hi2);
+    int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l);
+    if (r < 0)
+        return -1;
+    if (r > 0)
+        return 1;
+    return r;
+}
+
+collate_byname<wchar_t>::string_type
+collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const
+{
+    const string_type in(lo, hi);
+    string_type out(wcsxfrm_l(0, in.c_str(), 0, __l), wchar_t());
+    wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l);
+    return out;
+}
+
+// template <> class ctype<wchar_t>;
+
+const ctype_base::mask ctype_base::space;
+const ctype_base::mask ctype_base::print;
+const ctype_base::mask ctype_base::cntrl;
+const ctype_base::mask ctype_base::upper;
+const ctype_base::mask ctype_base::lower;
+const ctype_base::mask ctype_base::alpha;
+const ctype_base::mask ctype_base::digit;
+const ctype_base::mask ctype_base::punct;
+const ctype_base::mask ctype_base::xdigit;
+const ctype_base::mask ctype_base::blank;
+const ctype_base::mask ctype_base::alnum;
+const ctype_base::mask ctype_base::graph;
+    
+locale::id ctype<wchar_t>::id;
+
+ctype<wchar_t>::~ctype()
+{
+}
+
+bool
+ctype<wchar_t>::do_is(mask m, char_type c) const
+{
+    return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
+{
+    for (; low != high; ++low, ++vec)
+        *vec = static_cast<mask>(isascii(*low) ?
+                                   ctype<char>::classic_table()[*low] : 0);
+    return low;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+        if (isascii(*low) && (ctype<char>::classic_table()[*low] & m))
+            break;
+    return low;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+        if (!(isascii(*low) && (ctype<char>::classic_table()[*low] & m)))
+            break;
+    return low;
+}
+
+wchar_t
+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__)
+    return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
+#else
+    return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c;
+#endif
+}
+
+const wchar_t*
+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__)
+        *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
+                             : *low;
+#else
+        *low = (isascii(*low) && islower_l(*low, __cloc())) ? (*low-L'a'+L'A') : *low;
+#endif
+    return low;
+}
+
+wchar_t
+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__)
+    return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
+#else
+    return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c;
+#endif
+}
+
+const wchar_t*
+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__)
+        *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
+                             : *low;
+#else
+        *low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-L'A'+L'a' : *low;
+#endif
+    return low;
+}
+
+wchar_t
+ctype<wchar_t>::do_widen(char c) const
+{
+    return c;
+}
+
+const char*
+ctype<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
+{
+    for (; low != high; ++low, ++dest)
+        *dest = *low;
+    return low;
+}
+
+char
+ctype<wchar_t>::do_narrow(char_type c, char dfault) const
+{
+    if (isascii(c))
+        return static_cast<char>(c);
+    return dfault;
+}
+
+const wchar_t*
+ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
+{
+    for (; low != high; ++low, ++dest)
+        if (isascii(*low))
+            *dest = static_cast<char>(*low);
+        else
+            *dest = dfault;
+    return low;
+}
+
+// template <> class ctype<char>;
+
+locale::id ctype<char>::id;
+
+ctype<char>::ctype(const mask* tab, bool del, size_t refs)
+    : locale::facet(refs),
+      __tab_(tab),
+      __del_(del)
+{
+  if (__tab_ == 0)
+      __tab_ = classic_table();
+}
+
+ctype<char>::~ctype()
+{
+    if (__tab_ && __del_)
+        delete [] __tab_;
+}
+
+char
+ctype<char>::do_toupper(char_type c) const
+{
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+    return isascii(c) ?
+      static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
+#elif defined(__NetBSD__)
+    return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+    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;
+#endif
+}
+
+const char*
+ctype<char>::do_toupper(char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+        *low = isascii(*low) ?
+          static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low;
+#elif defined(__NetBSD__)
+        *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+        *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;
+#endif
+    return low;
+}
+
+char
+ctype<char>::do_tolower(char_type c) const
+{
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+    return isascii(c) ?
+      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__)
+    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;
+#endif
+}
+
+const char*
+ctype<char>::do_tolower(char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+        *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low;
+#elif defined(__NetBSD__)
+        *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
+#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;
+#endif
+    return low;
+}
+
+char
+ctype<char>::do_widen(char c) const
+{
+    return c;
+}
+
+const char*
+ctype<char>::do_widen(const char* low, const char* high, char_type* dest) const
+{
+    for (; low != high; ++low, ++dest)
+        *dest = *low;
+    return low;
+}
+
+char
+ctype<char>::do_narrow(char_type c, char dfault) const
+{
+    if (isascii(c))
+        return static_cast<char>(c);
+    return dfault;
+}
+
+const char*
+ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
+{
+    for (; low != high; ++low, ++dest)
+        if (isascii(*low))
+            *dest = *low;
+        else
+            *dest = dfault;
+    return low;
+}
+
+#ifdef __EMSCRIPTEN__
+extern "C" const unsigned short ** __ctype_b_loc();
+extern "C" const int ** __ctype_tolower_loc();
+extern "C" const int ** __ctype_toupper_loc();
+#endif
+
+const ctype<char>::mask*
+ctype<char>::classic_table()  _NOEXCEPT
+{
+#if defined(__APPLE__) || defined(__FreeBSD__)
+    return _DefaultRuneLocale.__runetype;
+#elif defined(__NetBSD__)
+    return _C_ctype_tab_ + 1;
+#elif defined(__GLIBC__)
+    return __cloc()->__ctype_b;
+#elif __sun__
+    return __ctype_mask;
+#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+    return _ctype+1; // internal ctype mask table defined in msvcrt.dll
+// This is assumed to be safe, which is a nonsense assumption because we're
+// going to end up dereferencing it later...
+#elif defined(__EMSCRIPTEN__)
+    return *__ctype_b_loc();
+#elif defined(_AIX)
+    return (const unsigned int *)__lc_ctype_ptr->obj->mask;
+#elif defined(__ANDROID__)
+    return _ctype_;
+#else
+    // Platform not supported: abort so the person doing the port knows what to
+    // fix
+# warning  ctype<char>::classic_table() is not implemented
+    printf("ctype<char>::classic_table() is not implemented\n");
+    abort();
+    return NULL;
+#endif
+}
+
+#if defined(__GLIBC__)
+const int*
+ctype<char>::__classic_lower_table() _NOEXCEPT
+{
+    return __cloc()->__ctype_tolower;
+}
+
+const int*
+ctype<char>::__classic_upper_table() _NOEXCEPT
+{
+    return __cloc()->__ctype_toupper;
+}
+#elif __NetBSD__
+const short*
+ctype<char>::__classic_lower_table() _NOEXCEPT
+{
+    return _C_tolower_tab_ + 1;
+}
+
+const short*
+ctype<char>::__classic_upper_table() _NOEXCEPT
+{
+    return _C_toupper_tab_ + 1;
+}
+
+#elif defined(__EMSCRIPTEN__)
+const int*
+ctype<char>::__classic_lower_table() _NOEXCEPT
+{
+    return *__ctype_tolower_loc();
+}
+
+const int*
+ctype<char>::__classic_upper_table() _NOEXCEPT
+{
+    return *__ctype_toupper_loc();
+}
+#endif // __GLIBC__ || __EMSCRIPTEN__ || __NETBSD__
+
+// template <> class ctype_byname<char>
+
+ctype_byname<char>::ctype_byname(const char* name, size_t refs)
+    : ctype<char>(0, false, refs),
+      __l(newlocale(LC_ALL_MASK, name, 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("ctype_byname<char>::ctype_byname"
+                            " failed to construct for " + string(name));
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+ctype_byname<char>::ctype_byname(const string& name, size_t refs)
+    : ctype<char>(0, false, refs),
+      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("ctype_byname<char>::ctype_byname"
+                            " failed to construct for " + name);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+ctype_byname<char>::~ctype_byname()
+{
+    freelocale(__l);
+}
+
+char
+ctype_byname<char>::do_toupper(char_type c) const
+{
+    return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l));
+}
+
+const char*
+ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+        *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l));
+    return low;
+}
+
+char
+ctype_byname<char>::do_tolower(char_type c) const
+{
+    return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l));
+}
+
+const char*
+ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+        *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l));
+    return low;
+}
+
+// template <> class ctype_byname<wchar_t>
+
+ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
+    : ctype<wchar_t>(refs),
+      __l(newlocale(LC_ALL_MASK, name, 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("ctype_byname<wchar_t>::ctype_byname"
+                            " failed to construct for " + string(name));
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
+    : ctype<wchar_t>(refs),
+      __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("ctype_byname<wchar_t>::ctype_byname"
+                            " failed to construct for " + name);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+ctype_byname<wchar_t>::~ctype_byname()
+{
+    freelocale(__l);
+}
+
+bool
+ctype_byname<wchar_t>::do_is(mask m, char_type c) const
+{
+#ifdef _LIBCPP_WCTYPE_IS_MASK
+    return static_cast<bool>(iswctype_l(c, m, __l));
+#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);
+    return result;
+#endif
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
+{
+    for (; low != high; ++low, ++vec)
+    {
+        if (isascii(*low))
+            *vec = static_cast<mask>(ctype<char>::classic_table()[*low]);
+        else
+        {
+            *vec = 0;
+            wint_t ch = static_cast<wint_t>(*low);
+            if (iswspace_l(ch, __l))
+                *vec |= space;
+            if (iswprint_l(ch, __l))
+                *vec |= print;
+            if (iswcntrl_l(ch, __l))
+                *vec |= cntrl;
+            if (iswupper_l(ch, __l))
+                *vec |= upper;
+            if (iswlower_l(ch, __l))
+                *vec |= lower;
+            if (iswalpha_l(ch, __l))
+                *vec |= alpha;
+            if (iswdigit_l(ch, __l))
+                *vec |= digit;
+            if (iswpunct_l(ch, __l))
+                *vec |= punct;
+            if (iswxdigit_l(ch, __l))
+                *vec |= xdigit;
+        }
+    }
+    return low;
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+    {
+#ifdef _LIBCPP_WCTYPE_IS_MASK
+        if (iswctype_l(*low, m, __l))
+            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;
+#endif
+    }
+    return low;
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+    {
+#ifdef _LIBCPP_WCTYPE_IS_MASK
+        if (!iswctype_l(*low, m, __l))
+            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;
+        break;
+#endif
+    }
+    return low;
+}
+
+wchar_t
+ctype_byname<wchar_t>::do_toupper(char_type c) const
+{
+    return towupper_l(c, __l);
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+        *low = towupper_l(*low, __l);
+    return low;
+}
+
+wchar_t
+ctype_byname<wchar_t>::do_tolower(char_type c) const
+{
+    return towlower_l(c, __l);
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
+{
+    for (; low != high; ++low)
+        *low = towlower_l(*low, __l);
+    return low;
+}
+
+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
+}
+
+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
+    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
+    return r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
+}
+
+const wchar_t*
+ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
+{
+    for (; low != high; ++low, ++dest)
+    {
+#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
+        int r = wctob_l(*low, __l);
+#else
+        int r = __wctob_l(*low, __l);
+#endif
+        *dest = r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault;
+    }
+    return low;
+}
+
+// template <> class codecvt<char, char, mbstate_t>
+
+locale::id codecvt<char, char, mbstate_t>::id;
+
+codecvt<char, char, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char, char, mbstate_t>::result
+codecvt<char, char, mbstate_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type*, const intern_type*& frm_nxt,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    return noconv;
+}
+
+codecvt<char, char, mbstate_t>::result
+codecvt<char, char, mbstate_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type*, const extern_type*& frm_nxt,
+    intern_type* to, intern_type*, intern_type*& to_nxt) const
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    return noconv;
+}
+
+codecvt<char, char, mbstate_t>::result
+codecvt<char, char, mbstate_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+codecvt<char, char, mbstate_t>::do_encoding() const  _NOEXCEPT
+{
+    return 1;
+}
+
+bool
+codecvt<char, char, mbstate_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return true;
+}
+
+int
+codecvt<char, char, mbstate_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* end, size_t mx) const
+{
+    return static_cast<int>(min<size_t>(mx, static_cast<size_t>(end-frm)));
+}
+
+int
+codecvt<char, char, mbstate_t>::do_max_length() const  _NOEXCEPT
+{
+    return 1;
+}
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+locale::id codecvt<wchar_t, char, mbstate_t>::id;
+
+codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
+    : locale::facet(refs),
+      __l(_LIBCPP_GET_C_LOCALE)
+{
+}
+
+codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
+    : locale::facet(refs),
+      __l(newlocale(LC_ALL_MASK, nm, 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__l == 0)
+        throw runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
+                            " failed to construct for " + string(nm));
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+codecvt<wchar_t, char, mbstate_t>::~codecvt()
+{
+    if (__l != _LIBCPP_GET_C_LOCALE)
+        freelocale(__l);
+}
+
+codecvt<wchar_t, char, mbstate_t>::result
+codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    // look for first internal null in frm
+    const intern_type* fend = frm;
+    for (; fend != frm_end; ++fend)
+        if (*fend == 0)
+            break;
+    // loop over all null-terminated sequences in frm
+    to_nxt = to;
+    for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt)
+    {
+        // 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
+        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
+                if (n == size_t(-1))
+                    break;
+                to_nxt += n;
+            }
+            frm_nxt = frm;
+            return error;
+        }
+        if (n == 0)
+            return partial;
+        to_nxt += n;
+        if (to_nxt == to_end)
+            break;
+        if (fend != frm_end)  // set up next null terminated sequence
+        {
+            // 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
+            if (n == size_t(-1))  // on error
+                return error;
+            if (n > static_cast<size_t>(to_end-to_nxt))  // is there room?
+                return partial;
+            for (extern_type* p = tmp; n; --n)  // write it
+                *to_nxt++ = *p++;
+            ++frm_nxt;
+            // look for next null in frm
+            for (fend = frm_nxt; fend != frm_end; ++fend)
+                if (*fend == 0)
+                    break;
+        }
+    }
+    return frm_nxt == frm_end ? ok : partial;
+}
+
+codecvt<wchar_t, char, mbstate_t>::result
+codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    // look for first internal null in frm
+    const extern_type* fend = frm;
+    for (; fend != frm_end; ++fend)
+        if (*fend == 0)
+            break;
+    // loop over all null-terminated sequences in frm
+    to_nxt = to;
+    for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt)
+    {
+        // 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
+        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
+                switch (n)
+                {
+                case 0:
+                    ++frm;
+                    break;
+                case size_t(-1):
+                    frm_nxt = frm;
+                    return error;
+                case size_t(-2):
+                    frm_nxt = frm;
+                    return partial;
+                default:
+                    frm += n;
+                    break;
+                }
+            }
+            frm_nxt = frm;
+            return frm_nxt == frm_end ? ok : partial;
+        }
+        if (n == 0)
+            return error;
+        to_nxt += n;
+        if (to_nxt == to_end)
+            break;
+        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
+            if (n != 0)  // on error
+                return error;
+            ++to_nxt;
+            ++frm_nxt;
+            // look for next null in frm
+            for (fend = frm_nxt; fend != frm_end; ++fend)
+                if (*fend == 0)
+                    break;
+        }
+    }
+    return frm_nxt == frm_end ? ok : partial;
+}
+
+codecvt<wchar_t, char, mbstate_t>::result
+codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    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
+    if (n == size_t(-1) || n == 0)  // on error
+        return error;
+    --n;
+    if (n > static_cast<size_t>(to_end-to_nxt))  // is there room?
+        return partial;
+    for (extern_type* p = tmp; n; --n)  // write it
+        *to_nxt++ = *p++;
+    return ok;
+}
+
+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
+#endif
+            return 1;                // which take more than 1 char to form a wchar_t
+         return 0;
+    }
+    return -1;
+}
+
+bool
+codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    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
+        switch (n)
+        {
+        case 0:
+            ++nbytes;
+            ++frm;
+            break;
+        case size_t(-1):
+        case size_t(-2):
+            return nbytes;
+        default:
+            nbytes += n;
+            frm += n;
+            break;
+        }
+    }
+    return nbytes;
+}
+
+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
+}
+
+//                                     Valid UTF ranges
+//     UTF-32               UTF-16                          UTF-8               # of code points
+//                     first      second       first   second    third   fourth
+// 000000 - 00007F  0000 - 007F               00 - 7F                                 127
+// 000080 - 0007FF  0080 - 07FF               C2 - DF, 80 - BF                       1920
+// 000800 - 000FFF  0800 - 0FFF               E0 - E0, A0 - BF, 80 - BF              2048
+// 001000 - 00CFFF  1000 - CFFF               E1 - EC, 80 - BF, 80 - BF             49152
+// 00D000 - 00D7FF  D000 - D7FF               ED - ED, 80 - 9F, 80 - BF              2048
+// 00D800 - 00DFFF                invalid
+// 00E000 - 00FFFF  E000 - FFFF               EE - EF, 80 - BF, 80 - BF              8192
+// 010000 - 03FFFF  D800 - D8BF, DC00 - DFFF  F0 - F0, 90 - BF, 80 - BF, 80 - BF   196608
+// 040000 - 0FFFFF  D8C0 - DBBF, DC00 - DFFF  F1 - F3, 80 - BF, 80 - BF, 80 - BF   786432
+// 100000 - 10FFFF  DBC0 - DBFF, DC00 - DFFF  F4 - F4, 80 - 8F, 80 - BF, 80 - BF    65536
+
+static
+codecvt_base::result
+utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+              uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+              unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 3)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(0xEF);
+        *to_nxt++ = static_cast<uint8_t>(0xBB);
+        *to_nxt++ = static_cast<uint8_t>(0xBF);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint16_t wc1 = *frm_nxt;
+        if (wc1 > Maxcode)
+            return codecvt_base::error;
+        if (wc1 < 0x0080)
+        {
+            if (to_end-to_nxt < 1)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(wc1);
+        }
+        else if (wc1 < 0x0800)
+        {
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
+        }
+        else if (wc1 < 0xD800)
+        {
+            if (to_end-to_nxt < 3)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xE0 |  (wc1 >> 12));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc1 & 0x003F));
+        }
+        else if (wc1 < 0xDC00)
+        {
+            if (frm_end-frm_nxt < 2)
+                return codecvt_base::partial;
+            uint16_t wc2 = frm_nxt[1];
+            if ((wc2 & 0xFC00) != 0xDC00)
+                return codecvt_base::error;
+            if (to_end-to_nxt < 4)
+                return codecvt_base::partial;
+            if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
+                ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
+                return codecvt_base::error;
+            ++frm_nxt;
+            uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
+            *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4)     | ((wc1 & 0x003C) >> 2));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc2 & 0x003F));
+        }
+        else if (wc1 < 0xE000)
+        {
+            return codecvt_base::error;
+        }
+        else
+        {
+            if (to_end-to_nxt < 3)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xE0 |  (wc1 >> 12));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc1 & 0x003F));
+        }
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+              uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+              unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 3)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(0xEF);
+        *to_nxt++ = static_cast<uint8_t>(0xBB);
+        *to_nxt++ = static_cast<uint8_t>(0xBF);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint16_t wc1 = static_cast<uint16_t>(*frm_nxt);
+        if (wc1 > Maxcode)
+            return codecvt_base::error;
+        if (wc1 < 0x0080)
+        {
+            if (to_end-to_nxt < 1)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(wc1);
+        }
+        else if (wc1 < 0x0800)
+        {
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
+        }
+        else if (wc1 < 0xD800)
+        {
+            if (to_end-to_nxt < 3)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xE0 |  (wc1 >> 12));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc1 & 0x003F));
+        }
+        else if (wc1 < 0xDC00)
+        {
+            if (frm_end-frm_nxt < 2)
+                return codecvt_base::partial;
+            uint16_t wc2 = static_cast<uint16_t>(frm_nxt[1]);
+            if ((wc2 & 0xFC00) != 0xDC00)
+                return codecvt_base::error;
+            if (to_end-to_nxt < 4)
+                return codecvt_base::partial;
+            if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
+                ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
+                return codecvt_base::error;
+            ++frm_nxt;
+            uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
+            *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4)     | ((wc1 & 0x003C) >> 2));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc2 & 0x003F));
+        }
+        else if (wc1 < 0xE000)
+        {
+            return codecvt_base::error;
+        }
+        else
+        {
+            if (to_end-to_nxt < 3)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xE0 |  (wc1 >> 12));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc1 & 0x003F));
+        }
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+              uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+              unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+                                                          frm_nxt[2] == 0xBF)
+            frm_nxt += 3;
+    }
+    for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+    {
+        uint8_t c1 = *frm_nxt;
+        if (c1 > Maxcode)
+            return codecvt_base::error;
+        if (c1 < 0x80)
+        {
+            *to_nxt = static_cast<uint16_t>(c1);
+            ++frm_nxt;
+        }
+        else if (c1 < 0xC2)
+        {
+            return codecvt_base::error;
+        }
+        else if (c1 < 0xE0)
+        {
+            if (frm_end-frm_nxt < 2)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            if ((c2 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 2;
+        }
+        else if (c1 < 0xF0)
+        {
+            if (frm_end-frm_nxt < 3)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            switch (c1)
+            {
+            case 0xE0:
+                if ((c2 & 0xE0) != 0xA0)
+                    return codecvt_base::error;
+                 break;
+            case 0xED:
+                if ((c2 & 0xE0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
+                                             | ((c2 & 0x3F) << 6)
+                                             |  (c3 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 3;
+        }
+        else if (c1 < 0xF5)
+        {
+            if (frm_end-frm_nxt < 4)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            uint8_t c4 = frm_nxt[3];
+            switch (c1)
+            {
+            case 0xF0:
+                if (!(0x90 <= c2 && c2 <= 0xBF))
+                    return codecvt_base::error;
+                 break;
+            case 0xF4:
+                if ((c2 & 0xF0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            if ((((c1 & 7UL) << 18) +
+                ((c2 & 0x3FUL) << 12) +
+                ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint16_t>(
+                    0xD800
+                  | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6)
+                  | ((c2 & 0x0F) << 2)
+                  | ((c3 & 0x30) >> 4));
+            *++to_nxt = static_cast<uint16_t>(
+                    0xDC00
+                  | ((c3 & 0x0F) << 6)
+                  |  (c4 & 0x3F));
+            frm_nxt += 4;
+        }
+        else
+        {
+            return codecvt_base::error;
+        }
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+              uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+              unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+                                                          frm_nxt[2] == 0xBF)
+            frm_nxt += 3;
+    }
+    for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+    {
+        uint8_t c1 = *frm_nxt;
+        if (c1 > Maxcode)
+            return codecvt_base::error;
+        if (c1 < 0x80)
+        {
+            *to_nxt = static_cast<uint32_t>(c1);
+            ++frm_nxt;
+        }
+        else if (c1 < 0xC2)
+        {
+            return codecvt_base::error;
+        }
+        else if (c1 < 0xE0)
+        {
+            if (frm_end-frm_nxt < 2)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            if ((c2 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint32_t>(t);
+            frm_nxt += 2;
+        }
+        else if (c1 < 0xF0)
+        {
+            if (frm_end-frm_nxt < 3)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            switch (c1)
+            {
+            case 0xE0:
+                if ((c2 & 0xE0) != 0xA0)
+                    return codecvt_base::error;
+                 break;
+            case 0xED:
+                if ((c2 & 0xE0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
+                                             | ((c2 & 0x3F) << 6)
+                                             |  (c3 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint32_t>(t);
+            frm_nxt += 3;
+        }
+        else if (c1 < 0xF5)
+        {
+            if (frm_end-frm_nxt < 4)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            uint8_t c4 = frm_nxt[3];
+            switch (c1)
+            {
+            case 0xF0:
+                if (!(0x90 <= c2 && c2 <= 0xBF))
+                    return codecvt_base::error;
+                 break;
+            case 0xF4:
+                if ((c2 & 0xF0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            if ((((c1 & 7UL) << 18) +
+                ((c2 & 0x3FUL) << 12) +
+                ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint32_t>(
+                    0xD800
+                  | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6)
+                  | ((c2 & 0x0F) << 2)
+                  | ((c3 & 0x30) >> 4));
+            *++to_nxt = static_cast<uint32_t>(
+                    0xDC00
+                  | ((c3 & 0x0F) << 6)
+                  |  (c4 & 0x3F));
+            frm_nxt += 4;
+        }
+        else
+        {
+            return codecvt_base::error;
+        }
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf8_to_utf16_length(const uint8_t* frm, const uint8_t* frm_end,
+                     size_t mx, unsigned long Maxcode = 0x10FFFF,
+                     codecvt_mode mode = codecvt_mode(0))
+{
+    const uint8_t* frm_nxt = frm;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+                                                          frm_nxt[2] == 0xBF)
+            frm_nxt += 3;
+    }
+    for (size_t nchar16_t = 0; frm_nxt < frm_end && nchar16_t < mx; ++nchar16_t)
+    {
+        uint8_t c1 = *frm_nxt;
+        if (c1 > Maxcode)
+            break;
+        if (c1 < 0x80)
+        {
+            ++frm_nxt;
+        }
+        else if (c1 < 0xC2)
+        {
+            break;
+        }
+        else if (c1 < 0xE0)
+        {
+            if ((frm_end-frm_nxt < 2) || (frm_nxt[1] & 0xC0) != 0x80)
+                break;
+            uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (frm_nxt[1] & 0x3F));
+            if (t > Maxcode)
+                break;
+            frm_nxt += 2;
+        }
+        else if (c1 < 0xF0)
+        {
+            if (frm_end-frm_nxt < 3)
+                break;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            switch (c1)
+            {
+            case 0xE0:
+                if ((c2 & 0xE0) != 0xA0)
+                    return static_cast<int>(frm_nxt - frm);
+                break;
+            case 0xED:
+                if ((c2 & 0xE0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80)
+                break;
+            if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+                break;
+            frm_nxt += 3;
+        }
+        else if (c1 < 0xF5)
+        {
+            if (frm_end-frm_nxt < 4 || mx-nchar16_t < 2)
+                break;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            uint8_t c4 = frm_nxt[3];
+            switch (c1)
+            {
+            case 0xF0:
+                if (!(0x90 <= c2 && c2 <= 0xBF))
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            case 0xF4:
+                if ((c2 & 0xF0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+                break;
+            if ((((c1 & 7UL) << 18) +
+                ((c2 & 0x3FUL) << 12) +
+                ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+                break;
+            ++nchar16_t;
+            frm_nxt += 4;
+        }
+        else
+        {
+            break;
+        }
+    }
+    return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs4_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+             uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+             unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 3)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(0xEF);
+        *to_nxt++ = static_cast<uint8_t>(0xBB);
+        *to_nxt++ = static_cast<uint8_t>(0xBF);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint32_t wc = *frm_nxt;
+        if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+            return codecvt_base::error;
+        if (wc < 0x000080)
+        {
+            if (to_end-to_nxt < 1)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(wc);
+        }
+        else if (wc < 0x000800)
+        {
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
+        }
+        else if (wc < 0x010000)
+        {
+            if (to_end-to_nxt < 3)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xE0 |  (wc >> 12));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc & 0x003F));
+        }
+        else // if (wc < 0x110000)
+        {
+            if (to_end-to_nxt < 4)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xF0 |  (wc >> 18));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x03F000) >> 12));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x000FC0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc & 0x00003F));
+        }
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+             uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+             unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+                                                          frm_nxt[2] == 0xBF)
+            frm_nxt += 3;
+    }
+    for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+    {
+        uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+        if (c1 < 0x80)
+        {
+            if (c1 > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint32_t>(c1);
+            ++frm_nxt;
+        }
+        else if (c1 < 0xC2)
+        {
+            return codecvt_base::error;
+        }
+        else if (c1 < 0xE0)
+        {
+            if (frm_end-frm_nxt < 2)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            if ((c2 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint32_t t = static_cast<uint32_t>(((c1 & 0x1F) << 6)
+                                              | (c2 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 2;
+        }
+        else if (c1 < 0xF0)
+        {
+            if (frm_end-frm_nxt < 3)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            switch (c1)
+            {
+            case 0xE0:
+                if ((c2 & 0xE0) != 0xA0)
+                    return codecvt_base::error;
+                 break;
+            case 0xED:
+                if ((c2 & 0xE0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint32_t t = static_cast<uint32_t>(((c1 & 0x0F) << 12)
+                                             | ((c2 & 0x3F) << 6)
+                                             |  (c3 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 3;
+        }
+        else if (c1 < 0xF5)
+        {
+            if (frm_end-frm_nxt < 4)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            uint8_t c4 = frm_nxt[3];
+            switch (c1)
+            {
+            case 0xF0:
+                if (!(0x90 <= c2 && c2 <= 0xBF))
+                    return codecvt_base::error;
+                 break;
+            case 0xF4:
+                if ((c2 & 0xF0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint32_t t = static_cast<uint32_t>(((c1 & 0x07) << 18)
+                                             | ((c2 & 0x3F) << 12)
+                                             | ((c3 & 0x3F) << 6)
+                                             |  (c4 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 4;
+        }
+        else
+        {
+            return codecvt_base::error;
+        }
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf8_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
+                    size_t mx, unsigned long Maxcode = 0x10FFFF,
+                    codecvt_mode mode = codecvt_mode(0))
+{
+    const uint8_t* frm_nxt = frm;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+                                                          frm_nxt[2] == 0xBF)
+            frm_nxt += 3;
+    }
+    for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
+    {
+        uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+        if (c1 < 0x80)
+        {
+            if (c1 > Maxcode)
+                break;
+            ++frm_nxt;
+        }
+        else if (c1 < 0xC2)
+        {
+            break;
+        }
+        else if (c1 < 0xE0)
+        {
+            if ((frm_end-frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
+                break;
+            if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
+                break;
+            frm_nxt += 2;
+        }
+        else if (c1 < 0xF0)
+        {
+            if (frm_end-frm_nxt < 3)
+                break;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            switch (c1)
+            {
+            case 0xE0:
+                if ((c2 & 0xE0) != 0xA0)
+                    return static_cast<int>(frm_nxt - frm);
+                break;
+            case 0xED:
+                if ((c2 & 0xE0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80)
+                break;
+            if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+                break;
+            frm_nxt += 3;
+        }
+        else if (c1 < 0xF5)
+        {
+            if (frm_end-frm_nxt < 4)
+                break;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            uint8_t c4 = frm_nxt[3];
+            switch (c1)
+            {
+            case 0xF0:
+                if (!(0x90 <= c2 && c2 <= 0xBF))
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            case 0xF4:
+                if ((c2 & 0xF0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+                break;
+            if ((((c1 & 0x07u) << 18) | ((c2 & 0x3Fu) << 12) |
+                 ((c3 & 0x3Fu) << 6)  |  (c4 & 0x3Fu)) > Maxcode)
+                break;
+            frm_nxt += 4;
+        }
+        else
+        {
+            break;
+        }
+    }
+    return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs2_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+             uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+             unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 3)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(0xEF);
+        *to_nxt++ = static_cast<uint8_t>(0xBB);
+        *to_nxt++ = static_cast<uint8_t>(0xBF);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint16_t wc = *frm_nxt;
+        if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+            return codecvt_base::error;
+        if (wc < 0x0080)
+        {
+            if (to_end-to_nxt < 1)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(wc);
+        }
+        else if (wc < 0x0800)
+        {
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
+        }
+        else // if (wc <= 0xFFFF)
+        {
+            if (to_end-to_nxt < 3)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xE0 |  (wc >> 12));
+            *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
+            *to_nxt++ = static_cast<uint8_t>(0x80 |  (wc & 0x003F));
+        }
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf8_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+             uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+             unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+                                                          frm_nxt[2] == 0xBF)
+            frm_nxt += 3;
+    }
+    for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
+    {
+        uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+        if (c1 < 0x80)
+        {
+            if (c1 > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint16_t>(c1);
+            ++frm_nxt;
+        }
+        else if (c1 < 0xC2)
+        {
+            return codecvt_base::error;
+        }
+        else if (c1 < 0xE0)
+        {
+            if (frm_end-frm_nxt < 2)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            if ((c2 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6)
+                                              | (c2 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 2;
+        }
+        else if (c1 < 0xF0)
+        {
+            if (frm_end-frm_nxt < 3)
+                return codecvt_base::partial;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            switch (c1)
+            {
+            case 0xE0:
+                if ((c2 & 0xE0) != 0xA0)
+                    return codecvt_base::error;
+                 break;
+            case 0xED:
+                if ((c2 & 0xE0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return codecvt_base::error;
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80)
+                return codecvt_base::error;
+            uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
+                                             | ((c2 & 0x3F) << 6)
+                                             |  (c3 & 0x3F));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 3;
+        }
+        else
+        {
+            return codecvt_base::error;
+        }
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf8_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
+                    size_t mx, unsigned long Maxcode = 0x10FFFF,
+                    codecvt_mode mode = codecvt_mode(0))
+{
+    const uint8_t* frm_nxt = frm;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
+                                                          frm_nxt[2] == 0xBF)
+            frm_nxt += 3;
+    }
+    for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
+    {
+        uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+        if (c1 < 0x80)
+        {
+            if (c1 > Maxcode)
+                break;
+            ++frm_nxt;
+        }
+        else if (c1 < 0xC2)
+        {
+            break;
+        }
+        else if (c1 < 0xE0)
+        {
+            if ((frm_end-frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
+                break;
+            if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
+                break;
+            frm_nxt += 2;
+        }
+        else if (c1 < 0xF0)
+        {
+            if (frm_end-frm_nxt < 3)
+                break;
+            uint8_t c2 = frm_nxt[1];
+            uint8_t c3 = frm_nxt[2];
+            switch (c1)
+            {
+            case 0xE0:
+                if ((c2 & 0xE0) != 0xA0)
+                    return static_cast<int>(frm_nxt - frm);
+                break;
+            case 0xED:
+                if ((c2 & 0xE0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            default:
+                if ((c2 & 0xC0) != 0x80)
+                    return static_cast<int>(frm_nxt - frm);
+                 break;
+            }
+            if ((c3 & 0xC0) != 0x80)
+                break;
+            if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+                break;
+            frm_nxt += 3;
+        }
+        else
+        {
+            break;
+        }
+    }
+    return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs4_to_utf16be(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+                uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 2)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(0xFE);
+        *to_nxt++ = static_cast<uint8_t>(0xFF);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint32_t wc = *frm_nxt;
+        if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+            return codecvt_base::error;
+        if (wc < 0x010000)
+        {
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+            *to_nxt++ = static_cast<uint8_t>(wc);
+        }
+        else
+        {
+            if (to_end-to_nxt < 4)
+                return codecvt_base::partial;
+            uint16_t t = static_cast<uint16_t>(
+                    0xD800
+                  | ((((wc & 0x1F0000) >> 16) - 1) << 6)
+                  |   ((wc & 0x00FC00) >> 10));
+            *to_nxt++ = static_cast<uint8_t>(t >> 8);
+            *to_nxt++ = static_cast<uint8_t>(t);
+            t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
+            *to_nxt++ = static_cast<uint8_t>(t >> 8);
+            *to_nxt++ = static_cast<uint8_t>(t);
+        }
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16be_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+                uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+            frm_nxt += 2;
+    }
+    for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+        if ((c1 & 0xFC00) == 0xDC00)
+            return codecvt_base::error;
+        if ((c1 & 0xFC00) != 0xD800)
+        {
+            if (c1 > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint32_t>(c1);
+            frm_nxt += 2;
+        }
+        else
+        {
+            if (frm_end-frm_nxt < 4)
+                return codecvt_base::partial;
+            uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
+            if ((c2 & 0xFC00) != 0xDC00)
+                return codecvt_base::error;
+            uint32_t t = static_cast<uint32_t>(
+                    ((((c1 & 0x03C0) >> 6) + 1) << 16)
+                  |   ((c1 & 0x003F) << 10)
+                  |    (c2 & 0x03FF));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 4;
+        }
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16be_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
+                       size_t mx, unsigned long Maxcode = 0x10FFFF,
+                       codecvt_mode mode = codecvt_mode(0))
+{
+    const uint8_t* frm_nxt = frm;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+            frm_nxt += 2;
+    }
+    for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+        if ((c1 & 0xFC00) == 0xDC00)
+            break;
+        if ((c1 & 0xFC00) != 0xD800)
+        {
+            if (c1 > Maxcode)
+                break;
+            frm_nxt += 2;
+        }
+        else
+        {
+            if (frm_end-frm_nxt < 4)
+                break;
+            uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
+            if ((c2 & 0xFC00) != 0xDC00)
+                break;
+            uint32_t t = static_cast<uint32_t>(
+                    ((((c1 & 0x03C0) >> 6) + 1) << 16)
+                  |   ((c1 & 0x003F) << 10)
+                  |    (c2 & 0x03FF));
+            if (t > Maxcode)
+                break;
+            frm_nxt += 4;
+        }
+    }
+    return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs4_to_utf16le(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
+                uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 2)
+            return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(0xFF);
+            *to_nxt++ = static_cast<uint8_t>(0xFE);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint32_t wc = *frm_nxt;
+        if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+            return codecvt_base::error;
+        if (wc < 0x010000)
+        {
+            if (to_end-to_nxt < 2)
+                return codecvt_base::partial;
+            *to_nxt++ = static_cast<uint8_t>(wc);
+            *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+        }
+        else
+        {
+            if (to_end-to_nxt < 4)
+                return codecvt_base::partial;
+            uint16_t t = static_cast<uint16_t>(
+                    0xD800
+                  | ((((wc & 0x1F0000) >> 16) - 1) << 6)
+                  |   ((wc & 0x00FC00) >> 10));
+            *to_nxt++ = static_cast<uint8_t>(t);
+            *to_nxt++ = static_cast<uint8_t>(t >> 8);
+            t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
+            *to_nxt++ = static_cast<uint8_t>(t);
+            *to_nxt++ = static_cast<uint8_t>(t >> 8);
+        }
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16le_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+                uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+            frm_nxt += 2;
+    }
+    for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+        if ((c1 & 0xFC00) == 0xDC00)
+            return codecvt_base::error;
+        if ((c1 & 0xFC00) != 0xD800)
+        {
+            if (c1 > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = static_cast<uint32_t>(c1);
+            frm_nxt += 2;
+        }
+        else
+        {
+            if (frm_end-frm_nxt < 4)
+                return codecvt_base::partial;
+            uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
+            if ((c2 & 0xFC00) != 0xDC00)
+                return codecvt_base::error;
+            uint32_t t = static_cast<uint32_t>(
+                    ((((c1 & 0x03C0) >> 6) + 1) << 16)
+                  |   ((c1 & 0x003F) << 10)
+                  |    (c2 & 0x03FF));
+            if (t > Maxcode)
+                return codecvt_base::error;
+            *to_nxt = t;
+            frm_nxt += 4;
+        }
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16le_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
+                       size_t mx, unsigned long Maxcode = 0x10FFFF,
+                       codecvt_mode mode = codecvt_mode(0))
+{
+    const uint8_t* frm_nxt = frm;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+            frm_nxt += 2;
+    }
+    for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+        if ((c1 & 0xFC00) == 0xDC00)
+            break;
+        if ((c1 & 0xFC00) != 0xD800)
+        {
+            if (c1 > Maxcode)
+                break;
+            frm_nxt += 2;
+        }
+        else
+        {
+            if (frm_end-frm_nxt < 4)
+                break;
+            uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
+            if ((c2 & 0xFC00) != 0xDC00)
+                break;
+            uint32_t t = static_cast<uint32_t>(
+                    ((((c1 & 0x03C0) >> 6) + 1) << 16)
+                  |   ((c1 & 0x003F) << 10)
+                  |    (c2 & 0x03FF));
+            if (t > Maxcode)
+                break;
+            frm_nxt += 4;
+        }
+    }
+    return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs2_to_utf16be(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+                uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 2)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(0xFE);
+        *to_nxt++ = static_cast<uint8_t>(0xFF);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint16_t wc = *frm_nxt;
+        if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+            return codecvt_base::error;
+        if (to_end-to_nxt < 2)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+        *to_nxt++ = static_cast<uint8_t>(wc);
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16be_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+                uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+            frm_nxt += 2;
+    }
+    for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+        if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+            return codecvt_base::error;
+        *to_nxt = c1;
+        frm_nxt += 2;
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16be_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
+                       size_t mx, unsigned long Maxcode = 0x10FFFF,
+                       codecvt_mode mode = codecvt_mode(0))
+{
+    const uint8_t* frm_nxt = frm;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+            frm_nxt += 2;
+    }
+    for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+        if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+            break;
+        frm_nxt += 2;
+    }
+    return static_cast<int>(frm_nxt - frm);
+}
+
+static
+codecvt_base::result
+ucs2_to_utf16le(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
+                uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & generate_header)
+    {
+        if (to_end-to_nxt < 2)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(0xFF);
+        *to_nxt++ = static_cast<uint8_t>(0xFE);
+    }
+    for (; frm_nxt < frm_end; ++frm_nxt)
+    {
+        uint16_t wc = *frm_nxt;
+        if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+            return codecvt_base::error;
+        if (to_end-to_nxt < 2)
+            return codecvt_base::partial;
+        *to_nxt++ = static_cast<uint8_t>(wc);
+        *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+    }
+    return codecvt_base::ok;
+}
+
+static
+codecvt_base::result
+utf16le_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
+                uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
+                unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
+{
+    frm_nxt = frm;
+    to_nxt = to;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+            frm_nxt += 2;
+    }
+    for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+        if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+            return codecvt_base::error;
+        *to_nxt = c1;
+        frm_nxt += 2;
+    }
+    return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static
+int
+utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
+                       size_t mx, unsigned long Maxcode = 0x10FFFF,
+                       codecvt_mode mode = codecvt_mode(0))
+{
+    const uint8_t* frm_nxt = frm;
+    frm_nxt = frm;
+    if (mode & consume_header)
+    {
+        if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+            frm_nxt += 2;
+    }
+    for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
+    {
+        uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+        if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+            break;
+        frm_nxt += 2;
+    }
+    return static_cast<int>(frm_nxt - frm);
+}
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+locale::id codecvt<char16_t, char, mbstate_t>::id;
+
+codecvt<char16_t, char, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char16_t, char, mbstate_t>::result
+codecvt<char16_t, char, mbstate_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+    const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+    const uint16_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+codecvt<char16_t, char, mbstate_t>::result
+codecvt<char16_t, char, mbstate_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+    uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+    uint16_t* _to_nxt = _to;
+    result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+codecvt<char16_t, char, mbstate_t>::result
+codecvt<char16_t, char, mbstate_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+codecvt<char16_t, char, mbstate_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+codecvt<char16_t, char, mbstate_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+codecvt<char16_t, char, mbstate_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_utf16_length(_frm, _frm_end, mx);
+}
+
+int
+codecvt<char16_t, char, mbstate_t>::do_max_length() const  _NOEXCEPT
+{
+    return 4;
+}
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+locale::id codecvt<char32_t, char, mbstate_t>::id;
+
+codecvt<char32_t, char, mbstate_t>::~codecvt()
+{
+}
+
+codecvt<char32_t, char, mbstate_t>::result
+codecvt<char32_t, char, mbstate_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+codecvt<char32_t, char, mbstate_t>::result
+codecvt<char32_t, char, mbstate_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+codecvt<char32_t, char, mbstate_t>::result
+codecvt<char32_t, char, mbstate_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+codecvt<char32_t, char, mbstate_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+codecvt<char32_t, char, mbstate_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+codecvt<char32_t, char, mbstate_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_ucs4_length(_frm, _frm_end, mx);
+}
+
+int
+codecvt<char32_t, char, mbstate_t>::do_max_length() const  _NOEXCEPT
+{
+    return 4;
+}
+
+// __codecvt_utf8<wchar_t>
+
+__codecvt_utf8<wchar_t>::result
+__codecvt_utf8<wchar_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+#if _WIN32
+    const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+    const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+    const uint16_t* _frm_nxt = _frm;
+#else
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+#endif
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+#if _WIN32
+    result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+#else
+    result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+#endif
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8<wchar_t>::result
+__codecvt_utf8<wchar_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+#if _WIN32
+    uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+    uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+    uint16_t* _to_nxt = _to;
+    result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+#else
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+#endif
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8<wchar_t>::result
+__codecvt_utf8<wchar_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf8<wchar_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf8<wchar_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf8<wchar_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8<wchar_t>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 7;
+    return 4;
+}
+
+// __codecvt_utf8<char16_t>
+
+__codecvt_utf8<char16_t>::result
+__codecvt_utf8<char16_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+    const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+    const uint16_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8<char16_t>::result
+__codecvt_utf8<char16_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+    uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+    uint16_t* _to_nxt = _to;
+    result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8<char16_t>::result
+__codecvt_utf8<char16_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf8<char16_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf8<char16_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf8<char16_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8<char16_t>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 6;
+    return 3;
+}
+
+// __codecvt_utf8<char32_t>
+
+__codecvt_utf8<char32_t>::result
+__codecvt_utf8<char32_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8<char32_t>::result
+__codecvt_utf8<char32_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                            _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8<char32_t>::result
+__codecvt_utf8<char32_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf8<char32_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf8<char32_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf8<char32_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8<char32_t>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 7;
+    return 4;
+}
+
+// __codecvt_utf16<wchar_t, false>
+
+__codecvt_utf16<wchar_t, false>::result
+__codecvt_utf16<wchar_t, false>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<wchar_t, false>::result
+__codecvt_utf16<wchar_t, false>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<wchar_t, false>::result
+__codecvt_utf16<wchar_t, false>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf16<wchar_t, false>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf16<wchar_t, false>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf16<wchar_t, false>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<wchar_t, false>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 6;
+    return 4;
+}
+
+// __codecvt_utf16<wchar_t, true>
+
+__codecvt_utf16<wchar_t, true>::result
+__codecvt_utf16<wchar_t, true>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<wchar_t, true>::result
+__codecvt_utf16<wchar_t, true>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<wchar_t, true>::result
+__codecvt_utf16<wchar_t, true>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf16<wchar_t, true>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf16<wchar_t, true>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf16<wchar_t, true>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<wchar_t, true>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 6;
+    return 4;
+}
+
+// __codecvt_utf16<char16_t, false>
+
+__codecvt_utf16<char16_t, false>::result
+__codecvt_utf16<char16_t, false>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+    const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+    const uint16_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char16_t, false>::result
+__codecvt_utf16<char16_t, false>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+    uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+    uint16_t* _to_nxt = _to;
+    result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char16_t, false>::result
+__codecvt_utf16<char16_t, false>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf16<char16_t, false>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf16<char16_t, false>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf16<char16_t, false>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char16_t, false>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 4;
+    return 2;
+}
+
+// __codecvt_utf16<char16_t, true>
+
+__codecvt_utf16<char16_t, true>::result
+__codecvt_utf16<char16_t, true>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+    const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+    const uint16_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char16_t, true>::result
+__codecvt_utf16<char16_t, true>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+    uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+    uint16_t* _to_nxt = _to;
+    result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char16_t, true>::result
+__codecvt_utf16<char16_t, true>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf16<char16_t, true>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf16<char16_t, true>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf16<char16_t, true>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char16_t, true>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 4;
+    return 2;
+}
+
+// __codecvt_utf16<char32_t, false>
+
+__codecvt_utf16<char32_t, false>::result
+__codecvt_utf16<char32_t, false>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char32_t, false>::result
+__codecvt_utf16<char32_t, false>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char32_t, false>::result
+__codecvt_utf16<char32_t, false>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf16<char32_t, false>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf16<char32_t, false>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf16<char32_t, false>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char32_t, false>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 6;
+    return 4;
+}
+
+// __codecvt_utf16<char32_t, true>
+
+__codecvt_utf16<char32_t, true>::result
+__codecvt_utf16<char32_t, true>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char32_t, true>::result
+__codecvt_utf16<char32_t, true>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                               _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf16<char32_t, true>::result
+__codecvt_utf16<char32_t, true>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf16<char32_t, true>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf16<char32_t, true>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf16<char32_t, true>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf16<char32_t, true>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 6;
+    return 4;
+}
+
+// __codecvt_utf8_utf16<wchar_t>
+
+__codecvt_utf8_utf16<wchar_t>::result
+__codecvt_utf8_utf16<wchar_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                             _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8_utf16<wchar_t>::result
+__codecvt_utf8_utf16<wchar_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                             _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8_utf16<wchar_t>::result
+__codecvt_utf8_utf16<wchar_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf8_utf16<wchar_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf8_utf16<wchar_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf8_utf16<wchar_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8_utf16<wchar_t>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 7;
+    return 4;
+}
+
+// __codecvt_utf8_utf16<char16_t>
+
+__codecvt_utf8_utf16<char16_t>::result
+__codecvt_utf8_utf16<char16_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+    const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+    const uint16_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                             _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8_utf16<char16_t>::result
+__codecvt_utf8_utf16<char16_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+    uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+    uint16_t* _to_nxt = _to;
+    result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                             _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8_utf16<char16_t>::result
+__codecvt_utf8_utf16<char16_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf8_utf16<char16_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf8_utf16<char16_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf8_utf16<char16_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8_utf16<char16_t>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 7;
+    return 4;
+}
+
+// __codecvt_utf8_utf16<char32_t>
+
+__codecvt_utf8_utf16<char32_t>::result
+__codecvt_utf8_utf16<char32_t>::do_out(state_type&,
+    const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
+    extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
+{
+    const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+    const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+    const uint32_t* _frm_nxt = _frm;
+    uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+    uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+    uint8_t* _to_nxt = _to;
+    result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                             _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8_utf16<char32_t>::result
+__codecvt_utf8_utf16<char32_t>::do_in(state_type&,
+    const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
+    intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    const uint8_t* _frm_nxt = _frm;
+    uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+    uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+    uint32_t* _to_nxt = _to;
+    result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
+                             _Maxcode_, _Mode_);
+    frm_nxt = frm + (_frm_nxt - _frm);
+    to_nxt = to + (_to_nxt - _to);
+    return r;
+}
+
+__codecvt_utf8_utf16<char32_t>::result
+__codecvt_utf8_utf16<char32_t>::do_unshift(state_type&,
+    extern_type* to, extern_type*, extern_type*& to_nxt) const
+{
+    to_nxt = to;
+    return noconv;
+}
+
+int
+__codecvt_utf8_utf16<char32_t>::do_encoding() const  _NOEXCEPT
+{
+    return 0;
+}
+
+bool
+__codecvt_utf8_utf16<char32_t>::do_always_noconv() const  _NOEXCEPT
+{
+    return false;
+}
+
+int
+__codecvt_utf8_utf16<char32_t>::do_length(state_type&,
+    const extern_type* frm, const extern_type* frm_end, size_t mx) const
+{
+    const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+    const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+    return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_);
+}
+
+int
+__codecvt_utf8_utf16<char32_t>::do_max_length() const  _NOEXCEPT
+{
+    if (_Mode_ & consume_header)
+        return 7;
+    return 4;
+}
+
+// __narrow_to_utf8<16>
+
+__narrow_to_utf8<16>::~__narrow_to_utf8()
+{
+}
+
+// __narrow_to_utf8<32>
+
+__narrow_to_utf8<32>::~__narrow_to_utf8()
+{
+}
+
+// __widen_from_utf8<16>
+
+__widen_from_utf8<16>::~__widen_from_utf8()
+{
+}
+
+// __widen_from_utf8<32>
+
+__widen_from_utf8<32>::~__widen_from_utf8()
+{
+}
+
+// numpunct<char> && numpunct<wchar_t>
+
+locale::id numpunct< char  >::id;
+locale::id numpunct<wchar_t>::id;
+
+numpunct<char>::numpunct(size_t refs)
+    : locale::facet(refs),
+      __decimal_point_('.'),
+      __thousands_sep_(',')
+{
+}
+
+numpunct<wchar_t>::numpunct(size_t refs)
+    : locale::facet(refs),
+      __decimal_point_(L'.'),
+      __thousands_sep_(L',')
+{
+}
+
+numpunct<char>::~numpunct()
+{
+}
+
+numpunct<wchar_t>::~numpunct()
+{
+}
+
+ char   numpunct< char  >::do_decimal_point() const {return __decimal_point_;}
+wchar_t numpunct<wchar_t>::do_decimal_point() const {return __decimal_point_;}
+
+ char   numpunct< char  >::do_thousands_sep() const {return __thousands_sep_;}
+wchar_t numpunct<wchar_t>::do_thousands_sep() const {return __thousands_sep_;}
+
+string numpunct< char  >::do_grouping() const {return __grouping_;}
+string numpunct<wchar_t>::do_grouping() const {return __grouping_;}
+
+ string numpunct< char  >::do_truename() const {return "true";}
+wstring numpunct<wchar_t>::do_truename() const {return L"true";}
+
+ string numpunct< char  >::do_falsename() const {return "false";}
+wstring numpunct<wchar_t>::do_falsename() const {return L"false";}
+
+// numpunct_byname<char>
+
+numpunct_byname<char>::numpunct_byname(const char* nm, size_t refs)
+    : numpunct<char>(refs)
+{
+    __init(nm);
+}
+
+numpunct_byname<char>::numpunct_byname(const string& nm, size_t refs)
+    : numpunct<char>(refs)
+{
+    __init(nm.c_str());
+}
+
+numpunct_byname<char>::~numpunct_byname()
+{
+}
+
+void
+numpunct_byname<char>::__init(const char* nm)
+{
+    if (strcmp(nm, "C") != 0)
+    {
+        __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (loc == nullptr)
+            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
+        if (*lc->decimal_point)
+            __decimal_point_ = *lc->decimal_point;
+        if (*lc->thousands_sep)
+            __thousands_sep_ = *lc->thousands_sep;
+        __grouping_ = lc->grouping;
+        // localization for truename and falsename is not available
+    }
+}
+
+// numpunct_byname<wchar_t>
+
+numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs)
+    : numpunct<wchar_t>(refs)
+{
+    __init(nm);
+}
+
+numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs)
+    : numpunct<wchar_t>(refs)
+{
+    __init(nm.c_str());
+}
+
+numpunct_byname<wchar_t>::~numpunct_byname()
+{
+}
+
+void
+numpunct_byname<wchar_t>::__init(const char* nm)
+{
+    if (strcmp(nm, "C") != 0)
+    {
+        __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        if (loc == nullptr)
+            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
+        if (*lc->decimal_point)
+            __decimal_point_ = *lc->decimal_point;
+        if (*lc->thousands_sep)
+            __thousands_sep_ = *lc->thousands_sep;
+        __grouping_ = lc->grouping;
+        // locallization for truename and falsename is not available
+    }
+}
+
+// num_get helpers
+
+int
+__num_get_base::__get_base(ios_base& iob)
+{
+    ios_base::fmtflags __basefield = iob.flags() & ios_base::basefield;
+    if (__basefield == ios_base::oct)
+        return 8;
+    else if (__basefield == ios_base::hex)
+        return 16;
+    else if (__basefield == 0)
+        return 0;
+    return 10;
+}
+
+const char __num_get_base::__src[33] = "0123456789abcdefABCDEFxX+-pPiInN";
+
+void
+__check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
+                 ios_base::iostate& __err)
+{
+    if (__grouping.size() != 0)
+    {
+        reverse(__g, __g_end);
+        const char* __ig = __grouping.data();
+        const char* __eg = __ig + __grouping.size();
+        for (unsigned* __r = __g; __r < __g_end-1; ++__r)
+        {
+            if (0 < *__ig && *__ig < numeric_limits<char>::max())
+            {
+                if (static_cast<unsigned>(*__ig) != *__r)
+                {
+                    __err = ios_base::failbit;
+                    return;
+                }
+            }
+            if (__eg - __ig > 1)
+                ++__ig;
+        }
+        if (0 < *__ig && *__ig < numeric_limits<char>::max())
+        {
+            if (static_cast<unsigned>(*__ig) < __g_end[-1] || __g_end[-1] == 0)
+                __err = ios_base::failbit;
+        }
+    }
+}
+
+void
+__num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd,
+                             ios_base::fmtflags __flags)
+{
+    if (__flags & ios_base::showpos)
+        *__fmtp++ = '+';
+    if (__flags & ios_base::showbase)
+        *__fmtp++ = '#';
+    while(*__len)
+        *__fmtp++ = *__len++;
+    if ((__flags & ios_base::basefield) == ios_base::oct)
+        *__fmtp = 'o';
+    else if ((__flags & ios_base::basefield) == ios_base::hex)
+    {
+        if (__flags & ios_base::uppercase)
+            *__fmtp = 'X';
+        else
+            *__fmtp = 'x';
+    }
+    else if (__signd)
+        *__fmtp = 'd';
+    else
+        *__fmtp = 'u';
+}
+
+bool
+__num_put_base::__format_float(char* __fmtp, const char* __len,
+                               ios_base::fmtflags __flags)
+{
+    bool specify_precision = true;
+    if (__flags & ios_base::showpos)
+        *__fmtp++ = '+';
+    if (__flags & ios_base::showpoint)
+        *__fmtp++ = '#';
+    ios_base::fmtflags floatfield = __flags & ios_base::floatfield;
+    bool uppercase = (__flags & ios_base::uppercase) != 0;
+    if (floatfield == (ios_base::fixed | ios_base::scientific))
+        specify_precision = false;
+    else
+    {
+        *__fmtp++ = '.';
+        *__fmtp++ = '*';
+    }
+    while(*__len)
+        *__fmtp++ = *__len++;
+    if (floatfield == ios_base::fixed)
+    {
+        if (uppercase)
+            *__fmtp = 'F';
+        else
+            *__fmtp = 'f';
+    }
+    else if (floatfield == ios_base::scientific)
+    {
+        if (uppercase)
+            *__fmtp = 'E';
+        else
+            *__fmtp = 'e';
+    }
+    else if (floatfield == (ios_base::fixed | ios_base::scientific))
+    {
+        if (uppercase)
+            *__fmtp = 'A';
+        else
+            *__fmtp = 'a';
+    }
+    else
+    {
+        if (uppercase)
+            *__fmtp = 'G';
+        else
+            *__fmtp = 'g';
+    }
+    return specify_precision;
+}
+
+char*
+__num_put_base::__identify_padding(char* __nb, char* __ne,
+                                   const ios_base& __iob)
+{
+    switch (__iob.flags() & ios_base::adjustfield)
+    {
+    case ios_base::internal:
+        if (__nb[0] == '-' || __nb[0] == '+')
+            return __nb+1;
+        if (__ne - __nb >= 2 && __nb[0] == '0'
+                            && (__nb[1] == 'x' || __nb[1] == 'X'))
+            return __nb+2;
+        break;
+    case ios_base::left:
+        return __ne;
+    case ios_base::right:
+    default:
+        break;
+    }
+    return __nb;
+}
+
+// time_get
+
+static
+string*
+init_weeks()
+{
+    static string weeks[14];
+    weeks[0]  = "Sunday";
+    weeks[1]  = "Monday";
+    weeks[2]  = "Tuesday";
+    weeks[3]  = "Wednesday";
+    weeks[4]  = "Thursday";
+    weeks[5]  = "Friday";
+    weeks[6]  = "Saturday";
+    weeks[7]  = "Sun";
+    weeks[8]  = "Mon";
+    weeks[9]  = "Tue";
+    weeks[10] = "Wed";
+    weeks[11] = "Thu";
+    weeks[12] = "Fri";
+    weeks[13] = "Sat";
+    return weeks;
+}
+
+static
+wstring*
+init_wweeks()
+{
+    static wstring weeks[14];
+    weeks[0]  = L"Sunday";
+    weeks[1]  = L"Monday";
+    weeks[2]  = L"Tuesday";
+    weeks[3]  = L"Wednesday";
+    weeks[4]  = L"Thursday";
+    weeks[5]  = L"Friday";
+    weeks[6]  = L"Saturday";
+    weeks[7]  = L"Sun";
+    weeks[8]  = L"Mon";
+    weeks[9]  = L"Tue";
+    weeks[10] = L"Wed";
+    weeks[11] = L"Thu";
+    weeks[12] = L"Fri";
+    weeks[13] = L"Sat";
+    return weeks;
+}
+
+template <>
+const string*
+__time_get_c_storage<char>::__weeks() const
+{
+    static const string* weeks = init_weeks();
+    return weeks;
+}
+
+template <>
+const wstring*
+__time_get_c_storage<wchar_t>::__weeks() const
+{
+    static const wstring* weeks = init_wweeks();
+    return weeks;
+}
+
+static
+string*
+init_months()
+{
+    static string months[24];
+    months[0]  = "January";
+    months[1]  = "February";
+    months[2]  = "March";
+    months[3]  = "April";
+    months[4]  = "May";
+    months[5]  = "June";
+    months[6]  = "July";
+    months[7]  = "August";
+    months[8]  = "September";
+    months[9]  = "October";
+    months[10] = "November";
+    months[11] = "December";
+    months[12] = "Jan";
+    months[13] = "Feb";
+    months[14] = "Mar";
+    months[15] = "Apr";
+    months[16] = "May";
+    months[17] = "Jun";
+    months[18] = "Jul";
+    months[19] = "Aug";
+    months[20] = "Sep";
+    months[21] = "Oct";
+    months[22] = "Nov";
+    months[23] = "Dec";
+    return months;
+}
+
+static
+wstring*
+init_wmonths()
+{
+    static wstring months[24];
+    months[0]  = L"January";
+    months[1]  = L"February";
+    months[2]  = L"March";
+    months[3]  = L"April";
+    months[4]  = L"May";
+    months[5]  = L"June";
+    months[6]  = L"July";
+    months[7]  = L"August";
+    months[8]  = L"September";
+    months[9]  = L"October";
+    months[10] = L"November";
+    months[11] = L"December";
+    months[12] = L"Jan";
+    months[13] = L"Feb";
+    months[14] = L"Mar";
+    months[15] = L"Apr";
+    months[16] = L"May";
+    months[17] = L"Jun";
+    months[18] = L"Jul";
+    months[19] = L"Aug";
+    months[20] = L"Sep";
+    months[21] = L"Oct";
+    months[22] = L"Nov";
+    months[23] = L"Dec";
+    return months;
+}
+
+template <>
+const string*
+__time_get_c_storage<char>::__months() const
+{
+    static const string* months = init_months();
+    return months;
+}
+
+template <>
+const wstring*
+__time_get_c_storage<wchar_t>::__months() const
+{
+    static const wstring* months = init_wmonths();
+    return months;
+}
+
+static
+string*
+init_am_pm()
+{
+    static string am_pm[24];
+    am_pm[0]  = "AM";
+    am_pm[1]  = "PM";
+    return am_pm;
+}
+
+static
+wstring*
+init_wam_pm()
+{
+    static wstring am_pm[24];
+    am_pm[0]  = L"AM";
+    am_pm[1]  = L"PM";
+    return am_pm;
+}
+
+template <>
+const string*
+__time_get_c_storage<char>::__am_pm() const
+{
+    static const string* am_pm = init_am_pm();
+    return am_pm;
+}
+
+template <>
+const wstring*
+__time_get_c_storage<wchar_t>::__am_pm() const
+{
+    static const wstring* am_pm = init_wam_pm();
+    return am_pm;
+}
+
+template <>
+const string&
+__time_get_c_storage<char>::__x() const
+{
+    static string s("%m/%d/%y");
+    return s;
+}
+
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__x() const
+{
+    static wstring s(L"%m/%d/%y");
+    return s;
+}
+
+template <>
+const string&
+__time_get_c_storage<char>::__X() const
+{
+    static string s("%H:%M:%S");
+    return s;
+}
+
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__X() const
+{
+    static wstring s(L"%H:%M:%S");
+    return s;
+}
+
+template <>
+const string&
+__time_get_c_storage<char>::__c() const
+{
+    static string s("%a %b %d %H:%M:%S %Y");
+    return s;
+}
+
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__c() const
+{
+    static wstring s(L"%a %b %d %H:%M:%S %Y");
+    return s;
+}
+
+template <>
+const string&
+__time_get_c_storage<char>::__r() const
+{
+    static string s("%I:%M:%S %p");
+    return s;
+}
+
+template <>
+const wstring&
+__time_get_c_storage<wchar_t>::__r() const
+{
+    static wstring s(L"%I:%M:%S %p");
+    return s;
+}
+
+// time_get_byname
+
+__time_get::__time_get(const char* nm)
+    : __loc_(newlocale(LC_ALL_MASK, nm, 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__loc_ == 0)
+        throw runtime_error("time_get_byname"
+                            " failed to construct for " + string(nm));
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+__time_get::__time_get(const string& nm)
+    : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__loc_ == 0)
+        throw runtime_error("time_get_byname"
+                            " failed to construct for " + nm);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+__time_get::~__time_get()
+{
+    freelocale(__loc_);
+}
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#endif
+#if defined(__GNUG__)
+#pragma GCC   diagnostic ignored "-Wmissing-field-initializers"
+#endif
+
+template <>
+string
+__time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
+{
+    tm t = {0};
+    t.tm_sec = 59;
+    t.tm_min = 55;
+    t.tm_hour = 23;
+    t.tm_mday = 31;
+    t.tm_mon = 11;
+    t.tm_year = 161;
+    t.tm_wday = 6;
+    t.tm_yday = 364;
+    t.tm_isdst = -1;
+    char buf[100];
+    char f[3] = {0};
+    f[0] = '%';
+    f[1] = fmt;
+    size_t n = strftime_l(buf, countof(buf), f, &t, __loc_);
+    char* bb = buf;
+    char* be = buf + n;
+    string result;
+    while (bb != be)
+    {
+        if (ct.is(ctype_base::space, *bb))
+        {
+            result.push_back(' ');
+            for (++bb; bb != be && ct.is(ctype_base::space, *bb); ++bb)
+                ;
+            continue;
+        }
+        char* w = bb;
+        ios_base::iostate err = ios_base::goodbit;
+        ptrdiff_t i = __scan_keyword(w, be, this->__weeks_, this->__weeks_+14,
+                               ct, err, false)
+                               - this->__weeks_;
+        if (i < 14)
+        {
+            result.push_back('%');
+            if (i < 7)
+                result.push_back('A');
+            else
+                result.push_back('a');
+            bb = w;
+            continue;
+        }
+        w = bb;
+        i = __scan_keyword(w, be, this->__months_, this->__months_+24,
+                           ct, err, false)
+                           - this->__months_;
+        if (i < 24)
+        {
+            result.push_back('%');
+            if (i < 12)
+                result.push_back('B');
+            else
+                result.push_back('b');
+            if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
+                result.back() = 'm';
+            bb = w;
+            continue;
+        }
+        if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0)
+        {
+            w = bb;
+            i = __scan_keyword(w, be, this->__am_pm_, this->__am_pm_+2,
+                               ct, err, false) - this->__am_pm_;
+            if (i < 2)
+            {
+                result.push_back('%');
+                result.push_back('p');
+                bb = w;
+                continue;
+            }
+        }
+        w = bb;
+        if (ct.is(ctype_base::digit, *bb))
+        {
+            switch(__get_up_to_n_digits(bb, be, err, ct, 4))
+            {
+            case 6:
+                result.push_back('%');
+                result.push_back('w');
+                break;
+            case 7:
+                result.push_back('%');
+                result.push_back('u');
+                break;
+            case 11:
+                result.push_back('%');
+                result.push_back('I');
+                break;
+            case 12:
+                result.push_back('%');
+                result.push_back('m');
+                break;
+            case 23:
+                result.push_back('%');
+                result.push_back('H');
+                break;
+            case 31:
+                result.push_back('%');
+                result.push_back('d');
+                break;
+            case 55:
+                result.push_back('%');
+                result.push_back('M');
+                break;
+            case 59:
+                result.push_back('%');
+                result.push_back('S');
+                break;
+            case 61:
+                result.push_back('%');
+                result.push_back('y');
+                break;
+            case 364:
+                result.push_back('%');
+                result.push_back('j');
+                break;
+            case 2061:
+                result.push_back('%');
+                result.push_back('Y');
+                break;
+            default:
+                for (; w != bb; ++w)
+                    result.push_back(*w);
+                break;
+            }
+            continue;
+        }
+        if (*bb == '%')
+        {
+            result.push_back('%');
+            result.push_back('%');
+            ++bb;
+            continue;
+        }
+        result.push_back(*bb);
+        ++bb;
+    }
+    return result;
+}
+
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wmissing-braces"
+#endif
+
+template <>
+wstring
+__time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
+{
+    tm t = {0};
+    t.tm_sec = 59;
+    t.tm_min = 55;
+    t.tm_hour = 23;
+    t.tm_mday = 31;
+    t.tm_mon = 11;
+    t.tm_year = 161;
+    t.tm_wday = 6;
+    t.tm_yday = 364;
+    t.tm_isdst = -1;
+    char buf[100];
+    char f[3] = {0};
+    f[0] = '%';
+    f[1] = fmt;
+    strftime_l(buf, countof(buf), f, &t, __loc_);
+    wchar_t wbuf[100];
+    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
+    if (j == size_t(-1))
+        __throw_runtime_error("locale not supported");
+    wchar_t* wbe = wbb + j;
+    wstring result;
+    while (wbb != wbe)
+    {
+        if (ct.is(ctype_base::space, *wbb))
+        {
+            result.push_back(L' ');
+            for (++wbb; wbb != wbe && ct.is(ctype_base::space, *wbb); ++wbb)
+                ;
+            continue;
+        }
+        wchar_t* w = wbb;
+        ios_base::iostate err = ios_base::goodbit;
+        ptrdiff_t i = __scan_keyword(w, wbe, this->__weeks_, this->__weeks_+14,
+                               ct, err, false)
+                               - this->__weeks_;
+        if (i < 14)
+        {
+            result.push_back(L'%');
+            if (i < 7)
+                result.push_back(L'A');
+            else
+                result.push_back(L'a');
+            wbb = w;
+            continue;
+        }
+        w = wbb;
+        i = __scan_keyword(w, wbe, this->__months_, this->__months_+24,
+                           ct, err, false)
+                           - this->__months_;
+        if (i < 24)
+        {
+            result.push_back(L'%');
+            if (i < 12)
+                result.push_back(L'B');
+            else
+                result.push_back(L'b');
+            if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
+                result.back() = L'm';
+            wbb = w;
+            continue;
+        }
+        if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0)
+        {
+            w = wbb;
+            i = __scan_keyword(w, wbe, this->__am_pm_, this->__am_pm_+2,
+                               ct, err, false) - this->__am_pm_;
+            if (i < 2)
+            {
+                result.push_back(L'%');
+                result.push_back(L'p');
+                wbb = w;
+                continue;
+            }
+        }
+        w = wbb;
+        if (ct.is(ctype_base::digit, *wbb))
+        {
+            switch(__get_up_to_n_digits(wbb, wbe, err, ct, 4))
+            {
+            case 6:
+                result.push_back(L'%');
+                result.push_back(L'w');
+                break;
+            case 7:
+                result.push_back(L'%');
+                result.push_back(L'u');
+                break;
+            case 11:
+                result.push_back(L'%');
+                result.push_back(L'I');
+                break;
+            case 12:
+                result.push_back(L'%');
+                result.push_back(L'm');
+                break;
+            case 23:
+                result.push_back(L'%');
+                result.push_back(L'H');
+                break;
+            case 31:
+                result.push_back(L'%');
+                result.push_back(L'd');
+                break;
+            case 55:
+                result.push_back(L'%');
+                result.push_back(L'M');
+                break;
+            case 59:
+                result.push_back(L'%');
+                result.push_back(L'S');
+                break;
+            case 61:
+                result.push_back(L'%');
+                result.push_back(L'y');
+                break;
+            case 364:
+                result.push_back(L'%');
+                result.push_back(L'j');
+                break;
+            case 2061:
+                result.push_back(L'%');
+                result.push_back(L'Y');
+                break;
+            default:
+                for (; w != wbb; ++w)
+                    result.push_back(*w);
+                break;
+            }
+            continue;
+        }
+        if (ct.narrow(*wbb, 0) == '%')
+        {
+            result.push_back(L'%');
+            result.push_back(L'%');
+            ++wbb;
+            continue;
+        }
+        result.push_back(*wbb);
+        ++wbb;
+    }
+    return result;
+}
+
+template <>
+void
+__time_get_storage<char>::init(const ctype<char>& ct)
+{
+    tm t = {0};
+    char buf[100];
+    // __weeks_
+    for (int i = 0; i < 7; ++i)
+    {
+        t.tm_wday = i;
+        strftime_l(buf, countof(buf), "%A", &t, __loc_);
+        __weeks_[i] = buf;
+        strftime_l(buf, countof(buf), "%a", &t, __loc_);
+        __weeks_[i+7] = buf;
+    }
+    // __months_
+    for (int i = 0; i < 12; ++i)
+    {
+        t.tm_mon = i;
+        strftime_l(buf, countof(buf), "%B", &t, __loc_);
+        __months_[i] = buf;
+        strftime_l(buf, countof(buf), "%b", &t, __loc_);
+        __months_[i+12] = buf;
+    }
+    // __am_pm_
+    t.tm_hour = 1;
+    strftime_l(buf, countof(buf), "%p", &t, __loc_);
+    __am_pm_[0] = buf;
+    t.tm_hour = 13;
+    strftime_l(buf, countof(buf), "%p", &t, __loc_);
+    __am_pm_[1] = buf;
+    __c_ = __analyze('c', ct);
+    __r_ = __analyze('r', ct);
+    __x_ = __analyze('x', ct);
+    __X_ = __analyze('X', ct);
+}
+
+template <>
+void
+__time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
+{
+    tm t = {0};
+    char buf[100];
+    wchar_t wbuf[100];
+    wchar_t* wbe;
+    mbstate_t mb = {0};
+    // __weeks_
+    for (int i = 0; i < 7; ++i)
+    {
+        t.tm_wday = i;
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __weeks_[i].assign(wbuf, wbe);
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __weeks_[i+7].assign(wbuf, wbe);
+    }
+    // __months_
+    for (int i = 0; i < 12; ++i)
+    {
+        t.tm_mon = i;
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __months_[i].assign(wbuf, wbe);
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __months_[i+12].assign(wbuf, wbe);
+    }
+    // __am_pm_
+    t.tm_hour = 1;
+    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
+    if (j == size_t(-1))
+        __throw_runtime_error("locale not supported");
+    wbe = wbuf + j;
+    __am_pm_[0].assign(wbuf, wbe);
+    t.tm_hour = 13;
+    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
+    if (j == size_t(-1))
+        __throw_runtime_error("locale not supported");
+    wbe = wbuf + j;
+    __am_pm_[1].assign(wbuf, wbe);
+    __c_ = __analyze('c', ct);
+    __r_ = __analyze('r', ct);
+    __x_ = __analyze('x', ct);
+    __X_ = __analyze('X', ct);
+}
+
+template <class CharT>
+struct _LIBCPP_HIDDEN __time_get_temp
+    : public ctype_byname<CharT>
+{
+    explicit __time_get_temp(const char* nm)
+        : ctype_byname<CharT>(nm, 1) {}
+    explicit __time_get_temp(const string& nm)
+        : ctype_byname<CharT>(nm, 1) {}
+};
+
+template <>
+__time_get_storage<char>::__time_get_storage(const char* __nm)
+    : __time_get(__nm)
+{
+    const __time_get_temp<char> ct(__nm);
+    init(ct);
+}
+
+template <>
+__time_get_storage<char>::__time_get_storage(const string& __nm)
+    : __time_get(__nm)
+{
+    const __time_get_temp<char> ct(__nm);
+    init(ct);
+}
+
+template <>
+__time_get_storage<wchar_t>::__time_get_storage(const char* __nm)
+    : __time_get(__nm)
+{
+    const __time_get_temp<wchar_t> ct(__nm);
+    init(ct);
+}
+
+template <>
+__time_get_storage<wchar_t>::__time_get_storage(const string& __nm)
+    : __time_get(__nm)
+{
+    const __time_get_temp<wchar_t> ct(__nm);
+    init(ct);
+}
+
+template <>
+time_base::dateorder
+__time_get_storage<char>::__do_date_order() const
+{
+    unsigned i;
+    for (i = 0; i < __x_.size(); ++i)
+        if (__x_[i] == '%')
+            break;
+    ++i;
+    switch (__x_[i])
+    {
+    case 'y':
+    case 'Y':
+        for (++i; i < __x_.size(); ++i)
+            if (__x_[i] == '%')
+                break;
+        if (i == __x_.size())
+            break;
+        ++i;
+        switch (__x_[i])
+        {
+        case 'm':
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == '%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == 'd')
+                return time_base::ymd;
+            break;
+        case 'd':
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == '%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == 'm')
+                return time_base::ydm;
+            break;
+        }
+        break;
+    case 'm':
+        for (++i; i < __x_.size(); ++i)
+            if (__x_[i] == '%')
+                break;
+        if (i == __x_.size())
+            break;
+        ++i;
+        if (__x_[i] == 'd')
+        {
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == '%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == 'y' || __x_[i] == 'Y')
+                return time_base::mdy;
+            break;
+        }
+        break;
+    case 'd':
+        for (++i; i < __x_.size(); ++i)
+            if (__x_[i] == '%')
+                break;
+        if (i == __x_.size())
+            break;
+        ++i;
+        if (__x_[i] == 'm')
+        {
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == '%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == 'y' || __x_[i] == 'Y')
+                return time_base::dmy;
+            break;
+        }
+        break;
+    }
+    return time_base::no_order;
+}
+
+template <>
+time_base::dateorder
+__time_get_storage<wchar_t>::__do_date_order() const
+{
+    unsigned i;
+    for (i = 0; i < __x_.size(); ++i)
+        if (__x_[i] == L'%')
+            break;
+    ++i;
+    switch (__x_[i])
+    {
+    case L'y':
+    case L'Y':
+        for (++i; i < __x_.size(); ++i)
+            if (__x_[i] == L'%')
+                break;
+        if (i == __x_.size())
+            break;
+        ++i;
+        switch (__x_[i])
+        {
+        case L'm':
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == L'%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == L'd')
+                return time_base::ymd;
+            break;
+        case L'd':
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == L'%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == L'm')
+                return time_base::ydm;
+            break;
+        }
+        break;
+    case L'm':
+        for (++i; i < __x_.size(); ++i)
+            if (__x_[i] == L'%')
+                break;
+        if (i == __x_.size())
+            break;
+        ++i;
+        if (__x_[i] == L'd')
+        {
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == L'%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == L'y' || __x_[i] == L'Y')
+                return time_base::mdy;
+            break;
+        }
+        break;
+    case L'd':
+        for (++i; i < __x_.size(); ++i)
+            if (__x_[i] == L'%')
+                break;
+        if (i == __x_.size())
+            break;
+        ++i;
+        if (__x_[i] == L'm')
+        {
+            for (++i; i < __x_.size(); ++i)
+                if (__x_[i] == L'%')
+                    break;
+            if (i == __x_.size())
+                break;
+            ++i;
+            if (__x_[i] == L'y' || __x_[i] == L'Y')
+                return time_base::dmy;
+            break;
+        }
+        break;
+    }
+    return time_base::no_order;
+}
+
+// time_put
+
+__time_put::__time_put(const char* nm)
+    : __loc_(newlocale(LC_ALL_MASK, nm, 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__loc_ == 0)
+        throw runtime_error("time_put_byname"
+                            " failed to construct for " + string(nm));
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+__time_put::__time_put(const string& nm)
+    : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (__loc_ == 0)
+        throw runtime_error("time_put_byname"
+                            " failed to construct for " + nm);
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+__time_put::~__time_put()
+{
+    if (__loc_ != _LIBCPP_GET_C_LOCALE)
+        freelocale(__loc_);
+}
+
+void
+__time_put::__do_put(char* __nb, char*& __ne, const tm* __tm,
+                     char __fmt, char __mod) const
+{
+    char fmt[] = {'%', __fmt, __mod, 0};
+    if (__mod != 0)
+        swap(fmt[1], fmt[2]);
+    size_t n = strftime_l(__nb, countof(__nb, __ne), fmt, __tm, __loc_);
+    __ne = __nb + n;
+}
+
+void
+__time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
+                     char __fmt, char __mod) const
+{
+    char __nar[100];
+    char* __ne = __nar + 100;
+    __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
+    if (j == size_t(-1))
+        __throw_runtime_error("locale not supported");
+    __we = __wb + j;
+}
+
+// moneypunct_byname
+
+template <class charT>
+static
+void
+__init_pat(money_base::pattern& pat, basic_string<charT>& __curr_symbol_,
+           bool intl, char cs_precedes, char sep_by_space, char sign_posn,
+           charT space_char)
+{
+    const char sign = static_cast<char>(money_base::sign);
+    const char space = static_cast<char>(money_base::space);
+    const char none = static_cast<char>(money_base::none);
+    const char symbol = static_cast<char>(money_base::symbol);
+    const char value = static_cast<char>(money_base::value);
+    const bool symbol_contains_sep = intl && __curr_symbol_.size() == 4;
+
+    // Comments on case branches reflect 'C11 7.11.2.1 The localeconv
+    // function'. "Space between sign and symbol or value" means that
+    // if the sign is adjacent to the symbol, there's a space between
+    // them, and otherwise there's a space between the sign and value.
+    //
+    // C11's localeconv specifies that the fourth character of an
+    // international curr_symbol is used to separate the sign and
+    // value when sep_by_space says to do so. C++ can't represent
+    // that, so we just use a space.  When sep_by_space says to
+    // separate the symbol and value-or-sign with a space, we rearrange the
+    // curr_symbol to put its spacing character on the correct side of
+    // the symbol.
+    //
+    // We also need to avoid adding an extra space between the sign
+    // and value when the currency symbol is suppressed (by not
+    // setting showbase).  We match glibc's strfmon by interpreting
+    // sep_by_space==1 as "omit the space when the currency symbol is
+    // absent".
+    //
+    // Users who want to get this right should use ICU instead.
+
+    switch (cs_precedes)
+    {
+    case 0:  // value before curr_symbol
+        if (symbol_contains_sep) {
+            // Move the separator to before the symbol, to place it
+            // between the value and symbol.
+            rotate(__curr_symbol_.begin(), __curr_symbol_.begin() + 3,
+                   __curr_symbol_.end());
+        }
+        switch (sign_posn)
+        {
+        case 0:  // Parentheses surround the quantity and currency symbol.
+            pat.field[0] = sign;
+            pat.field[1] = value;
+            pat.field[2] = none;  // Any space appears in the symbol.
+            pat.field[3] = symbol;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                // This case may have changed between C99 and C11;
+                // assume the currency symbol matches the intention.
+            case 2:  // Space between sign and currency or value.
+                // The "sign" is two parentheses, so no space here either.
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[2]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.insert(0, 1, space_char);
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 1:  // The sign string precedes the quantity and currency symbol.
+            pat.field[0] = sign;
+            pat.field[3] = symbol;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = value;
+                pat.field[2] = none;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                pat.field[1] = value;
+                pat.field[2] = none;
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[2]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.insert(0, 1, space_char);
+                }
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = space;
+                pat.field[2] = value;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // has already appeared after the sign.
+                    __curr_symbol_.erase(__curr_symbol_.begin());
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 2:  // The sign string succeeds the quantity and currency symbol.
+            pat.field[0] = value;
+            pat.field[3] = sign;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = none;
+                pat.field[2] = symbol;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[1]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.insert(0, 1, space_char);
+                }
+                pat.field[1] = none;
+                pat.field[2] = symbol;
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = symbol;
+                pat.field[2] = space;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // should not be removed if showbase is absent.
+                    __curr_symbol_.erase(__curr_symbol_.begin());
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 3:  // The sign string immediately precedes the currency symbol.
+            pat.field[0] = value;
+            pat.field[3] = symbol;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = none;
+                pat.field[2] = sign;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                pat.field[1] = space;
+                pat.field[2] = sign;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // has already appeared before the sign.
+                    __curr_symbol_.erase(__curr_symbol_.begin());
+                }
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = sign;
+                pat.field[2] = none;
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[2]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.insert(0, 1, space_char);
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 4:  // The sign string immediately succeeds the currency symbol.
+            pat.field[0] = value;
+            pat.field[3] = sign;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = none;
+                pat.field[2] = symbol;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                pat.field[1] = none;
+                pat.field[2] = symbol;
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[1]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.insert(0, 1, space_char);
+                }
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = symbol;
+                pat.field[2] = space;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // should not disappear when showbase is absent.
+                    __curr_symbol_.erase(__curr_symbol_.begin());
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        default:
+            break;
+        }
+        break;
+    case 1:  // curr_symbol before value
+        switch (sign_posn)
+        {
+        case 0:  // Parentheses surround the quantity and currency symbol.
+            pat.field[0] = sign;
+            pat.field[1] = symbol;
+            pat.field[2] = none;  // Any space appears in the symbol.
+            pat.field[3] = value;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                // This case may have changed between C99 and C11;
+                // assume the currency symbol matches the intention.
+            case 2:  // Space between sign and currency or value.
+                // The "sign" is two parentheses, so no space here either.
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[2]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.insert(0, 1, space_char);
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 1:  // The sign string precedes the quantity and currency symbol.
+            pat.field[0] = sign;
+            pat.field[3] = value;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = symbol;
+                pat.field[2] = none;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                pat.field[1] = symbol;
+                pat.field[2] = none;
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[2]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.push_back(space_char);
+                }
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = space;
+                pat.field[2] = symbol;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // has already appeared after the sign.
+                    __curr_symbol_.pop_back();
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 2:  // The sign string succeeds the quantity and currency symbol.
+            pat.field[0] = symbol;
+            pat.field[3] = sign;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = none;
+                pat.field[2] = value;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                pat.field[1] = none;
+                pat.field[2] = value;
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[1]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.push_back(space_char);
+                }
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = value;
+                pat.field[2] = space;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // will appear before the sign.
+                    __curr_symbol_.pop_back();
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 3:  // The sign string immediately precedes the currency symbol.
+            pat.field[0] = sign;
+            pat.field[3] = value;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = symbol;
+                pat.field[2] = none;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                pat.field[1] = symbol;
+                pat.field[2] = none;
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[2]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.push_back(space_char);
+                }
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = space;
+                pat.field[2] = symbol;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // has already appeared after the sign.
+                    __curr_symbol_.pop_back();
+                }
+                return;
+            default:
+                break;
+            }
+            break;
+        case 4:  // The sign string immediately succeeds the currency symbol.
+            pat.field[0] = symbol;
+            pat.field[3] = value;
+            switch (sep_by_space)
+            {
+            case 0:  // No space separates the currency symbol and value.
+                pat.field[1] = sign;
+                pat.field[2] = none;
+                return;
+            case 1:  // Space between currency-and-sign or currency and value.
+                pat.field[1] = sign;
+                pat.field[2] = space;
+                if (symbol_contains_sep) {
+                    // Remove the separator from the symbol, since it
+                    // should not disappear when showbase is absent.
+                    __curr_symbol_.pop_back();
+                }
+                return;
+            case 2:  // Space between sign and currency or value.
+                pat.field[1] = none;
+                pat.field[2] = sign;
+                if (!symbol_contains_sep) {
+                    // We insert the space into the symbol instead of
+                    // setting pat.field[1]=space so that when
+                    // showbase is not set, the space goes away too.
+                    __curr_symbol_.push_back(space_char);
+                }
+                return;
+           default:
+                break;
+            }
+            break;
+        default:
+            break;
+        }
+        break;
+    default:
+        break;
+    }
+    pat.field[0] = symbol;
+    pat.field[1] = sign;
+    pat.field[2] = none;
+    pat.field[3] = value;
+}
+
+template<>
+void
+moneypunct_byname<char, false>::init(const char* nm)
+{
+    typedef moneypunct<char, false> base;
+    __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (loc == nullptr)
+        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
+    if (*lc->mon_decimal_point)
+        __decimal_point_ = *lc->mon_decimal_point;
+    else
+        __decimal_point_ = base::do_decimal_point();
+    if (*lc->mon_thousands_sep)
+        __thousands_sep_ = *lc->mon_thousands_sep;
+    else
+        __thousands_sep_ = base::do_thousands_sep();
+    __grouping_ = lc->mon_grouping;
+    __curr_symbol_ = lc->currency_symbol;
+    if (lc->frac_digits != CHAR_MAX)
+        __frac_digits_ = lc->frac_digits;
+    else
+        __frac_digits_ = base::do_frac_digits();
+    if (lc->p_sign_posn == 0)
+        __positive_sign_ = "()";
+    else
+        __positive_sign_ = lc->positive_sign;
+    if (lc->n_sign_posn == 0)
+        __negative_sign_ = "()";
+    else
+        __negative_sign_ = lc->negative_sign;
+    // Assume the positive and negative formats will want spaces in
+    // the same places in curr_symbol since there's no way to
+    // represent anything else.
+    string_type __dummy_curr_symbol = __curr_symbol_;
+    __init_pat(__pos_format_, __dummy_curr_symbol, false,
+               lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
+    __init_pat(__neg_format_, __curr_symbol_, false,
+               lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
+}
+
+template<>
+void
+moneypunct_byname<char, true>::init(const char* nm)
+{
+    typedef moneypunct<char, true> base;
+    __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (loc == nullptr)
+        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
+    if (*lc->mon_decimal_point)
+        __decimal_point_ = *lc->mon_decimal_point;
+    else
+        __decimal_point_ = base::do_decimal_point();
+    if (*lc->mon_thousands_sep)
+        __thousands_sep_ = *lc->mon_thousands_sep;
+    else
+        __thousands_sep_ = base::do_thousands_sep();
+    __grouping_ = lc->mon_grouping;
+    __curr_symbol_ = lc->int_curr_symbol;
+    if (lc->int_frac_digits != CHAR_MAX)
+        __frac_digits_ = lc->int_frac_digits;
+    else
+        __frac_digits_ = base::do_frac_digits();
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+    if (lc->p_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+    if (lc->int_p_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+        __positive_sign_ = "()";
+    else
+        __positive_sign_ = lc->positive_sign;
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+    if(lc->n_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+    if (lc->int_n_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+        __negative_sign_ = "()";
+    else
+        __negative_sign_ = lc->negative_sign;
+    // Assume the positive and negative formats will want spaces in
+    // the same places in curr_symbol since there's no way to
+    // represent anything else.
+    string_type __dummy_curr_symbol = __curr_symbol_;
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+    __init_pat(__pos_format_, __dummy_curr_symbol, true,
+               lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
+    __init_pat(__neg_format_, __curr_symbol_, true,
+               lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
+#else // _LIBCPP_MSVCRT
+    __init_pat(__pos_format_, __dummy_curr_symbol, true,
+               lc->int_p_cs_precedes, lc->int_p_sep_by_space,
+               lc->int_p_sign_posn, ' ');
+    __init_pat(__neg_format_, __curr_symbol_, true,
+               lc->int_n_cs_precedes, lc->int_n_sep_by_space,
+               lc->int_n_sign_posn, ' ');
+#endif // !_LIBCPP_MSVCRT
+}
+
+template<>
+void
+moneypunct_byname<wchar_t, false>::init(const char* nm)
+{
+    typedef moneypunct<wchar_t, false> base;
+    __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (loc == nullptr)
+        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
+    if (*lc->mon_decimal_point)
+        __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
+    else
+        __decimal_point_ = base::do_decimal_point();
+    if (*lc->mon_thousands_sep)
+        __thousands_sep_ = static_cast<wchar_t>(*lc->mon_thousands_sep);
+    else
+        __thousands_sep_ = base::do_thousands_sep();
+    __grouping_ = lc->mon_grouping;
+    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
+    if (j == size_t(-1))
+        __throw_runtime_error("locale not supported");
+    wchar_t* wbe = wbuf + j;
+    __curr_symbol_.assign(wbuf, wbe);
+    if (lc->frac_digits != CHAR_MAX)
+        __frac_digits_ = lc->frac_digits;
+    else
+        __frac_digits_ = base::do_frac_digits();
+    if (lc->p_sign_posn == 0)
+        __positive_sign_ = L"()";
+    else
+    {
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __positive_sign_.assign(wbuf, wbe);
+    }
+    if (lc->n_sign_posn == 0)
+        __negative_sign_ = L"()";
+    else
+    {
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __negative_sign_.assign(wbuf, wbe);
+    }
+    // Assume the positive and negative formats will want spaces in
+    // the same places in curr_symbol since there's no way to
+    // represent anything else.
+    string_type __dummy_curr_symbol = __curr_symbol_;
+    __init_pat(__pos_format_, __dummy_curr_symbol, false,
+               lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
+    __init_pat(__neg_format_, __curr_symbol_, false,
+               lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
+}
+
+template<>
+void
+moneypunct_byname<wchar_t, true>::init(const char* nm)
+{
+    typedef moneypunct<wchar_t, true> base;
+    __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (loc == nullptr)
+        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
+    if (*lc->mon_decimal_point)
+        __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
+    else
+        __decimal_point_ = base::do_decimal_point();
+    if (*lc->mon_thousands_sep)
+        __thousands_sep_ = static_cast<wchar_t>(*lc->mon_thousands_sep);
+    else
+        __thousands_sep_ = base::do_thousands_sep();
+    __grouping_ = lc->mon_grouping;
+    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
+    if (j == size_t(-1))
+        __throw_runtime_error("locale not supported");
+    wchar_t* wbe = wbuf + j;
+    __curr_symbol_.assign(wbuf, wbe);
+    if (lc->int_frac_digits != CHAR_MAX)
+        __frac_digits_ = lc->int_frac_digits;
+    else
+        __frac_digits_ = base::do_frac_digits();
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+    if (lc->p_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+    if (lc->int_p_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+        __positive_sign_ = L"()";
+    else
+    {
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __positive_sign_.assign(wbuf, wbe);
+    }
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+    if (lc->n_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+    if (lc->int_n_sign_posn == 0)
+#endif // !_LIBCPP_MSVCRT
+        __negative_sign_ = L"()";
+    else
+    {
+        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
+        if (j == size_t(-1))
+            __throw_runtime_error("locale not supported");
+        wbe = wbuf + j;
+        __negative_sign_.assign(wbuf, wbe);
+    }
+    // Assume the positive and negative formats will want spaces in
+    // the same places in curr_symbol since there's no way to
+    // represent anything else.
+    string_type __dummy_curr_symbol = __curr_symbol_;
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+    __init_pat(__pos_format_, __dummy_curr_symbol, true,
+               lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
+    __init_pat(__neg_format_, __curr_symbol_, true,
+               lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
+#else // _LIBCPP_MSVCRT
+    __init_pat(__pos_format_, __dummy_curr_symbol, true,
+               lc->int_p_cs_precedes, lc->int_p_sep_by_space,
+               lc->int_p_sign_posn, L' ');
+    __init_pat(__neg_format_, __curr_symbol_, true,
+               lc->int_n_cs_precedes, lc->int_n_sep_by_space,
+               lc->int_n_sign_posn, L' ');
+#endif // !_LIBCPP_MSVCRT
+}
+
+void __do_nothing(void*) {}
+
+void __throw_runtime_error(const char* msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw runtime_error(msg);
+#else
+    (void)msg;
+#endif
+}
+
+template class collate<char>;
+template class collate<wchar_t>;
+
+template class num_get<char>;
+template class num_get<wchar_t>;
+
+template struct __num_get<char>;
+template struct __num_get<wchar_t>;
+
+template class num_put<char>;
+template class num_put<wchar_t>;
+
+template struct __num_put<char>;
+template struct __num_put<wchar_t>;
+
+template class time_get<char>;
+template class time_get<wchar_t>;
+
+template class time_get_byname<char>;
+template class time_get_byname<wchar_t>;
+
+template class time_put<char>;
+template class time_put<wchar_t>;
+
+template class time_put_byname<char>;
+template class time_put_byname<wchar_t>;
+
+template class moneypunct<char, false>;
+template class moneypunct<char, true>;
+template class moneypunct<wchar_t, false>;
+template class moneypunct<wchar_t, true>;
+
+template class moneypunct_byname<char, false>;
+template class moneypunct_byname<char, true>;
+template class moneypunct_byname<wchar_t, false>;
+template class moneypunct_byname<wchar_t, true>;
+
+template class money_get<char>;
+template class money_get<wchar_t>;
+
+template class __money_get<char>;
+template class __money_get<wchar_t>;
+
+template class money_put<char>;
+template class money_put<wchar_t>;
+
+template class __money_put<char>;
+template class __money_put<wchar_t>;
+
+template class messages<char>;
+template class messages<wchar_t>;
+
+template class messages_byname<char>;
+template class messages_byname<wchar_t>;
+
+template class codecvt_byname<char, char, mbstate_t>;
+template class codecvt_byname<wchar_t, char, mbstate_t>;
+template class codecvt_byname<char16_t, char, mbstate_t>;
+template class codecvt_byname<char32_t, char, mbstate_t>;
+
+template class __vector_base_common<true>;
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/memory.cpp b/final/src/memory.cpp
new file mode 100644
index 0000000..666673f
--- /dev/null
+++ b/final/src/memory.cpp
@@ -0,0 +1,223 @@
+//===------------------------ memory.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_BUILDING_MEMORY
+#include "memory"
+#include "mutex"
+#include "thread"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace
+{
+
+template <class T>
+inline T
+increment(T& t) _NOEXCEPT
+{
+    return __sync_add_and_fetch(&t, 1);
+}
+
+template <class T>
+inline T
+decrement(T& t) _NOEXCEPT
+{
+    return __sync_add_and_fetch(&t, -1);
+}
+
+}  // namespace
+
+const allocator_arg_t allocator_arg = allocator_arg_t();
+
+bad_weak_ptr::~bad_weak_ptr() _NOEXCEPT {}
+
+const char*
+bad_weak_ptr::what() const _NOEXCEPT
+{
+    return "bad_weak_ptr";
+}
+
+__shared_count::~__shared_count()
+{
+}
+
+void
+__shared_count::__add_shared() _NOEXCEPT
+{
+    increment(__shared_owners_);
+}
+
+bool
+__shared_count::__release_shared() _NOEXCEPT
+{
+    if (decrement(__shared_owners_) == -1)
+    {
+        __on_zero_shared();
+        return true;
+    }
+    return false;
+}
+
+__shared_weak_count::~__shared_weak_count()
+{
+}
+
+void
+__shared_weak_count::__add_shared() _NOEXCEPT
+{
+    __shared_count::__add_shared();
+}
+
+void
+__shared_weak_count::__add_weak() _NOEXCEPT
+{
+    increment(__shared_weak_owners_);
+}
+
+void
+__shared_weak_count::__release_shared() _NOEXCEPT
+{
+    if (__shared_count::__release_shared())
+        __release_weak();
+}
+
+void
+__shared_weak_count::__release_weak() _NOEXCEPT
+{
+    if (decrement(__shared_weak_owners_) == -1)
+        __on_zero_shared_weak();
+}
+
+__shared_weak_count*
+__shared_weak_count::lock() _NOEXCEPT
+{
+    long object_owners = __shared_owners_;
+    while (object_owners != -1)
+    {
+        if (__sync_bool_compare_and_swap(&__shared_owners_,
+                                         object_owners,
+                                         object_owners+1))
+            return this;
+        object_owners = __shared_owners_;
+    }
+    return 0;
+}
+
+#ifndef _LIBCPP_NO_RTTI
+
+const void*
+__shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
+{
+    return 0;
+}
+
+#endif  // _LIBCPP_NO_RTTI
+
+#if __has_feature(cxx_atomic)
+
+static const std::size_t __sp_mut_count = 16;
+static pthread_mutex_t mut_back_imp[__sp_mut_count] =
+{
+    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
+    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
+    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER,
+    PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER
+};
+
+static mutex* mut_back = reinterpret_cast<std::mutex*>(mut_back_imp);
+
+_LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) _NOEXCEPT
+   : __lx(p)
+{
+}
+
+void
+__sp_mut::lock() _NOEXCEPT
+{
+    mutex& m = *static_cast<mutex*>(__lx);
+    unsigned count = 0;
+    while (!m.try_lock())
+    {
+        if (++count > 16)
+        {
+            m.lock();
+            break;
+        }
+        this_thread::yield();
+    }
+}
+
+void
+__sp_mut::unlock() _NOEXCEPT
+{
+    static_cast<mutex*>(__lx)->unlock();
+}
+
+__sp_mut&
+__get_sp_mut(const void* p)
+{
+    static __sp_mut muts[__sp_mut_count] 
+    {
+        &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],
+        &mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7],
+        &mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11],
+        &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15]
+    };
+    return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
+}
+
+#endif // __has_feature(cxx_atomic)
+
+void
+declare_reachable(void*)
+{
+}
+
+void
+declare_no_pointers(char*, size_t)
+{
+}
+
+void
+undeclare_no_pointers(char*, size_t)
+{
+}
+
+pointer_safety
+get_pointer_safety() _NOEXCEPT
+{
+    return pointer_safety::relaxed;
+}
+
+void*
+__undeclare_reachable(void* p)
+{
+    return p;
+}
+
+void*
+align(size_t alignment, size_t size, void*& ptr, size_t& space)
+{
+    void* r = nullptr;
+    if (size <= space)
+    {
+        char* p1 = static_cast<char*>(ptr);
+        char* p2 = reinterpret_cast<char*>(reinterpret_cast<size_t>(p1 + (alignment - 1)) & -alignment);
+        size_t d = static_cast<size_t>(p2 - p1);
+        if (d <= space - size)
+        {
+            r = p2;
+            ptr = r;
+            space -= d;
+        }
+    }
+    return r;
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/mutex.cpp b/final/src/mutex.cpp
new file mode 100644
index 0000000..0767897
--- /dev/null
+++ b/final/src/mutex.cpp
@@ -0,0 +1,253 @@
+//===------------------------- mutex.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_BUILDING_MUTEX
+#include "mutex"
+#include "limits"
+#include "system_error"
+#include "cassert"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+const defer_lock_t  defer_lock = {};
+const try_to_lock_t try_to_lock = {};
+const adopt_lock_t  adopt_lock = {};
+
+mutex::~mutex()
+{
+    pthread_mutex_destroy(&__m_);
+}
+
+void
+mutex::lock()
+{
+    int ec = pthread_mutex_lock(&__m_);
+    if (ec)
+        __throw_system_error(ec, "mutex lock failed");
+}
+
+bool
+mutex::try_lock() _NOEXCEPT
+{
+    return pthread_mutex_trylock(&__m_) == 0;
+}
+
+void
+mutex::unlock() _NOEXCEPT
+{
+    int ec = pthread_mutex_unlock(&__m_);
+    (void)ec;
+    assert(ec == 0);
+}
+
+// recursive_mutex
+
+recursive_mutex::recursive_mutex()
+{
+    pthread_mutexattr_t attr;
+    int ec = pthread_mutexattr_init(&attr);
+    if (ec)
+        goto fail;
+    ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+    if (ec)
+    {
+        pthread_mutexattr_destroy(&attr);
+        goto fail;
+    }
+    ec = pthread_mutex_init(&__m_, &attr);
+    if (ec)
+    {
+        pthread_mutexattr_destroy(&attr);
+        goto fail;
+    }
+    ec = pthread_mutexattr_destroy(&attr);
+    if (ec)
+    {
+        pthread_mutex_destroy(&__m_);
+        goto fail;
+    }
+    return;
+fail:
+    __throw_system_error(ec, "recursive_mutex constructor failed");
+}
+
+recursive_mutex::~recursive_mutex()
+{
+    int e = pthread_mutex_destroy(&__m_);
+    (void)e;
+    assert(e == 0);
+}
+
+void
+recursive_mutex::lock()
+{
+    int ec = pthread_mutex_lock(&__m_);
+    if (ec)
+        __throw_system_error(ec, "recursive_mutex lock failed");
+}
+
+void
+recursive_mutex::unlock() _NOEXCEPT
+{
+    int e = pthread_mutex_unlock(&__m_);
+    (void)e;
+    assert(e == 0);
+}
+
+bool
+recursive_mutex::try_lock() _NOEXCEPT
+{
+    return pthread_mutex_trylock(&__m_) == 0;
+}
+
+// timed_mutex
+
+timed_mutex::timed_mutex()
+    : __locked_(false)
+{
+}
+
+timed_mutex::~timed_mutex()
+{
+    lock_guard<mutex> _(__m_);
+}
+
+void
+timed_mutex::lock()
+{
+    unique_lock<mutex> lk(__m_);
+    while (__locked_)
+        __cv_.wait(lk);
+    __locked_ = true;
+}
+
+bool
+timed_mutex::try_lock() _NOEXCEPT
+{
+    unique_lock<mutex> lk(__m_, try_to_lock);
+    if (lk.owns_lock() && !__locked_)
+    {
+        __locked_ = true;
+        return true;
+    }
+    return false;
+}
+
+void
+timed_mutex::unlock() _NOEXCEPT
+{
+    lock_guard<mutex> _(__m_);
+    __locked_ = false;
+    __cv_.notify_one();
+}
+
+// recursive_timed_mutex
+
+recursive_timed_mutex::recursive_timed_mutex()
+    : __count_(0),
+      __id_(0)
+{
+}
+
+recursive_timed_mutex::~recursive_timed_mutex()
+{
+    lock_guard<mutex> _(__m_);
+}
+
+void
+recursive_timed_mutex::lock()
+{
+    pthread_t id = pthread_self();
+    unique_lock<mutex> lk(__m_);
+    if (pthread_equal(id, __id_))
+    {
+        if (__count_ == numeric_limits<size_t>::max())
+            __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
+        ++__count_;
+        return;
+    }
+    while (__count_ != 0)
+        __cv_.wait(lk);
+    __count_ = 1;
+    __id_ = id;
+}
+
+bool
+recursive_timed_mutex::try_lock() _NOEXCEPT
+{
+    pthread_t id = pthread_self();
+    unique_lock<mutex> lk(__m_, try_to_lock);
+    if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+    {
+        if (__count_ == numeric_limits<size_t>::max())
+            return false;
+        ++__count_;
+        __id_ = id;
+        return true;
+    }
+    return false;
+}
+
+void
+recursive_timed_mutex::unlock() _NOEXCEPT
+{
+    unique_lock<mutex> lk(__m_);
+    if (--__count_ == 0)
+    {
+        __id_ = 0;
+        lk.unlock();
+        __cv_.notify_one();
+    }
+}
+
+// If dispatch_once_f ever handles C++ exceptions, and if one can get to it
+// without illegal macros (unexpected macros not beginning with _UpperCase or
+// __lowercase), and if it stops spinning waiting threads, then call_once should
+// call into dispatch_once_f instead of here. Relevant radar this code needs to
+// keep in sync with:  7741191.
+
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+
+void
+__call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
+{
+    pthread_mutex_lock(&mut);
+    while (flag == 1)
+        pthread_cond_wait(&cv, &mut);
+    if (flag == 0)
+    {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        try
+        {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+            flag = 1;
+            pthread_mutex_unlock(&mut);
+            func(arg);
+            pthread_mutex_lock(&mut);
+            flag = ~0ul;
+            pthread_mutex_unlock(&mut);
+            pthread_cond_broadcast(&cv);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        }
+        catch (...)
+        {
+            pthread_mutex_lock(&mut);
+            flag = 0ul;
+            pthread_mutex_unlock(&mut);
+            pthread_cond_broadcast(&cv);
+            throw;
+        }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    }
+    else
+        pthread_mutex_unlock(&mut);
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/new.cpp b/final/src/new.cpp
new file mode 100644
index 0000000..3b7c341
--- /dev/null
+++ b/final/src/new.cpp
@@ -0,0 +1,239 @@
+//===--------------------------- new.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_BUILDING_NEW
+
+#include <stdlib.h>
+
+#include "new"
+
+#ifndef __has_include
+#define __has_include(inc) 0
+#endif
+
+#ifdef __APPLE__
+    #include <cxxabi.h>
+
+    #ifndef _LIBCPPABI_VERSION
+        // On Darwin, there are two STL shared libraries and a lower level ABI
+        // shared library.  The global holding the current new handler is
+        // in the ABI library and named __cxa_new_handler.
+        #define __new_handler __cxxabiapple::__cxa_new_handler
+    #endif
+#else  // __APPLE__
+    #if defined(LIBCXXRT) || __has_include(<cxxabi.h>)
+        #include <cxxabi.h>
+    #endif  // __has_include(<cxxabi.h>)
+    #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__)
+        static std::new_handler __new_handler;
+    #endif  // _LIBCPPABI_VERSION
+#endif
+
+#ifndef __GLIBCXX__
+
+// Implement all new and delete operators as weak definitions
+// in this shared library, so that they can be overriden by programs
+// that define non-weak copies of the functions.
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void *
+operator new(std::size_t size)
+#if !__has_feature(cxx_noexcept)
+    throw(std::bad_alloc)
+#endif
+{
+    if (size == 0)
+        size = 1;
+    void* p;
+    while ((p = ::malloc(size)) == 0)
+    {
+        // If malloc fails and there is a new_handler,
+        // call it to try free up memory.
+        std::new_handler nh = std::get_new_handler();
+        if (nh)
+            nh();
+        else
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw std::bad_alloc();
+#else
+            break;
+#endif
+    }
+    return p;
+}
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void*
+operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
+{
+    void* p = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        p = ::operator new(size);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return p;
+}
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void*
+operator new[](size_t size)
+#if !__has_feature(cxx_noexcept)
+    throw(std::bad_alloc)
+#endif
+{
+    return ::operator new(size);
+}
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void*
+operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
+{
+    void* p = 0;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    try
+    {
+#endif  // _LIBCPP_NO_EXCEPTIONS
+        p = ::operator new[](size);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    }
+    catch (...)
+    {
+    }
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    return p;
+}
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void
+operator delete(void* ptr) _NOEXCEPT
+{
+    if (ptr)
+        ::free(ptr);
+}
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void
+operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT
+{
+    ::operator delete(ptr);
+}
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void
+operator delete[] (void* ptr) _NOEXCEPT
+{
+    ::operator delete (ptr);
+}
+
+_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
+void
+operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT
+{
+    ::operator delete[](ptr);
+}
+
+#endif // !__GLIBCXX__
+
+namespace std
+{
+
+#ifndef __GLIBCXX__
+const nothrow_t nothrow = {};
+#endif
+
+#ifndef _LIBCPPABI_VERSION
+
+#ifndef __GLIBCXX__
+
+new_handler
+set_new_handler(new_handler handler) _NOEXCEPT
+{
+    return __sync_lock_test_and_set(&__new_handler, handler);
+}
+
+new_handler
+get_new_handler() _NOEXCEPT
+{
+    return __sync_fetch_and_add(&__new_handler, nullptr);
+}
+
+#endif // !__GLIBCXX__
+
+#ifndef LIBCXXRT
+
+bad_alloc::bad_alloc() _NOEXCEPT
+{
+}
+
+#ifndef __GLIBCXX__
+
+bad_alloc::~bad_alloc() _NOEXCEPT
+{
+}
+
+const char*
+bad_alloc::what() const _NOEXCEPT
+{
+    return "std::bad_alloc";
+}
+
+#endif // !__GLIBCXX__
+
+#endif //LIBCXXRT
+
+bad_array_new_length::bad_array_new_length() _NOEXCEPT
+{
+}
+
+bad_array_new_length::~bad_array_new_length() _NOEXCEPT
+{
+}
+
+const char*
+bad_array_length::what() const _NOEXCEPT
+{
+    return "bad_array_length";
+}
+
+bad_array_length::bad_array_length() _NOEXCEPT
+{
+}
+
+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
+
+void
+__throw_bad_alloc()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw bad_alloc();
+#endif
+}
+
+#endif // !LIBSTDCXX
+
+}  // std
diff --git a/final/src/optional.cpp b/final/src/optional.cpp
new file mode 100644
index 0000000..b614d81
--- /dev/null
+++ b/final/src/optional.cpp
@@ -0,0 +1,25 @@
+//===------------------------ optional.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/optional"
+
+namespace std  // purposefully not using versioning namespace
+{ namespace experimental {
+
+#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+
+bad_optional_access::~bad_optional_access() _NOEXCEPT {}
+
+#else
+
+bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
+
+#endif
+
+}}  // std::experimental
diff --git a/final/src/random.cpp b/final/src/random.cpp
new file mode 100644
index 0000000..86017ef
--- /dev/null
+++ b/final/src/random.cpp
@@ -0,0 +1,91 @@
+//===-------------------------- random.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.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(_WIN32)
+// Must be defined before including stdlib.h to enable rand_s().
+#define _CRT_RAND_S
+#include <stdio.h>
+#endif
+
+#include "random"
+#include "system_error"
+
+#ifdef __sun__
+#define rename solaris_headers_are_broken
+#endif
+#if !defined(_WIN32)
+#include <fcntl.h>
+#include <unistd.h>
+#endif // defined(_WIN32)
+#include <errno.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if defined(_WIN32)
+random_device::random_device(const string&)
+{
+}
+
+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
+random_device::random_device(const string& __token)
+    : __f_(open(__token.c_str(), O_RDONLY))
+{
+    if (__f_ < 0)
+        __throw_system_error(errno, ("random_device failed to open " + __token).c_str());
+}
+
+random_device::~random_device()
+{
+    close(__f_);
+}
+
+unsigned
+random_device::operator()()
+{
+    unsigned r;
+    size_t n = sizeof(r);
+    char* p = reinterpret_cast<char*>(&r);
+    while (n > 0)
+    {
+        ssize_t s = read(__f_, p, n);
+        if (s == 0)
+            __throw_system_error(ENODATA, "random_device got EOF");
+        if (s == -1)
+        {
+            if (errno != EINTR)
+                __throw_system_error(errno, "random_device got an unexpected error");
+            continue;
+        }
+        n -= static_cast<size_t>(s);
+        p += static_cast<size_t>(s);
+    }
+    return r;
+}
+#endif // defined(_WIN32)
+
+double
+random_device::entropy() const _NOEXCEPT
+{
+    return 0;
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/regex.cpp b/final/src/regex.cpp
new file mode 100644
index 0000000..fb820e2
--- /dev/null
+++ b/final/src/regex.cpp
@@ -0,0 +1,333 @@
+//===-------------------------- regex.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 "regex"
+#include "algorithm"
+#include "iterator"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+static
+const char*
+make_error_type_string(regex_constants::error_type ecode)
+{
+    switch (ecode)
+    {
+    case regex_constants::error_collate:
+        return "The expression contained an invalid collating element name.";
+    case regex_constants::error_ctype:
+        return "The expression contained an invalid character class name.";
+    case regex_constants::error_escape:
+        return "The expression contained an invalid escaped character, or a "
+               "trailing escape.";
+    case regex_constants::error_backref:
+        return "The expression contained an invalid back reference.";
+    case regex_constants::error_brack:
+        return "The expression contained mismatched [ and ].";
+    case regex_constants::error_paren:
+        return "The expression contained mismatched ( and ).";
+    case regex_constants::error_brace:
+        return "The expression contained mismatched { and }.";
+    case regex_constants::error_badbrace:
+        return "The expression contained an invalid range in a {} expression.";
+    case regex_constants::error_range:
+        return "The expression contained an invalid character range, "
+               "such as [b-a] in most encodings.";
+    case regex_constants::error_space:
+        return "There was insufficient memory to convert the expression into "
+               "a finite state machine.";
+    case regex_constants::error_badrepeat:
+        return "One of *?+{ was not preceded by a valid regular expression.";
+    case regex_constants::error_complexity:
+        return "The complexity of an attempted match against a regular "
+               "expression exceeded a pre-set level.";
+    case regex_constants::error_stack:
+        return "There was insufficient memory to determine whether the regular "
+               "expression could match the specified character sequence.";
+    case regex_constants::__re_err_grammar:
+        return "An invalid regex grammar has been requested.";
+    case regex_constants::__re_err_empty:
+        return "An empty regex is not allowed in the POSIX grammar.";
+    default:
+        break;
+    }
+    return "Unknown error type";
+}
+
+regex_error::regex_error(regex_constants::error_type ecode)
+    : runtime_error(make_error_type_string(ecode)),
+      __code_(ecode)
+{}
+
+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},
+    {"B", 0x42},
+    {"C", 0x43},
+    {"D", 0x44},
+    {"E", 0x45},
+    {"F", 0x46},
+    {"G", 0x47},
+    {"H", 0x48},
+    {"I", 0x49},
+    {"J", 0x4a},
+    {"K", 0x4b},
+    {"L", 0x4c},
+    {"M", 0x4d},
+    {"N", 0x4e},
+    {"NUL", 0x00},
+    {"O", 0x4f},
+    {"P", 0x50},
+    {"Q", 0x51},
+    {"R", 0x52},
+    {"S", 0x53},
+    {"T", 0x54},
+    {"U", 0x55},
+    {"V", 0x56},
+    {"W", 0x57},
+    {"X", 0x58},
+    {"Y", 0x59},
+    {"Z", 0x5a},
+    {"a", 0x61},
+    {"alert", 0x07},
+    {"ampersand", 0x26},
+    {"apostrophe", 0x27},
+    {"asterisk", 0x2a},
+    {"b", 0x62},
+    {"backslash", 0x5c},
+    {"backspace", 0x08},
+    {"c", 0x63},
+    {"carriage-return", 0x0d},
+    {"circumflex", 0x5e},
+    {"circumflex-accent", 0x5e},
+    {"colon", 0x3a},
+    {"comma", 0x2c},
+    {"commercial-at", 0x40},
+    {"d", 0x64},
+    {"dollar-sign", 0x24},
+    {"e", 0x65},
+    {"eight", 0x38},
+    {"equals-sign", 0x3d},
+    {"exclamation-mark", 0x21},
+    {"f", 0x66},
+    {"five", 0x35},
+    {"form-feed", 0x0c},
+    {"four", 0x34},
+    {"full-stop", 0x2e},
+    {"g", 0x67},
+    {"grave-accent", 0x60},
+    {"greater-than-sign", 0x3e},
+    {"h", 0x68},
+    {"hyphen", 0x2d},
+    {"hyphen-minus", 0x2d},
+    {"i", 0x69},
+    {"j", 0x6a},
+    {"k", 0x6b},
+    {"l", 0x6c},
+    {"left-brace", 0x7b},
+    {"left-curly-bracket", 0x7b},
+    {"left-parenthesis", 0x28},
+    {"left-square-bracket", 0x5b},
+    {"less-than-sign", 0x3c},
+    {"low-line", 0x5f},
+    {"m", 0x6d},
+    {"n", 0x6e},
+    {"newline", 0x0a},
+    {"nine", 0x39},
+    {"number-sign", 0x23},
+    {"o", 0x6f},
+    {"one", 0x31},
+    {"p", 0x70},
+    {"percent-sign", 0x25},
+    {"period", 0x2e},
+    {"plus-sign", 0x2b},
+    {"q", 0x71},
+    {"question-mark", 0x3f},
+    {"quotation-mark", 0x22},
+    {"r", 0x72},
+    {"reverse-solidus", 0x5c},
+    {"right-brace", 0x7d},
+    {"right-curly-bracket", 0x7d},
+    {"right-parenthesis", 0x29},
+    {"right-square-bracket", 0x5d},
+    {"s", 0x73},
+    {"semicolon", 0x3b},
+    {"seven", 0x37},
+    {"six", 0x36},
+    {"slash", 0x2f},
+    {"solidus", 0x2f},
+    {"space", 0x20},
+    {"t", 0x74},
+    {"tab", 0x09},
+    {"three", 0x33},
+    {"tilde", 0x7e},
+    {"two", 0x32},
+    {"u", 0x75},
+    {"underscore", 0x5f},
+    {"v", 0x76},
+    {"vertical-line", 0x7c},
+    {"vertical-tab", 0x0b},
+    {"w", 0x77},
+    {"x", 0x78},
+    {"y", 0x79},
+    {"z", 0x7a},
+    {"zero", 0x30}
+};
+
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
+struct classnames
+{
+    const char* elem_;
+    ctype_base::mask mask_;
+};
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
+const classnames ClassNames[] =
+{
+    {"alnum",  ctype_base::alnum},
+    {"alpha",  ctype_base::alpha},
+    {"blank",  ctype_base::blank},
+    {"cntrl",  ctype_base::cntrl},
+    {"d",      ctype_base::digit},
+    {"digit",  ctype_base::digit},
+    {"graph",  ctype_base::graph},
+    {"lower",  ctype_base::lower},
+    {"print",  ctype_base::print},
+    {"punct",  ctype_base::punct},
+    {"s",      ctype_base::space},
+    {"space",  ctype_base::space},
+    {"upper",  ctype_base::upper},
+    {"w",      regex_traits<char>::__regex_word},
+    {"xdigit", ctype_base::xdigit}
+};
+
+struct use_strcmp
+{
+    bool operator()(const collationnames& x, const char* y)
+        {return strcmp(x.elem_, y) < 0;}
+    bool operator()(const classnames& x, const char* y)
+        {return strcmp(x.elem_, y) < 0;}
+};
+
+}
+
+string
+__get_collation_name(const char* s)
+{
+    const collationnames* i =
+            _VSTD::lower_bound(begin(collatenames), end(collatenames), s, use_strcmp());
+    string r;
+    if (i != end(collatenames) && strcmp(s, i->elem_) == 0)
+        r = char(i->char_);
+    return r;
+}
+
+ctype_base::mask
+__get_classname(const char* s, bool __icase)
+{
+    const classnames* i =
+            _VSTD::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp());
+    ctype_base::mask r = 0;
+    if (i != end(ClassNames) && strcmp(s, i->elem_) == 0)
+    {
+        r = i->mask_;
+        if (r == regex_traits<char>::__regex_word)
+            r |= ctype_base::alnum | ctype_base::upper | ctype_base::lower;
+        else if (__icase)
+        {
+            if (r & (ctype_base::lower | ctype_base::upper))
+                r |= ctype_base::alpha;
+        }
+    }
+    return r;
+}
+
+template <>
+void
+__match_any_but_newline<char>::__exec(__state& __s) const
+{
+    if (__s.__current_ != __s.__last_)
+    {
+        switch (*__s.__current_)
+        {
+        case '\r':
+        case '\n':
+            __s.__do_ = __state::__reject;
+            __s.__node_ = nullptr;
+            break;
+        default:
+            __s.__do_ = __state::__accept_and_consume;
+            ++__s.__current_;
+            __s.__node_ = this->first();
+            break;
+        }
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+template <>
+void
+__match_any_but_newline<wchar_t>::__exec(__state& __s) const
+{
+    if (__s.__current_ != __s.__last_)
+    {
+        switch (*__s.__current_)
+        {
+        case '\r':
+        case '\n':
+        case 0x2028:
+        case 0x2029:
+            __s.__do_ = __state::__reject;
+            __s.__node_ = nullptr;
+            break;
+        default:
+            __s.__do_ = __state::__accept_and_consume;
+            ++__s.__current_;
+            __s.__node_ = this->first();
+            break;
+        }
+    }
+    else
+    {
+        __s.__do_ = __state::__reject;
+        __s.__node_ = nullptr;
+    }
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/shared_mutex.cpp b/final/src/shared_mutex.cpp
new file mode 100644
index 0000000..dd78a16
--- /dev/null
+++ b/final/src/shared_mutex.cpp
@@ -0,0 +1,101 @@
+//===---------------------- shared_mutex.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_BUILDING_SHARED_MUTEX
+#include "shared_mutex"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+shared_timed_mutex::shared_timed_mutex()
+    : __state_(0)
+{
+}
+
+// Exclusive ownership
+
+void
+shared_timed_mutex::lock()
+{
+    unique_lock<mutex> lk(__mut_);
+    while (__state_ & __write_entered_)
+        __gate1_.wait(lk);
+    __state_ |= __write_entered_;
+    while (__state_ & __n_readers_)
+        __gate2_.wait(lk);
+}
+
+bool
+shared_timed_mutex::try_lock()
+{
+    unique_lock<mutex> lk(__mut_);
+    if (__state_ == 0)
+    {
+        __state_ = __write_entered_;
+        return true;
+    }
+    return false;
+}
+
+void
+shared_timed_mutex::unlock()
+{
+    lock_guard<mutex> _(__mut_);
+    __state_ = 0;
+    __gate1_.notify_all();
+}
+
+// Shared ownership
+
+void
+shared_timed_mutex::lock_shared()
+{
+    unique_lock<mutex> lk(__mut_);
+    while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
+        __gate1_.wait(lk);
+    unsigned num_readers = (__state_ & __n_readers_) + 1;
+    __state_ &= ~__n_readers_;
+    __state_ |= num_readers;
+}
+
+bool
+shared_timed_mutex::try_lock_shared()
+{
+    unique_lock<mutex> lk(__mut_);
+    unsigned num_readers = __state_ & __n_readers_;
+    if (!(__state_ & __write_entered_) && num_readers != __n_readers_)
+    {
+        ++num_readers;
+        __state_ &= ~__n_readers_;
+        __state_ |= num_readers;
+        return true;
+    }
+    return false;
+}
+
+void
+shared_timed_mutex::unlock_shared()
+{
+    lock_guard<mutex> _(__mut_);
+    unsigned num_readers = (__state_ & __n_readers_) - 1;
+    __state_ &= ~__n_readers_;
+    __state_ |= num_readers;
+    if (__state_ & __write_entered_)
+    {
+        if (num_readers == 0)
+            __gate2_.notify_one();
+    }
+    else
+    {
+        if (num_readers == __n_readers_ - 1)
+            __gate1_.notify_one();
+    }
+}
+
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/stdexcept.cpp b/final/src/stdexcept.cpp
new file mode 100644
index 0000000..aff4b18
--- /dev/null
+++ b/final/src/stdexcept.cpp
@@ -0,0 +1,106 @@
+//===------------------------ stdexcept.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 "__refstring"
+#include "stdexcept"
+#include "new"
+#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)
+#include <cxxabi.h>
+#endif
+
+static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
+
+namespace std  // purposefully not using versioning namespace
+{
+
+logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
+{
+}
+
+logic_error::logic_error(const char* msg) : __imp_(msg)
+{
+}
+
+logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
+{
+}
+
+logic_error&
+logic_error::operator=(const logic_error& le) _NOEXCEPT
+{
+    __imp_ = le.__imp_;
+    return *this;
+}
+
+#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
+
+logic_error::~logic_error() _NOEXCEPT
+{
+}
+
+const char*
+logic_error::what() const _NOEXCEPT
+{
+    return __imp_.c_str();
+}
+
+#endif
+
+runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
+{
+}
+
+runtime_error::runtime_error(const char* msg) : __imp_(msg)
+{
+}
+
+runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
+  : __imp_(le.__imp_)
+{
+}
+
+runtime_error&
+runtime_error::operator=(const runtime_error& le) _NOEXCEPT
+{
+    __imp_ = le.__imp_;
+    return *this;
+}
+
+#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
+
+runtime_error::~runtime_error() _NOEXCEPT
+{
+}
+
+const char*
+runtime_error::what() const _NOEXCEPT
+{
+    return __imp_.c_str();
+}
+
+domain_error::~domain_error() _NOEXCEPT {}
+invalid_argument::~invalid_argument() _NOEXCEPT {}
+length_error::~length_error() _NOEXCEPT {}
+out_of_range::~out_of_range() _NOEXCEPT {}
+
+range_error::~range_error() _NOEXCEPT {}
+overflow_error::~overflow_error() _NOEXCEPT {}
+underflow_error::~underflow_error() _NOEXCEPT {}
+
+#endif
+
+}  // std
diff --git a/final/src/string.cpp b/final/src/string.cpp
new file mode 100644
index 0000000..fde5212
--- /dev/null
+++ b/final/src/string.cpp
@@ -0,0 +1,530 @@
+//===------------------------- string.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+
+#include "string"
+#include "cstdlib"
+#include "cwchar"
+#include "cerrno"
+#include "limits"
+#include "stdexcept"
+#ifdef _LIBCPP_MSVCRT
+#include "support/win32/support.h"
+#endif // _LIBCPP_MSVCRT
+#include <stdio.h>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template class __basic_string_common<true>;
+
+template class basic_string<char>;
+template class basic_string<wchar_t>;
+
+template
+    string
+    operator+<char, char_traits<char>, allocator<char> >(char const*, string const&);
+
+namespace
+{
+
+template<typename T>
+inline
+void throw_helper( const string& msg )
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw T( msg );
+#else
+    printf("%s\n", msg.c_str());
+    abort();
+#endif
+}
+
+inline
+void throw_from_string_out_of_range( const string& func )
+{
+    throw_helper<out_of_range>(func + ": out of range");
+}
+
+inline
+void throw_from_string_invalid_arg( const string& func )
+{
+    throw_helper<invalid_argument>(func + ": no conversion");
+}
+
+// as_integer
+
+template<typename V, typename S, typename F>
+inline
+V
+as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f)
+{
+    typename S::value_type* ptr;
+    const typename S::value_type* const p = str.c_str();
+    typename remove_reference<decltype(errno)>::type errno_save = errno;
+    errno = 0;
+    V r = f(p, &ptr, base);
+    swap(errno, errno_save);
+    if (errno_save == ERANGE)
+        throw_from_string_out_of_range(func);
+    if (ptr == p)
+        throw_from_string_invalid_arg(func);
+    if (idx)
+        *idx = static_cast<size_t>(ptr - p);
+    return r;
+}
+
+template<typename V, typename S>
+inline
+V
+as_integer(const string& func, const S& s, size_t* idx, int base);
+
+// string
+template<>
+inline
+int
+as_integer(const string& func, const string& s, size_t* idx, int base )
+{
+    // Use long as no Standard string to integer exists.
+    long r = as_integer_helper<long>( func, s, idx, base, strtol );
+    if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
+        throw_from_string_out_of_range(func);
+    return static_cast<int>(r);
+}
+
+template<>
+inline
+long
+as_integer(const string& func, const string& s, size_t* idx, int base )
+{
+    return as_integer_helper<long>( func, s, idx, base, strtol );
+}
+
+template<>
+inline
+unsigned long
+as_integer( const string& func, const string& s, size_t* idx, int base )
+{
+    return as_integer_helper<unsigned long>( func, s, idx, base, strtoul );
+}
+
+template<>
+inline
+long long
+as_integer( const string& func, const string& s, size_t* idx, int base )
+{
+    return as_integer_helper<long long>( func, s, idx, base, strtoll );
+}
+
+template<>
+inline
+unsigned long long
+as_integer( const string& func, const string& s, size_t* idx, int base )
+{
+    return as_integer_helper<unsigned long long>( func, s, idx, base, strtoull );
+}
+
+// wstring
+template<>
+inline
+int
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+    // Use long as no Stantard string to integer exists.
+    long r = as_integer_helper<long>( func, s, idx, base, wcstol );
+    if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
+        throw_from_string_out_of_range(func);
+    return static_cast<int>(r);
+}
+
+template<>
+inline
+long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+    return as_integer_helper<long>( func, s, idx, base, wcstol );
+}
+
+template<>
+inline
+unsigned long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+    return as_integer_helper<unsigned long>( func, s, idx, base, wcstoul );
+}
+
+template<>
+inline
+long long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+    return as_integer_helper<long long>( func, s, idx, base, wcstoll );
+}
+
+template<>
+inline
+unsigned long long
+as_integer( const string& func, const wstring& s, size_t* idx, int base )
+{
+    return as_integer_helper<unsigned long long>( func, s, idx, base, wcstoull );
+}
+
+// as_float
+
+template<typename V, typename S, typename F> 
+inline
+V
+as_float_helper(const string& func, const S& str, size_t* idx, F f )
+{
+    typename S::value_type* ptr;
+    const typename S::value_type* const p = str.c_str();
+    typename remove_reference<decltype(errno)>::type errno_save = errno;
+    errno = 0;
+    V r = f(p, &ptr);
+    swap(errno, errno_save);
+    if (errno_save == ERANGE)
+        throw_from_string_out_of_range(func);
+    if (ptr == p)
+        throw_from_string_invalid_arg(func);
+    if (idx)
+        *idx = static_cast<size_t>(ptr - p);
+    return r;
+}
+
+template<typename V, typename S>
+inline
+V as_float( const string& func, const S& s, size_t* idx = nullptr );
+
+template<>
+inline
+float
+as_float( const string& func, const string& s, size_t* idx )
+{
+    return as_float_helper<float>( func, s, idx, strtof );
+}
+
+template<>
+inline
+double
+as_float(const string& func, const string& s, size_t* idx )
+{
+    return as_float_helper<double>( func, s, idx, strtod );
+}
+
+template<>
+inline
+long double
+as_float( const string& func, const string& s, size_t* idx )
+{
+    return as_float_helper<long double>( func, s, idx, strtold );
+}
+
+template<>
+inline
+float
+as_float( const string& func, const wstring& s, size_t* idx )
+{
+    return as_float_helper<float>( func, s, idx, wcstof );
+}
+
+template<>
+inline
+double
+as_float( const string& func, const wstring& s, size_t* idx )
+{
+    return as_float_helper<double>( func, s, idx, wcstod );
+}
+
+template<>
+inline
+long double
+as_float( const string& func, const wstring& s, size_t* idx )
+{
+    return as_float_helper<long double>( func, s, idx, wcstold );
+}
+
+}  // unnamed namespace
+
+int
+stoi(const string& str, size_t* idx, int base)
+{
+    return as_integer<int>( "stoi", str, idx, base );
+}
+
+int
+stoi(const wstring& str, size_t* idx, int base)
+{
+    return as_integer<int>( "stoi", str, idx, base );
+}
+
+long
+stol(const string& str, size_t* idx, int base)
+{
+    return as_integer<long>( "stol", str, idx, base );
+}
+
+long
+stol(const wstring& str, size_t* idx, int base)
+{
+    return as_integer<long>( "stol", str, idx, base );
+}
+
+unsigned long
+stoul(const string& str, size_t* idx, int base)
+{
+    return as_integer<unsigned long>( "stoul", str, idx, base );
+}
+
+unsigned long
+stoul(const wstring& str, size_t* idx, int base)
+{
+    return as_integer<unsigned long>( "stoul", str, idx, base );
+}
+
+long long
+stoll(const string& str, size_t* idx, int base)
+{
+    return as_integer<long long>( "stoll", str, idx, base );
+}
+
+long long
+stoll(const wstring& str, size_t* idx, int base)
+{
+    return as_integer<long long>( "stoll", str, idx, base );
+}
+
+unsigned long long
+stoull(const string& str, size_t* idx, int base)
+{
+    return as_integer<unsigned long long>( "stoull", str, idx, base );
+}
+
+unsigned long long
+stoull(const wstring& str, size_t* idx, int base)
+{
+    return as_integer<unsigned long long>( "stoull", str, idx, base );
+}
+
+float
+stof(const string& str, size_t* idx)
+{
+    return as_float<float>( "stof", str, idx );
+}
+
+float
+stof(const wstring& str, size_t* idx)
+{
+    return as_float<float>( "stof", str, idx );
+}
+
+double
+stod(const string& str, size_t* idx)
+{
+    return as_float<double>( "stod", str, idx );
+}
+
+double
+stod(const wstring& str, size_t* idx)
+{
+    return as_float<double>( "stod", str, idx );
+}
+
+long double
+stold(const string& str, size_t* idx)
+{
+    return as_float<long double>( "stold", str, idx );
+}
+
+long double
+stold(const wstring& str, size_t* idx)
+{
+    return as_float<long double>( "stold", str, idx );
+}
+
+// to_string
+
+namespace
+{
+
+// as_string
+
+template<typename S, typename P, typename V >
+inline
+S
+as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a)
+{
+    typedef typename S::size_type size_type;
+    size_type available = s.size();
+    while (true)
+    {
+        int status = sprintf_like(&s[0], available + 1, fmt, a);
+        if ( status >= 0 )
+        {
+            size_type used = static_cast<size_type>(status);
+            if ( used <= available )
+            {
+                s.resize( used );
+                break;
+            }
+            available = used; // Assume this is advice of how much space we need.
+        }
+        else
+            available = available * 2 + 1;
+        s.resize(available);
+    }
+    return s;
+}
+
+template <class S, class V, bool = is_floating_point<V>::value>
+struct initial_string;
+
+template <class V, bool b>
+struct initial_string<string, V, b>
+{
+    string
+    operator()() const
+    {
+        string s;
+        s.resize(s.capacity());
+        return s;
+    }
+};
+
+template <class V>
+struct initial_string<wstring, V, false>
+{
+    wstring
+    operator()() const
+    {
+        const size_t n = (numeric_limits<unsigned long long>::digits / 3)
+          + ((numeric_limits<unsigned long long>::digits % 3) != 0)
+          + 1;
+        wstring s(n, wchar_t());
+        s.resize(s.capacity());
+        return s;
+    }
+};
+
+template <class V>
+struct initial_string<wstring, V, true>
+{
+    wstring
+    operator()() const
+    {
+        wstring s(20, wchar_t());
+        s.resize(s.capacity());
+        return s;
+    }
+};
+
+typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...);
+
+inline
+wide_printf
+get_swprintf()
+{
+#ifndef _LIBCPP_MSVCRT
+    return swprintf;
+#else
+    return static_cast<int (__cdecl*)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...)>(swprintf);
+#endif
+}
+
+}  // unnamed namespace
+
+string to_string(int val)
+{
+    return as_string(snprintf, initial_string<string, int>()(), "%d", val);
+}
+
+string to_string(unsigned val)
+{
+    return as_string(snprintf, initial_string<string, unsigned>()(), "%u", val);
+}
+
+string to_string(long val)
+{
+    return as_string(snprintf, initial_string<string, long>()(), "%ld", val);
+}
+
+string to_string(unsigned long val)
+{
+    return as_string(snprintf, initial_string<string, unsigned long>()(), "%lu", val);
+}
+
+string to_string(long long val)
+{
+    return as_string(snprintf, initial_string<string, long long>()(), "%lld", val);
+}
+
+string to_string(unsigned long long val)
+{
+    return as_string(snprintf, initial_string<string, unsigned long long>()(), "%llu", val);
+}
+
+string to_string(float val)
+{
+    return as_string(snprintf, initial_string<string, float>()(), "%f", val);
+}
+
+string to_string(double val)
+{
+    return as_string(snprintf, initial_string<string, double>()(), "%f", val);
+}
+
+string to_string(long double val)
+{
+    return as_string(snprintf, initial_string<string, long double>()(), "%Lf", val);
+}
+
+wstring to_wstring(int val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, int>()(), L"%d", val);
+}
+
+wstring to_wstring(unsigned val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, unsigned>()(), L"%u", val);
+}
+
+wstring to_wstring(long val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, long>()(), L"%ld", val);
+}
+
+wstring to_wstring(unsigned long val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, unsigned long>()(), L"%lu", val);
+}
+
+wstring to_wstring(long long val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, long long>()(), L"%lld", val);
+}
+
+wstring to_wstring(unsigned long long val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, unsigned long long>()(), L"%llu", val);
+}
+
+wstring to_wstring(float val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, float>()(), L"%f", val);
+}
+
+wstring to_wstring(double val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, double>()(), L"%f", val);
+}
+
+wstring to_wstring(long double val)
+{
+    return as_string(get_swprintf(), initial_string<wstring, long double>()(), L"%Lf", val);
+}
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/strstream.cpp b/final/src/strstream.cpp
new file mode 100644
index 0000000..ea72813
--- /dev/null
+++ b/final/src/strstream.cpp
@@ -0,0 +1,329 @@
+//===------------------------ strstream.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 "strstream"
+#include "algorithm"
+#include "climits"
+#include "cstring"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+strstreambuf::strstreambuf(streamsize __alsize)
+    : __strmode_(__dynamic),
+      __alsize_(__alsize),
+      __palloc_(nullptr),
+      __pfree_(nullptr)
+{
+}
+
+strstreambuf::strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*))
+    : __strmode_(__dynamic),
+      __alsize_(__default_alsize),
+      __palloc_(__palloc),
+      __pfree_(__pfree)
+{
+}
+
+void
+strstreambuf::__init(char* __gnext, streamsize __n, char* __pbeg)
+{
+    if (__n == 0)
+        __n = static_cast<streamsize>(strlen(__gnext));
+    else if (__n < 0)
+        __n = INT_MAX;
+    if (__pbeg == nullptr)
+        setg(__gnext, __gnext, __gnext + __n);
+    else
+    {
+        setg(__gnext, __gnext, __pbeg);
+        setp(__pbeg, __pbeg + __n);
+    }
+}
+
+strstreambuf::strstreambuf(char* __gnext, streamsize __n, char* __pbeg)
+    : __strmode_(),
+      __alsize_(__default_alsize),
+      __palloc_(nullptr),
+      __pfree_(nullptr)
+{
+    __init(__gnext, __n, __pbeg);
+}
+
+strstreambuf::strstreambuf(const char* __gnext, streamsize __n)
+    : __strmode_(__constant),
+      __alsize_(__default_alsize),
+      __palloc_(nullptr),
+      __pfree_(nullptr)
+{
+    __init(const_cast<char *>(__gnext), __n, nullptr);
+}
+
+strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg)
+    : __strmode_(),
+      __alsize_(__default_alsize),
+      __palloc_(nullptr),
+      __pfree_(nullptr)
+{
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
+}
+
+strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n)
+    : __strmode_(__constant),
+      __alsize_(__default_alsize),
+      __palloc_(nullptr),
+      __pfree_(nullptr)
+{
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
+}
+
+strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg)
+    : __strmode_(),
+      __alsize_(__default_alsize),
+      __palloc_(nullptr),
+      __pfree_(nullptr)
+{
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg));
+}
+
+strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n)
+    : __strmode_(__constant),
+      __alsize_(__default_alsize),
+      __palloc_(nullptr),
+      __pfree_(nullptr)
+{
+    __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr);
+}
+
+strstreambuf::~strstreambuf()
+{
+    if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0)
+    {
+        if (__pfree_)
+            __pfree_(eback());
+        else
+            delete [] eback();
+    }
+}
+
+void
+strstreambuf::swap(strstreambuf& __rhs)
+{
+    streambuf::swap(__rhs);
+    _VSTD::swap(__strmode_, __rhs.__strmode_);
+    _VSTD::swap(__alsize_, __rhs.__alsize_);
+    _VSTD::swap(__palloc_, __rhs.__palloc_);
+    _VSTD::swap(__pfree_, __rhs.__pfree_);
+}
+
+void
+strstreambuf::freeze(bool __freezefl)
+{
+    if (__strmode_ & __dynamic)
+    {
+        if (__freezefl)
+            __strmode_ |= __frozen;
+        else
+            __strmode_ &= ~__frozen;
+    }
+}
+
+char*
+strstreambuf::str()
+{
+    if (__strmode_ & __dynamic)
+        __strmode_ |= __frozen;
+    return eback();
+}
+
+int
+strstreambuf::pcount() const
+{
+    return static_cast<int>(pptr() - pbase());
+}
+
+strstreambuf::int_type
+strstreambuf::overflow(int_type __c)
+{
+    if (__c == EOF)
+        return int_type(0);
+    if (pptr() == epptr())
+    {
+        if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0)
+            return int_type(EOF);
+        size_t old_size = static_cast<size_t> ((epptr() ? epptr() : egptr()) - eback());
+        size_t new_size = max<size_t>(static_cast<size_t>(__alsize_), 2*old_size);
+        if (new_size == 0)
+            new_size = __default_alsize;
+        char* buf = nullptr;
+        if (__palloc_)
+            buf = static_cast<char*>(__palloc_(new_size));
+        else
+            buf = new char[new_size];
+        if (buf == nullptr)
+            return int_type(EOF);
+        memcpy(buf, eback(), static_cast<size_t>(old_size));
+        ptrdiff_t ninp = gptr()  - eback();
+        ptrdiff_t einp = egptr() - eback();
+        ptrdiff_t nout = pptr()  - pbase();
+        ptrdiff_t eout = epptr() - pbase();
+        if (__strmode_ & __allocated)
+        {
+            if (__pfree_)
+                __pfree_(eback());
+            else
+                delete [] eback();
+        }
+        setg(buf, buf + ninp, buf + einp);
+        setp(buf + einp, buf + einp + eout);
+        pbump(static_cast<int>(nout));
+        __strmode_ |= __allocated;
+    }
+    *pptr() = static_cast<char>(__c);
+    pbump(1);
+    return int_type(static_cast<unsigned char>(__c));
+}
+
+strstreambuf::int_type
+strstreambuf::pbackfail(int_type __c)
+{
+    if (eback() == gptr())
+        return EOF;
+    if (__c == EOF)
+    {
+        gbump(-1);
+        return int_type(0);
+    }
+    if (__strmode_ & __constant)
+    {
+        if (gptr()[-1] == static_cast<char>(__c))
+        {
+            gbump(-1);
+            return __c;
+        }
+        return EOF;
+    }
+    gbump(-1);
+    *gptr() = static_cast<char>(__c);
+    return __c;
+}
+
+strstreambuf::int_type
+strstreambuf::underflow()
+{
+    if (gptr() == egptr())
+    {
+        if (egptr() >= pptr())
+            return EOF;
+        setg(eback(), gptr(), pptr());
+    }
+    return int_type(static_cast<unsigned char>(*gptr()));
+}
+
+strstreambuf::pos_type
+strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which)
+{
+    off_type __p(-1);
+    bool pos_in = (__which & ios::in) != 0;
+    bool pos_out = (__which & ios::out) != 0;
+    bool legal = false;
+    switch (__way)
+    {
+    case ios::beg:
+    case ios::end:
+        if (pos_in || pos_out)
+            legal = true;
+        break;
+    case ios::cur:
+        if (pos_in != pos_out)
+            legal = true;
+        break;
+    }
+    if (pos_in && gptr() == nullptr)
+        legal = false;
+    if (pos_out && pptr() == nullptr)
+        legal = false;
+    if (legal)
+    {
+        off_type newoff;
+        char* seekhigh = epptr() ? epptr() : egptr();
+        switch (__way)
+        {
+        case ios::beg:
+            newoff = 0;
+            break;
+        case ios::cur:
+            newoff = (pos_in ? gptr() : pptr()) - eback();
+            break;
+        case ios::end:
+            newoff = seekhigh - eback();
+            break;
+        }
+        newoff += __off;
+        if (0 <= newoff && newoff <= seekhigh - eback())
+        {
+            char* newpos = eback() + newoff;
+            if (pos_in)
+                setg(eback(), newpos, _VSTD::max(newpos, egptr()));
+            if (pos_out)
+            {
+                // min(pbase, newpos), newpos, epptr()
+                __off = epptr() - newpos;
+                setp(min(pbase(), newpos), epptr());
+                pbump(static_cast<int>((epptr() - pbase()) - __off));
+            }
+            __p = newoff;
+        }
+    }
+    return pos_type(__p);
+}
+
+strstreambuf::pos_type
+strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which)
+{
+    off_type __p(-1);
+    bool pos_in = (__which & ios::in) != 0;
+    bool pos_out = (__which & ios::out) != 0;
+    if (pos_in || pos_out)
+    {
+        if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr)))
+        {
+            off_type newoff = __sp;
+            char* seekhigh = epptr() ? epptr() : egptr();
+            if (0 <= newoff && newoff <= seekhigh - eback())
+            {
+                char* newpos = eback() + newoff;
+                if (pos_in)
+                    setg(eback(), newpos, _VSTD::max(newpos, egptr()));
+                if (pos_out)
+                {
+                    // min(pbase, newpos), newpos, epptr()
+                    off_type temp = epptr() - newpos;
+                    setp(min(pbase(), newpos), epptr());
+                    pbump(static_cast<int>((epptr() - pbase()) - temp));
+                }
+                __p = newoff;
+            }
+        }
+    }
+    return pos_type(__p);
+}
+
+istrstream::~istrstream()
+{
+}
+
+ostrstream::~ostrstream()
+{
+}
+
+strstream::~strstream()
+{
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/support/solaris/README b/final/src/support/solaris/README
new file mode 100644
index 0000000..89c887a
--- /dev/null
+++ b/final/src/support/solaris/README
@@ -0,0 +1,4 @@
+This directory contains a partial implementation of the xlocale APIs for
+Solaris.  Some portions are lifted from FreeBSD libc, and so are covered by a
+2-clause BSD license instead of the MIT/UUIC license that the rest of libc++ is
+distributed under.
diff --git a/final/src/support/solaris/mbsnrtowcs.inc b/final/src/support/solaris/mbsnrtowcs.inc
new file mode 100644
index 0000000..0740452
--- /dev/null
+++ b/final/src/support/solaris/mbsnrtowcs.inc
@@ -0,0 +1,76 @@
+
+
+/*-
+ * As noted in the source, some portions of this implementation are copied from
+ * FreeBSD libc.  These are covered by the following copyright:
+ *
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+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)
+{
+  const char *s;
+  size_t nchr;
+  wchar_t wc;
+  size_t nb;
+  FIX_LOCALE(loc);
+
+  s = *src;
+  nchr = 0;
+
+  if (dst == NULL) {
+    for (;;) {
+      if ((nb = mbrtowc_l(&wc, s, nms, ps, loc)) == (size_t)-1)
+        /* Invalid sequence - mbrtowc() sets errno. */
+        return ((size_t)-1);
+      else if (nb == 0 || nb == (size_t)-2)
+        return (nchr);
+      s += nb;
+      nms -= nb;
+      nchr++;
+    }
+    /*NOTREACHED*/
+  }
+
+  while (len-- > 0) {
+    if ((nb = mbrtowc_l(dst, s, nms, ps, loc)) == (size_t)-1) {
+      *src = s;
+      return ((size_t)-1);
+    } else if (nb == (size_t)-2) {
+      *src = s + nms;
+      return (nchr);
+    } else if (nb == 0) {
+      *src = NULL;
+      return (nchr);
+    }
+    s += nb;
+    nms -= nb;
+    nchr++;
+    dst++;
+  }
+  *src = s;
+  return (nchr);
+}
diff --git a/final/src/support/solaris/wcsnrtombs.inc b/final/src/support/solaris/wcsnrtombs.inc
new file mode 100644
index 0000000..67e7078
--- /dev/null
+++ b/final/src/support/solaris/wcsnrtombs.inc
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 2002-2004 Tim J. Robbins.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+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)
+{
+  FIX_LOCALE(loc);
+  mbstate_t mbsbak;
+  char buf[MB_CUR_MAX_L(loc)];
+  const wchar_t *s;
+  size_t nbytes;
+  size_t nb;
+
+  s = *src;
+  nbytes = 0;
+
+  if (dst == NULL) {
+    while (nwc-- > 0) {
+      if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1)
+        /* Invalid character - wcrtomb() sets errno. */
+        return ((size_t)-1);
+      else if (*s == L'\0')
+        return (nbytes + nb - 1);
+      s++;
+      nbytes += nb;
+    }
+    return (nbytes);
+  }
+
+  while (len > 0 && nwc-- > 0) {
+    if (len > (size_t)MB_CUR_MAX_L(loc)) {
+      /* Enough space to translate in-place. */
+      if ((nb = wcrtomb_l(dst, *s, ps, loc)) == (size_t)-1) {
+        *src = s;
+        return ((size_t)-1);
+      }
+    } else {
+      /*
+       * May not be enough space; use temp. buffer.
+       *
+       * We need to save a copy of the conversion state
+       * here so we can restore it if the multibyte
+       * character is too long for the buffer.
+       */
+      mbsbak = *ps;
+      if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1) {
+        *src = s;
+        return ((size_t)-1);
+      }
+      if (nb > (int)len) {
+        /* MB sequence for character won't fit. */
+        *ps = mbsbak;
+        break;
+      }
+      memcpy(dst, buf, nb);
+    }
+    if (*s == L'\0') {
+      *src = NULL;
+      return (nbytes + nb - 1);
+    }
+    s++;
+    dst += nb;
+    len -= nb;
+    nbytes += nb;
+  }
+  *src = s;
+  return (nbytes);
+}
+
diff --git a/final/src/support/solaris/xlocale.c b/final/src/support/solaris/xlocale.c
new file mode 100644
index 0000000..39dd8e3
--- /dev/null
+++ b/final/src/support/solaris/xlocale.c
@@ -0,0 +1,253 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 __sun__
+      
+#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);
+}
+
+#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);
+}
+
+// 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;
+  va_start(__va, __format);
+  int __res = vsnprintf_l(__s, __n , __l, __format, __va);
+  va_end(__va);
+  return __res;
+}
+
+int asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
+  va_list __va;
+  va_start(__va, __format);
+  // FIXME:
+  int __res = vasprintf(__s, __format, __va);
+  va_end(__va);
+  return __res;
+}
+
+int sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
+  va_list __va;
+  va_start(__va, __format);
+  // FIXME:
+  int __res = vsscanf(__s, __format, __va);
+  va_end(__va);
+  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;
+}
+
+void freelocale(locale_t loc)
+{
+  if (loc != __C_locale)
+    free(loc);
+}
+
+__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
diff --git a/final/src/support/win32/locale_win32.cpp b/final/src/support/win32/locale_win32.cpp
new file mode 100644
index 0000000..5a43743
--- /dev/null
+++ b/final/src/support/win32/locale_win32.cpp
@@ -0,0 +1,105 @@
+// -*- C++ -*-
+//===-------------------- support/win32/locale_win32.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 <locale>
+#include <cstdarg> // va_start, va_end
+
+// FIXME: base currently unused. Needs manual work to construct the new locale
+locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
+{
+    return _create_locale( mask, locale );
+}
+locale_t uselocale( locale_t newloc )
+{
+    locale_t old_locale = _get_current_locale();
+    if ( newloc == NULL )
+        return old_locale;
+    // uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
+    _configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
+    // uselocale sets all categories
+    setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
+    // uselocale returns the old locale_t
+    return old_locale;
+}
+lconv *localeconv_l( locale_t loc )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return localeconv();
+}
+size_t mbrlen_l( const char *__restrict s, size_t n,
+                 mbstate_t *__restrict ps, locale_t loc )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return mbrlen( s, n, ps );
+}
+size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
+                    size_t len, mbstate_t *__restrict ps, locale_t loc )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return mbsrtowcs( dst, src, len, ps );
+}
+size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
+                  locale_t loc )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return wcrtomb( s, wc, ps );
+}
+size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
+                  size_t n, mbstate_t *__restrict ps, locale_t loc )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return mbrtowc( pwc, s, n, ps );
+}
+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 )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return mbsnrtowcs( dst, src, nms, len, ps );
+}
+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_raii __current( uselocale(loc), uselocale );
+    return wcsnrtombs( dst, src, nwc, len, ps );
+}
+wint_t btowc_l( int c, locale_t loc )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return btowc( c );
+}
+int wctob_l( wint_t c, locale_t loc )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return wctob( c );
+}
+
+int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    va_list ap;
+    va_start( ap, format );
+    int result = vsnprintf( ret, n, format, ap );
+    va_end(ap);
+    return result;
+}
+
+int asprintf_l( char **ret, locale_t loc, const char *format, ... )
+{
+    va_list ap;
+    va_start( ap, format );
+    int result = vasprintf_l( ret, loc, format, ap );
+    va_end(ap);
+    return result;
+}
+int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap )
+{
+    __locale_raii __current( uselocale(loc), uselocale );
+    return vasprintf( ret, format, ap );
+}
diff --git a/final/src/support/win32/support.cpp b/final/src/support/win32/support.cpp
new file mode 100644
index 0000000..e989681
--- /dev/null
+++ b/final/src/support/win32/support.cpp
@@ -0,0 +1,166 @@
+// -*- C++ -*-
+//===----------------------- support/win32/support.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.
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdarg> // va_start, va_end
+#include <cstddef> // size_t
+#include <cstdlib> // malloc
+#include <cstdio>  // vsprintf, vsnprintf
+#include <cstring> // strcpy, wcsncpy
+#include <cwchar>  // mbstate_t
+
+// Some of these functions aren't standard or if they conform, the name does not.
+
+int asprintf(char **sptr, const char *__restrict format, ...)
+{
+    va_list ap;
+    va_start(ap, format);
+    int result;
+    result = vasprintf(sptr, format, ap);
+    va_end(ap);
+    return result;
+}
+
+// Like sprintf, but when return value >= 0 it returns
+// a pointer to a malloc'd string in *sptr.
+// If return >= 0, use free to delete *sptr.
+int vasprintf( char **sptr, const char *__restrict format, va_list ap )
+{
+    *sptr = NULL;
+    // Query the count required.
+    int count = _vsnprintf( NULL, 0, format, ap );
+    if (count < 0)
+        return count;
+    size_t buffer_size = static_cast<size_t>(count) + 1;
+    char* p = static_cast<char*>(malloc(buffer_size));
+    if ( ! p )
+        return -1;
+    // If we haven't used exactly what was required, something is wrong.
+    // Maybe bug in vsnprintf. Report the error and return.
+    if (_vsnprintf(p, buffer_size, format, ap) != count) {
+        free(p);
+        return -1;
+    }
+    // All good. This is returning memory to the caller not freeing it.
+    *sptr = p;
+    return count;
+}
+
+// Returns >= 0: the number of wide characters found in the 
+// multi byte sequence src (of src_size_bytes), that fit in the buffer dst 
+// (of max_dest_chars elements size). The count returned excludes the
+// null terminator. When dst is NULL, no characters are copied 
+// and no "out" parameters are updated.
+// Returns (size_t) -1: an incomplete sequence encountered.
+// Leaves *src pointing the next character to convert or NULL 
+// if a null character was converted from *src.
+size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
+                   size_t src_size_bytes, size_t max_dest_chars, mbstate_t *__restrict ps )
+{
+    const size_t terminated_sequence = static_cast<size_t>(0);
+    //const size_t invalid_sequence = static_cast<size_t>(-1);
+    const size_t incomplete_sequence = static_cast< size_t>(-2);
+
+    size_t dest_converted = 0;
+    size_t source_converted = 0;
+    size_t source_remaining = src_size_bytes;
+    size_t result = 0;
+    bool have_result = false;
+
+    while ( source_remaining ) {
+        if ( dst && dest_converted >= max_dest_chars )
+            break;
+        // Converts one multi byte character.
+        // if result > 0, it's the size in bytes of that character.
+        // othewise if result is zero it indicates the null character has been found.
+        // otherwise it's an error and errno may be set.
+        size_t char_size = mbrtowc( dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps );
+        // Don't do anything to change errno from here on.
+        if ( char_size > 0 ) {
+            source_remaining -= char_size;
+            source_converted += char_size;
+            ++dest_converted;
+            continue;
+        }
+        result = char_size;
+        have_result = true;
+        break;
+    }
+    if ( dst ) {
+        if ( have_result && result == terminated_sequence )
+            *src = NULL;
+        else
+            *src += source_converted;
+    }
+    if ( have_result && result != terminated_sequence && result != incomplete_sequence )
+        return static_cast<size_t>(-1);
+
+    return dest_converted;
+}
+
+// Converts max_source_chars from the wide character buffer pointer to by *src,
+// into the multi byte character sequence buffer stored at dst which must be
+// dst_size_bytes bytes in size.
+// Returns >= 0: the number of bytes in the sequence
+// converted from *src, excluding the null terminator.
+// Returns size_t(-1) if an error occurs, also sets errno.
+// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst 
+// and no "out" parameters are updated.
+size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
+                   size_t max_source_chars, size_t dst_size_bytes, mbstate_t *__restrict ps )
+{
+    //const size_t invalid_sequence = static_cast<size_t>(-1);
+
+    size_t source_converted = 0;
+    size_t dest_converted = 0;
+    size_t dest_remaining = dst_size_bytes;
+    size_t char_size = 0;
+    const errno_t no_error = ( errno_t) 0;
+    errno_t result = ( errno_t ) 0;
+    bool have_result = false;
+    bool terminator_found = false;
+
+    while ( source_converted != max_source_chars ) {
+        if ( ! dest_remaining )
+            break;
+        wchar_t c = (*src)[source_converted];
+        if ( dst )
+            result = wcrtomb_s( &char_size, dst + dest_converted, dest_remaining, c, ps);
+        else
+            result = wcrtomb_s( &char_size, NULL, 0, c, ps);
+        // If result is zero there is no error and char_size contains the 
+        // size of the multi-byte-sequence converted.
+        // Otherwise result indicates an errno type error.
+        if ( result == no_error ) {
+            if ( c == L'\0' ) {
+                terminator_found = true;
+                break;
+            }
+            ++source_converted;
+            if ( dst )
+                dest_remaining -= char_size;
+            dest_converted += char_size;
+            continue;
+        }
+        have_result = true;
+        break;
+    }
+    if ( dst ) {
+        if ( terminator_found )
+            *src = NULL;
+        else
+            *src = *src + source_converted;
+    }
+    if ( have_result && result != no_error ) {
+        errno = result;
+        return static_cast<size_t>(-1);
+    }
+
+    return dest_converted;
+}
diff --git a/final/src/system_error.cpp b/final/src/system_error.cpp
new file mode 100644
index 0000000..d5cb2d4
--- /dev/null
+++ b/final/src/system_error.cpp
@@ -0,0 +1,214 @@
+//===---------------------- system_error.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_BUILDING_SYSTEM_ERROR
+#include "system_error"
+#include "string"
+#include "cstring"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// class error_category
+
+error_category::error_category() _NOEXCEPT
+{
+}
+
+error_category::~error_category() _NOEXCEPT
+{
+}
+
+error_condition
+error_category::default_error_condition(int ev) const _NOEXCEPT
+{
+    return error_condition(ev, *this);
+}
+
+bool
+error_category::equivalent(int code, const error_condition& condition) const _NOEXCEPT
+{
+    return default_error_condition(code) == condition;
+}
+
+bool
+error_category::equivalent(const error_code& code, int condition) const _NOEXCEPT
+{
+    return *this == code.category() && code.value() == condition;
+}
+
+string
+__do_message::message(int ev) const
+{
+    return string(strerror(ev));
+}
+
+class _LIBCPP_HIDDEN __generic_error_category
+    : public __do_message
+{
+public:
+    virtual const char* name() const _NOEXCEPT;
+    virtual string message(int ev) const;
+};
+
+const char*
+__generic_error_category::name() const _NOEXCEPT
+{
+    return "generic";
+}
+
+string
+__generic_error_category::message(int ev) const
+{
+#ifdef ELAST
+    if (ev > ELAST)
+      return string("unspecified generic_category error");
+#elif defined(__linux__)
+    if (ev > 4095)
+      return string("unspecified generic_category error");
+#endif  // ELAST
+    return __do_message::message(ev);
+}
+
+const error_category&
+generic_category() _NOEXCEPT
+{
+    static __generic_error_category s;
+    return s;
+}
+
+class _LIBCPP_HIDDEN __system_error_category
+    : public __do_message
+{
+public:
+    virtual const char* name() const _NOEXCEPT;
+    virtual string message(int ev) const;
+    virtual error_condition default_error_condition(int ev) const _NOEXCEPT;
+};
+
+const char*
+__system_error_category::name() const _NOEXCEPT
+{
+    return "system";
+}
+
+string
+__system_error_category::message(int ev) const
+{
+#ifdef ELAST
+    if (ev > ELAST)
+      return string("unspecified system_category error");
+#elif defined(__linux__)
+    if (ev > 4095)
+      return string("unspecified system_category error");
+#endif  // ELAST
+    return __do_message::message(ev);
+}
+
+error_condition
+__system_error_category::default_error_condition(int ev) const _NOEXCEPT
+{
+#ifdef ELAST
+    if (ev > ELAST)
+      return error_condition(ev, system_category());
+#elif defined(__linux__)
+    if (ev > 4095)
+      return error_condition(ev, system_category());
+#endif  // ELAST
+    return error_condition(ev, generic_category());
+}
+
+const error_category&
+system_category() _NOEXCEPT
+{
+    static __system_error_category s;
+    return s;
+}
+
+// error_condition
+
+string
+error_condition::message() const
+{
+    return __cat_->message(__val_);
+}
+
+// error_code
+
+string
+error_code::message() const
+{
+    return __cat_->message(__val_);
+}
+
+// system_error
+
+string
+system_error::__init(const error_code& ec, string what_arg)
+{
+    if (ec)
+    {
+        if (!what_arg.empty())
+            what_arg += ": ";
+        what_arg += ec.message();
+    }
+    return _VSTD::move(what_arg);
+}
+
+system_error::system_error(error_code ec, const string& what_arg)
+    : runtime_error(__init(ec, what_arg)),
+      __ec_(ec)
+{
+}
+
+system_error::system_error(error_code ec, const char* what_arg)
+    : runtime_error(__init(ec, what_arg)),
+      __ec_(ec)
+{
+}
+
+system_error::system_error(error_code ec)
+    : runtime_error(__init(ec, "")),
+      __ec_(ec)
+{
+}
+
+system_error::system_error(int ev, const error_category& ecat, const string& what_arg)
+    : runtime_error(__init(error_code(ev, ecat), what_arg)),
+      __ec_(error_code(ev, ecat))
+{
+}
+
+system_error::system_error(int ev, const error_category& ecat, const char* what_arg)
+    : runtime_error(__init(error_code(ev, ecat), what_arg)),
+      __ec_(error_code(ev, ecat))
+{
+}
+
+system_error::system_error(int ev, const error_category& ecat)
+    : runtime_error(__init(error_code(ev, ecat), "")),
+      __ec_(error_code(ev, ecat))
+{
+}
+
+system_error::~system_error() _NOEXCEPT
+{
+}
+
+void
+__throw_system_error(int ev, const char* what_arg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw system_error(error_code(ev, system_category()), what_arg);
+#else
+    (void)ev;
+    (void)what_arg;
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/thread.cpp b/final/src/thread.cpp
new file mode 100644
index 0000000..e6f57c4
--- /dev/null
+++ b/final/src/thread.cpp
@@ -0,0 +1,227 @@
+//===------------------------- thread.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 "thread"
+#include "exception"
+#include "vector"
+#include "future"
+#include "limits"
+#include <sys/types.h>
+#if !defined(_WIN32)
+#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
+#include <sys/sysctl.h>
+#endif // !__sun__ && !__linux__ && !_AIX
+#include <unistd.h>
+#endif // !_WIN32
+
+#if defined(__NetBSD__)
+#pragma weak pthread_create // Do not create libpthread dependency
+#endif
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+thread::~thread()
+{
+    if (__t_ != 0)
+        terminate();
+}
+
+void
+thread::join()
+{
+    int ec = pthread_join(__t_, 0);
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (ec)
+        throw system_error(error_code(ec, system_category()), "thread::join failed");
+#else
+    (void)ec;
+#endif  // _LIBCPP_NO_EXCEPTIONS
+    __t_ = 0;
+}
+
+void
+thread::detach()
+{
+    int ec = EINVAL;
+    if (__t_ != 0)
+    {
+        ec = pthread_detach(__t_);
+        if (ec == 0)
+            __t_ = 0;
+    }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    if (ec)
+        throw system_error(error_code(ec, system_category()), "thread::detach failed");
+#endif  // _LIBCPP_NO_EXCEPTIONS
+}
+
+unsigned
+thread::hardware_concurrency() _NOEXCEPT
+{
+#if defined(CTL_HW) && defined(HW_NCPU)
+    unsigned n;
+    int mib[2] = {CTL_HW, HW_NCPU};
+    std::size_t s = sizeof(n);
+    sysctl(mib, 2, &n, &s, 0, 0);
+    return n;
+#elif defined(_SC_NPROCESSORS_ONLN)
+    long result = sysconf(_SC_NPROCESSORS_ONLN);
+    // sysconf returns -1 if the name is invalid, the option does not exist or
+    // does not have a definite limit.
+    // if sysconf returns some other negative number, we have no idea
+    // what is going on. Default to something safe.
+    if (result < 0)
+        return 0;
+    return static_cast<unsigned>(result);
+#elif defined(_WIN32)
+    SYSTEM_INFO info;
+    GetSystemInfo(&info);
+    return info.dwNumberOfProcessors;
+#else  // defined(CTL_HW) && defined(HW_NCPU)
+    // TODO: grovel through /proc or check cpuid on x86 and similar
+    // instructions on other architectures.
+#   if defined(_MSC_VER) && ! defined(__clang__)
+        _LIBCPP_WARNING("hardware_concurrency not yet implemented")
+#   else
+#       warning hardware_concurrency not yet implemented
+#   endif
+    return 0;  // Means not computable [thread.thread.static]
+#endif  // defined(CTL_HW) && defined(HW_NCPU)
+}
+
+namespace this_thread
+{
+
+void
+sleep_for(const chrono::nanoseconds& ns)
+{
+    using namespace chrono;
+    if (ns > nanoseconds::zero())
+    {
+        seconds s = duration_cast<seconds>(ns);
+        timespec ts;
+        typedef decltype(ts.tv_sec) ts_sec;
+        _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
+        if (s.count() < ts_sec_max)
+        {
+            ts.tv_sec = static_cast<ts_sec>(s.count());
+            ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((ns-s).count());
+        }
+        else
+        {
+            ts.tv_sec = ts_sec_max;
+            ts.tv_nsec = giga::num - 1;
+        }
+
+        while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
+            ;
+    }
+}
+
+}  // this_thread
+
+__thread_specific_ptr<__thread_struct>&
+__thread_local_data()
+{
+    static __thread_specific_ptr<__thread_struct> __p;
+    return __p;
+}
+
+// __thread_struct_imp
+
+template <class T>
+class _LIBCPP_HIDDEN __hidden_allocator
+{
+public:
+    typedef T  value_type;
+    
+    T* allocate(size_t __n)
+        {return static_cast<T*>(::operator new(__n * sizeof(T)));}
+    void deallocate(T* __p, size_t) {::operator delete(static_cast<void*>(__p));}
+
+    size_t max_size() const {return size_t(~0) / sizeof(T);}
+};
+
+class _LIBCPP_HIDDEN __thread_struct_imp
+{
+    typedef vector<__assoc_sub_state*,
+                          __hidden_allocator<__assoc_sub_state*> > _AsyncStates;
+    typedef vector<pair<condition_variable*, mutex*>,
+               __hidden_allocator<pair<condition_variable*, mutex*> > > _Notify;
+
+    _AsyncStates async_states_;
+    _Notify notify_;
+
+    __thread_struct_imp(const __thread_struct_imp&);
+    __thread_struct_imp& operator=(const __thread_struct_imp&);
+public:
+    __thread_struct_imp() {}
+    ~__thread_struct_imp();
+
+    void notify_all_at_thread_exit(condition_variable* cv, mutex* m);
+    void __make_ready_at_thread_exit(__assoc_sub_state* __s);
+};
+
+__thread_struct_imp::~__thread_struct_imp()
+{
+    for (_Notify::iterator i = notify_.begin(), e = notify_.end();
+            i != e; ++i)
+    {
+        i->second->unlock();
+        i->first->notify_all();
+    }
+    for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end();
+            i != e; ++i)
+    {
+        (*i)->__make_ready();
+        (*i)->__release_shared();
+    }
+}
+
+void
+__thread_struct_imp::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+{
+    notify_.push_back(pair<condition_variable*, mutex*>(cv, m));
+}
+
+void
+__thread_struct_imp::__make_ready_at_thread_exit(__assoc_sub_state* __s)
+{
+    async_states_.push_back(__s);
+    __s->__add_shared();
+}
+
+// __thread_struct
+
+__thread_struct::__thread_struct()
+    : __p_(new __thread_struct_imp)
+{
+}
+
+__thread_struct::~__thread_struct()
+{
+    delete __p_;
+}
+
+void
+__thread_struct::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
+{
+    __p_->notify_all_at_thread_exit(cv, m);
+}
+
+void
+__thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s)
+{
+    __p_->__make_ready_at_thread_exit(__s);
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/typeinfo.cpp b/final/src/typeinfo.cpp
new file mode 100644
index 0000000..b428120
--- /dev/null
+++ b/final/src/typeinfo.cpp
@@ -0,0 +1,73 @@
+//===------------------------- typeinfo.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 <stdlib.h>
+
+#ifndef __has_include
+#define __has_include(inc) 0
+#endif
+
+#ifdef __APPLE__
+#include <cxxabi.h>
+#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
+#include <cxxabi.h>
+#endif
+
+#include "typeinfo"
+
+#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
+
+std::bad_cast::bad_cast() _NOEXCEPT
+{
+}
+
+std::bad_typeid::bad_typeid() _NOEXCEPT
+{
+}
+
+#ifndef __GLIBCXX__
+
+std::bad_cast::~bad_cast() _NOEXCEPT
+{
+}
+
+const char*
+std::bad_cast::what() const _NOEXCEPT
+{
+  return "std::bad_cast";
+}
+
+std::bad_typeid::~bad_typeid() _NOEXCEPT
+{
+}
+
+const char*
+std::bad_typeid::what() const _NOEXCEPT
+{
+  return "std::bad_typeid";
+}
+
+#ifdef __APPLE__
+  // On Darwin, the cxa_bad_* functions cannot be in the lower level library
+  // because bad_cast and bad_typeid are defined in his higher level library
+  void __cxxabiv1::__cxa_bad_typeid()
+  {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+     throw std::bad_typeid();
+#endif
+  }
+  void __cxxabiv1::__cxa_bad_cast()
+  {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+      throw std::bad_cast();
+#endif
+  }
+#endif
+
+#endif  // !__GLIBCXX__
+#endif  // !LIBCXXRT && !_LIBCPPABI_VERSION
diff --git a/final/src/utility.cpp b/final/src/utility.cpp
new file mode 100644
index 0000000..e9830e7
--- /dev/null
+++ b/final/src/utility.cpp
@@ -0,0 +1,17 @@
+//===------------------------ utility.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_BUILDING_UTILITY
+#include "utility"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+const piecewise_construct_t piecewise_construct = {};
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/src/valarray.cpp b/final/src/valarray.cpp
new file mode 100644
index 0000000..e4c9ed0
--- /dev/null
+++ b/final/src/valarray.cpp
@@ -0,0 +1,56 @@
+//===------------------------ valarray.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.
+//
+//===----------------------------------------------------------------------===//
+
+#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
+
+#include "valarray"
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template valarray<size_t>::valarray(size_t);
+template valarray<size_t>::~valarray();
+template void valarray<size_t>::resize(size_t, size_t);
+
+void
+gslice::__init(size_t __start)
+{
+    valarray<size_t> __indices(__size_.size());
+    size_t __k = __size_.size() != 0;
+    for (size_t __i = 0; __i < __size_.size(); ++__i)
+        __k *= __size_[__i];
+    __1d_.resize(__k);
+    if (__1d_.size())
+    {
+        __k = 0;
+        __1d_[__k] = __start;
+        while (true)
+        {
+            size_t __i = __indices.size() - 1;
+            while (true)
+            {
+                if (++__indices[__i] < __size_[__i])
+                {
+                    ++__k;
+                    __1d_[__k] = __1d_[__k-1] + __stride_[__i];
+                    for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
+                        __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
+                    break;
+                }
+                else
+                {
+                    if (__i == 0)
+                        return;
+                    __indices[__i--] = 0;
+                }
+            }
+        }
+    }
+}
+
+_LIBCPP_END_NAMESPACE_STD
diff --git a/final/test/CMakeLists.txt b/final/test/CMakeLists.txt
new file mode 100644
index 0000000..4810b2c
--- /dev/null
+++ b/final/test/CMakeLists.txt
@@ -0,0 +1,49 @@
+macro(pythonize_bool var)
+  if (${var})
+    set(${var} True)
+  else()
+    set(${var} False)
+  endif()
+endmacro()
+
+include(FindPythonInterp)
+if(PYTHONINTERP_FOUND)
+  if(LIBCXX_BUILT_STANDALONE)
+    set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's lit.py.")
+  else()
+    set(LIT_EXECUTABLE "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
+  endif()
+
+  set(LIT_ARGS_DEFAULT "-sv")
+  if (MSVC OR XCODE)
+    set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+  endif()
+  set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}"
+      CACHE STRING "Default options for lit")
+  set(LIT_ARGS "${LLVM_LIT_ARGS}")
+  separate_arguments(LIT_ARGS)
+
+  set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
+  set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
+  set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR})
+  set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
+  pythonize_bool(LIBCXX_ENABLE_SHARED)
+  pythonize_bool(LIBCXX_HAS_STDCXX0X_FLAG)
+
+  set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
+
+  configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+    @ONLY)
+
+  add_custom_target(check-libcxx
+    COMMAND ${PYTHON_EXECUTABLE}
+            ${LIT_EXECUTABLE}
+            ${LIT_ARGS}
+            ${CMAKE_CURRENT_BINARY_DIR}
+    DEPENDS cxx
+    COMMENT "Running libcxx tests")
+else()
+  message(WARNING "Could not find Python, no check target will be available!")
+endif()
diff --git a/final/test/algorithms/alg.c.library/tested_elsewhere.pass.cpp b/final/test/algorithms/alg.c.library/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.c.library/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
new file mode 100644
index 0000000..a20d6ab
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.copy/copy.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+//   OutIter
+//   copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy(InIter(ia), InIter(ia+N), OutIter(ib));
+    assert(base(r) == ib+N);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
new file mode 100644
index 0000000..039fd2f
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.copy/copy_backward.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, BidirectionalIterator OutIter>
+//   requires OutputIterator<OutIter, InIter::reference>
+//   OutIter
+//   copy_backward(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+    assert(base(r) == ib);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
new file mode 100644
index 0000000..ab402a5
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.copy/copy_if.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter,
+//          Predicate<auto, InIter::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   OutIter
+//   copy_if(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct Pred
+{
+    bool operator()(int i) {return i % 3 == 0;}
+};
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy_if(InIter(ia), InIter(ia+N), OutIter(ib), Pred());
+    assert(base(r) == ib+N/3+1);
+    for (unsigned i = 0; i < N/3+1; ++i)
+        assert(ib[i] % 3 == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
new file mode 100644
index 0000000..f594a0b
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.copy/copy_n.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+//   OutIter
+//   copy_n(InIter first, InIter::difference_type n, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::copy_n(InIter(ia), N/2, OutIter(ib));
+    assert(base(r) == ib+N/2);
+    for (unsigned i = 0; i < N/2; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
new file mode 100644
index 0000000..c72adac
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.fill/fill.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires OutputIterator<Iter, const T&>
+//   void
+//   fill(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_char()
+{
+    const unsigned n = 4;
+    char ca[n] = {0};
+    std::fill(Iter(ca), Iter(ca+n), char(1));
+    assert(ca[0] == 1);
+    assert(ca[1] == 1);
+    assert(ca[2] == 1);
+    assert(ca[3] == 1);
+}
+
+template <class Iter>
+void
+test_int()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    std::fill(Iter(ia), Iter(ia+n), 1);
+    assert(ia[0] == 1);
+    assert(ia[1] == 1);
+    assert(ia[2] == 1);
+    assert(ia[3] == 1);
+}
+
+int main()
+{
+    test_char<forward_iterator<char*> >();
+    test_char<bidirectional_iterator<char*> >();
+    test_char<random_access_iterator<char*> >();
+    test_char<char*>();
+
+    test_int<forward_iterator<int*> >();
+    test_int<bidirectional_iterator<int*> >();
+    test_int<random_access_iterator<int*> >();
+    test_int<int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
new file mode 100644
index 0000000..bffcf1b
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.fill/fill_n.pass.cpp
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class Iter, IntegralLike Size, class T>
+//   requires OutputIterator<Iter, const T&>
+//   OutputIterator
+//   fill_n(Iter first, Size n, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_char()
+{
+    const unsigned n = 4;
+    char ca[n] = {0};
+    assert(std::fill_n(Iter(ca), n, char(1)) == std::next(Iter(ca), n));
+    assert(ca[0] == 1);
+    assert(ca[1] == 1);
+    assert(ca[2] == 1);
+    assert(ca[3] == 1);
+}
+
+template <class Iter>
+void
+test_int()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    assert(std::fill_n(Iter(ia), n, 1) == std::next(Iter(ia), n));
+    assert(ia[0] == 1);
+    assert(ia[1] == 1);
+    assert(ia[2] == 1);
+    assert(ia[3] == 1);
+}
+
+void
+test_int_array()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    assert(std::fill_n(ia, n, static_cast<char>(1)) == std::next(ia, n));
+    assert(ia[0] == 1);
+    assert(ia[1] == 1);
+    assert(ia[2] == 1);
+    assert(ia[3] == 1);
+}
+
+struct source {
+    source() : i(0) { }
+    
+    operator int() const { return i++; }
+    mutable int i;
+};
+
+void
+test_int_array_struct_source()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    assert(std::fill_n(ia, n, source()) == std::next(ia, n));
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 2);
+    assert(ia[3] == 3);
+}
+
+struct test1 {
+    test1() : c(0) { }
+    test1(char c) : c(c + 1) { }
+    char c;
+};
+
+void
+test_struct_array()
+{
+    const unsigned n = 4;
+    test1 test1a[n] = {0};
+    assert(std::fill_n(test1a, n, static_cast<char>(10)) == std::next(test1a, n));    
+    assert(test1a[0].c == 11);
+    assert(test1a[1].c == 11);
+    assert(test1a[2].c == 11);
+    assert(test1a[3].c == 11);
+}
+
+class A
+{
+    char a_;
+public:
+    A() {}
+    explicit A(char a) : a_(a) {}
+    operator unsigned char() const {return 'b';}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.a_ == y.a_;}
+};
+
+void
+test5()
+{
+    A a[3];
+    assert(std::fill_n(&a[0], 3, A('a')) == a+3);
+    assert(a[0] == A('a'));
+    assert(a[1] == A('a'));
+    assert(a[2] == A('a'));
+}
+
+struct Storage
+{
+  union
+  {
+    unsigned char a;
+    unsigned char b;
+  };
+};
+ 
+void test6()
+{
+  Storage foo[5];
+  std::fill_n(&foo[0], 5, Storage());
+}
+
+
+int main()
+{
+    test_char<forward_iterator<char*> >();
+    test_char<bidirectional_iterator<char*> >();
+    test_char<random_access_iterator<char*> >();
+    test_char<char*>();
+
+    test_int<forward_iterator<int*> >();
+    test_int<bidirectional_iterator<int*> >();
+    test_int<random_access_iterator<int*> >();
+    test_int<int*>();
+    
+    test_int_array();
+    test_int_array_struct_source();
+    test_struct_array();
+
+    test5();
+    test6();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp
new file mode 100644
index 0000000..f166d67
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.generate/generate.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Callable Generator>
+//   requires OutputIterator<Iter, Generator::result_type>
+//         && CopyConstructible<Generator>
+//   void
+//   generate(Iter first, Iter last, Generator gen);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct gen_test
+{
+    int operator()() const {return 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    std::generate(Iter(ia), Iter(ia+n), gen_test());
+    assert(ia[0] == 1);
+    assert(ia[1] == 1);
+    assert(ia[2] == 1);
+    assert(ia[3] == 1);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
new file mode 100644
index 0000000..2494191
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.generate/generate_n.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class Iter, IntegralLike Size, Callable Generator>
+//   requires OutputIterator<Iter, Generator::result_type>
+//         && CopyConstructible<Generator>
+//   void
+//   generate_n(Iter first, Size n, Generator gen);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct gen_test
+{
+    int operator()() const {return 2;}
+};
+
+template <class Iter>
+void
+test()
+{
+    const unsigned n = 4;
+    int ia[n] = {0};
+    assert(std::generate_n(Iter(ia), n, gen_test()) == Iter(ia+n));
+    assert(ia[0] == 2);
+    assert(ia[1] == 2);
+    assert(ia[2] == 2);
+    assert(ia[3] == 2);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.move/move.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
new file mode 100644
index 0000000..43234be
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.move/move.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter>
+//   requires OutputIterator<OutIter, RvalueOf<InIter::reference>::type>
+//   OutIter
+//   move(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib));
+    assert(base(r) == ib+N);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class InIter, class OutIter>
+void
+test1()
+{
+    const unsigned N = 100;
+    std::unique_ptr<int> ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::unique_ptr<int> ib[N];
+
+    OutIter r = std::move(InIter(ia), InIter(ia+N), OutIter(ib));
+    assert(base(r) == ib+N);
+    for (unsigned i = 0; i < N; ++i)
+        assert(*ib[i] == i);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test1<input_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<input_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<forward_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<random_access_iterator<std::unique_ptr<int>*>, output_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, input_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<std::unique_ptr<int>*, output_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, input_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, forward_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
new file mode 100644
index 0000000..02b6b16
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.move/move_backward.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, BidirectionalIterator OutIter>
+//   requires OutputIterator<OutIter, RvalueOf<InIter::reference>::type>
+//   OutIter
+//   move_backward(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const unsigned N = 1000;
+    int ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    int ib[N] = {0};
+
+    OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+    assert(base(r) == ib);
+    for (unsigned i = 0; i < N; ++i)
+        assert(ia[i] == ib[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class InIter, class OutIter>
+void
+test1()
+{
+    const unsigned N = 100;
+    std::unique_ptr<int> ia[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::unique_ptr<int> ib[N];
+
+    OutIter r = std::move_backward(InIter(ia), InIter(ia+N), OutIter(ib+N));
+    assert(base(r) == ib);
+    for (unsigned i = 0; i < N; ++i)
+        assert(*ib[i] == i);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
new file mode 100644
index 0000000..6098a20
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.partitions/is_partitioned.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//     bool
+//     is_partitioned(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+    {
+        const int ia[] = {1, 2, 3, 4, 5, 6};
+        assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6};
+        assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {2, 4, 6, 1, 3, 5};
+        assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+        assert(!std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::end(ia)),
+                                    is_odd()));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+        assert( std::is_partitioned(input_iterator<const int*>(std::begin(ia)),
+                                    input_iterator<const int*>(std::begin(ia)),
+                                    is_odd()));
+    }
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
new file mode 100644
index 0000000..8eddfbc
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.partitions/partition.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, Predicate<auto, Iter::value_type> Pred>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Pred>
+//   Iter
+//   partition(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+    // check mixed
+    int ia[] = {1, 2, 3, 4, 5, 6, 7, 8 ,9};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::partition(Iter(ia), Iter(ia + sa), is_odd());
+    assert(base(r) == ia + 5);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check empty
+    r = std::partition(Iter(ia), Iter(ia), is_odd());
+    assert(base(r) == ia);
+    // check all false
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia);
+    // check all true
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i+1;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+sa);
+    // check all true but last
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i+1;
+    ia[sa-1] = 10;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+sa-1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check all true but first
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i+1;
+    ia[0] = 10;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+sa-1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check all false but last
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i;
+    ia[sa-1] = 11;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+    // check all false but first
+    for (unsigned i = 0; i < sa; ++i)
+        ia[i] = 2*i;
+    ia[0] = 11;
+    r = std::partition(Iter(ia), Iter(ia+sa), is_odd());
+    assert(base(r) == ia+1);
+    for (int* i = ia; i < base(r); ++i)
+        assert(is_odd()(*i));
+    for (int* i = base(r); i < ia+sa; ++i)
+        assert(!is_odd()(*i));
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
new file mode 100644
index 0000000..67e1ccc
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class OutputIterator1,
+//           class OutputIterator2, class Predicate>
+//     pair<OutputIterator1, OutputIterator2>
+//     partition_copy(InputIterator first, InputIterator last,
+//                    OutputIterator1 out_true, OutputIterator2 out_false,
+//                    Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+    {
+        const int ia[] = {1, 2, 3, 4, 6, 8, 5, 7};
+        int r1[10] = {0};
+        int r2[10] = {0};
+        typedef std::pair<output_iterator<int*>,  int*> P;
+        P p = std::partition_copy(input_iterator<const int*>(std::begin(ia)),
+                                  input_iterator<const int*>(std::end(ia)),
+                                  output_iterator<int*>(r1), r2, is_odd());
+        assert(p.first.base() == r1 + 4);
+        assert(r1[0] == 1);
+        assert(r1[1] == 3);
+        assert(r1[2] == 5);
+        assert(r1[3] == 7);
+        assert(p.second == r2 + 4);
+        assert(r2[0] == 2);
+        assert(r2[1] == 4);
+        assert(r2[2] == 6);
+        assert(r2[3] == 8);
+    }
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
new file mode 100644
index 0000000..f5b832c
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.partitions/partition_point.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator, class Predicate>
+//     ForwardIterator
+//     partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+int main()
+{
+    {
+        const int ia[] = {2, 4, 6, 8, 10};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia));
+    }
+    {
+        const int ia[] = {1, 2, 4, 6, 8};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 1));
+    }
+    {
+        const int ia[] = {1, 3, 2, 4, 6};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 2));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 3));
+    }
+    {
+        const int ia[] = {1, 3, 5, 7, 2, 4};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 4));
+    }
+    {
+        const int ia[] = {1, 3, 5, 7, 9, 2};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 5));
+    }
+    {
+        const int ia[] = {1, 3, 5, 7, 9, 11};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::end(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia + 6));
+    }
+    {
+        const int ia[] = {1, 3, 5, 2, 4, 6, 7};
+        assert(std::partition_point(forward_iterator<const int*>(std::begin(ia)),
+                                    forward_iterator<const int*>(std::begin(ia)),
+                                    is_odd()) == forward_iterator<const int*>(ia));
+    }
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
new file mode 100644
index 0000000..7810dec
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp
@@ -0,0 +1,314 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, Predicate<auto, Iter::value_type> Pred>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Pred>
+//   Iter
+//   stable_partition(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+struct is_odd
+{
+    bool operator()(const int& i) const {return i & 1;}
+};
+
+struct odd_first
+{
+    bool operator()(const std::pair<int,int>& p) const
+        {return p.first & 1;}
+};
+
+template <class Iter>
+void
+test()
+{
+    {  // check mixed
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(1, 1),
+        P(1, 2),
+        P(2, 1),
+        P(2, 2),
+        P(3, 1),
+        P(3, 2),
+        P(4, 1),
+        P(4, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 4);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(0, 1));
+    assert(array[5] == P(0, 2));
+    assert(array[6] == P(2, 1));
+    assert(array[7] == P(2, 2));
+    assert(array[8] == P(4, 1));
+    assert(array[9] == P(4, 2));
+    }
+    {
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(1, 1),
+        P(1, 2),
+        P(2, 1),
+        P(2, 2),
+        P(3, 1),
+        P(3, 2),
+        P(4, 1),
+        P(4, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 4);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(0, 1));
+    assert(array[5] == P(0, 2));
+    assert(array[6] == P(2, 1));
+    assert(array[7] == P(2, 2));
+    assert(array[8] == P(4, 1));
+    assert(array[9] == P(4, 2));
+    // check empty
+    r = std::stable_partition(Iter(array), Iter(array), odd_first());
+    assert(base(r) == array);
+    // check one true
+    r = std::stable_partition(Iter(array), Iter(array+1), odd_first());
+    assert(base(r) == array+1);
+    assert(array[0] == P(1, 1));
+    // check one false
+    r = std::stable_partition(Iter(array+4), Iter(array+5), odd_first());
+    assert(base(r) == array+4);
+    assert(array[4] == P(0, 1));
+    }
+    {  // check all false
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(2, 1),
+        P(2, 2),
+        P(4, 1),
+        P(4, 2),
+        P(6, 1),
+        P(6, 2),
+        P(8, 1),
+        P(8, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array);
+    assert(array[0] == P(0, 1));
+    assert(array[1] == P(0, 2));
+    assert(array[2] == P(2, 1));
+    assert(array[3] == P(2, 2));
+    assert(array[4] == P(4, 1));
+    assert(array[5] == P(4, 2));
+    assert(array[6] == P(6, 1));
+    assert(array[7] == P(6, 2));
+    assert(array[8] == P(8, 1));
+    assert(array[9] == P(8, 2));
+    }
+    {  // check all true
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(1, 1),
+        P(1, 2),
+        P(3, 1),
+        P(3, 2),
+        P(5, 1),
+        P(5, 2),
+        P(7, 1),
+        P(7, 2),
+        P(9, 1),
+        P(9, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + size);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(5, 1));
+    assert(array[5] == P(5, 2));
+    assert(array[6] == P(7, 1));
+    assert(array[7] == P(7, 2));
+    assert(array[8] == P(9, 1));
+    assert(array[9] == P(9, 2));
+    }
+    {  // check all false but first true
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(1, 1),
+        P(0, 2),
+        P(2, 1),
+        P(2, 2),
+        P(4, 1),
+        P(4, 2),
+        P(6, 1),
+        P(6, 2),
+        P(8, 1),
+        P(8, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 1);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(0, 2));
+    assert(array[2] == P(2, 1));
+    assert(array[3] == P(2, 2));
+    assert(array[4] == P(4, 1));
+    assert(array[5] == P(4, 2));
+    assert(array[6] == P(6, 1));
+    assert(array[7] == P(6, 2));
+    assert(array[8] == P(8, 1));
+    assert(array[9] == P(8, 2));
+    }
+    {  // check all false but last true
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(0, 2),
+        P(2, 1),
+        P(2, 2),
+        P(4, 1),
+        P(4, 2),
+        P(6, 1),
+        P(6, 2),
+        P(8, 1),
+        P(1, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + 1);
+    assert(array[0] == P(1, 2));
+    assert(array[1] == P(0, 1));
+    assert(array[2] == P(0, 2));
+    assert(array[3] == P(2, 1));
+    assert(array[4] == P(2, 2));
+    assert(array[5] == P(4, 1));
+    assert(array[6] == P(4, 2));
+    assert(array[7] == P(6, 1));
+    assert(array[8] == P(6, 2));
+    assert(array[9] == P(8, 1));
+    }
+    {  // check all true but first false
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(0, 1),
+        P(1, 2),
+        P(3, 1),
+        P(3, 2),
+        P(5, 1),
+        P(5, 2),
+        P(7, 1),
+        P(7, 2),
+        P(9, 1),
+        P(9, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + size-1);
+    assert(array[0] == P(1, 2));
+    assert(array[1] == P(3, 1));
+    assert(array[2] == P(3, 2));
+    assert(array[3] == P(5, 1));
+    assert(array[4] == P(5, 2));
+    assert(array[5] == P(7, 1));
+    assert(array[6] == P(7, 2));
+    assert(array[7] == P(9, 1));
+    assert(array[8] == P(9, 2));
+    assert(array[9] == P(0, 1));
+    }
+    {  // check all true but last false
+    typedef std::pair<int,int> P;
+    P array[] =
+    {
+        P(1, 1),
+        P(1, 2),
+        P(3, 1),
+        P(3, 2),
+        P(5, 1),
+        P(5, 2),
+        P(7, 1),
+        P(7, 2),
+        P(9, 1),
+        P(0, 2)
+    };
+    const unsigned size = sizeof(array)/sizeof(array[0]);
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), odd_first());
+    assert(base(r) == array + size-1);
+    assert(array[0] == P(1, 1));
+    assert(array[1] == P(1, 2));
+    assert(array[2] == P(3, 1));
+    assert(array[3] == P(3, 2));
+    assert(array[4] == P(5, 1));
+    assert(array[5] == P(5, 2));
+    assert(array[6] == P(7, 1));
+    assert(array[7] == P(7, 2));
+    assert(array[8] == P(9, 1));
+    assert(array[9] == P(0, 2));
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct is_null
+{
+    template <class P>
+        bool operator()(const P& p) {return p == 0;}
+};
+
+template <class Iter>
+void
+test1()
+{
+    const unsigned size = 5;
+    std::unique_ptr<int> array[size];
+    Iter r = std::stable_partition(Iter(array), Iter(array+size), is_null());
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<bidirectional_iterator<std::pair<int,int>*> >();
+    test<random_access_iterator<std::pair<int,int>*> >();
+    test<std::pair<int,int>*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+#endif
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
new file mode 100644
index 0000000..a14ccf9
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter>
+//   void
+//   random_shuffle(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3, 4};
+    int ia1[] = {1, 4, 3, 2};
+    int ia2[] = {4, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::random_shuffle(ia, ia+sa);
+    assert(std::equal(ia, ia+sa, ia1));
+    std::random_shuffle(ia, ia+sa);
+    assert(std::equal(ia, ia+sa, ia2));
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
new file mode 100644
index 0000000..b944c89
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, Callable<auto, Iter::difference_type> Rand>
+//   requires ShuffleIterator<Iter>
+//         && Convertible<Rand::result_type, Iter::difference_type>
+//   void
+//   random_shuffle(Iter first, Iter last, Rand&& rand);
+
+#include <algorithm>
+#include <cassert>
+
+struct gen
+{
+    int operator()(int n)
+    {
+        return n-1;
+    }
+};
+
+int main()
+{
+    int ia[] = {1, 2, 3, 4};
+    int ia1[] = {4, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    gen r;
+    std::random_shuffle(ia, ia+sa, r);
+    assert(std::equal(ia, ia+sa, ia1));
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
new file mode 100644
index 0000000..343ae90
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_urng.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class RandomAccessIterator, class UniformRandomNumberGenerator>
+//     void shuffle(RandomAccessIterator first, RandomAccessIterator last,
+//                  UniformRandomNumberGenerator& g);
+
+#include <algorithm>
+#include <random>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+    int ia1[] = {2, 7, 1, 4, 3, 6, 5, 10, 9, 8};
+    int ia2[] = {1, 8, 3, 4, 6, 9, 5, 7, 2, 10};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::minstd_rand g;
+    std::shuffle(ia, ia+sa, g);
+    assert(std::equal(ia, ia+sa, ia1));
+    std::shuffle(ia, ia+sa, g);
+    assert(std::equal(ia, ia+sa, ia2));
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
new file mode 100644
index 0000000..80f8656
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.remove/remove.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
+//         && HasEqualTo<Iter::value_type, T>
+//   Iter
+//   remove(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::remove(Iter(ia), Iter(ia+sa), 2);
+    assert(base(r) == ia + sa-3);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 3);
+    assert(ia[3] == 4);
+    assert(ia[4] == 3);
+    assert(ia[5] == 4);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class Iter>
+void
+test1()
+{
+    const unsigned sa = 9;
+    std::unique_ptr<int> ia[sa];
+    ia[0].reset(new int(0));
+    ia[1].reset(new int(1));
+    ia[3].reset(new int(3));
+    ia[4].reset(new int(4));
+    ia[6].reset(new int(3));
+    ia[7].reset(new int(4));
+    Iter r = std::remove(Iter(ia), Iter(ia+sa), std::unique_ptr<int>());
+    assert(base(r) == ia + sa-3);
+    assert(*ia[0] == 0);
+    assert(*ia[1] == 1);
+    assert(*ia[2] == 3);
+    assert(*ia[3] == 4);
+    assert(*ia[4] == 3);
+    assert(*ia[5] == 4);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1<forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*>();
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
new file mode 100644
index 0000000..bf5f79c
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.remove/remove_copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter, class T>
+//   requires HasEqualTo<InIter::value_type, T>
+//   OutIter
+//   remove_copy(InIter first, InIter last, OutIter result, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa];
+    OutIter r = std::remove_copy(InIter(ia), InIter(ia+sa), OutIter(ib), 2);
+    assert(base(r) == ib + sa-3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 3);
+    assert(ib[3] == 4);
+    assert(ib[4] == 3);
+    assert(ib[5] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
new file mode 100644
index 0000000..de3f0a7
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, OutputIterator<auto, InIter::reference> OutIter,
+//          Predicate<auto, InIter::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   OutIter
+//   remove_copy_if(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa];
+    OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
+                                    std::bind2nd(std::equal_to<int>(), 2));
+    assert(base(r) == ib + sa-3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 3);
+    assert(ib[3] == 4);
+    assert(ib[4] == 3);
+    assert(ib[5] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp
new file mode 100644
index 0000000..6da3a67
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.remove/remove_if.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Predicate<auto, Iter::value_type> Pred>
+//   requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
+//         && CopyConstructible<Pred>
+//   Iter
+//   remove_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int* r = std::remove_if(ia, ia+sa, std::bind2nd(std::equal_to<int>(), 2));
+    assert(r == ia + sa-3);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 3);
+    assert(ia[3] == 4);
+    assert(ia[4] == 3);
+    assert(ia[5] == 4);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct pred
+{
+    bool operator()(const std::unique_ptr<int>& i) {return *i == 2;}
+};
+
+template <class Iter>
+void
+test1()
+{
+    const unsigned sa = 9;
+    std::unique_ptr<int> ia[sa];
+    ia[0].reset(new int(0));
+    ia[1].reset(new int(1));
+    ia[2].reset(new int(2));
+    ia[3].reset(new int(3));
+    ia[4].reset(new int(4));
+    ia[5].reset(new int(2));
+    ia[6].reset(new int(3));
+    ia[7].reset(new int(4));
+    ia[8].reset(new int(2));
+    Iter r = std::remove_if(Iter(ia), Iter(ia+sa), pred());
+    assert(base(r) == ia + sa-3);
+    assert(*ia[0] == 0);
+    assert(*ia[1] == 1);
+    assert(*ia[2] == 3);
+    assert(*ia[3] == 4);
+    assert(*ia[4] == 3);
+    assert(*ia[5] == 4);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1<forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*>();
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp
new file mode 100644
index 0000000..f603335
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.replace/replace.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires OutputIterator<Iter, Iter::reference>
+//         && OutputIterator<Iter, const T&>
+//         && HasEqualTo<Iter::value_type, T>
+//   void
+//   replace(Iter first, Iter last, const T& old_value, const T& new_value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::replace(Iter(ia), Iter(ia+sa), 2, 5);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 5);
+    assert(ia[3] == 3);
+    assert(ia[4] == 4);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp
new file mode 100644
index 0000000..3c4d0e5
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.replace/replace_copy.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter, class T>
+//   requires OutputIterator<OutIter, InIter::reference>
+//         && OutputIterator<OutIter, const T&>
+//         && HasEqualTo<InIter::value_type, T>
+//   OutIter
+//   replace_copy(InIter first, InIter last, OutIter result, const T& old_value,
+//                                                           const T& new_value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+    OutIter r = std::replace_copy(InIter(ia), InIter(ia+sa), OutIter(ib), 2, 5);
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 5);
+    assert(ib[3] == 3);
+    assert(ib[4] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
new file mode 100644
index 0000000..1eff3d3
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, typename OutIter,
+//          Predicate<auto, InIter::value_type> Pred, class T>
+//   requires OutputIterator<OutIter, InIter::reference>
+//         && OutputIterator<OutIter, const T&>
+//         && CopyConstructible<Pred>
+//   OutIter
+//   replace_copy_if(InIter first, InIter last, OutIter result, Pred pred, const T& new_value);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+    OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
+                                     std::bind2nd(std::equal_to<int>(), 2), 5);
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 5);
+    assert(ib[3] == 3);
+    assert(ib[4] == 4);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
new file mode 100644
index 0000000..8d6ab04
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, Predicate<auto, Iter::value_type> Pred, class T>
+//   requires OutputIterator<Iter, Iter::reference>
+//         && OutputIterator<Iter, const T&>
+//         && CopyConstructible<Pred>
+//   void
+//   replace_if(Iter first, Iter last, Pred pred, const T& new_value);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5);
+    assert(ia[0] == 0);
+    assert(ia[1] == 1);
+    assert(ia[2] == 5);
+    assert(ia[3] == 3);
+    assert(ia[4] == 4);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
new file mode 100644
index 0000000..6c49605
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.reverse/reverse.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+//   requires HasSwap<Iter::reference, Iter::reference>
+//   void
+//   reverse(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    std::reverse(Iter(ia), Iter(ia));
+    assert(ia[0] == 0);
+    std::reverse(Iter(ia), Iter(ia+sa));
+    assert(ia[0] == 0);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    std::reverse(Iter(ib), Iter(ib+sb));
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+
+    int ic[] = {0, 1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    std::reverse(Iter(ic), Iter(ic+sc));
+    assert(ic[0] == 2);
+    assert(ic[1] == 1);
+    assert(ic[2] == 0);
+
+    int id[] = {0, 1, 2, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    std::reverse(Iter(id), Iter(id+sd));
+    assert(id[0] == 3);
+    assert(id[1] == 2);
+    assert(id[2] == 1);
+    assert(id[3] == 0);
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
new file mode 100644
index 0000000..70840d1
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.reverse/reverse_copy.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+//   OutIter
+//   reverse_copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ja[sa] = {-1};
+    OutIter r = std::reverse_copy(InIter(ia), InIter(ia), OutIter(ja));
+    assert(base(r) == ja);
+    assert(ja[0] == -1);
+    r = std::reverse_copy(InIter(ia), InIter(ia+sa), OutIter(ja));
+    assert(ja[0] == 0);
+
+    const int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int jb[sb] = {-1};
+    r = std::reverse_copy(InIter(ib), InIter(ib+sb), OutIter(jb));
+    assert(base(r) == jb+sb);
+    assert(jb[0] == 1);
+    assert(jb[1] == 0);
+
+    const int ic[] = {0, 1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int jc[sc] = {-1};
+    r = std::reverse_copy(InIter(ic), InIter(ic+sc), OutIter(jc));
+    assert(base(r) == jc+sc);
+    assert(jc[0] == 2);
+    assert(jc[1] == 1);
+    assert(jc[2] == 0);
+
+    int id[] = {0, 1, 2, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    int jd[sd] = {-1};
+    r = std::reverse_copy(InIter(id), InIter(id+sd), OutIter(jd));
+    assert(base(r) == jd+sd);
+    assert(jd[0] == 3);
+    assert(jd[1] == 2);
+    assert(jd[2] == 1);
+    assert(jd[3] == 0);
+}
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
new file mode 100644
index 0000000..b7da735
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.rotate/rotate.pass.cpp
@@ -0,0 +1,439 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ShuffleIterator Iter>
+//   Iter
+//   rotate(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia));
+    assert(base(r) == ia);
+    assert(ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia+sa);
+    assert(ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia+sa), Iter(ia+sa));
+    assert(base(r) == ia);
+    assert(ia[0] == 0);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib+sb);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    r = std::rotate(Iter(ib), Iter(ib+1), Iter(ib+sb));
+    assert(base(r) == ib+1);
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+    r = std::rotate(Iter(ib), Iter(ib+sb), Iter(ib+sb));
+    assert(base(r) == ib);
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+
+    int ic[] = {0, 1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic+sc);
+    assert(ic[0] == 0);
+    assert(ic[1] == 1);
+    assert(ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+1), Iter(ic+sc));
+    assert(base(r) == ic+2);
+    assert(ic[0] == 1);
+    assert(ic[1] == 2);
+    assert(ic[2] == 0);
+    r = std::rotate(Iter(ic), Iter(ic+2), Iter(ic+sc));
+    assert(base(r) == ic+1);
+    assert(ic[0] == 0);
+    assert(ic[1] == 1);
+    assert(ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+sc), Iter(ic+sc));
+    assert(base(r) == ic);
+    assert(ic[0] == 0);
+    assert(ic[1] == 1);
+    assert(ic[2] == 2);
+
+    int id[] = {0, 1, 2, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    r = std::rotate(Iter(id), Iter(id), Iter(id+sd));
+    assert(base(r) == id+sd);
+    assert(id[0] == 0);
+    assert(id[1] == 1);
+    assert(id[2] == 2);
+    assert(id[3] == 3);
+    r = std::rotate(Iter(id), Iter(id+1), Iter(id+sd));
+    assert(base(r) == id+3);
+    assert(id[0] == 1);
+    assert(id[1] == 2);
+    assert(id[2] == 3);
+    assert(id[3] == 0);
+    r = std::rotate(Iter(id), Iter(id+2), Iter(id+sd));
+    assert(base(r) == id+2);
+    assert(id[0] == 3);
+    assert(id[1] == 0);
+    assert(id[2] == 1);
+    assert(id[3] == 2);
+    r = std::rotate(Iter(id), Iter(id+3), Iter(id+sd));
+    assert(base(r) == id+1);
+    assert(id[0] == 2);
+    assert(id[1] == 3);
+    assert(id[2] == 0);
+    assert(id[3] == 1);
+    r = std::rotate(Iter(id), Iter(id+sd), Iter(id+sd));
+    assert(base(r) == id);
+    assert(id[0] == 2);
+    assert(id[1] == 3);
+    assert(id[2] == 0);
+    assert(id[3] == 1);
+
+    int ie[] = {0, 1, 2, 3, 4};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se));
+    assert(base(r) == ie+se);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 2);
+    assert(ie[3] == 3);
+    assert(ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+1), Iter(ie+se));
+    assert(base(r) == ie+4);
+    assert(ie[0] == 1);
+    assert(ie[1] == 2);
+    assert(ie[2] == 3);
+    assert(ie[3] == 4);
+    assert(ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+2), Iter(ie+se));
+    assert(base(r) == ie+3);
+    assert(ie[0] == 3);
+    assert(ie[1] == 4);
+    assert(ie[2] == 0);
+    assert(ie[3] == 1);
+    assert(ie[4] == 2);
+    r = std::rotate(Iter(ie), Iter(ie+3), Iter(ie+se));
+    assert(base(r) == ie+2);
+    assert(ie[0] == 1);
+    assert(ie[1] == 2);
+    assert(ie[2] == 3);
+    assert(ie[3] == 4);
+    assert(ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+4), Iter(ie+se));
+    assert(base(r) == ie+1);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 2);
+    assert(ie[3] == 3);
+    assert(ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+se), Iter(ie+se));
+    assert(base(r) == ie);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 2);
+    assert(ie[3] == 3);
+    assert(ie[4] == 4);
+
+    int ig[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig+sg);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+    assert(ig[2] == 2);
+    assert(ig[3] == 3);
+    assert(ig[4] == 4);
+    assert(ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+1), Iter(ig+sg));
+    assert(base(r) == ig+5);
+    assert(ig[0] == 1);
+    assert(ig[1] == 2);
+    assert(ig[2] == 3);
+    assert(ig[3] == 4);
+    assert(ig[4] == 5);
+    assert(ig[5] == 0);
+    r = std::rotate(Iter(ig), Iter(ig+2), Iter(ig+sg));
+    assert(base(r) == ig+4);
+    assert(ig[0] == 3);
+    assert(ig[1] == 4);
+    assert(ig[2] == 5);
+    assert(ig[3] == 0);
+    assert(ig[4] == 1);
+    assert(ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+3), Iter(ig+sg));
+    assert(base(r) == ig+3);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+    assert(ig[2] == 2);
+    assert(ig[3] == 3);
+    assert(ig[4] == 4);
+    assert(ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+4), Iter(ig+sg));
+    assert(base(r) == ig+2);
+    assert(ig[0] == 4);
+    assert(ig[1] == 5);
+    assert(ig[2] == 0);
+    assert(ig[3] == 1);
+    assert(ig[4] == 2);
+    assert(ig[5] == 3);
+    r = std::rotate(Iter(ig), Iter(ig+5), Iter(ig+sg));
+    assert(base(r) == ig+1);
+    assert(ig[0] == 3);
+    assert(ig[1] == 4);
+    assert(ig[2] == 5);
+    assert(ig[3] == 0);
+    assert(ig[4] == 1);
+    assert(ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+sg), Iter(ig+sg));
+    assert(base(r) == ig);
+    assert(ig[0] == 3);
+    assert(ig[1] == 4);
+    assert(ig[2] == 5);
+    assert(ig[3] == 0);
+    assert(ig[4] == 1);
+    assert(ig[5] == 2);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class Iter>
+void
+test1()
+{
+    std::unique_ptr<int> ia[1];
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    for (int i = 0; i < sa; ++i)
+        ia[i].reset(new int(i));
+    Iter r = std::rotate(Iter(ia), Iter(ia), Iter(ia));
+    assert(base(r) == ia);
+    assert(*ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia+sa);
+    assert(*ia[0] == 0);
+    r = std::rotate(Iter(ia), Iter(ia+sa), Iter(ia+sa));
+    assert(base(r) == ia);
+    assert(*ia[0] == 0);
+
+    std::unique_ptr<int> ib[2];
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    for (int i = 0; i < sb; ++i)
+        ib[i].reset(new int(i));
+    r = std::rotate(Iter(ib), Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib+sb);
+    assert(*ib[0] == 0);
+    assert(*ib[1] == 1);
+    r = std::rotate(Iter(ib), Iter(ib+1), Iter(ib+sb));
+    assert(base(r) == ib+1);
+    assert(*ib[0] == 1);
+    assert(*ib[1] == 0);
+    r = std::rotate(Iter(ib), Iter(ib+sb), Iter(ib+sb));
+    assert(base(r) == ib);
+    assert(*ib[0] == 1);
+    assert(*ib[1] == 0);
+
+    std::unique_ptr<int> ic[3];
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    for (int i = 0; i < sc; ++i)
+        ic[i].reset(new int(i));
+    r = std::rotate(Iter(ic), Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic+sc);
+    assert(*ic[0] == 0);
+    assert(*ic[1] == 1);
+    assert(*ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+1), Iter(ic+sc));
+    assert(base(r) == ic+2);
+    assert(*ic[0] == 1);
+    assert(*ic[1] == 2);
+    assert(*ic[2] == 0);
+    r = std::rotate(Iter(ic), Iter(ic+2), Iter(ic+sc));
+    assert(base(r) == ic+1);
+    assert(*ic[0] == 0);
+    assert(*ic[1] == 1);
+    assert(*ic[2] == 2);
+    r = std::rotate(Iter(ic), Iter(ic+sc), Iter(ic+sc));
+    assert(base(r) == ic);
+    assert(*ic[0] == 0);
+    assert(*ic[1] == 1);
+    assert(*ic[2] == 2);
+
+    std::unique_ptr<int> id[4];
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    for (int i = 0; i < sd; ++i)
+        id[i].reset(new int(i));
+    r = std::rotate(Iter(id), Iter(id), Iter(id+sd));
+    assert(base(r) == id+sd);
+    assert(*id[0] == 0);
+    assert(*id[1] == 1);
+    assert(*id[2] == 2);
+    assert(*id[3] == 3);
+    r = std::rotate(Iter(id), Iter(id+1), Iter(id+sd));
+    assert(base(r) == id+3);
+    assert(*id[0] == 1);
+    assert(*id[1] == 2);
+    assert(*id[2] == 3);
+    assert(*id[3] == 0);
+    r = std::rotate(Iter(id), Iter(id+2), Iter(id+sd));
+    assert(base(r) == id+2);
+    assert(*id[0] == 3);
+    assert(*id[1] == 0);
+    assert(*id[2] == 1);
+    assert(*id[3] == 2);
+    r = std::rotate(Iter(id), Iter(id+3), Iter(id+sd));
+    assert(base(r) == id+1);
+    assert(*id[0] == 2);
+    assert(*id[1] == 3);
+    assert(*id[2] == 0);
+    assert(*id[3] == 1);
+    r = std::rotate(Iter(id), Iter(id+sd), Iter(id+sd));
+    assert(base(r) == id);
+    assert(*id[0] == 2);
+    assert(*id[1] == 3);
+    assert(*id[2] == 0);
+    assert(*id[3] == 1);
+
+    std::unique_ptr<int> ie[5];
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    for (int i = 0; i < se; ++i)
+        ie[i].reset(new int(i));
+    r = std::rotate(Iter(ie), Iter(ie), Iter(ie+se));
+    assert(base(r) == ie+se);
+    assert(*ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(*ie[2] == 2);
+    assert(*ie[3] == 3);
+    assert(*ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+1), Iter(ie+se));
+    assert(base(r) == ie+4);
+    assert(*ie[0] == 1);
+    assert(*ie[1] == 2);
+    assert(*ie[2] == 3);
+    assert(*ie[3] == 4);
+    assert(*ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+2), Iter(ie+se));
+    assert(base(r) == ie+3);
+    assert(*ie[0] == 3);
+    assert(*ie[1] == 4);
+    assert(*ie[2] == 0);
+    assert(*ie[3] == 1);
+    assert(*ie[4] == 2);
+    r = std::rotate(Iter(ie), Iter(ie+3), Iter(ie+se));
+    assert(base(r) == ie+2);
+    assert(*ie[0] == 1);
+    assert(*ie[1] == 2);
+    assert(*ie[2] == 3);
+    assert(*ie[3] == 4);
+    assert(*ie[4] == 0);
+    r = std::rotate(Iter(ie), Iter(ie+4), Iter(ie+se));
+    assert(base(r) == ie+1);
+    assert(*ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(*ie[2] == 2);
+    assert(*ie[3] == 3);
+    assert(*ie[4] == 4);
+    r = std::rotate(Iter(ie), Iter(ie+se), Iter(ie+se));
+    assert(base(r) == ie);
+    assert(*ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(*ie[2] == 2);
+    assert(*ie[3] == 3);
+    assert(*ie[4] == 4);
+
+    std::unique_ptr<int> ig[6];
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    for (int i = 0; i < sg; ++i)
+        ig[i].reset(new int(i));
+    r = std::rotate(Iter(ig), Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig+sg);
+    assert(*ig[0] == 0);
+    assert(*ig[1] == 1);
+    assert(*ig[2] == 2);
+    assert(*ig[3] == 3);
+    assert(*ig[4] == 4);
+    assert(*ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+1), Iter(ig+sg));
+    assert(base(r) == ig+5);
+    assert(*ig[0] == 1);
+    assert(*ig[1] == 2);
+    assert(*ig[2] == 3);
+    assert(*ig[3] == 4);
+    assert(*ig[4] == 5);
+    assert(*ig[5] == 0);
+    r = std::rotate(Iter(ig), Iter(ig+2), Iter(ig+sg));
+    assert(base(r) == ig+4);
+    assert(*ig[0] == 3);
+    assert(*ig[1] == 4);
+    assert(*ig[2] == 5);
+    assert(*ig[3] == 0);
+    assert(*ig[4] == 1);
+    assert(*ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+3), Iter(ig+sg));
+    assert(base(r) == ig+3);
+    assert(*ig[0] == 0);
+    assert(*ig[1] == 1);
+    assert(*ig[2] == 2);
+    assert(*ig[3] == 3);
+    assert(*ig[4] == 4);
+    assert(*ig[5] == 5);
+    r = std::rotate(Iter(ig), Iter(ig+4), Iter(ig+sg));
+    assert(base(r) == ig+2);
+    assert(*ig[0] == 4);
+    assert(*ig[1] == 5);
+    assert(*ig[2] == 0);
+    assert(*ig[3] == 1);
+    assert(*ig[4] == 2);
+    assert(*ig[5] == 3);
+    r = std::rotate(Iter(ig), Iter(ig+5), Iter(ig+sg));
+    assert(base(r) == ig+1);
+    assert(*ig[0] == 3);
+    assert(*ig[1] == 4);
+    assert(*ig[2] == 5);
+    assert(*ig[3] == 0);
+    assert(*ig[4] == 1);
+    assert(*ig[5] == 2);
+    r = std::rotate(Iter(ig), Iter(ig+sg), Iter(ig+sg));
+    assert(base(r) == ig);
+    assert(*ig[0] == 3);
+    assert(*ig[1] == 4);
+    assert(*ig[2] == 5);
+    assert(*ig[3] == 0);
+    assert(*ig[4] == 1);
+    assert(*ig[5] == 2);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1<forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*>();
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp
new file mode 100644
index 0000000..f2ad535
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.rotate/rotate_copy.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator InIter, OutputIterator<auto, InIter::reference> OutIter>
+//   OutIter
+//   rotate_copy(InIter first, InIter middle, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+
+    OutIter r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia), OutIter(ib));
+    assert(base(r) == ib);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+1), OutIter(ib));
+    assert(base(r) == ib+1);
+    assert(ib[0] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+1), OutIter(ib));
+    assert(base(r) == ib+1);
+    assert(ib[0] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+2), OutIter(ib));
+    assert(base(r) == ib+2);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+2), OutIter(ib));
+    assert(base(r) == ib+2);
+    assert(ib[0] == 1);
+    assert(ib[1] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+2), OutIter(ib));
+    assert(base(r) == ib+2);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 1);
+    assert(ib[1] == 2);
+    assert(ib[2] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 2);
+    assert(ib[1] == 0);
+    assert(ib[2] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+3), InIter(ia+3), OutIter(ib));
+    assert(base(r) == ib+3);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+    assert(ib[3] == 3);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+1), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 1);
+    assert(ib[1] == 2);
+    assert(ib[2] == 3);
+    assert(ib[3] == 0);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+2), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 2);
+    assert(ib[1] == 3);
+    assert(ib[2] == 0);
+    assert(ib[3] == 1);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+3), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 3);
+    assert(ib[1] == 0);
+    assert(ib[2] == 1);
+    assert(ib[3] == 2);
+
+    r = std::rotate_copy(InIter(ia), InIter(ia+4), InIter(ia+4), OutIter(ib));
+    assert(base(r) == ib+4);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(ib[2] == 2);
+    assert(ib[3] == 3);
+}
+
+int main()
+{
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp
new file mode 100644
index 0000000..d68efd9
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<Iterator Iter1, Iterator Iter2>
+//   requires HasSwap<Iter1::reference, Iter2::reference>
+//   void
+//   iter_swap(Iter1 a, Iter2 b);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+    int i = 1;
+    int j = 2;
+    std::iter_swap(&i, &j);
+    assert(i == 2);
+    assert(j == 1);
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp
new file mode 100644
index 0000000..24fc47e
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.swap/swap_ranges.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+//   requires HasSwap<Iter1::reference, Iter2::reference>
+//   Iter2
+//   swap_ranges(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template<class Iter1, class Iter2>
+void
+test()
+{
+    int i[3] = {1, 2, 3};
+    int j[3] = {4, 5, 6};
+    Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j));
+    assert(base(r) == j+3);
+    assert(i[0] == 4);
+    assert(i[1] == 5);
+    assert(i[2] == 6);
+    assert(j[0] == 1);
+    assert(j[1] == 2);
+    assert(j[2] == 3);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template<class Iter1, class Iter2>
+void
+test1()
+{
+    std::unique_ptr<int> i[3];
+    for (int k = 0; k < 3; ++k)
+        i[k].reset(new int(k+1));
+    std::unique_ptr<int> j[3];
+    for (int k = 0; k < 3; ++k)
+        j[k].reset(new int(k+4));
+    Iter2 r = std::swap_ranges(Iter1(i), Iter1(i+3), Iter2(j));
+    assert(base(r) == j+3);
+    assert(*i[0] == 4);
+    assert(*i[1] == 5);
+    assert(*i[2] == 6);
+    assert(*j[0] == 1);
+    assert(*j[1] == 2);
+    assert(*j[2] == 3);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<forward_iterator<int*>, forward_iterator<int*> >();
+    test<forward_iterator<int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<int*>, random_access_iterator<int*> >();
+    test<forward_iterator<int*>, int*>();
+
+    test<bidirectional_iterator<int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<int*>, int*>();
+
+    test<random_access_iterator<int*>, forward_iterator<int*> >();
+    test<random_access_iterator<int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<int*>, int*>();
+
+    test<int*, forward_iterator<int*> >();
+    test<int*, bidirectional_iterator<int*> >();
+    test<int*, random_access_iterator<int*> >();
+    test<int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1<forward_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<forward_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<bidirectional_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<random_access_iterator<std::unique_ptr<int>*>, forward_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<random_access_iterator<std::unique_ptr<int>*>, std::unique_ptr<int>*>();
+
+    test1<std::unique_ptr<int>*, forward_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, bidirectional_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, random_access_iterator<std::unique_ptr<int>*> >();
+    test1<std::unique_ptr<int>*, std::unique_ptr<int>*>();
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp
new file mode 100644
index 0000000..8491ea5
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.transform/binary_transform.pass.cpp
@@ -0,0 +1,217 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, class OutIter,
+//          Callable<auto, const InIter1::value_type&, const InIter2::value_type&> BinaryOp>
+//   requires OutputIterator<OutIter, BinaryOp::result_type> && CopyConstructible<BinaryOp>
+// OutIter
+// transform(InIter1 first1, InIter1 last1, InIter2 first2, OutIter result, BinaryOp binary_op);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template<class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {1, 2, 3, 4, 5};
+    OutIter r = std::transform(InIter1(ib), InIter1(ib+sa), InIter2(ia),
+                               OutIter(ib), std::minus<int>());
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 1);
+    assert(ib[1] == 1);
+    assert(ib[2] == 1);
+    assert(ib[3] == 1);
+    assert(ib[4] == 1);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, input_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, input_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
new file mode 100644
index 0000000..68556fd
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter,
+//          Callable<auto, const InIter::value_type&> Op>
+//   requires OutputIterator<OutIter, Op::result_type> && CopyConstructible<Op>
+//   OutIter
+//   transform(InIter first, InIter last, OutIter result, Op op);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[sa] = {0};
+    OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib),
+                               std::bind2nd(std::plus<int>(), 1));
+    assert(base(r) == ib + sa);
+    assert(ib[0] == 1);
+    assert(ib[1] == 2);
+    assert(ib[2] == 3);
+    assert(ib[3] == 4);
+    assert(ib[4] == 5);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, input_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp
new file mode 100644
index 0000000..ab4ffad
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.unique/unique.pass.cpp
@@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+//   requires OutputIterator<Iter, Iter::reference>
+//         && EqualityComparable<Iter::value_type>
+//   Iter
+//   unique(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::unique(Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    r = std::unique(Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+
+    int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    r = std::unique(Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+
+    int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    r = std::unique(Iter(id), Iter(id+sd));
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(id[1] == 1);
+
+    int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    r = std::unique(Iter(ie), Iter(ie+se));
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 0);
+
+    int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    r = std::unique(Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+
+    int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    r = std::unique(Iter(ih), Iter(ih+sh));
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(ih[1] == 1);
+
+    int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    r = std::unique(Iter(ii), Iter(ii+si));
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(ii[1] == 1);
+    assert(ii[2] == 2);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+typedef std::unique_ptr<int, do_nothing> Ptr;
+
+template <class Iter>
+void
+test1()
+{
+    int one = 1;
+    int two = 2;
+    Ptr ia[1];
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    Iter r = std::unique(Iter(ia), Iter(ia+sa));
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+
+    Ptr ib[2];
+    ib[1].reset(&one);
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    r = std::unique(Iter(ib), Iter(ib+sb));
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(*ib[1] == 1);
+
+    Ptr ic[2];
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    r = std::unique(Iter(ic), Iter(ic+sc));
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+
+    Ptr id[3];
+    id[2].reset(&one);
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    r = std::unique(Iter(id), Iter(id+sd));
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(*id[1] == 1);
+
+    Ptr ie[4];
+    ie[2].reset(&one);
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    r = std::unique(Iter(ie), Iter(ie+se));
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(ie[2] == 0);
+
+    Ptr ig[4];
+    ig[2].reset(&one);
+    ig[3].reset(&one);
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    r = std::unique(Iter(ig), Iter(ig+sg));
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(*ig[1] == 1);
+
+    Ptr ih[3];
+    ih[1].reset(&one);
+    ih[2].reset(&one);
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    r = std::unique(Iter(ih), Iter(ih+sh));
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(*ih[1] == 1);
+
+    Ptr ii[7];
+    ii[1].reset(&one);
+    ii[2].reset(&one);
+    ii[3].reset(&one);
+    ii[4].reset(&two);
+    ii[5].reset(&two);
+    ii[6].reset(&two);
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    r = std::unique(Iter(ii), Iter(ii+si));
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(*ii[1] == 1);
+    assert(*ii[2] == 2);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1<forward_iterator<Ptr*> >();
+    test1<bidirectional_iterator<Ptr*> >();
+    test1<random_access_iterator<Ptr*> >();
+    test1<Ptr*>();
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp
new file mode 100644
index 0000000..761dad4
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.unique/unique_copy.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter>
+//   requires OutputIterator<OutIter, RvalueOf<InIter::value_type>::type>
+//         && EqualityComparable<InIter::value_type>
+//         && HasAssign<InIter::value_type, InIter::reference>
+//         && Constructible<InIter::value_type, InIter::reference>
+//   OutIter
+//   unique_copy(InIter first, InIter last, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ja[sa] = {-1};
+    OutIter r = std::unique_copy(InIter(ia), InIter(ia+sa), OutIter(ja));
+    assert(base(r) == ja + sa);
+    assert(ja[0] == 0);
+
+    const int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int jb[sb] = {-1};
+    r = std::unique_copy(InIter(ib), InIter(ib+sb), OutIter(jb));
+    assert(base(r) == jb + sb);
+    assert(jb[0] == 0);
+    assert(jb[1] == 1);
+
+    const int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int jc[sc] = {-1};
+    r = std::unique_copy(InIter(ic), InIter(ic+sc), OutIter(jc));
+    assert(base(r) == jc + 1);
+    assert(jc[0] == 0);
+
+    const int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    int jd[sd] = {-1};
+    r = std::unique_copy(InIter(id), InIter(id+sd), OutIter(jd));
+    assert(base(r) == jd + 2);
+    assert(jd[0] == 0);
+    assert(jd[1] == 1);
+
+    const int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    int je[se] = {-1};
+    r = std::unique_copy(InIter(ie), InIter(ie+se), OutIter(je));
+    assert(base(r) == je + 3);
+    assert(je[0] == 0);
+    assert(je[1] == 1);
+    assert(je[2] == 0);
+
+    const int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    int jg[sg] = {-1};
+    r = std::unique_copy(InIter(ig), InIter(ig+sg), OutIter(jg));
+    assert(base(r) == jg + 2);
+    assert(jg[0] == 0);
+    assert(jg[1] == 1);
+
+    const int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int jh[sh] = {-1};
+    r = std::unique_copy(InIter(ih), InIter(ih+sh), OutIter(jh));
+    assert(base(r) == jh + 2);
+    assert(jh[0] == 0);
+    assert(jh[1] == 1);
+
+    const int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    int ji[si] = {-1};
+    r = std::unique_copy(InIter(ii), InIter(ii+si), OutIter(ji));
+    assert(base(r) == ji + 3);
+    assert(ji[0] == 0);
+    assert(ji[1] == 1);
+    assert(ji[2] == 2);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp
new file mode 100644
index 0000000..6819899
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.unique/unique_copy_pred.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, class OutIter,
+//          EquivalenceRelation<auto, InIter::value_type> Pred>
+//   requires OutputIterator<OutIter, RvalueOf<InIter::value_type>::type>
+//         && HasAssign<InIter::value_type, InIter::reference>
+//         && Constructible<InIter::value_type, InIter::reference>
+//         && CopyConstructible<Pred>
+//   OutIter
+//   unique_copy(InIter first, InIter last, OutIter result, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    const int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ja[sa] = {-1};
+    count_equal::count = 0;
+    OutIter r = std::unique_copy(InIter(ia), InIter(ia+sa), OutIter(ja), count_equal());
+    assert(base(r) == ja + sa);
+    assert(ja[0] == 0);
+    assert(count_equal::count == sa-1);
+
+    const int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int jb[sb] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ib), InIter(ib+sb), OutIter(jb), count_equal());
+    assert(base(r) == jb + sb);
+    assert(jb[0] == 0);
+    assert(jb[1] == 1);
+    assert(count_equal::count == sb-1);
+
+    const int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int jc[sc] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ic), InIter(ic+sc), OutIter(jc), count_equal());
+    assert(base(r) == jc + 1);
+    assert(jc[0] == 0);
+    assert(count_equal::count == sc-1);
+
+    const int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    int jd[sd] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(id), InIter(id+sd), OutIter(jd), count_equal());
+    assert(base(r) == jd + 2);
+    assert(jd[0] == 0);
+    assert(jd[1] == 1);
+    assert(count_equal::count == sd-1);
+
+    const int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    int je[se] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ie), InIter(ie+se), OutIter(je), count_equal());
+    assert(base(r) == je + 3);
+    assert(je[0] == 0);
+    assert(je[1] == 1);
+    assert(je[2] == 0);
+    assert(count_equal::count == se-1);
+
+    const int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    int jg[sg] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ig), InIter(ig+sg), OutIter(jg), count_equal());
+    assert(base(r) == jg + 2);
+    assert(jg[0] == 0);
+    assert(jg[1] == 1);
+    assert(count_equal::count == sg-1);
+
+    const int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int jh[sh] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ih), InIter(ih+sh), OutIter(jh), count_equal());
+    assert(base(r) == jh + 2);
+    assert(jh[0] == 0);
+    assert(jh[1] == 1);
+    assert(count_equal::count == sh-1);
+
+    const int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    int ji[si] = {-1};
+    count_equal::count = 0;
+    r = std::unique_copy(InIter(ii), InIter(ii+si), OutIter(ji), count_equal());
+    assert(base(r) == ji + 3);
+    assert(ji[0] == 0);
+    assert(ji[1] == 1);
+    assert(ji[2] == 2);
+    assert(count_equal::count == si-1);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp b/final/test/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp
new file mode 100644
index 0000000..c6df235
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/alg.unique/unique_pred.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred>
+//   requires OutputIterator<Iter, RvalueOf<Iter::reference>::type>
+//         && CopyConstructible<Pred>
+//   Iter
+//   unique(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    count_equal::count = 0;
+    Iter r = std::unique(Iter(ia), Iter(ia+sa), count_equal());
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+    assert(count_equal::count == sa-1);
+
+    int ib[] = {0, 1};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ib), Iter(ib+sb), count_equal());
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(ib[1] == 1);
+    assert(count_equal::count == sb-1);
+
+    int ic[] = {0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ic), Iter(ic+sc), count_equal());
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+    assert(count_equal::count == sc-1);
+
+    int id[] = {0, 0, 1};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(id), Iter(id+sd), count_equal());
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(id[1] == 1);
+    assert(count_equal::count == sd-1);
+
+    int ie[] = {0, 0, 1, 0};
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ie), Iter(ie+se), count_equal());
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(ie[1] == 1);
+    assert(ie[2] == 0);
+    assert(count_equal::count == se-1);
+
+    int ig[] = {0, 0, 1, 1};
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ig), Iter(ig+sg), count_equal());
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(ig[1] == 1);
+    assert(count_equal::count == sg-1);
+
+    int ih[] = {0, 1, 1};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ih), Iter(ih+sh), count_equal());
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(ih[1] == 1);
+    assert(count_equal::count == sh-1);
+
+    int ii[] = {0, 1, 1, 1, 2, 2, 2};
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ii), Iter(ii+si), count_equal());
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(ii[1] == 1);
+    assert(ii[2] == 2);
+    assert(count_equal::count == si-1);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+typedef std::unique_ptr<int, do_nothing> Ptr;
+
+template <class Iter>
+void
+test1()
+{
+    int one = 1;
+    int two = 2;
+    Ptr ia[1];
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    count_equal::count = 0;
+    Iter r = std::unique(Iter(ia), Iter(ia+sa), count_equal());
+    assert(base(r) == ia + sa);
+    assert(ia[0] == 0);
+    assert(count_equal::count == sa-1);
+
+    Ptr ib[2];
+    ib[1].reset(&one);
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ib), Iter(ib+sb), count_equal());
+    assert(base(r) == ib + sb);
+    assert(ib[0] == 0);
+    assert(*ib[1] == 1);
+    assert(count_equal::count == sb-1);
+
+    Ptr ic[2];
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ic), Iter(ic+sc), count_equal());
+    assert(base(r) == ic + 1);
+    assert(ic[0] == 0);
+    assert(count_equal::count == sc-1);
+
+    Ptr id[3];
+    id[2].reset(&one);
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(id), Iter(id+sd), count_equal());
+    assert(base(r) == id + 2);
+    assert(id[0] == 0);
+    assert(*id[1] == 1);
+    assert(count_equal::count == sd-1);
+
+    Ptr ie[4];
+    ie[2].reset(&one);
+    const unsigned se = sizeof(ie)/sizeof(ie[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ie), Iter(ie+se), count_equal());
+    assert(base(r) == ie + 3);
+    assert(ie[0] == 0);
+    assert(*ie[1] == 1);
+    assert(ie[2] == 0);
+    assert(count_equal::count == se-1);
+
+    Ptr ig[4];
+    ig[2].reset(&one);
+    ig[3].reset(&one);
+    const unsigned sg = sizeof(ig)/sizeof(ig[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ig), Iter(ig+sg), count_equal());
+    assert(base(r) == ig + 2);
+    assert(ig[0] == 0);
+    assert(*ig[1] == 1);
+    assert(count_equal::count == sg-1);
+
+    Ptr ih[3];
+    ih[1].reset(&one);
+    ih[2].reset(&one);
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ih), Iter(ih+sh), count_equal());
+    assert(base(r) == ih + 2);
+    assert(ih[0] == 0);
+    assert(*ih[1] == 1);
+    assert(count_equal::count == sh-1);
+
+    Ptr ii[7];
+    ii[1].reset(&one);
+    ii[2].reset(&one);
+    ii[3].reset(&one);
+    ii[4].reset(&two);
+    ii[5].reset(&two);
+    ii[6].reset(&two);
+    const unsigned si = sizeof(ii)/sizeof(ii[0]);
+    count_equal::count = 0;
+    r = std::unique(Iter(ii), Iter(ii+si), count_equal());
+    assert(base(r) == ii + 3);
+    assert(ii[0] == 0);
+    assert(*ii[1] == 1);
+    assert(*ii[2] == 2);
+    assert(count_equal::count == si-1);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1<forward_iterator<Ptr*> >();
+    test1<bidirectional_iterator<Ptr*> >();
+    test1<random_access_iterator<Ptr*> >();
+    test1<Ptr*>();
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp b/final/test/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.modifying.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
new file mode 100644
index 0000000..ee03092
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+//   requires EqualityComparable<Iter::value_type>
+//   Iter
+//   adjacent_find(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia + sa)) ==
+                              forward_iterator<const int*>(ia+2));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia)) ==
+                              forward_iterator<const int*>(ia));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
+                              forward_iterator<const int*>(ia + sa)) ==
+                              forward_iterator<const int*>(ia+sa));
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp
new file mode 100644
index 0000000..4d172ff
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.adjacent.find/adjacent_find_pred.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, EquivalenceRelation<auto, Iter::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   Iter
+//   adjacent_find(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia + sa),
+                              std::equal_to<int>()) ==
+                              forward_iterator<const int*>(ia+2));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ia),
+                              std::equal_to<int>()) ==
+                              forward_iterator<const int*>(ia));
+    assert(std::adjacent_find(forward_iterator<const int*>(ia+3),
+                              forward_iterator<const int*>(ia + sa),
+                              std::equal_to<int>()) ==
+                              forward_iterator<const int*>(ia+sa));
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
new file mode 100644
index 0000000..c3c3480
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.all_of/all_of.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//   bool
+//   all_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct test1
+{
+    bool operator()(const int& i) const
+    {
+        return i % 2 == 0;
+    }
+};
+
+int main()
+{
+    {
+        int ia[] = {2, 4, 6, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == true);
+    }
+    {
+        const int ia[] = {2, 4, 5, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::all_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == true);
+    }
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
new file mode 100644
index 0000000..d096e20
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.any_of/any_of.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//   bool
+//   any_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct test1
+{
+    bool operator()(const int& i) const
+    {
+        return i % 2 == 0;
+    }
+};
+
+int main()
+{
+    {
+        int ia[] = {2, 4, 6, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == false);
+    }
+    {
+        const int ia[] = {2, 4, 5, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == false);
+    }
+    {
+        const int ia[] = {1, 3, 5, 7};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::any_of(input_iterator<const int*>(ia),
+                           input_iterator<const int*>(ia), test1()) == false);
+    }
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp
new file mode 100644
index 0000000..260e5ed
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.count/count.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, class T>
+//   requires HasEqualTo<Iter::value_type, T>
+//   Iter::difference_type
+//   count(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::count(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia + sa), 2) == 3);
+    assert(std::count(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia + sa), 7) == 0);
+    assert(std::count(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia), 2) == 0);
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
new file mode 100644
index 0000000..025bc06
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   Iter::difference_type
+//   count_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::count_if(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         std::bind2nd(std::equal_to<int>(),2)) == 3);
+    assert(std::count_if(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         std::bind2nd(std::equal_to<int>(),7)) == 0);
+    assert(std::count_if(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia),
+                         std::bind2nd(std::equal_to<int>(),2)) == 0);
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
new file mode 100644
index 0000000..2348791
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.equal/equal.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+//   bool
+//   equal(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    int ib[s] = {0, 1, 2, 5, 4, 5};
+    assert(std::equal(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      input_iterator<const int*>(ia)));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+    assert(std::equal(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s)));
+    assert(std::equal(random_access_iterator<const int*>(ia),
+                      random_access_iterator<const int*>(ia+s),
+                      random_access_iterator<const int*>(ia),
+                      random_access_iterator<const int*>(ia+s)));
+#endif
+    assert(!std::equal(input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s),
+                       input_iterator<const int*>(ib)));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+    assert(!std::equal(input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s),
+                       input_iterator<const int*>(ib),
+                       input_iterator<const int*>(ib+s)));
+    assert(!std::equal(random_access_iterator<const int*>(ia),
+                       random_access_iterator<const int*>(ia+s),
+                       random_access_iterator<const int*>(ib),
+                       random_access_iterator<const int*>(ib+s)));
+    assert(!std::equal(input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s),
+                       input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s-1)));
+    assert(!std::equal(random_access_iterator<const int*>(ia),
+                       random_access_iterator<const int*>(ia+s),
+                       random_access_iterator<const int*>(ia),
+                       random_access_iterator<const int*>(ia+s-1)));
+    
+#endif
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp
new file mode 100644
index 0000000..047f720
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.equal/equal_pred.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2,
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   bool
+//   equal(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int comparison_count = 0;
+template <typename T>
+bool counting_equals ( const T &a, const T &b ) {
+    ++comparison_count;
+    return a == b;
+}
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    int ib[s] = {0, 1, 2, 5, 4, 5};
+    assert(std::equal(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      input_iterator<const int*>(ia),
+                      std::equal_to<int>()));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+    assert(std::equal(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      std::equal_to<int>()));
+    assert(std::equal(random_access_iterator<const int*>(ia),
+                      random_access_iterator<const int*>(ia+s),
+                      random_access_iterator<const int*>(ia),
+                      random_access_iterator<const int*>(ia+s),
+                      std::equal_to<int>()));
+
+    comparison_count = 0;
+    assert(!std::equal(input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s),
+                      input_iterator<const int*>(ia),
+                      input_iterator<const int*>(ia+s-1),
+                      counting_equals<int>));
+    assert(comparison_count > 0);
+    comparison_count = 0;
+    assert(!std::equal(random_access_iterator<const int*>(ia),
+                      random_access_iterator<const int*>(ia+s),
+                      random_access_iterator<const int*>(ia),
+                      random_access_iterator<const int*>(ia+s-1),
+                      counting_equals<int>));
+    assert(comparison_count == 0);
+#endif
+    assert(!std::equal(input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s),
+                       input_iterator<const int*>(ib),
+                       std::equal_to<int>()));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+    assert(!std::equal(input_iterator<const int*>(ia),
+                       input_iterator<const int*>(ia+s),
+                       input_iterator<const int*>(ib),
+                       input_iterator<const int*>(ib+s),
+                       std::equal_to<int>()));
+    assert(!std::equal(random_access_iterator<const int*>(ia),
+                       random_access_iterator<const int*>(ia+s),
+                       random_access_iterator<const int*>(ib),
+                       random_access_iterator<const int*>(ib+s),
+                       std::equal_to<int>()));
+#endif
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp
new file mode 100644
index 0000000..e95162b
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.find.end/find_end.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+//   Iter1
+//   find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int b[] = {0};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1)) == Iter1(ia+sa-1));
+    int c[] = {0, 1};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2)) == Iter1(ia+18));
+    int d[] = {0, 1, 2};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3)) == Iter1(ia+15));
+    int e[] = {0, 1, 2, 3};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4)) == Iter1(ia+11));
+    int f[] = {0, 1, 2, 3, 4};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5)) == Iter1(ia+6));
+    int g[] = {0, 1, 2, 3, 4, 5};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6)) == Iter1(ia));
+    int h[] = {0, 1, 2, 3, 4, 5, 6};
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7)) == Iter1(ia+sa));
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b)) == Iter1(ia+sa));
+    assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1)) == Iter1(ia));
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp
new file mode 100644
index 0000000..411858d
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.find.end/find_end_pred.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2,
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   Iter1
+//   find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1, 0};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int b[] = {0};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia+sa-1));
+    assert(count_equal::count <= 1*(sa-1+1));
+    int c[] = {0, 1};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(c), Iter2(c+2), count_equal()) == Iter1(ia+18));
+    assert(count_equal::count <= 2*(sa-2+1));
+    int d[] = {0, 1, 2};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(d), Iter2(d+3), count_equal()) == Iter1(ia+15));
+    assert(count_equal::count <= 3*(sa-3+1));
+    int e[] = {0, 1, 2, 3};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(e), Iter2(e+4), count_equal()) == Iter1(ia+11));
+    assert(count_equal::count <= 4*(sa-4+1));
+    int f[] = {0, 1, 2, 3, 4};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(f), Iter2(f+5), count_equal()) == Iter1(ia+6));
+    assert(count_equal::count <= 5*(sa-5+1));
+    int g[] = {0, 1, 2, 3, 4, 5};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(g), Iter2(g+6), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 6*(sa-6+1));
+    int h[] = {0, 1, 2, 3, 4, 5, 6};
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(h), Iter2(h+7), count_equal()) == Iter1(ia+sa));
+    assert(count_equal::count <= 7*(sa-7+1));
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia+sa), Iter2(b), Iter2(b), count_equal()) == Iter1(ia+sa));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::find_end(Iter1(ia), Iter1(ia), Iter2(b), Iter2(b+1), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp
new file mode 100644
index 0000000..9662076
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, ForwardIterator Iter2>
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+//   Iter1
+//   find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 3, 5, 7};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ib),
+                              forward_iterator<const int*>(ib + sb)) ==
+                              input_iterator<const int*>(ia+1));
+    int ic[] = {7};
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic + 1)) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic)) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic+1)) ==
+                              input_iterator<const int*>(ia));
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
new file mode 100644
index 0000000..d1d954c
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.find.first.of/find_first_of_pred.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, ForwardIterator Iter2,
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   Iter1
+//   find_first_of(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 3, 5, 7};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ib),
+                              forward_iterator<const int*>(ib + sb),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia+1));
+    int ic[] = {7};
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic + 1),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia + sa),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia+sa));
+    assert(std::find_first_of(input_iterator<const int*>(ia),
+                              input_iterator<const int*>(ia),
+                              forward_iterator<const int*>(ic),
+                              forward_iterator<const int*>(ic+1),
+                              std::equal_to<int>()) ==
+                              input_iterator<const int*>(ia));
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.find/find.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
new file mode 100644
index 0000000..09f0f41
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.find/find.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, class T>
+//   requires HasEqualTo<Iter::value_type, T>
+//   Iter
+//   find(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    input_iterator<const int*> r = std::find(input_iterator<const int*>(ia),
+                                             input_iterator<const int*>(ia+s), 3);
+    assert(*r == 3);
+    r = std::find(input_iterator<const int*>(ia), input_iterator<const int*>(ia+s), 10);
+    assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
new file mode 100644
index 0000000..bde6ff3
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   Iter
+//   find_if(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia),
+                                                input_iterator<const int*>(ia+s),
+                                                std::bind2nd(std::equal_to<int>(), 3));
+    assert(*r == 3);
+    r = std::find_if(input_iterator<const int*>(ia),
+                     input_iterator<const int*>(ia+s),
+                     std::bind2nd(std::equal_to<int>(), 10));
+    assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
new file mode 100644
index 0000000..661e643
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Predicate<auto, Iter::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   Iter
+//   find_if_not(Iter first, Iter last, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia),
+                                                    input_iterator<const int*>(ia+s),
+                                                    std::bind2nd(std::not_equal_to<int>(), 3));
+    assert(*r == 3);
+    r = std::find_if_not(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia+s),
+                         std::bind2nd(std::not_equal_to<int>(), 10));
+    assert(r == input_iterator<const int*>(ia+s));
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
new file mode 100644
index 0000000..bf80c2c
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.foreach/test.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter, Callable<auto, Iter::reference> Function>
+//   requires CopyConstructible<Function>
+//   Function
+//   for_each(Iter first, Iter last, Function f);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct for_each_test
+{
+    for_each_test(int c) : count(c) {}
+    int count;
+    void operator()(int& i) {++i; ++count;}
+};
+
+int main()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned s = sizeof(ia)/sizeof(ia[0]);
+    for_each_test f = std::for_each(input_iterator<int*>(ia),
+                                    input_iterator<int*>(ia+s),
+                                    for_each_test(0));
+    assert(f.count == s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ia[i] == i+1);
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
new file mode 100644
index 0000000..028aec5
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation.pass.cpp
@@ -0,0 +1,605 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator1, class ForwardIterator2>
+//   bool
+//   is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+//                  ForwardIterator2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int main()
+{
+    {
+        const int ia[] = {0};
+        const int ib[] = {0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + 0),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + 0),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + 0)) == true);
+#endif
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0};
+        const int ib[] = {1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+#endif
+    }
+
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib + 1),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib + 1 ),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1)) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib)) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa)) == false);
+#endif
+    }
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
new file mode 100644
index 0000000..ceb897d
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.is_permutation/is_permutation_pred.pass.cpp
@@ -0,0 +1,729 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
+//   bool
+//   is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
+//                  ForwardIterator2 first2, BinaryPredicate pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int comparison_count = 0;
+template <typename T>
+bool counting_equals ( const T &a, const T &b ) {
+    ++comparison_count;
+    return a == b;
+    }
+
+
+int main()
+{
+    {
+        const int ia[] = {0};
+        const int ib[] = {0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + 0),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0};
+        const int ib[] = {1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 0};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {1, 1};
+        const int ib[] = {1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 1, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 0};
+        const int ib[] = {1, 2, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 0, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {1, 2, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 1, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2};
+        const int ib[] = {2, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 1};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 0, 1};
+        const int ib[] = {1, 0, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib + 1),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 2};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == true);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == true);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib + 1),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   std::equal_to<const int>()) == false);
+        comparison_count = 0;
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa - 1),
+                                   counting_equals<const int>) == false);
+        assert ( comparison_count > 0 );
+        comparison_count = 0;
+        assert(std::is_permutation(random_access_iterator<const int*>(ia),
+                                   random_access_iterator<const int*>(ia + sa),
+                                   random_access_iterator<const int*>(ib),
+                                   random_access_iterator<const int*>(ib + sa - 1),
+                                   counting_equals<const int>) == false);
+        assert ( comparison_count == 0 );
+#endif
+    }
+    {
+        const int ia[] = {0, 1, 2, 3, 0, 5, 6, 2, 4, 4};
+        const int ib[] = {4, 2, 3, 0, 1, 4, 0, 5, 6, 0};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   std::equal_to<const int>()) == false);
+#ifdef HAS_FOUR_ITERATOR_VERSION
+        assert(std::is_permutation(forward_iterator<const int*>(ia),
+                                   forward_iterator<const int*>(ia + sa),
+                                   forward_iterator<const int*>(ib),
+                                   forward_iterator<const int*>(ib + sa),
+                                   std::equal_to<const int>()) == false);
+#endif
+    }
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp
new file mode 100644
index 0000000..f4ea161
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.none_of/none_of.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class InputIterator, class Predicate>
+//   bool
+//   none_of(InputIterator first, InputIterator last, Predicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct test1
+{
+    bool operator()(const int& i) const
+    {
+        return i % 2 == 0;
+    }
+};
+
+int main()
+{
+    {
+        int ia[] = {2, 4, 6, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia), test1()) == true);
+    }
+    {
+        const int ia[] = {2, 4, 5, 8};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia + sa), test1()) == false);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia), test1()) == true);
+    }
+    {
+        const int ia[] = {1, 3, 5, 7};
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia + sa), test1()) == true);
+        assert(std::none_of(input_iterator<const int*>(ia),
+                            input_iterator<const int*>(ia), test1()) == true);
+    }
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.search/search.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.search/search.pass.cpp
new file mode 100644
index 0000000..e5c2dd2
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.search/search.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+//   Iter1
+//   search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2)) == Iter1(ia+1));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia+2));
+    assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa)) == Iter1(ia+sa-1));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa)) == Iter1(ia+sa-3));
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)) == Iter1(ia));
+    assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+sa-1));
+    assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+1));
+    int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1)) == Iter1(ib+1));
+    int id[] = {1, 2};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2)) == Iter1(ib+1));
+    int ie[] = {1, 2, 3};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3)) == Iter1(ib+4));
+    int ig[] = {1, 2, 3, 4};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4)) == Iter1(ib+8));
+    int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int ii[] = {1, 1, 2};
+    assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3)) == Iter1(ih+3));
+    int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
+    const unsigned sj = sizeof(ij)/sizeof(ij[0]);
+    int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0};
+    const unsigned sk = sizeof(ik)/sizeof(ik[0]);
+    assert(std::search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk)) == Iter1(ij+6));
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp
new file mode 100644
index 0000000..b834da2
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.search/search_n.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator, class Size, class T>
+//   ForwardIterator
+//   search_n(ForwardIterator first, ForwardIterator last, Size count,
+//            const T& value);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 0) == Iter(ia));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 0) == Iter(ia+0));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 0) == Iter(ia+sa));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 0) == Iter(ia+sa));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 3) == Iter(ia));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 3) == Iter(ia+3));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 3) == Iter(ia+sa));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 3) == Iter(ia+sa));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 5) == Iter(ia));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 5) == Iter(ia+5));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 5) == Iter(ia+sa));
+    assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 5) == Iter(ia+sa));
+
+    int ib[] = {0, 0, 1, 1, 2, 2};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 0) == Iter(ib));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 0) == Iter(ib+0));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 0) == Iter(ib+0));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 0) == Iter(ib+sb));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 0) == Iter(ib+sb));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 1) == Iter(ib));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 1) == Iter(ib+2));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 1) == Iter(ib+2));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 1) == Iter(ib+sb));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 1) == Iter(ib+sb));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 2) == Iter(ib));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 2) == Iter(ib+4));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 2) == Iter(ib+4));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 2) == Iter(ib+sb));
+    assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 2) == Iter(ib+sb));
+
+    int ic[] = {0, 0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 0, 0) == Iter(ic));
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 1, 0) == Iter(ic));
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 2, 0) == Iter(ic));
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 3, 0) == Iter(ic));
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 4, 0) == Iter(ic+sc));
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp
new file mode 100644
index 0000000..6004b0e
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class ForwardIterator, class Size, class T, class BinaryPredicate>
+//   ForwardIterator
+//   search_n(ForwardIterator first, ForwardIterator last, Size count,
+//            const T& value, BinaryPredicate pred);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 0, count_equal()) == Iter(ia));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 0, count_equal()) == Iter(ia+0));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 0, count_equal()) == Iter(ia+sa));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 0, count_equal()) == Iter(ia+sa));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 3, count_equal()) == Iter(ia));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 3, count_equal()) == Iter(ia+3));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 3, count_equal()) == Iter(ia+sa));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 3, count_equal()) == Iter(ia+sa));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 0, 5, count_equal()) == Iter(ia));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 1, 5, count_equal()) == Iter(ia+5));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), 2, 5, count_equal()) == Iter(ia+sa));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ia), Iter(ia+sa), sa, 5, count_equal()) == Iter(ia+sa));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+
+    int ib[] = {0, 0, 1, 1, 2, 2};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 0, count_equal()) == Iter(ib));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 0, count_equal()) == Iter(ib+0));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 0, count_equal()) == Iter(ib+0));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 0, count_equal()) == Iter(ib+sb));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 0, count_equal()) == Iter(ib+sb));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 1, count_equal()) == Iter(ib));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 1, count_equal()) == Iter(ib+2));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 1, count_equal()) == Iter(ib+2));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 1, count_equal()) == Iter(ib+sb));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 1, count_equal()) == Iter(ib+sb));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 0, 2, count_equal()) == Iter(ib));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 1, 2, count_equal()) == Iter(ib+4));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 2, 2, count_equal()) == Iter(ib+4));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), 3, 2, count_equal()) == Iter(ib+sb));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ib), Iter(ib+sb), sb, 2, count_equal()) == Iter(ib+sb));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+
+    int ic[] = {0, 0, 0};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 0, 0, count_equal()) == Iter(ic));
+    assert(count_equal::count <= sc);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 1, 0, count_equal()) == Iter(ic));
+    assert(count_equal::count <= sc);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 2, 0, count_equal()) == Iter(ic));
+    assert(count_equal::count <= sc);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 3, 0, count_equal()) == Iter(ic));
+    assert(count_equal::count <= sc);
+    count_equal::count = 0;
+    assert(std::search_n(Iter(ic), Iter(ic+sc), 4, 0, count_equal()) == Iter(ic+sc));
+    assert(count_equal::count <= sc);
+    count_equal::count = 0;
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+}
diff --git a/final/test/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
new file mode 100644
index 0000000..192da03
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/alg.search/search_pred.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter1, ForwardIterator Iter2>
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+//   Iter1
+//   search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+    static unsigned count;
+    template <class T>
+    bool operator()(const T& x, const T& y)
+        {++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {0, 1, 2, 3, 4, 5};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), count_equal()) == Iter1(ia+1));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia+2));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= 0);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-3));
+    assert(count_equal::count <= sa*3);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia));
+    assert(count_equal::count <= sa*sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+sa-1));
+    assert(count_equal::count <= (sa-1)*sa);
+    count_equal::count = 0;
+    assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), count_equal()) == Iter1(ia+1));
+    assert(count_equal::count <= sa);
+    count_equal::count = 0;
+    int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), count_equal()) == Iter1(ib+1));
+    assert(count_equal::count <= sb);
+    count_equal::count = 0;
+    int id[] = {1, 2};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), count_equal()) == Iter1(ib+1));
+    assert(count_equal::count <= sb*2);
+    count_equal::count = 0;
+    int ie[] = {1, 2, 3};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), count_equal()) == Iter1(ib+4));
+    assert(count_equal::count <= sb*3);
+    count_equal::count = 0;
+    int ig[] = {1, 2, 3, 4};
+    assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), count_equal()) == Iter1(ib+8));
+    assert(count_equal::count <= sb*4);
+    count_equal::count = 0;
+    int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
+    const unsigned sh = sizeof(ih)/sizeof(ih[0]);
+    int ii[] = {1, 1, 2};
+    assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), count_equal()) == Iter1(ih+3));
+    assert(count_equal::count <= sh*3);
+}
+
+int main()
+{
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+}
diff --git a/final/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp b/final/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
new file mode 100644
index 0000000..fe67854
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+//   requires HasEqualTo<Iter1::value_type, Iter2::value_type>
+//   pair<Iter1, Iter2>
+//   mismatch(Iter1 first1, Iter1 last1, Iter2 first2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    assert(std::mismatch(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         input_iterator<const int*>(ib)) ==
+                         (std::pair<input_iterator<const int*>,
+                                    input_iterator<const int*> >(
+                            input_iterator<const int*>(ia+3),
+                            input_iterator<const int*>(ib+3))));
+
+#ifdef HAS_FOUR_ITERATOR_VERSION
+    assert(std::mismatch(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         input_iterator<const int*>(ib),
+                         input_iterator<const int*>(ib + sa)) ==
+                         (std::pair<input_iterator<const int*>,
+                                    input_iterator<const int*> >(
+                            input_iterator<const int*>(ia+3),
+                            input_iterator<const int*>(ib+3))));
+
+    assert(std::mismatch(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         input_iterator<const int*>(ib),
+                         input_iterator<const int*>(ib + 2)) ==
+                         (std::pair<input_iterator<const int*>,
+                                    input_iterator<const int*> >(
+                            input_iterator<const int*>(ia+2),
+                            input_iterator<const int*>(ib+2))));
+#endif
+}
diff --git a/final/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp b/final/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
new file mode 100644
index 0000000..202a1b7
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2,
+//          Predicate<auto, Iter1::value_type, Iter2::value_type> Pred>
+//   requires CopyConstructible<Pred>
+//   pair<Iter1, Iter2>
+//   mismatch(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+#define HAS_FOUR_ITERATOR_VERSION
+#endif
+
+
+int main()
+{
+    int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {0, 1, 2, 3, 0, 1, 2, 3};
+    assert(std::mismatch(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         input_iterator<const int*>(ib),
+                         std::equal_to<int>()) ==
+                         (std::pair<input_iterator<const int*>,
+                                    input_iterator<const int*> >(
+                            input_iterator<const int*>(ia+3),
+                            input_iterator<const int*>(ib+3))));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+    assert(std::mismatch(input_iterator<const int*>(ia),
+                         input_iterator<const int*>(ia + sa),
+                         input_iterator<const int*>(ib),
+                         input_iterator<const int*>(ib + sa),
+                         std::equal_to<int>()) ==
+                         (std::pair<input_iterator<const int*>,
+                                    input_iterator<const int*> >(
+                            input_iterator<const int*>(ia+3),
+                            input_iterator<const int*>(ib+3))));
+#endif
+
+    assert(std::mismatch(ia, ia + sa, ib, std::equal_to<int>()) ==
+           (std::pair<int*,int*>(ia+3,ib+3)));
+#ifdef HAS_FOUR_ITERATOR_VERSION
+    assert(std::mismatch(ia, ia + sa, ib, ib + sa, std::equal_to<int>()) ==
+           (std::pair<int*,int*>(ia+3,ib+3)));
+    assert(std::mismatch(ia, ia + sa, ib, ib + 2, std::equal_to<int>()) ==
+           (std::pair<int*,int*>(ia+2,ib+2)));
+#endif
+}
diff --git a/final/test/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp b/final/test/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.nonmodifying/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
new file mode 100644
index 0000000..253e0e3
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires HasLess<T, Iter::value_type>
+//         && HasLess<Iter::value_type, T>
+//   bool
+//   binary_search(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value, bool x)
+{
+    assert(std::binary_search(first, last, value) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x < M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x, true);
+    test(Iter(v.data()), Iter(v.data()+v.size()), -1, false);
+    test(Iter(v.data()), Iter(v.data()+v.size()), M, false);
+}
+
+int main()
+{
+    int d[] = {0, 2, 4, 6};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 7; ++x)
+            test(d, e, x, (x % 2 == 0) && ((e-d)*2 > x));
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp
new file mode 100644
index 0000000..1d28409
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, CopyConstructible Compare>
+//   requires Predicate<Compare, T, Iter::value_type>
+//         && Predicate<Compare, Iter::value_type, T>
+//   bool
+//   binary_search(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value, bool x)
+{
+    assert(std::binary_search(first, last, value, std::greater<int>()) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x < M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x, true);
+    test(Iter(v.data()), Iter(v.data()+v.size()), -1, false);
+    test(Iter(v.data()), Iter(v.data()+v.size()), M, false);
+}
+
+int main()
+{
+    int d[] = {6, 4, 2, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 7; ++x)
+            test(d, e, x, (x % 2 == 0) && e != d && (-2*(e-d) + 8 <= x));
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp
new file mode 100644
index 0000000..ce659c1
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires HasLess<T, Iter::value_type>
+//         && HasLess<Iter::value_type, T>
+//   pair<Iter, Iter>
+//   equal_range(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    std::pair<Iter, Iter> i = std::equal_range(first, last, value);
+    for (Iter j = first; j != i.first; ++j)
+        assert(*j < value);
+    for (Iter j = i.first; j != last; ++j)
+        assert(!(*j < value));
+    for (Iter j = first; j != i.second; ++j)
+        assert(!(value < *j));
+    for (Iter j = i.second; j != last; ++j)
+        assert(value < *j);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {0, 1, 2, 3};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp
new file mode 100644
index 0000000..2b29e2c
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/equal.range/equal_range_comp.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, CopyConstructible Compare>
+//   requires Predicate<Compare, T, Iter::value_type>
+//         && Predicate<Compare, Iter::value_type, T>
+//   pair<Iter, Iter>
+//   equal_range(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    std::pair<Iter, Iter> i = std::equal_range(first, last, value, std::greater<int>());
+    for (Iter j = first; j != i.first; ++j)
+        assert(std::greater<int>()(*j, value));
+    for (Iter j = i.first; j != last; ++j)
+        assert(!std::greater<int>()(*j, value));
+    for (Iter j = first; j != i.second; ++j)
+        assert(!std::greater<int>()(value, *j));
+    for (Iter j = i.second; j != last; ++j)
+        assert(std::greater<int>()(value, *j));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {3, 2, 1, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp
new file mode 100644
index 0000000..ce4f7ce
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires HasLess<Iter::value_type, T>
+//   Iter
+//   lower_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::lower_bound(first, last, value);
+    for (Iter j = first; j != i; ++j)
+        assert(*j < value);
+    for (Iter j = i; j != last; ++j)
+        assert(!(*j < value));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {0, 1, 2, 3};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp
new file mode 100644
index 0000000..ae65c59
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/lower.bound/lower_bound_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires HasLess<Iter::value_type, T>
+//   Iter
+//   lower_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::lower_bound(first, last, value, std::greater<int>());
+    for (Iter j = first; j != i; ++j)
+        assert(std::greater<int>()(*j, value));
+    for (Iter j = i; j != last; ++j)
+        assert(!std::greater<int>()(*j, value));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {3, 2, 1, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp
new file mode 100644
index 0000000..3659e08
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T>
+//   requires HasLess<T, Iter::value_type>
+//   Iter
+//   upper_bound(Iter first, Iter last, const T& value);
+
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::upper_bound(first, last, value);
+    for (Iter j = first; j != i; ++j)
+        assert(!(value < *j));
+    for (Iter j = i; j != last; ++j)
+        assert(value < *j);
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {0, 1, 2, 3};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp
new file mode 100644
index 0000000..dd5fcfc
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.binary.search/upper.bound/upper_bound_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, class T, Predicate<auto, T, Iter::value_type> Compare>
+//   requires CopyConstructible<Compare>
+//   Iter
+//   upper_bound(Iter first, Iter last, const T& value, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, const T& value)
+{
+    Iter i = std::upper_bound(first, last, value, std::greater<int>());
+    for (Iter j = first; j != i; ++j)
+        assert(!std::greater<int>()(value, *j));
+    for (Iter j = i; j != last; ++j)
+        assert(std::greater<int>()(value, *j));
+}
+
+template <class Iter>
+void
+test()
+{
+    const unsigned N = 1000;
+    const unsigned M = 10;
+    std::vector<int> v(N);
+    int x = 0;
+    for (int i = 0; i < v.size(); ++i)
+    {
+        v[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    for (x = 0; x <= M; ++x)
+        test(Iter(v.data()), Iter(v.data()+v.size()), x);
+}
+
+int main()
+{
+    int d[] = {3, 2, 1, 0};
+    for (int* e = d; e <= d+4; ++e)
+        for (int x = -1; x <= 4; ++x)
+            test(d, e, x);
+
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
new file mode 100644
index 0000000..f16b2c3
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap.pass.cpp
@@ -0,0 +1,521 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   bool
+//   is_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap(i1, i1));
+    assert(std::is_heap(i1, i1+1) == (std::is_heap_until(i1, i1+1) == i1+1));
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap(i1, i1+2) == (std::is_heap_until(i1, i1+2) == i1+2));
+    assert(std::is_heap(i2, i2+2) == (std::is_heap_until(i2, i2+2) == i2+2));
+    assert(std::is_heap(i3, i3+2) == (std::is_heap_until(i3, i3+2) == i3+2));
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap(i4, i4+3) == (std::is_heap_until(i4, i4+3) == i4+3));
+    assert(std::is_heap(i5, i5+3) == (std::is_heap_until(i5, i5+3) == i5+3));
+    assert(std::is_heap(i6, i6+3) == (std::is_heap_until(i6, i6+3) == i6+3));
+    assert(std::is_heap(i7, i7+3) == (std::is_heap_until(i7, i7+3) == i7+3));
+    assert(std::is_heap(i8, i8+3) == (std::is_heap_until(i8, i8+3) == i8+3));
+    assert(std::is_heap(i9, i9+3) == (std::is_heap_until(i9, i9+3) == i9+3));
+    assert(std::is_heap(i10, i10+3) == (std::is_heap_until(i10, i10+3) == i10+3));
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap(i11, i11+4) == (std::is_heap_until(i11, i11+4) == i11+4));
+    assert(std::is_heap(i12, i12+4) == (std::is_heap_until(i12, i12+4) == i12+4));
+    assert(std::is_heap(i13, i13+4) == (std::is_heap_until(i13, i13+4) == i13+4));
+    assert(std::is_heap(i14, i14+4) == (std::is_heap_until(i14, i14+4) == i14+4));
+    assert(std::is_heap(i15, i15+4) == (std::is_heap_until(i15, i15+4) == i15+4));
+    assert(std::is_heap(i16, i16+4) == (std::is_heap_until(i16, i16+4) == i16+4));
+    assert(std::is_heap(i17, i17+4) == (std::is_heap_until(i17, i17+4) == i17+4));
+    assert(std::is_heap(i18, i18+4) == (std::is_heap_until(i18, i18+4) == i18+4));
+    assert(std::is_heap(i19, i19+4) == (std::is_heap_until(i19, i19+4) == i19+4));
+    assert(std::is_heap(i20, i20+4) == (std::is_heap_until(i20, i20+4) == i20+4));
+    assert(std::is_heap(i21, i21+4) == (std::is_heap_until(i21, i21+4) == i21+4));
+    assert(std::is_heap(i22, i22+4) == (std::is_heap_until(i22, i22+4) == i22+4));
+    assert(std::is_heap(i23, i23+4) == (std::is_heap_until(i23, i23+4) == i23+4));
+    assert(std::is_heap(i24, i24+4) == (std::is_heap_until(i24, i24+4) == i24+4));
+    assert(std::is_heap(i25, i25+4) == (std::is_heap_until(i25, i25+4) == i25+4));
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap(i26, i26+5) == (std::is_heap_until(i26, i26+5) == i26+5));
+    assert(std::is_heap(i27, i27+5) == (std::is_heap_until(i27, i27+5) == i27+5));
+    assert(std::is_heap(i28, i28+5) == (std::is_heap_until(i28, i28+5) == i28+5));
+    assert(std::is_heap(i29, i29+5) == (std::is_heap_until(i29, i29+5) == i29+5));
+    assert(std::is_heap(i30, i30+5) == (std::is_heap_until(i30, i30+5) == i30+5));
+    assert(std::is_heap(i31, i31+5) == (std::is_heap_until(i31, i31+5) == i31+5));
+    assert(std::is_heap(i32, i32+5) == (std::is_heap_until(i32, i32+5) == i32+5));
+    assert(std::is_heap(i33, i33+5) == (std::is_heap_until(i33, i33+5) == i33+5));
+    assert(std::is_heap(i34, i34+5) == (std::is_heap_until(i34, i34+5) == i34+5));
+    assert(std::is_heap(i35, i35+5) == (std::is_heap_until(i35, i35+5) == i35+5));
+    assert(std::is_heap(i36, i36+5) == (std::is_heap_until(i36, i36+5) == i36+5));
+    assert(std::is_heap(i37, i37+5) == (std::is_heap_until(i37, i37+5) == i37+5));
+    assert(std::is_heap(i38, i38+5) == (std::is_heap_until(i38, i38+5) == i38+5));
+    assert(std::is_heap(i39, i39+5) == (std::is_heap_until(i39, i39+5) == i39+5));
+    assert(std::is_heap(i40, i40+5) == (std::is_heap_until(i40, i40+5) == i40+5));
+    assert(std::is_heap(i41, i41+5) == (std::is_heap_until(i41, i41+5) == i41+5));
+    assert(std::is_heap(i42, i42+5) == (std::is_heap_until(i42, i42+5) == i42+5));
+    assert(std::is_heap(i43, i43+5) == (std::is_heap_until(i43, i43+5) == i43+5));
+    assert(std::is_heap(i44, i44+5) == (std::is_heap_until(i44, i44+5) == i44+5));
+    assert(std::is_heap(i45, i45+5) == (std::is_heap_until(i45, i45+5) == i45+5));
+    assert(std::is_heap(i46, i46+5) == (std::is_heap_until(i46, i46+5) == i46+5));
+    assert(std::is_heap(i47, i47+5) == (std::is_heap_until(i47, i47+5) == i47+5));
+    assert(std::is_heap(i48, i48+5) == (std::is_heap_until(i48, i48+5) == i48+5));
+    assert(std::is_heap(i49, i49+5) == (std::is_heap_until(i49, i49+5) == i49+5));
+    assert(std::is_heap(i50, i50+5) == (std::is_heap_until(i50, i50+5) == i50+5));
+    assert(std::is_heap(i51, i51+5) == (std::is_heap_until(i51, i51+5) == i51+5));
+    assert(std::is_heap(i52, i52+5) == (std::is_heap_until(i52, i52+5) == i52+5));
+    assert(std::is_heap(i53, i53+5) == (std::is_heap_until(i53, i53+5) == i53+5));
+    assert(std::is_heap(i54, i54+5) == (std::is_heap_until(i54, i54+5) == i54+5));
+    assert(std::is_heap(i55, i55+5) == (std::is_heap_until(i55, i55+5) == i55+5));
+    assert(std::is_heap(i56, i56+5) == (std::is_heap_until(i56, i56+5) == i56+5));
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i57, i57+6) == (std::is_heap_until(i57, i57+6) == i57+6));
+    assert(std::is_heap(i58, i58+6) == (std::is_heap_until(i58, i58+6) == i58+6));
+    assert(std::is_heap(i59, i59+6) == (std::is_heap_until(i59, i59+6) == i59+6));
+    assert(std::is_heap(i60, i60+6) == (std::is_heap_until(i60, i60+6) == i60+6));
+    assert(std::is_heap(i61, i61+6) == (std::is_heap_until(i61, i61+6) == i61+6));
+    assert(std::is_heap(i62, i62+6) == (std::is_heap_until(i62, i62+6) == i62+6));
+    assert(std::is_heap(i63, i63+6) == (std::is_heap_until(i63, i63+6) == i63+6));
+    assert(std::is_heap(i64, i64+6) == (std::is_heap_until(i64, i64+6) == i64+6));
+    assert(std::is_heap(i65, i65+6) == (std::is_heap_until(i65, i65+6) == i65+6));
+    assert(std::is_heap(i66, i66+6) == (std::is_heap_until(i66, i66+6) == i66+6));
+    assert(std::is_heap(i67, i67+6) == (std::is_heap_until(i67, i67+6) == i67+6));
+    assert(std::is_heap(i68, i68+6) == (std::is_heap_until(i68, i68+6) == i68+6));
+    assert(std::is_heap(i69, i69+6) == (std::is_heap_until(i69, i69+6) == i69+6));
+    assert(std::is_heap(i70, i70+6) == (std::is_heap_until(i70, i70+6) == i70+6));
+    assert(std::is_heap(i71, i71+6) == (std::is_heap_until(i71, i71+6) == i71+6));
+    assert(std::is_heap(i72, i72+6) == (std::is_heap_until(i72, i72+6) == i72+6));
+    assert(std::is_heap(i73, i73+6) == (std::is_heap_until(i73, i73+6) == i73+6));
+    assert(std::is_heap(i74, i74+6) == (std::is_heap_until(i74, i74+6) == i74+6));
+    assert(std::is_heap(i75, i75+6) == (std::is_heap_until(i75, i75+6) == i75+6));
+    assert(std::is_heap(i76, i76+6) == (std::is_heap_until(i76, i76+6) == i76+6));
+    assert(std::is_heap(i77, i77+6) == (std::is_heap_until(i77, i77+6) == i77+6));
+    assert(std::is_heap(i78, i78+6) == (std::is_heap_until(i78, i78+6) == i78+6));
+    assert(std::is_heap(i79, i79+6) == (std::is_heap_until(i79, i79+6) == i79+6));
+    assert(std::is_heap(i80, i80+6) == (std::is_heap_until(i80, i80+6) == i80+6));
+    assert(std::is_heap(i81, i81+6) == (std::is_heap_until(i81, i81+6) == i81+6));
+    assert(std::is_heap(i82, i82+6) == (std::is_heap_until(i82, i82+6) == i82+6));
+    assert(std::is_heap(i83, i83+6) == (std::is_heap_until(i83, i83+6) == i83+6));
+    assert(std::is_heap(i84, i84+6) == (std::is_heap_until(i84, i84+6) == i84+6));
+    assert(std::is_heap(i85, i85+6) == (std::is_heap_until(i85, i85+6) == i85+6));
+    assert(std::is_heap(i86, i86+6) == (std::is_heap_until(i86, i86+6) == i86+6));
+    assert(std::is_heap(i87, i87+6) == (std::is_heap_until(i87, i87+6) == i87+6));
+    assert(std::is_heap(i88, i88+6) == (std::is_heap_until(i88, i88+6) == i88+6));
+    assert(std::is_heap(i89, i89+6) == (std::is_heap_until(i89, i89+6) == i89+6));
+    assert(std::is_heap(i90, i90+6) == (std::is_heap_until(i90, i90+6) == i90+6));
+    assert(std::is_heap(i91, i91+6) == (std::is_heap_until(i91, i91+6) == i91+6));
+    assert(std::is_heap(i92, i92+6) == (std::is_heap_until(i92, i92+6) == i92+6));
+    assert(std::is_heap(i93, i93+6) == (std::is_heap_until(i93, i93+6) == i93+6));
+    assert(std::is_heap(i94, i94+6) == (std::is_heap_until(i94, i94+6) == i94+6));
+    assert(std::is_heap(i95, i95+6) == (std::is_heap_until(i95, i95+6) == i95+6));
+    assert(std::is_heap(i96, i96+6) == (std::is_heap_until(i96, i96+6) == i96+6));
+    assert(std::is_heap(i97, i97+6) == (std::is_heap_until(i97, i97+6) == i97+6));
+    assert(std::is_heap(i98, i98+6) == (std::is_heap_until(i98, i98+6) == i98+6));
+    assert(std::is_heap(i99, i99+6) == (std::is_heap_until(i99, i99+6) == i99+6));
+    assert(std::is_heap(i100, i100+6) == (std::is_heap_until(i100, i100+6) == i100+6));
+    assert(std::is_heap(i101, i101+6) == (std::is_heap_until(i101, i101+6) == i101+6));
+    assert(std::is_heap(i102, i102+6) == (std::is_heap_until(i102, i102+6) == i102+6));
+    assert(std::is_heap(i103, i103+6) == (std::is_heap_until(i103, i103+6) == i103+6));
+    assert(std::is_heap(i104, i104+6) == (std::is_heap_until(i104, i104+6) == i104+6));
+    assert(std::is_heap(i105, i105+6) == (std::is_heap_until(i105, i105+6) == i105+6));
+    assert(std::is_heap(i106, i106+6) == (std::is_heap_until(i106, i106+6) == i106+6));
+    assert(std::is_heap(i107, i107+6) == (std::is_heap_until(i107, i107+6) == i107+6));
+    assert(std::is_heap(i108, i108+6) == (std::is_heap_until(i108, i108+6) == i108+6));
+    assert(std::is_heap(i109, i109+6) == (std::is_heap_until(i109, i109+6) == i109+6));
+    assert(std::is_heap(i110, i110+6) == (std::is_heap_until(i110, i110+6) == i110+6));
+    assert(std::is_heap(i111, i111+6) == (std::is_heap_until(i111, i111+6) == i111+6));
+    assert(std::is_heap(i112, i112+6) == (std::is_heap_until(i112, i112+6) == i112+6));
+    assert(std::is_heap(i113, i113+6) == (std::is_heap_until(i113, i113+6) == i113+6));
+    assert(std::is_heap(i114, i114+6) == (std::is_heap_until(i114, i114+6) == i114+6));
+    assert(std::is_heap(i115, i115+6) == (std::is_heap_until(i115, i115+6) == i115+6));
+    assert(std::is_heap(i116, i116+6) == (std::is_heap_until(i116, i116+6) == i116+6));
+    assert(std::is_heap(i117, i117+6) == (std::is_heap_until(i117, i117+6) == i117+6));
+    assert(std::is_heap(i118, i118+6) == (std::is_heap_until(i118, i118+6) == i118+6));
+    assert(std::is_heap(i119, i119+6) == (std::is_heap_until(i119, i119+6) == i119+6));
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i120, i120+7) == (std::is_heap_until(i120, i120+7) == i120+7));
+    assert(std::is_heap(i121, i121+7) == (std::is_heap_until(i121, i121+7) == i121+7));
+    assert(std::is_heap(i122, i122+7) == (std::is_heap_until(i122, i122+7) == i122+7));
+    assert(std::is_heap(i123, i123+7) == (std::is_heap_until(i123, i123+7) == i123+7));
+    assert(std::is_heap(i124, i124+7) == (std::is_heap_until(i124, i124+7) == i124+7));
+    assert(std::is_heap(i125, i125+7) == (std::is_heap_until(i125, i125+7) == i125+7));
+    assert(std::is_heap(i126, i126+7) == (std::is_heap_until(i126, i126+7) == i126+7));
+    assert(std::is_heap(i127, i127+7) == (std::is_heap_until(i127, i127+7) == i127+7));
+    assert(std::is_heap(i128, i128+7) == (std::is_heap_until(i128, i128+7) == i128+7));
+    assert(std::is_heap(i129, i129+7) == (std::is_heap_until(i129, i129+7) == i129+7));
+    assert(std::is_heap(i130, i130+7) == (std::is_heap_until(i130, i130+7) == i130+7));
+    assert(std::is_heap(i131, i131+7) == (std::is_heap_until(i131, i131+7) == i131+7));
+    assert(std::is_heap(i132, i132+7) == (std::is_heap_until(i132, i132+7) == i132+7));
+    assert(std::is_heap(i133, i133+7) == (std::is_heap_until(i133, i133+7) == i133+7));
+    assert(std::is_heap(i134, i134+7) == (std::is_heap_until(i134, i134+7) == i134+7));
+    assert(std::is_heap(i135, i135+7) == (std::is_heap_until(i135, i135+7) == i135+7));
+    assert(std::is_heap(i136, i136+7) == (std::is_heap_until(i136, i136+7) == i136+7));
+    assert(std::is_heap(i137, i137+7) == (std::is_heap_until(i137, i137+7) == i137+7));
+    assert(std::is_heap(i138, i138+7) == (std::is_heap_until(i138, i138+7) == i138+7));
+    assert(std::is_heap(i139, i139+7) == (std::is_heap_until(i139, i139+7) == i139+7));
+    assert(std::is_heap(i140, i140+7) == (std::is_heap_until(i140, i140+7) == i140+7));
+    assert(std::is_heap(i141, i141+7) == (std::is_heap_until(i141, i141+7) == i141+7));
+    assert(std::is_heap(i142, i142+7) == (std::is_heap_until(i142, i142+7) == i142+7));
+    assert(std::is_heap(i143, i143+7) == (std::is_heap_until(i143, i143+7) == i143+7));
+    assert(std::is_heap(i144, i144+7) == (std::is_heap_until(i144, i144+7) == i144+7));
+    assert(std::is_heap(i145, i145+7) == (std::is_heap_until(i145, i145+7) == i145+7));
+    assert(std::is_heap(i146, i146+7) == (std::is_heap_until(i146, i146+7) == i146+7));
+    assert(std::is_heap(i147, i147+7) == (std::is_heap_until(i147, i147+7) == i147+7));
+    assert(std::is_heap(i148, i148+7) == (std::is_heap_until(i148, i148+7) == i148+7));
+    assert(std::is_heap(i149, i149+7) == (std::is_heap_until(i149, i149+7) == i149+7));
+    assert(std::is_heap(i150, i150+7) == (std::is_heap_until(i150, i150+7) == i150+7));
+    assert(std::is_heap(i151, i151+7) == (std::is_heap_until(i151, i151+7) == i151+7));
+    assert(std::is_heap(i152, i152+7) == (std::is_heap_until(i152, i152+7) == i152+7));
+    assert(std::is_heap(i153, i153+7) == (std::is_heap_until(i153, i153+7) == i153+7));
+    assert(std::is_heap(i154, i154+7) == (std::is_heap_until(i154, i154+7) == i154+7));
+    assert(std::is_heap(i155, i155+7) == (std::is_heap_until(i155, i155+7) == i155+7));
+    assert(std::is_heap(i156, i156+7) == (std::is_heap_until(i156, i156+7) == i156+7));
+    assert(std::is_heap(i157, i157+7) == (std::is_heap_until(i157, i157+7) == i157+7));
+    assert(std::is_heap(i158, i158+7) == (std::is_heap_until(i158, i158+7) == i158+7));
+    assert(std::is_heap(i159, i159+7) == (std::is_heap_until(i159, i159+7) == i159+7));
+    assert(std::is_heap(i160, i160+7) == (std::is_heap_until(i160, i160+7) == i160+7));
+    assert(std::is_heap(i161, i161+7) == (std::is_heap_until(i161, i161+7) == i161+7));
+    assert(std::is_heap(i162, i162+7) == (std::is_heap_until(i162, i162+7) == i162+7));
+    assert(std::is_heap(i163, i163+7) == (std::is_heap_until(i163, i163+7) == i163+7));
+    assert(std::is_heap(i164, i164+7) == (std::is_heap_until(i164, i164+7) == i164+7));
+    assert(std::is_heap(i165, i165+7) == (std::is_heap_until(i165, i165+7) == i165+7));
+    assert(std::is_heap(i166, i166+7) == (std::is_heap_until(i166, i166+7) == i166+7));
+    assert(std::is_heap(i167, i167+7) == (std::is_heap_until(i167, i167+7) == i167+7));
+    assert(std::is_heap(i168, i168+7) == (std::is_heap_until(i168, i168+7) == i168+7));
+    assert(std::is_heap(i169, i169+7) == (std::is_heap_until(i169, i169+7) == i169+7));
+    assert(std::is_heap(i170, i170+7) == (std::is_heap_until(i170, i170+7) == i170+7));
+    assert(std::is_heap(i171, i171+7) == (std::is_heap_until(i171, i171+7) == i171+7));
+    assert(std::is_heap(i172, i172+7) == (std::is_heap_until(i172, i172+7) == i172+7));
+    assert(std::is_heap(i173, i173+7) == (std::is_heap_until(i173, i173+7) == i173+7));
+    assert(std::is_heap(i174, i174+7) == (std::is_heap_until(i174, i174+7) == i174+7));
+    assert(std::is_heap(i175, i175+7) == (std::is_heap_until(i175, i175+7) == i175+7));
+    assert(std::is_heap(i176, i176+7) == (std::is_heap_until(i176, i176+7) == i176+7));
+    assert(std::is_heap(i177, i177+7) == (std::is_heap_until(i177, i177+7) == i177+7));
+    assert(std::is_heap(i178, i178+7) == (std::is_heap_until(i178, i178+7) == i178+7));
+    assert(std::is_heap(i179, i179+7) == (std::is_heap_until(i179, i179+7) == i179+7));
+    assert(std::is_heap(i180, i180+7) == (std::is_heap_until(i180, i180+7) == i180+7));
+    assert(std::is_heap(i181, i181+7) == (std::is_heap_until(i181, i181+7) == i181+7));
+    assert(std::is_heap(i182, i182+7) == (std::is_heap_until(i182, i182+7) == i182+7));
+    assert(std::is_heap(i183, i183+7) == (std::is_heap_until(i183, i183+7) == i183+7));
+    assert(std::is_heap(i184, i184+7) == (std::is_heap_until(i184, i184+7) == i184+7));
+    assert(std::is_heap(i185, i185+7) == (std::is_heap_until(i185, i185+7) == i185+7));
+    assert(std::is_heap(i186, i186+7) == (std::is_heap_until(i186, i186+7) == i186+7));
+    assert(std::is_heap(i187, i187+7) == (std::is_heap_until(i187, i187+7) == i187+7));
+    assert(std::is_heap(i188, i188+7) == (std::is_heap_until(i188, i188+7) == i188+7));
+    assert(std::is_heap(i189, i189+7) == (std::is_heap_until(i189, i189+7) == i189+7));
+    assert(std::is_heap(i190, i190+7) == (std::is_heap_until(i190, i190+7) == i190+7));
+    assert(std::is_heap(i191, i191+7) == (std::is_heap_until(i191, i191+7) == i191+7));
+    assert(std::is_heap(i192, i192+7) == (std::is_heap_until(i192, i192+7) == i192+7));
+    assert(std::is_heap(i193, i193+7) == (std::is_heap_until(i193, i193+7) == i193+7));
+    assert(std::is_heap(i194, i194+7) == (std::is_heap_until(i194, i194+7) == i194+7));
+    assert(std::is_heap(i195, i195+7) == (std::is_heap_until(i195, i195+7) == i195+7));
+    assert(std::is_heap(i196, i196+7) == (std::is_heap_until(i196, i196+7) == i196+7));
+    assert(std::is_heap(i197, i197+7) == (std::is_heap_until(i197, i197+7) == i197+7));
+    assert(std::is_heap(i198, i198+7) == (std::is_heap_until(i198, i198+7) == i198+7));
+    assert(std::is_heap(i199, i199+7) == (std::is_heap_until(i199, i199+7) == i199+7));
+    assert(std::is_heap(i200, i200+7) == (std::is_heap_until(i200, i200+7) == i200+7));
+    assert(std::is_heap(i201, i201+7) == (std::is_heap_until(i201, i201+7) == i201+7));
+    assert(std::is_heap(i202, i202+7) == (std::is_heap_until(i202, i202+7) == i202+7));
+    assert(std::is_heap(i203, i203+7) == (std::is_heap_until(i203, i203+7) == i203+7));
+    assert(std::is_heap(i204, i204+7) == (std::is_heap_until(i204, i204+7) == i204+7));
+    assert(std::is_heap(i205, i205+7) == (std::is_heap_until(i205, i205+7) == i205+7));
+    assert(std::is_heap(i206, i206+7) == (std::is_heap_until(i206, i206+7) == i206+7));
+    assert(std::is_heap(i207, i207+7) == (std::is_heap_until(i207, i207+7) == i207+7));
+    assert(std::is_heap(i208, i208+7) == (std::is_heap_until(i208, i208+7) == i208+7));
+    assert(std::is_heap(i209, i209+7) == (std::is_heap_until(i209, i209+7) == i209+7));
+    assert(std::is_heap(i210, i210+7) == (std::is_heap_until(i210, i210+7) == i210+7));
+    assert(std::is_heap(i211, i211+7) == (std::is_heap_until(i211, i211+7) == i211+7));
+    assert(std::is_heap(i212, i212+7) == (std::is_heap_until(i212, i212+7) == i212+7));
+    assert(std::is_heap(i213, i213+7) == (std::is_heap_until(i213, i213+7) == i213+7));
+    assert(std::is_heap(i214, i214+7) == (std::is_heap_until(i214, i214+7) == i214+7));
+    assert(std::is_heap(i215, i215+7) == (std::is_heap_until(i215, i215+7) == i215+7));
+    assert(std::is_heap(i216, i216+7) == (std::is_heap_until(i216, i216+7) == i216+7));
+    assert(std::is_heap(i217, i217+7) == (std::is_heap_until(i217, i217+7) == i217+7));
+    assert(std::is_heap(i218, i218+7) == (std::is_heap_until(i218, i218+7) == i218+7));
+    assert(std::is_heap(i219, i219+7) == (std::is_heap_until(i219, i219+7) == i219+7));
+    assert(std::is_heap(i220, i220+7) == (std::is_heap_until(i220, i220+7) == i220+7));
+    assert(std::is_heap(i221, i221+7) == (std::is_heap_until(i221, i221+7) == i221+7));
+    assert(std::is_heap(i222, i222+7) == (std::is_heap_until(i222, i222+7) == i222+7));
+    assert(std::is_heap(i223, i223+7) == (std::is_heap_until(i223, i223+7) == i223+7));
+    assert(std::is_heap(i224, i224+7) == (std::is_heap_until(i224, i224+7) == i224+7));
+    assert(std::is_heap(i225, i225+7) == (std::is_heap_until(i225, i225+7) == i225+7));
+    assert(std::is_heap(i226, i226+7) == (std::is_heap_until(i226, i226+7) == i226+7));
+    assert(std::is_heap(i227, i227+7) == (std::is_heap_until(i227, i227+7) == i227+7));
+    assert(std::is_heap(i228, i228+7) == (std::is_heap_until(i228, i228+7) == i228+7));
+    assert(std::is_heap(i229, i229+7) == (std::is_heap_until(i229, i229+7) == i229+7));
+    assert(std::is_heap(i230, i230+7) == (std::is_heap_until(i230, i230+7) == i230+7));
+    assert(std::is_heap(i231, i231+7) == (std::is_heap_until(i231, i231+7) == i231+7));
+    assert(std::is_heap(i232, i232+7) == (std::is_heap_until(i232, i232+7) == i232+7));
+    assert(std::is_heap(i233, i233+7) == (std::is_heap_until(i233, i233+7) == i233+7));
+    assert(std::is_heap(i234, i234+7) == (std::is_heap_until(i234, i234+7) == i234+7));
+    assert(std::is_heap(i235, i235+7) == (std::is_heap_until(i235, i235+7) == i235+7));
+    assert(std::is_heap(i236, i236+7) == (std::is_heap_until(i236, i236+7) == i236+7));
+    assert(std::is_heap(i237, i237+7) == (std::is_heap_until(i237, i237+7) == i237+7));
+    assert(std::is_heap(i238, i238+7) == (std::is_heap_until(i238, i238+7) == i238+7));
+    assert(std::is_heap(i239, i239+7) == (std::is_heap_until(i239, i239+7) == i239+7));
+    assert(std::is_heap(i240, i240+7) == (std::is_heap_until(i240, i240+7) == i240+7));
+    assert(std::is_heap(i241, i241+7) == (std::is_heap_until(i241, i241+7) == i241+7));
+    assert(std::is_heap(i242, i242+7) == (std::is_heap_until(i242, i242+7) == i242+7));
+    assert(std::is_heap(i243, i243+7) == (std::is_heap_until(i243, i243+7) == i243+7));
+    assert(std::is_heap(i244, i244+7) == (std::is_heap_until(i244, i244+7) == i244+7));
+    assert(std::is_heap(i245, i245+7) == (std::is_heap_until(i245, i245+7) == i245+7));
+    assert(std::is_heap(i246, i246+7) == (std::is_heap_until(i246, i246+7) == i246+7));
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
new file mode 100644
index 0000000..af55cc4
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_comp.pass.cpp
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   bool
+//   is_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap(i1, i1, std::greater<int>()));
+    assert(std::is_heap(i1, i1+1, std::greater<int>()) == (std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1));
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap(i1, i1+2, std::greater<int>()) == (std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2));
+    assert(std::is_heap(i2, i2+2, std::greater<int>()) == (std::is_heap_until(i2, i2+2, std::greater<int>()) == i2+2));
+    assert(std::is_heap(i3, i3+2, std::greater<int>()) == (std::is_heap_until(i3, i3+2, std::greater<int>()) == i3+2));
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap(i4, i4+3, std::greater<int>()) == (std::is_heap_until(i4, i4+3, std::greater<int>()) == i4+3));
+    assert(std::is_heap(i5, i5+3, std::greater<int>()) == (std::is_heap_until(i5, i5+3, std::greater<int>()) == i5+3));
+    assert(std::is_heap(i6, i6+3, std::greater<int>()) == (std::is_heap_until(i6, i6+3, std::greater<int>()) == i6+3));
+    assert(std::is_heap(i7, i7+3, std::greater<int>()) == (std::is_heap_until(i7, i7+3, std::greater<int>()) == i7+3));
+    assert(std::is_heap(i8, i8+3, std::greater<int>()) == (std::is_heap_until(i8, i8+3, std::greater<int>()) == i8+3));
+    assert(std::is_heap(i9, i9+3, std::greater<int>()) == (std::is_heap_until(i9, i9+3, std::greater<int>()) == i9+3));
+    assert(std::is_heap(i10, i10+3, std::greater<int>()) == (std::is_heap_until(i10, i10+3, std::greater<int>()) == i10+3));
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap(i11, i11+4, std::greater<int>()) == (std::is_heap_until(i11, i11+4, std::greater<int>()) == i11+4));
+    assert(std::is_heap(i12, i12+4, std::greater<int>()) == (std::is_heap_until(i12, i12+4, std::greater<int>()) == i12+4));
+    assert(std::is_heap(i13, i13+4, std::greater<int>()) == (std::is_heap_until(i13, i13+4, std::greater<int>()) == i13+4));
+    assert(std::is_heap(i14, i14+4, std::greater<int>()) == (std::is_heap_until(i14, i14+4, std::greater<int>()) == i14+4));
+    assert(std::is_heap(i15, i15+4, std::greater<int>()) == (std::is_heap_until(i15, i15+4, std::greater<int>()) == i15+4));
+    assert(std::is_heap(i16, i16+4, std::greater<int>()) == (std::is_heap_until(i16, i16+4, std::greater<int>()) == i16+4));
+    assert(std::is_heap(i17, i17+4, std::greater<int>()) == (std::is_heap_until(i17, i17+4, std::greater<int>()) == i17+4));
+    assert(std::is_heap(i18, i18+4, std::greater<int>()) == (std::is_heap_until(i18, i18+4, std::greater<int>()) == i18+4));
+    assert(std::is_heap(i19, i19+4, std::greater<int>()) == (std::is_heap_until(i19, i19+4, std::greater<int>()) == i19+4));
+    assert(std::is_heap(i20, i20+4, std::greater<int>()) == (std::is_heap_until(i20, i20+4, std::greater<int>()) == i20+4));
+    assert(std::is_heap(i21, i21+4, std::greater<int>()) == (std::is_heap_until(i21, i21+4, std::greater<int>()) == i21+4));
+    assert(std::is_heap(i22, i22+4, std::greater<int>()) == (std::is_heap_until(i22, i22+4, std::greater<int>()) == i22+4));
+    assert(std::is_heap(i23, i23+4, std::greater<int>()) == (std::is_heap_until(i23, i23+4, std::greater<int>()) == i23+4));
+    assert(std::is_heap(i24, i24+4, std::greater<int>()) == (std::is_heap_until(i24, i24+4, std::greater<int>()) == i24+4));
+    assert(std::is_heap(i25, i25+4, std::greater<int>()) == (std::is_heap_until(i25, i25+4, std::greater<int>()) == i25+4));
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap(i26, i26+5, std::greater<int>()) == (std::is_heap_until(i26, i26+5, std::greater<int>()) == i26+5));
+    assert(std::is_heap(i27, i27+5, std::greater<int>()) == (std::is_heap_until(i27, i27+5, std::greater<int>()) == i27+5));
+    assert(std::is_heap(i28, i28+5, std::greater<int>()) == (std::is_heap_until(i28, i28+5, std::greater<int>()) == i28+5));
+    assert(std::is_heap(i29, i29+5, std::greater<int>()) == (std::is_heap_until(i29, i29+5, std::greater<int>()) == i29+5));
+    assert(std::is_heap(i30, i30+5, std::greater<int>()) == (std::is_heap_until(i30, i30+5, std::greater<int>()) == i30+5));
+    assert(std::is_heap(i31, i31+5, std::greater<int>()) == (std::is_heap_until(i31, i31+5, std::greater<int>()) == i31+5));
+    assert(std::is_heap(i32, i32+5, std::greater<int>()) == (std::is_heap_until(i32, i32+5, std::greater<int>()) == i32+5));
+    assert(std::is_heap(i33, i33+5, std::greater<int>()) == (std::is_heap_until(i33, i33+5, std::greater<int>()) == i33+5));
+    assert(std::is_heap(i34, i34+5, std::greater<int>()) == (std::is_heap_until(i34, i34+5, std::greater<int>()) == i34+5));
+    assert(std::is_heap(i35, i35+5, std::greater<int>()) == (std::is_heap_until(i35, i35+5, std::greater<int>()) == i35+5));
+    assert(std::is_heap(i36, i36+5, std::greater<int>()) == (std::is_heap_until(i36, i36+5, std::greater<int>()) == i36+5));
+    assert(std::is_heap(i37, i37+5, std::greater<int>()) == (std::is_heap_until(i37, i37+5, std::greater<int>()) == i37+5));
+    assert(std::is_heap(i38, i38+5, std::greater<int>()) == (std::is_heap_until(i38, i38+5, std::greater<int>()) == i38+5));
+    assert(std::is_heap(i39, i39+5, std::greater<int>()) == (std::is_heap_until(i39, i39+5, std::greater<int>()) == i39+5));
+    assert(std::is_heap(i40, i40+5, std::greater<int>()) == (std::is_heap_until(i40, i40+5, std::greater<int>()) == i40+5));
+    assert(std::is_heap(i41, i41+5, std::greater<int>()) == (std::is_heap_until(i41, i41+5, std::greater<int>()) == i41+5));
+    assert(std::is_heap(i42, i42+5, std::greater<int>()) == (std::is_heap_until(i42, i42+5, std::greater<int>()) == i42+5));
+    assert(std::is_heap(i43, i43+5, std::greater<int>()) == (std::is_heap_until(i43, i43+5, std::greater<int>()) == i43+5));
+    assert(std::is_heap(i44, i44+5, std::greater<int>()) == (std::is_heap_until(i44, i44+5, std::greater<int>()) == i44+5));
+    assert(std::is_heap(i45, i45+5, std::greater<int>()) == (std::is_heap_until(i45, i45+5, std::greater<int>()) == i45+5));
+    assert(std::is_heap(i46, i46+5, std::greater<int>()) == (std::is_heap_until(i46, i46+5, std::greater<int>()) == i46+5));
+    assert(std::is_heap(i47, i47+5, std::greater<int>()) == (std::is_heap_until(i47, i47+5, std::greater<int>()) == i47+5));
+    assert(std::is_heap(i48, i48+5, std::greater<int>()) == (std::is_heap_until(i48, i48+5, std::greater<int>()) == i48+5));
+    assert(std::is_heap(i49, i49+5, std::greater<int>()) == (std::is_heap_until(i49, i49+5, std::greater<int>()) == i49+5));
+    assert(std::is_heap(i50, i50+5, std::greater<int>()) == (std::is_heap_until(i50, i50+5, std::greater<int>()) == i50+5));
+    assert(std::is_heap(i51, i51+5, std::greater<int>()) == (std::is_heap_until(i51, i51+5, std::greater<int>()) == i51+5));
+    assert(std::is_heap(i52, i52+5, std::greater<int>()) == (std::is_heap_until(i52, i52+5, std::greater<int>()) == i52+5));
+    assert(std::is_heap(i53, i53+5, std::greater<int>()) == (std::is_heap_until(i53, i53+5, std::greater<int>()) == i53+5));
+    assert(std::is_heap(i54, i54+5, std::greater<int>()) == (std::is_heap_until(i54, i54+5, std::greater<int>()) == i54+5));
+    assert(std::is_heap(i55, i55+5, std::greater<int>()) == (std::is_heap_until(i55, i55+5, std::greater<int>()) == i55+5));
+    assert(std::is_heap(i56, i56+5, std::greater<int>()) == (std::is_heap_until(i56, i56+5, std::greater<int>()) == i56+5));
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i57, i57+6, std::greater<int>()) == (std::is_heap_until(i57, i57+6, std::greater<int>()) == i57+6));
+    assert(std::is_heap(i58, i58+6, std::greater<int>()) == (std::is_heap_until(i58, i58+6, std::greater<int>()) == i58+6));
+    assert(std::is_heap(i59, i59+6, std::greater<int>()) == (std::is_heap_until(i59, i59+6, std::greater<int>()) == i59+6));
+    assert(std::is_heap(i60, i60+6, std::greater<int>()) == (std::is_heap_until(i60, i60+6, std::greater<int>()) == i60+6));
+    assert(std::is_heap(i61, i61+6, std::greater<int>()) == (std::is_heap_until(i61, i61+6, std::greater<int>()) == i61+6));
+    assert(std::is_heap(i62, i62+6, std::greater<int>()) == (std::is_heap_until(i62, i62+6, std::greater<int>()) == i62+6));
+    assert(std::is_heap(i63, i63+6, std::greater<int>()) == (std::is_heap_until(i63, i63+6, std::greater<int>()) == i63+6));
+    assert(std::is_heap(i64, i64+6, std::greater<int>()) == (std::is_heap_until(i64, i64+6, std::greater<int>()) == i64+6));
+    assert(std::is_heap(i65, i65+6, std::greater<int>()) == (std::is_heap_until(i65, i65+6, std::greater<int>()) == i65+6));
+    assert(std::is_heap(i66, i66+6, std::greater<int>()) == (std::is_heap_until(i66, i66+6, std::greater<int>()) == i66+6));
+    assert(std::is_heap(i67, i67+6, std::greater<int>()) == (std::is_heap_until(i67, i67+6, std::greater<int>()) == i67+6));
+    assert(std::is_heap(i68, i68+6, std::greater<int>()) == (std::is_heap_until(i68, i68+6, std::greater<int>()) == i68+6));
+    assert(std::is_heap(i69, i69+6, std::greater<int>()) == (std::is_heap_until(i69, i69+6, std::greater<int>()) == i69+6));
+    assert(std::is_heap(i70, i70+6, std::greater<int>()) == (std::is_heap_until(i70, i70+6, std::greater<int>()) == i70+6));
+    assert(std::is_heap(i71, i71+6, std::greater<int>()) == (std::is_heap_until(i71, i71+6, std::greater<int>()) == i71+6));
+    assert(std::is_heap(i72, i72+6, std::greater<int>()) == (std::is_heap_until(i72, i72+6, std::greater<int>()) == i72+6));
+    assert(std::is_heap(i73, i73+6, std::greater<int>()) == (std::is_heap_until(i73, i73+6, std::greater<int>()) == i73+6));
+    assert(std::is_heap(i74, i74+6, std::greater<int>()) == (std::is_heap_until(i74, i74+6, std::greater<int>()) == i74+6));
+    assert(std::is_heap(i75, i75+6, std::greater<int>()) == (std::is_heap_until(i75, i75+6, std::greater<int>()) == i75+6));
+    assert(std::is_heap(i76, i76+6, std::greater<int>()) == (std::is_heap_until(i76, i76+6, std::greater<int>()) == i76+6));
+    assert(std::is_heap(i77, i77+6, std::greater<int>()) == (std::is_heap_until(i77, i77+6, std::greater<int>()) == i77+6));
+    assert(std::is_heap(i78, i78+6, std::greater<int>()) == (std::is_heap_until(i78, i78+6, std::greater<int>()) == i78+6));
+    assert(std::is_heap(i79, i79+6, std::greater<int>()) == (std::is_heap_until(i79, i79+6, std::greater<int>()) == i79+6));
+    assert(std::is_heap(i80, i80+6, std::greater<int>()) == (std::is_heap_until(i80, i80+6, std::greater<int>()) == i80+6));
+    assert(std::is_heap(i81, i81+6, std::greater<int>()) == (std::is_heap_until(i81, i81+6, std::greater<int>()) == i81+6));
+    assert(std::is_heap(i82, i82+6, std::greater<int>()) == (std::is_heap_until(i82, i82+6, std::greater<int>()) == i82+6));
+    assert(std::is_heap(i83, i83+6, std::greater<int>()) == (std::is_heap_until(i83, i83+6, std::greater<int>()) == i83+6));
+    assert(std::is_heap(i84, i84+6, std::greater<int>()) == (std::is_heap_until(i84, i84+6, std::greater<int>()) == i84+6));
+    assert(std::is_heap(i85, i85+6, std::greater<int>()) == (std::is_heap_until(i85, i85+6, std::greater<int>()) == i85+6));
+    assert(std::is_heap(i86, i86+6, std::greater<int>()) == (std::is_heap_until(i86, i86+6, std::greater<int>()) == i86+6));
+    assert(std::is_heap(i87, i87+6, std::greater<int>()) == (std::is_heap_until(i87, i87+6, std::greater<int>()) == i87+6));
+    assert(std::is_heap(i88, i88+6, std::greater<int>()) == (std::is_heap_until(i88, i88+6, std::greater<int>()) == i88+6));
+    assert(std::is_heap(i89, i89+6, std::greater<int>()) == (std::is_heap_until(i89, i89+6, std::greater<int>()) == i89+6));
+    assert(std::is_heap(i90, i90+6, std::greater<int>()) == (std::is_heap_until(i90, i90+6, std::greater<int>()) == i90+6));
+    assert(std::is_heap(i91, i91+6, std::greater<int>()) == (std::is_heap_until(i91, i91+6, std::greater<int>()) == i91+6));
+    assert(std::is_heap(i92, i92+6, std::greater<int>()) == (std::is_heap_until(i92, i92+6, std::greater<int>()) == i92+6));
+    assert(std::is_heap(i93, i93+6, std::greater<int>()) == (std::is_heap_until(i93, i93+6, std::greater<int>()) == i93+6));
+    assert(std::is_heap(i94, i94+6, std::greater<int>()) == (std::is_heap_until(i94, i94+6, std::greater<int>()) == i94+6));
+    assert(std::is_heap(i95, i95+6, std::greater<int>()) == (std::is_heap_until(i95, i95+6, std::greater<int>()) == i95+6));
+    assert(std::is_heap(i96, i96+6, std::greater<int>()) == (std::is_heap_until(i96, i96+6, std::greater<int>()) == i96+6));
+    assert(std::is_heap(i97, i97+6, std::greater<int>()) == (std::is_heap_until(i97, i97+6, std::greater<int>()) == i97+6));
+    assert(std::is_heap(i98, i98+6, std::greater<int>()) == (std::is_heap_until(i98, i98+6, std::greater<int>()) == i98+6));
+    assert(std::is_heap(i99, i99+6, std::greater<int>()) == (std::is_heap_until(i99, i99+6, std::greater<int>()) == i99+6));
+    assert(std::is_heap(i100, i100+6, std::greater<int>()) == (std::is_heap_until(i100, i100+6, std::greater<int>()) == i100+6));
+    assert(std::is_heap(i101, i101+6, std::greater<int>()) == (std::is_heap_until(i101, i101+6, std::greater<int>()) == i101+6));
+    assert(std::is_heap(i102, i102+6, std::greater<int>()) == (std::is_heap_until(i102, i102+6, std::greater<int>()) == i102+6));
+    assert(std::is_heap(i103, i103+6, std::greater<int>()) == (std::is_heap_until(i103, i103+6, std::greater<int>()) == i103+6));
+    assert(std::is_heap(i104, i104+6, std::greater<int>()) == (std::is_heap_until(i104, i104+6, std::greater<int>()) == i104+6));
+    assert(std::is_heap(i105, i105+6, std::greater<int>()) == (std::is_heap_until(i105, i105+6, std::greater<int>()) == i105+6));
+    assert(std::is_heap(i106, i106+6, std::greater<int>()) == (std::is_heap_until(i106, i106+6, std::greater<int>()) == i106+6));
+    assert(std::is_heap(i107, i107+6, std::greater<int>()) == (std::is_heap_until(i107, i107+6, std::greater<int>()) == i107+6));
+    assert(std::is_heap(i108, i108+6, std::greater<int>()) == (std::is_heap_until(i108, i108+6, std::greater<int>()) == i108+6));
+    assert(std::is_heap(i109, i109+6, std::greater<int>()) == (std::is_heap_until(i109, i109+6, std::greater<int>()) == i109+6));
+    assert(std::is_heap(i110, i110+6, std::greater<int>()) == (std::is_heap_until(i110, i110+6, std::greater<int>()) == i110+6));
+    assert(std::is_heap(i111, i111+6, std::greater<int>()) == (std::is_heap_until(i111, i111+6, std::greater<int>()) == i111+6));
+    assert(std::is_heap(i112, i112+6, std::greater<int>()) == (std::is_heap_until(i112, i112+6, std::greater<int>()) == i112+6));
+    assert(std::is_heap(i113, i113+6, std::greater<int>()) == (std::is_heap_until(i113, i113+6, std::greater<int>()) == i113+6));
+    assert(std::is_heap(i114, i114+6, std::greater<int>()) == (std::is_heap_until(i114, i114+6, std::greater<int>()) == i114+6));
+    assert(std::is_heap(i115, i115+6, std::greater<int>()) == (std::is_heap_until(i115, i115+6, std::greater<int>()) == i115+6));
+    assert(std::is_heap(i116, i116+6, std::greater<int>()) == (std::is_heap_until(i116, i116+6, std::greater<int>()) == i116+6));
+    assert(std::is_heap(i117, i117+6, std::greater<int>()) == (std::is_heap_until(i117, i117+6, std::greater<int>()) == i117+6));
+    assert(std::is_heap(i118, i118+6, std::greater<int>()) == (std::is_heap_until(i118, i118+6, std::greater<int>()) == i118+6));
+    assert(std::is_heap(i119, i119+6, std::greater<int>()) == (std::is_heap_until(i119, i119+6, std::greater<int>()) == i119+6));
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap(i120, i120+7, std::greater<int>()) == (std::is_heap_until(i120, i120+7, std::greater<int>()) == i120+7));
+    assert(std::is_heap(i121, i121+7, std::greater<int>()) == (std::is_heap_until(i121, i121+7, std::greater<int>()) == i121+7));
+    assert(std::is_heap(i122, i122+7, std::greater<int>()) == (std::is_heap_until(i122, i122+7, std::greater<int>()) == i122+7));
+    assert(std::is_heap(i123, i123+7, std::greater<int>()) == (std::is_heap_until(i123, i123+7, std::greater<int>()) == i123+7));
+    assert(std::is_heap(i124, i124+7, std::greater<int>()) == (std::is_heap_until(i124, i124+7, std::greater<int>()) == i124+7));
+    assert(std::is_heap(i125, i125+7, std::greater<int>()) == (std::is_heap_until(i125, i125+7, std::greater<int>()) == i125+7));
+    assert(std::is_heap(i126, i126+7, std::greater<int>()) == (std::is_heap_until(i126, i126+7, std::greater<int>()) == i126+7));
+    assert(std::is_heap(i127, i127+7, std::greater<int>()) == (std::is_heap_until(i127, i127+7, std::greater<int>()) == i127+7));
+    assert(std::is_heap(i128, i128+7, std::greater<int>()) == (std::is_heap_until(i128, i128+7, std::greater<int>()) == i128+7));
+    assert(std::is_heap(i129, i129+7, std::greater<int>()) == (std::is_heap_until(i129, i129+7, std::greater<int>()) == i129+7));
+    assert(std::is_heap(i130, i130+7, std::greater<int>()) == (std::is_heap_until(i130, i130+7, std::greater<int>()) == i130+7));
+    assert(std::is_heap(i131, i131+7, std::greater<int>()) == (std::is_heap_until(i131, i131+7, std::greater<int>()) == i131+7));
+    assert(std::is_heap(i132, i132+7, std::greater<int>()) == (std::is_heap_until(i132, i132+7, std::greater<int>()) == i132+7));
+    assert(std::is_heap(i133, i133+7, std::greater<int>()) == (std::is_heap_until(i133, i133+7, std::greater<int>()) == i133+7));
+    assert(std::is_heap(i134, i134+7, std::greater<int>()) == (std::is_heap_until(i134, i134+7, std::greater<int>()) == i134+7));
+    assert(std::is_heap(i135, i135+7, std::greater<int>()) == (std::is_heap_until(i135, i135+7, std::greater<int>()) == i135+7));
+    assert(std::is_heap(i136, i136+7, std::greater<int>()) == (std::is_heap_until(i136, i136+7, std::greater<int>()) == i136+7));
+    assert(std::is_heap(i137, i137+7, std::greater<int>()) == (std::is_heap_until(i137, i137+7, std::greater<int>()) == i137+7));
+    assert(std::is_heap(i138, i138+7, std::greater<int>()) == (std::is_heap_until(i138, i138+7, std::greater<int>()) == i138+7));
+    assert(std::is_heap(i139, i139+7, std::greater<int>()) == (std::is_heap_until(i139, i139+7, std::greater<int>()) == i139+7));
+    assert(std::is_heap(i140, i140+7, std::greater<int>()) == (std::is_heap_until(i140, i140+7, std::greater<int>()) == i140+7));
+    assert(std::is_heap(i141, i141+7, std::greater<int>()) == (std::is_heap_until(i141, i141+7, std::greater<int>()) == i141+7));
+    assert(std::is_heap(i142, i142+7, std::greater<int>()) == (std::is_heap_until(i142, i142+7, std::greater<int>()) == i142+7));
+    assert(std::is_heap(i143, i143+7, std::greater<int>()) == (std::is_heap_until(i143, i143+7, std::greater<int>()) == i143+7));
+    assert(std::is_heap(i144, i144+7, std::greater<int>()) == (std::is_heap_until(i144, i144+7, std::greater<int>()) == i144+7));
+    assert(std::is_heap(i145, i145+7, std::greater<int>()) == (std::is_heap_until(i145, i145+7, std::greater<int>()) == i145+7));
+    assert(std::is_heap(i146, i146+7, std::greater<int>()) == (std::is_heap_until(i146, i146+7, std::greater<int>()) == i146+7));
+    assert(std::is_heap(i147, i147+7, std::greater<int>()) == (std::is_heap_until(i147, i147+7, std::greater<int>()) == i147+7));
+    assert(std::is_heap(i148, i148+7, std::greater<int>()) == (std::is_heap_until(i148, i148+7, std::greater<int>()) == i148+7));
+    assert(std::is_heap(i149, i149+7, std::greater<int>()) == (std::is_heap_until(i149, i149+7, std::greater<int>()) == i149+7));
+    assert(std::is_heap(i150, i150+7, std::greater<int>()) == (std::is_heap_until(i150, i150+7, std::greater<int>()) == i150+7));
+    assert(std::is_heap(i151, i151+7, std::greater<int>()) == (std::is_heap_until(i151, i151+7, std::greater<int>()) == i151+7));
+    assert(std::is_heap(i152, i152+7, std::greater<int>()) == (std::is_heap_until(i152, i152+7, std::greater<int>()) == i152+7));
+    assert(std::is_heap(i153, i153+7, std::greater<int>()) == (std::is_heap_until(i153, i153+7, std::greater<int>()) == i153+7));
+    assert(std::is_heap(i154, i154+7, std::greater<int>()) == (std::is_heap_until(i154, i154+7, std::greater<int>()) == i154+7));
+    assert(std::is_heap(i155, i155+7, std::greater<int>()) == (std::is_heap_until(i155, i155+7, std::greater<int>()) == i155+7));
+    assert(std::is_heap(i156, i156+7, std::greater<int>()) == (std::is_heap_until(i156, i156+7, std::greater<int>()) == i156+7));
+    assert(std::is_heap(i157, i157+7, std::greater<int>()) == (std::is_heap_until(i157, i157+7, std::greater<int>()) == i157+7));
+    assert(std::is_heap(i158, i158+7, std::greater<int>()) == (std::is_heap_until(i158, i158+7, std::greater<int>()) == i158+7));
+    assert(std::is_heap(i159, i159+7, std::greater<int>()) == (std::is_heap_until(i159, i159+7, std::greater<int>()) == i159+7));
+    assert(std::is_heap(i160, i160+7, std::greater<int>()) == (std::is_heap_until(i160, i160+7, std::greater<int>()) == i160+7));
+    assert(std::is_heap(i161, i161+7, std::greater<int>()) == (std::is_heap_until(i161, i161+7, std::greater<int>()) == i161+7));
+    assert(std::is_heap(i162, i162+7, std::greater<int>()) == (std::is_heap_until(i162, i162+7, std::greater<int>()) == i162+7));
+    assert(std::is_heap(i163, i163+7, std::greater<int>()) == (std::is_heap_until(i163, i163+7, std::greater<int>()) == i163+7));
+    assert(std::is_heap(i164, i164+7, std::greater<int>()) == (std::is_heap_until(i164, i164+7, std::greater<int>()) == i164+7));
+    assert(std::is_heap(i165, i165+7, std::greater<int>()) == (std::is_heap_until(i165, i165+7, std::greater<int>()) == i165+7));
+    assert(std::is_heap(i166, i166+7, std::greater<int>()) == (std::is_heap_until(i166, i166+7, std::greater<int>()) == i166+7));
+    assert(std::is_heap(i167, i167+7, std::greater<int>()) == (std::is_heap_until(i167, i167+7, std::greater<int>()) == i167+7));
+    assert(std::is_heap(i168, i168+7, std::greater<int>()) == (std::is_heap_until(i168, i168+7, std::greater<int>()) == i168+7));
+    assert(std::is_heap(i169, i169+7, std::greater<int>()) == (std::is_heap_until(i169, i169+7, std::greater<int>()) == i169+7));
+    assert(std::is_heap(i170, i170+7, std::greater<int>()) == (std::is_heap_until(i170, i170+7, std::greater<int>()) == i170+7));
+    assert(std::is_heap(i171, i171+7, std::greater<int>()) == (std::is_heap_until(i171, i171+7, std::greater<int>()) == i171+7));
+    assert(std::is_heap(i172, i172+7, std::greater<int>()) == (std::is_heap_until(i172, i172+7, std::greater<int>()) == i172+7));
+    assert(std::is_heap(i173, i173+7, std::greater<int>()) == (std::is_heap_until(i173, i173+7, std::greater<int>()) == i173+7));
+    assert(std::is_heap(i174, i174+7, std::greater<int>()) == (std::is_heap_until(i174, i174+7, std::greater<int>()) == i174+7));
+    assert(std::is_heap(i175, i175+7, std::greater<int>()) == (std::is_heap_until(i175, i175+7, std::greater<int>()) == i175+7));
+    assert(std::is_heap(i176, i176+7, std::greater<int>()) == (std::is_heap_until(i176, i176+7, std::greater<int>()) == i176+7));
+    assert(std::is_heap(i177, i177+7, std::greater<int>()) == (std::is_heap_until(i177, i177+7, std::greater<int>()) == i177+7));
+    assert(std::is_heap(i178, i178+7, std::greater<int>()) == (std::is_heap_until(i178, i178+7, std::greater<int>()) == i178+7));
+    assert(std::is_heap(i179, i179+7, std::greater<int>()) == (std::is_heap_until(i179, i179+7, std::greater<int>()) == i179+7));
+    assert(std::is_heap(i180, i180+7, std::greater<int>()) == (std::is_heap_until(i180, i180+7, std::greater<int>()) == i180+7));
+    assert(std::is_heap(i181, i181+7, std::greater<int>()) == (std::is_heap_until(i181, i181+7, std::greater<int>()) == i181+7));
+    assert(std::is_heap(i182, i182+7, std::greater<int>()) == (std::is_heap_until(i182, i182+7, std::greater<int>()) == i182+7));
+    assert(std::is_heap(i183, i183+7, std::greater<int>()) == (std::is_heap_until(i183, i183+7, std::greater<int>()) == i183+7));
+    assert(std::is_heap(i184, i184+7, std::greater<int>()) == (std::is_heap_until(i184, i184+7, std::greater<int>()) == i184+7));
+    assert(std::is_heap(i185, i185+7, std::greater<int>()) == (std::is_heap_until(i185, i185+7, std::greater<int>()) == i185+7));
+    assert(std::is_heap(i186, i186+7, std::greater<int>()) == (std::is_heap_until(i186, i186+7, std::greater<int>()) == i186+7));
+    assert(std::is_heap(i187, i187+7, std::greater<int>()) == (std::is_heap_until(i187, i187+7, std::greater<int>()) == i187+7));
+    assert(std::is_heap(i188, i188+7, std::greater<int>()) == (std::is_heap_until(i188, i188+7, std::greater<int>()) == i188+7));
+    assert(std::is_heap(i189, i189+7, std::greater<int>()) == (std::is_heap_until(i189, i189+7, std::greater<int>()) == i189+7));
+    assert(std::is_heap(i190, i190+7, std::greater<int>()) == (std::is_heap_until(i190, i190+7, std::greater<int>()) == i190+7));
+    assert(std::is_heap(i191, i191+7, std::greater<int>()) == (std::is_heap_until(i191, i191+7, std::greater<int>()) == i191+7));
+    assert(std::is_heap(i192, i192+7, std::greater<int>()) == (std::is_heap_until(i192, i192+7, std::greater<int>()) == i192+7));
+    assert(std::is_heap(i193, i193+7, std::greater<int>()) == (std::is_heap_until(i193, i193+7, std::greater<int>()) == i193+7));
+    assert(std::is_heap(i194, i194+7, std::greater<int>()) == (std::is_heap_until(i194, i194+7, std::greater<int>()) == i194+7));
+    assert(std::is_heap(i195, i195+7, std::greater<int>()) == (std::is_heap_until(i195, i195+7, std::greater<int>()) == i195+7));
+    assert(std::is_heap(i196, i196+7, std::greater<int>()) == (std::is_heap_until(i196, i196+7, std::greater<int>()) == i196+7));
+    assert(std::is_heap(i197, i197+7, std::greater<int>()) == (std::is_heap_until(i197, i197+7, std::greater<int>()) == i197+7));
+    assert(std::is_heap(i198, i198+7, std::greater<int>()) == (std::is_heap_until(i198, i198+7, std::greater<int>()) == i198+7));
+    assert(std::is_heap(i199, i199+7, std::greater<int>()) == (std::is_heap_until(i199, i199+7, std::greater<int>()) == i199+7));
+    assert(std::is_heap(i200, i200+7, std::greater<int>()) == (std::is_heap_until(i200, i200+7, std::greater<int>()) == i200+7));
+    assert(std::is_heap(i201, i201+7, std::greater<int>()) == (std::is_heap_until(i201, i201+7, std::greater<int>()) == i201+7));
+    assert(std::is_heap(i202, i202+7, std::greater<int>()) == (std::is_heap_until(i202, i202+7, std::greater<int>()) == i202+7));
+    assert(std::is_heap(i203, i203+7, std::greater<int>()) == (std::is_heap_until(i203, i203+7, std::greater<int>()) == i203+7));
+    assert(std::is_heap(i204, i204+7, std::greater<int>()) == (std::is_heap_until(i204, i204+7, std::greater<int>()) == i204+7));
+    assert(std::is_heap(i205, i205+7, std::greater<int>()) == (std::is_heap_until(i205, i205+7, std::greater<int>()) == i205+7));
+    assert(std::is_heap(i206, i206+7, std::greater<int>()) == (std::is_heap_until(i206, i206+7, std::greater<int>()) == i206+7));
+    assert(std::is_heap(i207, i207+7, std::greater<int>()) == (std::is_heap_until(i207, i207+7, std::greater<int>()) == i207+7));
+    assert(std::is_heap(i208, i208+7, std::greater<int>()) == (std::is_heap_until(i208, i208+7, std::greater<int>()) == i208+7));
+    assert(std::is_heap(i209, i209+7, std::greater<int>()) == (std::is_heap_until(i209, i209+7, std::greater<int>()) == i209+7));
+    assert(std::is_heap(i210, i210+7, std::greater<int>()) == (std::is_heap_until(i210, i210+7, std::greater<int>()) == i210+7));
+    assert(std::is_heap(i211, i211+7, std::greater<int>()) == (std::is_heap_until(i211, i211+7, std::greater<int>()) == i211+7));
+    assert(std::is_heap(i212, i212+7, std::greater<int>()) == (std::is_heap_until(i212, i212+7, std::greater<int>()) == i212+7));
+    assert(std::is_heap(i213, i213+7, std::greater<int>()) == (std::is_heap_until(i213, i213+7, std::greater<int>()) == i213+7));
+    assert(std::is_heap(i214, i214+7, std::greater<int>()) == (std::is_heap_until(i214, i214+7, std::greater<int>()) == i214+7));
+    assert(std::is_heap(i215, i215+7, std::greater<int>()) == (std::is_heap_until(i215, i215+7, std::greater<int>()) == i215+7));
+    assert(std::is_heap(i216, i216+7, std::greater<int>()) == (std::is_heap_until(i216, i216+7, std::greater<int>()) == i216+7));
+    assert(std::is_heap(i217, i217+7, std::greater<int>()) == (std::is_heap_until(i217, i217+7, std::greater<int>()) == i217+7));
+    assert(std::is_heap(i218, i218+7, std::greater<int>()) == (std::is_heap_until(i218, i218+7, std::greater<int>()) == i218+7));
+    assert(std::is_heap(i219, i219+7, std::greater<int>()) == (std::is_heap_until(i219, i219+7, std::greater<int>()) == i219+7));
+    assert(std::is_heap(i220, i220+7, std::greater<int>()) == (std::is_heap_until(i220, i220+7, std::greater<int>()) == i220+7));
+    assert(std::is_heap(i221, i221+7, std::greater<int>()) == (std::is_heap_until(i221, i221+7, std::greater<int>()) == i221+7));
+    assert(std::is_heap(i222, i222+7, std::greater<int>()) == (std::is_heap_until(i222, i222+7, std::greater<int>()) == i222+7));
+    assert(std::is_heap(i223, i223+7, std::greater<int>()) == (std::is_heap_until(i223, i223+7, std::greater<int>()) == i223+7));
+    assert(std::is_heap(i224, i224+7, std::greater<int>()) == (std::is_heap_until(i224, i224+7, std::greater<int>()) == i224+7));
+    assert(std::is_heap(i225, i225+7, std::greater<int>()) == (std::is_heap_until(i225, i225+7, std::greater<int>()) == i225+7));
+    assert(std::is_heap(i226, i226+7, std::greater<int>()) == (std::is_heap_until(i226, i226+7, std::greater<int>()) == i226+7));
+    assert(std::is_heap(i227, i227+7, std::greater<int>()) == (std::is_heap_until(i227, i227+7, std::greater<int>()) == i227+7));
+    assert(std::is_heap(i228, i228+7, std::greater<int>()) == (std::is_heap_until(i228, i228+7, std::greater<int>()) == i228+7));
+    assert(std::is_heap(i229, i229+7, std::greater<int>()) == (std::is_heap_until(i229, i229+7, std::greater<int>()) == i229+7));
+    assert(std::is_heap(i230, i230+7, std::greater<int>()) == (std::is_heap_until(i230, i230+7, std::greater<int>()) == i230+7));
+    assert(std::is_heap(i231, i231+7, std::greater<int>()) == (std::is_heap_until(i231, i231+7, std::greater<int>()) == i231+7));
+    assert(std::is_heap(i232, i232+7, std::greater<int>()) == (std::is_heap_until(i232, i232+7, std::greater<int>()) == i232+7));
+    assert(std::is_heap(i233, i233+7, std::greater<int>()) == (std::is_heap_until(i233, i233+7, std::greater<int>()) == i233+7));
+    assert(std::is_heap(i234, i234+7, std::greater<int>()) == (std::is_heap_until(i234, i234+7, std::greater<int>()) == i234+7));
+    assert(std::is_heap(i235, i235+7, std::greater<int>()) == (std::is_heap_until(i235, i235+7, std::greater<int>()) == i235+7));
+    assert(std::is_heap(i236, i236+7, std::greater<int>()) == (std::is_heap_until(i236, i236+7, std::greater<int>()) == i236+7));
+    assert(std::is_heap(i237, i237+7, std::greater<int>()) == (std::is_heap_until(i237, i237+7, std::greater<int>()) == i237+7));
+    assert(std::is_heap(i238, i238+7, std::greater<int>()) == (std::is_heap_until(i238, i238+7, std::greater<int>()) == i238+7));
+    assert(std::is_heap(i239, i239+7, std::greater<int>()) == (std::is_heap_until(i239, i239+7, std::greater<int>()) == i239+7));
+    assert(std::is_heap(i240, i240+7, std::greater<int>()) == (std::is_heap_until(i240, i240+7, std::greater<int>()) == i240+7));
+    assert(std::is_heap(i241, i241+7, std::greater<int>()) == (std::is_heap_until(i241, i241+7, std::greater<int>()) == i241+7));
+    assert(std::is_heap(i242, i242+7, std::greater<int>()) == (std::is_heap_until(i242, i242+7, std::greater<int>()) == i242+7));
+    assert(std::is_heap(i243, i243+7, std::greater<int>()) == (std::is_heap_until(i243, i243+7, std::greater<int>()) == i243+7));
+    assert(std::is_heap(i244, i244+7, std::greater<int>()) == (std::is_heap_until(i244, i244+7, std::greater<int>()) == i244+7));
+    assert(std::is_heap(i245, i245+7, std::greater<int>()) == (std::is_heap_until(i245, i245+7, std::greater<int>()) == i245+7));
+    assert(std::is_heap(i246, i246+7, std::greater<int>()) == (std::is_heap_until(i246, i246+7, std::greater<int>()) == i246+7));
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
new file mode 100644
index 0000000..082c044
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until.pass.cpp
@@ -0,0 +1,521 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   Iter
+//   is_heap_until(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap_until(i1, i1) == i1);
+    assert(std::is_heap_until(i1, i1+1) == i1+1);
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap_until(i1, i1+2) == i1+2);
+    assert(std::is_heap_until(i2, i2+2) == i2+1);
+    assert(std::is_heap_until(i3, i3+2) == i3+2);
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap_until(i4, i4+3) == i4+3);
+    assert(std::is_heap_until(i5, i5+3) == i5+2);
+    assert(std::is_heap_until(i6, i6+3) == i6+1);
+    assert(std::is_heap_until(i7, i7+3) == i7+1);
+    assert(std::is_heap_until(i8, i8+3) == i8+3);
+    assert(std::is_heap_until(i9, i9+3) == i9+3);
+    assert(std::is_heap_until(i10, i10+3) == i10+3);
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap_until(i11, i11+4) == i11+4);
+    assert(std::is_heap_until(i12, i12+4) == i12+3);
+    assert(std::is_heap_until(i13, i13+4) == i13+2);
+    assert(std::is_heap_until(i14, i14+4) == i14+2);
+    assert(std::is_heap_until(i15, i15+4) == i15+1);
+    assert(std::is_heap_until(i16, i16+4) == i16+1);
+    assert(std::is_heap_until(i17, i17+4) == i17+1);
+    assert(std::is_heap_until(i18, i18+4) == i18+1);
+    assert(std::is_heap_until(i19, i19+4) == i19+4);
+    assert(std::is_heap_until(i20, i20+4) == i20+3);
+    assert(std::is_heap_until(i21, i21+4) == i21+4);
+    assert(std::is_heap_until(i22, i22+4) == i22+3);
+    assert(std::is_heap_until(i23, i23+4) == i23+4);
+    assert(std::is_heap_until(i24, i24+4) == i24+4);
+    assert(std::is_heap_until(i25, i25+4) == i25+4);
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i26, i26+5) == i26+5);
+    assert(std::is_heap_until(i27, i27+5) == i27+4);
+    assert(std::is_heap_until(i28, i28+5) == i28+3);
+    assert(std::is_heap_until(i29, i29+5) == i29+3);
+    assert(std::is_heap_until(i30, i30+5) == i30+2);
+    assert(std::is_heap_until(i31, i31+5) == i31+2);
+    assert(std::is_heap_until(i32, i32+5) == i32+2);
+    assert(std::is_heap_until(i33, i33+5) == i33+2);
+    assert(std::is_heap_until(i34, i34+5) == i34+1);
+    assert(std::is_heap_until(i35, i35+5) == i35+1);
+    assert(std::is_heap_until(i36, i36+5) == i36+1);
+    assert(std::is_heap_until(i37, i37+5) == i37+1);
+    assert(std::is_heap_until(i38, i38+5) == i38+1);
+    assert(std::is_heap_until(i39, i39+5) == i39+1);
+    assert(std::is_heap_until(i40, i40+5) == i40+1);
+    assert(std::is_heap_until(i41, i41+5) == i41+1);
+    assert(std::is_heap_until(i42, i42+5) == i42+5);
+    assert(std::is_heap_until(i43, i43+5) == i43+4);
+    assert(std::is_heap_until(i44, i44+5) == i44+3);
+    assert(std::is_heap_until(i45, i45+5) == i45+3);
+    assert(std::is_heap_until(i46, i46+5) == i46+5);
+    assert(std::is_heap_until(i47, i47+5) == i47+4);
+    assert(std::is_heap_until(i48, i48+5) == i48+3);
+    assert(std::is_heap_until(i49, i49+5) == i49+3);
+    assert(std::is_heap_until(i50, i50+5) == i50+5);
+    assert(std::is_heap_until(i51, i51+5) == i51+5);
+    assert(std::is_heap_until(i52, i52+5) == i52+5);
+    assert(std::is_heap_until(i53, i53+5) == i53+5);
+    assert(std::is_heap_until(i54, i54+5) == i54+5);
+    assert(std::is_heap_until(i55, i55+5) == i55+5);
+    assert(std::is_heap_until(i56, i56+5) == i56+5);
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i57, i57+6) == i57+6);
+    assert(std::is_heap_until(i58, i58+6) == i58+5);
+    assert(std::is_heap_until(i59, i59+6) == i59+4);
+    assert(std::is_heap_until(i60, i60+6) == i60+4);
+    assert(std::is_heap_until(i61, i61+6) == i61+3);
+    assert(std::is_heap_until(i62, i62+6) == i62+3);
+    assert(std::is_heap_until(i63, i63+6) == i63+3);
+    assert(std::is_heap_until(i64, i64+6) == i64+3);
+    assert(std::is_heap_until(i65, i65+6) == i65+2);
+    assert(std::is_heap_until(i66, i66+6) == i66+2);
+    assert(std::is_heap_until(i67, i67+6) == i67+2);
+    assert(std::is_heap_until(i68, i68+6) == i68+2);
+    assert(std::is_heap_until(i69, i69+6) == i69+2);
+    assert(std::is_heap_until(i70, i70+6) == i70+2);
+    assert(std::is_heap_until(i71, i71+6) == i71+2);
+    assert(std::is_heap_until(i72, i72+6) == i72+2);
+    assert(std::is_heap_until(i73, i73+6) == i73+1);
+    assert(std::is_heap_until(i74, i74+6) == i74+1);
+    assert(std::is_heap_until(i75, i75+6) == i75+1);
+    assert(std::is_heap_until(i76, i76+6) == i76+1);
+    assert(std::is_heap_until(i77, i77+6) == i77+1);
+    assert(std::is_heap_until(i78, i78+6) == i78+1);
+    assert(std::is_heap_until(i79, i79+6) == i79+1);
+    assert(std::is_heap_until(i80, i80+6) == i80+1);
+    assert(std::is_heap_until(i81, i81+6) == i81+1);
+    assert(std::is_heap_until(i82, i82+6) == i82+1);
+    assert(std::is_heap_until(i83, i83+6) == i83+1);
+    assert(std::is_heap_until(i84, i84+6) == i84+1);
+    assert(std::is_heap_until(i85, i85+6) == i85+1);
+    assert(std::is_heap_until(i86, i86+6) == i86+1);
+    assert(std::is_heap_until(i87, i87+6) == i87+1);
+    assert(std::is_heap_until(i88, i88+6) == i88+1);
+    assert(std::is_heap_until(i89, i89+6) == i89+6);
+    assert(std::is_heap_until(i90, i90+6) == i90+5);
+    assert(std::is_heap_until(i91, i91+6) == i91+4);
+    assert(std::is_heap_until(i92, i92+6) == i92+4);
+    assert(std::is_heap_until(i93, i93+6) == i93+3);
+    assert(std::is_heap_until(i94, i94+6) == i94+3);
+    assert(std::is_heap_until(i95, i95+6) == i95+3);
+    assert(std::is_heap_until(i96, i96+6) == i96+3);
+    assert(std::is_heap_until(i97, i97+6) == i97+6);
+    assert(std::is_heap_until(i98, i98+6) == i98+6);
+    assert(std::is_heap_until(i99, i99+6) == i99+4);
+    assert(std::is_heap_until(i100, i100+6) == i100+4);
+    assert(std::is_heap_until(i101, i101+6) == i101+3);
+    assert(std::is_heap_until(i102, i102+6) == i102+3);
+    assert(std::is_heap_until(i103, i103+6) == i103+3);
+    assert(std::is_heap_until(i104, i104+6) == i104+3);
+    assert(std::is_heap_until(i105, i105+6) == i105+6);
+    assert(std::is_heap_until(i106, i106+6) == i106+5);
+    assert(std::is_heap_until(i107, i107+6) == i107+6);
+    assert(std::is_heap_until(i108, i108+6) == i108+5);
+    assert(std::is_heap_until(i109, i109+6) == i109+6);
+    assert(std::is_heap_until(i110, i110+6) == i110+5);
+    assert(std::is_heap_until(i111, i111+6) == i111+6);
+    assert(std::is_heap_until(i112, i112+6) == i112+5);
+    assert(std::is_heap_until(i113, i113+6) == i113+6);
+    assert(std::is_heap_until(i114, i114+6) == i114+6);
+    assert(std::is_heap_until(i115, i115+6) == i115+6);
+    assert(std::is_heap_until(i116, i116+6) == i116+6);
+    assert(std::is_heap_until(i117, i117+6) == i117+6);
+    assert(std::is_heap_until(i118, i118+6) == i118+6);
+    assert(std::is_heap_until(i119, i119+6) == i119+6);
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i120, i120+7) == i120+7);
+    assert(std::is_heap_until(i121, i121+7) == i121+6);
+    assert(std::is_heap_until(i122, i122+7) == i122+5);
+    assert(std::is_heap_until(i123, i123+7) == i123+5);
+    assert(std::is_heap_until(i124, i124+7) == i124+4);
+    assert(std::is_heap_until(i125, i125+7) == i125+4);
+    assert(std::is_heap_until(i126, i126+7) == i126+4);
+    assert(std::is_heap_until(i127, i127+7) == i127+4);
+    assert(std::is_heap_until(i128, i128+7) == i128+3);
+    assert(std::is_heap_until(i129, i129+7) == i129+3);
+    assert(std::is_heap_until(i130, i130+7) == i130+3);
+    assert(std::is_heap_until(i131, i131+7) == i131+3);
+    assert(std::is_heap_until(i132, i132+7) == i132+3);
+    assert(std::is_heap_until(i133, i133+7) == i133+3);
+    assert(std::is_heap_until(i134, i134+7) == i134+3);
+    assert(std::is_heap_until(i135, i135+7) == i135+3);
+    assert(std::is_heap_until(i136, i136+7) == i136+2);
+    assert(std::is_heap_until(i137, i137+7) == i137+2);
+    assert(std::is_heap_until(i138, i138+7) == i138+2);
+    assert(std::is_heap_until(i139, i139+7) == i139+2);
+    assert(std::is_heap_until(i140, i140+7) == i140+2);
+    assert(std::is_heap_until(i141, i141+7) == i141+2);
+    assert(std::is_heap_until(i142, i142+7) == i142+2);
+    assert(std::is_heap_until(i143, i143+7) == i143+2);
+    assert(std::is_heap_until(i144, i144+7) == i144+2);
+    assert(std::is_heap_until(i145, i145+7) == i145+2);
+    assert(std::is_heap_until(i146, i146+7) == i146+2);
+    assert(std::is_heap_until(i147, i147+7) == i147+2);
+    assert(std::is_heap_until(i148, i148+7) == i148+2);
+    assert(std::is_heap_until(i149, i149+7) == i149+2);
+    assert(std::is_heap_until(i150, i150+7) == i150+2);
+    assert(std::is_heap_until(i151, i151+7) == i151+2);
+    assert(std::is_heap_until(i152, i152+7) == i152+1);
+    assert(std::is_heap_until(i153, i153+7) == i153+1);
+    assert(std::is_heap_until(i154, i154+7) == i154+1);
+    assert(std::is_heap_until(i155, i155+7) == i155+1);
+    assert(std::is_heap_until(i156, i156+7) == i156+1);
+    assert(std::is_heap_until(i157, i157+7) == i157+1);
+    assert(std::is_heap_until(i158, i158+7) == i158+1);
+    assert(std::is_heap_until(i159, i159+7) == i159+1);
+    assert(std::is_heap_until(i160, i160+7) == i160+1);
+    assert(std::is_heap_until(i161, i161+7) == i161+1);
+    assert(std::is_heap_until(i162, i162+7) == i162+1);
+    assert(std::is_heap_until(i163, i163+7) == i163+1);
+    assert(std::is_heap_until(i164, i164+7) == i164+1);
+    assert(std::is_heap_until(i165, i165+7) == i165+1);
+    assert(std::is_heap_until(i166, i166+7) == i166+1);
+    assert(std::is_heap_until(i167, i167+7) == i167+1);
+    assert(std::is_heap_until(i168, i168+7) == i168+1);
+    assert(std::is_heap_until(i169, i169+7) == i169+1);
+    assert(std::is_heap_until(i170, i170+7) == i170+1);
+    assert(std::is_heap_until(i171, i171+7) == i171+1);
+    assert(std::is_heap_until(i172, i172+7) == i172+1);
+    assert(std::is_heap_until(i173, i173+7) == i173+1);
+    assert(std::is_heap_until(i174, i174+7) == i174+1);
+    assert(std::is_heap_until(i175, i175+7) == i175+1);
+    assert(std::is_heap_until(i176, i176+7) == i176+1);
+    assert(std::is_heap_until(i177, i177+7) == i177+1);
+    assert(std::is_heap_until(i178, i178+7) == i178+1);
+    assert(std::is_heap_until(i179, i179+7) == i179+1);
+    assert(std::is_heap_until(i180, i180+7) == i180+1);
+    assert(std::is_heap_until(i181, i181+7) == i181+1);
+    assert(std::is_heap_until(i182, i182+7) == i182+1);
+    assert(std::is_heap_until(i183, i183+7) == i183+1);
+    assert(std::is_heap_until(i184, i184+7) == i184+7);
+    assert(std::is_heap_until(i185, i185+7) == i185+6);
+    assert(std::is_heap_until(i186, i186+7) == i186+5);
+    assert(std::is_heap_until(i187, i187+7) == i187+5);
+    assert(std::is_heap_until(i188, i188+7) == i188+4);
+    assert(std::is_heap_until(i189, i189+7) == i189+4);
+    assert(std::is_heap_until(i190, i190+7) == i190+4);
+    assert(std::is_heap_until(i191, i191+7) == i191+4);
+    assert(std::is_heap_until(i192, i192+7) == i192+3);
+    assert(std::is_heap_until(i193, i193+7) == i193+3);
+    assert(std::is_heap_until(i194, i194+7) == i194+3);
+    assert(std::is_heap_until(i195, i195+7) == i195+3);
+    assert(std::is_heap_until(i196, i196+7) == i196+3);
+    assert(std::is_heap_until(i197, i197+7) == i197+3);
+    assert(std::is_heap_until(i198, i198+7) == i198+3);
+    assert(std::is_heap_until(i199, i199+7) == i199+3);
+    assert(std::is_heap_until(i200, i200+7) == i200+7);
+    assert(std::is_heap_until(i201, i201+7) == i201+7);
+    assert(std::is_heap_until(i202, i202+7) == i202+7);
+    assert(std::is_heap_until(i203, i203+7) == i203+7);
+    assert(std::is_heap_until(i204, i204+7) == i204+4);
+    assert(std::is_heap_until(i205, i205+7) == i205+4);
+    assert(std::is_heap_until(i206, i206+7) == i206+4);
+    assert(std::is_heap_until(i207, i207+7) == i207+4);
+    assert(std::is_heap_until(i208, i208+7) == i208+3);
+    assert(std::is_heap_until(i209, i209+7) == i209+3);
+    assert(std::is_heap_until(i210, i210+7) == i210+3);
+    assert(std::is_heap_until(i211, i211+7) == i211+3);
+    assert(std::is_heap_until(i212, i212+7) == i212+3);
+    assert(std::is_heap_until(i213, i213+7) == i213+3);
+    assert(std::is_heap_until(i214, i214+7) == i214+3);
+    assert(std::is_heap_until(i215, i215+7) == i215+3);
+    assert(std::is_heap_until(i216, i216+7) == i216+7);
+    assert(std::is_heap_until(i217, i217+7) == i217+6);
+    assert(std::is_heap_until(i218, i218+7) == i218+5);
+    assert(std::is_heap_until(i219, i219+7) == i219+5);
+    assert(std::is_heap_until(i220, i220+7) == i220+7);
+    assert(std::is_heap_until(i221, i221+7) == i221+6);
+    assert(std::is_heap_until(i222, i222+7) == i222+5);
+    assert(std::is_heap_until(i223, i223+7) == i223+5);
+    assert(std::is_heap_until(i224, i224+7) == i224+7);
+    assert(std::is_heap_until(i225, i225+7) == i225+6);
+    assert(std::is_heap_until(i226, i226+7) == i226+5);
+    assert(std::is_heap_until(i227, i227+7) == i227+5);
+    assert(std::is_heap_until(i228, i228+7) == i228+7);
+    assert(std::is_heap_until(i229, i229+7) == i229+6);
+    assert(std::is_heap_until(i230, i230+7) == i230+5);
+    assert(std::is_heap_until(i231, i231+7) == i231+5);
+    assert(std::is_heap_until(i232, i232+7) == i232+7);
+    assert(std::is_heap_until(i233, i233+7) == i233+7);
+    assert(std::is_heap_until(i234, i234+7) == i234+7);
+    assert(std::is_heap_until(i235, i235+7) == i235+7);
+    assert(std::is_heap_until(i236, i236+7) == i236+7);
+    assert(std::is_heap_until(i237, i237+7) == i237+7);
+    assert(std::is_heap_until(i238, i238+7) == i238+7);
+    assert(std::is_heap_until(i239, i239+7) == i239+7);
+    assert(std::is_heap_until(i240, i240+7) == i240+7);
+    assert(std::is_heap_until(i241, i241+7) == i241+7);
+    assert(std::is_heap_until(i242, i242+7) == i242+7);
+    assert(std::is_heap_until(i243, i243+7) == i243+7);
+    assert(std::is_heap_until(i244, i244+7) == i244+7);
+    assert(std::is_heap_until(i245, i245+7) == i245+7);
+    assert(std::is_heap_until(i246, i246+7) == i246+7);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
new file mode 100644
index 0000000..657c177
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/is.heap/is_heap_until_comp.pass.cpp
@@ -0,0 +1,522 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires CopyConstructible<Compare>
+//   Iter
+//   is_heap_until(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+void test()
+{
+    int i1[] = {0, 0};
+    assert(std::is_heap_until(i1, i1, std::greater<int>()) == i1);
+    assert(std::is_heap_until(i1, i1+1, std::greater<int>()) == i1+1);
+    int i2[] = {0, 1};
+    int i3[] = {1, 0};
+    assert(std::is_heap_until(i1, i1+2, std::greater<int>()) == i1+2);
+    assert(std::is_heap_until(i2, i2+2, std::greater<int>()) == i2+2);
+    assert(std::is_heap_until(i3, i3+2, std::greater<int>()) == i3+1);
+    int i4[] = {0, 0, 0};
+    int i5[] = {0, 0, 1};
+    int i6[] = {0, 1, 0};
+    int i7[] = {0, 1, 1};
+    int i8[] = {1, 0, 0};
+    int i9[] = {1, 0, 1};
+    int i10[] = {1, 1, 0};
+    assert(std::is_heap_until(i4, i4+3, std::greater<int>()) == i4+3);
+    assert(std::is_heap_until(i5, i5+3, std::greater<int>()) == i5+3);
+    assert(std::is_heap_until(i6, i6+3, std::greater<int>()) == i6+3);
+    assert(std::is_heap_until(i7, i7+3, std::greater<int>()) == i7+3);
+    assert(std::is_heap_until(i8, i8+3, std::greater<int>()) == i8+1);
+    assert(std::is_heap_until(i9, i9+3, std::greater<int>()) == i9+1);
+    assert(std::is_heap_until(i10, i10+3, std::greater<int>()) == i10+2);
+    int i11[] = {0, 0, 0, 0};
+    int i12[] = {0, 0, 0, 1};
+    int i13[] = {0, 0, 1, 0};
+    int i14[] = {0, 0, 1, 1};
+    int i15[] = {0, 1, 0, 0};
+    int i16[] = {0, 1, 0, 1};
+    int i17[] = {0, 1, 1, 0};
+    int i18[] = {0, 1, 1, 1};
+    int i19[] = {1, 0, 0, 0};
+    int i20[] = {1, 0, 0, 1};
+    int i21[] = {1, 0, 1, 0};
+    int i22[] = {1, 0, 1, 1};
+    int i23[] = {1, 1, 0, 0};
+    int i24[] = {1, 1, 0, 1};
+    int i25[] = {1, 1, 1, 0};
+    assert(std::is_heap_until(i11, i11+4, std::greater<int>()) == i11+4);
+    assert(std::is_heap_until(i12, i12+4, std::greater<int>()) == i12+4);
+    assert(std::is_heap_until(i13, i13+4, std::greater<int>()) == i13+4);
+    assert(std::is_heap_until(i14, i14+4, std::greater<int>()) == i14+4);
+    assert(std::is_heap_until(i15, i15+4, std::greater<int>()) == i15+3);
+    assert(std::is_heap_until(i16, i16+4, std::greater<int>()) == i16+4);
+    assert(std::is_heap_until(i17, i17+4, std::greater<int>()) == i17+3);
+    assert(std::is_heap_until(i18, i18+4, std::greater<int>()) == i18+4);
+    assert(std::is_heap_until(i19, i19+4, std::greater<int>()) == i19+1);
+    assert(std::is_heap_until(i20, i20+4, std::greater<int>()) == i20+1);
+    assert(std::is_heap_until(i21, i21+4, std::greater<int>()) == i21+1);
+    assert(std::is_heap_until(i22, i22+4, std::greater<int>()) == i22+1);
+    assert(std::is_heap_until(i23, i23+4, std::greater<int>()) == i23+2);
+    assert(std::is_heap_until(i24, i24+4, std::greater<int>()) == i24+2);
+    assert(std::is_heap_until(i25, i25+4, std::greater<int>()) == i25+3);
+    int i26[] = {0, 0, 0, 0, 0};
+    int i27[] = {0, 0, 0, 0, 1};
+    int i28[] = {0, 0, 0, 1, 0};
+    int i29[] = {0, 0, 0, 1, 1};
+    int i30[] = {0, 0, 1, 0, 0};
+    int i31[] = {0, 0, 1, 0, 1};
+    int i32[] = {0, 0, 1, 1, 0};
+    int i33[] = {0, 0, 1, 1, 1};
+    int i34[] = {0, 1, 0, 0, 0};
+    int i35[] = {0, 1, 0, 0, 1};
+    int i36[] = {0, 1, 0, 1, 0};
+    int i37[] = {0, 1, 0, 1, 1};
+    int i38[] = {0, 1, 1, 0, 0};
+    int i39[] = {0, 1, 1, 0, 1};
+    int i40[] = {0, 1, 1, 1, 0};
+    int i41[] = {0, 1, 1, 1, 1};
+    int i42[] = {1, 0, 0, 0, 0};
+    int i43[] = {1, 0, 0, 0, 1};
+    int i44[] = {1, 0, 0, 1, 0};
+    int i45[] = {1, 0, 0, 1, 1};
+    int i46[] = {1, 0, 1, 0, 0};
+    int i47[] = {1, 0, 1, 0, 1};
+    int i48[] = {1, 0, 1, 1, 0};
+    int i49[] = {1, 0, 1, 1, 1};
+    int i50[] = {1, 1, 0, 0, 0};
+    int i51[] = {1, 1, 0, 0, 1};
+    int i52[] = {1, 1, 0, 1, 0};
+    int i53[] = {1, 1, 0, 1, 1};
+    int i54[] = {1, 1, 1, 0, 0};
+    int i55[] = {1, 1, 1, 0, 1};
+    int i56[] = {1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i26, i26+5, std::greater<int>()) == i26+5);
+    assert(std::is_heap_until(i27, i27+5, std::greater<int>()) == i27+5);
+    assert(std::is_heap_until(i28, i28+5, std::greater<int>()) == i28+5);
+    assert(std::is_heap_until(i29, i29+5, std::greater<int>()) == i29+5);
+    assert(std::is_heap_until(i30, i30+5, std::greater<int>()) == i30+5);
+    assert(std::is_heap_until(i31, i31+5, std::greater<int>()) == i31+5);
+    assert(std::is_heap_until(i32, i32+5, std::greater<int>()) == i32+5);
+    assert(std::is_heap_until(i33, i33+5, std::greater<int>()) == i33+5);
+    assert(std::is_heap_until(i34, i34+5, std::greater<int>()) == i34+3);
+    assert(std::is_heap_until(i35, i35+5, std::greater<int>()) == i35+3);
+    assert(std::is_heap_until(i36, i36+5, std::greater<int>()) == i36+4);
+    assert(std::is_heap_until(i37, i37+5, std::greater<int>()) == i37+5);
+    assert(std::is_heap_until(i38, i38+5, std::greater<int>()) == i38+3);
+    assert(std::is_heap_until(i39, i39+5, std::greater<int>()) == i39+3);
+    assert(std::is_heap_until(i40, i40+5, std::greater<int>()) == i40+4);
+    assert(std::is_heap_until(i41, i41+5, std::greater<int>()) == i41+5);
+    assert(std::is_heap_until(i42, i42+5, std::greater<int>()) == i42+1);
+    assert(std::is_heap_until(i43, i43+5, std::greater<int>()) == i43+1);
+    assert(std::is_heap_until(i44, i44+5, std::greater<int>()) == i44+1);
+    assert(std::is_heap_until(i45, i45+5, std::greater<int>()) == i45+1);
+    assert(std::is_heap_until(i46, i46+5, std::greater<int>()) == i46+1);
+    assert(std::is_heap_until(i47, i47+5, std::greater<int>()) == i47+1);
+    assert(std::is_heap_until(i48, i48+5, std::greater<int>()) == i48+1);
+    assert(std::is_heap_until(i49, i49+5, std::greater<int>()) == i49+1);
+    assert(std::is_heap_until(i50, i50+5, std::greater<int>()) == i50+2);
+    assert(std::is_heap_until(i51, i51+5, std::greater<int>()) == i51+2);
+    assert(std::is_heap_until(i52, i52+5, std::greater<int>()) == i52+2);
+    assert(std::is_heap_until(i53, i53+5, std::greater<int>()) == i53+2);
+    assert(std::is_heap_until(i54, i54+5, std::greater<int>()) == i54+3);
+    assert(std::is_heap_until(i55, i55+5, std::greater<int>()) == i55+3);
+    assert(std::is_heap_until(i56, i56+5, std::greater<int>()) == i56+4);
+    int i57[] = {0, 0, 0, 0, 0, 0};
+    int i58[] = {0, 0, 0, 0, 0, 1};
+    int i59[] = {0, 0, 0, 0, 1, 0};
+    int i60[] = {0, 0, 0, 0, 1, 1};
+    int i61[] = {0, 0, 0, 1, 0, 0};
+    int i62[] = {0, 0, 0, 1, 0, 1};
+    int i63[] = {0, 0, 0, 1, 1, 0};
+    int i64[] = {0, 0, 0, 1, 1, 1};
+    int i65[] = {0, 0, 1, 0, 0, 0};
+    int i66[] = {0, 0, 1, 0, 0, 1};
+    int i67[] = {0, 0, 1, 0, 1, 0};
+    int i68[] = {0, 0, 1, 0, 1, 1};
+    int i69[] = {0, 0, 1, 1, 0, 0};
+    int i70[] = {0, 0, 1, 1, 0, 1};
+    int i71[] = {0, 0, 1, 1, 1, 0};
+    int i72[] = {0, 0, 1, 1, 1, 1};
+    int i73[] = {0, 1, 0, 0, 0, 0};
+    int i74[] = {0, 1, 0, 0, 0, 1};
+    int i75[] = {0, 1, 0, 0, 1, 0};
+    int i76[] = {0, 1, 0, 0, 1, 1};
+    int i77[] = {0, 1, 0, 1, 0, 0};
+    int i78[] = {0, 1, 0, 1, 0, 1};
+    int i79[] = {0, 1, 0, 1, 1, 0};
+    int i80[] = {0, 1, 0, 1, 1, 1};
+    int i81[] = {0, 1, 1, 0, 0, 0};
+    int i82[] = {0, 1, 1, 0, 0, 1};
+    int i83[] = {0, 1, 1, 0, 1, 0};
+    int i84[] = {0, 1, 1, 0, 1, 1};
+    int i85[] = {0, 1, 1, 1, 0, 0};
+    int i86[] = {0, 1, 1, 1, 0, 1};
+    int i87[] = {0, 1, 1, 1, 1, 0};
+    int i88[] = {0, 1, 1, 1, 1, 1};
+    int i89[] = {1, 0, 0, 0, 0, 0};
+    int i90[] = {1, 0, 0, 0, 0, 1};
+    int i91[] = {1, 0, 0, 0, 1, 0};
+    int i92[] = {1, 0, 0, 0, 1, 1};
+    int i93[] = {1, 0, 0, 1, 0, 0};
+    int i94[] = {1, 0, 0, 1, 0, 1};
+    int i95[] = {1, 0, 0, 1, 1, 0};
+    int i96[] = {1, 0, 0, 1, 1, 1};
+    int i97[] = {1, 0, 1, 0, 0, 0};
+    int i98[] = {1, 0, 1, 0, 0, 1};
+    int i99[] = {1, 0, 1, 0, 1, 0};
+    int i100[] = {1, 0, 1, 0, 1, 1};
+    int i101[] = {1, 0, 1, 1, 0, 0};
+    int i102[] = {1, 0, 1, 1, 0, 1};
+    int i103[] = {1, 0, 1, 1, 1, 0};
+    int i104[] = {1, 0, 1, 1, 1, 1};
+    int i105[] = {1, 1, 0, 0, 0, 0};
+    int i106[] = {1, 1, 0, 0, 0, 1};
+    int i107[] = {1, 1, 0, 0, 1, 0};
+    int i108[] = {1, 1, 0, 0, 1, 1};
+    int i109[] = {1, 1, 0, 1, 0, 0};
+    int i110[] = {1, 1, 0, 1, 0, 1};
+    int i111[] = {1, 1, 0, 1, 1, 0};
+    int i112[] = {1, 1, 0, 1, 1, 1};
+    int i113[] = {1, 1, 1, 0, 0, 0};
+    int i114[] = {1, 1, 1, 0, 0, 1};
+    int i115[] = {1, 1, 1, 0, 1, 0};
+    int i116[] = {1, 1, 1, 0, 1, 1};
+    int i117[] = {1, 1, 1, 1, 0, 0};
+    int i118[] = {1, 1, 1, 1, 0, 1};
+    int i119[] = {1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i57, i57+6, std::greater<int>()) == i57+6);
+    assert(std::is_heap_until(i58, i58+6, std::greater<int>()) == i58+6);
+    assert(std::is_heap_until(i59, i59+6, std::greater<int>()) == i59+6);
+    assert(std::is_heap_until(i60, i60+6, std::greater<int>()) == i60+6);
+    assert(std::is_heap_until(i61, i61+6, std::greater<int>()) == i61+6);
+    assert(std::is_heap_until(i62, i62+6, std::greater<int>()) == i62+6);
+    assert(std::is_heap_until(i63, i63+6, std::greater<int>()) == i63+6);
+    assert(std::is_heap_until(i64, i64+6, std::greater<int>()) == i64+6);
+    assert(std::is_heap_until(i65, i65+6, std::greater<int>()) == i65+5);
+    assert(std::is_heap_until(i66, i66+6, std::greater<int>()) == i66+6);
+    assert(std::is_heap_until(i67, i67+6, std::greater<int>()) == i67+5);
+    assert(std::is_heap_until(i68, i68+6, std::greater<int>()) == i68+6);
+    assert(std::is_heap_until(i69, i69+6, std::greater<int>()) == i69+5);
+    assert(std::is_heap_until(i70, i70+6, std::greater<int>()) == i70+6);
+    assert(std::is_heap_until(i71, i71+6, std::greater<int>()) == i71+5);
+    assert(std::is_heap_until(i72, i72+6, std::greater<int>()) == i72+6);
+    assert(std::is_heap_until(i73, i73+6, std::greater<int>()) == i73+3);
+    assert(std::is_heap_until(i74, i74+6, std::greater<int>()) == i74+3);
+    assert(std::is_heap_until(i75, i75+6, std::greater<int>()) == i75+3);
+    assert(std::is_heap_until(i76, i76+6, std::greater<int>()) == i76+3);
+    assert(std::is_heap_until(i77, i77+6, std::greater<int>()) == i77+4);
+    assert(std::is_heap_until(i78, i78+6, std::greater<int>()) == i78+4);
+    assert(std::is_heap_until(i79, i79+6, std::greater<int>()) == i79+6);
+    assert(std::is_heap_until(i80, i80+6, std::greater<int>()) == i80+6);
+    assert(std::is_heap_until(i81, i81+6, std::greater<int>()) == i81+3);
+    assert(std::is_heap_until(i82, i82+6, std::greater<int>()) == i82+3);
+    assert(std::is_heap_until(i83, i83+6, std::greater<int>()) == i83+3);
+    assert(std::is_heap_until(i84, i84+6, std::greater<int>()) == i84+3);
+    assert(std::is_heap_until(i85, i85+6, std::greater<int>()) == i85+4);
+    assert(std::is_heap_until(i86, i86+6, std::greater<int>()) == i86+4);
+    assert(std::is_heap_until(i87, i87+6, std::greater<int>()) == i87+5);
+    assert(std::is_heap_until(i88, i88+6, std::greater<int>()) == i88+6);
+    assert(std::is_heap_until(i89, i89+6, std::greater<int>()) == i89+1);
+    assert(std::is_heap_until(i90, i90+6, std::greater<int>()) == i90+1);
+    assert(std::is_heap_until(i91, i91+6, std::greater<int>()) == i91+1);
+    assert(std::is_heap_until(i92, i92+6, std::greater<int>()) == i92+1);
+    assert(std::is_heap_until(i93, i93+6, std::greater<int>()) == i93+1);
+    assert(std::is_heap_until(i94, i94+6, std::greater<int>()) == i94+1);
+    assert(std::is_heap_until(i95, i95+6, std::greater<int>()) == i95+1);
+    assert(std::is_heap_until(i96, i96+6, std::greater<int>()) == i96+1);
+    assert(std::is_heap_until(i97, i97+6, std::greater<int>()) == i97+1);
+    assert(std::is_heap_until(i98, i98+6, std::greater<int>()) == i98+1);
+    assert(std::is_heap_until(i99, i99+6, std::greater<int>()) == i99+1);
+    assert(std::is_heap_until(i100, i100+6, std::greater<int>()) == i100+1);
+    assert(std::is_heap_until(i101, i101+6, std::greater<int>()) == i101+1);
+    assert(std::is_heap_until(i102, i102+6, std::greater<int>()) == i102+1);
+    assert(std::is_heap_until(i103, i103+6, std::greater<int>()) == i103+1);
+    assert(std::is_heap_until(i104, i104+6, std::greater<int>()) == i104+1);
+    assert(std::is_heap_until(i105, i105+6, std::greater<int>()) == i105+2);
+    assert(std::is_heap_until(i106, i106+6, std::greater<int>()) == i106+2);
+    assert(std::is_heap_until(i107, i107+6, std::greater<int>()) == i107+2);
+    assert(std::is_heap_until(i108, i108+6, std::greater<int>()) == i108+2);
+    assert(std::is_heap_until(i109, i109+6, std::greater<int>()) == i109+2);
+    assert(std::is_heap_until(i110, i110+6, std::greater<int>()) == i110+2);
+    assert(std::is_heap_until(i111, i111+6, std::greater<int>()) == i111+2);
+    assert(std::is_heap_until(i112, i112+6, std::greater<int>()) == i112+2);
+    assert(std::is_heap_until(i113, i113+6, std::greater<int>()) == i113+3);
+    assert(std::is_heap_until(i114, i114+6, std::greater<int>()) == i114+3);
+    assert(std::is_heap_until(i115, i115+6, std::greater<int>()) == i115+3);
+    assert(std::is_heap_until(i116, i116+6, std::greater<int>()) == i116+3);
+    assert(std::is_heap_until(i117, i117+6, std::greater<int>()) == i117+4);
+    assert(std::is_heap_until(i118, i118+6, std::greater<int>()) == i118+4);
+    assert(std::is_heap_until(i119, i119+6, std::greater<int>()) == i119+5);
+    int i120[] = {0, 0, 0, 0, 0, 0, 0};
+    int i121[] = {0, 0, 0, 0, 0, 0, 1};
+    int i122[] = {0, 0, 0, 0, 0, 1, 0};
+    int i123[] = {0, 0, 0, 0, 0, 1, 1};
+    int i124[] = {0, 0, 0, 0, 1, 0, 0};
+    int i125[] = {0, 0, 0, 0, 1, 0, 1};
+    int i126[] = {0, 0, 0, 0, 1, 1, 0};
+    int i127[] = {0, 0, 0, 0, 1, 1, 1};
+    int i128[] = {0, 0, 0, 1, 0, 0, 0};
+    int i129[] = {0, 0, 0, 1, 0, 0, 1};
+    int i130[] = {0, 0, 0, 1, 0, 1, 0};
+    int i131[] = {0, 0, 0, 1, 0, 1, 1};
+    int i132[] = {0, 0, 0, 1, 1, 0, 0};
+    int i133[] = {0, 0, 0, 1, 1, 0, 1};
+    int i134[] = {0, 0, 0, 1, 1, 1, 0};
+    int i135[] = {0, 0, 0, 1, 1, 1, 1};
+    int i136[] = {0, 0, 1, 0, 0, 0, 0};
+    int i137[] = {0, 0, 1, 0, 0, 0, 1};
+    int i138[] = {0, 0, 1, 0, 0, 1, 0};
+    int i139[] = {0, 0, 1, 0, 0, 1, 1};
+    int i140[] = {0, 0, 1, 0, 1, 0, 0};
+    int i141[] = {0, 0, 1, 0, 1, 0, 1};
+    int i142[] = {0, 0, 1, 0, 1, 1, 0};
+    int i143[] = {0, 0, 1, 0, 1, 1, 1};
+    int i144[] = {0, 0, 1, 1, 0, 0, 0};
+    int i145[] = {0, 0, 1, 1, 0, 0, 1};
+    int i146[] = {0, 0, 1, 1, 0, 1, 0};
+    int i147[] = {0, 0, 1, 1, 0, 1, 1};
+    int i148[] = {0, 0, 1, 1, 1, 0, 0};
+    int i149[] = {0, 0, 1, 1, 1, 0, 1};
+    int i150[] = {0, 0, 1, 1, 1, 1, 0};
+    int i151[] = {0, 0, 1, 1, 1, 1, 1};
+    int i152[] = {0, 1, 0, 0, 0, 0, 0};
+    int i153[] = {0, 1, 0, 0, 0, 0, 1};
+    int i154[] = {0, 1, 0, 0, 0, 1, 0};
+    int i155[] = {0, 1, 0, 0, 0, 1, 1};
+    int i156[] = {0, 1, 0, 0, 1, 0, 0};
+    int i157[] = {0, 1, 0, 0, 1, 0, 1};
+    int i158[] = {0, 1, 0, 0, 1, 1, 0};
+    int i159[] = {0, 1, 0, 0, 1, 1, 1};
+    int i160[] = {0, 1, 0, 1, 0, 0, 0};
+    int i161[] = {0, 1, 0, 1, 0, 0, 1};
+    int i162[] = {0, 1, 0, 1, 0, 1, 0};
+    int i163[] = {0, 1, 0, 1, 0, 1, 1};
+    int i164[] = {0, 1, 0, 1, 1, 0, 0};
+    int i165[] = {0, 1, 0, 1, 1, 0, 1};
+    int i166[] = {0, 1, 0, 1, 1, 1, 0};
+    int i167[] = {0, 1, 0, 1, 1, 1, 1};
+    int i168[] = {0, 1, 1, 0, 0, 0, 0};
+    int i169[] = {0, 1, 1, 0, 0, 0, 1};
+    int i170[] = {0, 1, 1, 0, 0, 1, 0};
+    int i171[] = {0, 1, 1, 0, 0, 1, 1};
+    int i172[] = {0, 1, 1, 0, 1, 0, 0};
+    int i173[] = {0, 1, 1, 0, 1, 0, 1};
+    int i174[] = {0, 1, 1, 0, 1, 1, 0};
+    int i175[] = {0, 1, 1, 0, 1, 1, 1};
+    int i176[] = {0, 1, 1, 1, 0, 0, 0};
+    int i177[] = {0, 1, 1, 1, 0, 0, 1};
+    int i178[] = {0, 1, 1, 1, 0, 1, 0};
+    int i179[] = {0, 1, 1, 1, 0, 1, 1};
+    int i180[] = {0, 1, 1, 1, 1, 0, 0};
+    int i181[] = {0, 1, 1, 1, 1, 0, 1};
+    int i182[] = {0, 1, 1, 1, 1, 1, 0};
+    int i183[] = {0, 1, 1, 1, 1, 1, 1};
+    int i184[] = {1, 0, 0, 0, 0, 0, 0};
+    int i185[] = {1, 0, 0, 0, 0, 0, 1};
+    int i186[] = {1, 0, 0, 0, 0, 1, 0};
+    int i187[] = {1, 0, 0, 0, 0, 1, 1};
+    int i188[] = {1, 0, 0, 0, 1, 0, 0};
+    int i189[] = {1, 0, 0, 0, 1, 0, 1};
+    int i190[] = {1, 0, 0, 0, 1, 1, 0};
+    int i191[] = {1, 0, 0, 0, 1, 1, 1};
+    int i192[] = {1, 0, 0, 1, 0, 0, 0};
+    int i193[] = {1, 0, 0, 1, 0, 0, 1};
+    int i194[] = {1, 0, 0, 1, 0, 1, 0};
+    int i195[] = {1, 0, 0, 1, 0, 1, 1};
+    int i196[] = {1, 0, 0, 1, 1, 0, 0};
+    int i197[] = {1, 0, 0, 1, 1, 0, 1};
+    int i198[] = {1, 0, 0, 1, 1, 1, 0};
+    int i199[] = {1, 0, 0, 1, 1, 1, 1};
+    int i200[] = {1, 0, 1, 0, 0, 0, 0};
+    int i201[] = {1, 0, 1, 0, 0, 0, 1};
+    int i202[] = {1, 0, 1, 0, 0, 1, 0};
+    int i203[] = {1, 0, 1, 0, 0, 1, 1};
+    int i204[] = {1, 0, 1, 0, 1, 0, 0};
+    int i205[] = {1, 0, 1, 0, 1, 0, 1};
+    int i206[] = {1, 0, 1, 0, 1, 1, 0};
+    int i207[] = {1, 0, 1, 0, 1, 1, 1};
+    int i208[] = {1, 0, 1, 1, 0, 0, 0};
+    int i209[] = {1, 0, 1, 1, 0, 0, 1};
+    int i210[] = {1, 0, 1, 1, 0, 1, 0};
+    int i211[] = {1, 0, 1, 1, 0, 1, 1};
+    int i212[] = {1, 0, 1, 1, 1, 0, 0};
+    int i213[] = {1, 0, 1, 1, 1, 0, 1};
+    int i214[] = {1, 0, 1, 1, 1, 1, 0};
+    int i215[] = {1, 0, 1, 1, 1, 1, 1};
+    int i216[] = {1, 1, 0, 0, 0, 0, 0};
+    int i217[] = {1, 1, 0, 0, 0, 0, 1};
+    int i218[] = {1, 1, 0, 0, 0, 1, 0};
+    int i219[] = {1, 1, 0, 0, 0, 1, 1};
+    int i220[] = {1, 1, 0, 0, 1, 0, 0};
+    int i221[] = {1, 1, 0, 0, 1, 0, 1};
+    int i222[] = {1, 1, 0, 0, 1, 1, 0};
+    int i223[] = {1, 1, 0, 0, 1, 1, 1};
+    int i224[] = {1, 1, 0, 1, 0, 0, 0};
+    int i225[] = {1, 1, 0, 1, 0, 0, 1};
+    int i226[] = {1, 1, 0, 1, 0, 1, 0};
+    int i227[] = {1, 1, 0, 1, 0, 1, 1};
+    int i228[] = {1, 1, 0, 1, 1, 0, 0};
+    int i229[] = {1, 1, 0, 1, 1, 0, 1};
+    int i230[] = {1, 1, 0, 1, 1, 1, 0};
+    int i231[] = {1, 1, 0, 1, 1, 1, 1};
+    int i232[] = {1, 1, 1, 0, 0, 0, 0};
+    int i233[] = {1, 1, 1, 0, 0, 0, 1};
+    int i234[] = {1, 1, 1, 0, 0, 1, 0};
+    int i235[] = {1, 1, 1, 0, 0, 1, 1};
+    int i236[] = {1, 1, 1, 0, 1, 0, 0};
+    int i237[] = {1, 1, 1, 0, 1, 0, 1};
+    int i238[] = {1, 1, 1, 0, 1, 1, 0};
+    int i239[] = {1, 1, 1, 0, 1, 1, 1};
+    int i240[] = {1, 1, 1, 1, 0, 0, 0};
+    int i241[] = {1, 1, 1, 1, 0, 0, 1};
+    int i242[] = {1, 1, 1, 1, 0, 1, 0};
+    int i243[] = {1, 1, 1, 1, 0, 1, 1};
+    int i244[] = {1, 1, 1, 1, 1, 0, 0};
+    int i245[] = {1, 1, 1, 1, 1, 0, 1};
+    int i246[] = {1, 1, 1, 1, 1, 1, 0};
+    assert(std::is_heap_until(i120, i120+7, std::greater<int>()) == i120+7);
+    assert(std::is_heap_until(i121, i121+7, std::greater<int>()) == i121+7);
+    assert(std::is_heap_until(i122, i122+7, std::greater<int>()) == i122+7);
+    assert(std::is_heap_until(i123, i123+7, std::greater<int>()) == i123+7);
+    assert(std::is_heap_until(i124, i124+7, std::greater<int>()) == i124+7);
+    assert(std::is_heap_until(i125, i125+7, std::greater<int>()) == i125+7);
+    assert(std::is_heap_until(i126, i126+7, std::greater<int>()) == i126+7);
+    assert(std::is_heap_until(i127, i127+7, std::greater<int>()) == i127+7);
+    assert(std::is_heap_until(i128, i128+7, std::greater<int>()) == i128+7);
+    assert(std::is_heap_until(i129, i129+7, std::greater<int>()) == i129+7);
+    assert(std::is_heap_until(i130, i130+7, std::greater<int>()) == i130+7);
+    assert(std::is_heap_until(i131, i131+7, std::greater<int>()) == i131+7);
+    assert(std::is_heap_until(i132, i132+7, std::greater<int>()) == i132+7);
+    assert(std::is_heap_until(i133, i133+7, std::greater<int>()) == i133+7);
+    assert(std::is_heap_until(i134, i134+7, std::greater<int>()) == i134+7);
+    assert(std::is_heap_until(i135, i135+7, std::greater<int>()) == i135+7);
+    assert(std::is_heap_until(i136, i136+7, std::greater<int>()) == i136+5);
+    assert(std::is_heap_until(i137, i137+7, std::greater<int>()) == i137+5);
+    assert(std::is_heap_until(i138, i138+7, std::greater<int>()) == i138+6);
+    assert(std::is_heap_until(i139, i139+7, std::greater<int>()) == i139+7);
+    assert(std::is_heap_until(i140, i140+7, std::greater<int>()) == i140+5);
+    assert(std::is_heap_until(i141, i141+7, std::greater<int>()) == i141+5);
+    assert(std::is_heap_until(i142, i142+7, std::greater<int>()) == i142+6);
+    assert(std::is_heap_until(i143, i143+7, std::greater<int>()) == i143+7);
+    assert(std::is_heap_until(i144, i144+7, std::greater<int>()) == i144+5);
+    assert(std::is_heap_until(i145, i145+7, std::greater<int>()) == i145+5);
+    assert(std::is_heap_until(i146, i146+7, std::greater<int>()) == i146+6);
+    assert(std::is_heap_until(i147, i147+7, std::greater<int>()) == i147+7);
+    assert(std::is_heap_until(i148, i148+7, std::greater<int>()) == i148+5);
+    assert(std::is_heap_until(i149, i149+7, std::greater<int>()) == i149+5);
+    assert(std::is_heap_until(i150, i150+7, std::greater<int>()) == i150+6);
+    assert(std::is_heap_until(i151, i151+7, std::greater<int>()) == i151+7);
+    assert(std::is_heap_until(i152, i152+7, std::greater<int>()) == i152+3);
+    assert(std::is_heap_until(i153, i153+7, std::greater<int>()) == i153+3);
+    assert(std::is_heap_until(i154, i154+7, std::greater<int>()) == i154+3);
+    assert(std::is_heap_until(i155, i155+7, std::greater<int>()) == i155+3);
+    assert(std::is_heap_until(i156, i156+7, std::greater<int>()) == i156+3);
+    assert(std::is_heap_until(i157, i157+7, std::greater<int>()) == i157+3);
+    assert(std::is_heap_until(i158, i158+7, std::greater<int>()) == i158+3);
+    assert(std::is_heap_until(i159, i159+7, std::greater<int>()) == i159+3);
+    assert(std::is_heap_until(i160, i160+7, std::greater<int>()) == i160+4);
+    assert(std::is_heap_until(i161, i161+7, std::greater<int>()) == i161+4);
+    assert(std::is_heap_until(i162, i162+7, std::greater<int>()) == i162+4);
+    assert(std::is_heap_until(i163, i163+7, std::greater<int>()) == i163+4);
+    assert(std::is_heap_until(i164, i164+7, std::greater<int>()) == i164+7);
+    assert(std::is_heap_until(i165, i165+7, std::greater<int>()) == i165+7);
+    assert(std::is_heap_until(i166, i166+7, std::greater<int>()) == i166+7);
+    assert(std::is_heap_until(i167, i167+7, std::greater<int>()) == i167+7);
+    assert(std::is_heap_until(i168, i168+7, std::greater<int>()) == i168+3);
+    assert(std::is_heap_until(i169, i169+7, std::greater<int>()) == i169+3);
+    assert(std::is_heap_until(i170, i170+7, std::greater<int>()) == i170+3);
+    assert(std::is_heap_until(i171, i171+7, std::greater<int>()) == i171+3);
+    assert(std::is_heap_until(i172, i172+7, std::greater<int>()) == i172+3);
+    assert(std::is_heap_until(i173, i173+7, std::greater<int>()) == i173+3);
+    assert(std::is_heap_until(i174, i174+7, std::greater<int>()) == i174+3);
+    assert(std::is_heap_until(i175, i175+7, std::greater<int>()) == i175+3);
+    assert(std::is_heap_until(i176, i176+7, std::greater<int>()) == i176+4);
+    assert(std::is_heap_until(i177, i177+7, std::greater<int>()) == i177+4);
+    assert(std::is_heap_until(i178, i178+7, std::greater<int>()) == i178+4);
+    assert(std::is_heap_until(i179, i179+7, std::greater<int>()) == i179+4);
+    assert(std::is_heap_until(i180, i180+7, std::greater<int>()) == i180+5);
+    assert(std::is_heap_until(i181, i181+7, std::greater<int>()) == i181+5);
+    assert(std::is_heap_until(i182, i182+7, std::greater<int>()) == i182+6);
+    assert(std::is_heap_until(i183, i183+7, std::greater<int>()) == i183+7);
+    assert(std::is_heap_until(i184, i184+7, std::greater<int>()) == i184+1);
+    assert(std::is_heap_until(i185, i185+7, std::greater<int>()) == i185+1);
+    assert(std::is_heap_until(i186, i186+7, std::greater<int>()) == i186+1);
+    assert(std::is_heap_until(i187, i187+7, std::greater<int>()) == i187+1);
+    assert(std::is_heap_until(i188, i188+7, std::greater<int>()) == i188+1);
+    assert(std::is_heap_until(i189, i189+7, std::greater<int>()) == i189+1);
+    assert(std::is_heap_until(i190, i190+7, std::greater<int>()) == i190+1);
+    assert(std::is_heap_until(i191, i191+7, std::greater<int>()) == i191+1);
+    assert(std::is_heap_until(i192, i192+7, std::greater<int>()) == i192+1);
+    assert(std::is_heap_until(i193, i193+7, std::greater<int>()) == i193+1);
+    assert(std::is_heap_until(i194, i194+7, std::greater<int>()) == i194+1);
+    assert(std::is_heap_until(i195, i195+7, std::greater<int>()) == i195+1);
+    assert(std::is_heap_until(i196, i196+7, std::greater<int>()) == i196+1);
+    assert(std::is_heap_until(i197, i197+7, std::greater<int>()) == i197+1);
+    assert(std::is_heap_until(i198, i198+7, std::greater<int>()) == i198+1);
+    assert(std::is_heap_until(i199, i199+7, std::greater<int>()) == i199+1);
+    assert(std::is_heap_until(i200, i200+7, std::greater<int>()) == i200+1);
+    assert(std::is_heap_until(i201, i201+7, std::greater<int>()) == i201+1);
+    assert(std::is_heap_until(i202, i202+7, std::greater<int>()) == i202+1);
+    assert(std::is_heap_until(i203, i203+7, std::greater<int>()) == i203+1);
+    assert(std::is_heap_until(i204, i204+7, std::greater<int>()) == i204+1);
+    assert(std::is_heap_until(i205, i205+7, std::greater<int>()) == i205+1);
+    assert(std::is_heap_until(i206, i206+7, std::greater<int>()) == i206+1);
+    assert(std::is_heap_until(i207, i207+7, std::greater<int>()) == i207+1);
+    assert(std::is_heap_until(i208, i208+7, std::greater<int>()) == i208+1);
+    assert(std::is_heap_until(i209, i209+7, std::greater<int>()) == i209+1);
+    assert(std::is_heap_until(i210, i210+7, std::greater<int>()) == i210+1);
+    assert(std::is_heap_until(i211, i211+7, std::greater<int>()) == i211+1);
+    assert(std::is_heap_until(i212, i212+7, std::greater<int>()) == i212+1);
+    assert(std::is_heap_until(i213, i213+7, std::greater<int>()) == i213+1);
+    assert(std::is_heap_until(i214, i214+7, std::greater<int>()) == i214+1);
+    assert(std::is_heap_until(i215, i215+7, std::greater<int>()) == i215+1);
+    assert(std::is_heap_until(i216, i216+7, std::greater<int>()) == i216+2);
+    assert(std::is_heap_until(i217, i217+7, std::greater<int>()) == i217+2);
+    assert(std::is_heap_until(i218, i218+7, std::greater<int>()) == i218+2);
+    assert(std::is_heap_until(i219, i219+7, std::greater<int>()) == i219+2);
+    assert(std::is_heap_until(i220, i220+7, std::greater<int>()) == i220+2);
+    assert(std::is_heap_until(i221, i221+7, std::greater<int>()) == i221+2);
+    assert(std::is_heap_until(i222, i222+7, std::greater<int>()) == i222+2);
+    assert(std::is_heap_until(i223, i223+7, std::greater<int>()) == i223+2);
+    assert(std::is_heap_until(i224, i224+7, std::greater<int>()) == i224+2);
+    assert(std::is_heap_until(i225, i225+7, std::greater<int>()) == i225+2);
+    assert(std::is_heap_until(i226, i226+7, std::greater<int>()) == i226+2);
+    assert(std::is_heap_until(i227, i227+7, std::greater<int>()) == i227+2);
+    assert(std::is_heap_until(i228, i228+7, std::greater<int>()) == i228+2);
+    assert(std::is_heap_until(i229, i229+7, std::greater<int>()) == i229+2);
+    assert(std::is_heap_until(i230, i230+7, std::greater<int>()) == i230+2);
+    assert(std::is_heap_until(i231, i231+7, std::greater<int>()) == i231+2);
+    assert(std::is_heap_until(i232, i232+7, std::greater<int>()) == i232+3);
+    assert(std::is_heap_until(i233, i233+7, std::greater<int>()) == i233+3);
+    assert(std::is_heap_until(i234, i234+7, std::greater<int>()) == i234+3);
+    assert(std::is_heap_until(i235, i235+7, std::greater<int>()) == i235+3);
+    assert(std::is_heap_until(i236, i236+7, std::greater<int>()) == i236+3);
+    assert(std::is_heap_until(i237, i237+7, std::greater<int>()) == i237+3);
+    assert(std::is_heap_until(i238, i238+7, std::greater<int>()) == i238+3);
+    assert(std::is_heap_until(i239, i239+7, std::greater<int>()) == i239+3);
+    assert(std::is_heap_until(i240, i240+7, std::greater<int>()) == i240+4);
+    assert(std::is_heap_until(i241, i241+7, std::greater<int>()) == i241+4);
+    assert(std::is_heap_until(i242, i242+7, std::greater<int>()) == i242+4);
+    assert(std::is_heap_until(i243, i243+7, std::greater<int>()) == i243+4);
+    assert(std::is_heap_until(i244, i244+7, std::greater<int>()) == i244+5);
+    assert(std::is_heap_until(i245, i245+7, std::greater<int>()) == i245+5);
+    assert(std::is_heap_until(i246, i246+7, std::greater<int>()) == i246+6);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
new file mode 100644
index 0000000..51b9127
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type>
+//   void
+//   make_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N);
+    assert(std::is_heap(ia, ia+N));
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
new file mode 100644
index 0000000..7bbdd09
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/make.heap/make_heap_comp.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter> && CopyConstructible<Compare>
+//   void
+//   make_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "counting_predicates.hpp"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    {
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, std::greater<int>());
+    assert(std::is_heap(ia, ia+N, std::greater<int>()));
+    }
+
+    {
+    binary_counting_predicate<std::greater<int>, int, int> pred ((std::greater<int>()));
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, std::ref(pred));
+    assert(pred.count() <= 3*N);
+    assert(std::is_heap(ia, ia+N, pred));   
+    }
+
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+    test(10000);
+    test(100000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, indirect_less());
+    assert(std::is_heap(ia, ia+N, indirect_less()));
+    delete [] ia;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
new file mode 100644
index 0000000..823985d
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type>
+//   void
+//   pop_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N);
+    for (int i = N; i > 0; --i)
+    {
+        std::pop_heap(ia, ia+i);
+        assert(std::is_heap(ia, ia+i-1));
+    }
+    std::pop_heap(ia, ia);
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
new file mode 100644
index 0000000..1db4428
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/pop.heap/pop_heap_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter> && CopyConstructible<Compare>
+//   void
+//   pop_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, std::greater<int>());
+    for (int i = N; i > 0; --i)
+    {
+        std::pop_heap(ia, ia+i, std::greater<int>());
+        assert(std::is_heap(ia, ia+i-1, std::greater<int>()));
+    }
+    std::pop_heap(ia, ia, std::greater<int>());
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, indirect_less());
+    for (int i = N; i > 0; --i)
+    {
+        std::pop_heap(ia, ia+i, indirect_less());
+        assert(std::is_heap(ia, ia+i-1, indirect_less()));
+    }
+    delete [] ia;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
new file mode 100644
index 0000000..0fc50a8
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   void
+//   push_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    for (int i = 0; i <= N; ++i)
+    {
+        std::push_heap(ia, ia+i);
+        assert(std::is_heap(ia, ia+i));
+    }
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
new file mode 100644
index 0000000..217217b
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/push.heap/push_heap_comp.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   void
+//   push_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    for (int i = 0; i <= N; ++i)
+    {
+        std::push_heap(ia, ia+i, std::greater<int>());
+        assert(std::is_heap(ia, ia+i, std::greater<int>()));
+    }
+    delete [] ia;
+}
+
+int main()
+{
+    test(1000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    for (int i = 0; i <= N; ++i)
+    {
+        std::push_heap(ia, ia+i, indirect_less());
+        assert(std::is_heap(ia, ia+i, indirect_less()));
+    }
+    delete [] ia;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
new file mode 100644
index 0000000..4a08f11
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter> && LessThanComparable<Iter::value_type>
+//   void
+//   sort_heap(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N);
+    std::sort_heap(ia, ia+N);
+    assert(std::is_sorted(ia, ia+N));
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
new file mode 100644
index 0000000..7d3e2d5
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.heap.operations/sort.heap/sort_heap_comp.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter> && CopyConstructible<Compare>
+//   void
+//   sort_heap(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void test(unsigned N)
+{
+    int* ia = new int [N];
+    for (int i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, std::greater<int>());
+    std::sort_heap(ia, ia+N, std::greater<int>());
+    assert(std::is_sorted(ia, ia+N, std::greater<int>()));
+    delete [] ia;
+}
+
+int main()
+{
+    test(0);
+    test(1);
+    test(2);
+    test(3);
+    test(10);
+    test(1000);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    const int N = 1000;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int> [N];
+    for (int i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::make_heap(ia, ia+N, indirect_less());
+    std::sort_heap(ia, ia+N, indirect_less());
+    assert(std::is_sorted(ia, ia+N, indirect_less()));
+    delete [] ia;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp b/final/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
new file mode 100644
index 0000000..71dfeef
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+//   requires HasLess<Iter1::value_type, Iter2::value_type>
+//         && HasLess<Iter2::value_type, Iter1::value_type>
+//   bool
+//   lexicographical_compare(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 2, 3};
+    assert(!std::lexicographical_compare(Iter1(ia),   Iter1(ia+sa), Iter2(ib),   Iter2(ib+2)));
+    assert( std::lexicographical_compare(Iter1(ib),   Iter1(ib+2),  Iter2(ia),   Iter2(ia+sa)));
+    assert(!std::lexicographical_compare(Iter1(ia),   Iter1(ia+sa), Iter2(ib),   Iter2(ib+3)));
+    assert( std::lexicographical_compare(Iter1(ib),   Iter1(ib+3),  Iter2(ia),   Iter2(ia+sa)));
+    assert( std::lexicographical_compare(Iter1(ia),   Iter1(ia+sa), Iter2(ib+1), Iter2(ib+3)));
+    assert(!std::lexicographical_compare(Iter1(ib+1), Iter1(ib+3),  Iter2(ia),   Iter2(ia+sa)));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp
new file mode 100644
index 0000000..c185156
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.lex.comparison/lexicographical_compare_comp.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, CopyConstructible Compare>
+//   requires Predicate<Compare, Iter1::value_type, Iter2::value_type>
+//         && Predicate<Compare, Iter2::value_type, Iter1::value_type>
+//   bool
+//   lexicographical_compare(Iter1 first1, Iter1 last1,
+//                           Iter2 first2, Iter2 last2, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {1, 2, 3};
+    typedef std::greater<int> C;
+    C c;
+    assert(!std::lexicographical_compare(Iter1(ia),   Iter1(ia+sa), Iter2(ib),   Iter2(ib+2),  c));
+    assert( std::lexicographical_compare(Iter1(ib),   Iter1(ib+2),  Iter2(ia),   Iter2(ia+sa), c));
+    assert(!std::lexicographical_compare(Iter1(ia),   Iter1(ia+sa), Iter2(ib),   Iter2(ib+3),  c));
+    assert( std::lexicographical_compare(Iter1(ib),   Iter1(ib+3),  Iter2(ia),   Iter2(ia+sa), c));
+    assert(!std::lexicographical_compare(Iter1(ia),   Iter1(ia+sa), Iter2(ib+1), Iter2(ib+3),  c));
+    assert( std::lexicographical_compare(Iter1(ib+1), Iter1(ib+3),  Iter2(ia),   Iter2(ia+sa), c));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp b/final/test/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
new file mode 100644
index 0000000..01db088
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   void
+//   inplace_merge(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(M <= N);
+    int* ia = new int[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::sort(ia, ia+M);
+    std::sort(ia+M, ia+N);
+    std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N));
+    if(N > 0)
+    {
+        assert(ia[0] == 0);
+        assert(ia[N-1] == N-1);
+        assert(std::is_sorted(ia, ia+N));
+    }
+    delete [] ia;
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    test_one<Iter>(N, 0);
+    test_one<Iter>(N, N/4);
+    test_one<Iter>(N, N/2);
+    test_one<Iter>(N, 3*N/4);
+    test_one<Iter>(N, N);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_one<Iter>(0, 0);
+    test_one<Iter>(1, 0);
+    test_one<Iter>(1, 1);
+    test_one<Iter>(2, 0);
+    test_one<Iter>(2, 1);
+    test_one<Iter>(2, 2);
+    test_one<Iter>(3, 0);
+    test_one<Iter>(3, 1);
+    test_one<Iter>(3, 2);
+    test_one<Iter>(3, 3);
+    test<Iter>(4);
+    test<Iter>(100);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
new file mode 100644
index 0000000..8da8dfe
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Compare>
+//   void
+//   inplace_merge(Iter first, Iter middle, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(M <= N);
+    int* ia = new int[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = i;
+    std::random_shuffle(ia, ia+N);
+    std::sort(ia, ia+M, std::greater<int>());
+    std::sort(ia+M, ia+N, std::greater<int>());
+    std::inplace_merge(Iter(ia), Iter(ia+M), Iter(ia+N), std::greater<int>());
+    if(N > 0)
+    {
+        assert(ia[0] == N-1);
+        assert(ia[N-1] == 0);
+        assert(std::is_sorted(ia, ia+N, std::greater<int>()));
+    }
+    delete [] ia;
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    test_one<Iter>(N, 0);
+    test_one<Iter>(N, N/4);
+    test_one<Iter>(N, N/2);
+    test_one<Iter>(N, 3*N/4);
+    test_one<Iter>(N, N);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_one<Iter>(0, 0);
+    test_one<Iter>(1, 0);
+    test_one<Iter>(1, 1);
+    test_one<Iter>(2, 0);
+    test_one<Iter>(2, 1);
+    test_one<Iter>(2, 2);
+    test_one<Iter>(3, 0);
+    test_one<Iter>(3, 1);
+    test_one<Iter>(3, 2);
+    test_one<Iter>(3, 3);
+    test<Iter>(4);
+    test<Iter>(100);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    unsigned N = 100;
+    unsigned M = 50;
+    std::unique_ptr<int>* ia = new std::unique_ptr<int>[N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i].reset(new int(i));
+    std::random_shuffle(ia, ia+N);
+    std::sort(ia, ia+M, indirect_less());
+    std::sort(ia+M, ia+N, indirect_less());
+    std::inplace_merge(ia, ia+M, ia+N, indirect_less());
+    if(N > 0)
+    {
+        assert(*ia[0] == 0);
+        assert(*ia[N-1] == N-1);
+        assert(std::is_sorted(ia, ia+N, indirect_less()));
+    }
+    delete [] ia;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.merge/merge.pass.cpp b/final/test/algorithms/alg.sorting/alg.merge/merge.pass.cpp
new file mode 100644
index 0000000..be19710
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.merge/merge.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && HasLess<InIter2::value_type, InIter1::value_type>
+//   OutIter
+//   merge(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+    {
+    unsigned N = 100000;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = 2*i;
+    for (unsigned i = 0; i < N; ++i)
+        ib[i] = 2*i+1;
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic));
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 0);
+    assert(ic[2*N-1] == 2*N-1);
+    assert(std::is_sorted(ic, ic+2*N));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+    {
+    unsigned N = 100;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < 2*N; ++i)
+        ic[i] = i;
+    std::random_shuffle(ic, ic+2*N);
+    std::copy(ic, ic+N, ia);
+    std::copy(ic+N, ic+2*N, ib);
+    std::sort(ia, ia+N);
+    std::sort(ib, ib+N);
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic));
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 0);
+    assert(ic[2*N-1] == 2*N-1);
+    assert(std::is_sorted(ic, ic+2*N));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
new file mode 100644
index 0000000..8ef6d54
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.merge/merge_comp.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+//          Predicate<auto, InIter2::value_type, InIter1::value_type> Compare>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && CopyConstructible<Compare>
+//   OutIter
+//   merge(InIter1 first1, InIter1 last1,
+//         InIter2 first2, InIter2 last2, OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter1, class InIter2, class OutIter>
+void
+test()
+{
+    {
+    unsigned N = 100000;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < N; ++i)
+        ia[i] = 2*i;
+    for (unsigned i = 0; i < N; ++i)
+        ib[i] = 2*i+1;
+    std::reverse(ia, ia+N);
+    std::reverse(ib, ib+N);
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater<int>());
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 2*N-1);
+    assert(ic[2*N-1] == 0);
+    assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+    {
+    unsigned N = 100;
+    int* ia = new int[N];
+    int* ib = new int[N];
+    int* ic = new int[2*N];
+    for (unsigned i = 0; i < 2*N; ++i)
+        ic[i] = i;
+    std::random_shuffle(ic, ic+2*N);
+    std::copy(ic, ic+N, ia);
+    std::copy(ic+N, ic+2*N, ib);
+    std::sort(ia, ia+N, std::greater<int>());
+    std::sort(ib, ib+N, std::greater<int>());
+    OutIter r = std::merge(InIter1(ia), InIter1(ia+N),
+                           InIter2(ib), InIter2(ib+N), OutIter(ic), std::greater<int>());
+    assert(base(r) == ic+2*N);
+    assert(ic[0] == 2*N-1);
+    assert(ic[2*N-1] == 0);
+    assert(std::is_sorted(ic, ic+2*N, std::greater<int>()));
+    delete [] ic;
+    delete [] ib;
+    delete [] ia;
+    }
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/max.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/max.pass.cpp
new file mode 100644
index 0000000..c560c22
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/max.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+//   const T&
+//   max(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x)
+{
+    assert(&std::max(a, b) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, x);
+    test(y, x, y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, y);
+    test(y, x, y);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, x);
+    test(y, x, x);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr int x = 1;
+    constexpr int y = 0;
+    static_assert(std::max(x, y) == x, "" );
+    static_assert(std::max(y, x) == x, "" );
+    }
+#endif
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp
new file mode 100644
index 0000000..95241af
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/max_comp.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare>
+//   requires !SameType<T, Compare> && CopyConstructible<Compare>
+//   const T&
+//   max(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x)
+{
+    assert(&std::max(a, b, c) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), x);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, std::greater<int>(), y);
+    test(y, x, std::greater<int>(), y);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr int x = 1;
+    constexpr int y = 0;
+    static_assert(std::max(x, y, std::greater<int>()) == y, "" );
+    static_assert(std::max(y, x, std::greater<int>()) == y, "" );
+    }
+#endif
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
new file mode 100644
index 0000000..2788b19
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/max_element.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   Iter
+//   max_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::max_element(first, last);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!(*i < *j));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N));
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
new file mode 100644
index 0000000..74e9fe6
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/max_element_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires CopyConstructible<Compare>
+//   Iter
+//   max_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::max_element(first, last, std::greater<int>());
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!std::greater<int>()(*i, *j));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N));
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+template <class Iter, class Pred>
+void test_eq0(Iter first, Iter last, Pred p)
+{
+    assert(first == std::max_element(first, last, p));
+}
+
+void test_eq()
+{
+    const size_t N = 10;
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = 10; // all the same
+    test_eq0(a, a+N, std::less<int>());
+    test_eq0(a, a+N, std::greater<int>());
+    delete [] a;
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+    test_eq();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp
new file mode 100644
index 0000000..0438412
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/max_init_list.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class T>
+//   T
+//   max(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    int i = std::max({2, 3, 1});
+    assert(i == 3);
+    i = std::max({2, 1, 3});
+    assert(i == 3);
+    i = std::max({3, 1, 2});
+    assert(i == 3);
+    i = std::max({3, 2, 1});
+    assert(i == 3);
+    i = std::max({1, 2, 3});
+    assert(i == 3);
+    i = std::max({1, 3, 2});
+    assert(i == 3);
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert(std::max({1, 3, 2}) == 3, "");
+    static_assert(std::max({2, 1, 3}) == 3, "");
+    static_assert(std::max({3, 2, 1}) == 3, "");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp
new file mode 100644
index 0000000..4dd47a7
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/max_init_list_comp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare>
+//   T
+//   max(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    int i = std::max({2, 3, 1}, std::greater<int>());
+    assert(i == 1);
+    i = std::max({2, 1, 3}, std::greater<int>());
+    assert(i == 1);
+    i = std::max({3, 1, 2}, std::greater<int>());
+    assert(i == 1);
+    i = std::max({3, 2, 1}, std::greater<int>());
+    assert(i == 1);
+    i = std::max({1, 2, 3}, std::greater<int>());
+    assert(i == 1);
+    i = std::max({1, 3, 2}, std::greater<int>());
+    assert(i == 1);
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert(std::max({1, 3, 2}, std::greater<int>()) == 1, "");
+    static_assert(std::max({2, 1, 3}, std::greater<int>()) == 1, "");
+    static_assert(std::max({3, 2, 1}, std::greater<int>()) == 1, "");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/min.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/min.pass.cpp
new file mode 100644
index 0000000..bbbd97b
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/min.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+//   const T&
+//   min(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x)
+{
+    assert(&std::min(a, b) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, x);
+    test(y, x, y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, x);
+    test(y, x, x);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, y);
+    test(y, x, y);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr int x = 1;
+    constexpr int y = 0;
+    static_assert(std::min(x, y) == y, "" );
+    static_assert(std::min(y, x) == y, "" );
+    }
+#endif
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp
new file mode 100644
index 0000000..4ef705e
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/min_comp.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare>
+//   requires !SameType<T, Compare> && CopyConstructible<Compare>
+//   const T&
+//   min(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x)
+{
+    assert(&std::min(a, b, c) == &x);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), y);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, std::greater<int>(), y);
+    test(y, x, std::greater<int>(), y);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, std::greater<int>(), x);
+    test(y, x, std::greater<int>(), x);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr int x = 1;
+    constexpr int y = 0;
+    static_assert(std::min(x, y, std::greater<int>()) == x, "" );
+    static_assert(std::min(y, x, std::greater<int>()) == x, "" );
+    }
+#endif
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
new file mode 100644
index 0000000..fd41f7a
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/min_element.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   Iter
+//   min_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::min_element(first, last);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!(*j < *i));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N));
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
new file mode 100644
index 0000000..2b5fdb1
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/min_element_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires CopyConstructible<Compare>
+//   Iter
+//   min_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    Iter i = std::min_element(first, last, std::greater<int>());
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+            assert(!std::greater<int>()(*j, *i));
+    }
+    else
+        assert(i == last);
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N));
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+}
+
+template <class Iter, class Pred>
+void test_eq0(Iter first, Iter last, Pred p)
+{
+    assert(first == std::min_element(first, last, p));
+}
+
+void test_eq()
+{
+    const size_t N = 10;
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = 10; // all the same
+    test_eq0(a, a+N, std::less<int>());
+    test_eq0(a, a+N, std::greater<int>());
+    delete [] a;
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+    test_eq();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp
new file mode 100644
index 0000000..eed4ebd
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/min_init_list.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T>
+//   T
+//   min(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    int i = std::min({2, 3, 1});
+    assert(i == 1);
+    i = std::min({2, 1, 3});
+    assert(i == 1);
+    i = std::min({3, 1, 2});
+    assert(i == 1);
+    i = std::min({3, 2, 1});
+    assert(i == 1);
+    i = std::min({1, 2, 3});
+    assert(i == 1);
+    i = std::min({1, 3, 2});
+    assert(i == 1);
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert(std::min({1, 3, 2}) == 1, "");
+    static_assert(std::min({2, 1, 3}) == 1, "");
+    static_assert(std::min({3, 2, 1}) == 1, "");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp
new file mode 100644
index 0000000..5e0301b
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/min_init_list_comp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare>
+//   T
+//   min(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    int i = std::min({2, 3, 1}, std::greater<int>());
+    assert(i == 3);
+    i = std::min({2, 1, 3}, std::greater<int>());
+    assert(i == 3);
+    i = std::min({3, 1, 2}, std::greater<int>());
+    assert(i == 3);
+    i = std::min({3, 2, 1}, std::greater<int>());
+    assert(i == 3);
+    i = std::min({1, 2, 3}, std::greater<int>());
+    assert(i == 3);
+    i = std::min({1, 3, 2}, std::greater<int>());
+    assert(i == 3);
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert(std::min({1, 3, 2}, std::greater<int>()) == 3, "");
+    static_assert(std::min({2, 1, 3}, std::greater<int>()) == 3, "");
+    static_assert(std::min({3, 2, 1}, std::greater<int>()) == 3, "");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
new file mode 100644
index 0000000..6ac972a
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/minmax.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<LessThanComparable T>
+//   pair<const T&, const T&>
+//   minmax(const T& a, const T& b);
+
+#include <algorithm>
+#include <cassert>
+
+template <class T>
+void
+test(const T& a, const T& b, const T& x, const T& y)
+{
+    std::pair<const T&, const T&> p = std::minmax(a, b);
+    assert(&p.first == &x);
+    assert(&p.second == &y);
+}
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, x, y);
+    test(y, x, y, x);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, x, y);
+    test(y, x, x, y);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, y, x);
+    test(y, x, y, x);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+//  Note that you can't take a reference to a local var, since 
+//  its address is not a compile-time constant.
+    constexpr static int x = 1;
+    constexpr static int y = 0;
+    constexpr auto p1 = std::minmax (x, y);
+    static_assert(p1.first  == y, "");
+    static_assert(p1.second == x, "");
+    constexpr auto p2 = std::minmax (y, x);
+    static_assert(p2.first  == y, "");
+    static_assert(p2.second == x, "");
+    }
+#endif
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
new file mode 100644
index 0000000..771c8f8
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/minmax_comp.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, StrictWeakOrder<auto, T> Compare>
+//   requires !SameType<T, Compare> && CopyConstructible<Compare>
+//   pair<const T&, const T&>
+//   minmax(const T& a, const T& b, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+template <class T, class C>
+void
+test(const T& a, const T& b, C c, const T& x, const T& y)
+{
+    std::pair<const T&, const T&> p = std::minmax(a, b, c);
+    assert(&p.first == &x);
+    assert(&p.second == &y);
+}
+
+
+int main()
+{
+    {
+    int x = 0;
+    int y = 0;
+    test(x, y, std::greater<int>(), x, y);
+    test(y, x, std::greater<int>(), y, x);
+    }
+    {
+    int x = 0;
+    int y = 1;
+    test(x, y, std::greater<int>(), y, x);
+    test(y, x, std::greater<int>(), y, x);
+    }
+    {
+    int x = 1;
+    int y = 0;
+    test(x, y, std::greater<int>(), x, y);
+    test(y, x, std::greater<int>(), x, y);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+//  Note that you can't take a reference to a local var, since 
+//  its address is not a compile-time constant.
+    constexpr static int x = 1;
+    constexpr static int y = 0;
+    constexpr auto p1 = std::minmax(x, y, std::greater<>());
+    static_assert(p1.first  == x, "");
+    static_assert(p1.second == y, "");
+    constexpr auto p2 = std::minmax(y, x, std::greater<>());
+    static_assert(p2.first  == x, "");
+    static_assert(p2.second == y, "");
+    }
+#endif
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
new file mode 100644
index 0000000..6cdb87d
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/minmax_element.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   pair<Iter, Iter>
+//   minmax_element(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    std::pair<Iter, Iter> p = std::minmax_element(first, last);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+        {
+            assert(!(*j < *p.first));
+            assert(!(*p.second < *j));
+        }
+    }
+    else
+    {
+        assert(p.first == last);
+        assert(p.second == last);
+    }
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N));
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+    {
+    const unsigned N = 100;
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = 5;
+    std::random_shuffle(a, a+N);
+    std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N));
+    assert(base(p.first) == a);
+    assert(base(p.second) == a+N-1);
+    delete [] a;
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
new file mode 100644
index 0000000..cc0e66e
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/minmax_element_comp.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires CopyConstructible<Compare>
+//   pair<Iter, Iter>
+//   minmax_element(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last)
+{
+    typedef std::greater<int> Compare;
+    Compare comp;
+    std::pair<Iter, Iter> p = std::minmax_element(first, last, comp);
+    if (first != last)
+    {
+        for (Iter j = first; j != last; ++j)
+        {
+            assert(!comp(*j, *p.first));
+            assert(!comp(*p.second, *j));
+        }
+    }
+    else
+    {
+        assert(p.first == last);
+        assert(p.second == last);
+    }
+}
+
+template <class Iter>
+void
+test(unsigned N)
+{
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = i;
+    std::random_shuffle(a, a+N);
+    test(Iter(a), Iter(a+N));
+    delete [] a;
+}
+
+template <class Iter>
+void
+test()
+{
+    test<Iter>(0);
+    test<Iter>(1);
+    test<Iter>(2);
+    test<Iter>(3);
+    test<Iter>(10);
+    test<Iter>(1000);
+    {
+    const unsigned N = 100;
+    int* a = new int[N];
+    for (int i = 0; i < N; ++i)
+        a[i] = 5;
+    std::random_shuffle(a, a+N);
+    typedef std::greater<int> Compare;
+    Compare comp;
+    std::pair<Iter, Iter> p = std::minmax_element(Iter(a), Iter(a+N), comp);
+    assert(base(p.first) == a);
+    assert(base(p.second) == a+N-1);
+    delete [] a;
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp
new file mode 100644
index 0000000..0196d10
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/minmax_init_list.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T>
+//   pair<T, T>
+//   minmax(initializer_list<T> t);
+
+#include <algorithm>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3)));
+    assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3)));
+    assert((std::minmax({2, 1, 3}) == std::pair<int, int>(1, 3)));
+    assert((std::minmax({2, 3, 1}) == std::pair<int, int>(1, 3)));
+    assert((std::minmax({3, 1, 2}) == std::pair<int, int>(1, 3)));
+    assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3)));
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert((std::minmax({1, 2, 3}) == std::pair<int, int>(1, 3)), "");
+    static_assert((std::minmax({1, 3, 2}) == std::pair<int, int>(1, 3)), "");
+    static_assert((std::minmax({2, 1, 3}) == std::pair<int, int>(1, 3)), "");
+    static_assert((std::minmax({2, 3, 1}) == std::pair<int, int>(1, 3)), "");
+    static_assert((std::minmax({3, 1, 2}) == std::pair<int, int>(1, 3)), "");
+    static_assert((std::minmax({3, 2, 1}) == std::pair<int, int>(1, 3)), "");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
new file mode 100644
index 0000000..95a8c85
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<class T, class Compare>
+//   pair<T, T>
+//   minmax(initializer_list<T> t, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+    assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+    assert((std::minmax({2, 1, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+    assert((std::minmax({2, 3, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+    assert((std::minmax({3, 1, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+    assert((std::minmax({3, 2, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)));
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert((std::minmax({1, 2, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+    static_assert((std::minmax({1, 3, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+    static_assert((std::minmax({2, 1, 3}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+    static_assert((std::minmax({2, 3, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+    static_assert((std::minmax({3, 1, 2}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+    static_assert((std::minmax({3, 2, 1}, std::greater<int>()) == std::pair<int, int>(3, 1)), "");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp b/final/test/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
new file mode 100644
index 0000000..dc5564e
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.nth.element/nth_element.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   void
+//   nth_element(Iter first, Iter nth, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M < N);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::nth_element(array, array+M, array+N);
+    assert(array[M] == M);
+    std::nth_element(array, array+N, array+N); // begin, end, end
+    delete [] array;
+}
+
+void
+test(unsigned N)
+{
+    test_one(N, 0);
+    test_one(N, 1);
+    test_one(N, 2);
+    test_one(N, 3);
+    test_one(N, N/2-1);
+    test_one(N, N/2);
+    test_one(N, N/2+1);
+    test_one(N, N-3);
+    test_one(N, N-2);
+    test_one(N, N-1);
+}
+
+int main()
+{
+    int d = 0;
+    std::nth_element(&d, &d, &d);
+    assert(d == 0);
+    test(256);
+    test(257);
+    test(499);
+    test(500);
+    test(997);
+    test(1000);
+    test(1009);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
new file mode 100644
index 0000000..cf86590
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Compare>
+//   void
+//   nth_element(Iter first, Iter nth, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test_one(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M < N);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::nth_element(array, array+M, array+N, std::greater<int>());
+    assert(array[M] == N-M-1);
+    std::nth_element(array, array+N, array+N, std::greater<int>()); // begin, end, end
+    delete [] array;
+}
+
+void
+test(unsigned N)
+{
+    test_one(N, 0);
+    test_one(N, 1);
+    test_one(N, 2);
+    test_one(N, 3);
+    test_one(N, N/2-1);
+    test_one(N, N/2);
+    test_one(N, N/2+1);
+    test_one(N, N-3);
+    test_one(N, N-2);
+    test_one(N, N-1);
+}
+
+int main()
+{
+    int d = 0;
+    std::nth_element(&d, &d, &d);
+    assert(d == 0);
+    test(256);
+    test(257);
+    test(499);
+    test(500);
+    test(997);
+    test(1000);
+    test(1009);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::nth_element(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
+    assert(*v[v.size()/2] == v.size()/2);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp b/final/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp
new file mode 100644
index 0000000..fb58c71
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   bool
+//   next_permutation(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::next_permutation(Iter(ia), Iter(ia+e));
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e));
+                else
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp
new file mode 100644
index 0000000..8e87e9a
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.permutation.generators/next_permutation_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Compare>
+//   bool
+//   next_permutation(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    typedef std::greater<int> C;
+    int ia[] = {6, 5, 4, 3, 2, 1};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::next_permutation(Iter(ia), Iter(ia+e), C());
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e, C()));
+                else
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e, C()));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp b/final/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp
new file mode 100644
index 0000000..d2fa2cb
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   bool
+//   prev_permutation(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {6, 5, 4, 3, 2, 1};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::prev_permutation(Iter(ia), Iter(ia+e));
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e));
+                else
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp
new file mode 100644
index 0000000..51b7aa8
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.permutation.generators/prev_permutation_comp.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<BidirectionalIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Compare>
+//   bool
+//   prev_permutation(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#include <cstdio>
+
+int factorial(int x)
+{
+    int r = 1;
+    for (; x; --x)
+        r *= x;
+    return r;
+}
+
+template <class Iter>
+void
+test()
+{
+    typedef std::greater<int> C;
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int prev[sa];
+    for (int e = 0; e <= sa; ++e)
+    {
+        int count = 0;
+        bool x;
+        do
+        {
+            std::copy(ia, ia+e, prev);
+            x = std::prev_permutation(Iter(ia), Iter(ia+e), C());
+            if (e > 1)
+            {
+                if (x)
+                    assert(std::lexicographical_compare(ia, ia+e, prev, prev+e, C()));
+                else
+                    assert(std::lexicographical_compare(prev, prev+e, ia, ia+e, C()));
+            }
+            ++count;
+        } while (x);
+        assert(count == factorial(e));
+    }
+}
+
+int main()
+{
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
new file mode 100644
index 0000000..8db8177
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2>
+//   requires HasLess<Iter1::value_type, Iter2::value_type>
+//         && HasLess<Iter2::value_type, Iter1::value_type>
+//   bool
+//   includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int id[] = {3, 3, 3, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+
+    assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib)));
+    assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1)));
+    assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib)));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb)));
+    assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa)));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2)));
+    assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(ib+2)));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+1)));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+2)));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+3)));
+    assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4)));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
new file mode 100644
index 0000000..7e1aef4
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator Iter1, InputIterator Iter2, typename Compare>
+//   requires Predicate<Compare, Iter1::value_type, Iter2::value_type>
+//         && Predicate<Compare, Iter2::value_type, Iter1::value_type>
+//   bool
+//   includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4};
+    const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[] = {1, 2};
+    const unsigned sc = sizeof(ic)/sizeof(ic[0]);
+    int id[] = {3, 3, 3, 3};
+    const unsigned sd = sizeof(id)/sizeof(id[0]);
+
+    assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib), std::less<int>()));
+    assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+1), Iter2(ib), Iter2(ib), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), std::less<int>()));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(ib), Iter2(ib+sb), std::less<int>()));
+    assert(!std::includes(Iter1(ib), Iter1(ib+sb), Iter2(ia), Iter2(ia+sa), std::less<int>()));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+2), Iter2(ic), Iter2(ic+2), std::less<int>()));
+    assert(!std::includes(Iter1(ia), Iter1(ia+2), Iter2(ib), Iter2(ib+2), std::less<int>()));
+
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+1), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+2), std::less<int>()));
+    assert(std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+3), std::less<int>()));
+    assert(!std::includes(Iter1(ia), Iter1(ia+sa), Iter2(id), Iter2(id+4), std::less<int>()));
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp
new file mode 100644
index 0000000..c2c20c2
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && HasLess<InIter2::value_type, InIter1::value_type>
+//         && HasLess<InIter1::value_type, InIter2::value_type>
+//   OutIter
+//   set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                  OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_difference(Iter1(ia), Iter1(ia+sa),
+                                     Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    int irr[] = {6};
+    const int srr = sizeof(irr)/sizeof(irr[0]);
+    ce = std::set_difference(Iter1(ib), Iter1(ib+sb),
+                             Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == srr);
+    assert(std::lexicographical_compare(ic, base(ce), irr, irr+srr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp
new file mode 100644
index 0000000..2b5a6a9
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.difference/set_difference_comp.pass.cpp
@@ -0,0 +1,202 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+//          CopyConstructible Compare>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+//   OutIter
+//   set_difference(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                  OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_difference(Iter1(ia), Iter1(ia+sa),
+                                     Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    int irr[] = {6};
+    const int srr = sizeof(irr)/sizeof(irr[0]);
+    ce = std::set_difference(Iter1(ib), Iter1(ib+sb),
+                             Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == srr);
+    assert(std::lexicographical_compare(ic, base(ce), irr, irr+srr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
new file mode 100644
index 0000000..f371890
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && HasLess<InIter2::value_type, InIter1::value_type>
+//         && HasLess<InIter1::value_type, InIter2::value_type>
+//   OutIter
+//   set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                    OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {2, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_intersection(Iter1(ia), Iter1(ia+sa),
+                                       Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_intersection(Iter1(ib), Iter1(ib+sb),
+                               Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
new file mode 100644
index 0000000..035522b
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_comp.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+//          CopyConstructible Compare>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+//   OutIter
+//   set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//                    OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {2, 4, 4};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_intersection(Iter1(ia), Iter1(ia+sa),
+                                       Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_intersection(Iter1(ib), Iter1(ib+sb),
+                               Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp
new file mode 100644
index 0000000..ea3812a
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && HasLess<InIter2::value_type, InIter1::value_type>
+//         && HasLess<InIter1::value_type, InIter2::value_type>
+//   OutIter
+//   set_symmetric_difference(InIter1 first1, InIter1 last1,
+//                            InIter2 first2, InIter2 last2,
+//                            OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_symmetric_difference(Iter1(ia), Iter1(ia+sa),
+                                               Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_symmetric_difference(Iter1(ib), Iter1(ib+sb),
+                                       Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp
new file mode 100644
index 0000000..ba1f61a
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.symmetric.difference/set_symmetric_difference_comp.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+//          CopyConstructible Compare>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+//   OutIter
+//   set_symmetric_difference(InIter1 first1, InIter1 last1,
+//                            InIter2 first2, InIter2 last2,
+//                            OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 3, 3, 3, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_symmetric_difference(Iter1(ia), Iter1(ia+sa),
+                                               Iter2(ib), Iter2(ib+sb),
+                                               OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_symmetric_difference(Iter1(ib), Iter1(ib+sb),
+                                       Iter2(ia), Iter2(ia+sa),
+                                       OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp
new file mode 100644
index 0000000..4657850
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && HasLess<InIter2::value_type, InIter1::value_type>
+//         && HasLess<InIter1::value_type, InIter2::value_type>
+//   OutIter
+//   set_union(InIter1 first1, InIter1 last1,
+//             InIter2 first2, InIter2 last2, OutIter result);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_union(Iter1(ia), Iter1(ia+sa),
+                                Iter2(ib), Iter2(ib+sb), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_union(Iter1(ib), Iter1(ib+sb),
+                        Iter2(ia), Iter2(ia+sa), OutIter(ic));
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp
new file mode 100644
index 0000000..3d63e3f
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.set.operations/set.union/set_union_comp.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+//          CopyConstructible Compare>
+//   requires OutputIterator<OutIter, InIter1::reference>
+//         && OutputIterator<OutIter, InIter2::reference>
+//         && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+//         && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+//   OutIter
+//   set_union(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+//             OutIter result, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+    const int sa = sizeof(ia)/sizeof(ia[0]);
+    int ib[] = {2, 4, 4, 6};
+    const int sb = sizeof(ib)/sizeof(ib[0]);
+    int ic[20];
+    int ir[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 6};
+    const int sr = sizeof(ir)/sizeof(ir[0]);
+    OutIter ce = std::set_union(Iter1(ia), Iter1(ia+sa),
+                                Iter2(ib), Iter2(ib+sb), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+    ce = std::set_union(Iter1(ib), Iter1(ib+sb),
+                        Iter2(ia), Iter2(ia+sa), OutIter(ic), std::less<int>());
+    assert(base(ce) - ic == sr);
+    assert(std::lexicographical_compare(ic, base(ce), ir, ir+sr) == 0);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<input_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, const int*, int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, const int*, int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, const int*, int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, input_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, const int*, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, const int*, int*>();
+
+    test<const int*, input_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, input_iterator<const int*>, int*>();
+
+    test<const int*, forward_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, forward_iterator<const int*>, int*>();
+
+    test<const int*, bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, bidirectional_iterator<const int*>, int*>();
+
+    test<const int*, random_access_iterator<const int*>, output_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<const int*, random_access_iterator<const int*>, int*>();
+
+    test<const int*, const int*, output_iterator<int*> >();
+    test<const int*, const int*, forward_iterator<int*> >();
+    test<const int*, const int*, bidirectional_iterator<int*> >();
+    test<const int*, const int*, random_access_iterator<int*> >();
+    test<const int*, const int*, int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
new file mode 100644
index 0000000..dd6b5c1
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted.pass.cpp
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   bool
+//   is_sorted(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a)));
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa)));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
new file mode 100644
index 0000000..d5a34e2
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_comp.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires CopyConstructible<Compare>
+//   bool
+//   is_sorted(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a)));
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(!std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted(Iter(a), Iter(a+sa), std::greater<int>()));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
new file mode 100644
index 0000000..bef0102
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until.pass.cpp
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter>
+//   requires LessThanComparable<Iter::value_type>
+//   Iter
+//   is_sorted_until(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a)) == Iter(a));
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+3));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa)) == Iter(a+sa));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
new file mode 100644
index 0000000..68ed29c
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/is.sorted/is_sorted_until_comp.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<ForwardIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires CopyConstructible<Compare>
+//   Iter
+//   is_sorted_until(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test()
+{
+    {
+    int a[] = {0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a), std::greater<int>()) == Iter(a));
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+
+    {
+    int a[] = {0, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {0, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+    }
+    {
+    int a[] = {0, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {0, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {0, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+1));
+    }
+    {
+    int a[] = {1, 0, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 0, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+    }
+    {
+    int a[] = {1, 0, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 0, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+2));
+    }
+    {
+    int a[] = {1, 1, 0, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1, 0, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+3));
+    }
+    {
+    int a[] = {1, 1, 1, 0};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+    {
+    int a[] = {1, 1, 1, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    assert(std::is_sorted_until(Iter(a), Iter(a+sa), std::greater<int>()) == Iter(a+sa));
+    }
+}
+
+int main()
+{
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
new file mode 100644
index 0000000..5f298fd
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, RandomAccessIterator RAIter>
+//   requires ShuffleIterator<RAIter>
+//         && OutputIterator<RAIter, InIter::reference>
+//         && HasLess<InIter::value_type, RAIter::value_type>
+//         && LessThanComparable<RAIter::value_type>
+//   RAIter
+//   partial_sort_copy(InIter first, InIter last, RAIter result_first, RAIter result_last);
+
+#include <algorithm>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    int* input = new int[N];
+    int* output = new int[M];
+    for (int i = 0; i < N; ++i)
+        input[i] = i;
+    std::random_shuffle(input, input+N);
+    int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M);
+    int* e = output + std::min(N, M);
+    assert(r == e);
+    int i = 0;
+    for (int* x = output; x < e; ++x, ++i)
+        assert(*x == i);
+    delete [] output;
+    delete [] input;
+}
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts<Iter>(N, 0);
+    test_larger_sorts<Iter>(N, 1);
+    test_larger_sorts<Iter>(N, 2);
+    test_larger_sorts<Iter>(N, 3);
+    test_larger_sorts<Iter>(N, N/2-1);
+    test_larger_sorts<Iter>(N, N/2);
+    test_larger_sorts<Iter>(N, N/2+1);
+    test_larger_sorts<Iter>(N, N-2);
+    test_larger_sorts<Iter>(N, N-1);
+    test_larger_sorts<Iter>(N, N);
+    test_larger_sorts<Iter>(N, N+1000);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_larger_sorts<Iter>(0, 100);
+    test_larger_sorts<Iter>(10);
+    test_larger_sorts<Iter>(256);
+    test_larger_sorts<Iter>(257);
+    test_larger_sorts<Iter>(499);
+    test_larger_sorts<Iter>(500);
+    test_larger_sorts<Iter>(997);
+    test_larger_sorts<Iter>(1000);
+    test_larger_sorts<Iter>(1009);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort_copy(&i, &i, &i, &i+5);
+    assert(i == 0);
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
new file mode 100644
index 0000000..df8fb9e
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/partial.sort.copy/partial_sort_copy_comp.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter, RandomAccessIterator RAIter, class Compare>
+//   requires ShuffleIterator<RAIter>
+//         && OutputIterator<RAIter, InIter::reference>
+//         && Predicate<Compare, InIter::value_type, RAIter::value_type>
+//         && StrictWeakOrder<Compare, RAIter::value_type>}
+//         && CopyConstructible<Compare>
+//   RAIter
+//   partial_sort_copy(InIter first, InIter last,
+//                     RAIter result_first, RAIter result_last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    int* input = new int[N];
+    int* output = new int[M];
+    for (int i = 0; i < N; ++i)
+        input[i] = i;
+    std::random_shuffle(input, input+N);
+    int* r = std::partial_sort_copy(Iter(input), Iter(input+N), output, output+M,
+                                    std::greater<int>());
+    int* e = output + std::min(N, M);
+    assert(r == e);
+    int i = 0;
+    for (int* x = output; x < e; ++x, ++i)
+        assert(*x == N-i-1);
+    delete [] output;
+    delete [] input;
+}
+
+template <class Iter>
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts<Iter>(N, 0);
+    test_larger_sorts<Iter>(N, 1);
+    test_larger_sorts<Iter>(N, 2);
+    test_larger_sorts<Iter>(N, 3);
+    test_larger_sorts<Iter>(N, N/2-1);
+    test_larger_sorts<Iter>(N, N/2);
+    test_larger_sorts<Iter>(N, N/2+1);
+    test_larger_sorts<Iter>(N, N-2);
+    test_larger_sorts<Iter>(N, N-1);
+    test_larger_sorts<Iter>(N, N);
+    test_larger_sorts<Iter>(N, N+1000);
+}
+
+template <class Iter>
+void
+test()
+{
+    test_larger_sorts<Iter>(0, 100);
+    test_larger_sorts<Iter>(10);
+    test_larger_sorts<Iter>(256);
+    test_larger_sorts<Iter>(257);
+    test_larger_sorts<Iter>(499);
+    test_larger_sorts<Iter>(500);
+    test_larger_sorts<Iter>(997);
+    test_larger_sorts<Iter>(1000);
+    test_larger_sorts<Iter>(1009);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort_copy(&i, &i, &i, &i+5);
+    assert(i == 0);
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
new file mode 100644
index 0000000..7bb4346
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   void
+//   partial_sort(Iter first, Iter middle, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::partial_sort(array, array+M, array+N);
+    for (int i = 0; i < M; ++i)
+        assert(array[i] == i);
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 0);
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort(&i, &i, &i);
+    assert(i == 0);
+    test_larger_sorts(10);
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
new file mode 100644
index 0000000..d822f6c
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Compare>
+//   void
+//   partial_sort(Iter first, Iter middle, Iter last, Compare comp);
+
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    int* array = new int[N];
+    for (int i = 0; i < N; ++i)
+        array[i] = i;
+    std::random_shuffle(array, array+N);
+    std::partial_sort(array, array+M, array+N, std::greater<int>());
+    for (int i = 0; i < M; ++i)
+        assert(array[i] == N-i-1);
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 0);
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    int i = 0;
+    std::partial_sort(&i, &i, &i);
+    assert(i == 0);
+    test_larger_sorts(10);
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::partial_sort(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
+    for (int i = 0; i < v.size()/2; ++i)
+        assert(*v[i] == i);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
new file mode 100644
index 0000000..2ea697a
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   void
+//   sort(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+template <class RI>
+void
+test_sort_helper(RI f, RI l)
+{
+    typedef typename std::iterator_traits<RI>::value_type value_type;
+    if (f != l)
+    {
+        long len = l - f;
+        value_type* save(new value_type[len]);
+        do
+        {
+            std::copy(f, l, save);
+            std::sort(save, save+len);
+            assert(std::is_sorted(save, save+len));
+        } while (std::next_permutation(f, l));
+        delete [] save;
+    }
+}
+
+template <class RI>
+void
+test_sort_driver_driver(RI f, RI l, int start, RI real_last)
+{
+    for (RI i = l; i > f + start;)
+    {
+        *--i = start;
+        if (f == i)
+        {
+            test_sort_helper(f, real_last);
+        }
+    if (start > 0)
+        test_sort_driver_driver(f, i, start-1, real_last);
+    }
+}
+
+template <class RI>
+void
+test_sort_driver(RI f, RI l, int start)
+{
+    test_sort_driver_driver(f, l, start, l);
+}
+
+template <unsigned sa>
+void
+test_sort_()
+{
+    int ia[sa];
+    for (int i = 0; i < sa; ++i)
+    {
+        test_sort_driver(ia, ia+sa, i);
+    }
+}
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M != 0);
+    // create array length N filled with M different numbers
+    int* array = new int[N];
+    int x = 0;
+    for (int i = 0; i < N; ++i)
+    {
+        array[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    // test saw tooth pattern
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test random pattern
+    std::random_shuffle(array, array+N);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test sorted pattern
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse sorted pattern
+    std::reverse(array, array+N);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test swap ranges 2 pattern
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse swap ranges 2 pattern
+    std::reverse(array, array+N);
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    // test null range
+    int d = 0;
+    std::sort(&d, &d);
+    // exhaustively test all possibilities up to length 8
+    test_sort_<1>();
+    test_sort_<2>();
+    test_sort_<3>();
+    test_sort_<4>();
+    test_sort_<5>();
+    test_sort_<6>();
+    test_sort_<7>();
+    test_sort_<8>();
+
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
new file mode 100644
index 0000000..d6c4f04
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Compare>
+//   void
+//   sort(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    {
+    std::vector<int> v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i] = i;
+    std::sort(v.begin(), v.end(), std::greater<int>());
+    std::reverse(v.begin(), v.end());
+    assert(std::is_sorted(v.begin(), v.end()));
+    }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::sort(v.begin(), v.end(), indirect_less());
+    assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
+    assert(*v[0] == 0);
+    assert(*v[1] == 1);
+    assert(*v[2] == 2);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
new file mode 100644
index 0000000..5faa168
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter>
+//   requires ShuffleIterator<Iter>
+//         && LessThanComparable<Iter::value_type>
+//   void
+//   stable_sort(Iter first, Iter last);
+
+#include <algorithm>
+#include <cassert>
+
+template <class RI>
+void
+test_sort_helper(RI f, RI l)
+{
+    typedef typename std::iterator_traits<RI>::value_type value_type;
+    if (f != l)
+    {
+        long len = l - f;
+        value_type* save(new value_type[len]);
+        do
+        {
+            std::copy(f, l, save);
+            std::stable_sort(save, save+len);
+            assert(std::is_sorted(save, save+len));
+        } while (std::next_permutation(f, l));
+        delete [] save;
+    }
+}
+
+template <class RI>
+void
+test_sort_driver_driver(RI f, RI l, int start, RI real_last)
+{
+    for (RI i = l; i > f + start;)
+    {
+        *--i = start;
+        if (f == i)
+        {
+            test_sort_helper(f, real_last);
+        }
+    if (start > 0)
+        test_sort_driver_driver(f, i, start-1, real_last);
+    }
+}
+
+template <class RI>
+void
+test_sort_driver(RI f, RI l, int start)
+{
+    test_sort_driver_driver(f, l, start, l);
+}
+
+template <unsigned sa>
+void
+test_sort_()
+{
+    int ia[sa];
+    for (int i = 0; i < sa; ++i)
+    {
+        test_sort_driver(ia, ia+sa, i);
+    }
+}
+
+void
+test_larger_sorts(unsigned N, unsigned M)
+{
+    assert(N != 0);
+    assert(M != 0);
+    // create array length N filled with M different numbers
+    int* array = new int[N];
+    int x = 0;
+    for (int i = 0; i < N; ++i)
+    {
+        array[i] = x;
+        if (++x == M)
+            x = 0;
+    }
+    // test saw tooth pattern
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test random pattern
+    std::random_shuffle(array, array+N);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test sorted pattern
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse sorted pattern
+    std::reverse(array, array+N);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test swap ranges 2 pattern
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    // test reverse swap ranges 2 pattern
+    std::reverse(array, array+N);
+    std::swap_ranges(array, array+N/2, array+N/2);
+    std::stable_sort(array, array+N);
+    assert(std::is_sorted(array, array+N));
+    delete [] array;
+}
+
+void
+test_larger_sorts(unsigned N)
+{
+    test_larger_sorts(N, 1);
+    test_larger_sorts(N, 2);
+    test_larger_sorts(N, 3);
+    test_larger_sorts(N, N/2-1);
+    test_larger_sorts(N, N/2);
+    test_larger_sorts(N, N/2+1);
+    test_larger_sorts(N, N-2);
+    test_larger_sorts(N, N-1);
+    test_larger_sorts(N, N);
+}
+
+int main()
+{
+    // test null range
+    int d = 0;
+    std::stable_sort(&d, &d);
+    // exhaustively test all possibilities up to length 8
+    test_sort_<1>();
+    test_sort_<2>();
+    test_sort_<3>();
+    test_sort_<4>();
+    test_sort_<5>();
+    test_sort_<6>();
+    test_sort_<7>();
+    test_sort_<8>();
+
+    test_larger_sorts(256);
+    test_larger_sorts(257);
+    test_larger_sorts(499);
+    test_larger_sorts(500);
+    test_larger_sorts(997);
+    test_larger_sorts(1000);
+    test_larger_sorts(1009);
+}
diff --git a/final/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/final/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
new file mode 100644
index 0000000..68e817e
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<RandomAccessIterator Iter, StrictWeakOrder<auto, Iter::value_type> Compare>
+//   requires ShuffleIterator<Iter>
+//         && CopyConstructible<Compare>
+//   void
+//   stable_sort(Iter first, Iter last, Compare comp);
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+
+struct indirect_less
+{
+    template <class P>
+    bool operator()(const P& x, const P& y)
+        {return *x < *y;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct first_only
+{
+    bool operator()(const std::pair<int, int>& x, const std::pair<int, int>& y)
+    {
+        return x.first < y.first;
+    }
+};
+
+void test()
+{
+    typedef std::pair<int, int> P;
+    const int N = 1000;
+    const int M = 10;
+    std::vector<P> v(N);
+    int x = 0;
+    int ver = 0;
+    for (int i = 0; i < N; ++i)
+    {
+        v[i] = P(x, ver);
+        if (++x == M)
+        {
+            x = 0;
+            ++ver;
+        }
+    }
+    for (int i = 0; i < N - M; i += M)
+    {
+        std::random_shuffle(v.begin() + i, v.begin() + i + M);
+    }
+    std::stable_sort(v.begin(), v.end(), first_only());
+    assert(std::is_sorted(v.begin(), v.end()));
+}
+
+int main()
+{
+    test();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::vector<std::unique_ptr<int> > v(1000);
+    for (int i = 0; i < v.size(); ++i)
+        v[i].reset(new int(i));
+    std::stable_sort(v.begin(), v.end(), indirect_less());
+    assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
+    assert(*v[0] == 0);
+    assert(*v[1] == 1);
+    assert(*v[2] == 2);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/algorithms/alg.sorting/nothing_to_do.pass.cpp b/final/test/algorithms/alg.sorting/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/alg.sorting/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/algorithms.general/nothing_to_do.pass.cpp b/final/test/algorithms/algorithms.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/algorithms/algorithms.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/algorithms/version.pass.cpp b/final/test/algorithms/version.pass.cpp
new file mode 100644
index 0000000..20f0637
--- /dev/null
+++ b/final/test/algorithms/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+#include <algorithm>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp b/final/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp
new file mode 100644
index 0000000..65e1d38
--- /dev/null
+++ b/final/test/atomics/atomics.fences/atomic_signal_fence.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// void atomic_signal_fence(memory_order m);
+
+#include <atomic>
+
+int main()
+{
+    std::atomic_signal_fence(std::memory_order_seq_cst);
+}
diff --git a/final/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp b/final/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp
new file mode 100644
index 0000000..8c2abc0
--- /dev/null
+++ b/final/test/atomics/atomics.fences/atomic_thread_fence.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// void atomic_thread_fence(memory_order m);
+
+#include <atomic>
+
+int main()
+{
+    std::atomic_thread_fence(std::memory_order_seq_cst);
+}
diff --git a/final/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp b/final/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp
new file mode 100644
index 0000000..12be67c
--- /dev/null
+++ b/final/test/atomics/atomics.flag/atomic_flag_clear.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// void atomic_flag_clear(volatile atomic_flag*);
+// void atomic_flag_clear(atomic_flag*);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear(&f);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear(&f);
+        assert(f.test_and_set() == 0);
+    }
+}
diff --git a/final/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp b/final/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
new file mode 100644
index 0000000..f1065dc
--- /dev/null
+++ b/final/test/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// void atomic_flag_clear_explicit(volatile atomic_flag*, memory_order);
+// void atomic_flag_clear_explicit(atomic_flag*, memory_order);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear_explicit(&f, std::memory_order_release);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear_explicit(&f, std::memory_order_relaxed);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear_explicit(&f, std::memory_order_release);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        atomic_flag_clear_explicit(&f, std::memory_order_seq_cst);
+        assert(f.test_and_set() == 0);
+    }
+}
diff --git a/final/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp b/final/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
new file mode 100644
index 0000000..e3934d8
--- /dev/null
+++ b/final/test/atomics/atomics.flag/atomic_flag_test_and_set.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool atomic_flag_test_and_set(volatile atomic_flag*);
+// bool atomic_flag_test_and_set(atomic_flag*);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set(&f) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set(&f) == 0);
+        assert(f.test_and_set() == 1);
+    }
+}
diff --git a/final/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp b/final/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
new file mode 100644
index 0000000..83ee78d
--- /dev/null
+++ b/final/test/atomics/atomics.flag/atomic_flag_test_and_set_explicit.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool atomic_flag_test_and_set_explicit(volatile atomic_flag*, memory_order);
+// bool atomic_flag_test_and_set_explicit(atomic_flag*, memory_order);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_relaxed) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_consume) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acquire) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_release) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_acq_rel) == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(atomic_flag_test_and_set_explicit(&f, std::memory_order_seq_cst) == 0);
+        assert(f.test_and_set() == 1);
+    }
+}
diff --git a/final/test/atomics/atomics.flag/clear.pass.cpp b/final/test/atomics/atomics.flag/clear.pass.cpp
new file mode 100644
index 0000000..171f038
--- /dev/null
+++ b/final/test/atomics/atomics.flag/clear.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// void clear(memory_order = memory_order_seq_cst);
+// void clear(memory_order = memory_order_seq_cst) volatile;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        f.clear();
+        assert(f.test_and_set() == 0);
+    }
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        f.clear(std::memory_order_relaxed);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        f.clear(std::memory_order_release);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        std::atomic_flag f;
+        f.test_and_set();
+        f.clear(std::memory_order_seq_cst);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        f.clear();
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        f.clear(std::memory_order_relaxed);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        f.clear(std::memory_order_release);
+        assert(f.test_and_set() == 0);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.test_and_set();
+        f.clear(std::memory_order_seq_cst);
+        assert(f.test_and_set() == 0);
+    }
+}
diff --git a/final/test/atomics/atomics.flag/copy_assign.fail.cpp b/final/test/atomics/atomics.flag/copy_assign.fail.cpp
new file mode 100644
index 0000000..762e3a8
--- /dev/null
+++ b/final/test/atomics/atomics.flag/copy_assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag& operator=(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    std::atomic_flag f0;
+    std::atomic_flag f;
+    f = f0;
+}
diff --git a/final/test/atomics/atomics.flag/copy_ctor.fail.cpp b/final/test/atomics/atomics.flag/copy_ctor.fail.cpp
new file mode 100644
index 0000000..8d6a865
--- /dev/null
+++ b/final/test/atomics/atomics.flag/copy_ctor.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    std::atomic_flag f0;
+    std::atomic_flag f(f0);
+}
diff --git a/final/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp b/final/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp
new file mode 100644
index 0000000..c58c755
--- /dev/null
+++ b/final/test/atomics/atomics.flag/copy_volatile_assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag& operator=(const atomic_flag&) = delete;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    std::atomic_flag f0;
+    volatile std::atomic_flag f;
+    f = f0;
+}
diff --git a/final/test/atomics/atomics.flag/default.pass.cpp b/final/test/atomics/atomics.flag/default.pass.cpp
new file mode 100644
index 0000000..5c077b0
--- /dev/null
+++ b/final/test/atomics/atomics.flag/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag() = default;
+
+#include <atomic>
+#include <new>
+#include <cassert>
+
+int main()
+{
+    std::atomic_flag f;
+
+    {
+        typedef std::atomic_flag A;
+        _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};
+        A& zero = *new (storage) A();
+        assert(!zero.test_and_set());
+        zero.~A();
+    }
+}
diff --git a/final/test/atomics/atomics.flag/init.pass.cpp b/final/test/atomics/atomics.flag/init.pass.cpp
new file mode 100644
index 0000000..8a67e14
--- /dev/null
+++ b/final/test/atomics/atomics.flag/init.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// atomic_flag() = ATOMIC_FLAG_INIT;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    std::atomic_flag f = ATOMIC_FLAG_INIT;
+    assert(f.test_and_set() == 0);
+}
diff --git a/final/test/atomics/atomics.flag/test_and_set.pass.cpp b/final/test/atomics/atomics.flag/test_and_set.pass.cpp
new file mode 100644
index 0000000..2405275
--- /dev/null
+++ b/final/test/atomics/atomics.flag/test_and_set.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// struct atomic_flag
+
+// bool test_and_set(memory_order = memory_order_seq_cst);
+// bool test_and_set(memory_order = memory_order_seq_cst) volatile;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set() == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_relaxed) == 0);
+        assert(f.test_and_set(std::memory_order_relaxed) == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_consume) == 0);
+        assert(f.test_and_set(std::memory_order_consume) == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_acquire) == 0);
+        assert(f.test_and_set(std::memory_order_acquire) == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_release) == 0);
+        assert(f.test_and_set(std::memory_order_release) == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_acq_rel) == 0);
+        assert(f.test_and_set(std::memory_order_acq_rel) == 1);
+    }
+    {
+        std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_seq_cst) == 0);
+        assert(f.test_and_set(std::memory_order_seq_cst) == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set() == 0);
+        assert(f.test_and_set() == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_relaxed) == 0);
+        assert(f.test_and_set(std::memory_order_relaxed) == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_consume) == 0);
+        assert(f.test_and_set(std::memory_order_consume) == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_acquire) == 0);
+        assert(f.test_and_set(std::memory_order_acquire) == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_release) == 0);
+        assert(f.test_and_set(std::memory_order_release) == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_acq_rel) == 0);
+        assert(f.test_and_set(std::memory_order_acq_rel) == 1);
+    }
+    {
+        volatile std::atomic_flag f;
+        f.clear();
+        assert(f.test_and_set(std::memory_order_seq_cst) == 0);
+        assert(f.test_and_set(std::memory_order_seq_cst) == 1);
+    }
+}
diff --git a/final/test/atomics/atomics.general/nothing_to_do.pass.cpp b/final/test/atomics/atomics.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/atomics/atomics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/atomics/atomics.lockfree/lockfree.pass.cpp b/final/test/atomics/atomics.lockfree/lockfree.pass.cpp
new file mode 100644
index 0000000..467f561
--- /dev/null
+++ b/final/test/atomics/atomics.lockfree/lockfree.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// #define ATOMIC_CHAR_LOCK_FREE unspecified
+// #define ATOMIC_CHAR16_T_LOCK_FREE unspecified
+// #define ATOMIC_CHAR32_T_LOCK_FREE unspecified
+// #define ATOMIC_WCHAR_T_LOCK_FREE unspecified
+// #define ATOMIC_SHORT_LOCK_FREE unspecified
+// #define ATOMIC_INT_LOCK_FREE unspecified
+// #define ATOMIC_LONG_LOCK_FREE unspecified
+// #define ATOMIC_LLONG_LOCK_FREE unspecified
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    assert(ATOMIC_CHAR_LOCK_FREE == 0 ||
+           ATOMIC_CHAR_LOCK_FREE == 1 ||
+           ATOMIC_CHAR_LOCK_FREE == 2);
+    assert(ATOMIC_CHAR16_T_LOCK_FREE == 0 ||
+           ATOMIC_CHAR16_T_LOCK_FREE == 1 ||
+           ATOMIC_CHAR16_T_LOCK_FREE == 2);
+    assert(ATOMIC_CHAR32_T_LOCK_FREE == 0 ||
+           ATOMIC_CHAR32_T_LOCK_FREE == 1 ||
+           ATOMIC_CHAR32_T_LOCK_FREE == 2);
+    assert(ATOMIC_WCHAR_T_LOCK_FREE == 0 ||
+           ATOMIC_WCHAR_T_LOCK_FREE == 1 ||
+           ATOMIC_WCHAR_T_LOCK_FREE == 2);
+    assert(ATOMIC_SHORT_LOCK_FREE == 0 ||
+           ATOMIC_SHORT_LOCK_FREE == 1 ||
+           ATOMIC_SHORT_LOCK_FREE == 2);
+    assert(ATOMIC_INT_LOCK_FREE == 0 ||
+           ATOMIC_INT_LOCK_FREE == 1 ||
+           ATOMIC_INT_LOCK_FREE == 2);
+    assert(ATOMIC_LONG_LOCK_FREE == 0 ||
+           ATOMIC_LONG_LOCK_FREE == 1 ||
+           ATOMIC_LONG_LOCK_FREE == 2);
+    assert(ATOMIC_LLONG_LOCK_FREE == 0 ||
+           ATOMIC_LLONG_LOCK_FREE == 1 ||
+           ATOMIC_LLONG_LOCK_FREE == 2);
+}
diff --git a/final/test/atomics/atomics.order/kill_dependency.pass.cpp b/final/test/atomics/atomics.order/kill_dependency.pass.cpp
new file mode 100644
index 0000000..1beeb08
--- /dev/null
+++ b/final/test/atomics/atomics.order/kill_dependency.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T> T kill_dependency(T y);
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    assert(std::kill_dependency(5) == 5);
+    assert(std::kill_dependency(-5.5) == -5.5);
+}
diff --git a/final/test/atomics/atomics.order/memory_order.pass.cpp b/final/test/atomics/atomics.order/memory_order.pass.cpp
new file mode 100644
index 0000000..8289304
--- /dev/null
+++ b/final/test/atomics/atomics.order/memory_order.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// typedef enum memory_order
+// {
+//     memory_order_relaxed, memory_order_consume, memory_order_acquire,
+//     memory_order_release, memory_order_acq_rel, memory_order_seq_cst
+// } memory_order;
+
+#include <atomic>
+#include <cassert>
+
+int main()
+{
+    assert(std::memory_order_relaxed == 0);
+    assert(std::memory_order_consume == 1);
+    assert(std::memory_order_acquire == 2);
+    assert(std::memory_order_release == 3);
+    assert(std::memory_order_acq_rel == 4);
+    assert(std::memory_order_seq_cst == 5);
+    std::memory_order o = std::memory_order_seq_cst;
+    assert(o == 5);
+}
diff --git a/final/test/atomics/atomics.syn/nothing_to_do.pass.cpp b/final/test/atomics/atomics.syn/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/atomics/atomics.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/atomics/atomics.types.generic/address.pass.cpp b/final/test/atomics/atomics.types.generic/address.pass.cpp
new file mode 100644
index 0000000..af9826f
--- /dev/null
+++ b/final/test/atomics/atomics.types.generic/address.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+// struct atomic<T*>
+// {
+//     bool is_lock_free() const volatile;
+//     bool is_lock_free() const;
+//     void store(T* desr, memory_order m = memory_order_seq_cst) volatile;
+//     void store(T* desr, memory_order m = memory_order_seq_cst);
+//     T* load(memory_order m = memory_order_seq_cst) const volatile;
+//     T* load(memory_order m = memory_order_seq_cst) const;
+//     operator T*() const volatile;
+//     operator T*() const;
+//     T* exchange(T* desr, memory_order m = memory_order_seq_cst) volatile;
+//     T* exchange(T* desr, memory_order m = memory_order_seq_cst);
+//     bool compare_exchange_weak(T*& expc, T* desr,
+//                                memory_order s, memory_order f) volatile;
+//     bool compare_exchange_weak(T*& expc, T* desr,
+//                                memory_order s, memory_order f);
+//     bool compare_exchange_strong(T*& expc, T* desr,
+//                                  memory_order s, memory_order f) volatile;
+//     bool compare_exchange_strong(T*& expc, T* desr,
+//                                  memory_order s, memory_order f);
+//     bool compare_exchange_weak(T*& expc, T* desr,
+//                                memory_order m = memory_order_seq_cst) volatile;
+//     bool compare_exchange_weak(T*& expc, T* desr,
+//                                memory_order m = memory_order_seq_cst);
+//     bool compare_exchange_strong(T*& expc, T* desr,
+//                                 memory_order m = memory_order_seq_cst) volatile;
+//     bool compare_exchange_strong(T*& expc, T* desr,
+//                                  memory_order m = memory_order_seq_cst);
+//     T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
+//     T* fetch_add(ptrdiff_t op, memory_order m = memory_order_seq_cst);
+//     T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst) volatile;
+//     T* fetch_sub(ptrdiff_t op, memory_order m = memory_order_seq_cst);
+// 
+//     atomic() = default;
+//     constexpr atomic(T* desr);
+//     atomic(const atomic&) = delete;
+//     atomic& operator=(const atomic&) = delete;
+//     atomic& operator=(const atomic&) volatile = delete;
+// 
+//     T* operator=(T*) volatile;
+//     T* operator=(T*);
+//     T* operator++(int) volatile;
+//     T* operator++(int);
+//     T* operator--(int) volatile;
+//     T* operator--(int);
+//     T* operator++() volatile;
+//     T* operator++();
+//     T* operator--() volatile;
+//     T* operator--();
+//     T* operator+=(ptrdiff_t op) volatile;
+//     T* operator+=(ptrdiff_t op);
+//     T* operator-=(ptrdiff_t op) volatile;
+//     T* operator-=(ptrdiff_t op);
+// };
+
+#include <atomic>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class A, class T>
+void
+do_test()
+{
+    typedef typename std::remove_pointer<T>::type X;
+    A obj(T(0));
+    assert(obj == T(0));
+    std::atomic_init(&obj, T(1));
+    assert(obj == T(1));
+    std::atomic_init(&obj, T(2));
+    assert(obj == T(2));
+    bool b0 = obj.is_lock_free();
+    obj.store(T(0));
+    assert(obj == T(0));
+    obj.store(T(1), std::memory_order_release);
+    assert(obj == T(1));
+    assert(obj.load() == T(1));
+    assert(obj.load(std::memory_order_acquire) == T(1));
+    assert(obj.exchange(T(2)) == T(1));
+    assert(obj == T(2));
+    assert(obj.exchange(T(3), std::memory_order_relaxed) == T(2));
+    assert(obj == T(3));
+    T x = obj;
+    assert(obj.compare_exchange_weak(x, T(2)) == true);
+    assert(obj == T(2));
+    assert(x == T(3));
+    assert(obj.compare_exchange_weak(x, T(1)) == false);
+    assert(obj == T(2));
+    assert(x == T(2));
+    x = T(2);
+    assert(obj.compare_exchange_strong(x, T(1)) == true);
+    assert(obj == T(1));
+    assert(x == T(2));
+    assert(obj.compare_exchange_strong(x, T(0)) == false);
+    assert(obj == T(1));
+    assert(x == T(1));
+    assert((obj = T(0)) == T(0));
+    assert(obj == T(0));
+    obj = T(2*sizeof(X));
+    assert((obj += std::ptrdiff_t(3)) == T(5*sizeof(X)));
+    assert(obj == T(5*sizeof(X)));
+    assert((obj -= std::ptrdiff_t(3)) == T(2*sizeof(X)));
+    assert(obj == T(2*sizeof(X)));
+
+    {
+        _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {23};
+        A& zero = *new (storage) A();    
+        assert(zero == 0);
+        zero.~A();
+    }
+}
+
+template <class A, class T>
+void test()
+{
+    do_test<A, T>();
+    do_test<volatile A, T>();
+}
+
+int main()
+{
+    test<std::atomic<int*>, int*>();
+}
diff --git a/final/test/atomics/atomics.types.generic/bool.pass.cpp b/final/test/atomics/atomics.types.generic/bool.pass.cpp
new file mode 100644
index 0000000..80e5665
--- /dev/null
+++ b/final/test/atomics/atomics.types.generic/bool.pass.cpp
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+// struct atomic
+// {
+//     bool is_lock_free() const volatile;
+//     bool is_lock_free() const;
+//     void store(T desr, memory_order m = memory_order_seq_cst) volatile;
+//     void store(T desr, memory_order m = memory_order_seq_cst);
+//     T load(memory_order m = memory_order_seq_cst) const volatile;
+//     T load(memory_order m = memory_order_seq_cst) const;
+//     operator T() const volatile;
+//     operator T() const;
+//     T exchange(T desr, memory_order m = memory_order_seq_cst) volatile;
+//     T exchange(T desr, memory_order m = memory_order_seq_cst);
+//     bool compare_exchange_weak(T& expc, T desr,
+//                                memory_order s, memory_order f) volatile;
+//     bool compare_exchange_weak(T& expc, T desr, memory_order s, memory_order f);
+//     bool compare_exchange_strong(T& expc, T desr,
+//                                  memory_order s, memory_order f) volatile;
+//     bool compare_exchange_strong(T& expc, T desr,
+//                                  memory_order s, memory_order f);
+//     bool compare_exchange_weak(T& expc, T desr,
+//                                memory_order m = memory_order_seq_cst) volatile;
+//     bool compare_exchange_weak(T& expc, T desr,
+//                                memory_order m = memory_order_seq_cst);
+//     bool compare_exchange_strong(T& expc, T desr,
+//                                 memory_order m = memory_order_seq_cst) volatile;
+//     bool compare_exchange_strong(T& expc, T desr,
+//                                  memory_order m = memory_order_seq_cst);
+// 
+//     atomic() = default;
+//     constexpr atomic(T desr);
+//     atomic(const atomic&) = delete;
+//     atomic& operator=(const atomic&) = delete;
+//     atomic& operator=(const atomic&) volatile = delete;
+//     T operator=(T) volatile;
+//     T operator=(T);
+// };
+//
+// typedef atomic<bool> atomic_bool;
+
+#include <atomic>
+#include <new>
+#include <cassert>
+
+int main()
+{
+    {
+        volatile std::atomic<bool> _;
+        volatile std::atomic<bool> obj(true);
+        assert(obj == true);
+        std::atomic_init(&obj, false);
+        assert(obj == false);
+        std::atomic_init(&obj, true);
+        assert(obj == true);
+        bool b0 = obj.is_lock_free();
+        obj.store(false);
+        assert(obj == false);
+        obj.store(true, std::memory_order_release);
+        assert(obj == true);
+        assert(obj.load() == true);
+        assert(obj.load(std::memory_order_acquire) == true);
+        assert(obj.exchange(false) == true);
+        assert(obj == false);
+        assert(obj.exchange(true, std::memory_order_relaxed) == false);
+        assert(obj == true);
+        bool x = obj;
+        assert(obj.compare_exchange_weak(x, false) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert(obj.compare_exchange_weak(x, true,
+                                         std::memory_order_seq_cst) == false);
+        assert(obj == false);
+        assert(x == false);
+        obj.store(true);
+        x = true;
+        assert(obj.compare_exchange_weak(x, false,
+                                         std::memory_order_seq_cst,
+                                         std::memory_order_seq_cst) == true);
+        assert(obj == false);
+        assert(x == true);
+        x = true;
+        obj.store(true);
+        assert(obj.compare_exchange_strong(x, false) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert(obj.compare_exchange_strong(x, true,
+                                         std::memory_order_seq_cst) == false);
+        assert(obj == false);
+        assert(x == false);
+        x = true;
+        obj.store(true);
+        assert(obj.compare_exchange_strong(x, false,
+                                           std::memory_order_seq_cst,
+                                           std::memory_order_seq_cst) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert((obj = false) == false);
+        assert(obj == false);
+        assert((obj = true) == true);
+        assert(obj == true);
+    }
+    {
+        std::atomic<bool> _;
+        std::atomic<bool> obj(true);
+        assert(obj == true);
+        std::atomic_init(&obj, false);
+        assert(obj == false);
+        std::atomic_init(&obj, true);
+        assert(obj == true);
+        bool b0 = obj.is_lock_free();
+        obj.store(false);
+        assert(obj == false);
+        obj.store(true, std::memory_order_release);
+        assert(obj == true);
+        assert(obj.load() == true);
+        assert(obj.load(std::memory_order_acquire) == true);
+        assert(obj.exchange(false) == true);
+        assert(obj == false);
+        assert(obj.exchange(true, std::memory_order_relaxed) == false);
+        assert(obj == true);
+        bool x = obj;
+        assert(obj.compare_exchange_weak(x, false) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert(obj.compare_exchange_weak(x, true,
+                                         std::memory_order_seq_cst) == false);
+        assert(obj == false);
+        assert(x == false);
+        obj.store(true);
+        x = true;
+        assert(obj.compare_exchange_weak(x, false,
+                                         std::memory_order_seq_cst,
+                                         std::memory_order_seq_cst) == true);
+        assert(obj == false);
+        assert(x == true);
+        x = true;
+        obj.store(true);
+        assert(obj.compare_exchange_strong(x, false) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert(obj.compare_exchange_strong(x, true,
+                                         std::memory_order_seq_cst) == false);
+        assert(obj == false);
+        assert(x == false);
+        x = true;
+        obj.store(true);
+        assert(obj.compare_exchange_strong(x, false,
+                                           std::memory_order_seq_cst,
+                                           std::memory_order_seq_cst) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert((obj = false) == false);
+        assert(obj == false);
+        assert((obj = true) == true);
+        assert(obj == true);
+    }
+    {
+        std::atomic_bool _;
+        std::atomic_bool obj(true);
+        assert(obj == true);
+        std::atomic_init(&obj, false);
+        assert(obj == false);
+        std::atomic_init(&obj, true);
+        assert(obj == true);
+        bool b0 = obj.is_lock_free();
+        obj.store(false);
+        assert(obj == false);
+        obj.store(true, std::memory_order_release);
+        assert(obj == true);
+        assert(obj.load() == true);
+        assert(obj.load(std::memory_order_acquire) == true);
+        assert(obj.exchange(false) == true);
+        assert(obj == false);
+        assert(obj.exchange(true, std::memory_order_relaxed) == false);
+        assert(obj == true);
+        bool x = obj;
+        assert(obj.compare_exchange_weak(x, false) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert(obj.compare_exchange_weak(x, true,
+                                         std::memory_order_seq_cst) == false);
+        assert(obj == false);
+        assert(x == false);
+        obj.store(true);
+        x = true;
+        assert(obj.compare_exchange_weak(x, false,
+                                         std::memory_order_seq_cst,
+                                         std::memory_order_seq_cst) == true);
+        assert(obj == false);
+        assert(x == true);
+        x = true;
+        obj.store(true);
+        assert(obj.compare_exchange_strong(x, false) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert(obj.compare_exchange_strong(x, true,
+                                         std::memory_order_seq_cst) == false);
+        assert(obj == false);
+        assert(x == false);
+        x = true;
+        obj.store(true);
+        assert(obj.compare_exchange_strong(x, false,
+                                           std::memory_order_seq_cst,
+                                           std::memory_order_seq_cst) == true);
+        assert(obj == false);
+        assert(x == true);
+        assert((obj = false) == false);
+        assert(obj == false);
+        assert((obj = true) == true);
+        assert(obj == true);
+    }
+    {
+        typedef std::atomic<bool> A;
+        _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1};
+        A& zero = *new (storage) A();    
+        assert(zero == false);
+        zero.~A();
+    }
+}
diff --git a/final/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp b/final/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
new file mode 100644
index 0000000..eac5177
--- /dev/null
+++ b/final/test/atomics/atomics.types.generic/cstdint_typedefs.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// typedef atomic<int_least8_t>   atomic_int_least8_t;
+// typedef atomic<uint_least8_t>  atomic_uint_least8_t;
+// typedef atomic<int_least16_t>  atomic_int_least16_t;
+// typedef atomic<uint_least16_t> atomic_uint_least16_t;
+// typedef atomic<int_least32_t>  atomic_int_least32_t;
+// typedef atomic<uint_least32_t> atomic_uint_least32_t;
+// typedef atomic<int_least64_t>  atomic_int_least64_t;
+// typedef atomic<uint_least64_t> atomic_uint_least64_t;
+// 
+// typedef atomic<int_fast8_t>   atomic_int_fast8_t;
+// typedef atomic<uint_fast8_t>  atomic_uint_fast8_t;
+// typedef atomic<int_fast16_t>  atomic_int_fast16_t;
+// typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
+// typedef atomic<int_fast32_t>  atomic_int_fast32_t;
+// typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
+// typedef atomic<int_fast64_t>  atomic_int_fast64_t;
+// typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
+// 
+// typedef atomic<intptr_t>  atomic_intptr_t;
+// typedef atomic<uintptr_t> atomic_uintptr_t;
+// typedef atomic<size_t>    atomic_size_t;
+// typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
+// typedef atomic<intmax_t>  atomic_intmax_t;
+// typedef atomic<uintmax_t> atomic_uintmax_t;
+
+#include <atomic>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+    static_assert((std::is_same<std::atomic<  std::int_least8_t>,   std::atomic_int_least8_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::uint_least8_t>,  std::atomic_uint_least8_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::int_least16_t>,  std::atomic_int_least16_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uint_least16_t>, std::atomic_uint_least16_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::int_least32_t>,  std::atomic_int_least32_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uint_least32_t>, std::atomic_uint_least32_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::int_least64_t>,  std::atomic_int_least64_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uint_least64_t>, std::atomic_uint_least64_t>::value), "");
+
+    static_assert((std::is_same<std::atomic<  std::int_fast8_t>,   std::atomic_int_fast8_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::uint_fast8_t>,  std::atomic_uint_fast8_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::int_fast16_t>,  std::atomic_int_fast16_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uint_fast16_t>, std::atomic_uint_fast16_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::int_fast32_t>,  std::atomic_int_fast32_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uint_fast32_t>, std::atomic_uint_fast32_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::int_fast64_t>,  std::atomic_int_fast64_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uint_fast64_t>, std::atomic_uint_fast64_t>::value), "");
+
+    static_assert((std::is_same<std::atomic< std::intptr_t>,  std::atomic_intptr_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uintptr_t>, std::atomic_uintptr_t>::value), "");
+    static_assert((std::is_same<std::atomic<   std::size_t>,    std::atomic_size_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::ptrdiff_t>, std::atomic_ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::atomic< std::intmax_t>,  std::atomic_intmax_t>::value), "");
+    static_assert((std::is_same<std::atomic<std::uintmax_t>, std::atomic_uintmax_t>::value), "");
+}
diff --git a/final/test/atomics/atomics.types.generic/integral.pass.cpp b/final/test/atomics/atomics.types.generic/integral.pass.cpp
new file mode 100644
index 0000000..26caa50
--- /dev/null
+++ b/final/test/atomics/atomics.types.generic/integral.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <>
+// struct atomic<integral>
+// {
+//     bool is_lock_free() const volatile;
+//     bool is_lock_free() const;
+//     void store(integral desr, memory_order m = memory_order_seq_cst) volatile;
+//     void store(integral desr, memory_order m = memory_order_seq_cst);
+//     integral load(memory_order m = memory_order_seq_cst) const volatile;
+//     integral load(memory_order m = memory_order_seq_cst) const;
+//     operator integral() const volatile;
+//     operator integral() const;
+//     integral exchange(integral desr,
+//                       memory_order m = memory_order_seq_cst) volatile;
+//     integral exchange(integral desr, memory_order m = memory_order_seq_cst);
+//     bool compare_exchange_weak(integral& expc, integral desr,
+//                                memory_order s, memory_order f) volatile;
+//     bool compare_exchange_weak(integral& expc, integral desr,
+//                                memory_order s, memory_order f);
+//     bool compare_exchange_strong(integral& expc, integral desr,
+//                                  memory_order s, memory_order f) volatile;
+//     bool compare_exchange_strong(integral& expc, integral desr,
+//                                  memory_order s, memory_order f);
+//     bool compare_exchange_weak(integral& expc, integral desr,
+//                                memory_order m = memory_order_seq_cst) volatile;
+//     bool compare_exchange_weak(integral& expc, integral desr,
+//                                memory_order m = memory_order_seq_cst);
+//     bool compare_exchange_strong(integral& expc, integral desr,
+//                                 memory_order m = memory_order_seq_cst) volatile;
+//     bool compare_exchange_strong(integral& expc, integral desr,
+//                                  memory_order m = memory_order_seq_cst);
+// 
+//     integral
+//         fetch_add(integral op, memory_order m = memory_order_seq_cst) volatile;
+//     integral fetch_add(integral op, memory_order m = memory_order_seq_cst);
+//     integral
+//         fetch_sub(integral op, memory_order m = memory_order_seq_cst) volatile;
+//     integral fetch_sub(integral op, memory_order m = memory_order_seq_cst);
+//     integral
+//         fetch_and(integral op, memory_order m = memory_order_seq_cst) volatile;
+//     integral fetch_and(integral op, memory_order m = memory_order_seq_cst);
+//     integral
+//         fetch_or(integral op, memory_order m = memory_order_seq_cst) volatile;
+//     integral fetch_or(integral op, memory_order m = memory_order_seq_cst);
+//     integral
+//         fetch_xor(integral op, memory_order m = memory_order_seq_cst) volatile;
+//     integral fetch_xor(integral op, memory_order m = memory_order_seq_cst);
+// 
+//     atomic() = default;
+//     constexpr atomic(integral desr);
+//     atomic(const atomic&) = delete;
+//     atomic& operator=(const atomic&) = delete;
+//     atomic& operator=(const atomic&) volatile = delete;
+//     integral operator=(integral desr) volatile;
+//     integral operator=(integral desr);
+// 
+//     integral operator++(int) volatile;
+//     integral operator++(int);
+//     integral operator--(int) volatile;
+//     integral operator--(int);
+//     integral operator++() volatile;
+//     integral operator++();
+//     integral operator--() volatile;
+//     integral operator--();
+//     integral operator+=(integral op) volatile;
+//     integral operator+=(integral op);
+//     integral operator-=(integral op) volatile;
+//     integral operator-=(integral op);
+//     integral operator&=(integral op) volatile;
+//     integral operator&=(integral op);
+//     integral operator|=(integral op) volatile;
+//     integral operator|=(integral op);
+//     integral operator^=(integral op) volatile;
+//     integral operator^=(integral op);
+// };
+
+#include <atomic>
+#include <new>
+#include <cassert>
+
+template <class A, class T>
+void
+do_test()
+{
+    A obj(T(0));
+    assert(obj == T(0));
+    std::atomic_init(&obj, T(1));
+    assert(obj == T(1));
+    std::atomic_init(&obj, T(2));
+    assert(obj == T(2));
+    bool b0 = obj.is_lock_free();
+    obj.store(T(0));
+    assert(obj == T(0));
+    obj.store(T(1), std::memory_order_release);
+    assert(obj == T(1));
+    assert(obj.load() == T(1));
+    assert(obj.load(std::memory_order_acquire) == T(1));
+    assert(obj.exchange(T(2)) == T(1));
+    assert(obj == T(2));
+    assert(obj.exchange(T(3), std::memory_order_relaxed) == T(2));
+    assert(obj == T(3));
+    T x = obj;
+    assert(obj.compare_exchange_weak(x, T(2)) == true);
+    assert(obj == T(2));
+    assert(x == T(3));
+    assert(obj.compare_exchange_weak(x, T(1)) == false);
+    assert(obj == T(2));
+    assert(x == T(2));
+    x = T(2);
+    assert(obj.compare_exchange_strong(x, T(1)) == true);
+    assert(obj == T(1));
+    assert(x == T(2));
+    assert(obj.compare_exchange_strong(x, T(0)) == false);
+    assert(obj == T(1));
+    assert(x == T(1));
+    assert((obj = T(0)) == T(0));
+    assert(obj == T(0));
+    assert(obj++ == T(0));
+    assert(obj == T(1));
+    assert(++obj == T(2));
+    assert(obj == T(2));
+    assert(--obj == T(1));
+    assert(obj == T(1));
+    assert(obj-- == T(1));
+    assert(obj == T(0));
+    obj = T(2);
+    assert((obj += T(3)) == T(5));
+    assert(obj == T(5));
+    assert((obj -= T(3)) == T(2));
+    assert(obj == T(2));
+    assert((obj |= T(5)) == T(7));
+    assert(obj == T(7));
+    assert((obj &= T(0xF)) == T(7));
+    assert(obj == T(7));
+    assert((obj ^= T(0xF)) == T(8));
+    assert(obj == T(8));
+
+    {
+        _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {23};
+        A& zero = *new (storage) A();    
+        assert(zero == 0);
+        zero.~A();
+    }
+}
+
+template <class A, class T>
+void test()
+{
+    do_test<A, T>();
+    do_test<volatile A, T>();
+}
+
+
+int main()
+{
+    test<std::atomic_char, char>();
+    test<std::atomic_schar, signed char>();
+    test<std::atomic_uchar, unsigned char>();
+    test<std::atomic_short, short>();
+    test<std::atomic_ushort, unsigned short>();
+    test<std::atomic_int, int>();
+    test<std::atomic_uint, unsigned int>();
+    test<std::atomic_long, long>();
+    test<std::atomic_ulong, unsigned long>();
+    test<std::atomic_llong, long long>();
+    test<std::atomic_ullong, unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<std::atomic_char16_t, char16_t>();
+    test<std::atomic_char32_t, char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<std::atomic_wchar_t, wchar_t>();
+
+    test<volatile std::atomic_char, char>();
+    test<volatile std::atomic_schar, signed char>();
+    test<volatile std::atomic_uchar, unsigned char>();
+    test<volatile std::atomic_short, short>();
+    test<volatile std::atomic_ushort, unsigned short>();
+    test<volatile std::atomic_int, int>();
+    test<volatile std::atomic_uint, unsigned int>();
+    test<volatile std::atomic_long, long>();
+    test<volatile std::atomic_ulong, unsigned long>();
+    test<volatile std::atomic_llong, long long>();
+    test<volatile std::atomic_ullong, unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<volatile std::atomic_char16_t, char16_t>();
+    test<volatile std::atomic_char32_t, char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<volatile std::atomic_wchar_t, wchar_t>();
+}
diff --git a/final/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp b/final/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp
new file mode 100644
index 0000000..c622d6e
--- /dev/null
+++ b/final/test/atomics/atomics.types.generic/integral_typedefs.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// typedef atomic<char>               atomic_char;
+// typedef atomic<signed char>        atomic_schar;
+// typedef atomic<unsigned char>      atomic_uchar;
+// typedef atomic<short>              atomic_short;
+// typedef atomic<unsigned short>     atomic_ushort;
+// typedef atomic<int>                atomic_int;
+// typedef atomic<unsigned int>       atomic_uint;
+// typedef atomic<long>               atomic_long;
+// typedef atomic<unsigned long>      atomic_ulong;
+// typedef atomic<long long>          atomic_llong;
+// typedef atomic<unsigned long long> atomic_ullong;
+// typedef atomic<char16_t>           atomic_char16_t;
+// typedef atomic<char32_t>           atomic_char32_t;
+// typedef atomic<wchar_t>            atomic_wchar_t;
+
+#include <atomic>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::atomic<char>, std::atomic_char>::value), "");
+    static_assert((std::is_same<std::atomic<signed char>, std::atomic_schar>::value), "");
+    static_assert((std::is_same<std::atomic<unsigned char>, std::atomic_uchar>::value), "");
+    static_assert((std::is_same<std::atomic<short>, std::atomic_short>::value), "");
+    static_assert((std::is_same<std::atomic<unsigned short>, std::atomic_ushort>::value), "");
+    static_assert((std::is_same<std::atomic<int>, std::atomic_int>::value), "");
+    static_assert((std::is_same<std::atomic<unsigned int>, std::atomic_uint>::value), "");
+    static_assert((std::is_same<std::atomic<long>, std::atomic_long>::value), "");
+    static_assert((std::is_same<std::atomic<unsigned long>, std::atomic_ulong>::value), "");
+    static_assert((std::is_same<std::atomic<long long>, std::atomic_llong>::value), "");
+    static_assert((std::is_same<std::atomic<unsigned long long>, std::atomic_ullong>::value), "");
+    static_assert((std::is_same<std::atomic<wchar_t>, std::atomic_wchar_t>::value), "");
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    static_assert((std::is_same<std::atomic<char16_t>, std::atomic_char16_t>::value), "");
+    static_assert((std::is_same<std::atomic<char32_t>, std::atomic_char32_t>::value), "");
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.arith/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.pointer/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
new file mode 100644
index 0000000..fd5102b
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     bool
+//     atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr);
+// 
+// template <class T>
+//     bool
+//     atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_strong(&a, &t, T(2)) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_strong(&a, &t, T(3)) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
new file mode 100644
index 0000000..f2610a3
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     bool
+//     atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, T* expc,
+//                                           T desr,
+//                                           memory_order s, memory_order f);
+// 
+// template <class T>
+//     bool
+//     atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, T desr,
+//                                           memory_order s, memory_order f);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(2),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_strong_explicit(&a, &t, T(3),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
new file mode 100644
index 0000000..a3f95a4
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     bool
+//     atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr);
+// 
+// template <class T>
+//     bool
+//     atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_weak(&a, &t, T(2)) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_weak(&a, &t, T(2)) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_weak(&a, &t, T(3)) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
new file mode 100644
index 0000000..2f3e996
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     bool
+//     atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc,
+//                                           T desr,
+//                                           memory_order s, memory_order f);
+// 
+// template <class T>
+//     bool
+//     atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr,
+//                                           memory_order s, memory_order f);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(2),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A a;
+        T t(T(1));
+        std::atomic_init(&a, t);
+        assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(2),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == true);
+        assert(a == T(2));
+        assert(t == T(1));
+        assert(std::atomic_compare_exchange_weak_explicit(&a, &t, T(3),
+               std::memory_order_seq_cst, std::memory_order_seq_cst) == false);
+        assert(a == T(2));
+        assert(t == T(2));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
new file mode 100644
index 0000000..4264943
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     T
+//     atomic_exchange(volatile atomic<T>* obj, T desr);
+// 
+// template <class T>
+//     T
+//     atomic_exchange(atomic<T>* obj, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    std::atomic_init(&t, T(1));
+    assert(std::atomic_exchange(&t, T(2)) == T(1));
+    assert(t == T(2));
+    volatile A vt;
+    std::atomic_init(&vt, T(3));
+    assert(std::atomic_exchange(&vt, T(4)) == T(3));
+    assert(vt == T(4));
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
new file mode 100644
index 0000000..0f3add5
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     T
+//     atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m);
+// 
+// template <class T>
+//     T
+//     atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    std::atomic_init(&t, T(1));
+    assert(std::atomic_exchange_explicit(&t, T(2), std::memory_order_seq_cst)
+           == T(1));
+    assert(t == T(2));
+    volatile A vt;
+    std::atomic_init(&vt, T(3));
+    assert(std::atomic_exchange_explicit(&vt, T(4), std::memory_order_seq_cst)
+           == T(3));
+    assert(vt == T(4));
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
new file mode 100644
index 0000000..9ce60ad
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_add(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_add(atomic<Integral>* obj, Integral op);
+// 
+// template <class T>
+//     T*
+//     atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op);
+// 
+// template <class T>
+//     T*
+//     atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_add(&t, T(2)) == T(1));
+        assert(t == T(3));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_add(&t, T(2)) == T(1));
+        assert(t == T(3));
+    }
+}
+
+template <class T>
+void
+testp()
+{
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        A t;
+        std::atomic_init(&t, T(1*sizeof(X)));
+        assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
+        assert(t == T(3*sizeof(X)));
+    }
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        volatile A t;
+        std::atomic_init(&t, T(1*sizeof(X)));
+        assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X)));
+        assert(t == T(3*sizeof(X)));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+    A(const A& a) : i(a.i) {}
+    A(const volatile A& a) : i(a.i) {}
+
+    void operator=(const volatile A& a) volatile {i = a.i;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    testp<int*>();
+    testp<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
new file mode 100644
index 0000000..a2a1a44
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op,
+//                               memory_order m);
+// template <class Integral>
+//     Integral
+//     atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op,
+//                               memory_order m);
+// template <class T>
+//     T*
+//     atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
+//                               memory_order m);
+// template <class T>
+//     T*
+//     atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_add_explicit(&t, T(2),
+                                            std::memory_order_seq_cst) == T(1));
+        assert(t == T(3));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_add_explicit(&t, T(2),
+                                            std::memory_order_seq_cst) == T(1));
+        assert(t == T(3));
+    }
+}
+
+template <class T>
+void
+testp()
+{
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        A t;
+        std::atomic_init(&t, T(1*sizeof(X)));
+        assert(std::atomic_fetch_add_explicit(&t, 2,
+                                  std::memory_order_seq_cst) == T(1*sizeof(X)));
+        assert(t == T(3*sizeof(X)));
+    }
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        volatile A t;
+        std::atomic_init(&t, T(1*sizeof(X)));
+        assert(std::atomic_fetch_add_explicit(&t, 2,
+                                  std::memory_order_seq_cst) == T(1*sizeof(X)));
+        assert(t == T(3*sizeof(X)));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+    A(const A& a) : i(a.i) {}
+    A(const volatile A& a) : i(a.i) {}
+
+    void operator=(const volatile A& a) volatile {i = a.i;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    testp<int*>();
+    testp<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
new file mode 100644
index 0000000..01d2cc6
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_and(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_and(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_and(&t, T(2)) == T(1));
+        assert(t == T(0));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_and(&t, T(2)) == T(3));
+        assert(t == T(2));
+    }
+}
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
new file mode 100644
index 0000000..abfb83d
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_and_explicit(&t, T(2),
+               std::memory_order_seq_cst) == T(1));
+        assert(t == T(0));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_and_explicit(&t, T(2),
+               std::memory_order_seq_cst) == T(3));
+        assert(t == T(2));
+    }
+}
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
new file mode 100644
index 0000000..43b6c4f
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_or(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_or(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_or(&t, T(2)) == T(1));
+        assert(t == T(3));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_or(&t, T(2)) == T(3));
+        assert(t == T(3));
+    }
+}
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
new file mode 100644
index 0000000..21078bb
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_or_explicit(&t, T(2),
+               std::memory_order_seq_cst) == T(1));
+        assert(t == T(3));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_or_explicit(&t, T(2),
+               std::memory_order_seq_cst) == T(3));
+        assert(t == T(3));
+    }
+}
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
new file mode 100644
index 0000000..d33b81e
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_sub(atomic<Integral>* obj, Integral op);
+// 
+// template <class T>
+//     T*
+//     atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op);
+// 
+// template <class T>
+//     T*
+//     atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
+        assert(t == T(1));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_sub(&t, T(2)) == T(3));
+        assert(t == T(1));
+    }
+}
+
+template <class T>
+void
+testp()
+{
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        A t;
+        std::atomic_init(&t, T(3*sizeof(X)));
+        assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
+        assert(t == T(1*sizeof(X)));
+    }
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        volatile A t;
+        std::atomic_init(&t, T(3*sizeof(X)));
+        assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X)));
+        assert(t == T(1*sizeof(X)));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+    A(const A& a) : i(a.i) {}
+    A(const volatile A& a) : i(a.i) {}
+
+    void operator=(const volatile A& a) volatile {i = a.i;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    testp<int*>();
+    testp<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
new file mode 100644
index 0000000..886a65f
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op,
+//                               memory_order m);
+// template <class Integral>
+//     Integral
+//     atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op,
+//                               memory_order m);
+// 
+// template <class T>
+//     T*
+//     atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op,
+//                               memory_order m);
+// template <class T>
+//     T*
+//     atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_sub_explicit(&t, T(2),
+                                            std::memory_order_seq_cst) == T(3));
+        assert(t == T(1));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_sub_explicit(&t, T(2),
+                                            std::memory_order_seq_cst) == T(3));
+        assert(t == T(1));
+    }
+}
+
+template <class T>
+void
+testp()
+{
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        A t;
+        std::atomic_init(&t, T(3*sizeof(X)));
+        assert(std::atomic_fetch_sub_explicit(&t, 2,
+                                  std::memory_order_seq_cst) == T(3*sizeof(X)));
+        assert(t == T(1*sizeof(X)));
+    }
+    {
+        typedef std::atomic<T> A;
+        typedef typename std::remove_pointer<T>::type X;
+        volatile A t;
+        std::atomic_init(&t, T(3*sizeof(X)));
+        assert(std::atomic_fetch_sub_explicit(&t, 2,
+                                  std::memory_order_seq_cst) == T(3*sizeof(X)));
+        assert(t == T(1*sizeof(X)));
+    }
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+    A(const A& a) : i(a.i) {}
+    A(const volatile A& a) : i(a.i) {}
+
+    void operator=(const volatile A& a) volatile {i = a.i;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    testp<int*>();
+    testp<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
new file mode 100644
index 0000000..78120a7
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_xor(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_xor(&t, T(2)) == T(1));
+        assert(t == T(3));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_xor(&t, T(2)) == T(3));
+        assert(t == T(1));
+    }
+}
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
new file mode 100644
index 0000000..0a0cd15
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class Integral>
+//     Integral
+//     atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op);
+// 
+// template <class Integral>
+//     Integral
+//     atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+        typedef std::atomic<T> A;
+        A t;
+        std::atomic_init(&t, T(1));
+        assert(std::atomic_fetch_xor_explicit(&t, T(2),
+               std::memory_order_seq_cst) == T(1));
+        assert(t == T(3));
+    }
+    {
+        typedef std::atomic<T> A;
+        volatile A t;
+        std::atomic_init(&t, T(3));
+        assert(std::atomic_fetch_xor_explicit(&t, T(2),
+               std::memory_order_seq_cst) == T(3));
+        assert(t == T(1));
+    }
+}
+
+int main()
+{
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
new file mode 100644
index 0000000..f0d9a24
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     void
+//     atomic_init(volatile atomic<T>* obj, T desr);
+// 
+// template <class T>
+//     void
+//     atomic_init(atomic<T>* obj, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    std::atomic_init(&t, T(1));
+    assert(t == T(1));
+    volatile A vt;
+    std::atomic_init(&vt, T(2));
+    assert(vt == T(2));
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
new file mode 100644
index 0000000..4071989
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     bool
+//     atomic_is_lock_free(const volatile atomic<T>* obj);
+// 
+// template <class T>
+//     bool
+//     atomic_is_lock_free(const atomic<T>* obj);
+
+#include <atomic>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    bool b1 = std::atomic_is_lock_free(static_cast<const A*>(&t));
+    volatile A vt;
+    bool b2 = std::atomic_is_lock_free(static_cast<const volatile A*>(&vt));
+}
+
+struct A
+{
+    char _[4];
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
new file mode 100644
index 0000000..b239886
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     T
+//     atomic_load(const volatile atomic<T>* obj);
+// 
+// template <class T>
+//     T
+//     atomic_load(const atomic<T>* obj);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    std::atomic_init(&t, T(1));
+    assert(std::atomic_load(&t) == T(1));
+    volatile A vt;
+    std::atomic_init(&vt, T(2));
+    assert(std::atomic_load(&vt) == T(2));
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
new file mode 100644
index 0000000..3072dd5
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     T
+//     atomic_load_explicit(const volatile atomic<T>* obj, memory_order m);
+// 
+// template <class T>
+//     T
+//     atomic_load_explicit(const atomic<T>* obj, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    std::atomic_init(&t, T(1));
+    assert(std::atomic_load_explicit(&t, std::memory_order_seq_cst) == T(1));
+    volatile A vt;
+    std::atomic_init(&vt, T(2));
+    assert(std::atomic_load_explicit(&vt, std::memory_order_seq_cst) == T(2));
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
new file mode 100644
index 0000000..f9044bf
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     void
+//     atomic_store(volatile atomic<T>* obj, T desr);
+// 
+// template <class T>
+//     void
+//     atomic_store(atomic<T>* obj, T desr);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    std::atomic_store(&t, T(1));
+    assert(t == T(1));
+    volatile A vt;
+    std::atomic_store(&vt, T(2));
+    assert(vt == T(2));
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
new file mode 100644
index 0000000..18038ae
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// template <class T>
+//     void
+//     atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m);
+// 
+// template <class T>
+//     void
+//     atomic_store_explicit(atomic<T>* obj, T desr, memory_order m);
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    typedef std::atomic<T> A;
+    A t;
+    std::atomic_store_explicit(&t, T(1), std::memory_order_seq_cst);
+    assert(t == T(1));
+    volatile A vt;
+    std::atomic_store_explicit(&vt, T(2), std::memory_order_seq_cst);
+    assert(vt == T(2));
+}
+
+struct A
+{
+    int i;
+
+    explicit A(int d = 0) : i(d) {}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.i == y.i;}
+};
+
+int main()
+{
+    test<A>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<int*>();
+    test<const int*>();
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
new file mode 100644
index 0000000..6758c7b
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+// #define ATOMIC_VAR_INIT(value)
+
+#include <atomic>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::atomic<int> v = ATOMIC_VAR_INIT(5);
+    assert(v == 5);
+}
diff --git a/final/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp b/final/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/atomics.types.operations.templ/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp b/final/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/atomics/atomics.types.operations/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/atomics/version.pass.cpp b/final/test/atomics/version.pass.cpp
new file mode 100644
index 0000000..85c4270
--- /dev/null
+++ b/final/test/atomics/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <atomic>
+
+#include <atomic>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/Copyable.h b/final/test/containers/Copyable.h
new file mode 100644
index 0000000..9542c7e
--- /dev/null
+++ b/final/test/containers/Copyable.h
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 COPYABLE_H
+#define COPYABLE_H
+
+class Copyable
+{
+public:
+};
+
+#endif  // COPYABLE_H
diff --git a/final/test/containers/Emplaceable.h b/final/test/containers/Emplaceable.h
new file mode 100644
index 0000000..34dd326
--- /dev/null
+++ b/final/test/containers/Emplaceable.h
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 EMPLACEABLE_H
+#define EMPLACEABLE_H
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Emplaceable
+{
+    Emplaceable(const Emplaceable&);
+    Emplaceable& operator=(const Emplaceable&);
+
+    int int_;
+    double double_;
+public:
+    Emplaceable() : int_(0), double_(0) {}
+    Emplaceable(int i, double d) : int_(i), double_(d) {}
+    Emplaceable(Emplaceable&& x)
+        : int_(x.int_), double_(x.double_)
+            {x.int_ = 0; x.double_ = 0;}
+    Emplaceable& operator=(Emplaceable&& x)
+        {int_ = x.int_; x.int_ = 0;
+         double_ = x.double_; x.double_ = 0;
+         return *this;}
+
+    bool operator==(const Emplaceable& x) const
+        {return int_ == x.int_ && double_ == x.double_;}
+    bool operator<(const Emplaceable& x) const
+        {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+
+    int get() const {return int_;}
+};
+
+namespace std {
+
+template <>
+struct hash<Emplaceable>
+    : public std::unary_function<Emplaceable, std::size_t>
+{
+    std::size_t operator()(const Emplaceable& x) const {return x.get();}
+};
+
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif  // EMPLACEABLE_H
diff --git a/final/test/containers/MoveOnly.h b/final/test/containers/MoveOnly.h
new file mode 100644
index 0000000..e4d9f64
--- /dev/null
+++ b/final/test/containers/MoveOnly.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 MOVEONLY_H
+#define MOVEONLY_H
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <cstddef>
+#include <functional>
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+    MoveOnly& operator=(const MoveOnly&);
+
+    int data_;
+public:
+    MoveOnly(int data = 1) : data_(data) {}
+    MoveOnly(MoveOnly&& x)
+        : data_(x.data_) {x.data_ = 0;}
+    MoveOnly& operator=(MoveOnly&& x)
+        {data_ = x.data_; x.data_ = 0; return *this;}
+
+    int get() const {return data_;}
+
+    bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
+    bool operator< (const MoveOnly& x) const {return data_ <  x.data_;}
+};
+
+namespace std {
+
+template <>
+struct hash<MoveOnly>
+    : public std::unary_function<MoveOnly, std::size_t>
+{
+    std::size_t operator()(const MoveOnly& x) const {return x.get();}
+};
+
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif  // MOVEONLY_H
diff --git a/final/test/containers/NotConstructible.h b/final/test/containers/NotConstructible.h
new file mode 100644
index 0000000..ac8b98e
--- /dev/null
+++ b/final/test/containers/NotConstructible.h
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 NOTCONSTRUCTIBLE_H
+#define NOTCONSTRUCTIBLE_H
+
+#include <functional>
+
+class NotConstructible
+{
+    NotConstructible(const NotConstructible&);
+    NotConstructible& operator=(const NotConstructible&);
+public:
+};
+
+inline
+bool
+operator==(const NotConstructible&, const NotConstructible&)
+{return true;}
+
+namespace std
+{
+
+template <>
+struct hash<NotConstructible>
+    : public std::unary_function<NotConstructible, std::size_t>
+{
+    std::size_t operator()(const NotConstructible&) const {return 0;}
+};
+
+}
+
+#endif  // NOTCONSTRUCTIBLE_H
diff --git a/final/test/containers/associative/map/compare.pass.cpp b/final/test/containers/associative/map/compare.pass.cpp
new file mode 100644
index 0000000..aa4d599
--- /dev/null
+++ b/final/test/containers/associative/map/compare.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+//           class Allocator = allocator<pair<const Key, T>>>
+// class map
+
+// http://llvm.org/bugs/show_bug.cgi?id=16538
+// http://llvm.org/bugs/show_bug.cgi?id=16549
+
+#include <map>
+
+struct Key {
+  template <typename T> Key(const T&) {}
+  bool operator< (const Key&) const { return false; }
+};
+
+int
+main()
+{
+    std::map<Key, int>::iterator it = std::map<Key, int>().find(Key(0));
+    std::pair<std::map<Key, int>::iterator, bool> result =
+                        std::map<Key, int>().insert(std::make_pair(Key(0), 0));
+}
diff --git a/final/test/containers/associative/map/map.access/at.pass.cpp b/final/test/containers/associative/map/map.access/at.pass.cpp
new file mode 100644
index 0000000..86b1e3d
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/at.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       mapped_type& at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1.5),
+            V(2, 2.5),
+            V(3, 3.5),
+            V(4, 4.5),
+            V(5, 5.5),
+            V(7, 7.5),
+            V(8, 8.5),
+        };
+        std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 7);
+        assert(m.at(1) == 1.5);
+        m.at(1) = -1.5;
+        assert(m.at(1) == -1.5);
+        assert(m.at(2) == 2.5);
+        assert(m.at(3) == 3.5);
+        assert(m.at(4) == 4.5);
+        assert(m.at(5) == 5.5);
+        try
+        {
+            m.at(6);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(m.at(7) == 7.5);
+        assert(m.at(8) == 8.5);
+        assert(m.size() == 7);
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1.5),
+            V(2, 2.5),
+            V(3, 3.5),
+            V(4, 4.5),
+            V(5, 5.5),
+            V(7, 7.5),
+            V(8, 8.5),
+        };
+        const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 7);
+        assert(m.at(1) == 1.5);
+        assert(m.at(2) == 2.5);
+        assert(m.at(3) == 3.5);
+        assert(m.at(4) == 4.5);
+        assert(m.at(5) == 5.5);
+        try
+        {
+            m.at(6);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(m.at(7) == 7.5);
+        assert(m.at(8) == 8.5);
+        assert(m.size() == 7);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1.5),
+            V(2, 2.5),
+            V(3, 3.5),
+            V(4, 4.5),
+            V(5, 5.5),
+            V(7, 7.5),
+            V(8, 8.5),
+        };
+        std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 7);
+        assert(m.at(1) == 1.5);
+        m.at(1) = -1.5;
+        assert(m.at(1) == -1.5);
+        assert(m.at(2) == 2.5);
+        assert(m.at(3) == 3.5);
+        assert(m.at(4) == 4.5);
+        assert(m.at(5) == 5.5);
+        try
+        {
+            m.at(6);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(m.at(7) == 7.5);
+        assert(m.at(8) == 8.5);
+        assert(m.size() == 7);
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1.5),
+            V(2, 2.5),
+            V(3, 3.5),
+            V(4, 4.5),
+            V(5, 5.5),
+            V(7, 7.5),
+            V(8, 8.5),
+        };
+        const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 7);
+        assert(m.at(1) == 1.5);
+        assert(m.at(2) == 2.5);
+        assert(m.at(3) == 3.5);
+        assert(m.at(4) == 4.5);
+        assert(m.at(5) == 5.5);
+        try
+        {
+            m.at(6);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(m.at(7) == 7.5);
+        assert(m.at(8) == 8.5);
+        assert(m.size() == 7);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.access/empty.pass.cpp b/final/test/containers/associative/map/map.access/empty.pass.cpp
new file mode 100644
index 0000000..b11e94c
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::map<int, double> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1, 1.5));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1, 1.5));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.access/index_key.pass.cpp b/final/test/containers/associative/map/map.access/index_key.pass.cpp
new file mode 100644
index 0000000..ab1144c
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/index_key.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1.5),
+        V(2, 2.5),
+        V(3, 3.5),
+        V(4, 4.5),
+        V(5, 5.5),
+        V(7, 7.5),
+        V(8, 8.5),
+    };
+    std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 7);
+    assert(m[1] == 1.5);
+    assert(m.size() == 7);
+    m[1] = -1.5;
+    assert(m[1] == -1.5);
+    assert(m.size() == 7);
+    assert(m[6] == 0);
+    assert(m.size() == 8);
+    m[6] = 6.5;
+    assert(m[6] == 6.5);
+    assert(m.size() == 8);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1.5),
+        V(2, 2.5),
+        V(3, 3.5),
+        V(4, 4.5),
+        V(5, 5.5),
+        V(7, 7.5),
+        V(8, 8.5),
+    };
+    std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 7);
+    assert(m[1] == 1.5);
+    assert(m.size() == 7);
+    const int i = 1;
+    m[i] = -1.5;
+    assert(m[1] == -1.5);
+    assert(m.size() == 7);
+    assert(m[6] == 0);
+    assert(m.size() == 8);
+    m[6] = 6.5;
+    assert(m[6] == 6.5);
+    assert(m.size() == 8);
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1.5),
+        V(2, 2.5),
+        V(3, 3.5),
+        V(4, 4.5),
+        V(5, 5.5),
+        V(7, 7.5),
+        V(8, 8.5),
+    };
+    std::map<int, double, std::less<>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+
+    assert(m.size() == 7);
+    assert(m[1] == 1.5);
+    assert(m.size() == 7);
+    m[1] = -1.5;
+    assert(m[1] == -1.5);
+    assert(m.size() == 7);
+    assert(m[6] == 0);
+    assert(m.size() == 8);
+    m[6] = 6.5;
+    assert(m[6] == 6.5);
+    assert(m.size() == 8);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.access/index_rv_key.pass.cpp b/final/test/containers/associative/map/map.access/index_rv_key.pass.cpp
new file mode 100644
index 0000000..a58d50d
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/index_rv_key.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](key_type&& k);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    typedef std::pair<MoveOnly, double> V;
+    std::map<MoveOnly, double> m;
+    assert(m.size() == 0);
+    assert(m[1] == 0.0);
+    assert(m.size() == 1);
+    m[1] = -1.5;
+    assert(m[1] == -1.5);
+    assert(m.size() == 1);
+    assert(m[6] == 0);
+    assert(m.size() == 2);
+    m[6] = 6.5;
+    assert(m[6] == 6.5);
+    assert(m.size() == 2);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<MoveOnly, double> V;
+    std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m;
+    assert(m.size() == 0);
+    assert(m[1] == 0.0);
+    assert(m.size() == 1);
+    m[1] = -1.5;
+    assert(m[1] == -1.5);
+    assert(m.size() == 1);
+    assert(m[6] == 0);
+    assert(m.size() == 2);
+    m[6] = 6.5;
+    assert(m[6] == 6.5);
+    assert(m.size() == 2);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.access/index_tuple.pass.cpp b/final/test/containers/associative/map/map.access/index_tuple.pass.cpp
new file mode 100644
index 0000000..9a00829
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/index_tuple.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    using namespace std;
+    map<tuple<int,int>, size_t> m;
+    m[make_tuple(2,3)]=7;
+#endif
+}
diff --git a/final/test/containers/associative/map/map.access/iterator.pass.cpp b/final/test/containers/associative/map/map.access/iterator.pass.cpp
new file mode 100644
index 0000000..552e87d
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/iterator.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+//
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+//
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::map<int, double>::iterator i;
+        i = m.begin();
+        std::map<int, double>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= m.size(); ++j, ++i)
+        {
+            assert(i->first == j);
+            assert(i->second == 1);
+            i->second = 2.5;
+            assert(i->second == 2.5);
+        }
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::map<int, double>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= m.size(); ++j, ++i)
+        {
+            assert(i->first == j);
+            assert(i->second == 1);
+        }
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::map<int, double, std::less<int>, min_allocator<V>>::iterator i;
+        i = m.begin();
+        std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= m.size(); ++j, ++i)
+        {
+            assert(i->first == j);
+            assert(i->second == 1);
+            i->second = 2.5;
+            assert(i->second == 2.5);
+        }
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= m.size(); ++j, ++i)
+        {
+            assert(i->first == j);
+            assert(i->second == 1);
+        }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::map<int, double> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.access/max_size.pass.cpp b/final/test/containers/associative/map/map.access/max_size.pass.cpp
new file mode 100644
index 0000000..551120d
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::map<int, double> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.access/size.pass.cpp b/final/test/containers/associative/map/map.access/size.pass.cpp
new file mode 100644
index 0000000..07c1232
--- /dev/null
+++ b/final/test/containers/associative/map/map.access/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::map<int, double> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2, 1.5));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1, 1.5));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3, 1.5));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2, 1.5));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1, 1.5));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3, 1.5));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/alloc.pass.cpp b/final/test/containers/associative/map/map.cons/alloc.pass.cpp
new file mode 100644
index 0000000..2292c47
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::less<int> C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::less<int> C;
+    typedef min_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m(A{});
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/final/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..482d1ac
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::pair<const int, double> V;
+    std::map<int, double> m =
+                            {
+                                {20, 1},
+                            };
+    m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    std::map<int, double, std::less<int>, min_allocator<V>> m =
+                            {
+                                {20, 1},
+                            };
+    m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/map/map.cons/compare.pass.cpp b/final/test/containers/associative/map/map.cons/compare.pass.cpp
new file mode 100644
index 0000000..5a213c8
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/compare_alloc.pass.cpp b/final/test/containers/associative/map/map.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..56b3c33
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/compare_alloc.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef test_compare<std::less<int> > C;
+    typedef min_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m(C(4), A());
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/copy.pass.cpp b/final/test/containers/associative/map/map.cons/copy.pass.cpp
new file mode 100644
index 0000000..be52741
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/copy.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::map<int, double, C, A> m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::map<int, double, C, A> m = mo;
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::map<int, double, C, A> m = mo;
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/copy_alloc.pass.cpp b/final/test/containers/associative/map/map.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..fcbe597
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/copy_alloc.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::map<int, double, C, A> m(mo, A(3));
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+    assert(mo.size() == 3);
+    assert(distance(mo.begin(), mo.end()) == 3);
+    assert(*mo.begin() == V(1, 1));
+    assert(*next(mo.begin()) == V(2, 1));
+    assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef min_allocator<V> A;
+    std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+    std::map<int, double, C, A> m(mo, A());
+    assert(m.get_allocator() == A());
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+
+    assert(mo.get_allocator() == A());
+    assert(mo.key_comp() == C(5));
+    assert(mo.size() == 3);
+    assert(distance(mo.begin(), mo.end()) == 3);
+    assert(*mo.begin() == V(1, 1));
+    assert(*next(mo.begin()) == V(2, 1));
+    assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/copy_assign.pass.cpp b/final/test/containers/associative/map/map.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..a1bcb30
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -0,0 +1,182 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2)
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+    {
+        typedef std::pair<const int, double> V;
+        const V ar[] =
+        {
+            V(1, 1),
+            V(2, 1),
+            V(3, 1),
+        };
+        std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        std::map<int, double> *p = &m;
+        m = *p;
+
+        assert(m.size() == 3);
+        assert(std::equal(m.begin(), m.end(), ar));
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2)
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2)
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+        m = mo;
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2)
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+        m = mo;
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == V(1, 1));
+        assert(*next(mo.begin()) == V(2, 1));
+        assert(*next(mo.begin(), 2) == V(3, 1));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/default.pass.cpp b/final/test/containers/associative/map/map.cons/default.pass.cpp
new file mode 100644
index 0000000..1832a32
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::map<int, double> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+    std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+    {
+    std::map<int, double> m = {};
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/default_noexcept.pass.cpp b/final/test/containers/associative/map/map.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..6c6b614
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/default_recursive.pass.cpp b/final/test/containers/associative/map/map.cons/default_recursive.pass.cpp
new file mode 100644
index 0000000..8b393d3
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map();
+
+#include <map>
+
+#if !__has_feature(cxx_noexcept)
+
+struct X
+{
+    std::map<int, X> m;
+};
+
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/final/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..c60f2e7
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// ~map() // implied noexcept;
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/initializer_list.pass.cpp b/final/test/containers/associative/map/map.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..1969436
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/initializer_list.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::pair<const int, double> V;
+    std::map<int, double> m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    std::map<int, double, std::less<int>, min_allocator<V>> m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/final/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..08f8a52
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::pair<const int, double> V;
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C> m({
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                               }, C(3));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.key_comp() == C(3));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C, min_allocator<std::pair<const int, double>>> m({
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {2, 1},
+                                {2, 1.5},
+                                {2, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                               }, C(3));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.key_comp() == C(3));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/final/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..765428a
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::pair<const int, double> V;
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m({
+                                   {1, 1},
+                                   {1, 1.5},
+                                   {1, 2},
+                                   {2, 1},
+                                   {2, 1.5},
+                                   {2, 2},
+                                   {3, 1},
+                                   {3, 1.5},
+                                   {3, 2}
+                                  }, C(3), A(6));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.key_comp() == C(3));
+    assert(m.get_allocator() == A(6));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef test_compare<std::less<int> > C;
+    typedef min_allocator<std::pair<const int, double> > A;
+    std::map<int, double, C, A> m({
+                                   {1, 1},
+                                   {1, 1.5},
+                                   {1, 2},
+                                   {2, 1},
+                                   {2, 1.5},
+                                   {2, 2},
+                                   {3, 1},
+                                   {3, 1.5},
+                                   {3, 2}
+                                  }, C(3), A());
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.key_comp() == C(3));
+    assert(m.get_allocator() == A());
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef min_allocator<V> A;
+    typedef test_compare<std::less<int> > C;
+    typedef std::map<int, double, C, A> M;
+    A a;
+    M m ({ {1, 1},
+           {1, 1.5},
+           {1, 2},
+           {2, 1},
+           {2, 1.5},
+           {2, 2},
+           {3, 1},
+           {3, 1.5},
+           {3, 2}
+          }, a);
+
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.get_allocator() == a);
+    }
+#endif
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/map/map.cons/iter_iter.pass.cpp b/final/test/containers/associative/map/map.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..c1029af
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/iter_iter.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//     map(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/final/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..837fa8c
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//     map(InputIterator first, InputIterator last, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/final/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 0000000..67fb5d6
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//     map(InputIterator first, InputIterator last,
+//         const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    assert(m.get_allocator() == A(7));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef min_allocator<V> A;
+    std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+    assert(m.get_allocator() == A());
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef std::pair<const int, double> V;
+    typedef min_allocator<V> A;
+    typedef test_compare<std::less<int> > C;
+    A a;
+    std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a );
+
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    assert(m.get_allocator() == a);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/move.pass.cpp b/final/test/containers/associative/map/map.cons/move.pass.cpp
new file mode 100644
index 0000000..c06f2ee
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/move.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    typedef std::pair<const int, double> V;
+    {
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(C(5), A(7));
+        std::map<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::map<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::map<int, double, C, A> mo(C(5), A());
+        std::map<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::map<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(2, 1));
+        assert(*next(m.begin(), 2) == V(3, 1));
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/map/map.cons/move_alloc.pass.cpp b/final/test/containers/associative/map/map.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..1845e88
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/move_alloc.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef min_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+        M m3(std::move(m1), A());
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A());
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/map/map.cons/move_assign.pass.cpp b/final/test/containers/associative/map/map.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..6d285fc
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/move_assign.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef min_allocator<VC> A;
+        typedef std::map<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+        M m3(C(3), A());
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A());
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/final/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..d12f9a9
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map& operator=(map&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.cons/move_noexcept.pass.cpp b/final/test/containers/associative/map/map.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..6de4b67
--- /dev/null
+++ b/final/test/containers/associative/map/map.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map(map&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/clear.pass.cpp b/final/test/containers/associative/map/map.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..c37499d
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/emplace.pass.cpp b/final/test/containers/associative/map/map.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..81846c6
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/emplace.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+//   pair<iterator, bool> emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+#include <tuple>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::map<int, DefaultOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(!r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::map<int, Emplaceable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+                                                  std::forward_as_tuple());
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(2, 3.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(2, 3.5));
+        assert(!r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(M::value_type(2, 3.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(!r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+                                                  std::forward_as_tuple());
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(2, 3.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(2, 3.5));
+        assert(!r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(M::value_type(2, 3.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/final/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..15f74b1
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::map<int, DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.end());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::map<int, Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(2),
+                                       std::forward_as_tuple());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace_hint(m.end(), std::piecewise_construct, 
+                                    std::forward_as_tuple(1),
+                                    std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                    std::forward_as_tuple(1),
+                                    std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::map<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.end());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(2),
+                                       std::forward_as_tuple());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace_hint(m.end(), std::piecewise_construct, 
+                                    std::forward_as_tuple(1),
+                                    std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.end(), std::piecewise_construct,
+                                    std::forward_as_tuple(1),
+                                    std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/final/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..05fb988
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,237 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 5);
+        assert(next(m.begin(), 3)->second == 5.5);
+        assert(next(m.begin(), 4)->first == 6);
+        assert(next(m.begin(), 4)->second == 6.5);
+        assert(next(m.begin(), 5)->first == 7);
+        assert(next(m.begin(), 5)->second == 7.5);
+        assert(next(m.begin(), 6)->first == 8);
+        assert(next(m.begin(), 6)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 6);
+        assert(next(m.begin(), 2)->second == 6.5);
+        assert(next(m.begin(), 3)->first == 7);
+        assert(next(m.begin(), 3)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 7);
+        assert(next(m.begin(), 2)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(m.begin()->first == 5);
+        assert(m.begin()->second == 5.5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 5);
+        assert(next(m.begin(), 3)->second == 5.5);
+        assert(next(m.begin(), 4)->first == 6);
+        assert(next(m.begin(), 4)->second == 6.5);
+        assert(next(m.begin(), 5)->first == 7);
+        assert(next(m.begin(), 5)->second == 7.5);
+        assert(next(m.begin(), 6)->first == 8);
+        assert(next(m.begin(), 6)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 6);
+        assert(next(m.begin(), 2)->second == 6.5);
+        assert(next(m.begin(), 3)->first == 7);
+        assert(next(m.begin(), 3)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 7);
+        assert(next(m.begin(), 2)->second == 7.5);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(m.begin()->first == 5);
+        assert(m.begin()->second == 5.5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/final/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..1b49956
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(m.cbegin(), m.cbegin());
+        assert(m.size() == 8);
+        assert(i == m.begin());
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(m.cbegin(), m.cbegin());
+        assert(m.size() == 8);
+        assert(i == m.begin());
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/erase_key.pass.cpp b/final/test/containers/associative/map/map.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..e41f512
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/erase_key.pass.cpp
@@ -0,0 +1,275 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::size_type R;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        R s = m.erase(9);
+        assert(s == 0);
+        assert(m.size() == 8);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        s = m.erase(4);
+        assert(m.size() == 7);
+        assert(s == 1);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 5);
+        assert(next(m.begin(), 3)->second == 5.5);
+        assert(next(m.begin(), 4)->first == 6);
+        assert(next(m.begin(), 4)->second == 6.5);
+        assert(next(m.begin(), 5)->first == 7);
+        assert(next(m.begin(), 5)->second == 7.5);
+        assert(next(m.begin(), 6)->first == 8);
+        assert(next(m.begin(), 6)->second == 8.5);
+
+        s = m.erase(1);
+        assert(m.size() == 6);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        s = m.erase(8);
+        assert(m.size() == 5);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+
+        s = m.erase(3);
+        assert(m.size() == 4);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 6);
+        assert(next(m.begin(), 2)->second == 6.5);
+        assert(next(m.begin(), 3)->first == 7);
+        assert(next(m.begin(), 3)->second == 7.5);
+
+        s = m.erase(6);
+        assert(m.size() == 3);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 7);
+        assert(next(m.begin(), 2)->second == 7.5);
+
+        s = m.erase(7);
+        assert(m.size() == 2);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+
+        s = m.erase(2);
+        assert(m.size() == 1);
+        assert(s == 1);
+        assert(m.begin()->first == 5);
+        assert(m.begin()->second == 5.5);
+
+        s = m.erase(5);
+        assert(m.size() == 0);
+        assert(s == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        typedef M::size_type R;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        R s = m.erase(9);
+        assert(s == 0);
+        assert(m.size() == 8);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        s = m.erase(4);
+        assert(m.size() == 7);
+        assert(s == 1);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 5);
+        assert(next(m.begin(), 3)->second == 5.5);
+        assert(next(m.begin(), 4)->first == 6);
+        assert(next(m.begin(), 4)->second == 6.5);
+        assert(next(m.begin(), 5)->first == 7);
+        assert(next(m.begin(), 5)->second == 7.5);
+        assert(next(m.begin(), 6)->first == 8);
+        assert(next(m.begin(), 6)->second == 8.5);
+
+        s = m.erase(1);
+        assert(m.size() == 6);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        s = m.erase(8);
+        assert(m.size() == 5);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 3);
+        assert(next(m.begin())->second == 3.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+
+        s = m.erase(3);
+        assert(m.size() == 4);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 6);
+        assert(next(m.begin(), 2)->second == 6.5);
+        assert(next(m.begin(), 3)->first == 7);
+        assert(next(m.begin(), 3)->second == 7.5);
+
+        s = m.erase(6);
+        assert(m.size() == 3);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+        assert(next(m.begin(), 2)->first == 7);
+        assert(next(m.begin(), 2)->second == 7.5);
+
+        s = m.erase(7);
+        assert(m.size() == 2);
+        assert(s == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 2.5);
+        assert(next(m.begin())->first == 5);
+        assert(next(m.begin())->second == 5.5);
+
+        s = m.erase(2);
+        assert(m.size() == 1);
+        assert(s == 1);
+        assert(m.begin()->first == 5);
+        assert(m.begin()->second == 5.5);
+
+        s = m.erase(5);
+        assert(m.size() == 0);
+        assert(s == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/final/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp
new file mode 100644
index 0000000..3d28242
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2, 2.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(r.first->first == 2);
+        assert(r.first->second == 2.5);
+
+        r = m.insert(M::value_type(1, 1.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(r.first->first == 1);
+        assert(r.first->second == 1.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2, 2.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(r.first->first == 2);
+        assert(r.first->second == 2.5);
+
+        r = m.insert(M::value_type(1, 1.5));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(r.first->first == 1);
+        assert(r.first->second == 1.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3.5);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/final/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..ab325ed
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::pair<const int, double> V;
+    std::map<int, double> m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    m.insert({
+                 {2, 1},
+                 {2, 1.5},
+                 {2, 2},
+             });
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    std::map<int, double, std::less<int>, min_allocator<V>> m =
+                            {
+                                {1, 1},
+                                {1, 1.5},
+                                {1, 2},
+                                {3, 1},
+                                {3, 1.5},
+                                {3, 2}
+                            };
+    m.insert({
+                 {2, 1},
+                 {2, 1.5},
+                 {2, 2},
+             });
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(2, 1));
+    assert(*next(m.begin(), 2) == V(3, 1));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/final/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..278db46
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(m.end(), M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(m.end(), M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/final/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..964738b
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::map<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m;
+        m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 3);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 1);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m;
+        m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 3);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 1);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/final/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..2216420
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+//     iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::map<int, MoveOnly> M;
+        typedef std::pair<int, MoveOnly> P;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), P(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(m.end(), P(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(m.end(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(m.end(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+        typedef std::pair<int, MoveOnly> P;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), P(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(m.end(), P(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(m.end(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(m.end(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/final/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp
new file mode 100644
index 0000000..fea8895
--- /dev/null
+++ b/final/test/containers/associative/map/map.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+//   pair<iterator, bool> insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::map<int, MoveOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2, 2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(r.first->first == 2);
+        assert(r.first->second == 2);
+
+        r = m.insert(M::value_type(1, 1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(r.first->first == 1);
+        assert(r.first->second == 1);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2, 2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(r.first->first == 2);
+        assert(r.first->second == 2);
+
+        r = m.insert(M::value_type(1, 1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(r.first->first == 1);
+        assert(r.first->second == 1);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/map/map.ops/count.pass.cpp b/final/test/containers/associative/map/map.ops/count.pass.cpp
new file mode 100644
index 0000000..6628e3d
--- /dev/null
+++ b/final/test/containers/associative/map/map.ops/count.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(5);
+        assert(r == 1);
+        r = m.count(6);
+        assert(r == 1);
+        r = m.count(7);
+        assert(r == 1);
+        r = m.count(8);
+        assert(r == 1);
+        r = m.count(9);
+        assert(r == 1);
+        r = m.count(10);
+        assert(r == 1);
+        r = m.count(11);
+        assert(r == 1);
+        r = m.count(12);
+        assert(r == 1);
+        r = m.count(4);
+        assert(r == 0);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(5);
+        assert(r == 1);
+        r = m.count(6);
+        assert(r == 1);
+        r = m.count(7);
+        assert(r == 1);
+        r = m.count(8);
+        assert(r == 1);
+        r = m.count(9);
+        assert(r == 1);
+        r = m.count(10);
+        assert(r == 1);
+        r = m.count(11);
+        assert(r == 1);
+        r = m.count(12);
+        assert(r == 1);
+        r = m.count(4);
+        assert(r == 0);
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.ops/equal_range.pass.cpp b/final/test/containers/associative/map/map.ops/equal_range.pass.cpp
new file mode 100644
index 0000000..dff751c
--- /dev/null
+++ b/final/test/containers/associative/map/map.ops/equal_range.pass.cpp
@@ -0,0 +1,437 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator,iterator>             equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<>> M;
+    typedef std::pair<M::iterator, M::iterator> R;
+
+    V ar[] =
+    {
+        V(5, 5),
+        V(7, 6),
+        V(9, 7),
+        V(11, 8),
+        V(13, 9),
+        V(15, 10),
+        V(17, 11),
+        V(19, 12)
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.equal_range(5);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(7);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(9);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(11);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(13);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(15);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(17);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(19);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 8));
+    r = m.equal_range(4);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 0));
+    r = m.equal_range(6);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(8);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(10);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(12);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(14);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(16);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(18);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(20);
+    assert(r.first == next(m.begin(), 8));
+    assert(r.second == next(m.begin(), 8));
+    }
+    {
+    typedef PrivateConstructor PC;
+    typedef std::map<PC, double, std::less<>> M;
+    typedef std::pair<M::iterator, M::iterator> R;
+
+    M m;
+    m [ PC::make(5)  ] = 5;
+    m [ PC::make(7)  ] = 6;
+    m [ PC::make(9)  ] = 7;
+    m [ PC::make(11) ] = 8;
+    m [ PC::make(13) ] = 9;
+    m [ PC::make(15) ] = 10;
+    m [ PC::make(17) ] = 11;
+    m [ PC::make(19) ] = 12;
+
+    R r = m.equal_range(5);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(7);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(9);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(11);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(13);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(15);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(17);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(19);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 8));
+    r = m.equal_range(4);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 0));
+    r = m.equal_range(6);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(8);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(10);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(12);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(14);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(16);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(18);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(20);
+    assert(r.first == next(m.begin(), 8));
+    assert(r.second == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.ops/find.pass.cpp b/final/test/containers/associative/map/map.ops/find.pass.cpp
new file mode 100644
index 0000000..a757844
--- /dev/null
+++ b/final/test/containers/associative/map/map.ops/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<>> M;
+    typedef M::iterator R;
+
+    V ar[] =
+    {
+        V(5, 5),
+        V(6, 6),
+        V(7, 7),
+        V(8, 8),
+        V(9, 9),
+        V(10, 10),
+        V(11, 11),
+        V(12, 12)
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.find(5);
+    assert(r == m.begin());
+    r = m.find(6);
+    assert(r == next(m.begin()));
+    r = m.find(7);
+    assert(r == next(m.begin(), 2));
+    r = m.find(8);
+    assert(r == next(m.begin(), 3));
+    r = m.find(9);
+    assert(r == next(m.begin(), 4));
+    r = m.find(10);
+    assert(r == next(m.begin(), 5));
+    r = m.find(11);
+    assert(r == next(m.begin(), 6));
+    r = m.find(12);
+    assert(r == next(m.begin(), 7));
+    r = m.find(4);
+    assert(r == next(m.begin(), 8));
+    }
+
+    {
+    typedef PrivateConstructor PC;
+    typedef std::map<PC, double, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m [ PC::make(5)  ] = 5;
+    m [ PC::make(6)  ] = 6;
+    m [ PC::make(7)  ] = 7;
+    m [ PC::make(8)  ] = 8;
+    m [ PC::make(9)  ] = 9;
+    m [ PC::make(10) ] = 10;
+    m [ PC::make(11) ] = 11;
+    m [ PC::make(12) ] = 12;
+
+    R r = m.find(5);
+    assert(r == m.begin());
+    r = m.find(6);
+    assert(r == next(m.begin()));
+    r = m.find(7);
+    assert(r == next(m.begin(), 2));
+    r = m.find(8);
+    assert(r == next(m.begin(), 3));
+    r = m.find(9);
+    assert(r == next(m.begin(), 4));
+    r = m.find(10);
+    assert(r == next(m.begin(), 5));
+    r = m.find(11);
+    assert(r == next(m.begin(), 6));
+    r = m.find(12);
+    assert(r == next(m.begin(), 7));
+    r = m.find(4);
+    assert(r == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.ops/lower_bound.pass.cpp b/final/test/containers/associative/map/map.ops/lower_bound.pass.cpp
new file mode 100644
index 0000000..87b84ee
--- /dev/null
+++ b/final/test/containers/associative/map/map.ops/lower_bound.pass.cpp
@@ -0,0 +1,336 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less <>> M;
+    typedef M::iterator R;
+
+    V ar[] =
+    {
+        V(5, 5),
+        V(7, 6),
+        V(9, 7),
+        V(11, 8),
+        V(13, 9),
+        V(15, 10),
+        V(17, 11),
+        V(19, 12)
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.lower_bound(5);
+    assert(r == m.begin());
+    r = m.lower_bound(7);
+    assert(r == next(m.begin()));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(11);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(13);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(15);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(17);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(19);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+    
+    {
+    typedef PrivateConstructor PC;
+    typedef std::map<PC, double, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m [ PC::make(5)  ] = 5;
+    m [ PC::make(7)  ] = 6;
+    m [ PC::make(9)  ] = 7;
+    m [ PC::make(11) ] = 8;
+    m [ PC::make(13) ] = 9;
+    m [ PC::make(15) ] = 10;
+    m [ PC::make(17) ] = 11;
+    m [ PC::make(19) ] = 12;
+
+    R r = m.lower_bound(5);
+    assert(r == m.begin());
+    r = m.lower_bound(7);
+    assert(r == next(m.begin()));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(11);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(13);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(15);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(17);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(19);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.ops/upper_bound.pass.cpp b/final/test/containers/associative/map/map.ops/upper_bound.pass.cpp
new file mode 100644
index 0000000..037ceb9
--- /dev/null
+++ b/final/test/containers/associative/map/map.ops/upper_bound.pass.cpp
@@ -0,0 +1,335 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 5),
+            V(7, 6),
+            V(9, 7),
+            V(11, 8),
+            V(13, 9),
+            V(15, 10),
+            V(17, 11),
+            V(19, 12)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<>> M;
+    typedef M::iterator R;
+    V ar[] =
+    {
+        V(5, 5),
+        V(7, 6),
+        V(9, 7),
+        V(11, 8),
+        V(13, 9),
+        V(15, 10),
+        V(17, 11),
+        V(19, 12)
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.upper_bound(5);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(11);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(13);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(15);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(17);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(19);
+    assert(r == next(m.begin(), 8));
+    r = m.upper_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+    
+    {
+    typedef PrivateConstructor PC;
+    typedef std::map<PC, double, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m [ PC::make(5)  ] = 5;
+    m [ PC::make(7)  ] = 6;
+    m [ PC::make(9)  ] = 7;
+    m [ PC::make(11) ] = 8;
+    m [ PC::make(13) ] = 9;
+    m [ PC::make(15) ] = 10;
+    m [ PC::make(17) ] = 11;
+    m [ PC::make(19) ] = 12;
+
+    R r = m.upper_bound(5);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(11);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(13);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(15);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(17);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(19);
+    assert(r == next(m.begin(), 8));
+    r = m.upper_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.special/member_swap.pass.cpp b/final/test/containers/associative/map/map.special/member_swap.pass.cpp
new file mode 100644
index 0000000..4f7bd51
--- /dev/null
+++ b/final/test/containers/associative/map/map.special/member_swap.pass.cpp
@@ -0,0 +1,201 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void swap(map& m);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.special/non_member_swap.pass.cpp b/final/test/containers/associative/map/map.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..57588e6
--- /dev/null
+++ b/final/test/containers/associative/map/map.special/non_member_swap.pass.cpp
@@ -0,0 +1,306 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class Key, class T, class Compare, class Allocator>
+//   void
+//   swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::map<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::map<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef min_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::map<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A());
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A());
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A());
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A());
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/map.special/swap_noexcept.pass.cpp b/final/test/containers/associative/map/map.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..b8b7863
--- /dev/null
+++ b/final/test/containers/associative/map/map.special/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// void swap(map& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::map<MoveOnly, MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/types.pass.cpp b/final/test/containers/associative/map/types.pass.cpp
new file mode 100644
index 0000000..d117def
--- /dev/null
+++ b/final/test/containers/associative/map/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+//           class Allocator = allocator<pair<const Key, T>>>
+// class map
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef T                                        mapped_type;
+//     typedef pair<const key_type, mapped_type>        value_type;
+//     typedef Compare                                  key_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::map<int, double> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::mapped_type, double>::value), "");
+    static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+    static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::mapped_type, double>::value), "");
+    static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
+    static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
+    static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
+//  min_allocator doesn't have a size_type, so one gets synthesized
+    static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/map/version.pass.cpp b/final/test/containers/associative/map/version.pass.cpp
new file mode 100644
index 0000000..b2e3fa4
--- /dev/null
+++ b/final/test/containers/associative/map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+#include <map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/associative/multimap/empty.pass.cpp b/final/test/containers/associative/multimap/empty.pass.cpp
new file mode 100644
index 0000000..2384960
--- /dev/null
+++ b/final/test/containers/associative/multimap/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multimap<int, double> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1, 1.5));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1, 1.5));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/iterator.pass.cpp b/final/test/containers/associative/multimap/iterator.pass.cpp
new file mode 100644
index 0000000..2763129
--- /dev/null
+++ b/final/test/containers/associative/multimap/iterator.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+//
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+//
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::multimap<int, double>::iterator i;
+        i = m.begin();
+        std::multimap<int, double>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= 8; ++j)
+            for (double d = 1; d <= 2; d += .5, ++i)
+            {
+                assert(i->first == j);
+                assert(i->second == d);
+                i->second = 2.5;
+                assert(i->second == 2.5);
+            }
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        const std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::multimap<int, double>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= 8; ++j)
+            for (double d = 1; d <= 2; d += .5, ++i)
+            {
+                assert(i->first == j);
+                assert(i->second == d);
+            }
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::multimap<int, double, std::less<int>, min_allocator<V>>::iterator i;
+        i = m.begin();
+        std::multimap<int, double, std::less<int>, min_allocator<V>>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= 8; ++j)
+            for (double d = 1; d <= 2; d += .5, ++i)
+            {
+                assert(i->first == j);
+                assert(i->second == d);
+                i->second = 2.5;
+                assert(i->second == 2.5);
+            }
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+            V(4, 1),
+            V(4, 1.5),
+            V(4, 2),
+            V(5, 1),
+            V(5, 1.5),
+            V(5, 2),
+            V(6, 1),
+            V(6, 1.5),
+            V(6, 2),
+            V(7, 1),
+            V(7, 1.5),
+            V(7, 2),
+            V(8, 1),
+            V(8, 1.5),
+            V(8, 2)
+        };
+        const std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::multimap<int, double, std::less<int>, min_allocator<V>>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= 8; ++j)
+            for (double d = 1; d <= 2; d += .5, ++i)
+            {
+                assert(i->first == j);
+                assert(i->second == d);
+            }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::multimap<int, double> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/max_size.pass.cpp b/final/test/containers/associative/multimap/max_size.pass.cpp
new file mode 100644
index 0000000..ccd8b10
--- /dev/null
+++ b/final/test/containers/associative/multimap/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multimap<int, double> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp
new file mode 100644
index 0000000..87bf044
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::less<int> C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::multimap<int, double, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::less<int> C;
+    typedef min_allocator<std::pair<const int, double> > A;
+    std::multimap<int, double, C, A> m(A{});
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..0c89918
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::multimap<int, double> C;
+    typedef C::value_type V;
+    C m = {{20, 1}};
+    m =
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           };
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+    typedef C::value_type V;
+    C m = {{20, 1}};
+    m =
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           };
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/compare.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/compare.pass.cpp
new file mode 100644
index 0000000..9a4e0f9
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef test_compare<std::less<int> > C;
+    std::multimap<int, double, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef test_compare<std::less<int> > C;
+    std::multimap<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..1224884
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<std::pair<const int, double> > A;
+    std::multimap<int, double, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef test_compare<std::less<int> > C;
+    typedef min_allocator<std::pair<const int, double> > A;
+    std::multimap<int, double, C, A> m(C(4), A());
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/copy.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/copy.pass.cpp
new file mode 100644
index 0000000..3d6626e
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/copy.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multimap<int, double, C, A> m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multimap<int, double, C, A> m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::multimap<int, double, C, A> m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..22594e3
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::multimap<int, double, C, A> m(mo, A(3));
+    assert(m == mo);
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef min_allocator<V> A;
+    std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+    std::multimap<int, double, C, A> m(mo, A());
+    assert(m == mo);
+    assert(m.get_allocator() == A());
+    assert(m.key_comp() == C(5));
+
+    assert(mo.get_allocator() == A());
+    assert(mo.key_comp() == C(5));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..2bdc4d6
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+    }
+    {
+        typedef std::pair<const int, double> V;
+        const V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        std::multimap<int, double> *p = &m;
+        m = *p;
+        assert(m.size() == sizeof(ar)/sizeof(ar[0]));
+        assert(std::equal(m.begin(), m.end(), ar));
+    }
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<const int, double> V;
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+        m = mo;
+        assert(m == mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/default.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/default.pass.cpp
new file mode 100644
index 0000000..1c3ab8c
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::multimap<int, double> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+    std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+    {
+    std::multimap<int, double> m = {};
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..315efd1
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..50d8f42
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// ~multimap() // implied noexcept;
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..937a202
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::multimap<int, double> C;
+    typedef C::value_type V;
+    C m =
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           };
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+    typedef C::value_type V;
+    C m =
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           };
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..e667703
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef test_compare<std::less<int> > Cmp;
+    typedef std::multimap<int, double, Cmp> C;
+    typedef C::value_type V;
+    C m(
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           },
+           Cmp(4)
+        );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    assert(m.key_comp() == Cmp(4));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef test_compare<std::less<int> > Cmp;
+    typedef std::multimap<int, double, Cmp, min_allocator<std::pair<const int, double>>> C;
+    typedef C::value_type V;
+    C m(
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           },
+           Cmp(4)
+        );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    assert(m.key_comp() == Cmp(4));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..0e73f72
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef test_compare<std::less<int> > Cmp;
+    typedef test_allocator<std::pair<const int, double> > A;
+    typedef std::multimap<int, double, Cmp, A> C;
+    typedef C::value_type V;
+    C m(
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           },
+           Cmp(4), A(5)
+        );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    assert(m.key_comp() == Cmp(4));
+    assert(m.get_allocator() == A(5));
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+    {
+    typedef test_compare<std::less<int> > Cmp;
+    typedef min_allocator<std::pair<const int, double> > A;
+    typedef std::multimap<int, double, Cmp, A> C;
+    typedef C::value_type V;
+    C m(
+           {
+               {1, 1},
+               {1, 1.5},
+               {1, 2},
+               {2, 1},
+               {2, 1.5},
+               {2, 2},
+               {3, 1},
+               {3, 1.5},
+               {3, 2}
+           },
+           Cmp(4), A()
+        );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    assert(m.key_comp() == Cmp(4));
+    assert(m.get_allocator() == A());
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef test_compare<std::less<int> > C;
+    typedef std::pair<const int, double> V;
+    typedef min_allocator<V> A;
+    typedef std::multimap<int, double, C, A> M;
+    A a;
+    M m ({ {1, 1},
+           {1, 1.5},
+           {1, 2},
+           {2, 1},
+           {2, 1.5},
+           {2, 2},
+           {3, 1},
+           {3, 1.5},
+           {3, 2}
+          }, a);
+
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    M::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 1.5));
+    assert(*++i == V(3, 2));
+    assert(m.get_allocator() == a);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..fa062e2
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//     multimap(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef min_allocator<std::pair<const int, double>> A;
+    A a;
+    std::multimap<int, double, std::less<int>, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+    assert(m.get_allocator() == a);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..d6de594
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//     multimap(InputIterator first, InputIterator last,
+//              const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    std::multimap<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    std::multimap<int, double, C, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 0000000..259fbd1
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//     multimap(InputIterator first, InputIterator last,
+//              const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    assert(m.get_allocator() == A(7));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::pair<const int, double> V;
+    V ar[] =
+    {
+        V(1, 1),
+        V(1, 1.5),
+        V(1, 2),
+        V(2, 1),
+        V(2, 1.5),
+        V(2, 2),
+        V(3, 1),
+        V(3, 1.5),
+        V(3, 2),
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef min_allocator<V> A;
+    std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+    assert(m.get_allocator() == A());
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*m.begin() == V(1, 1));
+    assert(*next(m.begin()) == V(1, 1.5));
+    assert(*next(m.begin(), 2) == V(1, 2));
+    assert(*next(m.begin(), 3) == V(2, 1));
+    assert(*next(m.begin(), 4) == V(2, 1.5));
+    assert(*next(m.begin(), 5) == V(2, 2));
+    assert(*next(m.begin(), 6) == V(3, 1));
+    assert(*next(m.begin(), 7) == V(3, 1.5));
+    assert(*next(m.begin(), 8) == V(3, 2));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/move.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/move.pass.cpp
new file mode 100644
index 0000000..aed0886
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/move.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    typedef std::pair<const int, double> V;
+    {
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(C(5), A(7));
+        std::multimap<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multimap<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(1, 1.5));
+        assert(*next(m.begin(), 2) == V(1, 2));
+        assert(*next(m.begin(), 3) == V(2, 1));
+        assert(*next(m.begin(), 4) == V(2, 1.5));
+        assert(*next(m.begin(), 5) == V(2, 2));
+        assert(*next(m.begin(), 6) == V(3, 1));
+        assert(*next(m.begin(), 7) == V(3, 1.5));
+        assert(*next(m.begin(), 8) == V(3, 2));
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::multimap<int, double, C, A> mo(C(5), A());
+        std::multimap<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        V ar[] =
+        {
+            V(1, 1),
+            V(1, 1.5),
+            V(1, 2),
+            V(2, 1),
+            V(2, 1.5),
+            V(2, 2),
+            V(3, 1),
+            V(3, 1.5),
+            V(3, 2),
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::multimap<int, double, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*m.begin() == V(1, 1));
+        assert(*next(m.begin()) == V(1, 1.5));
+        assert(*next(m.begin(), 2) == V(1, 2));
+        assert(*next(m.begin(), 3) == V(2, 1));
+        assert(*next(m.begin(), 4) == V(2, 1.5));
+        assert(*next(m.begin(), 5) == V(2, 2));
+        assert(*next(m.begin(), 6) == V(3, 1));
+        assert(*next(m.begin(), 7) == V(3, 1.5));
+        assert(*next(m.begin(), 8) == V(3, 2));
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..651993a
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef min_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+        M m3(std::move(m1), A());
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A());
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..496e535
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<MoveOnly, MoveOnly> V;
+        typedef std::pair<const MoveOnly, MoveOnly> VC;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef min_allocator<VC> A;
+        typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+        V a2[] =
+        {
+            V(1, 1),
+            V(1, 2),
+            V(1, 3),
+            V(2, 1),
+            V(2, 2),
+            V(2, 3),
+            V(3, 1),
+            V(3, 2),
+            V(3, 3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+        M m3(C(3), A());
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A());
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..b248818
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap& operator=(multimap&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/final/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..84316a1
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap(multimap&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..fe9b8c8
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..03da4af
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+//   iterator emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multimap<int, DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == DefaultOnly());
+        assert(DefaultOnly::count == 3);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multimap<int, Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+                                                  std::forward_as_tuple());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(3, 3.5));
+        assert(r == next(m.begin()));
+        assert(m.size() == 3);
+        assert(r->first == 1);
+        assert(r->second == Emplaceable(3, 3.5));
+    }
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple());
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == DefaultOnly());
+        assert(DefaultOnly::count == 3);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+                                                  std::forward_as_tuple());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+                                                std::forward_as_tuple(3, 3.5));
+        assert(r == next(m.begin()));
+        assert(m.size() == 3);
+        assert(r->first == 1);
+        assert(r->second == Emplaceable(3, 3.5));
+    }
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..846d599
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multimap<int, DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace_hint(m.cend(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace_hint(m.cend(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == DefaultOnly());
+        assert(DefaultOnly::count == 3);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multimap<int, Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+                                       std::forward_as_tuple(2),
+                                       std::forward_as_tuple());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple(3, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 3);
+        assert(r->first == 1);
+        assert(r->second == Emplaceable(3, 3.5));
+    }
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 0);
+        assert(m.begin()->second == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+        r = m.emplace_hint(m.cend(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+        r = m.emplace_hint(m.cend(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple());
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == DefaultOnly());
+        assert(DefaultOnly::count == 3);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+                                       std::forward_as_tuple(2),
+                                       std::forward_as_tuple());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == Emplaceable());
+        r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+                                       std::forward_as_tuple(1),
+                                       std::forward_as_tuple(3, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 3);
+        assert(r->first == 1);
+        assert(r->second == Emplaceable(3, 3.5));
+    }
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(m.begin()->first == 2);
+        assert(m.begin()->second == 3.5);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..d91295b
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,279 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 3));
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 1.5);
+        assert(next(m.begin(), 4)->first == 2);
+        assert(next(m.begin(), 4)->second == 2);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 1);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 1.5);
+        assert(next(m.begin(), 7)->first == 3);
+        assert(next(m.begin(), 7)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 7);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 2);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 1.5);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 2);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 1.5);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 6);
+        assert(i == prev(m.end()));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 2);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 1.5);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 2);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 5);
+        assert(i == next(m.begin()));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 1);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(next(m.begin(), 0)->first == 2);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 3);
+        assert(next(m.begin(), 1)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 1);
+        assert(i == m.end());
+        assert(next(m.begin(), 0)->first == 2);
+        assert(next(m.begin(), 0)->second == 1.5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 3));
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 1.5);
+        assert(next(m.begin(), 4)->first == 2);
+        assert(next(m.begin(), 4)->second == 2);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 1);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 1.5);
+        assert(next(m.begin(), 7)->first == 3);
+        assert(next(m.begin(), 7)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 7);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 2);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 1.5);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 2);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 1.5);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 6);
+        assert(i == prev(m.end()));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 2);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 1.5);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 2);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 5);
+        assert(i == next(m.begin()));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 2);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 1);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 2);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(next(m.begin(), 0)->first == 2);
+        assert(next(m.begin(), 0)->second == 1.5);
+        assert(next(m.begin(), 1)->first == 3);
+        assert(next(m.begin(), 1)->second == 2);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 1);
+        assert(i == m.end());
+        assert(next(m.begin(), 0)->first == 2);
+        assert(next(m.begin(), 0)->second == 1.5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..4d37894
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(m.cbegin(), m.cbegin());
+        assert(m.size() == 8);
+        assert(i == m.begin());
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        typedef M::iterator I;
+        P ar[] =
+        {
+            P(1, 1.5),
+            P(2, 2.5),
+            P(3, 3.5),
+            P(4, 4.5),
+            P(5, 5.5),
+            P(6, 6.5),
+            P(7, 7.5),
+            P(8, 8.5),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(m.cbegin(), m.cbegin());
+        assert(m.size() == 8);
+        assert(i == m.begin());
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1.5);
+        assert(next(m.begin())->first == 2);
+        assert(next(m.begin())->second == 2.5);
+        assert(next(m.begin(), 2)->first == 3);
+        assert(next(m.begin(), 2)->second == 3.5);
+        assert(next(m.begin(), 3)->first == 4);
+        assert(next(m.begin(), 3)->second == 4.5);
+        assert(next(m.begin(), 4)->first == 5);
+        assert(next(m.begin(), 4)->second == 5.5);
+        assert(next(m.begin(), 5)->first == 6);
+        assert(next(m.begin(), 5)->second == 6.5);
+        assert(next(m.begin(), 6)->first == 7);
+        assert(next(m.begin(), 6)->second == 7.5);
+        assert(next(m.begin(), 7)->first == 8);
+        assert(next(m.begin(), 7)->second == 8.5);
+
+        i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+        assert(next(m.begin(), 2)->first == 5);
+        assert(next(m.begin(), 2)->second == 5.5);
+        assert(next(m.begin(), 3)->first == 6);
+        assert(next(m.begin(), 3)->second == 6.5);
+        assert(next(m.begin(), 4)->first == 7);
+        assert(next(m.begin(), 4)->second == 7.5);
+        assert(next(m.begin(), 5)->first == 8);
+        assert(next(m.begin(), 5)->second == 8.5);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(next(m.begin(), 0)->first == 3);
+        assert(next(m.begin(), 0)->second == 3.5);
+        assert(next(m.begin(), 1)->first == 4);
+        assert(next(m.begin(), 1)->second == 4.5);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..ebae10e
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        typedef M::size_type I;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(2);
+        assert(m.size() == 6);
+        assert(i == 3);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(2);
+        assert(m.size() == 6);
+        assert(i == 0);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(3);
+        assert(m.size() == 3);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+
+        i = m.erase(1);
+        assert(m.size() == 0);
+        assert(i == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        typedef M::size_type I;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(2);
+        assert(m.size() == 6);
+        assert(i == 3);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(2);
+        assert(m.size() == 6);
+        assert(i == 0);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 3);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 3);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 3);
+        assert(next(m.begin(), 5)->second == 2);
+
+        i = m.erase(3);
+        assert(m.size() == 3);
+        assert(next(m.begin(), 0)->first == 1);
+        assert(next(m.begin(), 0)->second == 1);
+        assert(next(m.begin(), 1)->first == 1);
+        assert(next(m.begin(), 1)->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+
+        i = m.erase(1);
+        assert(m.size() == 0);
+        assert(i == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
new file mode 100644
index 0000000..d9afc9d
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..5e1a1d4
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::multimap<int, double> C;
+    typedef C::value_type V;
+    C m =
+           {
+               {1, 1},
+               {1, 2},
+               {2, 1},
+               {2, 2},
+               {3, 1},
+               {3, 2}
+           };
+    m.insert(
+               {
+                   {1, 1.5},
+                   {2, 1.5},
+                   {3, 1.5},
+               }
+            );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 2));
+    assert(*++i == V(3, 1.5));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+    typedef C::value_type V;
+    C m =
+           {
+               {1, 1},
+               {1, 2},
+               {2, 1},
+               {2, 2},
+               {3, 1},
+               {3, 2}
+           };
+    m.insert(
+               {
+                   {1, 1.5},
+                   {2, 1.5},
+                   {3, 1.5},
+               }
+            );
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1, 1));
+    assert(*++i == V(1, 2));
+    assert(*++i == V(1, 1.5));
+    assert(*++i == V(2, 1));
+    assert(*++i == V(2, 2));
+    assert(*++i == V(2, 1.5));
+    assert(*++i == V(3, 1));
+    assert(*++i == V(3, 2));
+    assert(*++i == V(3, 1.5));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..b83c802
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(m.end(), M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(prev(m.end()), M::value_type(3, 4.5));
+        assert(r == prev(m.end(), 2));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 4.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.end(), M::value_type(2, 2.5));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2.5);
+
+        r = m.insert(m.end(), M::value_type(1, 1.5));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1.5);
+
+        r = m.insert(m.end(), M::value_type(3, 3.5));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3.5);
+
+        r = m.insert(prev(m.end()), M::value_type(3, 4.5));
+        assert(r == prev(m.end(), 2));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 4.5);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..70ff7ef
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multimap<int, double> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m;
+        m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 9);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 2);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 2);
+        assert(next(m.begin(), 5)->second == 2);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 1);
+        assert(next(m.begin(), 7)->first == 3);
+        assert(next(m.begin(), 7)->second == 1.5);
+        assert(next(m.begin(), 8)->first == 3);
+        assert(next(m.begin(), 8)->second == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+        typedef std::pair<int, double> P;
+        P ar[] =
+        {
+            P(1, 1),
+            P(1, 1.5),
+            P(1, 2),
+            P(2, 1),
+            P(2, 1.5),
+            P(2, 2),
+            P(3, 1),
+            P(3, 1.5),
+            P(3, 2),
+        };
+        M m;
+        m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 9);
+        assert(m.begin()->first == 1);
+        assert(m.begin()->second == 1);
+        assert(next(m.begin())->first == 1);
+        assert(next(m.begin())->second == 1.5);
+        assert(next(m.begin(), 2)->first == 1);
+        assert(next(m.begin(), 2)->second == 2);
+        assert(next(m.begin(), 3)->first == 2);
+        assert(next(m.begin(), 3)->second == 1);
+        assert(next(m.begin(), 4)->first == 2);
+        assert(next(m.begin(), 4)->second == 1.5);
+        assert(next(m.begin(), 5)->first == 2);
+        assert(next(m.begin(), 5)->second == 2);
+        assert(next(m.begin(), 6)->first == 3);
+        assert(next(m.begin(), 6)->second == 1);
+        assert(next(m.begin(), 7)->first == 3);
+        assert(next(m.begin(), 7)->second == 1.5);
+        assert(next(m.begin(), 8)->first == 3);
+        assert(next(m.begin(), 8)->second == 2);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..60ca7d4
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+//     iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multimap<int, MoveOnly> M;
+        typedef std::pair<int, MoveOnly> P;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), P(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(m.cend(), P(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(m.cend(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(m.cend(), P(3, 2));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+        typedef std::pair<int, MoveOnly> P;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), P(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(m.cend(), P(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(m.cend(), P(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(m.cend(), P(3, 2));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/final/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
new file mode 100644
index 0000000..2f198f8
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+//   iterator insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multimap<int, MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(M::value_type(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2, 2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(r->first == 2);
+        assert(r->second == 2);
+
+        r = m.insert(M::value_type(1, 1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(r->first == 1);
+        assert(r->second == 1);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = m.insert(M::value_type(3, 3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(r->first == 3);
+        assert(r->second == 3);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multimap/multimap.ops/count.pass.cpp b/final/test/containers/associative/multimap/multimap.ops/count.pass.cpp
new file mode 100644
index 0000000..34c0413
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.ops/count.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    {
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(4);
+        assert(r == 0);
+        r = m.count(5);
+        assert(r == 3);
+        r = m.count(6);
+        assert(r == 0);
+        r = m.count(7);
+        assert(r == 3);
+        r = m.count(8);
+        assert(r == 0);
+        r = m.count(9);
+        assert(r == 3);
+        r = m.count(10);
+        assert(r == 0);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(4);
+        assert(r == 0);
+        r = m.count(5);
+        assert(r == 3);
+        r = m.count(6);
+        assert(r == 0);
+        r = m.count(7);
+        assert(r == 3);
+        r = m.count(8);
+        assert(r == 0);
+        r = m.count(9);
+        assert(r == 3);
+        r = m.count(10);
+        assert(r == 0);
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/final/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
new file mode 100644
index 0000000..a408796
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
@@ -0,0 +1,264 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// pair<iterator, iterator>             equal_range(const key_type& k);
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    {
+    typedef std::multimap<int, double> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first == m.begin());
+        assert(r.second == m.begin());
+        r = m.equal_range(5);
+        assert(r.first == m.begin());
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first == m.end());
+        assert(r.second == m.end());
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first == m.begin());
+        assert(r.second == m.begin());
+        r = m.equal_range(5);
+        assert(r.first == m.begin());
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first == m.end());
+        assert(r.second == m.end());
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first == m.begin());
+        assert(r.second == m.begin());
+        r = m.equal_range(5);
+        assert(r.first == m.begin());
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first == m.end());
+        assert(r.second == m.end());
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first == m.begin());
+        assert(r.second == m.begin());
+        r = m.equal_range(5);
+        assert(r.first == m.begin());
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first == m.end());
+        assert(r.second == m.end());
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double, std::less<>> M;
+
+    typedef std::pair<M::iterator, M::iterator> R;
+    V ar[] =
+    {
+        V(5, 1),
+        V(5, 2),
+        V(5, 3),
+        V(7, 1),
+        V(7, 2),
+        V(7, 3),
+        V(9, 1),
+        V(9, 2),
+        V(9, 3)
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.equal_range(4);
+    assert(r.first == m.begin());
+    assert(r.second == m.begin());
+    r = m.equal_range(5);
+    assert(r.first == m.begin());
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(6);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(7);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(8);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(9);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 9));
+    r = m.equal_range(10);
+    assert(r.first == m.end());
+    assert(r.second == m.end());
+    }
+
+    {
+    typedef PrivateConstructor PC;
+    typedef std::multimap<PC, double, std::less<>> M;
+    typedef std::pair<M::iterator, M::iterator> R;
+
+    M m;
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+//  assert(m.size() == 9);
+    R r = m.equal_range(4);
+    assert(r.first == m.begin());
+    assert(r.second == m.begin());
+    r = m.equal_range(5);
+    assert(r.first == m.begin());
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(6);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(7);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(8);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(9);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 9));
+    r = m.equal_range(10);
+    assert(r.first == m.end());
+    assert(r.second == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.ops/find.pass.cpp b/final/test/containers/associative/multimap/multimap.ops/find.pass.cpp
new file mode 100644
index 0000000..fb5afa2
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.ops/find.pass.cpp
@@ -0,0 +1,209 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    {
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == m.end());
+        r = m.find(7);
+        assert(r == next(m.begin(), 3));
+        r = m.find(8);
+        assert(r == m.end());
+        r = m.find(9);
+        assert(r == next(m.begin(), 6));
+        r = m.find(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == m.end());
+        r = m.find(7);
+        assert(r == next(m.begin(), 3));
+        r = m.find(8);
+        assert(r == m.end());
+        r = m.find(9);
+        assert(r == next(m.begin(), 6));
+        r = m.find(10);
+        assert(r == m.end());
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == m.end());
+        r = m.find(7);
+        assert(r == next(m.begin(), 3));
+        r = m.find(8);
+        assert(r == m.end());
+        r = m.find(9);
+        assert(r == next(m.begin(), 6));
+        r = m.find(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == m.end());
+        r = m.find(7);
+        assert(r == next(m.begin(), 3));
+        r = m.find(8);
+        assert(r == m.end());
+        r = m.find(9);
+        assert(r == next(m.begin(), 6));
+        r = m.find(10);
+        assert(r == m.end());
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double, std::less<>> M;
+    typedef M::iterator R;
+
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == m.end());
+        r = m.find(7);
+        assert(r == next(m.begin(), 3));
+        r = m.find(8);
+        assert(r == m.end());
+        r = m.find(9);
+        assert(r == next(m.begin(), 6));
+        r = m.find(10);
+        assert(r == m.end());
+    }
+
+    {
+    typedef PrivateConstructor PC;
+    typedef std::multimap<PC, double, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+    R r = m.find(5);
+    assert(r == m.begin());
+    r = m.find(6);
+    assert(r == m.end());
+    r = m.find(7);
+    assert(r == next(m.begin(), 3));
+    r = m.find(8);
+    assert(r == m.end());
+    r = m.find(9);
+    assert(r == next(m.begin(), 6));
+    r = m.find(10);
+    assert(r == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/final/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
new file mode 100644
index 0000000..49cf6de
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
@@ -0,0 +1,221 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    {
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == m.begin());
+        r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == m.begin());
+        r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(10);
+        assert(r == m.end());
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == m.begin());
+        r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(4);
+        assert(r == m.begin());
+        r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(7);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(10);
+        assert(r == m.end());
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double, std::less<>> M;
+    typedef M::iterator R;
+    V ar[] =
+    {
+        V(5, 1),
+        V(5, 2),
+        V(5, 3),
+        V(7, 1),
+        V(7, 2),
+        V(7, 3),
+        V(9, 1),
+        V(9, 2),
+        V(9, 3)
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.lower_bound(4);
+    assert(r == m.begin());
+    r = m.lower_bound(5);
+    assert(r == m.begin());
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(7);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(10);
+    assert(r == m.end());
+    }
+
+    {
+    typedef PrivateConstructor PC;
+    typedef std::multimap<PC, double, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+    R r = m.lower_bound(4);
+    assert(r == m.begin());
+    r = m.lower_bound(5);
+    assert(r == m.begin());
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(7);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(10);
+    assert(r == m.end());
+    }
+
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/final/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
new file mode 100644
index 0000000..1920647
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
@@ -0,0 +1,221 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    {
+    typedef std::multimap<int, double> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == m.begin());
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == m.begin());
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(10);
+        assert(r == m.end());
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == m.begin());
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(10);
+        assert(r == m.end());
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            V(5, 1),
+            V(5, 2),
+            V(5, 3),
+            V(7, 1),
+            V(7, 2),
+            V(7, 3),
+            V(9, 1),
+            V(9, 2),
+            V(9, 3)
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == m.begin());
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(10);
+        assert(r == m.end());
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<const int, double> V;
+    typedef std::multimap<int, double, std::less<>> M;
+    typedef M::iterator R;
+    V ar[] =
+    {
+        V(5, 1),
+        V(5, 2),
+        V(5, 3),
+        V(7, 1),
+        V(7, 2),
+        V(7, 3),
+        V(9, 1),
+        V(9, 2),
+        V(9, 3)
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.upper_bound(4);
+    assert(r == m.begin());
+    r = m.upper_bound(5);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 9));
+    r = m.upper_bound(10);
+    assert(r == m.end());
+    }
+
+    {
+    typedef PrivateConstructor PC;
+    typedef std::multimap<PC, double, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+    m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+    R r = m.upper_bound(4);
+    assert(r == m.begin());
+    r = m.upper_bound(5);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 9));
+    r = m.upper_bound(10);
+    assert(r == m.end());
+    }
+
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp b/final/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp
new file mode 100644
index 0000000..c8f30aa
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.special/member_swap.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void swap(multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    {
+    typedef std::multimap<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp b/final/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..effec2b
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class Key, class T, class Compare, class Allocator>
+//   void
+//   swap(multimap<Key, T, Compare, Allocator>& x, multimap<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+    typedef std::pair<const int, double> V;
+    {
+    typedef std::multimap<int, double> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::multimap<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::multimap<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef min_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::multimap<int, double, C, A> M;
+        V ar1[] =
+        {
+            V(1, 1),
+            V(2, 2),
+            V(3, 3),
+            V(4, 4)
+        };
+        V ar2[] =
+        {
+            V(5, 5),
+            V(6, 6),
+            V(7, 7),
+            V(8, 8),
+            V(9, 9),
+            V(10, 10),
+            V(11, 11),
+            V(12, 12)
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A());
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A());
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A());
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A());
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/final/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..687c443
--- /dev/null
+++ b/final/test/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// void swap(multimap& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multimap<MoveOnly, MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/scary.pass.cpp b/final/test/containers/associative/multimap/scary.pass.cpp
new file mode 100644
index 0000000..b99d9bc
--- /dev/null
+++ b/final/test/containers/associative/multimap/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map class multimap
+
+// Extension:  SCARY/N2913 iterator compatibility between map and multimap
+
+#include <map>
+
+int main()
+{
+    typedef std::map<int, int> M1;
+    typedef std::multimap<int, int> M2;
+    M2::iterator i;
+    M1::iterator j = i;
+}
diff --git a/final/test/containers/associative/multimap/size.pass.cpp b/final/test/containers/associative/multimap/size.pass.cpp
new file mode 100644
index 0000000..ac71d4c
--- /dev/null
+++ b/final/test/containers/associative/multimap/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multimap<int, double> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2, 1.5));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1, 1.5));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3, 1.5));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2, 1.5));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1, 1.5));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3, 1.5));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multimap/types.pass.cpp b/final/test/containers/associative/multimap/types.pass.cpp
new file mode 100644
index 0000000..a0f4db0
--- /dev/null
+++ b/final/test/containers/associative/multimap/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+//           class Allocator = allocator<pair<const Key, T>>>
+// class multimap
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef T                                        mapped_type;
+//     typedef pair<const key_type, mapped_type>        value_type;
+//     typedef Compare                                  key_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multimap<int, double> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::mapped_type, double>::value), "");
+    static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+    static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
+    static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::mapped_type, double>::value), "");
+    static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
+    static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+    static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
+    static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
+//  min_allocator doesn't have a size_type, so one gets synthesized
+    static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/clear.pass.cpp b/final/test/containers/associative/multiset/clear.pass.cpp
new file mode 100644
index 0000000..3069de5
--- /dev/null
+++ b/final/test/containers/associative/multiset/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/count.pass.cpp b/final/test/containers/associative/multiset/count.pass.cpp
new file mode 100644
index 0000000..12af167
--- /dev/null
+++ b/final/test/containers/associative/multiset/count.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(4);
+        assert(r == 0);
+        r = m.count(5);
+        assert(r == 4);
+        r = m.count(6);
+        assert(r == 0);
+        r = m.count(7);
+        assert(r == 3);
+        r = m.count(8);
+        assert(r == 0);
+        r = m.count(9);
+        assert(r == 2);
+        r = m.count(10);
+        assert(r == 0);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+    {
+        typedef M::size_type R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(4);
+        assert(r == 0);
+        r = m.count(5);
+        assert(r == 4);
+        r = m.count(6);
+        assert(r == 0);
+        r = m.count(7);
+        assert(r == 3);
+        r = m.count(8);
+        assert(r == 0);
+        r = m.count(9);
+        assert(r == 2);
+        r = m.count(10);
+        assert(r == 0);
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/emplace.pass.cpp b/final/test/containers/associative/multiset/emplace.pass.cpp
new file mode 100644
index 0000000..450ee6c
--- /dev/null
+++ b/final/test/containers/associative/multiset/emplace.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+//   iterator emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multiset<DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace();
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multiset<Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace();
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace(2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+        r = m.emplace(2, 3.5);
+        assert(r == next(m.begin(), 2));
+        assert(m.size() == 3);
+        assert(*r == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multiset/emplace_hint.pass.cpp b/final/test/containers/associative/multiset/emplace_hint.pass.cpp
new file mode 100644
index 0000000..194adf7
--- /dev/null
+++ b/final/test/containers/associative/multiset/emplace_hint.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multiset<DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace_hint(m.cbegin());
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 2);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::multiset<Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace_hint(m.cend(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.cbegin(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 3);
+        assert(*r == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multiset/empty.pass.cpp b/final/test/containers/associative/multiset/empty.pass.cpp
new file mode 100644
index 0000000..32aef90
--- /dev/null
+++ b/final/test/containers/associative/multiset/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multiset<int> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/equal_range.pass.cpp b/final/test/containers/associative/multiset/equal_range.pass.cpp
new file mode 100644
index 0000000..8c69d0c
--- /dev/null
+++ b/final/test/containers/associative/multiset/equal_range.pass.cpp
@@ -0,0 +1,263 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// pair<iterator,iterator>             equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(5);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first  == next(m.begin(), 9));
+        assert(r.second == next(m.begin(), 9));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(5);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first  == next(m.begin(), 9));
+        assert(r.second == next(m.begin(), 9));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(5);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first  == next(m.begin(), 9));
+        assert(r.second == next(m.begin(), 9));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(4);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(5);
+        assert(r.first  == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(6);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(7);
+        assert(r.first  == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(8);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(9);
+        assert(r.first  == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 9));
+        r = m.equal_range(10);
+        assert(r.first  == next(m.begin(), 9));
+        assert(r.second == next(m.begin(), 9));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::multiset<V, std::less<>> M;
+    typedef std::pair<M::iterator, M::iterator> R;
+    V ar[] =
+    {
+        5,
+        5,
+        5,
+        7,
+        7,
+        7,
+        9,
+        9,
+        9
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.equal_range(4);
+    assert(r.first  == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 0));
+    r = m.equal_range(5);
+    assert(r.first  == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(6);
+    assert(r.first  == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(7);
+    assert(r.first  == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(8);
+    assert(r.first  == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(9);
+    assert(r.first  == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 9));
+    r = m.equal_range(10);
+    assert(r.first  == next(m.begin(), 9));
+    assert(r.second == next(m.begin(), 9));
+    }
+
+    {
+    typedef PrivateConstructor V;
+    typedef std::multiset<V, std::less<>> M;
+    typedef std::pair<M::iterator, M::iterator> R;
+
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 9 ));
+
+    R r = m.equal_range(4);
+    assert(r.first  == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 0));
+    r = m.equal_range(5);
+    assert(r.first  == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(6);
+    assert(r.first  == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(7);
+    assert(r.first  == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(8);
+    assert(r.first  == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(9);
+    assert(r.first  == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 9));
+    r = m.equal_range(10);
+    assert(r.first  == next(m.begin(), 9));
+    assert(r.second == next(m.begin(), 9));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/erase_iter.pass.cpp b/final/test/containers/associative/multiset/erase_iter.pass.cpp
new file mode 100644
index 0000000..b665666
--- /dev/null
+++ b/final/test/containers/associative/multiset/erase_iter.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/erase_iter_iter.pass.cpp b/final/test/containers/associative/multiset/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..e1d7090
--- /dev/null
+++ b/final/test/containers/associative/multiset/erase_iter_iter.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 5));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 7);
+        assert(*next(m.begin(), 3) == 8);
+
+        i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 8);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 5));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 7);
+        assert(*next(m.begin(), 3) == 8);
+
+        i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 8);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/erase_key.pass.cpp b/final/test/containers/associative/multiset/erase_key.pass.cpp
new file mode 100644
index 0000000..e9bce1e
--- /dev/null
+++ b/final/test/containers/associative/multiset/erase_key.pass.cpp
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        typedef M::size_type I;
+        V ar[] =
+        {
+            3,
+            3,
+            3,
+            5,
+            5,
+            5,
+            7,
+            7,
+            7
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(6);
+        assert(m.size() == 9);
+        assert(i == 0);
+        assert(*next(m.begin(), 0) == 3);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 5);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 7);
+        assert(*next(m.begin(), 8) == 7);
+
+        i = m.erase(5);
+        assert(m.size() == 6);
+        assert(i == 3);
+        assert(*next(m.begin(), 0) == 3);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 7);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 7);
+
+        i = m.erase(3);
+        assert(m.size() == 3);
+        assert(i == 3);
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 7);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(7);
+        assert(m.size() == 0);
+        assert(i == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        typedef M::size_type I;
+        V ar[] =
+        {
+            3,
+            3,
+            3,
+            5,
+            5,
+            5,
+            7,
+            7,
+            7
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 9);
+        I i = m.erase(6);
+        assert(m.size() == 9);
+        assert(i == 0);
+        assert(*next(m.begin(), 0) == 3);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 5);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 7);
+        assert(*next(m.begin(), 8) == 7);
+
+        i = m.erase(5);
+        assert(m.size() == 6);
+        assert(i == 3);
+        assert(*next(m.begin(), 0) == 3);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 7);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 7);
+
+        i = m.erase(3);
+        assert(m.size() == 3);
+        assert(i == 3);
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 7);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(7);
+        assert(m.size() == 0);
+        assert(i == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/find.pass.cpp b/final/test/containers/associative/multiset/find.pass.cpp
new file mode 100644
index 0000000..364460a
--- /dev/null
+++ b/final/test/containers/associative/multiset/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+        typedef int V;
+        typedef std::multiset<int> M;
+        {
+            typedef M::iterator R;
+            V ar[] =
+            {
+                5,
+                6,
+                7,
+                8,
+                9,
+                10,
+                11,
+                12
+            };
+            M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.find(5);
+            assert(r == m.begin());
+            r = m.find(6);
+            assert(r == next(m.begin()));
+            r = m.find(7);
+            assert(r == next(m.begin(), 2));
+            r = m.find(8);
+            assert(r == next(m.begin(), 3));
+            r = m.find(9);
+            assert(r == next(m.begin(), 4));
+            r = m.find(10);
+            assert(r == next(m.begin(), 5));
+            r = m.find(11);
+            assert(r == next(m.begin(), 6));
+            r = m.find(12);
+            assert(r == next(m.begin(), 7));
+            r = m.find(4);
+            assert(r == next(m.begin(), 8));
+        }
+        {
+            typedef M::const_iterator R;
+            V ar[] =
+            {
+                5,
+                6,
+                7,
+                8,
+                9,
+                10,
+                11,
+                12
+            };
+            const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.find(5);
+            assert(r == m.begin());
+            r = m.find(6);
+            assert(r == next(m.begin()));
+            r = m.find(7);
+            assert(r == next(m.begin(), 2));
+            r = m.find(8);
+            assert(r == next(m.begin(), 3));
+            r = m.find(9);
+            assert(r == next(m.begin(), 4));
+            r = m.find(10);
+            assert(r == next(m.begin(), 5));
+            r = m.find(11);
+            assert(r == next(m.begin(), 6));
+            r = m.find(12);
+            assert(r == next(m.begin(), 7));
+            r = m.find(4);
+            assert(r == next(m.begin(), 8));
+        }
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int V;
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        {
+            typedef M::iterator R;
+            V ar[] =
+            {
+                5,
+                6,
+                7,
+                8,
+                9,
+                10,
+                11,
+                12
+            };
+            M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.find(5);
+            assert(r == m.begin());
+            r = m.find(6);
+            assert(r == next(m.begin()));
+            r = m.find(7);
+            assert(r == next(m.begin(), 2));
+            r = m.find(8);
+            assert(r == next(m.begin(), 3));
+            r = m.find(9);
+            assert(r == next(m.begin(), 4));
+            r = m.find(10);
+            assert(r == next(m.begin(), 5));
+            r = m.find(11);
+            assert(r == next(m.begin(), 6));
+            r = m.find(12);
+            assert(r == next(m.begin(), 7));
+            r = m.find(4);
+            assert(r == next(m.begin(), 8));
+        }
+        {
+            typedef M::const_iterator R;
+            V ar[] =
+            {
+                5,
+                6,
+                7,
+                8,
+                9,
+                10,
+                11,
+                12
+            };
+            const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.find(5);
+            assert(r == m.begin());
+            r = m.find(6);
+            assert(r == next(m.begin()));
+            r = m.find(7);
+            assert(r == next(m.begin(), 2));
+            r = m.find(8);
+            assert(r == next(m.begin(), 3));
+            r = m.find(9);
+            assert(r == next(m.begin(), 4));
+            r = m.find(10);
+            assert(r == next(m.begin(), 5));
+            r = m.find(11);
+            assert(r == next(m.begin(), 6));
+            r = m.find(12);
+            assert(r == next(m.begin(), 7));
+            r = m.find(4);
+            assert(r == next(m.begin(), 8));
+        }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::multiset<V, std::less<>> M;
+    typedef M::iterator R;
+
+    V ar[] =
+    {
+        5,
+        6,
+        7,
+        8,
+        9,
+        10,
+        11,
+        12
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.find(5);
+    assert(r == m.begin());
+    r = m.find(6);
+    assert(r == next(m.begin()));
+    r = m.find(7);
+    assert(r == next(m.begin(), 2));
+    r = m.find(8);
+    assert(r == next(m.begin(), 3));
+    r = m.find(9);
+    assert(r == next(m.begin(), 4));
+    r = m.find(10);
+    assert(r == next(m.begin(), 5));
+    r = m.find(11);
+    assert(r == next(m.begin(), 6));
+    r = m.find(12);
+    assert(r == next(m.begin(), 7));
+    r = m.find(4);
+    assert(r == next(m.begin(), 8));
+    }
+
+    {
+    typedef PrivateConstructor V;
+    typedef std::multiset<V, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 6 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 8 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 10 ));
+    m.insert ( V::make ( 11 ));
+    m.insert ( V::make ( 12 ));
+
+    R r = m.find(5);
+    assert(r == m.begin());
+    r = m.find(6);
+    assert(r == next(m.begin()));
+    r = m.find(7);
+    assert(r == next(m.begin(), 2));
+    r = m.find(8);
+    assert(r == next(m.begin(), 3));
+    r = m.find(9);
+    assert(r == next(m.begin(), 4));
+    r = m.find(10);
+    assert(r == next(m.begin(), 5));
+    r = m.find(11);
+    assert(r == next(m.begin(), 6));
+    r = m.find(12);
+    assert(r == next(m.begin(), 7));
+    r = m.find(4);
+    assert(r == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/insert_cv.pass.cpp b/final/test/containers/associative/multiset/insert_cv.pass.cpp
new file mode 100644
index 0000000..1797157
--- /dev/null
+++ b/final/test/containers/associative/multiset/insert_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/insert_initializer_list.pass.cpp b/final/test/containers/associative/multiset/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..7e923f2
--- /dev/null
+++ b/final/test/containers/associative/multiset/insert_initializer_list.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::multiset<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m.insert({1, 2, 3, 4, 5, 6});
+    assert(m.size() == 8);
+    assert(distance(m.begin(), m.end()) == m.size());
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(*++i == V(8));
+    assert(*++i == V(10));
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m.insert({1, 2, 3, 4, 5, 6});
+    assert(m.size() == 8);
+    assert(distance(m.begin(), m.end()) == m.size());
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(*++i == V(8));
+    assert(*++i == V(10));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/insert_iter_cv.pass.cpp b/final/test/containers/associative/multiset/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..7d20402
--- /dev/null
+++ b/final/test/containers/associative/multiset/insert_iter_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/insert_iter_iter.pass.cpp b/final/test/containers/associative/multiset/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..189c454
--- /dev/null
+++ b/final/test/containers/associative/multiset/insert_iter_iter.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::multiset<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        M m;
+        m.insert(input_iterator<const V*>(ar),
+                 input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        M m;
+        m.insert(input_iterator<const V*>(ar),
+                 input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/insert_iter_rv.pass.cpp b/final/test/containers/associative/multiset/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..342c6fd
--- /dev/null
+++ b/final/test/containers/associative/multiset/insert_iter_rv.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multiset<MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/insert_rv.pass.cpp b/final/test/containers/associative/multiset/insert_rv.pass.cpp
new file mode 100644
index 0000000..1030e08
--- /dev/null
+++ b/final/test/containers/associative/multiset/insert_rv.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::multiset<MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 4);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/iterator.pass.cpp b/final/test/containers/associative/multiset/iterator.pass.cpp
new file mode 100644
index 0000000..d1f0ecf
--- /dev/null
+++ b/final/test/containers/associative/multiset/iterator.pass.cpp
@@ -0,0 +1,215 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+//
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+//
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::multiset<int>::iterator i;
+        i = m.begin();
+        std::multiset<int>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= 8; ++j)
+            for (int k = 0; k < 3; ++k, ++i)
+                assert(*i == j);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        const std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::multiset<int>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= 8; ++j)
+            for (int k = 0; k < 3; ++k, ++i)
+                assert(*i == j);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::multiset<int, std::less<int>, min_allocator<int>>::iterator i;
+        i = m.begin();
+        std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= 8; ++j)
+            for (int k = 0; k < 3; ++k, ++i)
+                assert(*i == j);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        const std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= 8; ++j)
+            for (int k = 0; k < 3; ++k, ++i)
+                assert(*i == j);
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::multiset<int> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/lower_bound.pass.cpp b/final/test/containers/associative/multiset/lower_bound.pass.cpp
new file mode 100644
index 0000000..e466791
--- /dev/null
+++ b/final/test/containers/associative/multiset/lower_bound.pass.cpp
@@ -0,0 +1,223 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+        typedef int V;
+        typedef std::multiset<int> M;
+        {
+            typedef M::iterator R;
+            V ar[] =
+            {
+                5,
+                5,
+                5,
+                7,
+                7,
+                7,
+                9,
+                9,
+                9
+            };
+            M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.lower_bound(4);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(5);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(6);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(7);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(8);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(9);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(11);
+            assert(r == next(m.begin(), 9));
+        }
+        {
+            typedef M::const_iterator R;
+            V ar[] =
+            {
+                5,
+                5,
+                5,
+                7,
+                7,
+                7,
+                9,
+                9,
+                9
+            };
+            const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.lower_bound(4);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(5);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(6);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(7);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(8);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(9);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(11);
+            assert(r == next(m.begin(), 9));
+        }
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int V;
+        typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+        {
+            typedef M::iterator R;
+            V ar[] =
+            {
+                5,
+                5,
+                5,
+                7,
+                7,
+                7,
+                9,
+                9,
+                9
+            };
+            M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.lower_bound(4);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(5);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(6);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(7);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(8);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(9);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(11);
+            assert(r == next(m.begin(), 9));
+        }
+        {
+            typedef M::const_iterator R;
+            V ar[] =
+            {
+                5,
+                5,
+                5,
+                7,
+                7,
+                7,
+                9,
+                9,
+                9
+            };
+            const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+            R r = m.lower_bound(4);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(5);
+            assert(r == next(m.begin(), 0));
+            r = m.lower_bound(6);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(7);
+            assert(r == next(m.begin(), 3));
+            r = m.lower_bound(8);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(9);
+            assert(r == next(m.begin(), 6));
+            r = m.lower_bound(11);
+            assert(r == next(m.begin(), 9));
+        }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::multiset<V, std::less<>> M;
+
+    typedef M::iterator R;
+    V ar[] =
+    {
+        5,
+        5,
+        5,
+        7,
+        7,
+        7,
+        9,
+        9,
+        9
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+
+    R r = m.lower_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(5);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(7);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(11);
+    assert(r == next(m.begin(), 9));
+    }
+
+    {
+    typedef PrivateConstructor V;
+    typedef std::multiset<V, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 9 ));
+
+    R r = m.lower_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(5);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(7);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(11);
+    assert(r == next(m.begin(), 9));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/max_size.pass.cpp b/final/test/containers/associative/multiset/max_size.pass.cpp
new file mode 100644
index 0000000..5524f77
--- /dev/null
+++ b/final/test/containers/associative/multiset/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multiset<int> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/alloc.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/alloc.pass.cpp
new file mode 100644
index 0000000..0a75722
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+    typedef std::less<int> C;
+    typedef test_allocator<int> A;
+    std::multiset<int, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..7d76581
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::multiset<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/compare.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/compare.pass.cpp
new file mode 100644
index 0000000..84038ca
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// explicit multiset(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    std::multiset<int, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..76c9f8b
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<int> A;
+    std::multiset<int, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/copy.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/copy.pass.cpp
new file mode 100644
index 0000000..dde3628
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/copy.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multiset<int, C, A> m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multiset<int, C, A> m = mo;
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..04a769e
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::multiset<int, C, A> m(mo, A(3));
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+    assert(mo.size() == 9);
+    assert(distance(mo.begin(), mo.end()) == 9);
+    assert(*next(mo.begin(), 0) == 1);
+    assert(*next(mo.begin(), 1) == 1);
+    assert(*next(mo.begin(), 2) == 1);
+    assert(*next(mo.begin(), 3) == 2);
+    assert(*next(mo.begin(), 4) == 2);
+    assert(*next(mo.begin(), 5) == 2);
+    assert(*next(mo.begin(), 6) == 3);
+    assert(*next(mo.begin(), 7) == 3);
+    assert(*next(mo.begin(), 8) == 3);
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..cca6363
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(const multiset& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+    {
+        typedef int V;
+        const V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        std::multiset<int> *p = &m;
+        m = *p;
+        assert(m.size() == 9);
+        assert(std::equal(m.begin(), m.end(), ar));
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 9);
+        assert(distance(mo.begin(), mo.end()) == 9);
+        assert(*next(mo.begin(), 0) == 1);
+        assert(*next(mo.begin(), 1) == 1);
+        assert(*next(mo.begin(), 2) == 1);
+        assert(*next(mo.begin(), 3) == 2);
+        assert(*next(mo.begin(), 4) == 2);
+        assert(*next(mo.begin(), 5) == 2);
+        assert(*next(mo.begin(), 6) == 3);
+        assert(*next(mo.begin(), 7) == 3);
+        assert(*next(mo.begin(), 8) == 3);
+    }
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/default.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/default.pass.cpp
new file mode 100644
index 0000000..5bb0312
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::multiset<int> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+    std::multiset<int, std::less<int>, min_allocator<int>> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+    {
+    std::multiset<int> m = {};
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..a0bdb07
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..658af1a
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// ~multiset() // implied noexcept;
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..dadafec
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::multiset<int> C;
+    typedef C::value_type V;
+    C m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+    typedef C::value_type V;
+    C m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+    typedef C::value_type V;
+    min_allocator<int> a;
+    C m ({1, 2, 3, 4, 5, 6}, a);
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.get_allocator() == a);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..c67657a
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    typedef test_compare<std::less<int> > Cmp;
+    typedef std::multiset<int, Cmp> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..8311489
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    typedef test_compare<std::less<int> > Cmp;
+    typedef test_allocator<int> A;
+    typedef std::multiset<int, Cmp, A> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+    assert(m.get_allocator() == A(4));
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..f6c1fd7
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//     multiset(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    std::multiset<V> m(input_iterator<const int*>(ar),
+                  input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    std::multiset<V, std::less<V>, min_allocator<V>> m(input_iterator<const int*>(ar),
+                  input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..4ed00c7
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//     multiset(InputIterator first, InputIterator last,
+//         const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    typedef test_allocator<V> A;
+    std::multiset<V, C, A> m(input_iterator<const V*>(ar),
+                        input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+                        C(5), A(7));
+    assert(m.value_comp() == C(5));
+    assert(m.get_allocator() == A(7));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_allocator<V> A;
+    typedef test_compare<std::less<int> > C;
+    A a;
+    std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+    assert(m.get_allocator() == a);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..0bbaaf1
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+//     multiset(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    std::multiset<V, C> m(input_iterator<const V*>(ar),
+                     input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+    assert(m.value_comp() == C(5));
+    assert(m.size() == 9);
+    assert(distance(m.begin(), m.end()) == 9);
+    assert(*next(m.begin(), 0) == 1);
+    assert(*next(m.begin(), 1) == 1);
+    assert(*next(m.begin(), 2) == 1);
+    assert(*next(m.begin(), 3) == 2);
+    assert(*next(m.begin(), 4) == 2);
+    assert(*next(m.begin(), 5) == 2);
+    assert(*next(m.begin(), 6) == 3);
+    assert(*next(m.begin(), 7) == 3);
+    assert(*next(m.begin(), 8) == 3);
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/move.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/move.pass.cpp
new file mode 100644
index 0000000..40321cd
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/move.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int V;
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(C(5), A(7));
+        std::multiset<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::multiset<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::multiset<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 9);
+        assert(distance(m.begin(), m.end()) == 9);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 1);
+        assert(*next(m.begin(), 2) == 1);
+        assert(*next(m.begin(), 3) == 2);
+        assert(*next(m.begin(), 4) == 2);
+        assert(*next(m.begin(), 5) == 2);
+        assert(*next(m.begin(), 6) == 3);
+        assert(*next(m.begin(), 7) == 3);
+        assert(*next(m.begin(), 8) == 3);
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..1a0b065
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..0b0ce44
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef min_allocator<V> A;
+        typedef std::multiset<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+        M m3(C(3), A());
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A());
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..cef3f20
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset& operator=(multiset&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/final/test/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..e18f3f5
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset(multiset&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp b/final/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp
new file mode 100644
index 0000000..ce90689
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.special/member_swap.pass.cpp
@@ -0,0 +1,201 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp b/final/test/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..222985a
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::set<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::set<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+}
diff --git a/final/test/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/final/test/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..531fe80
--- /dev/null
+++ b/final/test/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// void swap(multiset& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::multiset<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/scary.pass.cpp b/final/test/containers/associative/multiset/scary.pass.cpp
new file mode 100644
index 0000000..f5ee327
--- /dev/null
+++ b/final/test/containers/associative/multiset/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set class multiset
+
+// Extension:  SCARY/N2913 iterator compatibility between set and multiset
+
+#include <set>
+
+int main()
+{
+    typedef std::set<int> M1;
+    typedef std::multiset<int> M2;
+    M2::iterator i;
+    M1::iterator j = i;
+}
diff --git a/final/test/containers/associative/multiset/size.pass.cpp b/final/test/containers/associative/multiset/size.pass.cpp
new file mode 100644
index 0000000..68099b5
--- /dev/null
+++ b/final/test/containers/associative/multiset/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multiset<int> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1));
+    assert(m.size() == 2);
+    m.insert(M::value_type(2));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1));
+    assert(m.size() == 2);
+    m.insert(M::value_type(2));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/types.pass.cpp b/final/test/containers/associative/multiset/types.pass.cpp
new file mode 100644
index 0000000..e1e3ad9
--- /dev/null
+++ b/final/test/containers/associative/multiset/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+//           class Allocator = allocator<Key>>
+// class multiset
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef key_type                                 value_type;
+//     typedef Compare                                  key_compare;
+//     typedef key_compare                              value_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::multiset<int> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::value_type, int>::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
+    static_assert((std::is_same<C::reference, int&>::value), "");
+    static_assert((std::is_same<C::const_reference, const int&>::value), "");
+    static_assert((std::is_same<C::pointer, int*>::value), "");
+    static_assert((std::is_same<C::const_pointer, const int*>::value), "");
+    static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::value_type, int>::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, min_allocator<int>>::value), "");
+    static_assert((std::is_same<C::reference, int&>::value), "");
+    static_assert((std::is_same<C::const_reference, const int&>::value), "");
+    static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+    static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+//  min_allocator doesn't have a size_type, so one gets synthesized
+    static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/multiset/upper_bound.pass.cpp b/final/test/containers/associative/multiset/upper_bound.pass.cpp
new file mode 100644
index 0000000..7ad3d6c
--- /dev/null
+++ b/final/test/containers/associative/multiset/upper_bound.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::multiset<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            5,
+            5,
+            7,
+            7,
+            7,
+            9,
+            9,
+            9
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(5);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 9));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 9));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::multiset<V, std::less<>> M;
+
+    typedef M::iterator R;
+    V ar[] =
+    {
+        5,
+        5,
+        5,
+        7,
+        7,
+        7,
+        9,
+        9,
+        9
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.upper_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.upper_bound(5);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 9));
+    r = m.upper_bound(11);
+    assert(r == next(m.begin(), 9));
+    }
+
+    {
+    typedef PrivateConstructor V;
+    typedef std::multiset<V, std::less<>> M;
+
+    typedef M::iterator R;
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 9 ));
+
+    R r = m.upper_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.upper_bound(5);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 9));
+    r = m.upper_bound(11);
+    assert(r == next(m.begin(), 9));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/clear.pass.cpp b/final/test/containers/associative/set/clear.pass.cpp
new file mode 100644
index 0000000..4439ad3
--- /dev/null
+++ b/final/test/containers/associative/set/clear.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        m.clear();
+        assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/count.pass.cpp b/final/test/containers/associative/set/count.pass.cpp
new file mode 100644
index 0000000..a2dc177
--- /dev/null
+++ b/final/test/containers/associative/set/count.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        typedef std::set<int> M;
+        typedef M::size_type R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(5);
+        assert(r == 1);
+        r = m.count(6);
+        assert(r == 1);
+        r = m.count(7);
+        assert(r == 1);
+        r = m.count(8);
+        assert(r == 1);
+        r = m.count(9);
+        assert(r == 1);
+        r = m.count(10);
+        assert(r == 1);
+        r = m.count(11);
+        assert(r == 1);
+        r = m.count(12);
+        assert(r == 1);
+        r = m.count(4);
+        assert(r == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int V;
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef M::size_type R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.count(5);
+        assert(r == 1);
+        r = m.count(6);
+        assert(r == 1);
+        r = m.count(7);
+        assert(r == 1);
+        r = m.count(8);
+        assert(r == 1);
+        r = m.count(9);
+        assert(r == 1);
+        r = m.count(10);
+        assert(r == 1);
+        r = m.count(11);
+        assert(r == 1);
+        r = m.count(12);
+        assert(r == 1);
+        r = m.count(4);
+        assert(r == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/emplace.pass.cpp b/final/test/containers/associative/set/emplace.pass.cpp
new file mode 100644
index 0000000..5ebab4d
--- /dev/null
+++ b/final/test/containers/associative/set/emplace.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+//   pair<iterator, bool> emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::set<DefaultOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace();
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace();
+        assert(!r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::set<Emplaceable> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace();
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace(2, 3.5);
+        assert(r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r.first == Emplaceable(2, 3.5));
+        r = m.emplace(2, 3.5);
+        assert(!r.second);
+        assert(r.first == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r.first == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::set<int> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.emplace(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/set/emplace_hint.pass.cpp b/final/test/containers/associative/set/emplace_hint.pass.cpp
new file mode 100644
index 0000000..5fdeb4f
--- /dev/null
+++ b/final/test/containers/associative/set/emplace_hint.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+//   iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::set<DefaultOnly> M;
+        typedef M::iterator R;
+        M m;
+        assert(DefaultOnly::count == 0);
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+
+        r = m.emplace_hint(m.cbegin());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == DefaultOnly());
+        assert(DefaultOnly::count == 1);
+    }
+    assert(DefaultOnly::count == 0);
+    {
+        typedef std::set<Emplaceable> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend());
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*m.begin() == Emplaceable());
+        r = m.emplace_hint(m.cend(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+        r = m.emplace_hint(m.cbegin(), 2, 3.5);
+        assert(r == next(m.begin()));
+        assert(m.size() == 2);
+        assert(*r == Emplaceable(2, 3.5));
+    }
+    {
+        typedef std::set<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.emplace_hint(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/set/empty.pass.cpp b/final/test/containers/associative/set/empty.pass.cpp
new file mode 100644
index 0000000..eb10802
--- /dev/null
+++ b/final/test/containers/associative/set/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::set<int> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    M m;
+    assert(m.empty());
+    m.insert(M::value_type(1));
+    assert(!m.empty());
+    m.clear();
+    assert(m.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/equal_range.pass.cpp b/final/test/containers/associative/set/equal_range.pass.cpp
new file mode 100644
index 0000000..8a180ef
--- /dev/null
+++ b/final/test/containers/associative/set/equal_range.pass.cpp
@@ -0,0 +1,370 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator,iterator>             equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    {
+        typedef std::pair<M::const_iterator, M::const_iterator> R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    typedef std::pair<M::iterator, M::iterator> R;
+    V ar[] =
+    {
+        5,
+        7,
+        9,
+        11,
+        13,
+        15,
+        17,
+        19
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.equal_range(5);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(7);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(9);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(11);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(13);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(15);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(17);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(19);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 8));
+    r = m.equal_range(4);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 0));
+    r = m.equal_range(6);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(8);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(10);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(12);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(14);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(16);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(18);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(20);
+    assert(r.first == next(m.begin(), 8));
+    assert(r.second == next(m.begin(), 8));
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::set<V, std::less<>> M;
+    {
+        typedef std::pair<M::iterator, M::iterator> R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.equal_range(5);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(7);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(9);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(11);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(13);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(15);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(17);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(19);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 8));
+        r = m.equal_range(4);
+        assert(r.first == next(m.begin(), 0));
+        assert(r.second == next(m.begin(), 0));
+        r = m.equal_range(6);
+        assert(r.first == next(m.begin(), 1));
+        assert(r.second == next(m.begin(), 1));
+        r = m.equal_range(8);
+        assert(r.first == next(m.begin(), 2));
+        assert(r.second == next(m.begin(), 2));
+        r = m.equal_range(10);
+        assert(r.first == next(m.begin(), 3));
+        assert(r.second == next(m.begin(), 3));
+        r = m.equal_range(12);
+        assert(r.first == next(m.begin(), 4));
+        assert(r.second == next(m.begin(), 4));
+        r = m.equal_range(14);
+        assert(r.first == next(m.begin(), 5));
+        assert(r.second == next(m.begin(), 5));
+        r = m.equal_range(16);
+        assert(r.first == next(m.begin(), 6));
+        assert(r.second == next(m.begin(), 6));
+        r = m.equal_range(18);
+        assert(r.first == next(m.begin(), 7));
+        assert(r.second == next(m.begin(), 7));
+        r = m.equal_range(20);
+        assert(r.first == next(m.begin(), 8));
+        assert(r.second == next(m.begin(), 8));
+        }
+    }
+    {
+    typedef PrivateConstructor V;
+    typedef std::set<V, std::less<>> M;
+    typedef std::pair<M::iterator, M::iterator> R;
+
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 11 ));
+    m.insert ( V::make ( 13 ));
+    m.insert ( V::make ( 15 ));
+    m.insert ( V::make ( 17 ));
+    m.insert ( V::make ( 19 ));
+
+    R r = m.equal_range(5);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(7);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(9);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(11);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(13);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(15);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(17);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(19);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 8));
+    r = m.equal_range(4);
+    assert(r.first == next(m.begin(), 0));
+    assert(r.second == next(m.begin(), 0));
+    r = m.equal_range(6);
+    assert(r.first == next(m.begin(), 1));
+    assert(r.second == next(m.begin(), 1));
+    r = m.equal_range(8);
+    assert(r.first == next(m.begin(), 2));
+    assert(r.second == next(m.begin(), 2));
+    r = m.equal_range(10);
+    assert(r.first == next(m.begin(), 3));
+    assert(r.second == next(m.begin(), 3));
+    r = m.equal_range(12);
+    assert(r.first == next(m.begin(), 4));
+    assert(r.second == next(m.begin(), 4));
+    r = m.equal_range(14);
+    assert(r.first == next(m.begin(), 5));
+    assert(r.second == next(m.begin(), 5));
+    r = m.equal_range(16);
+    assert(r.first == next(m.begin(), 6));
+    assert(r.second == next(m.begin(), 6));
+    r = m.equal_range(18);
+    assert(r.first == next(m.begin(), 7));
+    assert(r.second == next(m.begin(), 7));
+    r = m.equal_range(20);
+    assert(r.first == next(m.begin(), 8));
+    assert(r.second == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/erase_iter.pass.cpp b/final/test/containers/associative/set/erase_iter.pass.cpp
new file mode 100644
index 0000000..21666c3
--- /dev/null
+++ b/final/test/containers/associative/set/erase_iter.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 3));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 6);
+        assert(i == m.begin());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(next(m.cbegin(), 5));
+        assert(m.size() == 5);
+        assert(i == m.end());
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(next(m.cbegin(), 1));
+        assert(m.size() == 4);
+        assert(i == next(m.begin()));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 3);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(next(m.cbegin(), 0));
+        assert(m.size() == 1);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(m.cbegin());
+        assert(m.size() == 0);
+        assert(i == m.begin());
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/erase_iter_iter.pass.cpp b/final/test/containers/associative/set/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..4799503
--- /dev/null
+++ b/final/test/containers/associative/set/erase_iter_iter.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 5));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 7);
+        assert(*next(m.begin(), 3) == 8);
+
+        i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 8);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        typedef M::iterator I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+        assert(m.size() == 8);
+        assert(i == next(m.begin(), 5));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+        assert(m.size() == 7);
+        assert(i == next(m.begin(), 3));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+        assert(m.size() == 4);
+        assert(i == next(m.begin(), 2));
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 7);
+        assert(*next(m.begin(), 3) == 8);
+
+        i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+        assert(m.size() == 2);
+        assert(i == next(m.begin(), 0));
+        assert(*next(m.begin(), 0) == 7);
+        assert(*next(m.begin(), 1) == 8);
+
+        i = m.erase(m.cbegin(), m.cend());
+        assert(m.size() == 0);
+        assert(i == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/erase_key.pass.cpp b/final/test/containers/associative/set/erase_key.pass.cpp
new file mode 100644
index 0000000..9d92bd7
--- /dev/null
+++ b/final/test/containers/associative/set/erase_key.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        typedef M::size_type I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(9);
+        assert(m.size() == 8);
+        assert(i == 0);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(4);
+        assert(m.size() == 7);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(1);
+        assert(m.size() == 6);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(8);
+        assert(m.size() == 5);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(3);
+        assert(m.size() == 4);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(6);
+        assert(m.size() == 3);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(7);
+        assert(m.size() == 2);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(2);
+        assert(m.size() == 1);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(5);
+        assert(m.size() == 0);
+        assert(i == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        typedef M::size_type I;
+        V ar[] =
+        {
+            1,
+            2,
+            3,
+            4,
+            5,
+            6,
+            7,
+            8
+        };
+        M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+        assert(m.size() == 8);
+        I i = m.erase(9);
+        assert(m.size() == 8);
+        assert(i == 0);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 4);
+        assert(*next(m.begin(), 4) == 5);
+        assert(*next(m.begin(), 5) == 6);
+        assert(*next(m.begin(), 6) == 7);
+        assert(*next(m.begin(), 7) == 8);
+
+        i = m.erase(4);
+        assert(m.size() == 7);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 1);
+        assert(*next(m.begin(), 1) == 2);
+        assert(*next(m.begin(), 2) == 3);
+        assert(*next(m.begin(), 3) == 5);
+        assert(*next(m.begin(), 4) == 6);
+        assert(*next(m.begin(), 5) == 7);
+        assert(*next(m.begin(), 6) == 8);
+
+        i = m.erase(1);
+        assert(m.size() == 6);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+        assert(*next(m.begin(), 5) == 8);
+
+        i = m.erase(8);
+        assert(m.size() == 5);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 3);
+        assert(*next(m.begin(), 2) == 5);
+        assert(*next(m.begin(), 3) == 6);
+        assert(*next(m.begin(), 4) == 7);
+
+        i = m.erase(3);
+        assert(m.size() == 4);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 6);
+        assert(*next(m.begin(), 3) == 7);
+
+        i = m.erase(6);
+        assert(m.size() == 3);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+        assert(*next(m.begin(), 2) == 7);
+
+        i = m.erase(7);
+        assert(m.size() == 2);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 2);
+        assert(*next(m.begin(), 1) == 5);
+
+        i = m.erase(2);
+        assert(m.size() == 1);
+        assert(i == 1);
+        assert(*next(m.begin(), 0) == 5);
+
+        i = m.erase(5);
+        assert(m.size() == 0);
+        assert(i == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/find.pass.cpp b/final/test/containers/associative/set/find.pass.cpp
new file mode 100644
index 0000000..d08d2fb
--- /dev/null
+++ b/final/test/containers/associative/set/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.find(5);
+        assert(r == m.begin());
+        r = m.find(6);
+        assert(r == next(m.begin()));
+        r = m.find(7);
+        assert(r == next(m.begin(), 2));
+        r = m.find(8);
+        assert(r == next(m.begin(), 3));
+        r = m.find(9);
+        assert(r == next(m.begin(), 4));
+        r = m.find(10);
+        assert(r == next(m.begin(), 5));
+        r = m.find(11);
+        assert(r == next(m.begin(), 6));
+        r = m.find(12);
+        assert(r == next(m.begin(), 7));
+        r = m.find(4);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::set<V, std::less<>> M;
+    typedef M::iterator R;
+
+    V ar[] =
+    {
+        5,
+        6,
+        7,
+        8,
+        9,
+        10,
+        11,
+        12
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.find(5);
+    assert(r == m.begin());
+    r = m.find(6);
+    assert(r == next(m.begin()));
+    r = m.find(7);
+    assert(r == next(m.begin(), 2));
+    r = m.find(8);
+    assert(r == next(m.begin(), 3));
+    r = m.find(9);
+    assert(r == next(m.begin(), 4));
+    r = m.find(10);
+    assert(r == next(m.begin(), 5));
+    r = m.find(11);
+    assert(r == next(m.begin(), 6));
+    r = m.find(12);
+    assert(r == next(m.begin(), 7));
+    r = m.find(4);
+    assert(r == next(m.begin(), 8));
+    }
+
+    {
+    typedef PrivateConstructor V;
+    typedef std::set<V, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 6 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 8 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 10 ));
+    m.insert ( V::make ( 11 ));
+    m.insert ( V::make ( 12 ));
+
+    R r = m.find(5);
+    assert(r == m.begin());
+    r = m.find(6);
+    assert(r == next(m.begin()));
+    r = m.find(7);
+    assert(r == next(m.begin(), 2));
+    r = m.find(8);
+    assert(r == next(m.begin(), 3));
+    r = m.find(9);
+    assert(r == next(m.begin(), 4));
+    r = m.find(10);
+    assert(r == next(m.begin(), 5));
+    r = m.find(11);
+    assert(r == next(m.begin(), 6));
+    r = m.find(12);
+    assert(r == next(m.begin(), 7));
+    r = m.find(4);
+    assert(r == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/insert_cv.pass.cpp b/final/test/containers/associative/set/insert_cv.pass.cpp
new file mode 100644
index 0000000..18d5c2e
--- /dev/null
+++ b/final/test/containers/associative/set/insert_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(*r.first == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(*r.first == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/insert_initializer_list.pass.cpp b/final/test/containers/associative/set/insert_initializer_list.pass.cpp
new file mode 100644
index 0000000..fc6d612
--- /dev/null
+++ b/final/test/containers/associative/set/insert_initializer_list.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::set<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m.insert({1, 2, 3, 4, 5, 6});
+    assert(m.size() == 8);
+    assert(distance(m.begin(), m.end()) == m.size());
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(*++i == V(8));
+    assert(*++i == V(10));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::set<int, std::less<int>, min_allocator<int>> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m.insert({1, 2, 3, 4, 5, 6});
+    assert(m.size() == 8);
+    assert(distance(m.begin(), m.end()) == m.size());
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(*++i == V(8));
+    assert(*++i == V(10));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/set/insert_iter_cv.pass.cpp b/final/test/containers/associative/set/insert_iter_cv.pass.cpp
new file mode 100644
index 0000000..718e720
--- /dev/null
+++ b/final/test/containers/associative/set/insert_iter_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/insert_iter_iter.pass.cpp b/final/test/containers/associative/set/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..ff729a0
--- /dev/null
+++ b/final/test/containers/associative/set/insert_iter_iter.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//   void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::set<int> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        M m;
+        m.insert(input_iterator<const V*>(ar),
+                 input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<int, std::less<int>, min_allocator<int>> M;
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        M m;
+        m.insert(input_iterator<const V*>(ar),
+                 input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+        assert(m.size() == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/insert_iter_rv.pass.cpp b/final/test/containers/associative/set/insert_iter_rv.pass.cpp
new file mode 100644
index 0000000..c149fa3
--- /dev/null
+++ b/final/test/containers/associative/set/insert_iter_rv.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::set<MoveOnly> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+        typedef M::iterator R;
+        M m;
+        R r = m.insert(m.cend(), M::value_type(2));
+        assert(r == m.begin());
+        assert(m.size() == 1);
+        assert(*r == 2);
+
+        r = m.insert(m.cend(), M::value_type(1));
+        assert(r == m.begin());
+        assert(m.size() == 2);
+        assert(*r == 1);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+
+        r = m.insert(m.cend(), M::value_type(3));
+        assert(r == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r == 3);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/set/insert_rv.pass.cpp b/final/test/containers/associative/set/insert_rv.pass.cpp
new file mode 100644
index 0000000..3989451
--- /dev/null
+++ b/final/test/containers/associative/set/insert_rv.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::set<MoveOnly> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(*r.first == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+        typedef std::pair<M::iterator, bool> R;
+        M m;
+        R r = m.insert(M::value_type(2));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 1);
+        assert(*r.first == 2);
+
+        r = m.insert(M::value_type(1));
+        assert(r.second);
+        assert(r.first == m.begin());
+        assert(m.size() == 2);
+        assert(*r.first == 1);
+
+        r = m.insert(M::value_type(3));
+        assert(r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+
+        r = m.insert(M::value_type(3));
+        assert(!r.second);
+        assert(r.first == prev(m.end()));
+        assert(m.size() == 3);
+        assert(*r.first == 3);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/set/iterator.pass.cpp b/final/test/containers/associative/set/iterator.pass.cpp
new file mode 100644
index 0000000..ecd950f
--- /dev/null
+++ b/final/test/containers/associative/set/iterator.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator begin();
+// const_iterator begin() const;
+//       iterator end();
+// const_iterator end()   const;
+//
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+//       reverse_iterator rend();
+// const_reverse_iterator rend()   const;
+//
+// const_iterator         cbegin()  const;
+// const_iterator         cend()    const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend()   const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::set<int>::iterator i;
+        i = m.begin();
+        std::set<int>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= m.size(); ++j, ++i)
+            assert(*i == j);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        const std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::set<int>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= m.size(); ++j, ++i)
+            assert(*i == j);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        std::set<int, std::less<int>, min_allocator<int>>::iterator i;
+        i = m.begin();
+        std::set<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
+        assert(i == k);
+        for (int j = 1; j <= m.size(); ++j, ++i)
+            assert(*i == j);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3,
+            4,
+            4,
+            4,
+            5,
+            5,
+            5,
+            6,
+            6,
+            6,
+            7,
+            7,
+            7,
+            8,
+            8,
+            8
+        };
+        const std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        assert(std::distance(m.begin(), m.end()) == m.size());
+        assert(std::distance(m.cbegin(), m.cend()) == m.size());
+        assert(std::distance(m.rbegin(), m.rend()) == m.size());
+        assert(std::distance(m.crbegin(), m.crend()) == m.size());
+        std::set<int, std::less<int>, min_allocator<int>>::const_iterator i;
+        i = m.begin();
+        for (int j = 1; j <= m.size(); ++j, ++i)
+            assert(*i == j);
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::set<int> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/lower_bound.pass.cpp b/final/test/containers/associative/set/lower_bound.pass.cpp
new file mode 100644
index 0000000..df202f3
--- /dev/null
+++ b/final/test/containers/associative/set/lower_bound.pass.cpp
@@ -0,0 +1,337 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.lower_bound(5);
+        assert(r == m.begin());
+        r = m.lower_bound(7);
+        assert(r == next(m.begin()));
+        r = m.lower_bound(9);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(11);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(13);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(15);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(17);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(19);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.lower_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.lower_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.lower_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.lower_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.lower_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.lower_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.lower_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.lower_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::set<V, std::less<>> M;
+    typedef M::iterator R;
+
+    V ar[] =
+    {
+        5,
+        7,
+        9,
+        11,
+        13,
+        15,
+        17,
+        19
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.lower_bound(5);
+    assert(r == m.begin());
+    r = m.lower_bound(7);
+    assert(r == next(m.begin()));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(11);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(13);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(15);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(17);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(19);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+    
+    {
+    typedef PrivateConstructor V;
+    typedef std::set<V, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 11 ));
+    m.insert ( V::make ( 13 ));
+    m.insert ( V::make ( 15 ));
+    m.insert ( V::make ( 17 ));
+    m.insert ( V::make ( 19 ));
+
+    R r = m.lower_bound(5);
+    assert(r == m.begin());
+    r = m.lower_bound(7);
+    assert(r == next(m.begin()));
+    r = m.lower_bound(9);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(11);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(13);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(15);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(17);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(19);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.lower_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.lower_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.lower_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.lower_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.lower_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.lower_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.lower_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.lower_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+#endif
+
+}
diff --git a/final/test/containers/associative/set/max_size.pass.cpp b/final/test/containers/associative/set/max_size.pass.cpp
new file mode 100644
index 0000000..cde4397
--- /dev/null
+++ b/final/test/containers/associative/set/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::set<int> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    M m;
+    assert(m.max_size() != 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.cons/alloc.pass.cpp b/final/test/containers/associative/set/set.cons/alloc.pass.cpp
new file mode 100644
index 0000000..67433ff
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+    typedef std::less<int> C;
+    typedef test_allocator<int> A;
+    std::set<int, C, A> m(A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.get_allocator() == A(5));
+}
diff --git a/final/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/final/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..892ae5a
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::set<int> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::set<int, std::less<int>, min_allocator<int>> C;
+    typedef C::value_type V;
+    C m = {10, 8};
+    m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/set/set.cons/compare.pass.cpp b/final/test/containers/associative/set/set.cons/compare.pass.cpp
new file mode 100644
index 0000000..af94c70
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// explicit set(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    std::set<int, C> m(C(3));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(3));
+}
diff --git a/final/test/containers/associative/set/set.cons/compare_alloc.pass.cpp b/final/test/containers/associative/set/set.cons/compare_alloc.pass.cpp
new file mode 100644
index 0000000..22b3328
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<int> A;
+    std::set<int, C, A> m(C(4), A(5));
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    assert(m.key_comp() == C(4));
+    assert(m.get_allocator() == A(5));
+}
diff --git a/final/test/containers/associative/set/set.cons/copy.pass.cpp b/final/test/containers/associative/set/set.cons/copy.pass.cpp
new file mode 100644
index 0000000..a0e34e4
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/copy.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::set<int, C, A> m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::set<int, C, A> m = mo;
+        assert(m.get_allocator() == A(-2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/final/test/containers/associative/set/set.cons/copy_alloc.pass.cpp b/final/test/containers/associative/set/set.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..1ad03dc
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/copy_alloc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<int> > C;
+    typedef test_allocator<V> A;
+    std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+    std::set<int, C, A> m(mo, A(3));
+    assert(m.get_allocator() == A(3));
+    assert(m.key_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+
+    assert(mo.get_allocator() == A(7));
+    assert(mo.key_comp() == C(5));
+    assert(mo.size() == 3);
+    assert(distance(mo.begin(), mo.end()) == 3);
+    assert(*mo.begin() == 1);
+    assert(*next(mo.begin()) == 2);
+    assert(*next(mo.begin(), 2) == 3);
+}
diff --git a/final/test/containers/associative/set/set.cons/copy_assign.pass.cpp b/final/test/containers/associative/set/set.cons/copy_assign.pass.cpp
new file mode 100644
index 0000000..7f0f044
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/copy_assign.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(const set& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+    {
+        typedef int V;
+        const V ar[] =
+        {
+            1,
+            2,
+            3
+        };
+        std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        std::set<int> *p = &m;
+        m = *p;
+
+        assert(m.size() == 3);
+        assert(std::equal(m.begin(), m.end(), ar));
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef other_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+        std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+        m = mo;
+        assert(m.get_allocator() == A(2));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+
+        assert(mo.get_allocator() == A(2));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 3);
+        assert(distance(mo.begin(), mo.end()) == 3);
+        assert(*mo.begin() == 1);
+        assert(*next(mo.begin()) == 2);
+        assert(*next(mo.begin(), 2) == 3);
+    }
+}
diff --git a/final/test/containers/associative/set/set.cons/default.pass.cpp b/final/test/containers/associative/set/set.cons/default.pass.cpp
new file mode 100644
index 0000000..746a2d1
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::set<int> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#if __cplusplus >= 201103L
+    {
+    std::set<int, std::less<int>, min_allocator<int>> m;
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+    {
+    std::set<int> m = {};
+    assert(m.empty());
+    assert(m.begin() == m.end());
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.cons/default_noexcept.pass.cpp b/final/test/containers/associative/set/set.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..4d5754a
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::set<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.cons/dtor_noexcept.pass.cpp b/final/test/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..25f5425
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// ~set() // implied noexcept;
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::set<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.cons/initializer_list.pass.cpp b/final/test/containers/associative/set/set.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..2ad538e
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/initializer_list.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef std::set<int> C;
+    typedef C::value_type V;
+    C m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::set<int, std::less<int>, min_allocator<int>> C;
+    typedef C::value_type V;
+    C m = {1, 2, 3, 4, 5, 6};
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/set/set.cons/initializer_list_compare.pass.cpp b/final/test/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 0000000..a0afa02
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    typedef test_compare<std::less<int> > Cmp;
+    typedef std::set<int, Cmp> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp b/final/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 0000000..821820a
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+// set(initializer_list<value_type> il, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    typedef test_compare<std::less<int> > Cmp;
+    typedef test_allocator<int> A;
+    typedef std::set<int, Cmp, A> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.key_comp() == Cmp(10));
+    assert(m.get_allocator() == A(4));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef test_compare<std::less<int> > Cmp;
+    typedef test_allocator<int> A;
+    typedef std::set<int, Cmp, A> C;
+    typedef C::value_type V;
+    C m({1, 2, 3, 4, 5, 6}, A(4));
+    assert(m.size() == 6);
+    assert(distance(m.begin(), m.end()) == 6);
+    C::const_iterator i = m.cbegin();
+    assert(*i == V(1));
+    assert(*++i == V(2));
+    assert(*++i == V(3));
+    assert(*++i == V(4));
+    assert(*++i == V(5));
+    assert(*++i == V(6));
+    assert(m.get_allocator() == A(4));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/associative/set/set.cons/iter_iter.pass.cpp b/final/test/containers/associative/set/set.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..7ca7fe1
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/iter_iter.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//     set(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    std::set<V> m(input_iterator<const int*>(ar),
+                  input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    std::set<V, std::less<int>, min_allocator<int>> m(input_iterator<const int*>(ar),
+                  input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp b/final/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..5ccb6e5
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//     set(InputIterator first, InputIterator last,
+//         const value_compare& comp, const allocator_type& a);
+//
+// template <class InputIterator>
+//     set(InputIterator first, InputIterator last,
+//         const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    typedef test_allocator<V> A;
+    std::set<V, C, A> m(input_iterator<const V*>(ar),
+                        input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+                        C(5), A(7));
+    assert(m.value_comp() == C(5));
+    assert(m.get_allocator() == A(7));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_allocator<V> A;
+    typedef test_compare<std::less<int> > C;
+    A a(7);
+    std::set<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+    assert(m.get_allocator() == a);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.cons/iter_iter_comp.pass.cpp b/final/test/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..18bc083
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+//     set(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    V ar[] =
+    {
+        1,
+        1,
+        1,
+        2,
+        2,
+        2,
+        3,
+        3,
+        3
+    };
+    typedef test_compare<std::less<V> > C;
+    std::set<V, C> m(input_iterator<const V*>(ar),
+                     input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+    assert(m.value_comp() == C(5));
+    assert(m.size() == 3);
+    assert(distance(m.begin(), m.end()) == 3);
+    assert(*m.begin() == 1);
+    assert(*next(m.begin()) == 2);
+    assert(*next(m.begin(), 2) == 3);
+}
diff --git a/final/test/containers/associative/set/set.cons/move.pass.cpp b/final/test/containers/associative/set/set.cons/move.pass.cpp
new file mode 100644
index 0000000..4026ec7
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/move.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int V;
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(C(5), A(7));
+        std::set<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 0);
+        assert(distance(m.begin(), m.end()) == 0);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef test_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+        std::set<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A(7));
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+
+        assert(mo.get_allocator() == A(7));
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int V;
+        V ar[] =
+        {
+            1,
+            1,
+            1,
+            2,
+            2,
+            2,
+            3,
+            3,
+            3
+        };
+        typedef test_compare<std::less<int> > C;
+        typedef min_allocator<V> A;
+        std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+        std::set<int, C, A> m = std::move(mo);
+        assert(m.get_allocator() == A());
+        assert(m.key_comp() == C(5));
+        assert(m.size() == 3);
+        assert(distance(m.begin(), m.end()) == 3);
+        assert(*m.begin() == 1);
+        assert(*next(m.begin()) == 2);
+        assert(*next(m.begin(), 2) == 3);
+
+        assert(mo.get_allocator() == A());
+        assert(mo.key_comp() == C(5));
+        assert(mo.size() == 0);
+        assert(distance(mo.begin(), mo.end()) == 0);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/set/set.cons/move_alloc.pass.cpp b/final/test/containers/associative/set/set.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..c4617f0
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(7));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(std::move(m1), A(5));
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/set/set.cons/move_assign.pass.cpp b/final/test/containers/associative/set/set.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..4e08f01
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/move_assign.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(7));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef test_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(5));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef other_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+        M m3(C(3), A(5));
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A(7));
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef MoveOnly V;
+        typedef test_compare<std::less<MoveOnly> > C;
+        typedef min_allocator<V> A;
+        typedef std::set<MoveOnly, C, A> M;
+        typedef std::move_iterator<V*> I;
+        V a1[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+        V a2[] =
+        {
+            V(1),
+            V(1),
+            V(1),
+            V(2),
+            V(2),
+            V(2),
+            V(3),
+            V(3),
+            V(3)
+        };
+        M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+        M m3(C(3), A());
+        m3 = std::move(m1);
+        assert(m3 == m2);
+        assert(m3.get_allocator() == A());
+        assert(m3.key_comp() == C(5));
+        assert(m1.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp b/final/test/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..17ea740
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set& operator=(set&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::set<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.cons/move_noexcept.pass.cpp b/final/test/containers/associative/set/set.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..7a8ae7b
--- /dev/null
+++ b/final/test/containers/associative/set/set.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set(set&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::set<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.special/member_swap.pass.cpp b/final/test/containers/associative/set/set.special/member_swap.pass.cpp
new file mode 100644
index 0000000..f72abd7
--- /dev/null
+++ b/final/test/containers/associative/set/set.special/member_swap.pass.cpp
@@ -0,0 +1,201 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        m1.swap(m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/set.special/non_member_swap.pass.cpp b/final/test/containers/associative/set/set.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..c9cffc6
--- /dev/null
+++ b/final/test/containers/associative/set/set.special/non_member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+    }
+    {
+        typedef test_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::set<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(1));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<V> A;
+        typedef test_compare<std::less<int> > C;
+        typedef std::set<int, C, A> M;
+        V ar1[] =
+        {
+            1,
+            2,
+            3,
+            4
+        };
+        V ar2[] =
+        {
+            5,
+            6,
+            7,
+            8,
+            9,
+            10,
+            11,
+            12
+        };
+        M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+        M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+        M m1_save = m1;
+        M m2_save = m2;
+        swap(m1, m2);
+        assert(m1 == m2_save);
+        assert(m2 == m1_save);
+        assert(m1.key_comp() == C(2));
+        assert(m1.get_allocator() == A(2));
+        assert(m2.key_comp() == C(1));
+        assert(m2.get_allocator() == A(1));
+    }
+}
diff --git a/final/test/containers/associative/set/set.special/swap_noexcept.pass.cpp b/final/test/containers/associative/set/set.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..c4f169a
--- /dev/null
+++ b/final/test/containers/associative/set/set.special/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// void swap(set& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::set<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/size.pass.cpp b/final/test/containers/associative/set/size.pass.cpp
new file mode 100644
index 0000000..e786547
--- /dev/null
+++ b/final/test/containers/associative/set/size.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::set<int> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    M m;
+    assert(m.size() == 0);
+    m.insert(M::value_type(2));
+    assert(m.size() == 1);
+    m.insert(M::value_type(1));
+    assert(m.size() == 2);
+    m.insert(M::value_type(3));
+    assert(m.size() == 3);
+    m.erase(m.begin());
+    assert(m.size() == 2);
+    m.erase(m.begin());
+    assert(m.size() == 1);
+    m.erase(m.begin());
+    assert(m.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/types.pass.cpp b/final/test/containers/associative/set/types.pass.cpp
new file mode 100644
index 0000000..3362c42
--- /dev/null
+++ b/final/test/containers/associative/set/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+//           class Allocator = allocator<Key>>
+// class set
+// {
+// public:
+//     // types:
+//     typedef Key                                      key_type;
+//     typedef key_type                                 value_type;
+//     typedef Compare                                  key_compare;
+//     typedef key_compare                              value_compare;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     ...
+// };
+
+#include <set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::set<int> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::value_type, int>::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
+    static_assert((std::is_same<C::reference, int&>::value), "");
+    static_assert((std::is_same<C::const_reference, const int&>::value), "");
+    static_assert((std::is_same<C::pointer, int*>::value), "");
+    static_assert((std::is_same<C::const_pointer, const int*>::value), "");
+    static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::set<int, std::less<int>, min_allocator<int>> C;
+    static_assert((std::is_same<C::key_type, int>::value), "");
+    static_assert((std::is_same<C::value_type, int>::value), "");
+    static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+    static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), "");
+    static_assert((std::is_same<C::reference, int&>::value), "");
+    static_assert((std::is_same<C::const_reference, const int&>::value), "");
+    static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+    static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+//  min_allocator doesn't have a size_type, so one gets synthesized
+    static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/upper_bound.pass.cpp b/final/test/containers/associative/set/upper_bound.pass.cpp
new file mode 100644
index 0000000..10a28f0
--- /dev/null
+++ b/final/test/containers/associative/set/upper_bound.pass.cpp
@@ -0,0 +1,336 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+//       iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+    {
+    typedef int V;
+    typedef std::set<int> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int V;
+    typedef std::set<int, std::less<int>, min_allocator<int>> M;
+    {
+        typedef M::iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    {
+        typedef M::const_iterator R;
+        V ar[] =
+        {
+            5,
+            7,
+            9,
+            11,
+            13,
+            15,
+            17,
+            19
+        };
+        const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+        R r = m.upper_bound(5);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(7);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(9);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(11);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(13);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(15);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(17);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(19);
+        assert(r == next(m.begin(), 8));
+        r = m.upper_bound(4);
+        assert(r == next(m.begin(), 0));
+        r = m.upper_bound(6);
+        assert(r == next(m.begin(), 1));
+        r = m.upper_bound(8);
+        assert(r == next(m.begin(), 2));
+        r = m.upper_bound(10);
+        assert(r == next(m.begin(), 3));
+        r = m.upper_bound(12);
+        assert(r == next(m.begin(), 4));
+        r = m.upper_bound(14);
+        assert(r == next(m.begin(), 5));
+        r = m.upper_bound(16);
+        assert(r == next(m.begin(), 6));
+        r = m.upper_bound(18);
+        assert(r == next(m.begin(), 7));
+        r = m.upper_bound(20);
+        assert(r == next(m.begin(), 8));
+    }
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef int V;
+    typedef std::set<V, std::less<>> M;
+    typedef M::iterator R;
+
+    V ar[] =
+    {
+        5,
+        7,
+        9,
+        11,
+        13,
+        15,
+        17,
+        19
+    };
+    M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+    R r = m.upper_bound(5);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(11);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(13);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(15);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(17);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(19);
+    assert(r == next(m.begin(), 8));
+    r = m.upper_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+    
+    {
+    typedef PrivateConstructor V;
+    typedef std::set<V, std::less<>> M;
+    typedef M::iterator R;
+
+    M m;
+    m.insert ( V::make ( 5 ));
+    m.insert ( V::make ( 7 ));
+    m.insert ( V::make ( 9 ));
+    m.insert ( V::make ( 11 ));
+    m.insert ( V::make ( 13 ));
+    m.insert ( V::make ( 15 ));
+    m.insert ( V::make ( 17 ));
+    m.insert ( V::make ( 19 ));
+
+    R r = m.upper_bound(5);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(7);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(9);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(11);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(13);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(15);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(17);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(19);
+    assert(r == next(m.begin(), 8));
+    r = m.upper_bound(4);
+    assert(r == next(m.begin(), 0));
+    r = m.upper_bound(6);
+    assert(r == next(m.begin(), 1));
+    r = m.upper_bound(8);
+    assert(r == next(m.begin(), 2));
+    r = m.upper_bound(10);
+    assert(r == next(m.begin(), 3));
+    r = m.upper_bound(12);
+    assert(r == next(m.begin(), 4));
+    r = m.upper_bound(14);
+    assert(r == next(m.begin(), 5));
+    r = m.upper_bound(16);
+    assert(r == next(m.begin(), 6));
+    r = m.upper_bound(18);
+    assert(r == next(m.begin(), 7));
+    r = m.upper_bound(20);
+    assert(r == next(m.begin(), 8));
+    }
+#endif
+}
diff --git a/final/test/containers/associative/set/version.pass.cpp b/final/test/containers/associative/set/version.pass.cpp
new file mode 100644
index 0000000..c3c4d92
--- /dev/null
+++ b/final/test/containers/associative/set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+#include <set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/associative/tree_balance_after_insert.pass.cpp b/final/test/containers/associative/tree_balance_after_insert.pass.cpp
new file mode 100644
index 0000000..b0a3e74
--- /dev/null
+++ b/final/test/containers/associative/tree_balance_after_insert.pass.cpp
@@ -0,0 +1,1616 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition:  __root->__is_black_ == true
+// template <class _NodePtr>
+// void
+// __tree_balance_after_insert(_NodePtr __root, _NodePtr __x)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+    bool __is_black_;
+
+    Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = 0;
+        d.__right_ = 0;
+        d.__is_black_ = false;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == 0);
+        assert(d.__right_ == 0);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = &a;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = 0;
+        d.__right_ = 0;
+        d.__is_black_ = false;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &a);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == 0);
+        assert(d.__right_ == 0);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = &a;
+        d.__right_ = 0;
+        d.__is_black_ = false;
+
+        a.__parent_ = &d;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &a);
+        assert(d.__right_ == 0);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = 0;
+        d.__right_ = &a;
+        d.__is_black_ = false;
+
+        a.__parent_ = &d;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == 0);
+        assert(d.__right_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = &g;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = &h;
+        d.__right_ = &i;
+        d.__is_black_ = false;
+
+        a.__parent_ = &b;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+
+        h.__parent_ = &d;
+        h.__is_black_ = true;
+
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &g);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &h);
+        assert(d.__right_ == &i);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = &g;
+        b.__right_ = &a;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = &h;
+        d.__right_ = &i;
+        d.__is_black_ = false;
+
+        a.__parent_ = &b;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+
+        h.__parent_ = &d;
+        h.__is_black_ = true;
+
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &g);
+        assert(b.__right_ == &a);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &h);
+        assert(d.__right_ == &i);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = &g;
+        b.__right_ = &h;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = &a;
+        d.__right_ = &i;
+        d.__is_black_ = false;
+
+        a.__parent_ = &d;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+
+        h.__parent_ = &b;
+        h.__is_black_ = true;
+
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &g);
+        assert(b.__right_ == &h);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &a);
+        assert(d.__right_ == &i);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+        Node h;
+        Node i;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &d;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = &g;
+        b.__right_ = &h;
+        b.__is_black_ = false;
+
+        d.__parent_ = &c;
+        d.__left_ = &i;
+        d.__right_ = &a;
+        d.__is_black_ = false;
+
+        a.__parent_ = &d;
+        a.__left_ = &e;
+        a.__right_ = &f;
+        a.__is_black_ = false;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+
+        f.__parent_ = &a;
+        f.__is_black_ = true;
+
+        g.__parent_ = &b;
+        g.__is_black_ = true;
+
+        h.__parent_ = &b;
+        h.__is_black_ = true;
+
+        i.__parent_ = &d;
+        i.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &c);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &b);
+        assert(c.__right_ == &d);
+        assert(c.__is_black_ == true);
+
+        assert(b.__parent_ == &c);
+        assert(b.__left_ == &g);
+        assert(b.__right_ == &h);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &c);
+        assert(d.__left_ == &i);
+        assert(d.__right_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(a.__parent_ == &d);
+        assert(a.__left_ == &e);
+        assert(a.__right_ == &f);
+        assert(a.__is_black_ == false);
+    }
+}
+
+void
+test2()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &a;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        a.__parent_ = &c;
+        a.__left_ = 0;
+        a.__right_ = &b;
+        a.__is_black_ = false;
+
+        b.__parent_ = &a;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &a;
+
+        a.__parent_ = &root;
+        a.__left_ = 0;
+        a.__right_ = &c;
+        a.__is_black_ = true;
+
+        c.__parent_ = &a;
+        c.__left_ = &b;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        b.__parent_ = &c;
+        b.__left_ = 0;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &a;
+        c.__right_ = &g;
+        c.__is_black_ = true;
+
+        a.__parent_ = &c;
+        a.__left_ = &d;
+        a.__right_ = &b;
+        a.__is_black_ = false;
+
+        b.__parent_ = &a;
+        b.__left_ = &e;
+        b.__right_ = &f;
+        b.__is_black_ = false;
+
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+
+        e.__parent_ = &b;
+        e.__is_black_ = true;
+
+        f.__parent_ = &b;
+        f.__is_black_ = true;
+
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+
+        root.__left_ = &a;
+
+        a.__parent_ = &root;
+        a.__left_ = &d;
+        a.__right_ = &c;
+        a.__is_black_ = true;
+
+        c.__parent_ = &a;
+        c.__left_ = &b;
+        c.__right_ = &g;
+        c.__is_black_ = false;
+
+        b.__parent_ = &c;
+        b.__left_ = &e;
+        b.__right_ = &f;
+        b.__is_black_ = false;
+
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+
+        e.__parent_ = &b;
+        e.__is_black_ = true;
+
+        f.__parent_ = &b;
+        f.__is_black_ = true;
+
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+}
+
+void
+test3()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = 0;
+        b.__is_black_ = false;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &a;
+
+        a.__parent_ = &root;
+        a.__left_ = 0;
+        a.__right_ = &b;
+        a.__is_black_ = true;
+
+        b.__parent_ = &a;
+        b.__left_ = 0;
+        b.__right_ = &c;
+        b.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_balance_after_insert(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+
+        root.__left_ = &c;
+
+        c.__parent_ = &root;
+        c.__left_ = &b;
+        c.__right_ = &g;
+        c.__is_black_ = true;
+
+        b.__parent_ = &c;
+        b.__left_ = &a;
+        b.__right_ = &f;
+        b.__is_black_ = false;
+
+        a.__parent_ = &b;
+        a.__left_ = &d;
+        a.__right_ = &e;
+        a.__is_black_ = false;
+
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+
+        e.__parent_ = &a;
+        e.__is_black_ = true;
+
+        f.__parent_ = &b;
+        f.__is_black_ = true;
+
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node g;
+
+        root.__left_ = &a;
+
+        a.__parent_ = &root;
+        a.__left_ = &d;
+        a.__right_ = &b;
+        a.__is_black_ = true;
+
+        b.__parent_ = &a;
+        b.__left_ = &e;
+        b.__right_ = &c;
+        b.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = &f;
+        c.__right_ = &g;
+        c.__is_black_ = false;
+
+        d.__parent_ = &a;
+        d.__is_black_ = true;
+
+        e.__parent_ = &b;
+        e.__is_black_ = true;
+
+        f.__parent_ = &c;
+        f.__is_black_ = true;
+
+        g.__parent_ = &c;
+        g.__is_black_ = true;
+
+        std::__tree_balance_after_insert(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__left_ == &b);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == &f);
+        assert(c.__right_ == &g);
+        assert(c.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == &d);
+        assert(a.__right_ == &e);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(d.__parent_ == &a);
+        assert(d.__is_black_ == true);
+
+        assert(e.__parent_ == &a);
+        assert(e.__is_black_ == true);
+
+        assert(f.__parent_ == &c);
+        assert(f.__is_black_ == true);
+
+        assert(g.__parent_ == &c);
+        assert(g.__is_black_ == true);
+    }
+}
+
+void
+test4()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &a;
+    a.__parent_ = &root;
+
+    std::__tree_balance_after_insert(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &a);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &root);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    a.__right_ = &b;
+    b.__parent_ = &a;
+
+    std::__tree_balance_after_insert(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &a);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &root);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == &b);
+    assert(a.__is_black_ == true);
+
+    assert(b.__parent_ == &a);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == false);
+
+    b.__right_ = &c;
+    c.__parent_ = &b;
+
+    std::__tree_balance_after_insert(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    c.__right_ = &d;
+    d.__parent_ = &c;
+
+    std::__tree_balance_after_insert(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == true);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    d.__right_ = &e;
+    e.__parent_ = &d;
+
+    std::__tree_balance_after_insert(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &d);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(d.__parent_ == &b);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &e);
+    assert(d.__is_black_ == true);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    assert(e.__parent_ == &d);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    e.__right_ = &f;
+    f.__parent_ = &e;
+
+    std::__tree_balance_after_insert(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &d);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(d.__parent_ == &b);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &e);
+    assert(d.__is_black_ == false);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(e.__parent_ == &d);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == true);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    f.__right_ = &g;
+    g.__parent_ = &f;
+
+    std::__tree_balance_after_insert(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &d);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(d.__parent_ == &b);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == false);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == true);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == 0);
+    assert(g.__is_black_ == false);
+
+    g.__right_ = &h;
+    h.__parent_ = &g;
+
+    std::__tree_balance_after_insert(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &d);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(d.__parent_ == &root);
+    assert(d.__left_ == &b);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == true);
+
+    assert(b.__parent_ == &d);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == false);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == false);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+}
+
+void
+test5()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &h;
+    h.__parent_ = &root;
+
+    std::__tree_balance_after_insert(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &h);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(h.__parent_ == &root);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    h.__left_ = &g;
+    g.__parent_ = &h;
+
+    std::__tree_balance_after_insert(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &h);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(h.__parent_ == &root);
+    assert(h.__left_ == &g);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    assert(g.__parent_ == &h);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == 0);
+    assert(g.__is_black_ == false);
+
+    g.__left_ = &f;
+    f.__parent_ = &g;
+
+    std::__tree_balance_after_insert(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    f.__left_ = &e;
+    e.__parent_ = &f;
+
+    std::__tree_balance_after_insert(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    e.__left_ = &d;
+    d.__parent_ = &e;
+
+    std::__tree_balance_after_insert(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &e);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &g);
+    assert(e.__left_ == &d);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == true);
+
+    assert(d.__parent_ == &e);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    d.__left_ = &c;
+    c.__parent_ = &d;
+
+    std::__tree_balance_after_insert(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &e);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &g);
+    assert(e.__left_ == &d);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == false);
+
+    assert(d.__parent_ == &e);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    c.__left_ = &b;
+    b.__parent_ = &c;
+
+    std::__tree_balance_after_insert(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &e);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &g);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == false);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    b.__left_ = &a;
+    a.__parent_ = &b;
+
+    std::__tree_balance_after_insert(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &e);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(e.__parent_ == &root);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &g);
+    assert(e.__is_black_ == true);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == false);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(g.__parent_ == &e);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == false);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+}
diff --git a/final/test/containers/associative/tree_left_rotate.pass.cpp b/final/test/containers/associative/tree_left_rotate.pass.cpp
new file mode 100644
index 0000000..774cbc6
--- /dev/null
+++ b/final/test/containers/associative/tree_left_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition:  __x->__right_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_left_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+
+    Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+    Node root;
+    Node x;
+    Node y;
+    root.__left_ = &x;
+    x.__left_ = 0;
+    x.__right_ = &y;
+    x.__parent_ = &root;
+    y.__left_ = 0;
+    y.__right_ = 0;
+    y.__parent_ = &x;
+    std::__tree_left_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == &x);
+    assert(y.__right_ == 0);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == 0);
+    assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+    Node root;
+    Node x;
+    Node y;
+    Node a;
+    Node b;
+    Node c;
+    root.__left_ = &x;
+    x.__left_ = &a;
+    x.__right_ = &y;
+    x.__parent_ = &root;
+    y.__left_ = &b;
+    y.__right_ = &c;
+    y.__parent_ = &x;
+    a.__parent_ = &x;
+    b.__parent_ = &y;
+    c.__parent_ = &y;
+    std::__tree_left_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == &x);
+    assert(y.__right_ == &c);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == &a);
+    assert(x.__right_ == &b);
+    assert(a.__parent_ == &x);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(b.__parent_ == &x);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(c.__parent_ == &y);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/containers/associative/tree_remove.pass.cpp b/final/test/containers/associative/tree_remove.pass.cpp
new file mode 100644
index 0000000..fb14bd9
--- /dev/null
+++ b/final/test/containers/associative/tree_remove.pass.cpp
@@ -0,0 +1,1648 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Returns __tree_next(__z)
+// template <class _NodePtr>
+// void
+// __tree_remove(_NodePtr __root, _NodePtr __z)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+    bool __is_black_;
+
+    Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+    {
+        // Left
+        // Case 1 -> Case 2 -> x is red turned to black
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node y;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &y;
+        b.__right_ = &d;
+        b.__is_black_ = true;
+
+        y.__parent_ = &b;
+        y.__left_ = 0;
+        y.__right_ = 0;
+        y.__is_black_ = true;
+
+        d.__parent_ = &b;
+        d.__left_ = &c;
+        d.__right_ = &e;
+        d.__is_black_ = false;
+
+        c.__parent_ = &d;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        e.__parent_ = &d;
+        e.__left_ = 0;
+        e.__right_ = 0;
+        e.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(d.__parent_ == &root);
+        assert(d.__left_ == &b);
+        assert(d.__right_ == &e);
+        assert(d.__is_black_ == true);
+
+        assert(b.__parent_ == &d);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        assert(e.__parent_ == &d);
+        assert(e.__left_ == 0);
+        assert(e.__right_ == 0);
+        assert(e.__is_black_ == true);
+    }
+    {
+        // Right
+        // Case 1 -> Case 2 -> x is red turned to black
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node y;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__right_ = &y;
+        b.__left_ = &d;
+        b.__is_black_ = true;
+
+        y.__parent_ = &b;
+        y.__right_ = 0;
+        y.__left_ = 0;
+        y.__is_black_ = true;
+
+        d.__parent_ = &b;
+        d.__right_ = &c;
+        d.__left_ = &e;
+        d.__is_black_ = false;
+
+        c.__parent_ = &d;
+        c.__right_ = 0;
+        c.__left_ = 0;
+        c.__is_black_ = true;
+
+        e.__parent_ = &d;
+        e.__right_ = 0;
+        e.__left_ = 0;
+        e.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(d.__parent_ == &root);
+        assert(d.__right_ == &b);
+        assert(d.__left_ == &e);
+        assert(d.__is_black_ == true);
+
+        assert(b.__parent_ == &d);
+        assert(b.__right_ == 0);
+        assert(b.__left_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__right_ == 0);
+        assert(c.__left_ == 0);
+        assert(c.__is_black_ == false);
+
+        assert(e.__parent_ == &d);
+        assert(e.__right_ == 0);
+        assert(e.__left_ == 0);
+        assert(e.__is_black_ == true);
+    }
+    {
+        // Left
+        // Case 1 -> Case 3 -> Case 4
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node y;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &y;
+        b.__right_ = &d;
+        b.__is_black_ = true;
+
+        y.__parent_ = &b;
+        y.__left_ = 0;
+        y.__right_ = 0;
+        y.__is_black_ = true;
+
+        d.__parent_ = &b;
+        d.__left_ = &c;
+        d.__right_ = &e;
+        d.__is_black_ = false;
+
+        c.__parent_ = &d;
+        c.__left_ = &f;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        e.__parent_ = &d;
+        e.__left_ = 0;
+        e.__right_ = 0;
+        e.__is_black_ = true;
+
+        f.__parent_ = &c;
+        f.__left_ = 0;
+        f.__right_ = 0;
+        f.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(d.__parent_ == &root);
+        assert(d.__left_ == &f);
+        assert(d.__right_ == &e);
+        assert(d.__is_black_ == true);
+
+        assert(f.__parent_ == &d);
+        assert(f.__left_ == &b);
+        assert(f.__right_ == &c);
+        assert(f.__is_black_ == false);
+
+        assert(b.__parent_ == &f);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &f);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        assert(e.__parent_ == &d);
+        assert(e.__left_ == 0);
+        assert(e.__right_ == 0);
+        assert(e.__is_black_ == true);
+    }
+    {
+        // Right
+        // Case 1 -> Case 3 -> Case 4
+        Node root;
+        Node b;
+        Node c;
+        Node d;
+        Node e;
+        Node f;
+        Node y;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__right_ = &y;
+        b.__left_ = &d;
+        b.__is_black_ = true;
+
+        y.__parent_ = &b;
+        y.__right_ = 0;
+        y.__left_ = 0;
+        y.__is_black_ = true;
+
+        d.__parent_ = &b;
+        d.__right_ = &c;
+        d.__left_ = &e;
+        d.__is_black_ = false;
+
+        c.__parent_ = &d;
+        c.__right_ = &f;
+        c.__left_ = 0;
+        c.__is_black_ = true;
+
+        e.__parent_ = &d;
+        e.__right_ = 0;
+        e.__left_ = 0;
+        e.__is_black_ = true;
+
+        f.__parent_ = &c;
+        f.__right_ = 0;
+        f.__left_ = 0;
+        f.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &y);
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &d);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(d.__parent_ == &root);
+        assert(d.__right_ == &f);
+        assert(d.__left_ == &e);
+        assert(d.__is_black_ == true);
+
+        assert(f.__parent_ == &d);
+        assert(f.__right_ == &b);
+        assert(f.__left_ == &c);
+        assert(f.__is_black_ == false);
+
+        assert(b.__parent_ == &f);
+        assert(b.__right_ == 0);
+        assert(b.__left_ == 0);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &f);
+        assert(c.__right_ == 0);
+        assert(c.__left_ == 0);
+        assert(c.__is_black_ == true);
+
+        assert(e.__parent_ == &d);
+        assert(e.__right_ == 0);
+        assert(e.__left_ == 0);
+        assert(e.__is_black_ == true);
+    }
+}
+
+void
+test2()
+{
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == &c);
+        assert(b.__is_black_ == true);
+
+        assert(c.__parent_ == &b);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == false);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == 0);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &c);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &c);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(c.__parent_ == &root);
+        assert(c.__left_ == &a);
+        assert(c.__right_ == 0);
+        assert(c.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &a);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &root);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = true;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = true;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+    {
+        Node root;
+        Node a;
+        Node b;
+        Node c;
+
+        root.__left_ = &b;
+
+        b.__parent_ = &root;
+        b.__left_ = &a;
+        b.__right_ = &c;
+        b.__is_black_ = true;
+
+        a.__parent_ = &b;
+        a.__left_ = 0;
+        a.__right_ = 0;
+        a.__is_black_ = false;
+
+        c.__parent_ = &b;
+        c.__left_ = 0;
+        c.__right_ = 0;
+        c.__is_black_ = false;
+
+        std::__tree_remove(root.__left_, &c);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(a.__parent_ == &b);
+        assert(a.__left_ == 0);
+        assert(a.__right_ == 0);
+        assert(a.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == &a);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &a);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == &b);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+
+        assert(b.__parent_ == &root);
+        assert(b.__left_ == 0);
+        assert(b.__right_ == 0);
+        assert(b.__is_black_ == true);
+
+        std::__tree_remove(root.__left_, &b);
+
+        assert(std::__tree_invariant(root.__left_));
+
+        assert(root.__parent_ == 0);
+        assert(root.__left_ == 0);
+        assert(root.__right_ == 0);
+        assert(root.__is_black_ == false);
+    }
+}
+
+void
+test3()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &e;
+
+    e.__parent_ = &root;
+    e.__left_ = &c;
+    e.__right_ = &g;
+    e.__is_black_ = true;
+
+    c.__parent_ = &e;
+    c.__left_ = &b;
+    c.__right_ = &d;
+    c.__is_black_ = false;
+
+    g.__parent_ = &e;
+    g.__left_ = &f;
+    g.__right_ = &h;
+    g.__is_black_ = false;
+
+    b.__parent_ = &c;
+    b.__left_ = &a;
+    b.__right_ = 0;
+    b.__is_black_ = true;
+
+    d.__parent_ = &c;
+    d.__left_ = 0;
+    d.__right_ = 0;
+    d.__is_black_ = true;
+
+    f.__parent_ = &g;
+    f.__left_ = 0;
+    f.__right_ = 0;
+    f.__is_black_ = true;
+
+    h.__parent_ = &g;
+    h.__left_ = 0;
+    h.__right_ = 0;
+    h.__is_black_ = true;
+
+    a.__parent_ = &b;
+    a.__left_ = 0;
+    a.__right_ = 0;
+    a.__is_black_ = false;
+
+    assert(std::__tree_invariant(root.__left_));
+
+    std::__tree_remove(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &e);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(e.__parent_ == &root);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &g);
+    assert(e.__is_black_ == true);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == false);
+
+    assert(g.__parent_ == &e);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == 0);
+    assert(g.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &e);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(e.__parent_ == &root);
+    assert(e.__left_ == &c);
+    assert(e.__right_ == &f);
+    assert(e.__is_black_ == true);
+
+    assert(c.__parent_ == &e);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == false);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    assert(f.__parent_ == &e);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &c);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(c.__parent_ == &root);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &e);
+    assert(c.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(e.__parent_ == &c);
+    assert(e.__left_ == &d);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &e);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &c);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(c.__parent_ == &root);
+    assert(c.__left_ == &b);
+    assert(c.__right_ == &d);
+    assert(c.__is_black_ == true);
+
+    assert(b.__parent_ == &c);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    assert(d.__parent_ == &c);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == 0);
+    assert(d.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &b);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(b.__parent_ == &root);
+    assert(b.__left_ == &a);
+    assert(b.__right_ == 0);
+    assert(b.__is_black_ == true);
+
+    assert(a.__parent_ == &b);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &a);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(a.__parent_ == &root);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(a.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == 0);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+}
+
+void
+test4()
+{
+    Node root;
+    Node a;
+    Node b;
+    Node c;
+    Node d;
+    Node e;
+    Node f;
+    Node g;
+    Node h;
+
+    root.__left_ = &d;
+
+    d.__parent_ = &root;
+    d.__left_ = &b;
+    d.__right_ = &f;
+    d.__is_black_ = true;
+
+    b.__parent_ = &d;
+    b.__left_ = &a;
+    b.__right_ = &c;
+    b.__is_black_ = false;
+
+    f.__parent_ = &d;
+    f.__left_ = &e;
+    f.__right_ = &g;
+    f.__is_black_ = false;
+
+    a.__parent_ = &b;
+    a.__left_ = 0;
+    a.__right_ = 0;
+    a.__is_black_ = true;
+
+    c.__parent_ = &b;
+    c.__left_ = 0;
+    c.__right_ = 0;
+    c.__is_black_ = true;
+
+    e.__parent_ = &f;
+    e.__left_ = 0;
+    e.__right_ = 0;
+    e.__is_black_ = true;
+
+    g.__parent_ = &f;
+    g.__left_ = 0;
+    g.__right_ = &h;
+    g.__is_black_ = true;
+
+    h.__parent_ = &g;
+    h.__left_ = 0;
+    h.__right_ = 0;
+    h.__is_black_ = false;
+
+    assert(std::__tree_invariant(root.__left_));
+
+    std::__tree_remove(root.__left_, &a);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &d);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(d.__parent_ == &root);
+    assert(d.__left_ == &b);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == true);
+
+    assert(b.__parent_ == &d);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == &c);
+    assert(b.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == false);
+
+    assert(c.__parent_ == &b);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == false);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &b);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &d);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(d.__parent_ == &root);
+    assert(d.__left_ == &c);
+    assert(d.__right_ == &f);
+    assert(d.__is_black_ == true);
+
+    assert(c.__parent_ == &d);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+    assert(c.__is_black_ == true);
+
+    assert(f.__parent_ == &d);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == false);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &c);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &f);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(f.__parent_ == &root);
+    assert(f.__left_ == &d);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == true);
+
+    assert(d.__parent_ == &f);
+    assert(d.__left_ == 0);
+    assert(d.__right_ == &e);
+    assert(d.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(e.__parent_ == &d);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == false);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &d);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &f);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(f.__parent_ == &root);
+    assert(f.__left_ == &e);
+    assert(f.__right_ == &g);
+    assert(f.__is_black_ == true);
+
+    assert(e.__parent_ == &f);
+    assert(e.__left_ == 0);
+    assert(e.__right_ == 0);
+    assert(e.__is_black_ == true);
+
+    assert(g.__parent_ == &f);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &e);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == &f);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(f.__parent_ == &g);
+    assert(f.__left_ == 0);
+    assert(f.__right_ == 0);
+    assert(f.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &f);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &g);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(g.__parent_ == &root);
+    assert(g.__left_ == 0);
+    assert(g.__right_ == &h);
+    assert(g.__is_black_ == true);
+
+    assert(h.__parent_ == &g);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == false);
+
+    std::__tree_remove(root.__left_, &g);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &h);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+
+    assert(h.__parent_ == &root);
+    assert(h.__left_ == 0);
+    assert(h.__right_ == 0);
+    assert(h.__is_black_ == true);
+
+    std::__tree_remove(root.__left_, &h);
+
+    assert(std::__tree_invariant(root.__left_));
+
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == 0);
+    assert(root.__right_ == 0);
+    assert(root.__is_black_ == false);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+}
diff --git a/final/test/containers/associative/tree_right_rotate.pass.cpp b/final/test/containers/associative/tree_right_rotate.pass.cpp
new file mode 100644
index 0000000..06ec7b8
--- /dev/null
+++ b/final/test/containers/associative/tree_right_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition:  __x->__left_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_right_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+    Node* __left_;
+    Node* __right_;
+    Node* __parent_;
+
+    Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+    Node root;
+    Node x;
+    Node y;
+    root.__left_ = &x;
+    x.__left_ = &y;
+    x.__right_ = 0;
+    x.__parent_ = &root;
+    y.__left_ = 0;
+    y.__right_ = 0;
+    y.__parent_ = &x;
+    std::__tree_right_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == 0);
+    assert(y.__right_ == &x);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == 0);
+    assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+    Node root;
+    Node x;
+    Node y;
+    Node a;
+    Node b;
+    Node c;
+    root.__left_ = &x;
+    x.__left_ = &y;
+    x.__right_ = &c;
+    x.__parent_ = &root;
+    y.__left_ = &a;
+    y.__right_ = &b;
+    y.__parent_ = &x;
+    a.__parent_ = &y;
+    b.__parent_ = &y;
+    c.__parent_ = &x;
+    std::__tree_right_rotate(&x);
+    assert(root.__parent_ == 0);
+    assert(root.__left_ == &y);
+    assert(root.__right_ == 0);
+    assert(y.__parent_ == &root);
+    assert(y.__left_ == &a);
+    assert(y.__right_ == &x);
+    assert(x.__parent_ == &y);
+    assert(x.__left_ == &b);
+    assert(x.__right_ == &c);
+    assert(a.__parent_ == &y);
+    assert(a.__left_ == 0);
+    assert(a.__right_ == 0);
+    assert(b.__parent_ == &x);
+    assert(b.__left_ == 0);
+    assert(b.__right_ == 0);
+    assert(c.__parent_ == &x);
+    assert(c.__left_ == 0);
+    assert(c.__right_ == 0);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/containers/container.adaptors/nothing_to_do.pass.cpp b/final/test/containers/container.adaptors/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.adaptors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 0000000..b102f11
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     explicit priority_queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, c, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    test<int> q((test_allocator<int>(3)));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.c.size() == 0);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp
new file mode 100644
index 0000000..4d99fc1
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const Compare& comp, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    test<int> q(std::less<int>(), test_allocator<int>(3));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.c.size() == 0);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
new file mode 100644
index 0000000..66ca614
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const Compare& comp, const container_type& c,
+//                    const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    typedef std::vector<int, test_allocator<int> > C;
+    C v = make<C>(5);
+    test<int> q(std::less<int>(), v, test_allocator<int>(3));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.size() == 5);
+    assert(q.top() == 4);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
new file mode 100644
index 0000000..643b0c6
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const Compare& comp, container_type&& c,
+//                    const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    typedef std::vector<int, test_allocator<int> > C;
+    test<int> q(std::less<int>(), make<C>(5), test_allocator<int>(3));
+    assert(q.c.get_allocator() == test_allocator<int>(3));
+    assert(q.size() == 5);
+    assert(q.top() == 4);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 0000000..a5a073c
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(const priority_queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, c, a) {}
+    test(const value_compare& comp, const container_type& c,
+         const test_allocator<int>& a) : base(comp, c, a) {}
+    test(const test& q, const test_allocator<int>& a) : base(q, a) {}
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+int main()
+{
+    test<int> qo(std::less<int>(),
+                      make<std::vector<int, test_allocator<int> > >(5),
+                      test_allocator<int>(2));
+    test<int> q(qo, test_allocator<int>(6));
+    assert(q.size() == 5);
+    assert(q.c.get_allocator() == test_allocator<int>(6));
+    assert(q.top() == int(4));
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp
new file mode 100644
index 0000000..d4df36c
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//     priority_queue(priority_queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+    typedef typename base::container_type container_type;
+    typedef typename base::value_compare value_compare;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const value_compare& comp, const test_allocator<int>& a)
+        : base(comp, c, a) {}
+    test(const value_compare& comp, const container_type& c,
+        const test_allocator<int>& a) : base(comp, c, a) {}
+    test(const value_compare& comp, container_type&& c,
+         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+
+    using base::c;
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test<MoveOnly> qo(std::less<MoveOnly>(),
+                      make<std::vector<MoveOnly, test_allocator<MoveOnly> > >(5),
+                      test_allocator<MoveOnly>(2));
+    test<MoveOnly> q(std::move(qo), test_allocator<MoveOnly>(6));
+    assert(q.size() == 5);
+    assert(q.c.get_allocator() == test_allocator<MoveOnly>(6));
+    assert(q.top() == MoveOnly(4));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..82e44b4
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::vector<int> v = make<std::vector<int> >(5);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > q;
+    q = qo;
+    assert(q.size() == 5);
+    assert(q.top() == 0);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..07726f6
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+    std::priority_queue<MoveOnly> q;
+    q = std::move(qo);
+    assert(q.size() == 5);
+    assert(q.top() == MoveOnly(4));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
new file mode 100644
index 0000000..f543b63
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q((std::less<int>()));
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
new file mode 100644
index 0000000..2c73cbc
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::vector<int> v = make<std::vector<int> >(5);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > q(std::greater<int>(), v);
+    assert(q.size() == 5);
+    assert(q.top() == 0);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
new file mode 100644
index 0000000..40e3645
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::priority_queue<MoveOnly> q(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+    assert(q.size() == 5);
+    assert(q.top() == MoveOnly(4));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
new file mode 100644
index 0000000..f1129bc
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::vector<int> v = make<std::vector<int> >(5);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+    std::priority_queue<int, std::vector<int>, std::greater<int> > q = qo;
+    assert(q.size() == 5);
+    assert(q.top() == 0);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
new file mode 100644
index 0000000..2bffe80
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
new file mode 100644
index 0000000..1aaa8a3
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    std::priority_queue<int> q(a, an);
+    assert(q.size() == an - a);
+    assert(q.top() == 8);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
new file mode 100644
index 0000000..17a698c
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last, const Compare& comp);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+int main()
+{
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    std::priority_queue<int, std::vector<int>, std::greater<int> >
+        q(a, an, std::greater<int>());
+    assert(q.size() == an - a);
+    assert(q.top() == 0);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
new file mode 100644
index 0000000..b44d7d3
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last,
+//                  const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    const int n = sizeof(a)/sizeof(a[0]);
+    std::vector<int> v(a, a+n/2);
+    std::priority_queue<int> q(a+n/2, a+n, std::less<int>(), v);
+    assert(q.size() == n);
+    assert(q.top() == 8);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp
new file mode 100644
index 0000000..b81daf9
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+//   priority_queue(InputIterator first, InputIterator last,
+//                  const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    int a[] = {3, 5, 2, 0, 6, 8, 1};
+    const int n = sizeof(a)/sizeof(a[0]);
+    std::priority_queue<MoveOnly> q(a+n/2, a+n,
+                                    std::less<MoveOnly>(),
+                                    std::vector<MoveOnly>(a, a+n/2));
+    assert(q.size() == n);
+    assert(q.top() == MoveOnly(8));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
new file mode 100644
index 0000000..ad23f26
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+    std::priority_queue<MoveOnly> q = std::move(qo);
+    assert(q.size() == 5);
+    assert(q.top() == MoveOnly(4));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..48e0756
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue()
+//        noexcept(is_nothrow_default_constructible<container_type>::value &&
+//                 is_nothrow_default_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::priority_queue<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..80ad8bd
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// ~priority_queue() // implied noexcept;
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::priority_queue<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..7fd01d6
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(priority_queue&& c)
+//     noexcept(is_nothrow_move_assignable<container_type>::value &&
+//              is_nothrow_move_assignable<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::priority_queue<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..1e7fcd8
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_queue&&)
+//        noexcept(is_nothrow_move_constructible<container_type>::value &&
+//                 is_nothrow_move_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::priority_queue<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp
new file mode 100644
index 0000000..4f14e93
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::priority_queue<Emplaceable> q;
+    q.emplace(1, 2.5);
+    assert(q.top() == Emplaceable(1, 2.5));
+    q.emplace(3, 4.5);
+    assert(q.top() == Emplaceable(3, 4.5));
+    q.emplace(2, 3.5);
+    assert(q.top() == Emplaceable(3, 4.5));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
new file mode 100644
index 0000000..f0c914a
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    assert(q.empty());
+    q.push(1);
+    assert(!q.empty());
+    q.pop();
+    assert(q.empty());
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
new file mode 100644
index 0000000..f41b26f
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+    q.pop();
+    assert(q.top() == 2);
+    q.pop();
+    assert(q.top() == 1);
+    q.pop();
+    assert(q.empty());
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp
new file mode 100644
index 0000000..288e858
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp
new file mode 100644
index 0000000..2f737ce
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::priority_queue<MoveOnly> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
new file mode 100644
index 0000000..0ed579e
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    assert(q.size() == 1);
+    q.pop();
+    assert(q.size() == 0);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
new file mode 100644
index 0000000..397d67f
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void swap(priority_queue& q);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q1;
+    std::priority_queue<int> q2;
+    q1.push(1);
+    q1.push(3);
+    q1.push(2);
+    q1.swap(q2);
+    assert(q1.empty());
+    assert(q2.size() == 3);
+    assert(q2.top() == 3);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp
new file mode 100644
index 0000000..eddbb92
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// const_reference top() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q;
+    q.push(1);
+    assert(q.top() == 1);
+    q.push(3);
+    assert(q.top() == 3);
+    q.push(2);
+    assert(q.top() == 3);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp
new file mode 100644
index 0000000..1a828ad
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class T, class Container, class Compare>
+//   void swap(priority_queue<T, Container, Compare>& x,
+//             priority_queue<T, Container, Compare>& y);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::priority_queue<int> q1;
+    std::priority_queue<int> q2;
+    q1.push(1);
+    q1.push(3);
+    q1.push(2);
+    swap(q1, q2);
+    assert(q1.empty());
+    assert(q2.size() == 3);
+    assert(q2.top() == 3);
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp b/final/test/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..e40570a
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(priority_queue& c)
+//     noexcept(__is_nothrow_swappable<container_type>::value &&
+//              __is_nothrow_swappable<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::priority_queue<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/priority.queue/types.pass.cpp b/final/test/containers/container.adaptors/priority.queue/types.pass.cpp
new file mode 100644
index 0000000..ade20d4
--- /dev/null
+++ b/final/test/containers/container.adaptors/priority.queue/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = vector<T>,
+//           class Compare = less<typename Container::value_type>>
+// class priority_queue
+// {
+// public:
+//     typedef Container                                container_type;
+//     typedef typename container_type::value_type      value_type;
+//     typedef typename container_type::reference       reference;
+//     typedef typename container_type::const_reference const_reference;
+//     typedef typename container_type::size_type       size_type;
+//
+// protected:
+//     container_type c;
+//     Compare comp;
+
+#include <queue>
+#include <cassert>
+#include <type_traits>
+
+struct test
+    : private std::priority_queue<int>
+{
+    test()
+    {
+        c.push_back(1);
+        assert(comp(1, 2));
+    }
+};
+
+struct C
+{
+    typedef int value_type;
+    typedef int& reference;
+    typedef const int& const_reference;
+    typedef int size_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::priority_queue<int>::container_type, std::vector<int> >::value), "");
+    static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::container_type, std::deque<int> >::value), "");
+    static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::value_type, int>::value), "");
+    static_assert((std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), "");
+    static_assert((std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), "");
+    static_assert((std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<std::priority_queue<int, C>, std::allocator<int> >::value), "");
+    test t;
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 0000000..b3ee758
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   explicit queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+struct test
+    : private std::queue<int, std::deque<int, test_allocator<int> > >
+{
+    typedef std::queue<int, std::deque<int, test_allocator<int> > > base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    test q(test_allocator<int>(3));
+    assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 0000000..16ba174
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+    : public std::queue<int, C>
+{
+    typedef std::queue<int, C> base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    C d = make<C>(5);
+    test q(d, test_allocator<int>(4));
+    assert(q.get_allocator() == test_allocator<int>(4));
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.front() == d[i]);
+        q.pop();
+    }
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
new file mode 100644
index 0000000..70eaa18
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(const queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+    : public std::queue<T, C>
+{
+    typedef std::queue<T, C> base;
+    typedef test_allocator<int>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(const test& q, const allocator_type& a) : base(q, a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+    test<int> q(make<C>(5), test_allocator<int>(4));
+    test<int> q2(q, test_allocator<int>(5));
+    assert(q2.get_allocator() == test_allocator<int>(5));
+    assert(q2.size() == 5);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 0000000..b752238
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::queue<T, C>
+{
+    typedef std::queue<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+    assert(q.size() == 5);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 0000000..11b4ecd
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+//   queue(queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::queue<T, C>
+{
+    typedef std::queue<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+    assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+    assert(q2.size() == 5);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp
new file mode 100644
index 0000000..c4ab955
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::deque<int> d = make<std::deque<int> >(5);
+    std::queue<int> q(d);
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.front() == d[i]);
+        q.pop();
+    }
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp
new file mode 100644
index 0000000..998f849
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(const queue&) = default;
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q(make<std::deque<int> >(5));
+    std::queue<int> q2 = q;
+    assert(q2 == q);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp
new file mode 100644
index 0000000..e6aadd3
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    std::queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.front() == 1);
+    assert(q.back() == 2);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp
new file mode 100644
index 0000000..f168209
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::queue<MoveOnly> q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 0000000..2f6c3da
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    assert(q.size() == 5);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..874577c
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue()
+//        noexcept(is_nothrow_default_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::queue<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..1af20ec
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// ~queue() // implied noexcept;
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::queue<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..1b45bfa
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& c)
+//     noexcept(is_nothrow_move_assignable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::queue<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp b/final/test/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..8fba28f
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(queue&&)
+//        noexcept(is_nothrow_move_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::queue<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
new file mode 100644
index 0000000..e9afa0b
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(const queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q(make<std::deque<int> >(5));
+    std::queue<int> q2;
+    q2 = q;
+    assert(q2 == q);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp
new file mode 100644
index 0000000..828c0b7
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::queue<MoveOnly> q2;
+    q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/back.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/back.pass.cpp
new file mode 100644
index 0000000..e91edc2
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/back.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference back();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    int& ir = q.back();
+    assert(ir == 3);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp
new file mode 100644
index 0000000..f2696e9
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference back() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    const std::queue<int>& cqr = q;
+    const int& cir = cqr.back();
+    assert(cir == 3);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
new file mode 100644
index 0000000..1d9c08b
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::queue<Emplaceable> q;
+    q.emplace(1, 2.5);
+    q.emplace(2, 3.5);
+    q.emplace(3, 4.5);
+    assert(q.size() == 3);
+    assert(q.front() == Emplaceable(1, 2.5));
+    assert(q.back() == Emplaceable(3, 4.5));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/empty.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
new file mode 100644
index 0000000..deac5fa
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.empty());
+    q.push(1);
+    assert(!q.empty());
+    q.pop();
+    assert(q.empty());
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/front.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/front.pass.cpp
new file mode 100644
index 0000000..4fbbb00
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/front.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference front();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    int& ir = q.front();
+    assert(ir == 1);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp
new file mode 100644
index 0000000..253a278
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference front() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    const std::queue<int>& cqr = q;
+    const int& cir = cqr.front();
+    assert(cir == 1);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/pop.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/pop.pass.cpp
new file mode 100644
index 0000000..3da2d12
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/pop.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.front() == 1);
+    assert(q.back() == 3);
+    q.pop();
+    assert(q.size() == 2);
+    assert(q.front() == 2);
+    assert(q.back() == 3);
+    q.pop();
+    assert(q.size() == 1);
+    assert(q.front() == 3);
+    assert(q.back() == 3);
+    q.pop();
+    assert(q.size() == 0);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/push.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/push.pass.cpp
new file mode 100644
index 0000000..9d46295
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/push.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    q.push(1);
+    assert(q.size() == 1);
+    assert(q.front() == 1);
+    assert(q.back() == 1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.front() == 1);
+    assert(q.back() == 2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.front() == 1);
+    assert(q.back() == 3);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
new file mode 100644
index 0000000..11883d8
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::queue<MoveOnly> q;
+    q.push(MoveOnly(1));
+    assert(q.size() == 1);
+    assert(q.front() == MoveOnly(1));
+    assert(q.back() == MoveOnly(1));
+    q.push(MoveOnly(2));
+    assert(q.size() == 2);
+    assert(q.front() == MoveOnly(1));
+    assert(q.back() == MoveOnly(2));
+    q.push(MoveOnly(3));
+    assert(q.size() == 3);
+    assert(q.front() == MoveOnly(1));
+    assert(q.back() == MoveOnly(3));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/size.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/size.pass.cpp
new file mode 100644
index 0000000..1c72408
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/size.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+    std::queue<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    assert(q.size() == 1);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/swap.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
new file mode 100644
index 0000000..e074493
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    std::queue<int> q1_save = q1;
+    std::queue<int> q2_save = q2;
+    q1.swap(q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.defn/types.pass.cpp b/final/test/containers/container.adaptors/queue/queue.defn/types.pass.cpp
new file mode 100644
index 0000000..cc918a3
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.defn/types.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = deque<T>>
+// class queue
+// {
+// public:
+//     typedef Container                                container_type;
+//     typedef typename container_type::value_type      value_type;
+//     typedef typename container_type::reference       reference;
+//     typedef typename container_type::const_reference const_reference;
+//     typedef typename container_type::size_type       size_type;
+//
+// protected:
+//     container_type c;
+// ...
+// };
+
+#include <queue>
+#include <type_traits>
+
+struct test
+    : private std::queue<int>
+{
+    test()
+    {
+        c.push_back(1);
+    }
+};
+
+struct C
+{
+    typedef int value_type;
+    typedef int& reference;
+    typedef const int& const_reference;
+    typedef int size_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::queue<int>::container_type, std::deque<int> >::value), "");
+    static_assert((std::is_same<std::queue<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+    static_assert((std::is_same<std::queue<double, std::vector<int> >::value_type, int>::value), "");
+    static_assert((std::is_same<std::queue<int>::reference, std::deque<int>::reference>::value), "");
+    static_assert((std::is_same<std::queue<int>::const_reference, std::deque<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::queue<int>::size_type, std::deque<int>::size_type>::value), "");
+    static_assert((std::uses_allocator<std::queue<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<std::queue<int, C>, std::allocator<int> >::value), "");
+    test t;
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.ops/eq.pass.cpp b/final/test/containers/container.adaptors/queue/queue.ops/eq.pass.cpp
new file mode 100644
index 0000000..a2ad32f
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.ops/eq.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+//   bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    std::queue<int> q1_save = q1;
+    std::queue<int> q2_save = q2;
+    assert(q1 == q1_save);
+    assert(q1 != q2);
+    assert(q2 == q2_save);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.ops/lt.pass.cpp b/final/test/containers/container.adaptors/queue/queue.ops/lt.pass.cpp
new file mode 100644
index 0000000..af08cba
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.ops/lt.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+//   bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    assert(q1 < q2);
+    assert(q2 > q1);
+    assert(q1 <= q2);
+    assert(q2 >= q1);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.special/swap.pass.cpp b/final/test/containers/container.adaptors/queue/queue.special/swap.pass.cpp
new file mode 100644
index 0000000..a3f7c43
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.special/swap.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+//   void swap(queue<T, Container>& x, queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::queue<int> q1 = make<std::queue<int> >(5);
+    std::queue<int> q2 = make<std::queue<int> >(10);
+    std::queue<int> q1_save = q1;
+    std::queue<int> q2_save = q2;
+    swap(q1, q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/final/test/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp b/final/test/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..5c9b775
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& c)
+//     noexcept(__is_nothrow_swappable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::queue<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/queue/version.pass.cpp b/final/test/containers/container.adaptors/queue/version.pass.cpp
new file mode 100644
index 0000000..35b94b3
--- /dev/null
+++ b/final/test/containers/container.adaptors/queue/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+#include <queue>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 0000000..94899d4
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   explicit stack(const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+struct test
+    : private std::stack<int, std::deque<int, test_allocator<int> > >
+{
+    typedef std::stack<int, std::deque<int, test_allocator<int> > > base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    test q(test_allocator<int>(3));
+    assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 0000000..fe86227
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+    : public std::stack<int, C>
+{
+    typedef std::stack<int, C> base;
+
+    explicit test(const test_allocator<int>& a) : base(a) {}
+    test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+    C d = make<C>(5);
+    test q(d, test_allocator<int>(4));
+    assert(q.get_allocator() == test_allocator<int>(4));
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.top() == d[d.size() - i - 1]);
+        q.pop();
+    }
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 0000000..33cb4dd
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(const stack& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(int(i));
+    return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+    : public std::stack<T, C>
+{
+    typedef std::stack<T, C> base;
+    typedef test_allocator<int>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(const test& q, const allocator_type& a) : base(q, a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+    test<int> q(make<C>(5), test_allocator<int>(4));
+    test<int> q2(q, test_allocator<int>(5));
+    assert(q2.get_allocator() == test_allocator<int>(5));
+    assert(q2.size() == 5);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 0000000..16ba9d7
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::stack<T, C>
+{
+    typedef std::stack<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+    assert(q.size() == 5);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 0000000..19d968a
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+//   stack(stack&& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+    : public std::stack<T, C>
+{
+    typedef std::stack<T, C> base;
+    typedef test_allocator<MoveOnly>      allocator_type;
+    typedef typename base::container_type container_type;
+
+    explicit test(const allocator_type& a) : base(a) {}
+    test(const container_type& c, const allocator_type& a) : base(c, a) {}
+    test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+    test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+    allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+    test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+    assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+    assert(q2.size() == 5);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
new file mode 100644
index 0000000..9dc0501
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(const container_type& c);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::deque<int> d = make<std::deque<int> >(5);
+    std::stack<int> q(d);
+    assert(q.size() == 5);
+    for (int i = 0; i < d.size(); ++i)
+    {
+        assert(q.top() == d[d.size() - i - 1]);
+        q.pop();
+    }
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
new file mode 100644
index 0000000..8673e06
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(const stack&) = default;
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q(make<std::deque<int> >(5));
+    std::stack<int> q2 = q;
+    assert(q2 == q);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
new file mode 100644
index 0000000..523cd68
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack();
+
+#include <stack>
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+    std::stack<int, std::vector<int, stack_allocator<int, 10> > > q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
new file mode 100644
index 0000000..173bfc2
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::stack<MoveOnly> q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 0000000..a6c424d
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(container_type&& c);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    assert(q.size() == 5);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..521d956
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack()
+//        noexcept(is_nothrow_default_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::stack<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..c502012
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// ~stack() // implied noexcept;
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::stack<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..4952803
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& c)
+//     noexcept(is_nothrow_move_assignable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::stack<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/final/test/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..c982683
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&&)
+//        noexcept(is_nothrow_move_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::stack<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp
new file mode 100644
index 0000000..38769e3
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(const stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q(make<std::deque<int> >(5));
+    std::stack<int> q2;
+    q2 = q;
+    assert(q2 == q);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
new file mode 100644
index 0000000..5455299
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push_back(MoveOnly(i));
+    return c;
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+    std::stack<MoveOnly> q2;
+    q2 = std::move(q);
+    assert(q2.size() == 5);
+    assert(q.empty());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp
new file mode 100644
index 0000000..3573c22
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::stack<Emplaceable> q;
+    q.emplace(1, 2.5);
+    q.emplace(2, 3.5);
+    q.emplace(3, 4.5);
+    assert(q.size() == 3);
+    assert(q.top() == Emplaceable(3, 4.5));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/empty.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/empty.pass.cpp
new file mode 100644
index 0000000..a4f7281
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// bool empty() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.empty());
+    q.push(1);
+    assert(!q.empty());
+    q.pop();
+    assert(q.empty());
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/pop.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/pop.pass.cpp
new file mode 100644
index 0000000..7ec1bf1
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void pop();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.top() == 3);
+    q.pop();
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+    q.pop();
+    assert(q.size() == 1);
+    assert(q.top() == 1);
+    q.pop();
+    assert(q.size() == 0);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/push.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/push.pass.cpp
new file mode 100644
index 0000000..6d5c908
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/push.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(const value_type& v);
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    q.push(1);
+    assert(q.size() == 1);
+    assert(q.top() == 1);
+    q.push(2);
+    assert(q.size() == 2);
+    assert(q.top() == 2);
+    q.push(3);
+    assert(q.size() == 3);
+    assert(q.top() == 3);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
new file mode 100644
index 0000000..c769c5d
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(value_type&& v);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::stack<MoveOnly> q;
+    q.push(MoveOnly(1));
+    assert(q.size() == 1);
+    assert(q.top() == MoveOnly(1));
+    q.push(MoveOnly(2));
+    assert(q.size() == 2);
+    assert(q.top() == MoveOnly(2));
+    q.push(MoveOnly(3));
+    assert(q.size() == 3);
+    assert(q.top() == MoveOnly(3));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/size.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/size.pass.cpp
new file mode 100644
index 0000000..2d80247
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/size.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// size_type size() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    assert(q.size() == 1);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/swap.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/swap.pass.cpp
new file mode 100644
index 0000000..50a29c4
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void swap(stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    std::stack<int> q1_save = q1;
+    std::stack<int> q2_save = q2;
+    q1.swap(q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/top.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/top.pass.cpp
new file mode 100644
index 0000000..6bde162
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/top.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// reference top();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    int& ir = q.top();
+    assert(ir == 3);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp
new file mode 100644
index 0000000..8e43d05
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// const_reference top() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+    std::stack<int> q;
+    assert(q.size() == 0);
+    q.push(1);
+    q.push(2);
+    q.push(3);
+    const std::stack<int>& cqr = q;
+    const int& cir = cqr.top();
+    assert(cir == 3);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.defn/types.pass.cpp b/final/test/containers/container.adaptors/stack/stack.defn/types.pass.cpp
new file mode 100644
index 0000000..afc5ebd
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.defn/types.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container = deque<T>>
+// class stack
+// {
+// public:
+//     typedef Container                                container_type;
+//     typedef typename container_type::value_type      value_type;
+//     typedef typename container_type::reference       reference;
+//     typedef typename container_type::const_reference const_reference;
+//     typedef typename container_type::size_type       size_type;
+//
+// protected:
+//     container_type c;
+// ...
+// };
+
+#include <stack>
+#include <vector>
+#include <type_traits>
+
+struct test
+    : private std::stack<int>
+{
+    test()
+    {
+        c.push_back(1);
+    }
+};
+
+struct C
+{
+    typedef int value_type;
+    typedef int& reference;
+    typedef const int& const_reference;
+    typedef int size_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::stack<int>::container_type, std::deque<int> >::value), "");
+    static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+    static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), "");
+    static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), "");
+    static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), "");
+    static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), "");
+    test t;
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.ops/eq.pass.cpp b/final/test/containers/container.adaptors/stack/stack.ops/eq.pass.cpp
new file mode 100644
index 0000000..9b041f7
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.ops/eq.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+//   bool operator==(const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    std::stack<int> q1_save = q1;
+    std::stack<int> q2_save = q2;
+    assert(q1 == q1_save);
+    assert(q1 != q2);
+    assert(q2 == q2_save);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.ops/lt.pass.cpp b/final/test/containers/container.adaptors/stack/stack.ops/lt.pass.cpp
new file mode 100644
index 0000000..beb937d
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.ops/lt.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+//   bool operator< (const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator> (const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+//   bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    assert(q1 < q2);
+    assert(q2 > q1);
+    assert(q1 <= q2);
+    assert(q2 >= q1);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.special/swap.pass.cpp b/final/test/containers/container.adaptors/stack/stack.special/swap.pass.cpp
new file mode 100644
index 0000000..9037114
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.special/swap.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+//   void swap(stack<T, Container>& x, stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+    C c;
+    for (int i = 0; i < n; ++i)
+        c.push(i);
+    return c;
+}
+
+int main()
+{
+    std::stack<int> q1 = make<std::stack<int> >(5);
+    std::stack<int> q2 = make<std::stack<int> >(10);
+    std::stack<int> q1_save = q1;
+    std::stack<int> q2_save = q2;
+    swap(q1, q2);
+    assert(q1 == q2_save);
+    assert(q2 == q1_save);
+}
diff --git a/final/test/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp b/final/test/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..d0977f4
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void swap(stack& c)
+//     noexcept(__is_nothrow_swappable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::stack<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/container.adaptors/stack/version.pass.cpp b/final/test/containers/container.adaptors/stack/version.pass.cpp
new file mode 100644
index 0000000..339d0f4
--- /dev/null
+++ b/final/test/containers/container.adaptors/stack/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+#include <stack>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/unord.req/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp b/final/test/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/containers.general/nothing_to_do.pass.cpp b/final/test/containers/containers.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/containers.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/nothing_to_do.pass.cpp b/final/test/containers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/array/array.cons/default.pass.cpp b/final/test/containers/sequences/array/array.cons/default.pass.cpp
new file mode 100644
index 0000000..7bc62b7
--- /dev/null
+++ b/final/test/containers/sequences/array/array.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// array();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c;
+        assert(c.size() == 3);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c;
+        assert(c.size() == 0);
+    }
+}
diff --git a/final/test/containers/sequences/array/array.cons/initializer_list.pass.cpp b/final/test/containers/sequences/array/array.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..b9775ee
--- /dev/null
+++ b/final/test/containers/sequences/array/array.cons/initializer_list.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// Construct with initizializer list
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        assert(c.size() == 3);
+        assert(c[0] == 1);
+        assert(c[1] == 2);
+        assert(c[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        assert(c.size() == 0);
+    }
+}
diff --git a/final/test/containers/sequences/array/array.data/data.pass.cpp b/final/test/containers/sequences/array/array.data/data.pass.cpp
new file mode 100644
index 0000000..ea91357
--- /dev/null
+++ b/final/test/containers/sequences/array/array.data/data.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// T *data();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        T* p = c.data();
+        assert(p[0] == 1);
+        assert(p[1] == 2);
+        assert(p[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        T* p = c.data();
+    }
+}
diff --git a/final/test/containers/sequences/array/array.data/data_const.pass.cpp b/final/test/containers/sequences/array/array.data/data_const.pass.cpp
new file mode 100644
index 0000000..93acb71
--- /dev/null
+++ b/final/test/containers/sequences/array/array.data/data_const.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// const T* data() const;
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        const C c = {1, 2, 3.5};
+        const T* p = c.data();
+        assert(p[0] == 1);
+        assert(p[1] == 2);
+        assert(p[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        const C c = {};
+        const T* p = c.data();
+    }
+}
diff --git a/final/test/containers/sequences/array/array.fill/fill.pass.cpp b/final/test/containers/sequences/array/array.fill/fill.pass.cpp
new file mode 100644
index 0000000..675f495
--- /dev/null
+++ b/final/test/containers/sequences/array/array.fill/fill.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void fill(const T& u);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        c.fill(5.5);
+        assert(c.size() == 3);
+        assert(c[0] == 5.5);
+        assert(c[1] == 5.5);
+        assert(c[2] == 5.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        c.fill(5.5);
+        assert(c.size() == 0);
+    }
+}
diff --git a/final/test/containers/sequences/array/array.size/size.pass.cpp b/final/test/containers/sequences/array/array.size/size.pass.cpp
new file mode 100644
index 0000000..fe5a0d5
--- /dev/null
+++ b/final/test/containers/sequences/array/array.size/size.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> constexpr size_type array<T,N>::size();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        assert(c.size() == 3);
+        assert(c.max_size() == 3);
+        assert(!c.empty());
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c = {};
+        assert(c.size() == 0);
+        assert(c.max_size() == 0);
+        assert(c.empty());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        constexpr C c = {1, 2, 3.5};
+        static_assert(c.size() == 3, "");
+        static_assert(c.max_size() == 3, "");
+        static_assert(!c.empty(), "");
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        constexpr C c = {};
+        static_assert(c.size() == 0, "");
+        static_assert(c.max_size() == 0, "");
+        static_assert(c.empty(), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/array/array.special/swap.pass.cpp b/final/test/containers/sequences/array/array.special/swap.pass.cpp
new file mode 100644
index 0000000..08e4377
--- /dev/null
+++ b/final/test/containers/sequences/array/array.special/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c1 = {1, 2, 3.5};
+        C c2 = {4, 5, 6.5};
+        swap(c1, c2);
+        assert(c1.size() == 3);
+        assert(c1[0] == 4);
+        assert(c1[1] == 5);
+        assert(c1[2] == 6.5);
+        assert(c2.size() == 3);
+        assert(c2[0] == 1);
+        assert(c2[1] == 2);
+        assert(c2[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c1 = {};
+        C c2 = {};
+        swap(c1, c2);
+        assert(c1.size() == 0);
+        assert(c2.size() == 0);
+    }
+}
diff --git a/final/test/containers/sequences/array/array.swap/swap.pass.cpp b/final/test/containers/sequences/array/array.swap/swap.pass.cpp
new file mode 100644
index 0000000..c7a4cb8
--- /dev/null
+++ b/final/test/containers/sequences/array/array.swap/swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void swap(array& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c1 = {1, 2, 3.5};
+        C c2 = {4, 5, 6.5};
+        c1.swap(c2);
+        assert(c1.size() == 3);
+        assert(c1[0] == 4);
+        assert(c1[1] == 5);
+        assert(c1[2] == 6.5);
+        assert(c2.size() == 3);
+        assert(c2[0] == 1);
+        assert(c2[1] == 2);
+        assert(c2[2] == 3.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        C c1 = {};
+        C c2 = {};
+        c1.swap(c2);
+        assert(c1.size() == 0);
+        assert(c2.size() == 0);
+    }
+}
diff --git a/final/test/containers/sequences/array/array.tuple/get.fail.cpp b/final/test/containers/sequences/array/array.tuple/get.fail.cpp
new file mode 100644
index 0000000..4f4fbcf
--- /dev/null
+++ b/final/test/containers/sequences/array/array.tuple/get.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        std::get<3>(c) = 5.5;    // Can't get element 3!
+    }
+}
diff --git a/final/test/containers/sequences/array/array.tuple/get.pass.cpp b/final/test/containers/sequences/array/array.tuple/get.pass.cpp
new file mode 100644
index 0000000..d9e242c
--- /dev/null
+++ b/final/test/containers/sequences/array/array.tuple/get.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+#if __cplusplus > 201103L
+struct S {
+   std::array<int, 3> a;
+   int k;
+   constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
+   };
+
+constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        std::get<1>(c) = 5.5;
+        assert(c[0] == 1);
+        assert(c[1] == 5.5);
+        assert(c[2] == 3.5);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        constexpr C c = {1, 2, 3.5};
+        static_assert(std::get<0>(c) == 1, "");
+        static_assert(std::get<1>(c) == 2, "");
+        static_assert(std::get<2>(c) == 3.5, "");
+    }
+    {
+        static_assert(S().k == 3, "");
+        static_assert(std::get<1>(getArr()) == 4, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/array/array.tuple/get_const.pass.cpp b/final/test/containers/sequences/array/array.tuple/get_const.pass.cpp
new file mode 100644
index 0000000..1cbdfa4
--- /dev/null
+++ b/final/test/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        const C c = {1, 2, 3.5};
+        assert(std::get<0>(c) == 1);
+        assert(std::get<1>(c) == 2);
+        assert(std::get<2>(c) == 3.5);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        constexpr const C c = {1, 2, 3.5};
+        static_assert(std::get<0>(c) == 1, "");
+        static_assert(std::get<1>(c) == 2, "");
+        static_assert(std::get<2>(c) == 3.5, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/array/array.tuple/get_rv.pass.cpp b/final/test/containers/sequences/array/array.tuple/get_rv.pass.cpp
new file mode 100644
index 0000000..869c1ec
--- /dev/null
+++ b/final/test/containers/sequences/array/array.tuple/get_rv.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
+
+#include <array>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unique_ptr<double> T;
+        typedef std::array<T, 1> C;
+        C c = {std::unique_ptr<double>(new double(3.5))};
+        T t = std::get<0>(std::move(c));
+        assert(*t == 3.5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp b/final/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp
new file mode 100644
index 0000000..cd1dad6
--- /dev/null
+++ b/final/test/containers/sequences/array/array.tuple/tuple_element.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_element<I, array<T, N> >::type
+
+#include <array>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+    }
+    {
+        typedef int T;
+        typedef std::array<T, 3> C;
+        static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+        static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+    }
+}
diff --git a/final/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp b/final/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp
new file mode 100644
index 0000000..83394b1
--- /dev/null
+++ b/final/test/containers/sequences/array/array.tuple/tuple_size.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_size<array<T, N> >::value
+
+#include <array>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        static_assert((std::tuple_size<C>::value == 3), "");
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 0> C;
+        static_assert((std::tuple_size<C>::value == 0), "");
+    }
+}
diff --git a/final/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp b/final/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..0aa2f50
--- /dev/null
+++ b/final/test/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// support for zero-sized array
+
+#include <array>
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/array/at.pass.cpp b/final/test/containers/sequences/array/at.pass.cpp
new file mode 100644
index 0000000..b5cf8a5
--- /dev/null
+++ b/final/test/containers/sequences/array/at.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        C::reference r1 = c.at(0);
+        assert(r1 == 1);
+        r1 = 5.5;
+        assert(c.front() == 5.5);
+        
+        C::reference r2 = c.at(2);
+        assert(r2 == 3.5);
+        r2 = 7.5;
+        assert(c.back() == 7.5);
+
+        try { (void) c.at(3); }
+        catch (const std::out_of_range &) {}
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        const C c = {1, 2, 3.5};
+        C::const_reference r1 = c.at(0);
+        assert(r1 == 1);
+        
+        C::const_reference r2 = c.at(2);
+        assert(r2 == 3.5);
+
+        try { (void) c.at(3); }
+        catch (const std::out_of_range &) {}
+    }
+    
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        constexpr C c = {1, 2, 3.5};
+
+        constexpr T t1 = c.at(0);
+        static_assert (t1 == 1, "");
+
+        constexpr T t2 = c.at(2);
+        static_assert (t2 == 3.5, "");
+    }
+#endif
+
+}
diff --git a/final/test/containers/sequences/array/begin.pass.cpp b/final/test/containers/sequences/array/begin.pass.cpp
new file mode 100644
index 0000000..9cba0d6
--- /dev/null
+++ b/final/test/containers/sequences/array/begin.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator begin();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        C::iterator i;
+        i = c.begin();
+        assert(*i == 1);
+        assert(&*i == c.data());
+        *i = 5.5;
+        assert(c[0] == 5.5);
+    }
+    {
+    }
+}
diff --git a/final/test/containers/sequences/array/front_back.pass.cpp b/final/test/containers/sequences/array/front_back.pass.cpp
new file mode 100644
index 0000000..45a963b
--- /dev/null
+++ b/final/test/containers/sequences/array/front_back.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference front();
+// reference back();
+// const_reference front(); // constexpr in C++14
+// const_reference back(); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+
+        C::reference r1 = c.front();
+        assert(r1 == 1);
+        r1 = 5.5;
+        assert(c[0] == 5.5);
+        
+        C::reference r2 = c.back();
+        assert(r2 == 3.5);
+        r2 = 7.5;
+        assert(c[2] == 7.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        const C c = {1, 2, 3.5};
+        C::const_reference r1 = c.front();
+        assert(r1 == 1);
+
+        C::const_reference r2 = c.back();
+        assert(r2 == 3.5);
+    }
+
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        constexpr C c = {1, 2, 3.5};
+        
+        constexpr T t1 = c.front();
+        static_assert (t1 == 1, "");
+
+        constexpr T t2 = c.back();
+        static_assert (t2 == 3.5, "");
+    }
+#endif
+
+}
diff --git a/final/test/containers/sequences/array/indexing.pass.cpp b/final/test/containers/sequences/array/indexing.pass.cpp
new file mode 100644
index 0000000..e4dda0d
--- /dev/null
+++ b/final/test/containers/sequences/array/indexing.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        C c = {1, 2, 3.5};
+        C::reference r1 = c[0];
+        assert(r1 == 1);
+        r1 = 5.5;
+        assert(c.front() == 5.5);
+        
+        C::reference r2 = c[2];
+        assert(r2 == 3.5);
+        r2 = 7.5;
+        assert(c.back() == 7.5);
+    }
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        const C c = {1, 2, 3.5};
+        C::const_reference r1 = c[0];
+        assert(r1 == 1);
+        C::const_reference r2 = c[2];
+        assert(r2 == 3.5);
+    }
+    
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef double T;
+        typedef std::array<T, 3> C;
+        constexpr C c = {1, 2, 3.5};
+        
+        constexpr T t1 = c[0];
+        static_assert (t1 == 1, "");
+
+        constexpr T t2 = c[2];
+        static_assert (t2 == 3.5, "");
+    }
+#endif
+
+}
diff --git a/final/test/containers/sequences/array/iterators.pass.cpp b/final/test/containers/sequences/array/iterators.pass.cpp
new file mode 100644
index 0000000..98997d8
--- /dev/null
+++ b/final/test/containers/sequences/array/iterators.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator, const_iterator
+
+#include <array>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    {
+    typedef std::array<int, 5> C;
+    C c;
+    C::iterator i;
+    i = c.begin();
+    C::const_iterator j;
+    j = c.cbegin();
+    assert(i == j);
+    }
+    {
+    typedef std::array<int, 0> C;
+    C c;
+    C::iterator i;
+    i = c.begin();
+    C::const_iterator j;
+    j = c.cbegin();
+    assert(i == j);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        {
+        typedef std::array<int, 5> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+        assert ( ii1 == cii );
+
+        assert ( !(ii1 != ii2 ));
+        assert ( !(ii1 != cii ));
+
+        C c;
+        assert ( c.begin()   == std::begin(c));
+        assert ( c.cbegin()  == std::cbegin(c));
+        assert ( c.rbegin()  == std::rbegin(c));
+        assert ( c.crbegin() == std::crbegin(c));
+        assert ( c.end()     == std::end(c));
+        assert ( c.cend()    == std::cend(c));
+        assert ( c.rend()    == std::rend(c));
+        assert ( c.crend()   == std::crend(c));
+        
+        assert ( std::begin(c)   != std::end(c));
+        assert ( std::rbegin(c)  != std::rend(c));
+        assert ( std::cbegin(c)  != std::cend(c));
+        assert ( std::crbegin(c) != std::crend(c));
+        }
+        {
+        typedef std::array<int, 0> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+        assert (!(ii1 <  cii ));
+        assert (!(cii <  ii1 ));
+        assert ( (ii1 <= cii ));
+        assert ( (cii <= ii1 ));
+        assert (!(ii1 >  cii ));
+        assert (!(cii >  ii1 ));
+        assert ( (ii1 >= cii ));
+        assert ( (cii >= ii1 ));
+        assert (cii - ii1 == 0);
+        assert (ii1 - cii == 0);
+
+        C c;
+        assert ( c.begin()   == std::begin(c));
+        assert ( c.cbegin()  == std::cbegin(c));
+        assert ( c.rbegin()  == std::rbegin(c));
+        assert ( c.crbegin() == std::crbegin(c));
+        assert ( c.end()     == std::end(c));
+        assert ( c.cend()    == std::cend(c));
+        assert ( c.rend()    == std::rend(c));
+        assert ( c.crend()   == std::crend(c));
+
+        assert ( std::begin(c)   == std::end(c));
+        assert ( std::rbegin(c)  == std::rend(c));
+        assert ( std::cbegin(c)  == std::cend(c));
+        assert ( std::crbegin(c) == std::crend(c));
+        }
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/array/types.pass.cpp b/final/test/containers/sequences/array/types.pass.cpp
new file mode 100644
index 0000000..065ade9
--- /dev/null
+++ b/final/test/containers/sequences/array/types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N >
+// struct array
+// {
+//     // types:
+//     typedef T& reference;
+//     typedef const T& const_reference;
+//     typedef implementation defined iterator;
+//     typedef implementation defined const_iterator;
+//     typedef T value_type;
+//     typedef T* pointer;
+//     typedef size_t size_type;
+//     typedef ptrdiff_t difference_type;
+//     typedef T value_type;
+//     typedef std::reverse_iterator<iterator> reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#include <array>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef double T;
+        typedef std::array<T, 10> C;
+        static_assert((std::is_same<C::reference, T&>::value), "");
+        static_assert((std::is_same<C::const_reference, const T&>::value), "");
+        static_assert((std::is_same<C::iterator, T*>::value), "");
+        static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+        static_assert((std::is_same<C::pointer, T*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+        static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+        static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+    }
+    {
+        typedef int* T;
+        typedef std::array<T, 0> C;
+        static_assert((std::is_same<C::reference, T&>::value), "");
+        static_assert((std::is_same<C::const_reference, const T&>::value), "");
+        static_assert((std::is_same<C::iterator, T*>::value), "");
+        static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+        static_assert((std::is_same<C::pointer, T*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const T*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+        static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+        static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+    }
+}
diff --git a/final/test/containers/sequences/array/version.pass.cpp b/final/test/containers/sequences/array/version.pass.cpp
new file mode 100644
index 0000000..b89a8dd
--- /dev/null
+++ b/final/test/containers/sequences/array/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+#include <array>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/deque/deque.capacity/access.pass.cpp b/final/test/containers/sequences/deque/deque.capacity/access.pass.cpp
new file mode 100644
index 0000000..77aaf3c
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.capacity/access.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+//       reference operator[](size_type __i);
+// const_reference operator[](size_type __i) const;
+//
+//       reference at(size_type __i);
+// const_reference at(size_type __i) const;
+//
+//       reference front();
+// const_reference front() const;
+//
+//       reference back();
+// const_reference back() const;
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+int main()
+{
+    {
+        std::deque<int> c = make<std::deque<int> >(10);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c[i] == i);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c.at(i) == i);
+        assert(c.front() == 0);
+        assert(c.back() == 9);
+    }
+    {
+        const std::deque<int> c = make<std::deque<int> >(10);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c[i] == i);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c.at(i) == i);
+        assert(c.front() == 0);
+        assert(c.back() == 9);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c[i] == i);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c.at(i) == i);
+        assert(c.front() == 0);
+        assert(c.back() == 9);
+    }
+    {
+        const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c[i] == i);
+        for (unsigned i = 0; i < 10; ++i)
+            assert(c.at(i) == i);
+        assert(c.front() == 0);
+        assert(c.back() == 9);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp b/final/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..8f732a0
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.capacity/resize_size.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1, int size)
+{
+    typedef typename C::const_iterator CI;
+    typename C::size_type c1_osize = c1.size();
+    c1.resize(size);
+    assert(c1.size() == size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    CI i = c1.begin();
+    for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+        assert(*i == j);
+    for (int j = c1_osize; j < c1.size(); ++j, ++i)
+        assert(*i == 0);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+    typedef typename C::const_iterator CI;
+    C c1 = make<C>(N, start);
+    test(c1, M);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/final/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp
new file mode 100644
index 0000000..1d1522c
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1, int size, int x)
+{
+    typedef typename C::const_iterator CI;
+    typename C::size_type c1_osize = c1.size();
+    c1.resize(size, x);
+    assert(c1.size() == size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    CI i = c1.begin();
+    for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+        assert(*i == j);
+    for (int j = c1_osize; j < c1.size(); ++j, ++i)
+        assert(*i == x);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+    typedef typename C::const_iterator CI;
+    C c1 = make<C>(N, start);
+    test(c1, M, -10);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp b/final/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..0ac1d5a
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void shrink_to_fit();
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+    C s = c1;
+    c1.shrink_to_fit();
+    assert(c1 == s);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    typedef typename C::const_iterator CI;
+    C c1 = make<C>(N, start);
+    test(c1);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/alloc.pass.cpp b/final/test/containers/sequences/deque/deque.cons/alloc.pass.cpp
new file mode 100644
index 0000000..841bfd9
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/alloc.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(const Allocator& a)
+{
+    std::deque<T, Allocator> d(a);
+    assert(d.size() == 0);
+    assert(d.get_allocator() == a);
+}
+
+int main()
+{
+    test<int>(std::allocator<int>());
+    test<NotConstructible>(test_allocator<NotConstructible>(3));
+#if __cplusplus >= 201103L
+    test<int>(min_allocator<int>());
+    test<NotConstructible>(min_allocator<NotConstructible>{});
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/final/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..c760b43
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::deque<int> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::deque<int, min_allocator<int>> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/final/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
new file mode 100644
index 0000000..6594984
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+//   void assign(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1, const C& c2)
+{
+    std::size_t c1_osize = c1.size();
+    c1.assign(c2.begin(), c2.end());
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    assert(c1 == c2);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    C c1 = make<C>(N, start);
+    C c2 = make<C>(M);
+    test(c1, c2);
+}
+
+template <class C>
+void
+testI(C& c1, const C& c2)
+{
+    typedef typename C::const_iterator CI;
+    typedef input_iterator<CI> ICI;
+    std::size_t c1_osize = c1.size();
+    c1.assign(ICI(c2.begin()), ICI(c2.end()));
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    assert(c1 == c2);
+}
+
+template <class C>
+void
+testNI(int start, int N, int M)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    C c1 = make<C>(N, start);
+    C c2 = make<C>(M);
+    testI(c1, c2);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+    testNI<std::deque<int> >(1500, 2000, 1000);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+    testNI<std::deque<int, min_allocator<int>> >(1500, 2000, 1000);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp b/final/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp
new file mode 100644
index 0000000..fd6dd6e
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1, int size, int v)
+{
+    typedef typename C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    c1.assign(size, v);
+    assert(c1.size() == size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    for (CI i = c1.begin(); i != c1.end(); ++i)
+        assert(*i == v);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    C c1 = make<C>(N, start);
+    test(c1, M, -10);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/copy.pass.cpp b/final/test/containers/sequences/deque/deque.cons/copy.pass.cpp
new file mode 100644
index 0000000..fa0c120
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/copy.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque&);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    C c(x);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int>(ab, an));
+    }
+    {
+        std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+        std::deque<int, test_allocator<int> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+        std::deque<int, other_allocator<int> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == other_allocator<int>(-2));
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int, min_allocator<int>>(ab, an));
+    }
+    {
+        std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+        std::deque<int, min_allocator<int> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp b/final/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..efea494
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+    C c(x, a);
+    assert(c == x);
+    assert(c.get_allocator() == a);
+}
+
+int main()
+{
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int, test_allocator<int> >(ab, an, test_allocator<int>(3)),
+                                                           test_allocator<int>(4));
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)),
+                                                            other_allocator<int>(4));
+    }
+#if __cplusplus >= 201103L
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()),
+                                                          min_allocator<int>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/default.pass.cpp b/final/test/containers/sequences/deque/deque.cons/default.pass.cpp
new file mode 100644
index 0000000..b725dad
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/default.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque()
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+    std::deque<T, Allocator> d;
+    assert(d.size() == 0);
+#if __cplusplus >= 201103L
+    std::deque<T, Allocator> d1 = {};
+    assert(d1.size() == 0);
+#endif
+}
+
+int main()
+{
+    test<int, std::allocator<int> >();
+    test<NotConstructible, stack_allocator<NotConstructible, 1> >();
+#if __cplusplus >= 201103L
+    test<int, min_allocator<int> >();
+    test<NotConstructible, min_allocator<NotConstructible> >();
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp b/final/test/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..3605a1b
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque()
+//        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::deque<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/final/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..0f459b2
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// ~deque() // implied noexcept;
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+    ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::deque<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/final/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..a9e0218
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::deque<int> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::deque<int, min_allocator<int>> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/final/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..36c5af6
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+    assert(d.get_allocator() == test_allocator<int>(3));
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+    assert(d.get_allocator() == min_allocator<int>());
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/final/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
new file mode 100644
index 0000000..faadf2b
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator> deque(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+    typedef typename std::iterator_traits<InputIterator>::value_type T;
+    typedef std::allocator<T> Allocator;
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(f, l);
+    assert(d.size() == std::distance(f, l));
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+        assert(*i == *f);
+}
+
+template <class Allocator, class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+    typedef typename std::iterator_traits<InputIterator>::value_type T;
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(f, l);
+    assert(d.size() == std::distance(f, l));
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+        assert(*i == *f);
+}
+
+int main()
+{
+    int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+    int* an = ab + sizeof(ab)/sizeof(ab[0]);
+    test(input_iterator<const int*>(ab), input_iterator<const int*>(an));
+    test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an));
+    test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an));
+    test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an));
+    test<stack_allocator<int, 4096> >(ab, an);
+#if __cplusplus >= 201103L
+    test<min_allocator<int> >(ab, an);
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/final/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..b8c3e88
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+//   deque(InputIterator f, InputIterator l, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class InputIterator, class Allocator>
+void
+test(InputIterator f, InputIterator l, const Allocator& a)
+{
+    typedef typename std::iterator_traits<InputIterator>::value_type T;
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(f, l, a);
+    assert(d.get_allocator() == a);
+    assert(d.size() == std::distance(f, l));
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+        assert(*i == *f);
+}
+
+int main()
+{
+    int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+    int* an = ab + sizeof(ab)/sizeof(ab[0]);
+    test(input_iterator<const int*>(ab), input_iterator<const int*>(an), test_allocator<int>(3));
+    test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
+    test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
+    test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
+#if __cplusplus >= 201103L
+    test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>());
+    test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>());
+    test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
+    test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/move.pass.cpp b/final/test/containers/sequences/deque/deque.cons/move.pass.cpp
new file mode 100644
index 0000000..a20ad4c
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/move.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(2));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == c1.get_allocator());
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef other_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(2));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == c1.get_allocator());
+    }
+#if __cplusplus >= 201103L
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef min_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A{});
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A{});
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == c1.get_allocator());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/final/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..0ba4a2d
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/move_alloc.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(1));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+        assert(c2 == c3);
+        assert(c3.get_allocator() == A(3));
+        assert(c1.size() != 0);
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(1));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(std::move(c1), A(1));
+        assert(c2 == c3);
+        assert(c3.get_allocator() == A(1));
+        assert(c1.size() == 0);
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef other_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(1));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(1));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+        assert(c2 == c3);
+        assert(c3.get_allocator() == A(3));
+        assert(c1.size() != 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef min_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A{});
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A{});
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(std::move(c1), A());
+        assert(c2 == c3);
+        assert(c3.get_allocator() == A());
+        assert(c1.size() == 0);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/final/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..bb01dc5
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(deque&& c);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(5));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(5));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(A(5));
+        c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == A(5));
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef test_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(5));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(5));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(A(6));
+        c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() != 0);
+        assert(c3.get_allocator() == A(6));
+    }
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef other_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A(5));
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A(5));
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(A(6));
+        c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == A(5));
+    }
+#if __cplusplus >= 201103L
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        typedef min_allocator<MoveOnly> A;
+        std::deque<MoveOnly, A> c1(A{});
+        for (int* p = ab; p < an; ++p)
+            c1.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c2(A{});
+        for (int* p = ab; p < an; ++p)
+            c2.push_back(MoveOnly(*p));
+        std::deque<MoveOnly, A> c3(A{});
+        c3 = std::move(c1);
+        assert(c2 == c3);
+        assert(c1.size() == 0);
+        assert(c3.get_allocator() == A());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp b/final/test/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..c2bb40a
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(deque&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::deque<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/final/test/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..36f7807
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::deque<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp b/final/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp
new file mode 100644
index 0000000..3a6ec83
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/op_equal.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(const deque& c);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    C c;
+    c = x;
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int>(ab, an));
+    }
+    {
+        std::deque<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::deque<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::deque<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::deque<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(5));
+    }
+#if __cplusplus >= 201103L
+    {
+        int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+        int* an = ab + sizeof(ab)/sizeof(ab[0]);
+        test(std::deque<int, min_allocator<int>>(ab, an));
+    }
+    {
+        std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+        std::deque<int, min_allocator<int> > l2(l, min_allocator<int>());
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == min_allocator<int>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/final/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..6468e43
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::deque<int> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::deque<int, min_allocator<int>> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/size.pass.cpp b/final/test/containers/sequences/deque/deque.cons/size.pass.cpp
new file mode 100644
index 0000000..d2e324b
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/size.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(size_type n);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test2(unsigned n)
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    assert(DefaultOnly::count == 0);
+    {
+    C d(n, Allocator());
+    assert(DefaultOnly::count == n);
+    assert(d.size() == n);
+    assert(distance(d.begin(), d.end()) == d.size());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+        assert(*i == T());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+    assert(DefaultOnly::count == 0);
+#endif
+}
+
+template <class T, class Allocator>
+void
+test1(unsigned n)
+{
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    assert(DefaultOnly::count == 0);
+    {
+    C d(n);
+    assert(DefaultOnly::count == n);
+    assert(d.size() == n);
+    assert(distance(d.begin(), d.end()) == d.size());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+        assert(*i == T());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+    assert(DefaultOnly::count == 0);
+}
+
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    {
+    C d(n, alloc);
+    assert(d.size() == n);
+    assert(d.get_allocator() == alloc);
+    }
+#endif
+}
+
+template <class T, class Allocator>
+void
+test(unsigned n)
+{
+    test1<T, Allocator> ( n );
+    test2<T, Allocator> ( n );
+}
+
+int main()
+{
+    test<DefaultOnly, std::allocator<DefaultOnly> >(0);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(10);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1023);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1024);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(1025);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(2047);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(2048);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(2049);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
+    test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
+
+    test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
+
+#if __cplusplus >= 201103L
+    test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    test3<DefaultOnly, std::allocator<DefaultOnly>> (1023);
+    test3<int, std::allocator<int>>(1);
+    test3<int, min_allocator<int>> (3);
+#endif
+
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/size_value.pass.cpp b/final/test/containers/sequences/deque/deque.cons/size_value.pass.cpp
new file mode 100644
index 0000000..859deba
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/size_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x)
+{
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(n, x);
+    assert(d.size() == n);
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<int, std::allocator<int> >(0, 5);
+    test<int, std::allocator<int> >(1, 10);
+    test<int, std::allocator<int> >(10, 11);
+    test<int, std::allocator<int> >(1023, -11);
+    test<int, std::allocator<int> >(1024, 25);
+    test<int, std::allocator<int> >(1025, 0);
+    test<int, std::allocator<int> >(2047, 110);
+    test<int, std::allocator<int> >(2048, -500);
+    test<int, std::allocator<int> >(2049, 654);
+    test<int, std::allocator<int> >(4095, 78);
+    test<int, std::allocator<int> >(4096, 1165);
+    test<int, std::allocator<int> >(4097, 157);
+    test<int, stack_allocator<int, 4096> >(4095, 90);
+#if __cplusplus >= 201103L
+    test<int, min_allocator<int> >(4095, 90);
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp b/final/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp
new file mode 100644
index 0000000..5693be7
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x, const Allocator& a)
+{
+    typedef std::deque<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    C d(n, x, a);
+    assert(d.get_allocator() == a);
+    assert(d.size() == n);
+    assert(distance(d.begin(), d.end()) == d.size());
+    for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    {
+    std::allocator<int> a;
+    test(0, 5, a);
+    test(1, 10, a);
+    test(10, 11, a);
+    test(1023, -11, a);
+    test(1024, 25, a);
+    test(1025, 0, a);
+    test(2047, 110, a);
+    test(2048, -500, a);
+    test(2049, 654, a);
+    test(4095, 78, a);
+    test(4096, 1165, a);
+    test(4097, 157, a);
+    }
+#if __cplusplus >= 201103L
+    {
+    min_allocator<int> a;
+    test(0, 5, a);
+    test(1, 10, a);
+    test(10, 11, a);
+    test(1023, -11, a);
+    test(1024, 25, a);
+    test(1025, 0, a);
+    test(2047, 110, a);
+    test(2048, -500, a);
+    test(2049, 654, a);
+    test(4095, 78, a);
+    test(4096, 1165, a);
+    test(4097, 157, a);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..806f728
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/emplace.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> iterator emplace(const_iterator p, Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(Emplaceable());
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(int P, C& c1)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    assert(*i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1);
+        }
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
new file mode 100644
index 0000000..aa977eb
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(Emplaceable());
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+    typedef typename C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.emplace_back(Emplaceable(1, 2.5));
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.end();
+    assert(*--i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    C c1 = make<C>(N, start);
+    test(c1);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp
new file mode 100644
index 0000000..cf09d6e
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(Emplaceable());
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+    typedef typename C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.emplace_front(Emplaceable(1, 2.5));
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    assert(*i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    C c1 = make<C>(N, start);
+    test(c1);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..bfab2a3
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator p)
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(int P, C& c1)
+{
+    typedef typename C::iterator I;
+    assert(P < c1.size());
+    std::size_t c1_osize = c1.size();
+    I i = c1.erase(c1.cbegin() + P);
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize - 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    int j = 0;
+    for (; j < P; ++j, ++i)
+        assert(*i == j);
+    for (++j; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+    for (int p = 0; p < N; p += pstep)
+    {
+        C c1 = make<C>(N, start);
+        test(p, c1);
+    }
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..b7fa4f6
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator f, const_iterator l)
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int size)
+{
+    typedef typename C::iterator I;
+    assert(P + size <= c1.size());
+    std::size_t c1_osize = c1.size();
+    I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize - size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    int j = 0;
+    for (; j < P; ++j, ++i)
+        assert(*i == j);
+    for (j += size; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+    for (int p = 0; p <= N; p += pstep)
+    {
+        int sstep = std::max((N - p) / std::max(std::min(N - p, 10), 1), 1);
+        for (int s = 0; s <= N - p; s += sstep)
+        {
+            C c1 = make<C>(N, start);
+            test(p, c1, s);
+        }
+    }
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..5f78040
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::deque<int> d(10, 1);
+    std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(i == d.begin() + 2);
+    assert(d[0] == 1);
+    assert(d[1] == 1);
+    assert(d[2] == 3);
+    assert(d[3] == 4);
+    assert(d[4] == 5);
+    assert(d[5] == 6);
+    assert(d[6] == 1);
+    assert(d[7] == 1);
+    assert(d[8] == 1);
+    assert(d[9] == 1);
+    assert(d[10] == 1);
+    assert(d[11] == 1);
+    assert(d[12] == 1);
+    assert(d[13] == 1);
+    }
+    {
+    std::deque<int, min_allocator<int>> d(10, 1);
+    std::deque<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(i == d.begin() + 2);
+    assert(d[0] == 1);
+    assert(d[1] == 1);
+    assert(d[2] == 3);
+    assert(d[3] == 4);
+    assert(d[4] == 5);
+    assert(d[5] == 6);
+    assert(d[6] == 1);
+    assert(d[7] == 1);
+    assert(d[8] == 1);
+    assert(d[9] == 1);
+    assert(d[10] == 1);
+    assert(d[11] == 1);
+    assert(d[12] == 1);
+    assert(d[13] == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 0000000..6ab948e
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,254 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+//   iterator insert (const_iterator p, InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../MoveOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, const C& c2)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    typedef bidirectional_iterator<CI> BCI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + c2.size());
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    for (int j = 0; j < c2.size(); ++j, ++i)
+        assert(*i == j);
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = M-1; i <= M+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            test(i, c1, c2);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            test(i, c1, c2);
+        }
+    }
+}
+
+template <class C>
+void
+testI(int P, C& c1, const C& c2)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    typedef input_iterator<CI> ICI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end()));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + c2.size());
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    for (int j = 0; j < c2.size(); ++j, ++i)
+        assert(*i == j);
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testNI(int start, int N, int M)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = M-1; i <= M+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            testI(i, c1, c2);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            C c2 = make<C>(M);
+            testI(i, c1, c2);
+        }
+    }
+}
+
+template <class C>
+void
+test_move()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    C c;
+    typedef typename C::const_iterator CI;
+    {
+        MoveOnly mo(0);
+        typedef MoveOnly* I;
+        c.insert(c.end(), std::move_iterator<I>(&mo), std::move_iterator<I>(&mo+1));
+    }
+    int j = 0;
+    for (CI i = c.begin(); i != c.end(); ++i, ++j)
+        assert(*i == MoveOnly(j));
+    {
+        MoveOnly mo(1);
+        typedef input_iterator<MoveOnly*> I;
+        c.insert(c.end(), std::move_iterator<I>(I(&mo)), std::move_iterator<I>(I(&mo+1)));
+    }
+    j = 0;
+    for (CI i = c.begin(); i != c.end(); ++i, ++j)
+        assert(*i == MoveOnly(j));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+    testNI<std::deque<int> >(1500, 2000, 1000);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_move<std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > >();
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+    testNI<std::deque<int> >(1500, 2000, 1000);
+    test_move<std::deque<MoveOnly, min_allocator<MoveOnly> > >();
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..0bde7d9
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(MoveOnly(i));
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int x)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, MoveOnly(x));
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == MoveOnly(j));
+    assert(*i == MoveOnly(x));
+    ++i;
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == MoveOnly(j));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, -10);
+        }
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
new file mode 100644
index 0000000..7b77861
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int size, int x)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, size, x);
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + size);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    for (int j = 0; j < size; ++j, ++i)
+        assert(*i == x);
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = M-1; i <= M+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = N - M - 1; i <= N - M + 1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, M, -10);
+        }
+    }
+}
+
+template <class C>
+void
+self_reference_test()
+{
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i < 20; ++i)
+    {
+        for (int j = 0; j < 20; ++j)
+        {
+            C c = make<C>(20);
+            CI it = c.cbegin() + i;
+            CI jt = c.cbegin() + j;
+            c.insert(it, 5, *jt);
+            assert(c.size() == 25);
+            assert(distance(c.begin(), c.end()) == c.size());
+            it = c.cbegin();
+            for (int k = 0; k < i; ++k, ++it)
+                assert(*it == k);
+            for (int k = 0; k < 5; ++k, ++it)
+                assert(*it == j);
+            for (int k = i; k < 20; ++k, ++it)
+                assert(*it == k);
+        }
+    }
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+    self_reference_test<std::deque<int> >();
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            for (int k = 0; k < N; ++k)
+                testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+    self_reference_test<std::deque<int, min_allocator<int>> >();
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
new file mode 100644
index 0000000..97827c1
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
@@ -0,0 +1,139 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int x)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    std::size_t c1_osize = c1.size();
+    CI i = c1.insert(c1.begin() + P, x);
+    assert(i == c1.begin() + P);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    i = c1.begin();
+    for (int j = 0; j < P; ++j, ++i)
+        assert(*i == j);
+    assert(*i == x);
+    ++i;
+    for (int j = P; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i <= 3; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N/2-1; i <= N/2+1; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, -10);
+        }
+    }
+    for (int i = N - 3; i <= N; ++i)
+    {
+        if (0 <= i && i <= N)
+        {
+            C c1 = make<C>(N, start);
+            test(i, c1, -10);
+        }
+    }
+}
+
+template <class C>
+void
+self_reference_test()
+{
+    typedef typename C::const_iterator CI;
+    for (int i = 0; i < 20; ++i)
+    {
+        for (int j = 0; j < 20; ++j)
+        {
+            C c = make<C>(20);
+            CI it = c.cbegin() + i;
+            CI jt = c.cbegin() + j;
+            c.insert(it, *jt);
+            assert(c.size() == 21);
+            assert(distance(c.begin(), c.end()) == c.size());
+            it = c.cbegin();
+            for (int k = 0; k < i; ++k, ++it)
+                assert(*it == k);
+            assert(*it == j);
+            ++it;
+            for (int k = i; k < 20; ++k, ++it)
+                assert(*it == k);
+        }
+    }
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    self_reference_test<std::deque<int> >();
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    self_reference_test<std::deque<int, min_allocator<int>> >();
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp
new file mode 100644
index 0000000..e642f71
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_back()
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+    typedef typename C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.pop_back();
+    assert(c1.size() == c1_osize - 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    for (int j = 0; j < c1.size(); ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    if (N != 0)
+    {
+        C c1 = make<C>(N, start);
+        test(c1);
+    }
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp
new file mode 100644
index 0000000..e27edf5
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_front()
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+    typedef typename C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.pop_front();
+    assert(c1.size() == c1_osize - 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    for (int j = 1; j < c1.size(); ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    if (N != 0)
+    {
+        C c1 = make<C>(N, start);
+        test(c1);
+    }
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp
new file mode 100644
index 0000000..444ab9b
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/push_back.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(const value_type& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void test(int size)
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+    {
+        C c = make<C>(size, rng[j]);
+        typename C::const_iterator it = c.begin();
+        for (int i = 0; i < size; ++i, ++it)
+            assert(*it == i);
+    }
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+        test<std::deque<int> >(rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+        test<std::deque<int, min_allocator<int>> >(rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 0000000..3e62879
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(const value_type& x);
+
+#include <deque>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+    public: CMyClass(int tag);
+    public: CMyClass(const CMyClass& iOther);
+    public: ~CMyClass();
+
+    bool equal(const CMyClass &rhs) const
+        { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+    private:
+        int fMagicValue;
+        int fTag;
+        
+    private: static int kStartedConstructionMagicValue;
+    private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+    fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+    fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+    // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+    if (gCopyConstructorShouldThow) {
+        throw std::exception();
+    }
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+    // Only instances for which the constructor has finished running should be destructed
+    assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+    CMyClass instance(42);
+    std::deque<CMyClass> vec;
+
+    vec.push_back(instance);
+    std::deque<CMyClass> vec2(vec);
+
+    gCopyConstructorShouldThow = true;
+    try {
+        vec.push_back(instance);
+    }
+    catch (...) {
+        assert(vec==vec2);
+    }
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 0000000..d6c4439
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(value_type&& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(MoveOnly(i));
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void test(int size)
+{
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+    {
+        C c = make<C>(size, rng[j]);
+        typename C::const_iterator it = c.begin();
+        for (int i = 0; i < size; ++i, ++it)
+            assert(*it == MoveOnly(i));
+    }
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+        test<std::deque<MoveOnly> >(rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int j = 0; j < N; ++j)
+        test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp
new file mode 100644
index 0000000..700edd3
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/push_front.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1, int x)
+{
+    typedef typename C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.push_front(x);
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    assert(*i == x);
+    ++i;
+    for (int j = 0; j < c1_osize; ++j, ++i)
+        assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    C c1 = make<C>(N, start);
+    test(c1, -10);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+   {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 0000000..6ae06db
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(const value_type& x);
+
+#include <deque>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+    public: CMyClass(int tag);
+    public: CMyClass(const CMyClass& iOther);
+    public: ~CMyClass();
+
+    bool equal(const CMyClass &rhs) const
+        { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+    private:
+        int fMagicValue;
+        int fTag;
+        
+    private: static int kStartedConstructionMagicValue;
+    private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+    fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+    fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+    // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+    if (gCopyConstructorShouldThow) {
+        throw std::exception();
+    }
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+    // Only instances for which the constructor has finished running should be destructed
+    assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+    CMyClass instance(42);
+    std::deque<CMyClass> vec;
+
+    vec.push_front(instance);
+    std::deque<CMyClass> vec2(vec);
+
+    gCopyConstructorShouldThow = true;
+    try {
+        vec.push_front(instance);
+    }
+    catch (...) {
+        assert(vec==vec2);
+    }
+}
diff --git a/final/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/final/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 0000000..1670a44
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(MoveOnly(i));
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void
+test(C& c1, int x)
+{
+    typedef typename C::iterator I;
+    std::size_t c1_osize = c1.size();
+    c1.push_front(MoveOnly(x));
+    assert(c1.size() == c1_osize + 1);
+    assert(distance(c1.begin(), c1.end()) == c1.size());
+    I i = c1.begin();
+    assert(*i == MoveOnly(x));
+    ++i;
+    for (int j = 0; j < c1_osize; ++j, ++i)
+        assert(*i == MoveOnly(j));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+    C c1 = make<C>(N, start);
+    test(c1, -10);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/deque/deque.special/copy.pass.cpp b/final/test/containers/sequences/deque/deque.special/copy.pass.cpp
new file mode 100644
index 0000000..7dfb4bc
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.special/copy.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   copy(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    typedef input_iterator<CI> ICI;
+    C c1 = make<C>(N, start);
+    C c2 = make<C>(N);
+    assert(std::copy(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::copy(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+    assert(c1 == c2);
+    assert(std::copy(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+    assert(c1 == c2);
+    assert(std::copy(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+    assert(c1 == c2);
+    assert(std::copy(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::copy(ICI(c2.cbegin()), ICI(c2.cend()), c1.begin()) == c1.end());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp b/final/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp
new file mode 100644
index 0000000..b484a86
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.special/copy_backward.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   copy_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    C c1 = make<C>(N, start);
+    C c2 = make<C>(N);
+    assert(std::copy_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::copy_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+    assert(c1 == c2);
+    assert(std::copy_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+    assert(c1 == c2);
+    assert(std::copy_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+    assert(c1 == c2);
+    assert(std::copy_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::copy_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.special/move.pass.cpp b/final/test/containers/sequences/deque/deque.special/move.pass.cpp
new file mode 100644
index 0000000..b100ba4
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.special/move.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   move(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    C c1 = make<C>(N, start);
+    C c2 = make<C>(N);
+    assert(std::move(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::move(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+    assert(c1 == c2);
+    assert(std::move(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+    assert(c1 == c2);
+    assert(std::move(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+    assert(c1 == c2);
+    assert(std::move(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+    assert(c1 == c2);
+    assert(std::move(RACI(c2.cbegin()), RACI(c2.cend()), c1.begin()) == c1.end());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.special/move_backward.pass.cpp b/final/test/containers/sequences/deque/deque.special/move_backward.pass.cpp
new file mode 100644
index 0000000..072d7a7
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.special/move_backward.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+//   OutputIterator
+//   move_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+    typedef typename C::iterator I;
+    typedef typename C::const_iterator CI;
+    typedef random_access_iterator<I> RAI;
+    typedef random_access_iterator<CI> RACI;
+    C c1 = make<C>(N, start);
+    C c2 = make<C>(N);
+    assert(std::move_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::move_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+    assert(c1 == c2);
+    assert(std::move_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+    assert(c1 == c2);
+    assert(std::move_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+    assert(c1 == c2);
+    assert(std::move_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+    assert(c1 == c2);
+    assert(std::move_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+    assert(c1 == c2);
+}
+
+int main()
+{
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int> >(rng[i], rng[j]);
+    }
+#if __cplusplus >= 201103L
+    {
+    int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+    const int N = sizeof(rng)/sizeof(rng[0]);
+    for (int i = 0; i < N; ++i)
+        for (int j = 0; j < N; ++j)
+            testN<std::deque<int, min_allocator<int> > >(rng[i], rng[j]);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.special/swap.pass.cpp b/final/test/containers/sequences/deque/deque.special/swap.pass.cpp
new file mode 100644
index 0000000..808144c
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.special/swap.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class T, class A>
+//   void swap(deque<T, A>& x, deque<T, A>& y);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+    const int b = 4096 / sizeof(int);
+    int init = 0;
+    if (start > 0)
+    {
+        init = (start+1) / b + ((start+1) % b != 0);
+        init *= b;
+        --init;
+    }
+    C c(init, 0);
+    for (int i = 0; i < init-start; ++i)
+        c.pop_back();
+    for (int i = 0; i < size; ++i)
+        c.push_back(i);
+    for (int i = 0; i < start; ++i)
+        c.pop_front();
+    return c;
+};
+
+template <class C>
+void testN(int start, int N, int M)
+{
+    C c1 = make<C>(N, start);
+    C c2 = make<C>(M);
+    C c1_save = c1;
+    C c2_save = c2;
+    swap(c1, c2);
+    assert(c1 == c2_save);
+    assert(c2 == c1_save);
+}
+
+int main()
+{
+    {
+        int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+        const int N = sizeof(rng)/sizeof(rng[0]);
+        for (int i = 0; i < N; ++i)
+            for (int j = 0; j < N; ++j)
+                for (int k = 0; k < N; ++k)
+                    testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef test_allocator<int> A;
+        std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(1));
+        assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef other_allocator<int> A;
+        std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(2));
+        assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(1));
+    }
+#if __cplusplus >= 201103L
+    {
+        int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+        const int N = sizeof(rng)/sizeof(rng[0]);
+        for (int i = 0; i < N; ++i)
+            for (int j = 0; j < N; ++j)
+                for (int k = 0; k < N; ++k)
+                    testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef min_allocator<int> A;
+        std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+        std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+        swap(c1, c2);
+        assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A());
+        assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/final/test/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..d55d719
--- /dev/null
+++ b/final/test/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void swap(deque& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    
+    some_alloc() {}
+    some_alloc(const some_alloc&);
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::deque<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/iterators.pass.cpp b/final/test/containers/sequences/deque/iterators.pass.cpp
new file mode 100644
index 0000000..8ec491f
--- /dev/null
+++ b/final/test/containers/sequences/deque/iterators.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class deque;
+
+// iterator, const_iterator
+
+#include <deque>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::deque<int> C;
+    C c;
+    C::iterator i;
+    i = c.begin();
+    C::const_iterator j;
+    j = c.cbegin();
+    assert(i == j);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::deque<int, min_allocator<int>> C;
+    C c;
+    C::iterator i;
+    i = c.begin();
+    C::const_iterator j;
+    j = c.cbegin();
+    assert(i == j);
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        std::deque<int>::iterator ii1{}, ii2{};
+        std::deque<int>::iterator ii4 = ii1;
+        std::deque<int>::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+        assert (!(ii1 <  cii ));
+        assert (!(cii <  ii1 ));
+        assert ( (ii1 <= cii ));
+        assert ( (cii <= ii1 ));
+        assert (!(ii1 >  cii ));
+        assert (!(cii >  ii1 ));
+        assert ( (ii1 >= cii ));
+        assert ( (cii >= ii1 ));
+        assert (cii - ii1 == 0);
+        assert (ii1 - cii == 0);
+        
+//         std::deque<int> c;
+//         assert ( ii1 != c.cbegin());
+//         assert ( cii != c.begin());
+//         assert ( cii != c.cend());
+//         assert ( ii1 != c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/types.pass.cpp b/final/test/containers/sequences/deque/types.pass.cpp
new file mode 100644
index 0000000..da9470d
--- /dev/null
+++ b/final/test/containers/sequences/deque/types.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class deque
+// {
+// public:
+//     typedef T                                        value_type;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef implementation-defined                   iterator;
+//     typedef implementation-defined                   const_iterator;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef std::reverse_iterator<iterator>          reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+// };
+
+#include <deque>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+    typedef std::deque<T, Allocator> C;
+
+    static_assert((std::is_same<typename C::value_type, T>::value), "");
+    static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+    static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+    static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+    static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+    static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+    static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename C::reverse_iterator,
+        std::reverse_iterator<typename C::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename C::const_reverse_iterator,
+        std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+    test<int, test_allocator<int> >();
+    test<int*, std::allocator<int*> >();
+    test<Copyable, test_allocator<Copyable> >();
+    static_assert((std::is_same<std::deque<char>::allocator_type,
+                                std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+    {
+        typedef std::deque<short, min_allocator<short>> C;
+        static_assert((std::is_same<C::value_type, short>::value), "");
+        static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+        static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+//  min_allocator doesn't have a size_type, so one gets synthesized
+        static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/deque/version.pass.cpp b/final/test/containers/sequences/deque/version.pass.cpp
new file mode 100644
index 0000000..22e663d
--- /dev/null
+++ b/final/test/containers/sequences/deque/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+#include <deque>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp
new file mode 100644
index 0000000..d274bc0
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.cons
+
+// template <class Alloc>
+//   dynarray(size_type c, const Alloc& alloc);
+// template <class Alloc>
+//   dynarray(size_type c, const T& v, const Alloc& alloc);
+// template <class Alloc>
+//   dynarray(const dynarray& d, const Alloc& alloc);
+// template <class Alloc>
+//   dynarray(initializer_list<T>, const Alloc& alloc);
+
+// ~dynarray();
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+#include "test_allocator.h"
+
+using std::experimental::dynarray;
+
+template <class T, class Allocator>
+void check_allocator ( const dynarray<T> &dyn, const Allocator &alloc ) {
+    for ( int i = 0; i < dyn.size (); ++i )
+        assert ( dyn[i].get_allocator() == alloc );
+}
+
+template <class T, class Allocator>
+void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( vals, alloc );
+    assert ( d1.size () == vals.size() );
+    assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
+    check_allocator ( d1, alloc );
+    }
+
+
+template <class T, class Allocator>
+void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( 4, alloc1 );
+    assert ( d1.size () == 4 );
+    assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
+    check_allocator ( d1, alloc1 );
+
+    dynA d2 ( 7, val, alloc1 );
+    assert ( d2.size () == 7 );
+    assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
+    check_allocator ( d2, alloc1 );
+
+    dynA d3 ( d2, alloc2 );
+    assert ( d3.size () == 7 );
+    assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));   
+    check_allocator ( d3, alloc2 );
+    }
+
+int main()
+{
+//  This test is waiting on the resolution of LWG issue #2235 
+//     typedef test_allocator<char> Alloc;
+//     typedef std::basic_string<char, std::char_traits<char>, Alloc> nstr;
+// 
+//     test ( nstr("fourteen"), Alloc(3), Alloc(4) );
+//     test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6));
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.cons/default.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
new file mode 100644
index 0000000..0effac2
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.cons
+
+// explicit dynarray(size_type c);
+// dynarray(size_type c, const T& v);
+// dynarray(initializer_list<T>);
+// dynarray(const dynarray& d);
+
+// ~dynarray();
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( const std::initializer_list<T> &vals ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( vals );
+    assert ( d1.size () == vals.size() );
+    assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
+    }
+
+
+template <class T>
+void test ( const T &val ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( 4 );
+    assert ( d1.size () == 4 );
+    assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
+
+    dynA d2 ( 7, val );
+    assert ( d2.size () == 7 );
+    assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
+
+    dynA d3 ( d2 );
+    assert ( d3.size () == 7 );
+    assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));   
+    }
+
+void test_bad_length () {
+    try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
+    catch ( std::bad_array_length & ) { return ; }
+    assert ( false );
+    }
+
+void test_bad_alloc () {
+    try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) - 1 ); }
+    catch ( std::bad_alloc & ) { return ; }
+    assert ( false );
+    }
+
+int main()
+{
+//  test<int> ( 14 );       // ints don't get default initialized
+    test<long> ( 0 );
+    test<double> ( 14.0 );
+    test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+    test<std::string> ( "fourteen" );
+    
+    test ( { 1, 1, 2, 3, 5, 8 } );
+    test ( { 1., 1., 2., 3., 5., 8. } );
+    test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), 
+                std::string("5"), std::string("8")} );
+    
+//  Make sure we don't pick up the Allocator version here
+    dynarray<long> d1 ( 20, 3 );
+    assert ( d1.size() == 20 );
+    assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));
+
+    test_bad_length ();
+    test_bad_alloc ();
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.data/default.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.data/default.pass.cpp
new file mode 100644
index 0000000..b669f25
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.data/default.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// T* data() noexcept;
+// const T* data() const noexcept;
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+    const T *data = dyn.data ();
+    assert ( data != NULL );
+    assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+    }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+    T *data = dyn.data ();
+    assert ( data != NULL );
+    assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+    }
+
+    
+
+template <class T>
+void test ( const T &val ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( 4 );
+    dyn_test ( d1 );
+    dyn_test_const ( d1 );
+    
+    dynA d2 ( 7, val );
+    dyn_test ( d2 );
+    dyn_test_const ( d2 );
+    }
+
+int main()
+{
+    test<int> ( 14 );
+    test<double> ( 14.0 );
+    test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+    test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
new file mode 100644
index 0000000..c57887d
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// void fill(const T& v);
+// const T* data() const noexcept;
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( const T &val ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( 4 );
+    d1.fill ( val );
+    assert ( std::all_of ( d1.begin (), d1.end (), 
+                    [&val]( const T &item ){ return item == val; } ));  
+    }
+
+int main()
+{
+    test<int> ( 14 );
+    test<double> ( 14.0 );
+    test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+    test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.overview/at.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
new file mode 100644
index 0000000..4d77cf7
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// const_reference at(size_type n) const;
+//       reference at(size_type n);
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_at_fail ( dynarray<T> &dyn, size_t sz ) {
+    try { dyn.at (sz); }
+    catch (const std::out_of_range &) { return; }
+    assert ( false );
+    }
+
+template <class T>
+void dyn_at_fail_const ( const dynarray<T> &dyn, size_t sz ) {
+    try { dyn.at (sz); }
+    catch (const std::out_of_range &) { return; }
+    assert ( false );
+    }
+
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+    const T *data = dyn.data ();
+    auto it = vals.begin ();
+    for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+        assert ( data + i == &dyn.at(i));
+        assert ( *it == dyn.at(i));
+        }
+
+    dyn_at_fail_const ( dyn, dyn.size ());
+    dyn_at_fail_const ( dyn, 2*dyn.size ());
+    dyn_at_fail_const ( dyn, size_t (-1));
+    }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+    T *data = dyn.data ();
+    auto it = vals.begin ();
+    for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+        assert ( data + i == &dyn.at(i));
+        assert ( *it == dyn.at(i));
+        }
+
+    dyn_at_fail ( dyn, dyn.size ());
+    dyn_at_fail ( dyn, 2*dyn.size ());
+    dyn_at_fail ( dyn, size_t (-1));
+    }
+
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( vals );
+    dyn_test ( d1, vals );
+    dyn_test_const ( d1, vals );
+    }
+
+int main()
+{
+    test ( { 1, 1, 2, 3, 5, 8 } );
+    test ( { 1., 1., 2., 3., 5., 8. } );
+    test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), 
+                std::string("5"), std::string("8")} );
+
+    test<int> ( {} );
+    test<std::complex<double>> ( {} );
+    test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp
new file mode 100644
index 0000000..695e1aa
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+
+// iterator       begin()        noexcept;
+// const_iterator begin()  const noexcept;
+// const_iterator cbegin() const noexcept;
+// iterator       end()          noexcept;
+// const_iterator end()    const noexcept;
+// const_iterator cend()   const noexcept;
+// 
+// reverse_iterator       rbegin()        noexcept;
+// const_reverse_iterator rbegin()  const noexcept;
+// const_reverse_iterator crbegin() const noexcept;
+// reverse_iterator       rend()          noexcept;
+// const_reverse_iterator rend()    const noexcept;
+// const_reverse_iterator crend()   const noexcept;
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+    const T *data = dyn.data ();
+    assert ( data == &*dyn.begin ());
+    assert ( data == &*dyn.cbegin ());
+
+    assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
+    assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
+
+    assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
+    assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
+    assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
+    assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
+
+    assert (   dyn.begin ()  ==   dyn.cbegin ());
+    assert ( &*dyn.begin ()  == &*dyn.cbegin ());
+    assert (   dyn.rbegin () ==   dyn.crbegin ());
+    assert ( &*dyn.rbegin () == &*dyn.crbegin ());
+    assert (   dyn.end ()    ==   dyn.cend ());
+    assert (   dyn.rend ()   ==   dyn.crend ());
+    }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+    T *data = dyn.data ();
+    assert ( data == &*dyn.begin ());
+    assert ( data == &*dyn.cbegin ());
+
+    assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
+    assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
+
+    assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
+    assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
+    assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
+    assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
+
+    assert (   dyn.begin ()  ==   dyn.cbegin ());
+    assert ( &*dyn.begin ()  == &*dyn.cbegin ());
+    assert (   dyn.rbegin () ==   dyn.crbegin ());
+    assert ( &*dyn.rbegin () == &*dyn.crbegin ());
+    assert (   dyn.end ()    ==   dyn.cend ());
+    assert (   dyn.rend ()   ==   dyn.crend ());
+    }
+
+
+template <class T>
+void test ( const T &val ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( 4 );
+    dyn_test ( d1 );
+    dyn_test_const ( d1 );
+    
+    dynA d2 ( 7, val );
+    dyn_test ( d2 );
+    dyn_test_const ( d2 );
+    }
+
+int main()
+{
+    test<int> ( 14 );
+    test<double> ( 14.0 );
+    test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+    test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
new file mode 100644
index 0000000..6d28eef
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// size_type size()     const noexcept;
+// size_type max_size() const noexcept;
+// bool      empty()    const noexcept;  
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
+    assert ( dyn.size ()     == sz );
+    assert ( dyn.max_size () == sz );
+    assert ( dyn.empty () == ( sz == 0 ));
+    }
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( vals );
+    dyn_test ( d1, vals.size ());
+    }
+
+int main()
+{
+    test ( { 1, 1, 2, 3, 5, 8 } );
+    test ( { 1., 1., 2., 3., 5., 8. } );
+    test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), 
+                std::string("5"), std::string("8")} );
+
+    test<int> ( {} );
+    test<std::complex<double>> ( {} );
+    test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp
new file mode 100644
index 0000000..e82aa64
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// reference       front();
+// const_reference front() const;
+// reference       back();
+// const_reference back()  const;
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+    const T *data = dyn.data ();
+    assert ( *data == dyn.front ());
+    assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+    }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+    T *data = dyn.data ();
+    assert ( *data == dyn.front ());
+    assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+    }
+
+
+template <class T>
+void test ( const T &val ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( 4 );
+    dyn_test ( d1 );
+    dyn_test_const ( d1 );
+    
+    dynA d2 ( 7, val );
+    dyn_test ( d2 );
+    dyn_test_const ( d2 );
+    }
+
+int main()
+{
+    test<int> ( 14 );
+    test<double> ( 14.0 );
+    test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+    test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp
new file mode 100644
index 0000000..7317a20
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// const_reference at(size_type n) const;
+//       reference at(size_type n);
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+    const T *data = dyn.data ();
+    auto it = vals.begin ();
+    for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+        assert ( data + i == &dyn[i]);
+        assert ( *it == dyn[i]);
+        }
+    }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+    T *data = dyn.data ();
+    auto it = vals.begin ();
+    for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+        assert ( data + i == &dyn[i]);
+        assert ( *it == dyn[i]);
+        }
+    }
+
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( vals );
+    dyn_test ( d1, vals );
+    dyn_test_const ( d1, vals );
+    }
+
+int main()
+{
+    test ( { 1, 1, 2, 3, 5, 8 } );
+    test ( { 1., 1., 2., 3., 5., 8. } );
+    test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), 
+                std::string("5"), std::string("8")} );
+
+    test<int> ( {} );
+    test<std::complex<double>> ( {} );
+    test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.traits/default.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.traits/default.pass.cpp
new file mode 100644
index 0000000..9b8240d
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.traits/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// template <class Type, class Alloc>
+//   struct uses_allocator<dynarray<Type>, Alloc> : true_type { };
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include "test_allocator.h"
+
+using std::experimental::dynarray;
+
+int main()
+{
+    static_assert ( std::uses_allocator<dynarray<int>, test_allocator<int>>::value, "" );
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/dynarray.zero/default.pass.cpp b/final/test/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
new file mode 100644
index 0000000..93f3b18
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.zero
+
+// dynarray shall provide support for the special case of construction with a size of zero.
+// In the case that the size is zero, begin() == end() == unique value. 
+// The return value of data() is unspecified. 
+// The effect of calling front() or back() for a zero-sized dynarray is undefined.
+
+
+  
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( ) {
+    typedef dynarray<T> dynA;
+    
+    dynA d1 ( 0 );
+    assert ( d1.size() == 0 );
+    assert ( d1.begin() == d1.end ());
+    }
+
+int main()
+{
+    test<int> ();
+    test<double> ();
+    test<std::complex<double>> ();
+    test<std::string> ();
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/containers/sequences/dynarray/nothing_to_do.pass.cpp b/final/test/containers/sequences/dynarray/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/sequences/dynarray/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp
new file mode 100644
index 0000000..2ec9b87
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// reference       front();
+// const_reference front() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        assert(c.front() == 0);
+        c.front() = 10;
+        assert(c.front() == 10);
+        assert(*c.begin() == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const C c(std::begin(t), std::end(t));
+        assert(c.front() == 0);
+        assert(*c.begin() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        assert(c.front() == 0);
+        c.front() = 10;
+        assert(c.front() == 10);
+        assert(*c.begin() == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const C c(std::begin(t), std::end(t));
+        assert(c.front() == 0);
+        assert(*c.begin() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
new file mode 100644
index 0000000..cd4d1ed
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+
+int main()
+{
+    {
+        typedef test_allocator<NotConstructible> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        C c = A(12);
+        assert(c.get_allocator() == A(12));
+        assert(c.empty());
+    }
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
new file mode 100644
index 0000000..7aba906
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<NotConstructible> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        C c(A(12));
+        assert(c.get_allocator() == A(12));
+        assert(c.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<NotConstructible> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        C c(A{});
+        assert(c.get_allocator() == A());
+        assert(c.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..0b9263d
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(11));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(11));
+    }
+
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(10));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A(10));
+        C c1(std::begin(t1), std::end(t1), A(11));
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A(10));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef min_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c0(std::begin(t0), std::end(t0), A());
+        C c1(std::begin(t1), std::end(t1), A());
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A());
+    }
+    {
+        typedef int T;
+        typedef min_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t0), std::end(t0), A());
+        C c1(std::begin(t1), std::end(t1), A());
+        c1 = c0;
+        assert(c1 == c0);
+        assert(c1.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp
new file mode 100644
index 0000000..e0382a1
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c.assign({10, 11, 12, 13});
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c.assign({10, 11, 12, 13});
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..a3d270f
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(11));
+        assert(!c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(11));
+        assert(!c0.empty());
+    }
+
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+        C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A(10));
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef MoveOnly T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        T t1[] = {10, 11, 12, 13};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A());
+        C c1(I(std::begin(t1)), I(std::end(t1)), A());
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c1.get_allocator() == A());
+        assert(c0.empty());
+    }
+    {
+        typedef MoveOnly T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        T t0[] = {10, 11, 12, 13};
+        T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t0)), I(std::end(t0)), A());
+        C c1(I(std::begin(t1)), I(std::end(t1)), A());
+        c1 = std::move(c0);
+        int n = 0;
+        for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+        assert(c1.get_allocator() == A());
+        assert(c0.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp
new file mode 100644
index 0000000..551908f
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c = {10, 11, 12, 13};
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c = {10, 11, 12, 13};
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
new file mode 100644
index 0000000..fb3765d
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     void assign(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        typedef input_iterator<const T*> I;
+        c.assign(I(std::begin(t0)), I(std::end(t0)));
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        typedef input_iterator<const T*> I;
+        c.assign(I(std::begin(t0)), I(std::end(t0)));
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        typedef input_iterator<const T*> I;
+        c.assign(I(std::begin(t0)), I(std::end(t0)));
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t0[] = {10, 11, 12, 13};
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        typedef input_iterator<const T*> I;
+        c.assign(I(std::begin(t0)), I(std::end(t0)));
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10+n);
+        assert(n == 4);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp
new file mode 100644
index 0000000..ea53e1c
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c.assign(10, 1);
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 1);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c.assign(4, 10);
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10);
+        assert(n == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {10, 11, 12, 13};
+        C c(std::begin(t1), std::end(t1));
+        c.assign(10, 1);
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 1);
+        assert(n == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t1), std::end(t1));
+        c.assign(4, 10);
+        int n = 0;
+        for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+            assert(*i == 10);
+        assert(n == 4);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
new file mode 100644
index 0000000..2fc53bc
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c = c0;
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(10));
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c = c0;
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(-2));
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef min_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A());
+        C c = c0;
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..bcc24e1
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c(c0, A(9));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(9));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A(10));
+        C c(c0, A(9));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A(9));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef min_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c0(std::begin(t), std::end(t), A());
+        C c(c0, A());
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c == c0);
+        assert(c.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp
new file mode 100644
index 0000000..38e95fa
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list();
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        assert(c.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        assert(c.empty());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c = {};
+        assert(c.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..6b0233d
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list()
+//        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::forward_list<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp
new file mode 100644
index 0000000..5ff00e6
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// class forward_list
+
+// forward_list();
+
+#include <forward_list>
+
+struct X
+{
+    std::forward_list<X> q;
+};
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..1f7b05e
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// ~forward_list() // implied noexcept;
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+    ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::forward_list<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
new file mode 100644
index 0000000..5b31c4d
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
new file mode 100644
index 0000000..750486b
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c.get_allocator() == A(14));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A());
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == 10);
+        assert(c.get_allocator() == A());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
new file mode 100644
index 0000000..164801a
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c = std::move(c0);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A(10));
+    }
+    {
+        typedef MoveOnly T;
+        typedef other_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c = std::move(c0);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A(10));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef MoveOnly T;
+        typedef min_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A());
+        C c = std::move(c0);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..ba0cb5d
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c(std::move(c0), A(10));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A(10));
+    }
+    {
+        typedef MoveOnly T;
+        typedef test_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A(10));
+        C c(std::move(c0), A(9));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(!c0.empty());
+        assert(c.get_allocator() == A(9));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef MoveOnly T;
+        typedef min_allocator<int> A;
+        typedef std::forward_list<T, A> C;
+        T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        typedef std::move_iterator<T*> I;
+        C c0(I(std::begin(t)), I(std::end(t)), A());
+        C c(std::move(c0), A());
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c0.empty());
+        assert(c.get_allocator() == A());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..cc5b9d5
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(forward_list&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::forward_list<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..3666c7d
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::forward_list<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
new file mode 100644
index 0000000..7639524
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     forward_list(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef input_iterator<const T*> I;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(I(std::begin(t)), I(std::end(t)));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef input_iterator<const T*> I;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(I(std::begin(t)), I(std::end(t)));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
new file mode 100644
index 0000000..d72c358
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     forward_list(InputIterator first, InputIterator last,
+//                  const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        typedef input_iterator<const T*> I;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(I(std::begin(t)), I(std::end(t)), A(13));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c.get_allocator() == A(13));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        typedef input_iterator<const T*> I;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(I(std::begin(t)), I(std::end(t)), A());
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == n);
+        assert(n == std::end(t) - std::begin(t));
+        assert(c.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp
new file mode 100644
index 0000000..2d963a1
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+
+int main()
+{
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T> C;
+        unsigned N = 10;
+        C c = N;
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(*i == T());
+#else
+            ;
+#endif
+        assert(n == N);
+    }
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
new file mode 100644
index 0000000..e02dcb4
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+// explicit forward_list(size_type n, const Alloc& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void check_allocator(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::forward_list<T, Allocator> C;
+    C d(n, alloc);
+    assert(d.get_allocator() == alloc);
+    assert(std::distance(d.begin(), d.end()) == n);
+#endif
+}
+
+int main()
+{
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T> C;
+        unsigned N = 10;
+        C c(N);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(*i == T());
+#else
+            ;
+#endif
+        assert(n == N);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        unsigned N = 10;
+        C c(N);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(*i == T());
+#else
+            ;
+#endif
+        assert(n == N);
+        check_allocator<T, min_allocator<T>> ( 0 );
+        check_allocator<T, min_allocator<T>> ( 3 );
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp
new file mode 100644
index 0000000..05ab98b
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        T v(6);
+        unsigned N = 10;
+        C c(N, v);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == v);
+        assert(n == N);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        T v(6);
+        unsigned N = 10;
+        C c(N, v);
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == v);
+        assert(n == N);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
new file mode 100644
index 0000000..1d631ab
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<int> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        T v(6);
+        unsigned N = 10;
+        C c(N, v, A(12));
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == v);
+        assert(n == N);
+        assert(c.get_allocator() == A(12));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<int> A;
+        typedef A::value_type T;
+        typedef std::forward_list<T, A> C;
+        T v(6);
+        unsigned N = 10;
+        C c(N, v, A());
+        unsigned n = 0;
+        for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+            assert(*i == v);
+        assert(n == N);
+        assert(c.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp
new file mode 100644
index 0000000..083cec2
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator       before_begin();
+// const_iterator before_begin() const;
+// const_iterator cbefore_begin() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        C::iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 1);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const C c;
+        C::const_iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 1);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const C c;
+        C::const_iterator i = c.cbefore_begin();
+        assert(std::distance(i, c.end()) == 1);
+        assert(c.cbefore_begin() == c.before_begin());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 11);
+        assert(std::next(c.before_begin()) == c.begin());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const C c(std::begin(t), std::end(t));
+        C::const_iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 11);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        C::iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 1);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const C c;
+        C::const_iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 1);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const C c;
+        C::const_iterator i = c.cbefore_begin();
+        assert(std::distance(i, c.end()) == 1);
+        assert(c.cbefore_begin() == c.before_begin());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 11);
+        assert(std::next(c.before_begin()) == c.begin());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const C c(std::begin(t), std::end(t));
+        C::const_iterator i = c.before_begin();
+        assert(std::distance(i, c.end()) == 11);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
new file mode 100644
index 0000000..6f3ac54
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        std::forward_list<int>::iterator ii1{}, ii2{};
+        std::forward_list<int>::iterator ii4 = ii1;
+        std::forward_list<int>::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+ 
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+
+//         std::forward_list<int> c;
+//         assert ( ii1 != c.cbegin());
+//         assert ( cii != c.begin());
+//         assert ( cii != c.cend());
+//         assert ( ii1 != c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..2739b49
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void clear();
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef NotConstructible T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef NotConstructible T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+
+        c.clear();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp
new file mode 100644
index 0000000..e305c5b
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args>
+//     iterator emplace_after(const_iterator p, Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef Emplaceable T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.emplace_after(c.cbefore_begin());
+        assert(i == c.begin());
+        assert(c.front() == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.emplace_after(c.cbegin(), 1, 2.5);
+        assert(i == next(c.begin()));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin()) == Emplaceable(1, 2.5));
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.emplace_after(next(c.cbegin()), 2, 3.5);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin()) == Emplaceable(1, 2.5));
+        assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.emplace_after(c.cbegin(), 3, 4.5);
+        assert(i == next(c.begin()));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
+        assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
+        assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef Emplaceable T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.emplace_after(c.cbefore_begin());
+        assert(i == c.begin());
+        assert(c.front() == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.emplace_after(c.cbegin(), 1, 2.5);
+        assert(i == next(c.begin()));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin()) == Emplaceable(1, 2.5));
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.emplace_after(next(c.cbegin()), 2, 3.5);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin()) == Emplaceable(1, 2.5));
+        assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.emplace_after(c.cbegin(), 3, 4.5);
+        assert(i == next(c.begin()));
+        assert(c.front() == Emplaceable());
+        assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
+        assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
+        assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
new file mode 100644
index 0000000..c02337e
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef Emplaceable T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.emplace_front();
+        assert(c.front() == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 1);
+        c.emplace_front(1, 2.5);
+        assert(c.front() == Emplaceable(1, 2.5));
+        assert(*next(c.begin()) == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef Emplaceable T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        c.emplace_front();
+        assert(c.front() == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 1);
+        c.emplace_front(1, 2.5);
+        assert(c.front() == Emplaceable(1, 2.5));
+        assert(*next(c.begin()) == Emplaceable());
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
new file mode 100644
index 0000000..bd9b153
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator erase_after(const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+
+        C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
+        assert(i == next(c.cbefore_begin(), 4));
+        assert(distance(c.begin(), c.end()) == 10);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+        assert(*next(c.begin(), 4) == 4);
+        assert(*next(c.begin(), 5) == 5);
+        assert(*next(c.begin(), 6) == 6);
+        assert(*next(c.begin(), 7) == 7);
+        assert(*next(c.begin(), 8) == 8);
+        assert(*next(c.begin(), 9) == 9);
+
+        i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 8);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+        assert(*next(c.begin(), 5) == 7);
+        assert(*next(c.begin(), 6) == 8);
+        assert(*next(c.begin(), 7) == 9);
+
+        i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 8);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+        assert(*next(c.begin(), 5) == 7);
+        assert(*next(c.begin(), 6) == 8);
+        assert(*next(c.begin(), 7) == 9);
+
+        i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
+        assert(i == c.begin());
+        assert(distance(c.begin(), c.end()) == 4);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 4);
+        assert(*next(c.begin(), 2) == 5);
+        assert(*next(c.begin(), 3) == 6);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
+        assert(i == c.begin());
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+
+        C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
+        assert(i == next(c.cbefore_begin(), 4));
+        assert(distance(c.begin(), c.end()) == 10);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+        assert(*next(c.begin(), 4) == 4);
+        assert(*next(c.begin(), 5) == 5);
+        assert(*next(c.begin(), 6) == 6);
+        assert(*next(c.begin(), 7) == 7);
+        assert(*next(c.begin(), 8) == 8);
+        assert(*next(c.begin(), 9) == 9);
+
+        i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 8);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+        assert(*next(c.begin(), 5) == 7);
+        assert(*next(c.begin(), 6) == 8);
+        assert(*next(c.begin(), 7) == 9);
+
+        i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 8);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+        assert(*next(c.begin(), 5) == 7);
+        assert(*next(c.begin(), 6) == 8);
+        assert(*next(c.begin(), 7) == 9);
+
+        i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 5);
+        assert(*next(c.begin(), 4) == 6);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
+        assert(i == c.begin());
+        assert(distance(c.begin(), c.end()) == 4);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 4);
+        assert(*next(c.begin(), 2) == 5);
+        assert(*next(c.begin(), 3) == 6);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
+        assert(i == c.begin());
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
new file mode 100644
index 0000000..4f51498
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator erase_after(const_iterator p);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 4);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0));
+        assert(i == c.begin());
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 2);
+        assert(*next(c.begin(), 2) == 3);
+
+        i = c.erase_after(next(c.cbefore_begin(), 1));
+        assert(i == next(c.begin()));
+        assert(distance(c.begin(), c.end()) == 2);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 3);
+
+        i = c.erase_after(next(c.cbefore_begin(), 1));
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(*next(c.begin(), 0) == 1);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0));
+        assert(i == c.begin());
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 4);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0));
+        assert(i == c.begin());
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 2);
+        assert(*next(c.begin(), 2) == 3);
+
+        i = c.erase_after(next(c.cbefore_begin(), 1));
+        assert(i == next(c.begin()));
+        assert(distance(c.begin(), c.end()) == 2);
+        assert(*next(c.begin(), 0) == 1);
+        assert(*next(c.begin(), 1) == 3);
+
+        i = c.erase_after(next(c.cbefore_begin(), 1));
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(*next(c.begin(), 0) == 1);
+
+        i = c.erase_after(next(c.cbefore_begin(), 0));
+        assert(i == c.begin());
+        assert(i == c.end());
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp
new file mode 100644
index 0000000..ec650b6
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0);
+        assert(i == c.begin());
+        assert(c.front() == 0);
+        assert(c.front() == 0);
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.insert_after(c.cbegin(), 1);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.insert_after(next(c.cbegin()), 2);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.insert_after(c.cbegin(), 3);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 1);
+        assert(*next(c.begin(), 3) == 2);
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0);
+        assert(i == c.begin());
+        assert(c.front() == 0);
+        assert(c.front() == 0);
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.insert_after(c.cbegin(), 1);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.insert_after(next(c.cbegin()), 2);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.insert_after(c.cbegin(), 3);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 1);
+        assert(*next(c.begin(), 3) == 2);
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp
new file mode 100644
index 0000000..4d30181
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), {});
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
+        assert(i == next(c.before_begin(), 3));
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        i = c.insert_after(c.begin(), {3, 4});
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 1);
+        assert(*next(c.begin(), 4) == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), {});
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
+        assert(i == next(c.before_begin(), 3));
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        i = c.insert_after(c.begin(), {3, 4});
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 1);
+        assert(*next(c.begin(), 4) == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
new file mode 100644
index 0000000..103475f
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+//     iterator insert_after(const_iterator p,
+//                           InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        typedef input_iterator<const T*> J;
+        C c;
+        const T t[] = {0, 1, 2, 3, 4};
+        I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
+        assert(i == next(c.before_begin(), 3));
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        i = c.insert_after(c.begin(), J(t+3), J(t+5));
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 1);
+        assert(*next(c.begin(), 4) == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef C::iterator I;
+        typedef input_iterator<const T*> J;
+        C c;
+        const T t[] = {0, 1, 2, 3, 4};
+        I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
+        assert(i == next(c.before_begin(), 3));
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        i = c.insert_after(c.begin(), J(t+3), J(t+5));
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 4);
+        assert(*next(c.begin(), 3) == 1);
+        assert(*next(c.begin(), 4) == 2);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp
new file mode 100644
index 0000000..4f0be52
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0);
+        assert(i == c.begin());
+        assert(c.front() == 0);
+        assert(c.front() == 0);
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.insert_after(c.cbegin(), 1);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.insert_after(next(c.cbegin()), 2);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.insert_after(c.cbegin(), 3);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 1);
+        assert(*next(c.begin(), 3) == 2);
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0);
+        assert(i == c.begin());
+        assert(c.front() == 0);
+        assert(c.front() == 0);
+        assert(distance(c.begin(), c.end()) == 1);
+
+        i = c.insert_after(c.cbegin(), 1);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+
+        i = c.insert_after(next(c.cbegin()), 2);
+        assert(i == next(c.begin(), 2));
+        assert(c.front() == 0);
+        assert(*next(c.begin()) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(distance(c.begin(), c.end()) == 3);
+
+        i = c.insert_after(c.cbegin(), 3);
+        assert(i == next(c.begin()));
+        assert(c.front() == 0);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 1);
+        assert(*next(c.begin(), 3) == 2);
+        assert(distance(c.begin(), c.end()) == 4);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp
new file mode 100644
index 0000000..b2da2ec
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0, 0);
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), 3, 3);
+        assert(i == next(c.before_begin(), 3));
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 3);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 3);
+
+        i = c.insert_after(c.begin(), 2, 2);
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 3);
+        assert(*next(c.begin(), 1) == 2);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+        assert(*next(c.begin(), 4) == 3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef C::iterator I;
+        C c;
+        I i = c.insert_after(c.cbefore_begin(), 0, 0);
+        assert(i == c.before_begin());
+        assert(distance(c.begin(), c.end()) == 0);
+
+        i = c.insert_after(c.cbefore_begin(), 3, 3);
+        assert(i == next(c.before_begin(), 3));
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 3);
+        assert(*next(c.begin(), 1) == 3);
+        assert(*next(c.begin(), 2) == 3);
+
+        i = c.insert_after(c.begin(), 2, 2);
+        assert(i == next(c.begin(), 2));
+        assert(distance(c.begin(), c.end()) == 5);
+        assert(*next(c.begin(), 0) == 3);
+        assert(*next(c.begin(), 1) == 2);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 3);
+        assert(*next(c.begin(), 4) == 3);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp
new file mode 100644
index 0000000..276f2c9
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void pop_front();
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        c.push_front(3);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(c.front() == 1);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        c.push_front(3);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(c.front() == 1);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        c.push_front(1);
+        c.push_front(3);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(c.front() == 1);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        c.push_front(1);
+        c.push_front(3);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 1);
+        assert(c.front() == 1);
+        c.pop_front();
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp
new file mode 100644
index 0000000..85958af
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        assert(c.front() == 1);
+        assert(distance(c.begin(), c.end()) == 1);
+        c.push_front(3);
+        assert(c.front() == 3);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        c.push_front(1);
+        assert(c.front() == 1);
+        assert(distance(c.begin(), c.end()) == 1);
+        c.push_front(3);
+        assert(c.front() == 3);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 0000000..43c62eb
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(const value_type& x);
+
+#include <forward_list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+    public: CMyClass();
+    public: CMyClass(const CMyClass& iOther);
+    public: ~CMyClass();
+
+    private: int fMagicValue;
+
+    private: static int kStartedConstructionMagicValue;
+    private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+    fMagicValue(kStartedConstructionMagicValue)
+{
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+    fMagicValue(kStartedConstructionMagicValue)
+{
+    // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+    if (gCopyConstructorShouldThow) {
+        throw std::exception();
+    }
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+    // Only instances for which the constructor has finished running should be destructed
+    assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+    CMyClass instance;
+    std::forward_list<CMyClass> vec;
+
+    vec.push_front(instance);
+
+    gCopyConstructorShouldThow = true;
+    try {
+        vec.push_front(instance);
+    }
+    catch (...) {
+    }
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
new file mode 100644
index 0000000..53181ec
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.push_front(1);
+        assert(c.front() == 1);
+        assert(distance(c.begin(), c.end()) == 1);
+        c.push_front(3);
+        assert(c.front() == 3);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef MoveOnly T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        c.push_front(1);
+        assert(c.front() == 1);
+        assert(distance(c.begin(), c.end()) == 1);
+        c.push_front(3);
+        assert(c.front() == 3);
+        assert(*next(c.begin()) == 1);
+        assert(distance(c.begin(), c.end()) == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
new file mode 100644
index 0000000..ef7ef82
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T> C;
+        C c;
+        c.resize(0);
+        assert(distance(c.begin(), c.end()) == 0);
+        c.resize(10);
+        assert(distance(c.begin(), c.end()) == 10);
+        c.resize(20);
+        assert(distance(c.begin(), c.end()) == 20);
+        c.resize(5);
+        assert(distance(c.begin(), c.end()) == 5);
+        c.resize(0);
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.resize(3);
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        c.resize(6);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 0);
+        assert(*next(c.begin(), 4) == 0);
+        assert(*next(c.begin(), 5) == 0);
+
+        c.resize(6);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 0);
+        assert(*next(c.begin(), 4) == 0);
+        assert(*next(c.begin(), 5) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef DefaultOnly T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        c.resize(0);
+        assert(distance(c.begin(), c.end()) == 0);
+        c.resize(10);
+        assert(distance(c.begin(), c.end()) == 10);
+        c.resize(20);
+        assert(distance(c.begin(), c.end()) == 20);
+        c.resize(5);
+        assert(distance(c.begin(), c.end()) == 5);
+        c.resize(0);
+        assert(distance(c.begin(), c.end()) == 0);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.resize(3);
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        c.resize(6);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 0);
+        assert(*next(c.begin(), 4) == 0);
+        assert(*next(c.begin(), 5) == 0);
+
+        c.resize(6);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 0);
+        assert(*next(c.begin(), 4) == 0);
+        assert(*next(c.begin(), 5) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
new file mode 100644
index 0000000..d4bd6b4
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.resize(3, 10);
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        c.resize(6, 10);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 10);
+        assert(*next(c.begin(), 4) == 10);
+        assert(*next(c.begin(), 5) == 10);
+
+        c.resize(6, 12);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 10);
+        assert(*next(c.begin(), 4) == 10);
+        assert(*next(c.begin(), 5) == 10);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4};
+        C c(std::begin(t), std::end(t));
+
+        c.resize(3, 10);
+        assert(distance(c.begin(), c.end()) == 3);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+
+        c.resize(6, 10);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 10);
+        assert(*next(c.begin(), 4) == 10);
+        assert(*next(c.begin(), 5) == 10);
+
+        c.resize(6, 12);
+        assert(distance(c.begin(), c.end()) == 6);
+        assert(*next(c.begin(), 0) == 0);
+        assert(*next(c.begin(), 1) == 1);
+        assert(*next(c.begin(), 2) == 2);
+        assert(*next(c.begin(), 3) == 10);
+        assert(*next(c.begin(), 4) == 10);
+        assert(*next(c.begin(), 5) == 10);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp
new file mode 100644
index 0000000..3b6f853
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void merge(forward_list&& x);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {3, 5, 6, 7, 12, 13};
+        const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
+        const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.merge(c2);
+        C c3(std::begin(t3), std::end(t3));
+        assert(c1 == c3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {3, 5, 6, 7, 12, 13};
+        const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
+        const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.merge(c2);
+        C c3(std::begin(t3), std::end(t3));
+        assert(c1 == c3);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
new file mode 100644
index 0000000..7e873bd
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void merge(forward_list&& x, Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {13, 12, 7, 6, 5, 3};
+        const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
+        const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.merge(c2, std::greater<T>());
+        C c3(std::begin(t3), std::end(t3));
+        assert(c1 == c3);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {13, 12, 7, 6, 5, 3};
+        const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
+        const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.merge(c2, std::greater<T>());
+        C c3(std::begin(t3), std::end(t3));
+        assert(c1 == c3);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
new file mode 100644
index 0000000..a15e786
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void remove(const value_type& v);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2;
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 0, 0, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2;
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c1;
+        C c2;
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove(0);
+        assert(c1 == c2);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
new file mode 100644
index 0000000..4c4e80c
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Predicate> void remove_if(Predicate pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int i)
+{
+    return i < 3;
+}
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2;
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 0, 0, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2;
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c1;
+        C c2;
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 5, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.remove_if(g);
+        assert(c1 == c2);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp
new file mode 100644
index 0000000..9bf0d03
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void reverse();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+    C c;
+    for (int i = 0; i < N; ++i)
+        c.push_front(i);
+    c.reverse();
+    assert(distance(c.begin(), c.end()) == N);
+    typename C::const_iterator j = c.begin();
+    for (int i = 0; i < N; ++i, ++j)
+        assert(*j == i);
+}
+
+int main()
+{
+    for (int i = 0; i < 10; ++i)
+        test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+    for (int i = 0; i < 10; ++i)
+        test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp
new file mode 100644
index 0000000..06e40c5
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void sort();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+    typedef typename C::value_type T;
+    typedef std::vector<T> V;
+    V v;
+    for (int i = 0; i < N; ++i)
+        v.push_back(i);
+    std::random_shuffle(v.begin(), v.end());
+    C c(v.begin(), v.end());
+    c.sort();
+    assert(distance(c.begin(), c.end()) == N);
+    typename C::const_iterator j = c.begin();
+    for (int i = 0; i < N; ++i, ++j)
+        assert(*j == i);
+}
+
+int main()
+{
+    for (int i = 0; i < 40; ++i)
+        test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+    for (int i = 0; i < 40; ++i)
+        test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
new file mode 100644
index 0000000..8b6ca39
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void sort(Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+    typedef typename C::value_type T;
+    typedef std::vector<T> V;
+    V v;
+    for (int i = 0; i < N; ++i)
+        v.push_back(i);
+    std::random_shuffle(v.begin(), v.end());
+    C c(v.begin(), v.end());
+    c.sort(std::greater<T>());
+    assert(distance(c.begin(), c.end()) == N);
+    typename C::const_iterator j = c.begin();
+    for (int i = 0; i < N; ++i, ++j)
+        assert(*j == N-1-i);
+}
+
+int main()
+{
+    for (int i = 0; i < 40; ++i)
+        test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+    for (int i = 0; i < 40; ++i)
+        test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
new file mode 100644
index 0000000..51da651
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int l)
+{
+    typename C::const_iterator i = c.begin();
+    int n1 = 0;
+    for (; n1 < p; ++n1, ++i)
+        assert(*i == t1[n1]);
+    for (int n2 = 0; n2 < l; ++n2, ++i)
+        assert(*i == t2[n2]);
+    for (; n1 < size_t1; ++n1, ++i)
+        assert(*i == t1[n1]);
+    assert(distance(c.begin(), c.end()) == size_t1 + l);
+}
+
+int main()
+{
+    {
+    // splicing different containers
+    typedef std::forward_list<T> C;
+    for (int l = 0; l <= size_t2; ++l)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+            C c2(t2, t2+l);
+
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
+            testd(c1, p, l);
+        }
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    // splicing different containers
+    typedef std::forward_list<T, min_allocator<T>> C;
+    for (int l = 0; l <= size_t2; ++l)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+            C c2(t2, t2+l);
+
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
+            testd(c1, p, l);
+        }
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
new file mode 100644
index 0000000..296ffcd
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x, const_iterator i);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int f)
+{
+    typename C::const_iterator i = c.begin();
+    int n1 = 0;
+    for (; n1 < p; ++n1, ++i)
+        assert(*i == t1[n1]);
+    for (int n2 = f; n2 < f+1; ++n2, ++i)
+        assert(*i == t2[n2]);
+    for (; n1 < size_t1; ++n1, ++i)
+        assert(*i == t1[n1]);
+    assert(distance(c.begin(), c.end()) == size_t1 + 1);
+}
+
+template <class C>
+void
+tests(const C& c, int p, int f)
+{
+    typename C::const_iterator i = c.begin();
+    int n = 0;
+    int d = 1;
+    if (p == f || p == f+1)
+    {
+        for (n = 0; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else if (p < f)
+    {
+        for (n = 0; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < f+1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f+1; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else // p > f+1
+    {
+        for (n = 0; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f+1; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < f+1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+    {
+    // splicing different containers
+    typedef std::forward_list<T> C;
+    for (int f = 0; f <= size_t2-1; ++f)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+            C c2(std::begin(t2), std::end(t2));
+
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+                  next(c2.cbefore_begin(), f));
+            testd(c1, p, f);
+        }
+    }
+
+    // splicing within same container
+    for (int f = 0; f <= size_t1-1; ++f)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                  next(c1.cbefore_begin(), f));
+            tests(c1, p, f);
+        }
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    // splicing different containers
+    typedef std::forward_list<T, min_allocator<T>> C;
+    for (int f = 0; f <= size_t2-1; ++f)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+            C c2(std::begin(t2), std::end(t2));
+
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+                  next(c2.cbefore_begin(), f));
+            testd(c1, p, f);
+        }
+    }
+
+    // splicing within same container
+    for (int f = 0; f <= size_t1-1; ++f)
+    {
+        for (int p = 0; p <= size_t1; ++p)
+        {
+            C c1(std::begin(t1), std::end(t1));
+
+            c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                  next(c1.cbefore_begin(), f));
+            tests(c1, p, f);
+        }
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
new file mode 100644
index 0000000..90a1599
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
@@ -0,0 +1,169 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x,
+//                   const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int f, int l)
+{
+    typename C::const_iterator i = c.begin();
+    int n1 = 0;
+    for (; n1 < p; ++n1, ++i)
+        assert(*i == t1[n1]);
+    for (int n2 = f; n2 < l-1; ++n2, ++i)
+        assert(*i == t2[n2]);
+    for (; n1 < size_t1; ++n1, ++i)
+        assert(*i == t1[n1]);
+    assert(distance(c.begin(), c.end()) == size_t1 + (l > f+1 ? l-1-f : 0));
+}
+
+template <class C>
+void
+tests(const C& c, int p, int f, int l)
+{
+    typename C::const_iterator i = c.begin();
+    int n = 0;
+    int d = l > f+1 ? l-1-f : 0;
+    if (d == 0 || p == f)
+    {
+        for (n = 0; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else if (p < f)
+    {
+        for (n = 0; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < l-1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = l-1; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    else // p > f
+    {
+        for (n = 0; n < f; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = l-1; n < p; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = f; n < l-1; ++n, ++i)
+            assert(*i == t1[n]);
+        for (n = p; n < size_t1; ++n, ++i)
+            assert(*i == t1[n]);
+    }
+    assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+    {
+    // splicing different containers
+    typedef std::forward_list<T> C;
+    for (int f = 0; f <= size_t2+1; ++f)
+    {
+        for (int l = f; l <= size_t2+1; ++l)
+        {
+            for (int p = 0; p <= size_t1; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+                C c2(std::begin(t2), std::end(t2));
+
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+                      next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
+                testd(c1, p, f, l);
+            }
+        }
+    }
+
+    // splicing within same container
+    for (int f = 0; f <= size_t1+1; ++f)
+    {
+        for (int l = f; l <= size_t1; ++l)
+        {
+            for (int p = 0; p <= f; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                      next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+                tests(c1, p, f, l);
+            }
+            for (int p = l; p <= size_t1; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                      next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+                tests(c1, p, f, l);
+            }
+        }
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    // splicing different containers
+    typedef std::forward_list<T, min_allocator<T>> C;
+    for (int f = 0; f <= size_t2+1; ++f)
+    {
+        for (int l = f; l <= size_t2+1; ++l)
+        {
+            for (int p = 0; p <= size_t1; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+                C c2(std::begin(t2), std::end(t2));
+
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+                      next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
+                testd(c1, p, f, l);
+            }
+        }
+    }
+
+    // splicing within same container
+    for (int f = 0; f <= size_t1+1; ++f)
+    {
+        for (int l = f; l <= size_t1; ++l)
+        {
+            for (int p = 0; p <= f; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                      next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+                tests(c1, p, f, l);
+            }
+            for (int p = l; p <= size_t1; ++p)
+            {
+                C c1(std::begin(t1), std::end(t1));
+
+                c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+                      next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+                tests(c1, p, f, l);
+            }
+        }
+    }
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
new file mode 100644
index 0000000..25db6e6
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void unique();
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {0, 5, 0, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        const T t2[] = {0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {0, 5, 0, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 0, 0, 0};
+        const T t2[] = {0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c1;
+        C c2;
+        c1.unique();
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique();
+        assert(c1 == c2);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp
new file mode 100644
index 0000000..b7dce20
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int x, int y)
+{
+    return x == y;
+}
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {0, 5, 0, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {0, 0, 0, 0};
+        const T t2[] = {0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c1;
+        C c2;
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+        const T t2[] = {0, 5, 0, 5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {0, 0, 0, 0};
+        const T t2[] = {0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5};
+        const T t2[] = {5};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c1;
+        C c2;
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        const T t1[] = {5, 5, 5, 0};
+        const T t2[] = {5, 0};
+        C c1(std::begin(t1), std::end(t1));
+        C c2(std::begin(t2), std::end(t2));
+        c1.unique(g);
+        assert(c1 == c2);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp
new file mode 100644
index 0000000..ca673b5
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+//     bool operator==(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+//     bool operator!=(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N, int M)
+{
+    typedef typename C::value_type T;
+    C c1;
+    for (int i = 0; i < N; ++i)
+        c1.push_front(i);
+    C c2;
+    for (int i = 0; i < M; ++i)
+        c2.push_front(i);
+    if (N == M)
+        assert(c1 == c2);
+    else
+        assert(c1 != c2);
+    c2 = c1;
+    assert(c1 == c2);
+    if (N > 0)
+    {
+        c2.front() = N+1;
+        assert(c1 != c2);
+    }
+}
+
+int main()
+{
+    for (int i = 0; i < 10; ++i)
+        for (int j = 0; j < 10; ++j)
+            test<std::forward_list<int> >(i, j);
+#if __cplusplus >= 201103L
+    for (int i = 0; i < 10; ++i)
+        for (int j = 0; j < 10; ++j)
+            test<std::forward_list<int, min_allocator<int>> >(i, j);
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
new file mode 100644
index 0000000..2b2be7b
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
@@ -0,0 +1,259 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void swap(forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A());
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A());
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A());
+    }
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A());
+        C c2(A{});
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A());
+    }
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A{});
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A());
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A());
+    }
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A{});
+        C c2(A{});
+        c1.swap(c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
new file mode 100644
index 0000000..d6ba5a4
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
@@ -0,0 +1,260 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+//     void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+    {
+        typedef int T;
+        typedef test_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(1));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(2));
+    }
+
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+    {
+        typedef int T;
+        typedef other_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A(1));
+        C c2(A(2));
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A(2));
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A(1));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A());
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A());
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A());
+    }
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        const T t1[] = {0, 1, 2, 3, 4, 5};
+        C c1(std::begin(t1), std::end(t1), A());
+        C c2(A{});
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 6);
+        assert(*next(c2.begin(), 0) == 0);
+        assert(*next(c2.begin(), 1) == 1);
+        assert(*next(c2.begin(), 2) == 2);
+        assert(*next(c2.begin(), 3) == 3);
+        assert(*next(c2.begin(), 4) == 4);
+        assert(*next(c2.begin(), 5) == 5);
+        assert(c2.get_allocator() == A());
+    }
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A{});
+        const T t2[] = {10, 11, 12};
+        C c2(std::begin(t2), std::end(t2), A());
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 3);
+        assert(*next(c1.begin(), 0) == 10);
+        assert(*next(c1.begin(), 1) == 11);
+        assert(*next(c1.begin(), 2) == 12);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A());
+    }
+    {
+        typedef int T;
+        typedef min_allocator<T> A;
+        typedef std::forward_list<T, A> C;
+        C c1(A{});
+        C c2(A{});
+        swap(c1, c2);
+
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c1.get_allocator() == A());
+
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(c2.get_allocator() == A());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
new file mode 100644
index 0000000..42e245d
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+//     bool operator< (const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+//     bool operator> (const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+//     bool operator>=(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+//     bool operator<=(const forward_list<T, Allocator>& x,
+//                     const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N, int M)
+{
+    typedef typename C::value_type T;
+    C c1;
+    for (int i = 0; i < N; ++i)
+        c1.push_front(i);
+    C c2;
+    for (int i = 0; i < M; ++i)
+        c2.push_front(i);
+    if (N < M)
+        assert(c1 < c2);
+    if (N <= M)
+        assert(c1 <= c2);
+    if (N >= M)
+        assert(c1 >= c2);
+    if (N > M)
+        assert(c1 > c2);
+}
+
+int main()
+{
+    for (int i = 0; i < 10; ++i)
+        for (int j = 0; j < 10; ++j)
+            test<std::forward_list<int> >(i, j);
+#if __cplusplus >= 201103L
+    for (int i = 0; i < 10; ++i)
+        for (int j = 0; j < 10; ++j)
+            test<std::forward_list<int, min_allocator<int>> >(i, j);
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/final/test/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..cde97d5
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void swap(forward_list& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    
+    some_alloc() {}
+    some_alloc(const some_alloc&);
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::forward_list<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/max_size.pass.cpp b/final/test/containers/sequences/forwardlist/max_size.pass.cpp
new file mode 100644
index 0000000..be7ebaf
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// size_type max_size() const;
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::forward_list<T> C;
+        C c;
+        assert(c.max_size() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::forward_list<T, min_allocator<T>> C;
+        C c;
+        assert(c.max_size() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/types.pass.cpp b/final/test/containers/sequences/forwardlist/types.pass.cpp
new file mode 100644
index 0000000..c955487
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator = allocator<T>>
+// class forward_list
+// {
+// public:
+//   typedef T         value_type;
+//   typedef Allocator allocator_type;
+//
+//   typedef value_type&                                                reference;
+//   typedef const value_type&                                          const_reference;
+//   typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//   typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//   typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//   typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+//   ...
+// };
+
+#include <forward_list>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::forward_list<char> C;
+    static_assert((std::is_same<C::value_type, char>::value), "");
+    static_assert((std::is_same<C::allocator_type, std::allocator<char> >::value), "");
+    static_assert((std::is_same<C::reference, char&>::value), "");
+    static_assert((std::is_same<C::const_reference, const char&>::value), "");
+    static_assert((std::is_same<C::pointer, char*>::value), "");
+    static_assert((std::is_same<C::const_pointer, const char*>::value), "");
+    static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::forward_list<char, min_allocator<char>> C;
+    static_assert((std::is_same<C::value_type, char>::value), "");
+    static_assert((std::is_same<C::allocator_type, min_allocator<char> >::value), "");
+    static_assert((std::is_same<C::reference, char&>::value), "");
+    static_assert((std::is_same<C::const_reference, const char&>::value), "");
+    static_assert((std::is_same<C::pointer, min_pointer<char>>::value), "");
+    static_assert((std::is_same<C::const_pointer, min_pointer<const char>>::value), "");
+//  min_allocator doesn't have a size_type, so one gets synthesized
+    static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+    static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/forwardlist/version.pass.cpp b/final/test/containers/sequences/forwardlist/version.pass.cpp
new file mode 100644
index 0000000..918c8dd
--- /dev/null
+++ b/final/test/containers/sequences/forwardlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+#include <forward_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/list/db_back.pass.cpp b/final/test/containers/sequences/list/db_back.pass.cpp
new file mode 100644
index 0000000..b16c0e9
--- /dev/null
+++ b/final/test/containers/sequences/list/db_back.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::list<T> C;
+    C c(1);
+    assert(c.back() == 0);
+    c.clear();
+    assert(c.back() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::list<T, min_allocator<T>> C;
+    C c(1);
+    assert(c.back() == 0);
+    c.clear();
+    assert(c.back() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/db_cback.pass.cpp b/final/test/containers/sequences/list/db_cback.pass.cpp
new file mode 100644
index 0000000..ba3977e
--- /dev/null
+++ b/final/test/containers/sequences/list/db_cback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::list<T> C;
+    const C c;
+    assert(c.back() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::list<T, min_allocator<T>> C;
+    const C c;
+    assert(c.back() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/db_cfront.pass.cpp b/final/test/containers/sequences/list/db_cfront.pass.cpp
new file mode 100644
index 0000000..d42290c
--- /dev/null
+++ b/final/test/containers/sequences/list/db_cfront.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::list<T> C;
+    const C c;
+    assert(c.front() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::list<T, min_allocator<T>> C;
+    const C c;
+    assert(c.front() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/db_front.pass.cpp b/final/test/containers/sequences/list/db_front.pass.cpp
new file mode 100644
index 0000000..037b160
--- /dev/null
+++ b/final/test/containers/sequences/list/db_front.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::list<T> C;
+    C c(1);
+    assert(c.front() == 0);
+    c.clear();
+    assert(c.front() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::list<T, min_allocator<T>> C;
+    C c(1);
+    assert(c.front() == 0);
+    c.clear();
+    assert(c.front() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/db_iterators_6.pass.cpp b/final/test/containers/sequences/list/db_iterators_6.pass.cpp
new file mode 100644
index 0000000..a5b8020
--- /dev/null
+++ b/final/test/containers/sequences/list/db_iterators_6.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::list<T> C;
+    C c(1);
+    C::iterator i = c.end();
+    --i;
+    assert(i == c.begin());
+    --i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::list<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.end();
+    --i;
+    assert(i == c.begin());
+    --i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/db_iterators_7.pass.cpp b/final/test/containers/sequences/list/db_iterators_7.pass.cpp
new file mode 100644
index 0000000..76a491b
--- /dev/null
+++ b/final/test/containers/sequences/list/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::list<T> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::list<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/db_iterators_8.pass.cpp b/final/test/containers/sequences/list/db_iterators_8.pass.cpp
new file mode 100644
index 0000000..1d1ee23
--- /dev/null
+++ b/final/test/containers/sequences/list/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::list<T> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::list<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/db_iterators_9.pass.cpp b/final/test/containers/sequences/list/db_iterators_9.pass.cpp
new file mode 100644
index 0000000..d02fcd6
--- /dev/null
+++ b/final/test/containers/sequences/list/db_iterators_9.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Operations on "NULL" iterators
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0)
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+struct S { int val; };
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    unsigned lib_asserts;
+
+    typedef S T;
+    typedef std::list<T> C;
+    C::iterator i{};
+    C::const_iterator ci{};
+    
+    lib_asserts = 0;
+    try { ++i; }  catch (int) { ++lib_asserts; }
+    try { i++; }  catch (int) { ++lib_asserts; }
+    try { ++ci; } catch (int) { ++lib_asserts; }
+    try { ci++; } catch (int) { ++lib_asserts; }
+    assert(lib_asserts == 4);
+
+    lib_asserts = 0;
+    try { --i; }  catch (int) { ++lib_asserts; }
+    try { i--; }  catch (int) { ++lib_asserts; }
+    try { --ci; } catch (int) { ++lib_asserts; }
+    try { ci--; } catch (int) { ++lib_asserts; }
+    assert(lib_asserts == 4);
+
+    lib_asserts = 0;
+    try { *i; }             catch (int) { ++lib_asserts; }
+    try { *ci; }            catch (int) { ++lib_asserts; }
+    try { (void)  i->val; } catch (int) { ++lib_asserts; }
+    try { (void) ci->val; } catch (int) { ++lib_asserts; }
+    assert(lib_asserts == 4);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/iterators.pass.cpp b/final/test/containers/sequences/list/iterators.pass.cpp
new file mode 100644
index 0000000..a33ee3e
--- /dev/null
+++ b/final/test/containers/sequences/list/iterators.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+struct A
+{
+    int first;
+    int second;
+};
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::list<T, min_allocator<T>> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::list<T, min_allocator<T>> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::list<T, min_allocator<T>> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::list<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::list<T, min_allocator<T>> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+    {
+        typedef A T;
+        typedef std::list<T, min_allocator<T>> C;
+        C c = {A{1, 2}};
+        C::iterator i = c.begin();
+        i->first = 3;
+        C::const_iterator j = i;
+        assert(j->first == 3);
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    {
+        std::list<int> c;
+        std::list<int>::iterator ii1{}, ii2{};
+        std::list<int>::iterator ii4 = ii1;
+        std::list<int>::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+
+        assert ( ii1 != c.cbegin());
+        assert ( cii != c.begin());
+    }
+#endif
+
+}
diff --git a/final/test/containers/sequences/list/list.capacity/resize_size.pass.cpp b/final/test/containers/sequences/list/list.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..14629b1
--- /dev/null
+++ b/final/test/containers/sequences/list/list.capacity/resize_size.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l(5, 2);
+        l.resize(2);
+        assert(l.size() == 2);
+        assert(std::distance(l.begin(), l.end()) == 2);
+        assert(l == std::list<int>(2, 2));
+    }
+    {
+        std::list<int> l(5, 2);
+        l.resize(10);
+        assert(l.size() == 10);
+        assert(std::distance(l.begin(), l.end()) == 10);
+        assert(l.front() == 2);
+        assert(l.back() == 0);
+    }
+#ifdef __LIBCPP_MOVE
+    {
+        std::list<DefaultOnly> l(10);
+        l.resize(5);
+        assert(l.size() == 5);
+        assert(std::distance(l.begin(), l.end()) == 5);
+    }
+    {
+        std::list<DefaultOnly> l(10);
+        l.resize(20);
+        assert(l.size() == 20);
+        assert(std::distance(l.begin(), l.end()) == 20);
+    }
+#endif  // __LIBCPP_MOVE
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l(5, 2);
+        l.resize(2);
+        assert(l.size() == 2);
+        assert(std::distance(l.begin(), l.end()) == 2);
+        assert((l == std::list<int, min_allocator<int>>(2, 2)));
+    }
+    {
+        std::list<int, min_allocator<int>> l(5, 2);
+        l.resize(10);
+        assert(l.size() == 10);
+        assert(std::distance(l.begin(), l.end()) == 10);
+        assert(l.front() == 2);
+        assert(l.back() == 0);
+    }
+#ifdef __LIBCPP_MOVE
+    {
+        std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+        l.resize(5);
+        assert(l.size() == 5);
+        assert(std::distance(l.begin(), l.end()) == 5);
+    }
+    {
+        std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+        l.resize(20);
+        assert(l.size() == 20);
+        assert(std::distance(l.begin(), l.end()) == 20);
+    }
+#endif  // __LIBCPP_MOVE
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.capacity/resize_size_value.pass.cpp b/final/test/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
new file mode 100644
index 0000000..2738ffb
--- /dev/null
+++ b/final/test/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<double> l(5, 2);
+        l.resize(2, 3.5);
+        assert(l.size() == 2);
+        assert(std::distance(l.begin(), l.end()) == 2);
+        assert(l == std::list<double>(2, 2));
+    }
+    {
+        std::list<double> l(5, 2);
+        l.resize(10, 3.5);
+        assert(l.size() == 10);
+        assert(std::distance(l.begin(), l.end()) == 10);
+        assert(l.front() == 2);
+        assert(l.back() == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<double, min_allocator<double>> l(5, 2);
+        l.resize(2, 3.5);
+        assert(l.size() == 2);
+        assert(std::distance(l.begin(), l.end()) == 2);
+        assert((l == std::list<double, min_allocator<double>>(2, 2)));
+    }
+    {
+        std::list<double, min_allocator<double>> l(5, 2);
+        l.resize(10, 3.5);
+        assert(l.size() == 10);
+        assert(std::distance(l.begin(), l.end()) == 10);
+        assert(l.front() == 2);
+        assert(l.back() == 3.5);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/assign_copy.pass.cpp b/final/test/containers/sequences/list/list.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..b851eb9
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(const list& c);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(5));
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+        std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == min_allocator<int>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/final/test/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..24bd140
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::list<int> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<int, min_allocator<int>> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    std::list<int, min_allocator<int>>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/list/list.cons/assign_move.pass.cpp b/final/test/containers/sequences/list/list.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..99f0a98
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/assign_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+    }
+    {
+        std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+        std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/list/list.cons/copy.pass.cpp b/final/test/containers/sequences/list/list.cons/copy.pass.cpp
new file mode 100644
index 0000000..530690a
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l(3, 2);
+        std::list<int> l2 = l;
+        assert(l2 == l);
+    }
+    {
+        std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::list<int, test_allocator<int> > l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == l.get_allocator());
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::list<int, other_allocator<int> > l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(-2));
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l(3, 2);
+        std::list<int, min_allocator<int>> l2 = l;
+        assert(l2 == l);
+    }
+    {
+        std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+        std::list<int, min_allocator<int> > l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == l.get_allocator());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/copy_alloc.pass.cpp b/final/test/containers/sequences/list/list.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..99fe9f1
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/copy_alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(3));
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+        std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+        assert(l2 == l);
+        assert(l2.get_allocator() == min_allocator<int>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/default.pass.cpp b/final/test/containers/sequences/list/list.cons/default.pass.cpp
new file mode 100644
index 0000000..c05bd74
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/default.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<DefaultOnly> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int> l((std::allocator<int>()));
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<DefaultOnly, min_allocator<DefaultOnly>> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int, min_allocator<int>> l((min_allocator<int>()));
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int> l = {};
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/default_noexcept.pass.cpp b/final/test/containers/sequences/list/list.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..f821fb4
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list()
+//        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::list<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/final/test/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
new file mode 100644
index 0000000..9d9946b
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int> l((std::allocator<int>()));
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int, stack_allocator<int, 4> > l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l;
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+    {
+        std::list<int, min_allocator<int>> l((min_allocator<int>()));
+        assert(l.size() == 0);
+        assert(std::distance(l.begin(), l.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/final/test/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..13c7e5b
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// ~list() // implied noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+    ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::list<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/initializer_list.pass.cpp b/final/test/containers/sequences/list/list.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..3307017
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::list<int> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<int, min_allocator<int>> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    std::list<int, min_allocator<int>>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/final/test/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..4a85e37
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+    assert(d.get_allocator() == test_allocator<int>(3));
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+    assert(d.get_allocator() == min_allocator<int>());
+    assert(d.size() == 4);
+    std::list<int, min_allocator<int>>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/list/list.cons/input_iterator.pass.cpp b/final/test/containers/sequences/list/list.cons/input_iterator.pass.cpp
new file mode 100644
index 0000000..09eae8a
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/input_iterator.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class InputIterator>
+//   list(InputIterator first, InputIterator last, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int> l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int> l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+                         std::allocator<int>());
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int, stack_allocator<int, sizeof(a)/sizeof(a[0])> > l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+#if __cplusplus >= 201103L
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+    {
+        int a[] = {0, 1, 2, 3};
+        std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+                         input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+                         min_allocator<int>());
+        assert(l.size() == sizeof(a)/sizeof(a[0]));
+        assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+        int j = 0;
+        for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+            assert(*i == j);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/move.pass.cpp b/final/test/containers/sequences/list/list.cons/move.pass.cpp
new file mode 100644
index 0000000..44782b9
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+        std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> l1 = {1, 2, 3};
+        std::list<int>::iterator i = l1.begin();
+        std::list<int> l2 = std::move(l1);
+        assert(*l2.erase(i) == 2);
+        assert(l2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/list/list.cons/move_alloc.pass.cpp b/final/test/containers/sequences/list/list.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..4730755
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/move_alloc.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+    }
+    {
+        std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+    }
+    {
+        std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+        std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::list<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == min_allocator<MoveOnly>());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/final/test/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..d502e1c
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::list<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/final/test/containers/sequences/list/list.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..2c10443
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::list<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/final/test/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..7b7b8a3
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::list<int> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    std::list<int>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<int, min_allocator<int>> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    std::list<int, min_allocator<int>>::iterator i = d.begin();
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/list/list.cons/size_type.pass.cpp b/final/test/containers/sequences/list/list.cons/size_type.pass.cpp
new file mode 100644
index 0000000..75b93a3
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/size_type.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(size_type n);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::list<T, Allocator> C;
+    typedef typename C::const_iterator const_iterator;
+    {
+    C d(n, alloc);
+    assert(d.size() == n);
+    assert(std::distance(d.begin(), d.end()) == n);
+    assert(d.get_allocator() == alloc);
+    }
+#endif
+}
+
+
+int main()
+{
+    {
+        std::list<int> l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+    }
+    {
+        std::list<int, stack_allocator<int, 3> > l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::list<int, min_allocator<int> > C;
+        C l(3, min_allocator<int> ());
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        C::const_iterator i = l.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+        test3<int, min_allocator<int>> (3);
+    }
+#endif
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::list<DefaultOnly> l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+        ++i;
+        assert(*i == 0);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/final/test/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
new file mode 100644
index 0000000..12da86d
--- /dev/null
+++ b/final/test/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(size_type n, const T& value, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::list<int> l(3, 2);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l(3, 2, std::allocator<int>());
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, stack_allocator<int, 3> > l(3, 2);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l(3, 2);
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l(3, 2, min_allocator<int>());
+        assert(l.size() == 3);
+        assert(std::distance(l.begin(), l.end()) == 3);
+        std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/clear.pass.cpp b/final/test/containers/sequences/list/list.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..38696b6
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/clear.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void clear();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a[] = {1, 2, 3};
+    std::list<int> c(a, a+3);
+    c.clear();
+    assert(c.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+    int a[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> c(a, a+3);
+    c.clear();
+    assert(c.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/emplace.pass.cpp b/final/test/containers/sequences/list/list.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..6476d1d
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/emplace.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<A> c;
+    c.emplace(c.cbegin(), 2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace(c.cend(), 3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    assert(c.back().geti() == 3);
+    assert(c.back().getd() == 4.5);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<A> c1;
+        std::list<A> c2;
+        std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<A, min_allocator<A>> c;
+    c.emplace(c.cbegin(), 2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace(c.cend(), 3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    assert(c.back().geti() == 3);
+    assert(c.back().getd() == 4.5);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<A, min_allocator<A>> c1;
+        std::list<A, min_allocator<A>> c2;
+        std::list<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/emplace_back.pass.cpp b/final/test/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
new file mode 100644
index 0000000..5983efc
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<A> c;
+    c.emplace_back(2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace_back(3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    assert(c.back().geti() == 3);
+    assert(c.back().getd() == 4.5);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<A, min_allocator<A>> c;
+    c.emplace_back(2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace_back(3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    assert(c.back().geti() == 3);
+    assert(c.back().getd() == 4.5);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/emplace_front.pass.cpp b/final/test/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
new file mode 100644
index 0000000..e2e68e3
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<A> c;
+    c.emplace_front(2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace_front(3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 3);
+    assert(c.front().getd() == 4.5);
+    assert(c.back().geti() == 2);
+    assert(c.back().getd() == 3.5);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<A, min_allocator<A>> c;
+    c.emplace_front(2, 3.5);
+    assert(c.size() == 1);
+    assert(c.front().geti() == 2);
+    assert(c.front().getd() == 3.5);
+    c.emplace_front(3, 4.5);
+    assert(c.size() == 2);
+    assert(c.front().geti() == 3);
+    assert(c.front().getd() == 4.5);
+    assert(c.back().geti() == 2);
+    assert(c.back().getd() == 3.5);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..c1cc900
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator position);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::const_iterator i = l1.begin();
+    ++i;
+    std::list<int>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == 3);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == 3);
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == 1);
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+    ++i;
+    std::list<int, min_allocator<int>>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == 3);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == 3);
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == 1);
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000..18c15eb
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000..61ff840
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int> l2(a1, a1+3);
+    std::list<int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>> l2(a1, a1+3);
+    std::list<int, min_allocator<int>>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..bd3f66b
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert(l1 == std::list<int>(a1+1, a1+3));
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert(l1 == std::list<int>(a1+2, a1+3));
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+    }
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert((l1 == std::list<int, min_allocator<int>>(a1+1, a1+3)));
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert((l1 == std::list<int, min_allocator<int>>(a1+2, a1+3)));
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000..71ad497
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int> l2(a1, a1+3);
+    std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>> l2(a1, a1+3);
+    std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000..db76b4d
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int> l2(a1, a1+3);
+    std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>> l2(a1, a1+3);
+    std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000..25c5c61
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int> l2(a1, a1+3);
+    std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>> l2(a1, a1+3);
+    std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000..35a4ceb
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/final/test/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..a82a269
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::list<int> d(10, 1);
+    std::list<int>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(i == next(d.begin(), 2));
+    i = d.begin();
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<int, min_allocator<int>> d(10, 1);
+    std::list<int, min_allocator<int>>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(i == next(d.begin(), 2));
+    i = d.begin();
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 3);
+    assert(*i++ == 4);
+    assert(*i++ == 5);
+    assert(*i++ == 6);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    assert(*i++ == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/final/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..625004b
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <InputIterator Iter>
+//   iterator insert(const_iterator position, Iter first, Iter last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next == 0)
+        throw std::bad_alloc();
+    --throw_next;
+    ++count;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --count;
+    std::free(p);
+}
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int> l1;
+    std::list<int>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+    assert(i == l1.begin());
+    assert(l1.size() == 3);
+    assert(distance(l1.begin(), l1.end()) == 3);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 3);
+    int a2[] = {4, 5, 6};
+    i = l1.insert(i, a2, a2+3);
+    assert(*i == 4);
+    assert(l1.size() == 6);
+    assert(distance(l1.begin(), l1.end()) == 6);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 4);
+    ++i;
+    assert(*i == 5);
+    ++i;
+    assert(*i == 6);
+    ++i;
+    assert(*i == 3);
+    throw_next = 2;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, a2, a2+3);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    assert(save_count == count);
+    assert(l1.size() == 6);
+    assert(distance(l1.begin(), l1.end()) == 6);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 4);
+    ++i;
+    assert(*i == 5);
+    ++i;
+    assert(*i == 6);
+    ++i;
+    assert(*i == 3);
+    }
+    throw_next = 0xFFFF;
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> v(100);
+        std::list<int> v2(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
+                                       input_iterator<const int*>(a+N));
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> l1;
+    std::list<int, min_allocator<int>>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+    assert(i == l1.begin());
+    assert(l1.size() == 3);
+    assert(distance(l1.begin(), l1.end()) == 3);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 3);
+    int a2[] = {4, 5, 6};
+    i = l1.insert(i, a2, a2+3);
+    assert(*i == 4);
+    assert(l1.size() == 6);
+    assert(distance(l1.begin(), l1.end()) == 6);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 4);
+    ++i;
+    assert(*i == 5);
+    ++i;
+    assert(*i == 6);
+    ++i;
+    assert(*i == 3);
+    throw_next = 2;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, a2, a2+3);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    assert(save_count == count);
+    assert(l1.size() == 6);
+    assert(distance(l1.begin(), l1.end()) == 6);
+    i = l1.begin();
+    assert(*i == 1);
+    ++i;
+    assert(*i == 2);
+    ++i;
+    assert(*i == 4);
+    ++i;
+    assert(*i == 5);
+    ++i;
+    assert(*i == 6);
+    ++i;
+    assert(*i == 3);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        throw_next = 0xFFFF;
+        std::list<int, min_allocator<int>> v(100);
+        std::list<int, min_allocator<int>> v2(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::list<int, min_allocator<int>>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
+                                       input_iterator<const int*>(a+N));
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp b/final/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 0000000..27d0411
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<MoveOnly> l1;
+    l1.insert(l1.cend(), MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.insert(l1.cbegin(), MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(2));
+    assert(l1.back() == MoveOnly(1));
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> v1(3);
+        std::list<int> v2(3);
+        v1.insert(v2.begin(), 4);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+    l1.insert(l1.cend(), MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.insert(l1.cbegin(), MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(2));
+    assert(l1.back() == MoveOnly(1));
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int, min_allocator<int>> v1(3);
+        std::list<int, min_allocator<int>> v2(3);
+        v1.insert(v2.begin(), 4);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/final/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 0000000..ce2d386
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next == 0)
+        throw std::bad_alloc();
+    --throw_next;
+    ++count;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --count;
+    std::free(p);
+}
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+    assert(i == next(l1.begin()));
+    assert(l1 == std::list<int>(a2, a2+8));
+    throw_next = 4;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, 5, 5);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    throw_next = 0xFFFF;
+    assert(save_count == count);
+    assert(l1 == std::list<int>(a2, a2+8));
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> c1(100);
+        std::list<int> c2;
+        std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+    assert(i == next(l1.begin()));
+    assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
+    throw_next = 4;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, 5, 5);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    throw_next = 0xFFFF;
+    assert(save_count == count);
+    assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int, min_allocator<int>> c1(100);
+        std::list<int, min_allocator<int>> c2;
+        std::list<int, min_allocator<int>>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/final/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 0000000..1b097e3
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next == 0)
+        throw std::bad_alloc();
+    --throw_next;
+    ++count;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --count;
+    std::free(p);
+}
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    int a2[] = {1, 4, 2, 3};
+    std::list<int> l1(a1, a1+3);
+    std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 4);
+    assert(i == next(l1.begin()));
+    assert(l1.size() == 4);
+    assert(distance(l1.begin(), l1.end()) == 4);
+    assert(l1 == std::list<int>(a2, a2+4));
+    throw_next = 0;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, 5);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    throw_next = 0xFFFF;
+    assert(save_count == count);
+    assert(l1 == std::list<int>(a2, a2+4));
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> v1(3);
+        std::list<int> v2(3);
+        int i = 4;
+        v1.insert(v2.begin(), i);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    int a2[] = {1, 4, 2, 3};
+    std::list<int, min_allocator<int>> l1(a1, a1+3);
+    std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 4);
+    assert(i == next(l1.begin()));
+    assert(l1.size() == 4);
+    assert(distance(l1.begin(), l1.end()) == 4);
+    assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
+    throw_next = 0;
+    int save_count = count;
+    try
+    {
+        i = l1.insert(i, 5);
+        assert(false);
+    }
+    catch (...)
+    {
+    }
+    throw_next = 0xFFFF;
+    assert(save_count == count);
+    assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int, min_allocator<int>> v1(3);
+        std::list<int, min_allocator<int>> v2(3);
+        int i = 4;
+        v1.insert(v2.begin(), i);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp b/final/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp
new file mode 100644
index 0000000..3add851
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/pop_back.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a[] = {1, 2, 3};
+    std::list<int> c(a, a+3);
+    c.pop_back();
+    assert(c == std::list<int>(a, a+2));
+    c.pop_back();
+    assert(c == std::list<int>(a, a+1));
+    c.pop_back();
+    assert(c.empty());
+#if _LIBCPP_DEBUG >= 1
+        c.pop_back();
+        assert(false);
+#endif        
+    }
+#if __cplusplus >= 201103L
+    {
+    int a[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> c(a, a+3);
+    c.pop_back();
+    assert((c == std::list<int, min_allocator<int>>(a, a+2)));
+    c.pop_back();
+    assert((c == std::list<int, min_allocator<int>>(a, a+1)));
+    c.pop_back();
+    assert(c.empty());
+#if _LIBCPP_DEBUG >= 1
+        c.pop_back();
+        assert(false);
+#endif        
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/pop_front.pass.cpp b/final/test/containers/sequences/list/list.modifiers/pop_front.pass.cpp
new file mode 100644
index 0000000..aec17cc
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/pop_front.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_front();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a[] = {1, 2, 3};
+    std::list<int> c(a, a+3);
+    c.pop_front();
+    assert(c == std::list<int>(a+1, a+3));
+    c.pop_front();
+    assert(c == std::list<int>(a+2, a+3));
+    c.pop_front();
+    assert(c.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+    int a[] = {1, 2, 3};
+    std::list<int, min_allocator<int>> c(a, a+3);
+    c.pop_front();
+    assert((c == std::list<int, min_allocator<int>>(a+1, a+3)));
+    c.pop_front();
+    assert((c == std::list<int, min_allocator<int>>(a+2, a+3)));
+    c.pop_front();
+    assert(c.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/push_back.pass.cpp b/final/test/containers/sequences/list/list.modifiers/push_back.pass.cpp
new file mode 100644
index 0000000..2638c54
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/push_back.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::list<int> c;
+    for (int i = 0; i < 5; ++i)
+        c.push_back(i);
+    int a[] = {0, 1, 2, 3, 4};
+    assert(c == std::list<int>(a, a+5));
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<int, min_allocator<int>> c;
+    for (int i = 0; i < 5; ++i)
+        c.push_back(i);
+    int a[] = {0, 1, 2, 3, 4};
+    assert((c == std::list<int, min_allocator<int>>(a, a+5)));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp b/final/test/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 0000000..9d3c05e
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+    public: CMyClass();
+    public: CMyClass(const CMyClass& iOther);
+    public: ~CMyClass();
+
+    private: int fMagicValue;
+
+    private: static int kStartedConstructionMagicValue;
+    private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+    fMagicValue(kStartedConstructionMagicValue)
+{
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+    fMagicValue(kStartedConstructionMagicValue)
+{
+    // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+    if (gCopyConstructorShouldThow) {
+        throw std::exception();
+    }
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+    // Only instances for which the constructor has finished running should be destructed
+    assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+    CMyClass instance;
+    std::list<CMyClass> vec;
+
+    vec.push_back(instance);
+
+    gCopyConstructorShouldThow = true;
+    try {
+        vec.push_back(instance);
+    }
+    catch (...) {
+    }
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/final/test/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 0000000..070db9e
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<MoveOnly> l1;
+    l1.push_back(MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.push_back(MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(1));
+    assert(l1.back() == MoveOnly(2));
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+    l1.push_back(MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.push_back(MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(1));
+    assert(l1.back() == MoveOnly(2));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/push_front.pass.cpp b/final/test/containers/sequences/list/list.modifiers/push_front.pass.cpp
new file mode 100644
index 0000000..b7f4feb
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/push_front.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::list<int> c;
+    for (int i = 0; i < 5; ++i)
+        c.push_front(i);
+    int a[] = {4, 3, 2, 1, 0};
+    assert(c == std::list<int>(a, a+5));
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<int, min_allocator<int>> c;
+    for (int i = 0; i < 5; ++i)
+        c.push_front(i);
+    int a[] = {4, 3, 2, 1, 0};
+    assert((c == std::list<int, min_allocator<int>>(a, a+5)));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp b/final/test/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 0000000..6609005
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+    public: CMyClass();
+    public: CMyClass(const CMyClass& iOther);
+    public: ~CMyClass();
+
+    private: int fMagicValue;
+
+    private: static int kStartedConstructionMagicValue;
+    private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+    fMagicValue(kStartedConstructionMagicValue)
+{
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+    fMagicValue(kStartedConstructionMagicValue)
+{
+    // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+    if (gCopyConstructorShouldThow) {
+        throw std::exception();
+    }
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+    // Only instances for which the constructor has finished running should be destructed
+    assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+    CMyClass instance;
+    std::list<CMyClass> vec;
+
+    vec.push_front(instance);
+
+    gCopyConstructorShouldThow = true;
+    try {
+        vec.push_front(instance);
+    }
+    catch (...) {
+    }
+}
diff --git a/final/test/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/final/test/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 0000000..8a31755
--- /dev/null
+++ b/final/test/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    std::list<MoveOnly> l1;
+    l1.push_front(MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.push_front(MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(2));
+    assert(l1.back() == MoveOnly(1));
+    }
+#if __cplusplus >= 201103L
+    {
+    std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+    l1.push_front(MoveOnly(1));
+    assert(l1.size() == 1);
+    assert(l1.front() == MoveOnly(1));
+    l1.push_front(MoveOnly(2));
+    assert(l1.size() == 2);
+    assert(l1.front() == MoveOnly(2));
+    assert(l1.back() == MoveOnly(1));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/list/list.ops/merge.pass.cpp b/final/test/containers/sequences/list/list.ops/merge.pass.cpp
new file mode 100644
index 0000000..d226ed5
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/merge.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void merge(list& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 3, 7, 9, 10};
+    int a2[] = {0, 2, 4, 5, 6, 8, 11};
+    int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+    c1.merge(c2);
+    assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 3, 7, 9, 10};
+    int a2[] = {0, 2, 4, 5, 6, 8, 11};
+    int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+    c1.merge(c2);
+    assert((c1 == std::list<int, min_allocator<int>>(a3, a3+sizeof(a3)/sizeof(a3[0]))));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/merge_comp.pass.cpp b/final/test/containers/sequences/list/list.ops/merge_comp.pass.cpp
new file mode 100644
index 0000000..ce861a5
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/merge_comp.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> void merge(list& x, Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {10, 9, 7, 3, 1};
+    int a2[] = {11, 8, 6, 5, 4, 2, 0};
+    int a3[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+    c1.merge(c2, std::greater<int>());
+    assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {10, 9, 7, 3, 1};
+    int a2[] = {11, 8, 6, 5, 4, 2, 0};
+    int a3[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+    c1.merge(c2, std::greater<int>());
+    assert((c1 == std::list<int, min_allocator<int>>(a3, a3+sizeof(a3)/sizeof(a3[0]))));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/remove.pass.cpp b/final/test/containers/sequences/list/list.ops/remove.pass.cpp
new file mode 100644
index 0000000..76d878d
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/remove.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void remove(const value_type& value);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3, 4};
+    int a2[] = {1, 2, 4};
+    std::list<int> c(a1, a1+4);
+    c.remove(3);
+    assert(c == std::list<int>(a2, a2+3));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3, 4};
+    int a2[] = {1, 2, 4};
+    std::list<int, min_allocator<int>> c(a1, a1+4);
+    c.remove(3);
+    assert((c == std::list<int, min_allocator<int>>(a2, a2+3)));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/remove_if.pass.cpp b/final/test/containers/sequences/list/list.ops/remove_if.pass.cpp
new file mode 100644
index 0000000..b45562a
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/remove_if.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Pred> void remove_if(Pred pred);
+
+#include <list>
+#include <cassert>
+#include <functional>
+
+#include "min_allocator.h"
+
+bool g(int i)
+{
+    return i < 3;
+}
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3, 4};
+    int a2[] = {3, 4};
+    std::list<int> c(a1, a1+4);
+    c.remove_if(g);
+    assert(c == std::list<int>(a2, a2+2));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3, 4};
+    int a2[] = {3, 4};
+    std::list<int, min_allocator<int>> c(a1, a1+4);
+    c.remove_if(g);
+    assert((c == std::list<int, min_allocator<int>>(a2, a2+2)));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/reverse.pass.cpp b/final/test/containers/sequences/list/list.ops/reverse.pass.cpp
new file mode 100644
index 0000000..046453a
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/reverse.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void reverse();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.reverse();
+    assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.reverse();
+    assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/sort.pass.cpp b/final/test/containers/sequences/list/list.ops/sort.pass.cpp
new file mode 100644
index 0000000..1c11227
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/sort.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void sort();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+    int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.sort();
+    assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+    int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+    std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.sort();
+    assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/sort_comp.pass.cpp b/final/test/containers/sequences/list/list.ops/sort_comp.pass.cpp
new file mode 100644
index 0000000..28125ab
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/sort_comp.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> sort(Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+    int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.sort(std::greater<int>());
+    assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+    int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+    std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c1.sort(std::greater<int>());
+    assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp b/final/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
new file mode 100644
index 0000000..354871c
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
@@ -0,0 +1,803 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {4, 5, 6};
+    {
+        std::list<int> l1;
+        std::list<int> l2;
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 0);
+        assert(distance(l1.begin(), l1.end()) == 0);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2;
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2;
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2;
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2;
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2;
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        std::list<int> l2(a2, a2+2);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin(), 3), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> v1(3);
+        std::list<int> v2(3);
+        v1.splice(v2.begin(), v2);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2;
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 0);
+        assert(distance(l1.begin(), l1.end()) == 0);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2;
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2;
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.end(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2;
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2;
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2;
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 4);
+        assert(distance(l1.begin(), l1.end()) == 4);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(next(l1.begin()), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(next(l1.begin(), 2), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(next(l1.begin(), 3), l2);
+        assert(l1.size() == 6);
+        assert(distance(l1.begin(), l1.end()) == 6);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int, min_allocator<int>> v1(3);
+        std::list<int, min_allocator<int>> v2(3);
+        v1.splice(v2.begin(), v2);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp b/final/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
new file mode 100644
index 0000000..5082c3f
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
@@ -0,0 +1,357 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {4, 5, 6};
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 1);
+        assert(distance(l2.begin(), l2.end()) == 1);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        i = l2.begin();
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+2);
+        l1.splice(l1.end(), l2, next(l2.begin()));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 1);
+        assert(distance(l2.begin(), l2.end()) == 1);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        i = l2.begin();
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin()));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        i = l2.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int> l1;
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 6);
+        i = l2.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        l1.splice(l1.begin(), l1, l1.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2, l2.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+1);
+        std::list<int> l2(a2, a2+1);
+        l1.splice(next(l1.begin()), l2, l2.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(l1.begin(), l1, l1.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(l1.begin(), l1, next(l1.begin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(next(l1.begin()), l1, l1.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int> l1(a1, a1+2);
+        l1.splice(next(l1.begin()), l1, next(l1.begin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> v1(3);
+        std::list<int> v2(3);
+        v1.splice(v1.begin(), v2, v1.begin());
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 1);
+        assert(distance(l2.begin(), l2.end()) == 1);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        i = l2.begin();
+        assert(*i == 5);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+2);
+        l1.splice(l1.end(), l2, next(l2.begin()));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 1);
+        assert(distance(l2.begin(), l2.end()) == 1);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, l2.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        i = l2.begin();
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin()));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        i = l2.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 6);
+    }
+    {
+        std::list<int, min_allocator<int>> l1;
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        assert(l2.size() == 2);
+        assert(distance(l2.begin(), l2.end()) == 2);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 6);
+        i = l2.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 5);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        l1.splice(l1.begin(), l1, l1.begin());
+        assert(l1.size() == 1);
+        assert(distance(l1.begin(), l1.end()) == 1);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(l1.begin(), l2, l2.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+1);
+        std::list<int, min_allocator<int>> l2(a2, a2+1);
+        l1.splice(next(l1.begin()), l2, l2.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        assert(l2.size() == 0);
+        assert(distance(l2.begin(), l2.end()) == 0);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        l1.splice(l1.begin(), l1, l1.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        l1.splice(l1.begin(), l1, next(l1.begin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        l1.splice(next(l1.begin()), l1, l1.begin());
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+2);
+        l1.splice(next(l1.begin()), l1, next(l1.begin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.begin(), l1.end()) == 2);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int, min_allocator<int>> v1(3);
+        std::list<int, min_allocator<int>> v2(3);
+        v1.splice(v1.begin(), v2, v1.begin());
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp b/final/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
new file mode 100644
index 0000000..fcc4acc
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
@@ -0,0 +1,237 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x, iterator first, iterator last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    int a2[] = {4, 5, 6};
+    {
+        std::list<int> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int> l1(a1, a1+3);
+        std::list<int> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int> v1(3);
+        std::list<int> v2(3);
+        v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 3);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+        assert(l1.size() == 3);
+        assert(distance(l1.begin(), l1.end()) == 3);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 1);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+    {
+        std::list<int, min_allocator<int>> l1(a1, a1+3);
+        std::list<int, min_allocator<int>> l2(a2, a2+3);
+        l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+        assert(l1.size() == 5);
+        assert(distance(l1.begin(), l1.end()) == 5);
+        std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 5);
+        ++i;
+        assert(*i == 6);
+        assert(l2.size() == 1);
+        i = l2.begin();
+        assert(*i == 4);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::list<int, min_allocator<int>> v1(3);
+        std::list<int, min_allocator<int>> v2(3);
+        v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/unique.pass.cpp b/final/test/containers/sequences/list/list.ops/unique.pass.cpp
new file mode 100644
index 0000000..48cad1d
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/unique.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void unique();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+    int a2[] = {2, 1, 4, 3};
+    std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c.unique();
+    assert(c == std::list<int>(a2, a2+4));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+    int a2[] = {2, 1, 4, 3};
+    std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c.unique();
+    assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.ops/unique_pred.pass.cpp b/final/test/containers/sequences/list/list.ops/unique_pred.pass.cpp
new file mode 100644
index 0000000..f8935b8
--- /dev/null
+++ b/final/test/containers/sequences/list/list.ops/unique_pred.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class BinaryPred> void unique(BinaryPred pred);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int x, int y)
+{
+    return x == y;
+}
+
+int main()
+{
+    {
+    int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+    int a2[] = {2, 1, 4, 3};
+    std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c.unique(g);
+    assert(c == std::list<int>(a2, a2+4));
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+    int a2[] = {2, 1, 4, 3};
+    std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+    c.unique(g);
+    assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.special/db_swap_1.pass.cpp b/final/test/containers/sequences/list/list.special/db_swap_1.pass.cpp
new file mode 100644
index 0000000..f717179
--- /dev/null
+++ b/final/test/containers/sequences/list/list.special/db_swap_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+//   void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include <__debug>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::list<int>::iterator i1 = c1.begin();
+        std::list<int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        std::list<int>::iterator j = i1;
+        c1.erase(i1);
+        assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::list<int, min_allocator<int>>::iterator i1 = c1.begin();
+        std::list<int, min_allocator<int>>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        std::list<int, min_allocator<int>>::iterator j = i1;
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.special/swap.pass.cpp b/final/test/containers/sequences/list/list.special/swap.pass.cpp
new file mode 100644
index 0000000..bc5f485
--- /dev/null
+++ b/final/test/containers/sequences/list/list.special/swap.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+//   void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1);
+        std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int> c1(a1, a1);
+        std::list<int> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef test_allocator<int> A;
+        std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(1));
+        assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(2));
+    }
+#endif
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef other_allocator<int> A;
+        std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(2));
+        assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(1));
+    }
+#if __cplusplus >= 201103L
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int, min_allocator<int>> c1(a1, a1);
+        std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        swap(c1, c2);
+        assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::list<int, min_allocator<int>> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::list<int, min_allocator<int>> c1(a1, a1);
+        std::list<int, min_allocator<int>> c2(a2, a2);
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+    }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef min_allocator<int> A;
+        std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+        std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+        swap(c1, c2);
+        assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A());
+        assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A());
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/final/test/containers/sequences/list/list.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..7a23398
--- /dev/null
+++ b/final/test/containers/sequences/list/list.special/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void swap(list& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    
+    some_alloc() {}
+    some_alloc(const some_alloc&);
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::list<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/list/types.pass.cpp b/final/test/containers/sequences/list/types.pass.cpp
new file mode 100644
index 0000000..95d7f50
--- /dev/null
+++ b/final/test/containers/sequences/list/types.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc = allocator<T> >
+// class list
+// {
+// public:
+//
+//     // types:
+//     typedef T value_type;
+//     typedef Alloc allocator_type;
+//     typedef typename allocator_type::reference reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef typename allocator_type::pointer pointer;
+//     typedef typename allocator_type::const_pointer const_pointer;
+
+#include <list>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    static_assert((std::is_same<std::list<int>::value_type, int>::value), "");
+    static_assert((std::is_same<std::list<int>::allocator_type, std::allocator<int> >::value), "");
+    static_assert((std::is_same<std::list<int>::reference, std::allocator<int>::reference>::value), "");
+    static_assert((std::is_same<std::list<int>::const_reference, std::allocator<int>::const_reference>::value), "");
+    static_assert((std::is_same<std::list<int>::pointer, std::allocator<int>::pointer>::value), "");
+    static_assert((std::is_same<std::list<int>::const_pointer, std::allocator<int>::const_pointer>::value), "");
+#if __cplusplus >= 201103L
+    static_assert((std::is_same<std::list<int, min_allocator<int>>::value_type, int>::value), "");
+    static_assert((std::is_same<std::list<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+    static_assert((std::is_same<std::list<int, min_allocator<int>>::reference, int&>::value), "");
+    static_assert((std::is_same<std::list<int, min_allocator<int>>::const_reference, const int&>::value), "");
+    static_assert((std::is_same<std::list<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+    static_assert((std::is_same<std::list<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
diff --git a/final/test/containers/sequences/list/version.pass.cpp b/final/test/containers/sequences/list/version.pass.cpp
new file mode 100644
index 0000000..097c013
--- /dev/null
+++ b/final/test/containers/sequences/list/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+#include <list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/nothing_to_do.pass.cpp b/final/test/containers/sequences/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/containers/sequences/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/vector.bool/assign_copy.pass.cpp b/final/test/containers/sequences/vector.bool/assign_copy.pass.cpp
new file mode 100644
index 0000000..9501799
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<bool>(3));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<bool>(5));
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+        std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == min_allocator<bool>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/final/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..2925fbc
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<bool> d;
+    d.assign({true, false, false, true});
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<bool, min_allocator<bool>> d;
+    d.assign({true, false, false, true});
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector.bool/assign_move.pass.cpp b/final/test/containers/sequences/vector.bool/assign_move.pass.cpp
new file mode 100644
index 0000000..df98c81
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/assign_move.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(5));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<bool>(6));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+        std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, min_allocator<bool> > l2(min_allocator<bool>{});
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector.bool/capacity.pass.cpp b/final/test/containers/sequences/vector.bool/capacity.pass.cpp
new file mode 100644
index 0000000..63bff25
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/capacity.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v;
+        assert(v.capacity() == 0);
+    }
+    {
+        std::vector<bool> v(100);
+        assert(v.capacity() >= 100);
+        v.push_back(0);
+        assert(v.capacity() >= 101);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v;
+        assert(v.capacity() == 0);
+    }
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        assert(v.capacity() >= 100);
+        v.push_back(0);
+        assert(v.capacity() >= 101);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/construct_default.pass.cpp b/final/test/containers/sequences/vector.bool/construct_default.pass.cpp
new file mode 100644
index 0000000..d3d6670
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/construct_default.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test0()
+{
+    C c;
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == typename C::allocator_type());
+#if __cplusplus >= 201103L
+    C c1 = {};
+    assert(c1.__invariants());
+    assert(c1.empty());
+    assert(c1.get_allocator() == typename C::allocator_type());
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+    C c(a);
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == a);
+}
+
+int main()
+{
+    {
+    test0<std::vector<bool> >();
+    test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
+    }
+#if __cplusplus >= 201103L
+    {
+    test0<std::vector<bool, min_allocator<bool>> >();
+    test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/final/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
new file mode 100644
index 0000000..94e6801
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+    C c(first, last);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+int main()
+{
+    bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+    bool* an = a + sizeof(a)/sizeof(a[0]);
+    test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+    test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+    test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+    test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+    test<std::vector<bool> >(a, an);
+#if __cplusplus >= 201103L
+    test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+    test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+    test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+    test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+    test<std::vector<bool, min_allocator<bool>> >(a, an);
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/final/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..ea9d41d
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+//                                   const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last, const typename C::allocator_type& a)
+{
+    C c(first, last, a);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+int main()
+{
+    bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+    bool* an = a + sizeof(a)/sizeof(a[0]);
+    {
+    std::allocator<bool> alloc;
+    test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+    test<std::vector<bool> >(a, an, alloc);
+    }
+#if __cplusplus >= 201103L
+    {
+    min_allocator<bool> alloc;
+    test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+    test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+    test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+    test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+    test<std::vector<bool, min_allocator<bool>> >(a, an, alloc);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/construct_size.pass.cpp b/final/test/containers/sequences/vector.bool/construct_size.pass.cpp
new file mode 100644
index 0000000..93ecbe8
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/construct_size.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+
+template <class C>
+void
+test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ())
+{
+#if _LIBCPP_STD_VER > 11
+    C c(n, a);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    assert(c.get_allocator() == a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == typename C::value_type());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
+
+template <class C>
+void
+test1(typename C::size_type n)
+{
+    C c(n);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    assert(c.get_allocator() == typename C::allocator_type());
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == typename C::value_type());
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+    test1<C> ( n );
+    test2<C> ( n );
+}
+
+int main()
+{
+    test<std::vector<bool> >(50);
+#if __cplusplus >= 201103L
+    test<std::vector<bool, min_allocator<bool>> >(50);
+    test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23));
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/construct_size_value.pass.cpp b/final/test/containers/sequences/vector.bool/construct_size_value.pass.cpp
new file mode 100644
index 0000000..fc772f1
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/construct_size_value.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+    C c(n, x);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<bool> >(50, 3);
+#if __cplusplus >= 201103L
+    test<std::vector<bool, min_allocator<bool>> >(50, 3);
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/final/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
new file mode 100644
index 0000000..6cca948
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+     const typename C::allocator_type& a)
+{
+    C c(n, x, a);
+    assert(c.__invariants());
+    assert(a == c.get_allocator());
+    assert(c.size() == n);
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<bool> >(50, 3, std::allocator<bool>());
+#if __cplusplus >= 201103L
+    test<std::vector<bool, min_allocator<bool>> >(50, 3, min_allocator<bool>());
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/copy.pass.cpp b/final/test/containers/sequences/vector.bool/copy.pass.cpp
new file mode 100644
index 0000000..5882278
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/copy.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    unsigned s = x.size();
+    C c(x);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+        bool* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<bool>(a, an));
+    }
+    {
+        std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == other_allocator<bool>(-2));
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+        bool* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<bool, min_allocator<bool>>(a, an));
+    }
+    {
+        std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>());
+        std::vector<bool, min_allocator<bool> > v2 = v;
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/copy_alloc.pass.cpp b/final/test/containers/sequences/vector.bool/copy_alloc.pass.cpp
new file mode 100644
index 0000000..2f0192b
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/copy_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+    unsigned s = x.size();
+    C c(x, a);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+}
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<bool>(a, an), std::allocator<bool>());
+    }
+    {
+        std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<bool>(3));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<bool>(3));
+    }
+#if __cplusplus >= 201103L
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>());
+    }
+    {
+        std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+        std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+        assert(l2 == l);
+        assert(l2.get_allocator() == min_allocator<bool>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/default_noexcept.pass.cpp b/final/test/containers/sequences/vector.bool/default_noexcept.pass.cpp
new file mode 100644
index 0000000..b94588e
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/default_noexcept.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector<bool>()
+//        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<bool> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, test_allocator<bool>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, other_allocator<bool>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, some_alloc<bool>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/final/test/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..682e74e
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// ~vector<bool>() // implied noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+    ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<bool> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, test_allocator<bool>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, other_allocator<bool>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, some_alloc<bool>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/emplace.pass.cpp b/final/test/containers/sequences/vector.bool/emplace.pass.cpp
new file mode 100644
index 0000000..f3fd1e9
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/emplace.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+//  vector<bool>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::vector<bool> C;
+        C c;
+        
+        C::iterator i = c.emplace(c.cbegin());
+        assert(i == c.begin());
+        assert(c.size() == 1);
+        assert(c.front() == false);
+
+        i = c.emplace(c.cend(), true);
+        assert(i == c.end()-1);
+        assert(c.size() == 2);
+        assert(c.front() == false);
+        assert(c.back() == true);
+
+        i = c.emplace(c.cbegin()+1, 1 == 1);
+        assert(i == c.begin()+1);
+        assert(c.size() == 3);
+        assert(c.front() == false);
+        assert(c[1] == true);
+        assert(c.back() == true);
+    }
+    {
+        typedef std::vector<bool, min_allocator<bool>> C;
+        C c;
+
+        C::iterator i = c.emplace(c.cbegin());
+        assert(i == c.begin());
+        assert(c.size() == 1);
+        assert(c.front() == false);
+
+        i = c.emplace(c.cend(), true);
+        assert(i == c.end()-1);
+        assert(c.size() == 2);
+        assert(c.front() == false);
+        assert(c.back() == true);
+
+        i = c.emplace(c.cbegin()+1, 1 == 1);
+        assert(i == c.begin()+1);
+        assert(c.size() == 3);
+        assert(c.size() == 3);
+        assert(c.front() == false);
+        assert(c[1] == true);
+        assert(c.back() == true);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/emplace_back.pass.cpp b/final/test/containers/sequences/vector.bool/emplace_back.pass.cpp
new file mode 100644
index 0000000..57aa478
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/emplace_back.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+//  vector.bool
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::vector<bool> C;
+        C c;
+        c.emplace_back();
+        assert(c.size() == 1);
+        assert(c.front() == false);
+        c.emplace_back(true);
+        assert(c.size() == 2);
+        assert(c.front() == false);
+        assert(c.back() == true);
+        c.emplace_back(1 == 1);
+        assert(c.size() == 3);
+        assert(c.front() == false);
+        assert(c[1] == true);
+        assert(c.back() == true);
+    }
+    {
+        typedef std::vector<bool, min_allocator<bool>> C;
+        C c;
+        
+        c.emplace_back();
+        assert(c.size() == 1);
+        assert(c.front() == false);
+        c.emplace_back(true);
+        assert(c.size() == 2);
+        assert(c.front() == false);
+        assert(c.back() == true);
+        c.emplace_back(1 == 1);
+        assert(c.size() == 3);
+        assert(c.front() == false);
+        assert(c[1] == true);
+        assert(c.back() == true);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/erase_iter.pass.cpp b/final/test/containers/sequences/vector.bool/erase_iter.pass.cpp
new file mode 100644
index 0000000..cbf26dd
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/erase_iter.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    bool a1[] = {1, 0, 1};
+    {
+    std::vector<bool> l1(a1, a1+3);
+    std::vector<bool>::const_iterator i = l1.begin();
+    ++i;
+    std::vector<bool>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == true);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == true);
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == true);
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+    std::vector<bool, min_allocator<bool>>::const_iterator i = l1.begin();
+    ++i;
+    std::vector<bool, min_allocator<bool>>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == true);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == true);
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == true);
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/final/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..2c2c4cc
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    bool a1[] = {1, 0, 1};
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+    }
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<bool>(a1+1, a1+3));
+    }
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<bool>(a1+2, a1+3));
+    }
+    {
+        std::vector<bool> l1(a1, a1+3);
+        std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+        std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+    }
+    {
+        std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+        std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert((l1 == std::vector<bool, min_allocator<bool>>(a1+1, a1+3)));
+    }
+    {
+        std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+        std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert((l1 == std::vector<bool, min_allocator<bool>>(a1+2, a1+3)));
+    }
+    {
+        std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+        std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/find.pass.cpp b/final/test/containers/sequences/vector.bool/find.pass.cpp
new file mode 100644
index 0000000..75567a9
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/find.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// std::find with vector<bool>::iterator
+
+// http://llvm.org/bugs/show_bug.cgi?id=16816
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        for (unsigned i = 1; i < 256; ++i)
+        {
+            std::vector<bool> b(i,true);
+            std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), false);
+            assert(j-b.begin() == i);
+            assert(b.end() == j);
+        }
+    }
+    {
+        for (unsigned i = 1; i < 256; ++i)
+        {
+            std::vector<bool> b(i,false);
+            std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), true);
+            assert(j-b.begin() == i);
+            assert(b.end() == j);
+        }
+    }
+}
diff --git a/final/test/containers/sequences/vector.bool/initializer_list.pass.cpp b/final/test/containers/sequences/vector.bool/initializer_list.pass.cpp
new file mode 100644
index 0000000..b9b4686
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<bool> d = {true, false, false, true};
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<bool, min_allocator<bool>> d = {true, false, false, true};
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/final/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..aea3ad7
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
+    assert(d.get_allocator() == test_allocator<bool>(3));
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>());
+    assert(d.get_allocator() == min_allocator<bool>());
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/final/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..c081cc8
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<bool> d(10, true);
+    std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+    assert(d.size() == 14);
+    assert(i == d.begin() + 2);
+    assert(d[0] == true);
+    assert(d[1] == true);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    assert(d[4] == true);
+    assert(d[5] == false);
+    assert(d[6] == true);
+    assert(d[7] == true);
+    assert(d[8] == true);
+    assert(d[9] == true);
+    assert(d[10] == true);
+    assert(d[11] == true);
+    assert(d[12] == true);
+    assert(d[13] == true);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<bool, min_allocator<bool>> d(10, true);
+    std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+    assert(d.size() == 14);
+    assert(i == d.begin() + 2);
+    assert(d[0] == true);
+    assert(d[1] == true);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    assert(d[4] == true);
+    assert(d[5] == false);
+    assert(d[6] == true);
+    assert(d[7] == true);
+    assert(d[8] == true);
+    assert(d[9] == true);
+    assert(d[10] == true);
+    assert(d[11] == true);
+    assert(d[12] == true);
+    assert(d[13] == true);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/final/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..c49ef9b
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class Iter>
+//   iterator insert(const_iterator position, Iter first, Iter last);
+
+#include <vector>
+#include <cassert>
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        bool a[] = {1, 0, 0, 1, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+                                        input_iterator<const bool*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<bool> v(100);
+        bool a[] = {1, 0, 0, 1, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+                                        forward_iterator<const bool*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        bool a[] = {1, 0, 0, 1, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+                                        input_iterator<const bool*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        bool a[] = {1, 0, 0, 1, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+                                        forward_iterator<const bool*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/final/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
new file mode 100644
index 0000000..f9cb65c
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/final/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp
new file mode 100644
index 0000000..1213985
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/insert_iter_value.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/iterators.pass.cpp b/final/test/containers/sequences/vector.bool/iterators.pass.cpp
new file mode 100644
index 0000000..c54fa4a
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/iterators.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef bool T;
+        typedef std::vector<T, min_allocator<T>> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T, min_allocator<T>> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T, min_allocator<T>> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T, min_allocator<T>> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        std::vector<bool>::iterator ii1{}, ii2{};
+        std::vector<bool>::iterator ii4 = ii1;
+        std::vector<bool>::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+        assert (!(ii1 <  cii ));
+        assert (!(cii <  ii1 ));
+        assert ( (ii1 <= cii ));
+        assert ( (cii <= ii1 ));
+        assert (!(ii1 >  cii ));
+        assert (!(cii >  ii1 ));
+        assert ( (ii1 >= cii ));
+        assert ( (cii >= ii1 ));
+        assert (cii - ii1 == 0);
+        assert (ii1 - cii == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/move.pass.cpp b/final/test/containers/sequences/vector.bool/move.pass.cpp
new file mode 100644
index 0000000..e877292
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/move.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, other_allocator<bool> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+        std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, min_allocator<bool> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector.bool/move_alloc.pass.cpp b/final/test/containers/sequences/vector.bool/move_alloc.pass.cpp
new file mode 100644
index 0000000..deee932
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/move_alloc.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<bool>(6));
+    }
+    {
+        std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == test_allocator<bool>(5));
+    }
+    {
+        std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == other_allocator<bool>(4));
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+        std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == min_allocator<bool>());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/final/test/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..b580eb4
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<bool> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, test_allocator<bool>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, other_allocator<bool>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, some_alloc<bool>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/move_noexcept.pass.cpp b/final/test/containers/sequences/vector.bool/move_noexcept.pass.cpp
new file mode 100644
index 0000000..ab32bd0
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/move_noexcept.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<bool> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, test_allocator<bool>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, other_allocator<bool>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<bool, some_alloc<bool>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/final/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..ef3dc5d
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<bool> d;
+    d = {true, false, false, true};
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<bool, min_allocator<bool>> d;
+    d = {true, false, false, true};
+    assert(d.size() == 4);
+    assert(d[0] == true);
+    assert(d[1] == false);
+    assert(d[2] == false);
+    assert(d[3] == true);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector.bool/push_back.pass.cpp b/final/test/containers/sequences/vector.bool/push_back.pass.cpp
new file mode 100644
index 0000000..c6b0fbf
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/push_back.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        bool a[] = {0, 1, 1, 0, 1, 0, 0};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool> c;
+        for (unsigned i = 0; i < N; ++i)
+        {
+            c.push_back(a[i]);
+            assert(c.size() == i+1);
+            for (int j = 0; j < c.size(); ++j)
+                assert(c[j] == a[j]);
+        }
+    }
+#if __cplusplus >= 201103L
+    {
+        bool a[] = {0, 1, 1, 0, 1, 0, 0};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::vector<bool, min_allocator<bool>> c;
+        for (unsigned i = 0; i < N; ++i)
+        {
+            c.push_back(a[i]);
+            assert(c.size() == i+1);
+            for (int j = 0; j < c.size(); ++j)
+                assert(c[j] == a[j]);
+        }
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/reserve.pass.cpp b/final/test/containers/sequences/vector.bool/reserve.pass.cpp
new file mode 100644
index 0000000..be717a3
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/reserve.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v;
+        v.reserve(10);
+        assert(v.capacity() >= 10);
+    }
+    {
+        std::vector<bool> v(100);
+        assert(v.capacity() >= 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() >= 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() >= 150);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v;
+        v.reserve(10);
+        assert(v.capacity() >= 10);
+    }
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        assert(v.capacity() >= 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() >= 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() >= 150);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/resize_size.pass.cpp b/final/test/containers/sequences/vector.bool/resize_size.pass.cpp
new file mode 100644
index 0000000..77d54e5
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/resize_size.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() >= 100);
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() >= 100);
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/resize_size_value.pass.cpp b/final/test/containers/sequences/vector.bool/resize_size_value.pass.cpp
new file mode 100644
index 0000000..8cecf44
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/resize_size_value.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() >= 100);
+        assert(v == std::vector<bool>(50));
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        for (unsigned i = 0; i < 50; ++i)
+            assert(v[i] == 0);
+        for (unsigned i = 50; i < 200; ++i)
+            assert(v[i] == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() >= 100);
+        assert((v == std::vector<bool, min_allocator<bool>>(50)));
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        for (unsigned i = 0; i < 50; ++i)
+            assert(v[i] == 0);
+        for (unsigned i = 50; i < 200; ++i)
+            assert(v[i] == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/final/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..1f9fcac
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v(100);
+        v.push_back(1);
+        v.shrink_to_fit();
+        assert(v.capacity() >= 101);
+        assert(v.size() >= 101);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v(100);
+        v.push_back(1);
+        v.shrink_to_fit();
+        assert(v.capacity() >= 101);
+        assert(v.size() >= 101);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/swap.pass.cpp b/final/test/containers/sequences/vector.bool/swap.pass.cpp
new file mode 100644
index 0000000..a92c6a6
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/swap.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<bool> v1(100);
+        std::vector<bool> v2(200);
+        v1.swap(v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+    }
+    {
+        typedef test_allocator<bool> A;
+        std::vector<bool, A> v1(100, true, A(1));
+        std::vector<bool, A> v2(200, false, A(2));
+        swap(v1, v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+        assert(v1.get_allocator() == A(1));
+        assert(v2.get_allocator() == A(2));
+    }
+    {
+        typedef other_allocator<bool> A;
+        std::vector<bool, A> v1(100, true, A(1));
+        std::vector<bool, A> v2(200, false, A(2));
+        swap(v1, v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+        assert(v1.get_allocator() == A(2));
+        assert(v2.get_allocator() == A(1));
+    }
+    {
+        std::vector<bool> v(2);
+        std::vector<bool>::reference r1 = v[0];
+        std::vector<bool>::reference r2 = v[1];
+        r1 = true;
+        using std::swap;
+        swap(r1, r2);
+        assert(v[0] == false);
+        assert(v[1] == true);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<bool, min_allocator<bool>> v1(100);
+        std::vector<bool, min_allocator<bool>> v2(200);
+        v1.swap(v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+    }
+    {
+        typedef min_allocator<bool> A;
+        std::vector<bool, A> v1(100, true, A());
+        std::vector<bool, A> v2(200, false, A());
+        swap(v1, v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() >= 200);
+        assert(v2.size() == 100);
+        assert(v2.capacity() >= 100);
+        assert(v1.get_allocator() == A());
+        assert(v2.get_allocator() == A());
+    }
+    {
+        std::vector<bool, min_allocator<bool>> v(2);
+        std::vector<bool, min_allocator<bool>>::reference r1 = v[0];
+        std::vector<bool, min_allocator<bool>>::reference r2 = v[1];
+        r1 = true;
+        using std::swap;
+        swap(r1, r2);
+        assert(v[0] == false);
+        assert(v[1] == true);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/final/test/containers/sequences/vector.bool/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..bcaf161
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/swap_noexcept.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    
+    some_alloc() {}
+    some_alloc(const some_alloc&);
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<bool> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::vector<bool, test_allocator<bool>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::vector<bool, other_allocator<bool>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::vector<bool, some_alloc<bool>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/types.pass.cpp b/final/test/containers/sequences/vector.bool/types.pass.cpp
new file mode 100644
index 0000000..b266b3b
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class Allocator>
+// class vector<bool, Allocator
+// {
+// public:
+//     typedef T                                        value_type;
+//     typedef Allocator                                allocator_type;
+//     typedef implementation-defined                   iterator;
+//     typedef implementation-defined                   const_iterator;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef std::reverse_iterator<iterator>          reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class Allocator>
+void
+test()
+{
+    typedef std::vector<bool, Allocator> C;
+
+    static_assert((std::is_same<typename C::value_type, bool>::value), "");
+    static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
+    static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename C::reverse_iterator,
+        std::reverse_iterator<typename C::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename C::const_reverse_iterator,
+        std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+    test<test_allocator<bool> >();
+    test<std::allocator<bool> >();
+    static_assert((std::is_same<std::vector<bool>::allocator_type,
+                                std::allocator<bool> >::value), "");
+#if __cplusplus >= 201103L
+    test<min_allocator<bool> >();
+#endif
+}
diff --git a/final/test/containers/sequences/vector.bool/vector_bool.pass.cpp b/final/test/containers/sequences/vector.bool/vector_bool.pass.cpp
new file mode 100644
index 0000000..ea2262c
--- /dev/null
+++ b/final/test/containers/sequences/vector.bool/vector_bool.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <vector>
+#include <cassert>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::vector<bool> T;
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    bool ba[] = {true, false, true, true, false};
+    T vb(std::begin(ba), std::end(ba));
+    H h;
+    assert(h(vb) != 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::vector<bool, min_allocator<bool>> T;
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    bool ba[] = {true, false, true, true, false};
+    T vb(std::begin(ba), std::end(ba));
+    H h;
+    assert(h(vb) != 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/asan.pass.cpp b/final/test/containers/sequences/vector/asan.pass.cpp
new file mode 100644
index 0000000..86c02b2
--- /dev/null
+++ b/final/test/containers/sequences/vector/asan.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// reference operator[](size_type n);
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" void __asan_set_error_exit_code(int);
+
+int main()
+{
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::vector<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        c.reserve(2*c.size());
+        T foo = c[c.size()];    // bad, but not caught by ASAN
+    }
+#endif
+    
+    __asan_set_error_exit_code(0);
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        c.reserve(2*c.size());
+        assert(is_contiguous_container_asan_correct(c)); 
+        assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity()));
+        T foo = c[c.size()];    // should trigger ASAN
+        assert(false);          // if we got here, ASAN didn't trigger
+    }
+}
+#else
+int main () { return 0; }
+#endif
diff --git a/final/test/containers/sequences/vector/const_value_type.pass.cpp b/final/test/containers/sequences/vector/const_value_type.pass.cpp
new file mode 100644
index 0000000..e16e439
--- /dev/null
+++ b/final/test/containers/sequences/vector/const_value_type.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector<const int> v;  // an extension
+
+#include <vector>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    std::vector<const int> v = {1, 2, 3};
+#endif
+}
diff --git a/final/test/containers/sequences/vector/db_back.pass.cpp b/final/test/containers/sequences/vector/db_back.pass.cpp
new file mode 100644
index 0000000..05f3d07
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_back.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    assert(c.back() == 0);
+    c.clear();
+    assert(c.back() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    assert(c.back() == 0);
+    c.clear();
+    assert(c.back() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_cback.pass.cpp b/final/test/containers/sequences/vector/db_cback.pass.cpp
new file mode 100644
index 0000000..5eb1a35
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_cback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    const C c;
+    assert(c.back() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    const C c;
+    assert(c.back() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_cfront.pass.cpp b/final/test/containers/sequences/vector/db_cfront.pass.cpp
new file mode 100644
index 0000000..5e54da1
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_cfront.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    const C c;
+    assert(c.front() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    const C c;
+    assert(c.front() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_cindex.pass.cpp b/final/test/containers/sequences/vector/db_cindex.pass.cpp
new file mode 100644
index 0000000..133aa56
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_cindex.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index const vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    const C c(1);
+    assert(c[0] == 0);
+    assert(c[1] == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    const C c(1);
+    assert(c[0] == 0);
+    assert(c[1] == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_front.pass.cpp b/final/test/containers/sequences/vector/db_front.pass.cpp
new file mode 100644
index 0000000..388058f
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_front.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    assert(c.front() == 0);
+    c.clear();
+    assert(c.front() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    assert(c.front() == 0);
+    c.clear();
+    assert(c.front() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_index.pass.cpp b/final/test/containers/sequences/vector/db_index.pass.cpp
new file mode 100644
index 0000000..1daf076
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_index.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    assert(c[0] == 0);
+    c.clear();
+    assert(c[0] == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    assert(c[0] == 0);
+    c.clear();
+    assert(c[0] == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_iterators_2.pass.cpp b/final/test/containers/sequences/vector/db_iterators_2.pass.cpp
new file mode 100644
index 0000000..2d43843
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_iterators_2.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c1;
+    C c2;
+    bool b = c1.begin() < c2.begin();
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c1;
+    C c2;
+    bool b = c1.begin() < c2.begin();
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_iterators_3.pass.cpp b/final/test/containers/sequences/vector/db_iterators_3.pass.cpp
new file mode 100644
index 0000000..051d66c
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_iterators_3.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Subtract iterators from different containers.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c1;
+    C c2;
+    int i = c1.begin() - c2.begin();
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c1;
+    C c2;
+    int i = c1.begin() - c2.begin();
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_iterators_4.pass.cpp b/final/test/containers/sequences/vector/db_iterators_4.pass.cpp
new file mode 100644
index 0000000..4c2aa62
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_iterators_4.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    C::iterator i = c.begin();
+    assert(i[0] == 0);
+    assert(i[1] == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.begin();
+    assert(i[0] == 0);
+    assert(i[1] == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_iterators_5.pass.cpp b/final/test/containers/sequences/vector/db_iterators_5.pass.cpp
new file mode 100644
index 0000000..1b10904
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_iterators_5.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    C::iterator i = c.begin();
+    i += 1;
+    assert(i == c.end());
+    i = c.begin();
+    i += 2;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.begin();
+    i += 1;
+    assert(i == c.end());
+    i = c.begin();
+    i += 2;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_iterators_6.pass.cpp b/final/test/containers/sequences/vector/db_iterators_6.pass.cpp
new file mode 100644
index 0000000..424bc93
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_iterators_6.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    C::iterator i = c.end();
+    --i;
+    assert(i == c.begin());
+    --i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.end();
+    --i;
+    assert(i == c.begin());
+    --i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_iterators_7.pass.cpp b/final/test/containers/sequences/vector/db_iterators_7.pass.cpp
new file mode 100644
index 0000000..72cdb10
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/db_iterators_8.pass.cpp b/final/test/containers/sequences/vector/db_iterators_8.pass.cpp
new file mode 100644
index 0000000..7b89853
--- /dev/null
+++ b/final/test/containers/sequences/vector/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::vector<T> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::vector<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/iterators.pass.cpp b/final/test/containers/sequences/vector/iterators.pass.cpp
new file mode 100644
index 0000000..75a0828
--- /dev/null
+++ b/final/test/containers/sequences/vector/iterators.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+struct A
+{
+    int first;
+    int second;
+};
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int T;
+        typedef std::vector<T, min_allocator<T>> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T, min_allocator<T>> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T, min_allocator<T>> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::vector<T, min_allocator<T>> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T, min_allocator<T>> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+    {
+        typedef A T;
+        typedef std::vector<T, min_allocator<T>> C;
+        C c = {A{1, 2}};
+        C::iterator i = c.begin();
+        i->first = 3;
+        C::const_iterator j = i;
+        assert(j->first == 3);
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::vector<int> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+        assert (!(ii1 <  cii ));
+        assert (!(cii <  ii1 ));
+        assert ( (ii1 <= cii ));
+        assert ( (cii <= ii1 ));
+        assert (!(ii1 >  cii ));
+        assert (!(cii >  ii1 ));
+        assert ( (ii1 >= cii ));
+        assert ( (cii >= ii1 ));
+        assert (cii - ii1 == 0);
+        assert (ii1 - cii == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/types.pass.cpp b/final/test/containers/sequences/vector/types.pass.cpp
new file mode 100644
index 0000000..3504de6
--- /dev/null
+++ b/final/test/containers/sequences/vector/types.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class vector
+// {
+// public:
+//     typedef T                                        value_type;
+//     typedef Allocator                                allocator_type;
+//     typedef typename allocator_type::reference       reference;
+//     typedef typename allocator_type::const_reference const_reference;
+//     typedef implementation-defined                   iterator;
+//     typedef implementation-defined                   const_iterator;
+//     typedef typename allocator_type::size_type       size_type;
+//     typedef typename allocator_type::difference_type difference_type;
+//     typedef typename allocator_type::pointer         pointer;
+//     typedef typename allocator_type::const_pointer   const_pointer;
+//     typedef std::reverse_iterator<iterator>          reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+    typedef std::vector<T, Allocator> C;
+
+    static_assert((std::is_same<typename C::value_type, T>::value), "");
+    static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+    static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+    static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+    static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+    static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+    static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename C::reverse_iterator,
+        std::reverse_iterator<typename C::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename C::const_reverse_iterator,
+        std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+    test<int, test_allocator<int> >();
+    test<int*, std::allocator<int*> >();
+    test<Copyable, test_allocator<Copyable> >();
+    static_assert((std::is_same<std::vector<char>::allocator_type,
+                                std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+    static_assert((std::is_same<std::vector<int, min_allocator<int>>::value_type, int>::value), "");
+    static_assert((std::is_same<std::vector<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+    static_assert((std::is_same<std::vector<int, min_allocator<int>>::reference, int&>::value), "");
+    static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_reference, const int&>::value), "");
+    static_assert((std::is_same<std::vector<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+    static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/final/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp
new file mode 100644
index 0000000..21082c8
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.capacity/capacity.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v;
+        assert(v.capacity() == 0);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int> v(100);
+        assert(v.capacity() == 100);
+        v.push_back(0);
+        assert(v.capacity() > 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v;
+        assert(v.capacity() == 0);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        assert(v.capacity() == 100);
+        v.push_back(0);
+        assert(v.capacity() > 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/final/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp
new file mode 100644
index 0000000..4df5702
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.capacity/reserve.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v;
+        v.reserve(10);
+        assert(v.capacity() >= 10);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int> v(100);
+        assert(v.capacity() == 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() == 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() == 150);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int, stack_allocator<int, 250> > v(100);
+        assert(v.capacity() == 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() == 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() == 150);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v;
+        v.reserve(10);
+        assert(v.capacity() >= 10);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        assert(v.capacity() == 100);
+        v.reserve(50);
+        assert(v.size() == 100);
+        assert(v.capacity() == 100);
+        v.reserve(150);
+        assert(v.size() == 100);
+        assert(v.capacity() == 150);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/final/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..a47c513
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<MoveOnly> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<int> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+        v.resize(50);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.resize(200);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/final/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
new file mode 100644
index 0000000..de5126b
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(v == std::vector<int>(50));
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+        for (unsigned i = 0; i < 50; ++i)
+            assert(v[i] == 0);
+        for (unsigned i = 50; i < 200; ++i)
+            assert(v[i] == 1);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert((v == std::vector<int, min_allocator<int>>(50)));
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+        for (unsigned i = 0; i < 50; ++i)
+            assert(v[i] == 0);
+        for (unsigned i = 50; i < 200; ++i)
+            assert(v[i] == 1);
+    }
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        v.resize(50, 1);
+        assert(v.size() == 50);
+        assert(v.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.resize(200, 1);
+        assert(v.size() == 200);
+        assert(v.capacity() >= 200);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/final/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..49ab9cc
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        v.push_back(1);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.shrink_to_fit();
+        assert(v.capacity() == 101);
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int, stack_allocator<int, 401> > v(100);
+        v.push_back(1);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.shrink_to_fit();
+        assert(v.capacity() == 101);
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    {
+        std::vector<int, stack_allocator<int, 400> > v(100);
+        v.push_back(1);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.shrink_to_fit();
+        assert(v.capacity() == 200);
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        v.push_back(1);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v.shrink_to_fit();
+        assert(v.capacity() == 101);
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.capacity/swap.pass.cpp b/final/test/containers/sequences/vector/vector.capacity/swap.pass.cpp
new file mode 100644
index 0000000..f3d9289
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.capacity/swap.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v1(100);
+        std::vector<int> v2(200);
+        assert(is_contiguous_container_asan_correct(v1)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+        v1.swap(v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() == 200);
+        assert(is_contiguous_container_asan_correct(v1)); 
+        assert(v2.size() == 100);
+        assert(v2.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v2)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v1(100);
+        std::vector<int, min_allocator<int>> v2(200);
+        assert(is_contiguous_container_asan_correct(v1)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+        v1.swap(v2);
+        assert(v1.size() == 200);
+        assert(v1.capacity() == 200);
+        assert(is_contiguous_container_asan_correct(v1)); 
+        assert(v2.size() == 100);
+        assert(v2.capacity() == 100);
+        assert(is_contiguous_container_asan_correct(v2)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/final/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
new file mode 100644
index 0000000..6f02c3b
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(5));
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+        std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+        l2 = l;
+        assert(l2 == l);
+        assert(l2.get_allocator() == min_allocator<int>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/final/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 0000000..f5c06b1
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<int> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<int, min_allocator<int>> d;
+    d.assign({3, 4, 5, 6});
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/final/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp
new file mode 100644
index 0000000..d87ac86
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/assign_move.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+    {
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+        std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+        l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/final/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp
new file mode 100644
index 0000000..75772be
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/construct_default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test0()
+{
+    C c;
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == typename C::allocator_type());
+    assert(is_contiguous_container_asan_correct(c)); 
+#if __cplusplus >= 201103L
+    C c1 = {};
+    assert(c1.__invariants());
+    assert(c1.empty());
+    assert(c1.get_allocator() == typename C::allocator_type());
+    assert(is_contiguous_container_asan_correct(c1)); 
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+    C c(a);
+    assert(c.__invariants());
+    assert(c.empty());
+    assert(c.get_allocator() == a);
+    assert(is_contiguous_container_asan_correct(c)); 
+}
+
+int main()
+{
+    {
+    test0<std::vector<int> >();
+    test0<std::vector<NotConstructible> >();
+    test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3));
+    test1<std::vector<NotConstructible, test_allocator<NotConstructible> > >
+        (test_allocator<NotConstructible>(5));
+    }
+    {
+        std::vector<int, stack_allocator<int, 10> > v;
+        assert(v.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+    test0<std::vector<int, min_allocator<int>> >();
+    test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
+    test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{});
+    test1<std::vector<NotConstructible, min_allocator<NotConstructible> > >
+        (min_allocator<NotConstructible>{});
+    }
+    {
+        std::vector<int, min_allocator<int> > v;
+        assert(v.empty());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/final/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
new file mode 100644
index 0000000..36e231a
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+    C c(first, last);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    assert(is_contiguous_container_asan_correct(c)); 
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+int main()
+{
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+    test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+    test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+    test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+    test<std::vector<int> >(a, an);
+
+    test<std::vector<int, stack_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+    test<std::vector<int, stack_allocator<int, 18> > >(a, an);
+#if __cplusplus >= 201103L
+    test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+    test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+    test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+    test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+    test<std::vector<int> >(a, an);
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/final/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 0000000..7fa748a
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+//                                   const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C, class Iterator, class A>
+void
+test(Iterator first, Iterator last, const A& a)
+{
+    C c(first, last, a);
+    assert(c.__invariants());
+    assert(c.size() == std::distance(first, last));
+    assert(is_contiguous_container_asan_correct(c)); 
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+        assert(*i == *first);
+}
+
+#if __cplusplus >= 201103L
+
+template <class T>
+struct implicit_conv_allocator : min_allocator<T>
+{
+    implicit_conv_allocator(void* p) {}
+    implicit_conv_allocator(const implicit_conv_allocator&) = default;
+};
+
+#endif
+
+int main()
+{
+    {
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    std::allocator<int> alloc;
+    test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+    test<std::vector<int> >(a, an, alloc);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+    int* an = a + sizeof(a)/sizeof(a[0]);
+    min_allocator<int> alloc;
+    test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+    test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+    test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+    test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+    test<std::vector<int, min_allocator<int>> >(a, an, alloc);
+    test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/final/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp
new file mode 100644
index 0000000..e033895
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/construct_size.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ())
+{
+#if _LIBCPP_STD_VER > 11
+    C c(n, a);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    assert(c.get_allocator() == a);
+    assert(is_contiguous_container_asan_correct(c)); 
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == typename C::value_type());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
+
+template <class C>
+void
+test1(typename C::size_type n)
+{
+    C c(n);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    assert(c.get_allocator() == typename C::allocator_type());
+    assert(is_contiguous_container_asan_correct(c)); 
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == typename C::value_type());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+    test1<C> ( n );
+    test2<C> ( n );
+}
+
+int main()
+{
+    test<std::vector<int> >(50);
+    test<std::vector<DefaultOnly> >(500);
+    assert(DefaultOnly::count == 0);
+#if __cplusplus >= 201103L
+    test<std::vector<int, min_allocator<int>> >(50);
+    test<std::vector<DefaultOnly, min_allocator<DefaultOnly>> >(500);
+    test2<std::vector<DefaultOnly, test_allocator<DefaultOnly>> >( 100, test_allocator<DefaultOnly>(23));
+    assert(DefaultOnly::count == 0);
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/final/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
new file mode 100644
index 0000000..5b6c498
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+    C c(n, x);
+    assert(c.__invariants());
+    assert(c.size() == n);
+    assert(is_contiguous_container_asan_correct(c)); 
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<int> >(50, 3);
+    test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
+#if __cplusplus >= 201103L
+    test<std::vector<int, min_allocator<int>> >(50, 3);
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/final/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
new file mode 100644
index 0000000..c62b841
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+     const typename C::allocator_type& a)
+{
+    C c(n, x, a);
+    assert(c.__invariants());
+    assert(a == c.get_allocator());
+    assert(c.size() == n);
+    assert(is_contiguous_container_asan_correct(c)); 
+    for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+        assert(*i == x);
+}
+
+int main()
+{
+    test<std::vector<int> >(50, 3, std::allocator<int>());
+#if __cplusplus >= 201103L
+    test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/copy.pass.cpp b/final/test/containers/sequences/vector/vector.cons/copy.pass.cpp
new file mode 100644
index 0000000..677963d
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(const C& x)
+{
+    unsigned s = x.size();
+    C c(x);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+    assert(is_contiguous_container_asan_correct(c)); 
+}
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<int>(a, an));
+    }
+    {
+        std::vector<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+        std::vector<int, test_allocator<int> > v2 = v;
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        std::vector<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+        std::vector<int, other_allocator<int> > v2 = v;
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+        assert(v2 == v);
+        assert(v2.get_allocator() == other_allocator<int>(-2));
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<int, min_allocator<int>>(a, an));
+    }
+    {
+        std::vector<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+        std::vector<int, min_allocator<int> > v2 = v;
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+        assert(v2 == v);
+        assert(v2.get_allocator() == v.get_allocator());
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(is_contiguous_container_asan_correct(v2)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/final/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..128328c
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+    unsigned s = x.size();
+    C c(x, a);
+    assert(c.__invariants());
+    assert(c.size() == s);
+    assert(c == x);
+    assert(is_contiguous_container_asan_correct(c)); 
+}
+
+int main()
+{
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<int>(a, an), std::allocator<int>());
+    }
+    {
+        std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+        std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == test_allocator<int>(3));
+    }
+    {
+        std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+        std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+        assert(l2 == l);
+        assert(l2.get_allocator() == other_allocator<int>(3));
+    }
+#if __cplusplus >= 201103L
+    {
+        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+        int* an = a + sizeof(a)/sizeof(a[0]);
+        test(std::vector<int, min_allocator<int>>(a, an), min_allocator<int>());
+    }
+    {
+        std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+        std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+        assert(l2 == l);
+        assert(l2.get_allocator() == min_allocator<int>());
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/default.recursive.pass.cpp b/final/test/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
new file mode 100644
index 0000000..1a4a189
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// class vector
+// vector();
+
+#include <vector>
+
+struct X
+{
+    std::vector<X> q;
+};
+
+int main()
+{
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp b/final/test/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..3fc33b6
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector()
+//        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/final/test/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..0d73e9e
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// ~vector() // implied noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+    ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/final/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..7eb834f
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<int> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<int, min_allocator<int>> d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/final/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 0000000..5d7ae88
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+    assert(d.get_allocator() == test_allocator<int>(3));
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+    assert(d.get_allocator() == min_allocator<int>());
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/move.pass.cpp b/final/test/containers/sequences/vector/vector.cons/move.pass.cpp
new file mode 100644
index 0000000..bb61d54
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/move.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+    {
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        std::vector<int>::const_iterator i = c1.begin();
+        std::vector<int> c2 = std::move(c1);
+        assert(is_contiguous_container_asan_correct(c2)); 
+        std::vector<int>::iterator j = c2.erase(i);
+        assert(*j == 3);
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+        std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == lo.get_allocator());
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
+        std::vector<int, min_allocator<int>> c2 = std::move(c1);
+        assert(is_contiguous_container_asan_correct(c2)); 
+        std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
+        assert(*j == 3);
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/final/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..1923e68
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+    {
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+    {
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+        std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+        assert(l2 == lo);
+        assert(!l.empty());
+        assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+        std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        for (int i = 1; i <= 3; ++i)
+        {
+            l.push_back(i);
+            lo.push_back(i);
+        }
+        assert(is_contiguous_container_asan_correct(l)); 
+        assert(is_contiguous_container_asan_correct(lo)); 
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+        assert(l2 == lo);
+        assert(l.empty());
+        assert(l2.get_allocator() == min_allocator<MoveOnly>());
+        assert(is_contiguous_container_asan_correct(l2)); 
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp b/final/test/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..158370f
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp b/final/test/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..a2e36cc
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/final/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 0000000..592b714
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<int> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<int, min_allocator<int>> d;
+    d = {3, 4, 5, 6};
+    assert(d.size() == 4);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(d[0] == 3);
+    assert(d[1] == 4);
+    assert(d[2] == 5);
+    assert(d[3] == 6);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector/vector.data/data.pass.cpp b/final/test/containers/sequences/vector/vector.data/data.pass.cpp
new file mode 100644
index 0000000..aed56bc
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.data/data.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// pointer data();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v;
+        assert(v.data() == 0);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int> v(100);
+        assert(v.data() == &v.front());
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v;
+        assert(v.data() == 0);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        assert(v.data() == &v.front());
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.data/data_const.pass.cpp b/final/test/containers/sequences/vector/vector.data/data_const.pass.cpp
new file mode 100644
index 0000000..cb60626
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.data/data_const.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// const_pointer data() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        const std::vector<int> v;
+        assert(v.data() == 0);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        const std::vector<int> v(100);
+        assert(v.data() == &v.front());
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        const std::vector<int, min_allocator<int>> v;
+        assert(v.data() == 0);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        const std::vector<int, min_allocator<int>> v(100);
+        assert(v.data() == &v.front());
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..8af6bda
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    A(A&& a)
+        : i_(a.i_),
+          d_(a.d_)
+    {
+        a.i_ = 0;
+        a.d_ = 0;
+    }
+
+    A& operator=(A&& a)
+    {
+        i_ = a.i_;
+        d_ = a.d_;
+        a.i_ = 0;
+        a.d_ = 0;
+        return *this;
+    }
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<A> c;
+        std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+        assert(i == c.begin());
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        i = c.emplace(c.cend(), 3, 4.5);
+        assert(i == c.end()-1);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        i = c.emplace(c.cbegin()+1, 4, 6.5);
+        assert(i == c.begin()+1);
+        assert(c.size() == 3);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c[1].geti() == 4);
+        assert(c[1].getd() == 6.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+    }
+    {
+        std::vector<A, stack_allocator<A, 7> > c;
+        std::vector<A, stack_allocator<A, 7> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+        assert(i == c.begin());
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        i = c.emplace(c.cend(), 3, 4.5);
+        assert(i == c.end()-1);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        i = c.emplace(c.cbegin()+1, 4, 6.5);
+        assert(i == c.begin()+1);
+        assert(c.size() == 3);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c[1].geti() == 4);
+        assert(c[1].getd() == 6.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<A> c1;
+        std::vector<A> c2;
+        std::vector<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::vector<A, min_allocator<A>> c;
+        std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+        assert(i == c.begin());
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        i = c.emplace(c.cend(), 3, 4.5);
+        assert(i == c.end()-1);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        i = c.emplace(c.cbegin()+1, 4, 6.5);
+        assert(i == c.begin()+1);
+        assert(c.size() == 3);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c[1].geti() == 4);
+        assert(c[1].getd() == 6.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<A, min_allocator<A>> c1;
+        std::vector<A, min_allocator<A>> c2;
+        std::vector<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+        assert(false);
+    }
+#endif
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
new file mode 100644
index 0000000..bbf91a4
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+    int i_;
+    double d_;
+
+    A(const A&);
+    A& operator=(const A&);
+public:
+    A(int i, double d)
+        : i_(i), d_(d) {}
+
+    A(A&& a)
+        : i_(a.i_),
+          d_(a.d_)
+    {
+        a.i_ = 0;
+        a.d_ = 0;
+    }
+
+    A& operator=(A&& a)
+    {
+        i_ = a.i_;
+        d_ = a.d_;
+        a.i_ = 0;
+        a.d_ = 0;
+        return *this;
+    }
+
+    int geti() const {return i_;}
+    double getd() const {return d_;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<A> c;
+        c.emplace_back(2, 3.5);
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        c.emplace_back(3, 4.5);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+    }
+    {
+        std::vector<A, stack_allocator<A, 4> > c;
+        c.emplace_back(2, 3.5);
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        c.emplace_back(3, 4.5);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<A, min_allocator<A>> c;
+        c.emplace_back(2, 3.5);
+        assert(c.size() == 1);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        c.emplace_back(3, 4.5);
+        assert(c.size() == 2);
+        assert(c.front().geti() == 2);
+        assert(c.front().getd() == 3.5);
+        assert(c.back().geti() == 3);
+        assert(c.back().getd() == 4.5);
+        assert(is_contiguous_container_asan_correct(c)); 
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
new file mode 100644
index 0000000..85a4707
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::vector<int> v;
+        v.reserve(3);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v = { 1, 2, 3 };
+        v.emplace(v.begin(), v.back());
+        assert(v[0] == 3);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int> v;
+        v.reserve(4);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v = { 1, 2, 3 };
+        v.emplace(v.begin(), v.back());
+        assert(v[0] == 3);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v;
+        v.reserve(3);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v = { 1, 2, 3 };
+        v.emplace(v.begin(), v.back());
+        assert(v[0] == 3);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+    {
+        std::vector<int, min_allocator<int>> v;
+        v.reserve(4);
+        assert(is_contiguous_container_asan_correct(v)); 
+        v = { 1, 2, 3 };
+        v.emplace(v.begin(), v.back());
+        assert(v[0] == 3);
+        assert(is_contiguous_container_asan_correct(v)); 
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
new file mode 100644
index 0000000..7a850ed
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int>::const_iterator i = l1.begin();
+    assert(is_contiguous_container_asan_correct(l1)); 
+    ++i;
+    std::vector<int>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == 3);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == 3);
+    assert(is_contiguous_container_asan_correct(l1)); 
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == 1);
+    assert(is_contiguous_container_asan_correct(l1)); 
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+    assert(is_contiguous_container_asan_correct(l1)); 
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int, min_allocator<int>> l1(a1, a1+3);
+    std::vector<int, min_allocator<int>>::const_iterator i = l1.begin();
+    assert(is_contiguous_container_asan_correct(l1)); 
+    ++i;
+    std::vector<int, min_allocator<int>>::iterator j = l1.erase(i);
+    assert(l1.size() == 2);
+    assert(distance(l1.begin(), l1.end()) == 2);
+    assert(*j == 3);
+    assert(*l1.begin() == 1);
+    assert(*next(l1.begin()) == 3);
+    assert(is_contiguous_container_asan_correct(l1)); 
+    j = l1.erase(j);
+    assert(j == l1.end());
+    assert(l1.size() == 1);
+    assert(distance(l1.begin(), l1.end()) == 1);
+    assert(*l1.begin() == 1);
+    assert(is_contiguous_container_asan_correct(l1)); 
+    j = l1.erase(l1.begin());
+    assert(j == l1.end());
+    assert(l1.size() == 0);
+    assert(distance(l1.begin(), l1.end()) == 0);
+    assert(is_contiguous_container_asan_correct(l1)); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000..0478d24
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int, min_allocator<int>> l1(a1, a1+3);
+    std::vector<int, min_allocator<int>>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000..c394f19
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int> l2(a1, a1+3);
+    std::vector<int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int, min_allocator<int>> l1(a1, a1+3);
+    std::vector<int, min_allocator<int>> l2(a1, a1+3);
+    std::vector<int, min_allocator<int>>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 0000000..bfc18bc
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    int a1[] = {1, 2, 3};
+    {
+        std::vector<int> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<int> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<int>(a1+1, a1+3));
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<int> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert(l1 == std::vector<int>(a1+2, a1+3));
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<int> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<std::vector<int> > outer(2, std::vector<int>(1));
+        assert(is_contiguous_container_asan_correct(outer)); 
+        assert(is_contiguous_container_asan_correct(outer[0])); 
+        assert(is_contiguous_container_asan_correct(outer[1])); 
+        outer.erase(outer.begin(), outer.begin());
+        assert(outer.size() == 2);
+        assert(outer[0].size() == 1);
+        assert(outer[1].size() == 1);
+        assert(is_contiguous_container_asan_correct(outer)); 
+        assert(is_contiguous_container_asan_correct(outer[0])); 
+        assert(is_contiguous_container_asan_correct(outer[1])); 
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+        assert(l1.size() == 3);
+        assert(distance(l1.cbegin(), l1.cend()) == 3);
+        assert(i == l1.begin());
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<int, min_allocator<int>> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+        assert(l1.size() == 2);
+        assert(distance(l1.cbegin(), l1.cend()) == 2);
+        assert(i == l1.begin());
+        assert((l1 == std::vector<int, min_allocator<int>>(a1+1, a1+3)));
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<int, min_allocator<int>> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+        assert(l1.size() == 1);
+        assert(distance(l1.cbegin(), l1.cend()) == 1);
+        assert(i == l1.begin());
+        assert((l1 == std::vector<int, min_allocator<int>>(a1+2, a1+3)));
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<int, min_allocator<int>> l1(a1, a1+3);
+        assert(is_contiguous_container_asan_correct(l1)); 
+        std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+        assert(l1.size() == 0);
+        assert(distance(l1.cbegin(), l1.cend()) == 0);
+        assert(i == l1.begin());
+        assert(is_contiguous_container_asan_correct(l1)); 
+    }
+    {
+        std::vector<std::vector<int, min_allocator<int>>, min_allocator<std::vector<int, min_allocator<int>>>> outer(2, std::vector<int, min_allocator<int>>(1));
+        assert(is_contiguous_container_asan_correct(outer)); 
+        assert(is_contiguous_container_asan_correct(outer[0])); 
+        assert(is_contiguous_container_asan_correct(outer[1])); 
+        outer.erase(outer.begin(), outer.begin());
+        assert(outer.size() == 2);
+        assert(outer[0].size() == 1);
+        assert(outer[1].size() == 1);
+        assert(is_contiguous_container_asan_correct(outer)); 
+        assert(is_contiguous_container_asan_correct(outer[0])); 
+        assert(is_contiguous_container_asan_correct(outer[1])); 
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000..af6d0f7
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int> l2(a1, a1+3);
+    std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int, min_allocator<int>> l1(a1, a1+3);
+    std::vector<int, min_allocator<int>> l2(a1, a1+3);
+    std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000..eee2c66
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int> l2(a1, a1+3);
+    std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int, min_allocator<int>> l1(a1, a1+3);
+    std::vector<int, min_allocator<int>> l2(a1, a1+3);
+    std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000..505067d
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int> l2(a1, a1+3);
+    std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int, min_allocator<int>> l1(a1, a1+3);
+    std::vector<int, min_allocator<int>> l2(a1, a1+3);
+    std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000..c7e4131
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int> l1(a1, a1+3);
+    std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    int a1[] = {1, 2, 3};
+    std::vector<int, min_allocator<int>> l1(a1, a1+3);
+    std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..30b8017
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+    std::vector<int> d(10, 1);
+    std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(i == d.begin() + 2);
+    assert(d[0] == 1);
+    assert(d[1] == 1);
+    assert(d[2] == 3);
+    assert(d[3] == 4);
+    assert(d[4] == 5);
+    assert(d[5] == 6);
+    assert(d[6] == 1);
+    assert(d[7] == 1);
+    assert(d[8] == 1);
+    assert(d[9] == 1);
+    assert(d[10] == 1);
+    assert(d[11] == 1);
+    assert(d[12] == 1);
+    assert(d[13] == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+    std::vector<int, min_allocator<int>> d(10, 1);
+    std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+    assert(d.size() == 14);
+    assert(is_contiguous_container_asan_correct(d)); 
+    assert(i == d.begin() + 2);
+    assert(d[0] == 1);
+    assert(d[1] == 1);
+    assert(d[2] == 3);
+    assert(d[3] == 4);
+    assert(d[4] == 5);
+    assert(d[5] == 6);
+    assert(d[6] == 1);
+    assert(d[7] == 1);
+    assert(d[8] == 1);
+    assert(d[9] == 1);
+    assert(d[10] == 1);
+    assert(d[11] == 1);
+    assert(d[12] == 1);
+    assert(d[13] == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..cf24a87
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class Iter>
+//   iterator insert(const_iterator position, Iter first, Iter last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int> v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+                                        forward_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 308> > v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+                                        forward_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int> v(100);
+        std::vector<int> v2(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+                                        forward_iterator<const int*>(a+N));
+        assert(v.size() == 100 + N);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (int k = 0; k < N; ++j, ++k)
+            assert(v[j] == a[k]);
+        for (; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        std::vector<int, min_allocator<int>> v2(100);
+        int a[] = {1, 2, 3, 4, 5};
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::vector<int, min_allocator<int>>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+                                        input_iterator<const int*>(a+N));
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 0000000..cf3715c
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<MoveOnly> v(100);
+        std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == MoveOnly());
+        assert(v[j] == MoveOnly(3));
+        for (++j; j < 101; ++j)
+            assert(v[j] == MoveOnly());
+    }
+    {
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == MoveOnly());
+        assert(v[j] == MoveOnly(3));
+        for (++j; j < 101; ++j)
+            assert(v[j] == MoveOnly());
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int> v1(3);
+        std::vector<int> v2(3);
+        v1.insert(v2.begin(), 4);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+        std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == MoveOnly());
+        assert(v[j] == MoveOnly(3));
+        for (++j; j < 101; ++j)
+            assert(v[j] == MoveOnly());
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int, min_allocator<int>> v1(3);
+        std::vector<int, min_allocator<int>> v2(3);
+        v1.insert(v2.begin(), 4);
+        assert(false);
+    }
+#endif
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 0000000..42effc7
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int> c1(100);
+        std::vector<int> c2;
+        std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+        assert(v.size() == 105);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        for (; j < 15; ++j)
+            assert(v[j] == 1);
+        for (++j; j < 105; ++j)
+            assert(v[j] == 0);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int, min_allocator<int>> c1(100);
+        std::vector<int, min_allocator<int>> c2;
+        std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 0000000..feb74c0
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> v(100);
+        std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+    {
+        std::vector<int, stack_allocator<int, 300> > v(100);
+        std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int> v1(3);
+        std::vector<int> v2(3);
+        int i = 4;
+        v1.insert(v2.begin(), i);
+        assert(false);
+    }
+#endif
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> v(100);
+        std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 1);
+        assert(v.size() == 101);
+        assert(is_contiguous_container_asan_correct(v)); 
+        assert(i == v.begin() + 10);
+        int j;
+        for (j = 0; j < 10; ++j)
+            assert(v[j] == 0);
+        assert(v[j] == 1);
+        for (++j; j < 101; ++j)
+            assert(v[j] == 0);
+    }
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::vector<int, min_allocator<int>> v1(3);
+        std::vector<int, min_allocator<int>> v2(3);
+        int i = 4;
+        v1.insert(v2.begin(), i);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
new file mode 100644
index 0000000..62fa601
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+#if _LIBCPP_DEBUG >= 1
+#include <cstdlib>
+#include <exception>
+
+#endif
+
+int main()
+{
+    {
+        std::vector<int> c;
+        c.push_back(1);
+        assert(c.size() == 1);
+        c.pop_back();
+        assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+        c.pop_back();
+        assert(false);
+#endif        
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> c;
+        c.push_back(1);
+        assert(c.size() == 1);
+        c.pop_back();
+        assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+        c.pop_back();
+        assert(false);
+#endif        
+    }
+#endif        
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
new file mode 100644
index 0000000..eeeba62
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        std::vector<int> c;
+        c.push_back(0);
+        assert(c.size() == 1);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(1);
+        assert(c.size() == 2);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(2);
+        assert(c.size() == 3);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(3);
+        assert(c.size() == 4);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(4);
+        assert(c.size() == 5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+    }
+    {
+        std::vector<int, stack_allocator<int, 15> > c;
+        c.push_back(0);
+        assert(c.size() == 1);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(1);
+        assert(c.size() == 2);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(2);
+        assert(c.size() == 3);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(3);
+        assert(c.size() == 4);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(4);
+        assert(c.size() == 5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<int, min_allocator<int>> c;
+        c.push_back(0);
+        assert(c.size() == 1);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(1);
+        assert(c.size() == 2);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(2);
+        assert(c.size() == 3);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(3);
+        assert(c.size() == 4);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+        c.push_back(4);
+        assert(c.size() == 5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == j);
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 0000000..6615a25
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "asan_testing.h"
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+    public: CMyClass(int tag);
+    public: CMyClass(const CMyClass& iOther);
+    public: ~CMyClass();
+
+    bool equal(const CMyClass &rhs) const
+        { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+    private:
+        int fMagicValue;
+        int fTag;
+        
+    private: static int kStartedConstructionMagicValue;
+    private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+    fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+    fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+    // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+    if (gCopyConstructorShouldThow) {
+        throw std::exception();
+    }
+    // Signal that the constructor has finished running
+    fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+    // Only instances for which the constructor has finished running should be destructed
+    assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+    CMyClass instance(42);
+    std::vector<CMyClass> vec;
+
+    vec.push_back(instance);
+    std::vector<CMyClass> vec2(vec);
+    assert(is_contiguous_container_asan_correct(vec)); 
+    assert(is_contiguous_container_asan_correct(vec2)); 
+
+    gCopyConstructorShouldThow = true;
+    try {
+        vec.push_back(instance);
+    }
+    catch (...) {
+        assert(vec==vec2);
+        assert(is_contiguous_container_asan_correct(vec)); 
+    }
+}
diff --git a/final/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/final/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 0000000..be48893
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(value_type&& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::vector<MoveOnly> c;
+        c.push_back(MoveOnly(0));
+        assert(c.size() == 1);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(1));
+        assert(c.size() == 2);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(2));
+        assert(c.size() == 3);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(3));
+        assert(c.size() == 4);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(4));
+        assert(c.size() == 5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+    }
+    {
+        std::vector<MoveOnly, stack_allocator<MoveOnly, 15> > c;
+        c.push_back(MoveOnly(0));
+        assert(c.size() == 1);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(1));
+        assert(c.size() == 2);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(2));
+        assert(c.size() == 3);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(3));
+        assert(c.size() == 4);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(4));
+        assert(c.size() == 5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+    }
+#if __cplusplus >= 201103L
+    {
+        std::vector<MoveOnly, min_allocator<MoveOnly>> c;
+        c.push_back(MoveOnly(0));
+        assert(c.size() == 1);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(1));
+        assert(c.size() == 2);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(2));
+        assert(c.size() == 3);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(3));
+        assert(c.size() == 4);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+        c.push_back(MoveOnly(4));
+        assert(c.size() == 5);
+        assert(is_contiguous_container_asan_correct(c)); 
+        for (int j = 0; j < c.size(); ++j)
+            assert(c[j] == MoveOnly(j));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp b/final/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
new file mode 100644
index 0000000..e7f6a00
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+//   void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::vector<int>::iterator i1 = c1.begin();
+        std::vector<int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        c1.erase(i1);
+        assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
+        std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.special/swap.pass.cpp b/final/test/containers/sequences/vector/vector.special/swap.pass.cpp
new file mode 100644
index 0000000..27001ae
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.special/swap.pass.cpp
@@ -0,0 +1,187 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+//   void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1);
+        std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int> c2(a2, a2);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int> c1(a1, a1);
+        std::vector<int> c2(a2, a2);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef test_allocator<int> A;
+        std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        swap(c1, c2);
+        assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(1));
+        assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(2));
+    }
+#endif
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef other_allocator<int> A;
+        std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+        std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A(2));
+        assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A(1));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+#if __cplusplus >= 201103L
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int, min_allocator<int>> c1(a1, a1);
+        std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int, min_allocator<int>> c2(a2, a2);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::vector<int, min_allocator<int>> c1(a1, a1);
+        std::vector<int, min_allocator<int>> c2(a2, a2);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert(c1.empty());
+        assert(distance(c1.begin(), c1.end()) == 0);
+        assert(c2.empty());
+        assert(distance(c2.begin(), c2.end()) == 0);
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        typedef min_allocator<int> A;
+        std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+        std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+        swap(c1, c2);
+        assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+        assert(c1.get_allocator() == A());
+        assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+        assert(c2.get_allocator() == A());
+        assert(is_contiguous_container_asan_correct(c1)); 
+        assert(is_contiguous_container_asan_correct(c2)); 
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/final/test/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..996712a
--- /dev/null
+++ b/final/test/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    
+    some_alloc() {}
+    some_alloc(const some_alloc&);
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::vector<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/sequences/vector/version.pass.cpp b/final/test/containers/sequences/vector/version.pass.cpp
new file mode 100644
index 0000000..2c4fa12
--- /dev/null
+++ b/final/test/containers/sequences/vector/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/stack_allocator.h b/final/test/containers/stack_allocator.h
new file mode 100644
index 0000000..d5fab02
--- /dev/null
+++ b/final/test/containers/stack_allocator.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 STACK_ALLOCATOR_H
+#define STACK_ALLOCATOR_H
+
+#include <cstddef>
+#include <new>
+
+template <class T, std::size_t N>
+class stack_allocator
+{
+    char buf_[sizeof(T)*N];
+    char* ptr_;
+public:
+    typedef T                 value_type;
+    typedef value_type*       pointer;
+    typedef const value_type* const_pointer;
+    typedef value_type&       reference;
+    typedef const value_type& const_reference;
+    typedef std::size_t       size_type;
+    typedef std::ptrdiff_t    difference_type;
+
+    template <class U> struct rebind {typedef stack_allocator<U, N> other;};
+
+    stack_allocator() : ptr_(buf_) {}
+
+private:
+    stack_allocator(const stack_allocator&);// = delete;
+    stack_allocator& operator=(const stack_allocator&);// = delete;
+
+public:
+    pointer allocate(size_type n, const void* = 0)
+    {
+        if (n > N - (ptr_ - buf_) / sizeof(value_type)) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+            throw std::bad_alloc();
+#else
+            std::terminate();
+#endif
+        }
+        pointer r = (T*)ptr_;
+        ptr_ += n * sizeof(T);
+        return r;
+    }
+    void deallocate(pointer p, size_type n)
+    {
+        if ((char*)(p + n) == ptr_)
+            ptr_ = (char*)p;
+    }
+
+    size_type max_size() const {return N;}
+};
+
+template <class T, std::size_t N>
+inline
+void
+swap(stack_allocator<T, N>& x, stack_allocator<T, N>& y) {}
+
+#endif  // STACK_ALLOCATOR_H
diff --git a/final/test/containers/test_compare.h b/final/test/containers/test_compare.h
new file mode 100644
index 0000000..9c54799
--- /dev/null
+++ b/final/test/containers/test_compare.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 TEST_COMPARE_H
+#define TEST_COMPARE_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+template <class C>
+class test_compare
+    : private C
+{
+    int data_;
+public:
+    explicit test_compare(int data = 0) : data_(data) {}
+
+    typename C::result_type
+    operator()(typename std::add_lvalue_reference<const typename C::first_argument_type>::type x,
+               typename std::add_lvalue_reference<const typename C::second_argument_type>::type y) const
+        {return C::operator()(x, y);}
+
+    bool operator==(const test_compare& c) const
+        {return data_ == c.data_;}
+};
+
+#endif  // TEST_COMPARE_H
diff --git a/final/test/containers/test_hash.h b/final/test/containers/test_hash.h
new file mode 100644
index 0000000..1a70e7c
--- /dev/null
+++ b/final/test/containers/test_hash.h
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 TEST_HASH_H
+#define TEST_HASH_H
+
+#include <cstddef>
+#include <type_traits>
+
+template <class C>
+class test_hash
+    : private C
+{
+    int data_;
+public:
+    explicit test_hash(int data = 0) : data_(data) {}
+
+    std::size_t
+    operator()(typename std::add_lvalue_reference<const typename C::argument_type>::type x) const
+        {return C::operator()(x);}
+
+    bool operator==(const test_hash& c) const
+        {return data_ == c.data_;}
+};
+
+#endif  // TEST_HASH_H
diff --git a/final/test/containers/unord/next_prime.pass.cpp b/final/test/containers/unord/next_prime.pass.cpp
new file mode 100644
index 0000000..217cd18
--- /dev/null
+++ b/final/test/containers/unord/next_prime.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_prime(size_t n);
+
+// If n == 0, return 0, else return the lowest prime greater than or equal to n
+
+#include <__hash_table>
+#include <cassert>
+
+bool
+is_prime(size_t n)
+{
+    switch (n)
+    {
+    case 0:
+    case 1:
+        return false;
+    }
+    for (size_t i = 2; i*i <= n; ++i)
+    {
+        if (n % i == 0)
+            return false;
+    }
+    return true;
+}
+
+int main()
+{
+    assert(std::__next_prime(0) == 0);
+    for (std::size_t n = 1; n <= 100000; ++n)
+    {
+        std::size_t p = std::__next_prime(n);
+        assert(p >= n);
+        for (std::size_t i = n; i < p; ++i)
+            assert(!is_prime(i));
+        assert(is_prime(p));
+    }
+}
diff --git a/final/test/containers/unord/unord.map/bucket.pass.cpp b/final/test/containers/unord/unord.map/bucket.pass.cpp
new file mode 100644
index 0000000..6837294
--- /dev/null
+++ b/final/test/containers/unord/unord.map/bucket.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 5);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 5);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_map<int, std::string> C;
+        C c;
+        C::size_type i = c.bucket(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/bucket_count.pass.cpp b/final/test/containers/unord/unord.map/bucket_count.pass.cpp
new file mode 100644
index 0000000..d3e80d8
--- /dev/null
+++ b/final/test/containers/unord/unord.map/bucket_count.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/bucket_size.pass.cpp b/final/test/containers/unord/unord.map/bucket_size.pass.cpp
new file mode 100644
index 0000000..f3ab8ff
--- /dev/null
+++ b/final/test/containers/unord/unord.map/bucket_size.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 5);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 1);
+        assert(c.bucket_size(2) == 1);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 5);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 1);
+        assert(c.bucket_size(2) == 1);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_map<int, std::string> C;
+        C c;
+        C::size_type i = c.bucket_size(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/compare.pass.cpp b/final/test/containers/unord/unord.map/compare.pass.cpp
new file mode 100644
index 0000000..8979a3a
--- /dev/null
+++ b/final/test/containers/unord/unord.map/compare.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// http://llvm.org/bugs/show_bug.cgi?id=16538
+// http://llvm.org/bugs/show_bug.cgi?id=16549
+
+#include <unordered_map>
+
+struct Key {
+  template <typename T> Key(const T&) {}
+  bool operator== (const Key&) const { return true; }
+};
+
+namespace std
+{
+    template <>
+    struct hash<Key>
+    {
+        size_t operator()(Key const &) const {return 0;}
+    };
+}
+
+int
+main()
+{
+    std::unordered_map<Key, int>::iterator it =
+        std::unordered_map<Key, int>().find(Key(0));
+    std::pair<std::unordered_map<Key, int>::iterator, bool> result =
+        std::unordered_map<Key, int>().insert(std::make_pair(Key(0), 0));
+}
diff --git a/final/test/containers/unord/unord.map/count.pass.cpp b/final/test/containers/unord/unord.map/count.pass.cpp
new file mode 100644
index 0000000..50abb53
--- /dev/null
+++ b/final/test/containers/unord/unord.map/count.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(5) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(5) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/db_iterators_7.pass.cpp b/final/test/containers/unord/unord.map/db_iterators_7.pass.cpp
new file mode 100644
index 0000000..b8db0a3
--- /dev/null
+++ b/final/test/containers/unord/unord.map/db_iterators_7.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/db_iterators_8.pass.cpp b/final/test/containers/unord/unord.map/db_iterators_8.pass.cpp
new file mode 100644
index 0000000..c923dd7
--- /dev/null
+++ b/final/test/containers/unord/unord.map/db_iterators_8.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.end();
+    C::value_type j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.end();
+    C::value_type j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp b/final/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp
new file mode 100644
index 0000000..fa1886b
--- /dev/null
+++ b/final/test/containers/unord/unord.map/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp b/final/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp
new file mode 100644
index 0000000..4b071ca
--- /dev/null
+++ b/final/test/containers/unord/unord.map/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_map<int, std::string> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    C::value_type j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    C::value_type j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/eq.pass.cpp b/final/test/containers/unord/unord.map/eq.pass.cpp
new file mode 100644
index 0000000..9258378
--- /dev/null
+++ b/final/test/containers/unord/unord.map/eq.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90, "ninety"));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90, "ninety"));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90, "ninety"));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90, "ninety"));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/equal_range_const.pass.cpp b/final/test/containers/unord/unord.map/equal_range_const.pass.cpp
new file mode 100644
index 0000000..fe166c9
--- /dev/null
+++ b/final/test/containers/unord/unord.map/equal_range_const.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/equal_range_non_const.pass.cpp b/final/test/containers/unord/unord.map/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..9e8d1a9
--- /dev/null
+++ b/final/test/containers/unord/unord.map/equal_range_non_const.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/find_const.pass.cpp b/final/test/containers/unord/unord.map/find_const.pass.cpp
new file mode 100644
index 0000000..120efa3
--- /dev/null
+++ b/final/test/containers/unord/unord.map/find_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/find_non_const.pass.cpp b/final/test/containers/unord/unord.map/find_non_const.pass.cpp
new file mode 100644
index 0000000..7582a79
--- /dev/null
+++ b/final/test/containers/unord/unord.map/find_non_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/iterators.pass.cpp b/final/test/containers/unord/unord.map/iterators.pass.cpp
new file mode 100644
index 0000000..47b1d73
--- /dev/null
+++ b/final/test/containers/unord/unord.map/iterators.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::unordered_map<int,double> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+        
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/load_factor.pass.cpp b/final/test/containers/unord/unord.map/load_factor.pass.cpp
new file mode 100644
index 0000000..472e41a
--- /dev/null
+++ b/final/test/containers/unord/unord.map/load_factor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/local_iterators.pass.cpp b/final/test/containers/unord/unord.map/local_iterators.pass.cpp
new file mode 100644
index 0000000..770b1ac
--- /dev/null
+++ b/final/test/containers/unord/unord.map/local_iterators.pass.cpp
@@ -0,0 +1,421 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 1);
+        assert(i->second == "one");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 2);
+        assert(i->second == "two");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/max_bucket_count.pass.cpp b/final/test/containers/unord/unord.map/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..b4ca8eb
--- /dev/null
+++ b/final/test/containers/unord/unord.map/max_bucket_count.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/max_load_factor.pass.cpp b/final/test/containers/unord/unord.map/max_load_factor.pass.cpp
new file mode 100644
index 0000000..69fd70d
--- /dev/null
+++ b/final/test/containers/unord/unord.map/max_load_factor.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_map<int, std::string> C;
+        C c;
+        c.max_load_factor(0);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/max_size.pass.cpp b/final/test/containers/unord/unord.map/max_size.pass.cpp
new file mode 100644
index 0000000..7d5ae3a
--- /dev/null
+++ b/final/test/containers/unord/unord.map/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::unordered_map<int, int> u;
+        assert(u.max_size() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+                                    min_allocator<std::pair<const int, int>>> u;
+        assert(u.max_size() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/rehash.pass.cpp b/final/test/containers/unord/unord.map/rehash.pass.cpp
new file mode 100644
index 0000000..84ece23
--- /dev/null
+++ b/final/test/containers/unord/unord.map/rehash.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 4);
+    assert(c.at(1) == "one");
+    assert(c.at(2) == "two");
+    assert(c.at(3) == "three");
+    assert(c.at(4) == "four");
+}
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.rehash(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.rehash(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/reserve.pass.cpp b/final/test/containers/unord/unord.map/reserve.pass.cpp
new file mode 100644
index 0000000..48667cd
--- /dev/null
+++ b/final/test/containers/unord/unord.map/reserve.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void reserve(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 4);
+    assert(c.at(1) == "one");
+    assert(c.at(2) == "two");
+    assert(c.at(3) == "three");
+    assert(c.at(4) == "four");
+}
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.reserve(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() >= 2);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.reserve(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() >= 2);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/swap_member.pass.cpp b/final/test/containers/unord/unord.map/swap_member.pass.cpp
new file mode 100644
index 0000000..8ab1eb6
--- /dev/null
+++ b/final/test/containers/unord/unord.map/swap_member.pass.cpp
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/types.pass.cpp b/final/test/containers/unord/unord.map/types.pass.cpp
new file mode 100644
index 0000000..b53ff8e
--- /dev/null
+++ b/final/test/containers/unord/unord.map/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+// {
+// public:
+//     // types
+//     typedef Key                                                        key_type;
+//     typedef T                                                          mapped_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef pair<const key_type, mapped_type>                          value_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<char, short> C;
+        static_assert((std::is_same<C::key_type, char>::value), "");
+        static_assert((std::is_same<C::mapped_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<char, short, std::hash<char>, std::equal_to<char>,
+                            min_allocator<std::pair<const char, short>>> C;
+        static_assert((std::is_same<C::key_type, char>::value), "");
+        static_assert((std::is_same<C::mapped_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+        static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+    //  min_allocator doesn't have a size_type, so one gets synthesized
+        static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..0fc76db
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// explicit unordered_map(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef NotConstructible T;
+        typedef test_allocator<std::pair<const T, T>> A;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef std::unordered_map<T, T, HF, Comp, A> C;
+        
+        A a(10);
+        C c(2, a);
+        assert(c.bucket_count() == 2);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef NotConstructible T;
+        typedef test_allocator<std::pair<const T, T>> A;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef std::unordered_map<T, T, HF, Comp, A> C;
+
+        A a(10);
+        HF hf(12);
+        C c(2, hf, a);
+        assert(c.bucket_count() == 2);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..fa01056
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<const int, std::string> P;
+        const P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C *p = &c;
+        c = *p;
+        assert(c.size() == 4);
+        assert(std::is_permutation(c.begin(), c.end(), a));
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..3a854e1
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c =   {
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        c =     {
+                    P(1, "one"),
+                    P(2, "two"),
+                    P(3, "three"),
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c =   {
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        c =     {
+                    P(1, "one"),
+                    P(2, "two"),
+                    P(3, "three"),
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..dd57c58
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
@@ -0,0 +1,229 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c0.size() == 0);
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c0.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c0.size() == 0);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+        std::unordered_map<int, int>::iterator i = s1.begin();
+        std::pair<const int, int> k = *i;
+        std::unordered_map<int, int> s2;
+        s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..227343e
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (other_allocator<std::pair<const int, std::string> >(-2)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..d1757d8
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(5)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c(c0, min_allocator<std::pair<const int, std::string> >());
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
new file mode 100644
index 0000000..a0825db
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        std::unordered_map<int, int> c = {};
+        assert(c.bucket_count() == 0);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 0000000..df8c7b5
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..1fc37f7
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_map() // implied noexcept;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
new file mode 100644
index 0000000..dbc48f8
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c = {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c = {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+        A a(42);
+        C c ( {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              }, 12, a);
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == a);
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+        HF hf(42);
+        A a(43);
+        C c ( {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              }, 12, hf, a);
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == test_hash<std::hash<int> >()));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == a);
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..ac09053
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..7a4130b
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..036008c
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..7c83192
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
new file mode 100644
index 0000000..18e6683
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+        std::unordered_map<int, int>::iterator i = s1.begin();
+        std::pair<const int, int> k = *i;
+        std::unordered_map<int, int> s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..091a72f
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(12));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<int, std::string> P;
+        typedef min_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(std::move(c0), A());
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..f7fde37
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map& operator=(unordered_map&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 0000000..1c86dd3
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map(unordered_map&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
new file mode 100644
index 0000000..c1784d6
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+        P arr[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14);
+        assert(c.bucket_count() >= 14);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+        P arr[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        HF hf(42);
+        A a(43);
+        C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, hf, a);
+        assert(c.bucket_count() >= 14);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..f914b30
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            10
+           );
+        assert(c.bucket_count() == 11);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            10
+           );
+        assert(c.bucket_count() == 11);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..7a0dbce
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..61eef5b
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..99493fa
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     unordered_map(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
new file mode 100644
index 0000000..0a3ae3a
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
new file mode 100644
index 0000000..708dc23
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..6c975ec
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..8b2bb31
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..bcf7b91
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp b/final/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp
new file mode 100644
index 0000000..c4d7128
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.elem/at.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type&       at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c.at(1) = "ONE";
+        assert(c.at(1) == "ONE");
+        try
+        {
+            c.at(11) = "eleven";
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(c.size() == 4);
+    }
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        try
+        {
+            c.at(11);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(c.size() == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c.at(1) = "ONE";
+        assert(c.at(1) == "ONE");
+        try
+        {
+            c.at(11) = "eleven";
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(c.size() == 4);
+    }
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        try
+        {
+            c.at(11);
+            assert(false);
+        }
+        catch (std::out_of_range&)
+        {
+        }
+        assert(c.size() == 4);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp b/final/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp
new file mode 100644
index 0000000..7f4e067
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.elem/index.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c[1] = "ONE";
+        assert(c.at(1) == "ONE");
+        c[11] = "eleven";
+        assert(c.size() == 5);
+        assert(c.at(11) == "eleven");
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c[1] = "ONE";
+        assert(c.at(1) == "ONE");
+        c[11] = "eleven";
+        assert(c.size() == 5);
+        assert(c.at(11) == "eleven");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c[1] = "ONE";
+        assert(c.at(1) == "ONE");
+        c[11] = "eleven";
+        assert(c.size() == 5);
+        assert(c.at(11) == "eleven");
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, std::string, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+                            min_allocator<std::pair<const MoveOnly, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.size() == 4);
+        c[1] = "ONE";
+        assert(c.at(1) == "ONE");
+        c[11] = "eleven";
+        assert(c.size() == 5);
+        assert(c.at(11) == "eleven");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp b/final/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
new file mode 100644
index 0000000..c319b5c
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+using namespace std;
+
+struct my_hash
+{
+    size_t operator()(const tuple<int,int>&) const {return 0;}
+};
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    unordered_map<tuple<int,int>, size_t, my_hash> m;
+    m[make_tuple(2,3)]=7;
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp b/final/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
new file mode 100644
index 0000000..6ab9c92
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_map
+
+// void swap(unordered_map& x, unordered_map& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::pair<int, int> P;
+        P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+        P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+        std::unordered_map<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::unordered_map<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::unordered_map<int, int>::iterator i1 = c1.begin();
+        std::unordered_map<int, int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        std::unordered_map<int, int>::iterator j = i1;
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp b/final/test/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..49ac757
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// void swap(unordered_map& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash() {}
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp b/final/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..7e04b8d
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.at(10) == "ten");
+        assert(c1.at(20) == "twenty");
+        assert(c1.at(30) == "thirty");
+        assert(c1.at(40) == "forty");
+        assert(c1.at(50) == "fifty");
+        assert(c1.at(60) == "sixty");
+        assert(c1.at(70) == "seventy");
+        assert(c1.at(80) == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.at(1) == "one");
+        assert(c2.at(2) == "two");
+        assert(c2.at(3) == "three");
+        assert(c2.at(4) == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..9f320e9
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..5de74d2
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+//     pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+                                                  std::forward_as_tuple());
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == Emplaceable(5, 6));
+
+        r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+                                               std::forward_as_tuple(6, 7));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == Emplaceable(6, 7));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, Emplaceable>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+                                                  std::forward_as_tuple());
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == Emplaceable(5, 6));
+
+        r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+                                               std::forward_as_tuple(6, 7));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == Emplaceable(6, 7));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..21a4689
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+                                                          std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+                                                       std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, Emplaceable>>> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+                                                          std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+                                                       std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_map<int, Emplaceable> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(3),
+                                       std::forward_as_tuple());
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..422dbe4
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000..60b0935
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000..05046f5
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000..81a8d3d
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000..4b103a0
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000..6ef1e07
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int> l2(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000..1185ddf
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_map<int, int> l1(a1, a1+3);
+    std::unordered_map<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..0e8ef8b
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+    typename Unordered::const_iterator w = whole.begin();
+    typename Unordered::const_iterator p = part.begin();
+    
+    while ( w != whole.end () && p != part.end()) {        
+        if ( *w == *p )
+            p++;
+        w++;
+        }
+
+    return p == part.end();
+}
+#endif
+
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.at(3) == "three");
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+    {
+    typedef std::unordered_map<int, int> C;
+    C m, m2;
+    for ( int i = 0; i < 10; ++i ) {
+        m[i] = i;
+        m2[i] = i;
+        }
+    
+    C::iterator i = m2.begin();
+    int ctr = 0;
+    while (i != m2.end()) {
+        if (ctr++ % 2 == 0)
+            m2.erase(i++);
+        else
+            ++i;
+        }
+
+    assert (only_deletions (m, m2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
new file mode 100644
index 0000000..f0664c3
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 1);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(k == j);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(k == c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 1);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(k == j);
+        assert(c.at(1) == "one");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(k == c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..a16f097
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..981b8fb
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        P v(3.5, 3);
+        R r = c.insert(e, v);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..92f6c40
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+                            min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3, 4));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(4, 4));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
new file mode 100644
index 0000000..81e8a46
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
new file mode 100644
index 0000000..fc44e78
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.at(1) == "one");
+        assert(c.at(2) == "two");
+        assert(c.at(3) == "three");
+        assert(c.at(4) == "four");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..6c5e8c8
--- /dev/null
+++ b/final/test/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     pair<iterator, bool> insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_map<double, int> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3.5);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4.5, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4.5);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5.5);
+        assert(r.first->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+                            min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(!r.second);
+        assert(c.size() == 1);
+        assert(r.first->first == 3);
+        assert(r.first->second == 3);
+
+        r = c.insert(P(4, 4));
+        assert(r.second);
+        assert(c.size() == 2);
+        assert(r.first->first == 4);
+        assert(r.first->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(r.second);
+        assert(c.size() == 3);
+        assert(r.first->first == 5);
+        assert(r.first->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/unord/unord.map/version.pass.cpp b/final/test/containers/unord/unord.map/version.pass.cpp
new file mode 100644
index 0000000..fc47a32
--- /dev/null
+++ b/final/test/containers/unord/unord.map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/containers/unord/unord.multimap/bucket.pass.cpp b/final/test/containers/unord/unord.multimap/bucket.pass.cpp
new file mode 100644
index 0000000..be5acc1
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/bucket.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 7);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 7);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        C c;
+        C::size_type i = c.bucket(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/bucket_count.pass.cpp b/final/test/containers/unord/unord.multimap/bucket_count.pass.cpp
new file mode 100644
index 0000000..d44412f
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/bucket_count.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+}
diff --git a/final/test/containers/unord/unord.multimap/bucket_size.pass.cpp b/final/test/containers/unord/unord.multimap/bucket_size.pass.cpp
new file mode 100644
index 0000000..a02f72e
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/bucket_size.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 7);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 2);
+        assert(c.bucket_size(2) == 2);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+        assert(c.bucket_size(5) == 0);
+        assert(c.bucket_size(6) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 7);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 2);
+        assert(c.bucket_size(2) == 2);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+        assert(c.bucket_size(5) == 0);
+        assert(c.bucket_size(6) == 0);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        C c;
+        C::size_type i = c.bucket_size(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/count.pass.cpp b/final/test/containers/unord/unord.multimap/count.pass.cpp
new file mode 100644
index 0000000..efaf02e
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/count.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 3);
+        assert(c.count(5) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 3);
+        assert(c.count(5) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp b/final/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp
new file mode 100644
index 0000000..b6ba8d6
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/db_iterators_7.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_multimap<int, std::string> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp b/final/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp
new file mode 100644
index 0000000..f5ea508
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/db_iterators_8.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_multimap<int, std::string> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.end();
+    C::value_type j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c;
+    c.insert(std::make_pair(1, "one"));
+    C::iterator i = c.end();
+    C::value_type j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp b/final/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp
new file mode 100644
index 0000000..93cbd54
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_multimap<int, std::string> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp b/final/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp
new file mode 100644
index 0000000..159ae49
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::unordered_multimap<int, std::string> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    C::value_type j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                        min_allocator<std::pair<const int, std::string>>> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    C::value_type j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/eq.pass.cpp b/final/test/containers/unord/unord.multimap/eq.pass.cpp
new file mode 100644
index 0000000..3604e77
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/eq.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+//            const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90, "ninety"));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90, "ninety"));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(20, "twenty 2"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fifty 2"),
+            P(50, "fifty 3"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90, "ninety"));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90, "ninety"));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/equal_range_const.pass.cpp b/final/test/containers/unord/unord.multimap/equal_range_const.pass.cpp
new file mode 100644
index 0000000..67613b0
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/equal_range_const.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(r.first->first == 50);
+        assert(r.first->second == "fifty");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyA");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyB");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(r.first->first == 50);
+        assert(r.first->second == "fifty");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyA");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyB");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp b/final/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..eb4c019
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(r.first->first == 50);
+        assert(r.first->second == "fifty");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyA");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyB");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::iterator I;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(50, "fiftyA"),
+            P(50, "fiftyB"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(r.first->first == 30);
+        assert(r.first->second == "thirty");
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(r.first->first == 50);
+        assert(r.first->second == "fifty");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyA");
+        ++r.first;
+        assert(r.first->first == 50);
+        assert(r.first->second == "fiftyB");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/find_const.pass.cpp b/final/test/containers/unord/unord.multimap/find_const.pass.cpp
new file mode 100644
index 0000000..bc2650d
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/find_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/find_non_const.pass.cpp b/final/test/containers/unord/unord.multimap/find_non_const.pass.cpp
new file mode 100644
index 0000000..5a128c0
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/find_non_const.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(i->first == 30);
+        assert(i->second == "thirty");
+        i = c.find(5);
+        assert(i == c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/iterators.fail.cpp b/final/test/containers/unord/unord.multimap/iterators.fail.cpp
new file mode 100644
index 0000000..d0adb2c
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/iterators.fail.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i = c.begin();
+        i->second = "ONE";
+        assert(i->second == "ONE");
+        i->first = 2;
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/final/test/containers/unord/unord.multimap/iterators.pass.cpp b/final/test/containers/unord/unord.multimap/iterators.pass.cpp
new file mode 100644
index 0000000..1831cf1
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/iterators.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+        i = c.begin();
+        i->second = "ONE";
+        assert(i->second == "ONE");
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+        i = c.begin();
+        i->second = "ONE";
+        assert(i->second == "ONE");
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::unordered_multimap<int,double> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/load_factor.pass.cpp b/final/test/containers/unord/unord.multimap/load_factor.pass.cpp
new file mode 100644
index 0000000..f407097
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/load_factor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/local_iterators.fail.cpp b/final/test/containers/unord/unord.multimap/local_iterators.fail.cpp
new file mode 100644
index 0000000..5f66cfe
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/local_iterators.fail.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        i->first = 2;
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/final/test/containers/unord/unord.multimap/local_iterators.pass.cpp b/final/test/containers/unord/unord.multimap/local_iterators.pass.cpp
new file mode 100644
index 0000000..35e4c77
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/local_iterators.pass.cpp
@@ -0,0 +1,549 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 3);
+        assert(i->second == "three");
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(i->first == 4);
+        assert(i->second == "four");
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/final/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..23b9057
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/max_bucket_count.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef C::const_iterator I;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/max_load_factor.pass.cpp b/final/test/containers/unord/unord.multimap/max_load_factor.pass.cpp
new file mode 100644
index 0000000..39b7fee
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/max_load_factor.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        C c;
+        c.max_load_factor(0);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/max_size.pass.cpp b/final/test/containers/unord/unord.multimap/max_size.pass.cpp
new file mode 100644
index 0000000..caba593
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::unordered_multimap<int, int> u;
+        assert(u.max_size() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, int>>> u;
+        assert(u.max_size() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/rehash.pass.cpp b/final/test/containers/unord/unord.multimap/rehash.pass.cpp
new file mode 100644
index 0000000..1d99208
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/rehash.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 6);
+    typedef std::pair<typename C::const_iterator, typename C::const_iterator> Eq;
+    Eq eq = c.equal_range(1);
+    assert(std::distance(eq.first, eq.second) == 2);
+    typename C::const_iterator i = eq.first;
+    assert(i->first == 1);
+    assert(i->second == "one");
+    ++i;
+    assert(i->first == 1);
+    assert(i->second == "four");
+    eq = c.equal_range(2);
+    assert(std::distance(eq.first, eq.second) == 2);
+    i = eq.first;
+    assert(i->first == 2);
+    assert(i->second == "two");
+    ++i;
+    assert(i->first == 2);
+    assert(i->second == "four");
+
+    eq = c.equal_range(3);
+    assert(std::distance(eq.first, eq.second) == 1);
+    i = eq.first;
+    assert(i->first == 3);
+    assert(i->second == "three");
+    eq = c.equal_range(4);
+    assert(std::distance(eq.first, eq.second) == 1);
+    i = eq.first;
+    assert(i->first == 4);
+    assert(i->second == "four");
+    assert(std::distance(c.begin(), c.end()) == c.size());
+    assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.rehash(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.rehash(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/reserve.pass.cpp b/final/test/containers/unord/unord.multimap/reserve.pass.cpp
new file mode 100644
index 0000000..801c744
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/reserve.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 6);
+    assert(c.find(1)->second == "one");
+    assert(next(c.find(1))->second == "four");
+    assert(c.find(2)->second == "two");
+    assert(next(c.find(2))->second == "four");
+    assert(c.find(3)->second == "three");
+    assert(c.find(4)->second == "four");
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.reserve(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.reserve(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/scary.pass.cpp b/final/test/containers/unord/unord.multimap/scary.pass.cpp
new file mode 100644
index 0000000..e619a7a
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// class unordered_map class unordered_multimap
+
+// Extension:  SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
+
+#include <unordered_map>
+
+int main()
+{
+    typedef std::unordered_map<int, int> M1;
+    typedef std::unordered_multimap<int, int> M2;
+    M2::iterator i;
+    M1::iterator j = i;
+}
diff --git a/final/test/containers/unord/unord.multimap/swap_member.pass.cpp b/final/test/containers/unord/unord.multimap/swap_member.pass.cpp
new file mode 100644
index 0000000..225eccd
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/swap_member.pass.cpp
@@ -0,0 +1,585 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/types.pass.cpp b/final/test/containers/unord/unord.multimap/types.pass.cpp
new file mode 100644
index 0000000..55ae749
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+// {
+// public:
+//     // types
+//     typedef Key                                                        key_type;
+//     typedef T                                                          mapped_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef pair<const key_type, mapped_type>                          value_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<char, short> C;
+        static_assert((std::is_same<C::key_type, char>::value), "");
+        static_assert((std::is_same<C::mapped_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<char, short, std::hash<char>, std::equal_to<char>,
+                            min_allocator<std::pair<const char, short>>> C;
+        static_assert((std::is_same<C::key_type, char>::value), "");
+        static_assert((std::is_same<C::mapped_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+        static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+    //  min_allocator doesn't have a size_type, so one gets synthesized
+        static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..dc41fad
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// explicit unordered_multimap(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef NotConstructible T;
+        typedef test_allocator<std::pair<const T, T>> A;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+        
+        A a(10);
+        C c(2, a);
+        assert(c.bucket_count() == 2);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef NotConstructible T;
+        typedef test_allocator<std::pair<const T, T>> A;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+
+        A a(10);
+        HF hf(12);
+        C c(2, hf, a);
+        assert(c.bucket_count() == 2);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..df566b3
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<const int, std::string> P;
+        const P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a+sizeof(a)/sizeof(a[0]));
+        C *p = &c;
+        c = *p;
+        assert(c.size() == 6);
+        assert(std::is_permutation(c.begin(), c.end(), a));
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..2d3c143
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c =   {
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        c =     {
+                    P(1, "one"),
+                    P(2, "two"),
+                    P(3, "three"),
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c =   {
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        c =     {
+                    P(1, "one"),
+                    P(2, "two"),
+                    P(3, "three"),
+                    P(4, "four"),
+                    P(1, "four"),
+                    P(2, "four"),
+                };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..0c43fa8
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
@@ -0,0 +1,306 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<std::pair<const int, std::string> > A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+        std::unordered_multimap<int, int>::iterator i = s1.begin();
+        std::pair<const int, int> k = *i;
+        std::unordered_multimap<int, int> s2;
+        s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..d71838f
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (other_allocator<std::pair<const int, std::string> >(-2)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..2a064c5
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(5)));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c(c0, min_allocator<std::pair<const int, std::string> >());
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+        ++i;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        ++i;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
new file mode 100644
index 0000000..1884065
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        std::unordered_multimap<int, int> c = {};
+        assert(c.bucket_count() == 0);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 0000000..9812a45
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..ae2a96e
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_multimap() // implied noexcept;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
new file mode 100644
index 0000000..cc5532a
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
@@ -0,0 +1,254 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c = {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c = {
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+        A a(42);
+        C c ({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              }, 12, a );
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+        HF hf(42);
+        A a(43);
+        C c ({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+              }, 12, hf, a );
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+    }
+#endif
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..48239db
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..ff00546
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..095e9c3
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..d2f698a
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        C c({
+                P(1, "one"),
+                P(2, "two"),
+                P(3, "three"),
+                P(4, "four"),
+                P(1, "four"),
+                P(2, "four"),
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
new file mode 100644
index 0000000..fd70ff1
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
@@ -0,0 +1,243 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const int, std::string> >(10)));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const int, std::string> >()));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+        assert(c0.empty());
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+        std::unordered_multimap<int, int>::iterator i = s1.begin();
+        std::pair<const int, int> k = *i;
+        std::unordered_multimap<int, int> s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..d958e23
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,228 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u, const allocator_type& a);
+
+#include <iostream>
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(12)));
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::pair<int, std::string> P;
+        typedef min_allocator<std::pair<const int, std::string>> A;
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(std::move(c0), A());
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+        assert(c0.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..078693d
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap& operator=(unordered_multimap&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 0000000..44565d1
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap(unordered_multimap&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
new file mode 100644
index 0000000..bb700ec
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
@@ -0,0 +1,263 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+        P arr[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+         A a(42);
+       C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, a);
+        assert(c.bucket_count() >= 14);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+    }
+    {
+        typedef std::pair<int, std::string> P;
+        typedef test_allocator<std::pair<const int, std::string>> A;
+        typedef test_hash<std::hash<int>> HF;
+        typedef test_compare<std::equal_to<int>> Comp;
+        typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+        P arr[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        A a(42);
+        HF hf (43);
+        C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 12, hf, a );
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..a3fd4d1
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            10
+           );
+        assert(c.bucket_count() == 11);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            10
+           );
+        assert(c.bucket_count() == 11);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..4e7b1ac
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..879e681
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..8e42ca7
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     unordered_multimap(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<std::pair<const int, std::string> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<std::pair<const int, std::string> >
+                                   > C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<std::pair<const int, std::string> >()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator i = eq.first;
+        assert(i->first == 1);
+        assert(i->second == "one");
+        ++i;
+        assert(i->first == 1);
+        assert(i->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        i = eq.first;
+        assert(i->first == 2);
+        assert(i->second == "two");
+        ++i;
+        assert(i->first == 2);
+        assert(i->second == "four");
+
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 3);
+        assert(i->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        i = eq.first;
+        assert(i->first == 4);
+        assert(i->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
new file mode 100644
index 0000000..44cf84f
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
new file mode 100644
index 0000000..bd56a41
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..3346061
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..c2420ce
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..3388667
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<std::pair<const NotConstructible,
+                                                                  NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<NotConstructible, NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<std::pair<const NotConstructible,
+                                                                 NotConstructible> >
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() ==
+               (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..4efcfaa
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 0000000..4f2e8ef
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+//     iterator emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multimap<int, Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+                                                  std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+                                                std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, Emplaceable>>> C;
+        typedef C::iterator R;
+        C c;
+        R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+                                                  std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 4);
+        assert(r->second == Emplaceable(5, 6));
+
+        r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+                                                std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 5);
+        assert(r->second == Emplaceable(6, 7));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 0000000..4d141ad
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multimap<int, Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+                                                          std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(5, 6));
+        assert(r == next(c.begin()));
+
+        r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+                                                        std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(6, 7));
+        assert(r == next(c.begin()));
+        r = c.begin();
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+        r = next(r, 2);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(5, 6));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, Emplaceable>>> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+                                                          std::forward_as_tuple());
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+
+        r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(5, 6));
+        assert(r == next(c.begin()));
+
+        r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+                                                        std::forward_as_tuple(6, 7));
+        assert(c.size() == 3);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(6, 7));
+        assert(r == next(c.begin()));
+        r = c.begin();
+        assert(r->first == 3);
+        assert(r->second == Emplaceable());
+        r = next(r, 2);
+        assert(r->first == 3);
+        assert(r->second == Emplaceable(5, 6));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_multimap<int, Emplaceable> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+                                       std::forward_as_tuple(3),
+                                       std::forward_as_tuple());
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..25d6a7a
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+
+        assert(c.size() == 5);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+
+        assert(c.size() == 5);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000..83ccf3b
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_multimap<int, int> l1(a1, a1+3);
+    std::unordered_multimap<int, int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000..fffcfa6
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_multimap<int, int> l1(a1, a1+3);
+    std::unordered_multimap<int, int> l2(a1, a1+3);
+    std::unordered_multimap<int, int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000..be6caba
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_multimap<int, int> l1(a1, a1+3);
+    std::unordered_multimap<int, int> l2(a1, a1+3);
+    std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000..a6d5408
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_multimap<int, int> l1(a1, a1+3);
+    std::unordered_multimap<int, int> l2(a1, a1+3);
+    std::unordered_multimap<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000..301cfb4
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_multimap<int, int> l1(a1, a1+3);
+    std::unordered_multimap<int, int> l2(a1, a1+3);
+    std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000..b53b486
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    typedef std::pair<int, int> P;
+    P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+    std::unordered_multimap<int, int> l1(a1, a1+3);
+    std::unordered_multimap<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 0000000..892f8a2
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+    typename Unordered::const_iterator w = whole.begin();
+    typename Unordered::const_iterator p = part.begin();
+    
+    while ( w != whole.end () && p != part.end()) {
+        if ( *w == *p )
+            p++;
+        w++;
+        }
+
+    return p == part.end();
+}
+#endif
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(2) == 2);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 3);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 3);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(1) == 2);
+        assert(c.size() == 1);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 0);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 0);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 6);
+        typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::const_iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(2) == 2);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 3);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 3);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(1) == 2);
+        assert(c.size() == 1);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 0);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 0);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+    {
+    typedef std::unordered_multimap<int, int> C;
+    C m, m2;
+    for ( int i = 0; i < 10; ++i ) {
+        for (int j = 0; j < 2; ++j ) {
+            m.insert (std::make_pair(i,j));
+            m2.insert(std::make_pair(i,j));
+            }
+        }
+    
+    C::iterator i = m2.begin();
+    int ctr = 0;
+    while (i != m2.end()) {
+        if (ctr++ % 2 == 0)
+            m2.erase(i++);
+        else
+            ++i;
+        }
+
+    assert (only_deletions (m, m2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
new file mode 100644
index 0000000..f60ec07
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
@@ -0,0 +1,179 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 2);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        k = c.erase(i, j);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 2);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        k = c.erase(i, j);
+        assert(c.size() == 4);
+        eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..e7e7cb0
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..c7cb1f4
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(c.end(), P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        P v(3.5, 3);
+        R r = c.insert(e, v);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..bb89c3f
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(r, P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(r, P(3, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(4, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(r, P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+                            min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(r, P(3, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(4, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(c.end(), P(5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        R r = c.insert(e, P(3.5, 3));
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
new file mode 100644
index 0000000..23dbe84
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        C c;
+        c.insert(
+                    {
+                        P(1, "one"),
+                        P(2, "two"),
+                        P(3, "three"),
+                        P(4, "four"),
+                        P(1, "four"),
+                        P(2, "four"),
+                    }
+                );
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
new file mode 100644
index 0000000..2820639
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<int, std::string> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+                            min_allocator<std::pair<const int, std::string>>> C;
+        typedef std::pair<int, std::string> P;
+        P a[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 6);
+        typedef std::pair<C::iterator, C::iterator> Eq;
+        Eq eq = c.equal_range(1);
+        assert(std::distance(eq.first, eq.second) == 2);
+        C::iterator k = eq.first;
+        assert(k->first == 1);
+        assert(k->second == "one");
+        ++k;
+        assert(k->first == 1);
+        assert(k->second == "four");
+        eq = c.equal_range(2);
+        assert(std::distance(eq.first, eq.second) == 2);
+        k = eq.first;
+        assert(k->first == 2);
+        assert(k->second == "two");
+        ++k;
+        assert(k->first == 2);
+        assert(k->second == "four");
+        eq = c.equal_range(3);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 3);
+        assert(k->second == "three");
+        eq = c.equal_range(4);
+        assert(std::distance(eq.first, eq.second) == 1);
+        k = eq.first;
+        assert(k->first == 4);
+        assert(k->second == "four");
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..f363758
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+//           class = typename enable_if<is_convertible<P, value_type>::value>::type>
+//     iterator insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multimap<double, int> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == 4);
+
+        r = c.insert(P(4, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+                            min_allocator<std::pair<const double, int>>> C;
+        typedef C::iterator R;
+        typedef std::pair<double, short> P;
+        C c;
+        R r = c.insert(P(3.5, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3.5);
+        assert(r->second == 3);
+
+        r = c.insert(P(3.5, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(4.5, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4.5);
+        assert(r->second == 4);
+
+        r = c.insert(P(5.5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5.5);
+        assert(r->second == 4);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+                            min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        typedef C::iterator R;
+        typedef std::pair<MoveOnly, MoveOnly> P;
+        C c;
+        R r = c.insert(P(3, 3));
+        assert(c.size() == 1);
+        assert(r->first == 3);
+        assert(r->second == 3);
+
+        r = c.insert(P(3, 4));
+        assert(c.size() == 2);
+        assert(r->first == 3);
+        assert(r->second == 4);
+
+        r = c.insert(P(4, 4));
+        assert(c.size() == 3);
+        assert(r->first == 4);
+        assert(r->second == 4);
+
+        r = c.insert(P(5, 4));
+        assert(c.size() == 4);
+        assert(r->first == 5);
+        assert(r->second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp
new file mode 100644
index 0000000..a332b6f
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& x, unordered_multimap& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::pair<int, int> P;
+        P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+        P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+        std::unordered_multimap<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::unordered_multimap<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::unordered_multimap<int, int>::iterator i1 = c1.begin();
+        std::unordered_multimap<int, int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        std::unordered_multimap<int, int>::iterator j = i1;
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..a7700b4
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// void swap(unordered_multimap& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash() {}
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/final/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..0f579e0
--- /dev/null
+++ b/final/test/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
@@ -0,0 +1,584 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+//           class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<std::pair<const int, std::string> > Alloc;
+        typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+        typedef std::pair<int, std::string> P;
+        P a1[] =
+        {
+            P(1, "one"),
+            P(2, "two"),
+            P(3, "three"),
+            P(4, "four"),
+            P(1, "four"),
+            P(2, "four"),
+        };
+        P a2[] =
+        {
+            P(10, "ten"),
+            P(20, "twenty"),
+            P(30, "thirty"),
+            P(40, "forty"),
+            P(50, "fifty"),
+            P(60, "sixty"),
+            P(70, "seventy"),
+            P(80, "eighty"),
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(c1.find(10)->second == "ten");
+        assert(c1.find(20)->second == "twenty");
+        assert(c1.find(30)->second == "thirty");
+        assert(c1.find(40)->second == "forty");
+        assert(c1.find(50)->second == "fifty");
+        assert(c1.find(60)->second == "sixty");
+        assert(c1.find(70)->second == "seventy");
+        assert(c1.find(80)->second == "eighty");
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.find(1)->second == "one");
+        assert(next(c2.find(1))->second == "four");
+        assert(c2.find(2)->second == "two");
+        assert(next(c2.find(2))->second == "four");
+        assert(c2.find(3)->second == "three");
+        assert(c2.find(4)->second == "four");
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/bucket.pass.cpp b/final/test/containers/unord/unord.multiset/bucket.pass.cpp
new file mode 100644
index 0000000..0293133
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/bucket.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 7);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 7);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_multiset<int> C;
+        C c;
+        C::size_type i = c.bucket(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/bucket_count.pass.cpp b/final/test/containers/unord/unord.multiset/bucket_count.pass.cpp
new file mode 100644
index 0000000..c7842e5
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/bucket_count.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/bucket_size.pass.cpp b/final/test/containers/unord/unord.multiset/bucket_size.pass.cpp
new file mode 100644
index 0000000..639d7ac
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/bucket_size.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 7);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 2);
+        assert(c.bucket_size(2) == 2);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+        assert(c.bucket_size(5) == 0);
+        assert(c.bucket_size(6) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 7);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 2);
+        assert(c.bucket_size(2) == 2);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+        assert(c.bucket_size(5) == 0);
+        assert(c.bucket_size(6) == 0);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_multiset<int> C;
+        C c;
+        C::size_type i = c.bucket_size(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/clear.pass.cpp b/final/test/containers/unord/unord.multiset/clear.pass.cpp
new file mode 100644
index 0000000..61ca847
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/clear.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/count.pass.cpp b/final/test/containers/unord/unord.multiset/count.pass.cpp
new file mode 100644
index 0000000..e548324
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/count.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 3);
+        assert(c.count(5) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 3);
+        assert(c.count(5) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp b/final/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp
new file mode 100644
index 0000000..c8ef2fb
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp b/final/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp
new file mode 100644
index 0000000..eef7997
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp b/final/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp
new file mode 100644
index 0000000..c1de95c
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T, min_allocator<T>> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp b/final/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp
new file mode 100644
index 0000000..962b852
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    T j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_multiset<T, min_allocator<T>> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    T j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/emplace.pass.cpp b/final/test/containers/unord/unord.multiset/emplace.pass.cpp
new file mode 100644
index 0000000..13787d9
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/emplace.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+//     iterator emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multiset<Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        R r = c.emplace();
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace(Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace(5, 6);
+        assert(c.size() == 3);
+        assert(*r == Emplaceable(5, 6));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>,
+                      std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+        typedef C::iterator R;
+        C c;
+        R r = c.emplace();
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace(Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace(5, 6);
+        assert(c.size() == 3);
+        assert(*r == Emplaceable(5, 6));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multiset/emplace_hint.pass.cpp b/final/test/containers/unord/unord.multiset/emplace_hint.pass.cpp
new file mode 100644
index 0000000..8885cc0
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/emplace_hint.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multiset<Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e);
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace_hint(c.end(), Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace_hint(r, 5, 6);
+        assert(c.size() == 3);
+        assert(*r == Emplaceable(5, 6));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>,
+                      std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e);
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace_hint(c.end(), Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace_hint(r, 5, 6);
+        assert(c.size() == 3);
+        assert(*r == Emplaceable(5, 6));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_multiset<Emplaceable> C;
+        typedef C::iterator R;
+        C c1;
+        C c2;
+        R r = c1.emplace_hint(c2.begin(), 5, 6);
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multiset/eq.pass.cpp b/final/test/containers/unord/unord.multiset/eq.pass.cpp
new file mode 100644
index 0000000..bbedbc9
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/eq.pass.cpp
@@ -0,0 +1,180 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+//            const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+//            const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/equal_range_const.pass.cpp b/final/test/containers/unord/unord.multiset/equal_range_const.pass.cpp
new file mode 100644
index 0000000..a0aaac2
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/equal_range_const.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 3);
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 3);
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp b/final/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..73d44f7
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/equal_range_non_const.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef C::iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 3);
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef C::iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 3);
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+        ++r.first;
+        assert(*r.first == 50);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp b/final/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..6a005d3
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_const_iter.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 5);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 5);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp b/final/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000..baad385
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_iter_db1.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_multiset<int> l1(a1, a1+3);
+    std::unordered_multiset<int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp b/final/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000..a21f29e
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_multiset<int> l1(a1, a1+3);
+    std::unordered_multiset<int> l2(a1, a1+3);
+    std::unordered_multiset<int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp b/final/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000..03c9ec5
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_multiset<int> l1(a1, a1+3);
+    std::unordered_multiset<int> l2(a1, a1+3);
+    std::unordered_multiset<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp b/final/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000..4c6f209
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_multiset<int> l1(a1, a1+3);
+    std::unordered_multiset<int> l2(a1, a1+3);
+    std::unordered_multiset<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp b/final/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000..5ce3789
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_multiset<int> l1(a1, a1+3);
+    std::unordered_multiset<int> l2(a1, a1+3);
+    std::unordered_multiset<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp b/final/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000..7c362a2
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_multiset<int> l1(a1, a1+3);
+    std::unordered_multiset<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.multiset/erase_key.pass.cpp b/final/test/containers/unord/unord.multiset/erase_key.pass.cpp
new file mode 100644
index 0000000..7c24397
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_key.pass.cpp
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+    typename Unordered::const_iterator w = whole.begin();
+    typename Unordered::const_iterator p = part.begin();
+    
+    while ( w != whole.end () && p != part.end()) {
+        if ( *w == *p )
+            p++;
+        w++;
+        }
+
+    return p == part.end();
+}
+#endif
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 2);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 3);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 3);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 2);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 2);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 3);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 3);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 2);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+    {
+    typedef std::unordered_multiset<int> C;
+    C m, m2;
+    for ( int i = 0; i < 10; ++i ) {
+        m.insert(i);  m.insert(i);
+        m2.insert(i); m2.insert(i);
+        }
+    
+    C::iterator i = m2.begin();
+    int ctr = 0;
+    while (i != m2.end()) {
+        if (ctr++ % 2 == 0)
+            m2.erase(i++);
+        else
+            ++i;
+        }
+
+    assert (only_deletions (m, m2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/erase_range.pass.cpp b/final/test/containers/unord/unord.multiset/erase_range.pass.cpp
new file mode 100644
index 0000000..baac08e
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/erase_range.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 2);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(i, j);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i, 2);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(i, j);
+        assert(c.size() == 4);
+        assert(c.count(1) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/find_const.pass.cpp b/final/test/containers/unord/unord.multiset/find_const.pass.cpp
new file mode 100644
index 0000000..5caaf20
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/find_const.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/find_non_const.pass.cpp b/final/test/containers/unord/unord.multiset/find_non_const.pass.cpp
new file mode 100644
index 0000000..0304878
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/find_non_const.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp b/final/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..0051e49
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/final/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..25b4bc1
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(c.end(), P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(c.end(), P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(c.end(), P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(c.end(), P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(c.end(), P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(c.end(), P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        P v(3.5);
+        R r = c.insert(e, v);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp b/final/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..634e4f4
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(r, P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(c.end(), P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(c.end(), P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(r, P(3));
+        assert(c.size() == 2);
+        assert(*r == 3);
+
+        r = c.insert(c.end(), P(4));
+        assert(c.size() == 3);
+        assert(*r == 4);
+
+        r = c.insert(c.end(), P(5));
+        assert(c.size() == 4);
+        assert(*r == 5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(r, P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(c.end(), P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(c.end(), P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                            std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(r, P(3));
+        assert(c.size() == 2);
+        assert(*r == 3);
+
+        r = c.insert(c.end(), P(4));
+        assert(c.size() == 3);
+        assert(*r == 4);
+
+        r = c.insert(c.end(), P(5));
+        assert(c.size() == 4);
+        assert(*r == 5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        R r = c.insert(e, P(3.5));
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/insert_init.pass.cpp b/final/test/containers/unord/unord.multiset/insert_init.pass.cpp
new file mode 100644
index 0000000..6941d86
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/insert_init.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        C c;
+        c.insert(
+                    {
+                        P(1),
+                        P(2),
+                        P(3),
+                        P(4),
+                        P(1),
+                        P(2)
+                    }
+                );
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        C c;
+        c.insert(
+                    {
+                        P(1),
+                        P(2),
+                        P(3),
+                        P(4),
+                        P(1),
+                        P(2)
+                    }
+                );
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multiset/insert_range.pass.cpp b/final/test/containers/unord/unord.multiset/insert_range.pass.cpp
new file mode 100644
index 0000000..41c9d81
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/insert_range.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp b/final/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..65a5bc2
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/insert_rvalue.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<double> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        R r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(P(3));
+        assert(c.size() == 2);
+        assert(*r == 3);
+
+        r = c.insert(P(4));
+        assert(c.size() == 3);
+        assert(*r == 4);
+
+        r = c.insert(P(5));
+        assert(c.size() == 4);
+        assert(*r == 5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 2);
+        assert(*r == 3.5);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 3);
+        assert(*r == 4.5);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 4);
+        assert(*r == 5.5);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                            std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        R r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(P(3));
+        assert(c.size() == 2);
+        assert(*r == 3);
+
+        r = c.insert(P(4));
+        assert(c.size() == 3);
+        assert(*r == 4);
+
+        r = c.insert(P(5));
+        assert(c.size() == 4);
+        assert(*r == 5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/iterators.fail.cpp b/final/test/containers/unord/unord.multiset/iterators.fail.cpp
new file mode 100644
index 0000000..f78bccb
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/iterators.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i = c.begin();
+        assert(*i == 1);
+        *i = 2;
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/final/test/containers/unord/unord.multiset/iterators.pass.cpp b/final/test/containers/unord/unord.multiset/iterators.pass.cpp
new file mode 100644
index 0000000..be95b44
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/iterators.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::unordered_multiset<int> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/load_factor.pass.cpp b/final/test/containers/unord/unord.multiset/load_factor.pass.cpp
new file mode 100644
index 0000000..07980c2
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/load_factor.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/local_iterators.fail.cpp b/final/test/containers/unord/unord.multiset/local_iterators.fail.cpp
new file mode 100644
index 0000000..4118987
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        *i = 2;
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() == 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/final/test/containers/unord/unord.multiset/local_iterators.pass.cpp b/final/test/containers/unord/unord.multiset/local_iterators.pass.cpp
new file mode 100644
index 0000000..3471707
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/local_iterators.pass.cpp
@@ -0,0 +1,500 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 7);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp b/final/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..619a8cf
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/max_bucket_count.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/max_load_factor.pass.cpp b/final/test/containers/unord/unord.multiset/max_load_factor.pass.cpp
new file mode 100644
index 0000000..08f52bb
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/max_load_factor.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_multiset<int> C;
+        C c;
+        c.max_load_factor(0);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/max_size.pass.cpp b/final/test/containers/unord/unord.multiset/max_size.pass.cpp
new file mode 100644
index 0000000..a5d0b55
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::unordered_multiset<int> u;
+        assert(u.max_size() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> u;
+        assert(u.max_size() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/rehash.pass.cpp b/final/test/containers/unord/unord.multiset/rehash.pass.cpp
new file mode 100644
index 0000000..bc8d461
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/rehash.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 6);
+    assert(c.count(1) == 2);
+    assert(c.count(2) == 2);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.rehash(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.rehash(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/reserve.pass.cpp b/final/test/containers/unord/unord.multiset/reserve.pass.cpp
new file mode 100644
index 0000000..0c17583
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/reserve.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 6);
+    assert(c.count(1) == 2);
+    assert(c.count(2) == 2);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.reserve(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 7);
+        c.reserve(3);
+        assert(c.bucket_count() == 7);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/scary.pass.cpp b/final/test/containers/unord/unord.multiset/scary.pass.cpp
new file mode 100644
index 0000000..dfd144b
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// class unordered_set class unordered_multiset
+
+// Extension:  SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
+
+#include <unordered_set>
+
+int main()
+{
+    typedef std::unordered_set<int> M1;
+    typedef std::unordered_multiset<int> M2;
+    M2::iterator i;
+    M1::iterator j = i;
+}
diff --git a/final/test/containers/unord/unord.multiset/swap_member.pass.cpp b/final/test/containers/unord/unord.multiset/swap_member.pass.cpp
new file mode 100644
index 0000000..275ff40
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/swap_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& __u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/types.pass.cpp b/final/test/containers/unord/unord.multiset/types.pass.cpp
new file mode 100644
index 0000000..5222222
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/types.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+// {
+// public:
+//     // types
+//     typedef Value                                                      value_type;
+//     typedef value_type                                                 key_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<short> C;
+        static_assert((std::is_same<C::value_type, short>::value), "");
+        static_assert((std::is_same<C::key_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<short, std::hash<short>,
+                                  std::equal_to<short>, min_allocator<short>> C;
+        static_assert((std::is_same<C::value_type, short>::value), "");
+        static_assert((std::is_same<C::key_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+        static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+    //  min_allocator doesn't have a size_type, so one gets synthesized
+        static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..ccd21a5
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(test_allocator<NotConstructible>(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(min_allocator<NotConstructible>{});
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == min_allocator<NotConstructible>());
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef NotConstructible T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+        A a(43);
+        C c(3, a);
+        assert(c.bucket_count() == 3);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp ());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef NotConstructible T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+        HF hf(42);
+        A a(43);
+        C c(4, hf, a);
+        assert(c.bucket_count() == 4);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp ());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..2042f69
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,209 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_multiset<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C *p = &c;
+        c = *p;
+
+        assert(c.size() == 6);
+        assert(std::is_permutation(c.begin(), c.end(), a));
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..4eaf2c5
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        C c =   {
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        c =     {
+                    P(1),
+                    P(2),
+                    P(3),
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        C c =   {
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        c =     {
+                    P(1),
+                    P(2),
+                    P(3),
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..4b0e52c
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef min_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_multiset<int> s1 = {1, 2, 3};
+        std::unordered_multiset<int>::iterator i = s1.begin();
+        int k = *i;
+        std::unordered_multiset<int> s2;
+        s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..9424183
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == other_allocator<int>(-2));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..22e372b
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c(c0, test_allocator<int>(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(5));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c(c0, min_allocator<int>());
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
new file mode 100644
index 0000000..737ae2d
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        std::unordered_multiset<int> c = {};
+        assert(c.bucket_count() == 0);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 0000000..0effeed
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..c4c54a5
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// ~unordered_multiset() // implied noexcept;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
new file mode 100644
index 0000000..416c28c
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c = {
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c = {
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            };
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+        A a(42);
+        C c({
+                T(1),
+                T(2),
+                T(3),
+                T(4),
+                T(1),
+                T(2)
+            }, 12, a);
+
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+        A a(42);
+        HF hf(43);
+        C c({
+                T(1),
+                T(2),
+                T(3),
+                T(4),
+                T(1),
+                T(2)
+            }, 12, hf, a);
+
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..a6543a0
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..7d0f371
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+//               const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..cd013f9
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..4621c7f
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
new file mode 100644
index 0000000..a68cfe8
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_multiset<int> s1 = {1, 2, 3};
+        std::unordered_multiset<int>::iterator i = s1.begin();
+        int k = *i;
+        std::unordered_multiset<int> s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..9eee69a
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,213 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 4);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(12));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int P;
+        typedef min_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(std::move(c0), A());
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        C::const_iterator i = c.cbegin();
+        assert(*i == 4);
+        ++i;
+        assert(*i == 3);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+        ++i;
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef int P;
+        typedef min_allocator<int> A;
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(std::move(c0), A());
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..8a56d1a
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset& operator=(unordered_multiset&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 0000000..aa7ad05
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset(unordered_multiset&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
new file mode 100644
index 0000000..cd2bb1e
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
@@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_multiset<T, HF, Comp, A> C;
+        T arr[] =
+        {
+            T(1),
+            T(2),
+            T(3),
+            T(4),
+            T(1),
+            T(2)
+        };
+        A a(42);
+        C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a);
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_multiset<T, HF, Comp, A> C;
+        T arr[] =
+        {
+            T(1),
+            T(2),
+            T(3),
+            T(4),
+            T(1),
+            T(2)
+        };
+        HF hf(43);
+        A a(42);
+        C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a);
+        assert(c.bucket_count() >= 16);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..4f5e03e
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..6b83bde
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..89e7c7f
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..b712a96
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+//     unordered_multiset(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 6);
+        assert(c.count(1) == 2);
+        assert(c.count(2) == 2);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp
new file mode 100644
index 0000000..e55db7c
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp
new file mode 100644
index 0000000..35bfbe3
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..0171ea6
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..785cdf2
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..50dd3c9
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_multiset<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp
new file mode 100644
index 0000000..9470b1a
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::unordered_multiset<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::unordered_multiset<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::unordered_multiset<int>::iterator i1 = c1.begin();
+        std::unordered_multiset<int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        std::unordered_multiset<int>::iterator j = i1;
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..40dac3c
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// void swap(unordered_multiset& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash() {}
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_multiset<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/final/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..624b81c
--- /dev/null
+++ b/final/test/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 7);
+        assert(c2.size() == 6);
+        assert(c2.count(1) == 2);
+        assert(c2.count(2) == 2);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/bucket.pass.cpp b/final/test/containers/unord/unord.set/bucket.pass.cpp
new file mode 100644
index 0000000..0dae664
--- /dev/null
+++ b/final/test/containers/unord/unord.set/bucket.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 5);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        size_t bc = c.bucket_count();
+        assert(bc >= 5);
+        for (size_t i = 0; i < 13; ++i)
+            assert(c.bucket(i) == i % bc);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_set<int> C;
+        C c;
+        C::size_type i = c.bucket(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/bucket_count.pass.cpp b/final/test/containers/unord/unord.set/bucket_count.pass.cpp
new file mode 100644
index 0000000..caaa5a6
--- /dev/null
+++ b/final/test/containers/unord/unord.set/bucket_count.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        const C c;
+        assert(c.bucket_count() == 0);
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 11);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/bucket_size.pass.cpp b/final/test/containers/unord/unord.set/bucket_size.pass.cpp
new file mode 100644
index 0000000..628d557
--- /dev/null
+++ b/final/test/containers/unord/unord.set/bucket_size.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 5);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 1);
+        assert(c.bucket_size(2) == 1);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.bucket_count() >= 5);
+        assert(c.bucket_size(0) == 0);
+        assert(c.bucket_size(1) == 1);
+        assert(c.bucket_size(2) == 1);
+        assert(c.bucket_size(3) == 1);
+        assert(c.bucket_size(4) == 1);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_set<int> C;
+        C c;
+        C::size_type i = c.bucket_size(3);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/clear.pass.cpp b/final/test/containers/unord/unord.set/clear.pass.cpp
new file mode 100644
index 0000000..6da1530
--- /dev/null
+++ b/final/test/containers/unord/unord.set/clear.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        c.clear();
+        assert(c.size() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/count.pass.cpp b/final/test/containers/unord/unord.set/count.pass.cpp
new file mode 100644
index 0000000..83bb8aa
--- /dev/null
+++ b/final/test/containers/unord/unord.set/count.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 1);
+        assert(c.count(5) == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(c.count(30) == 1);
+        assert(c.count(50) == 1);
+        assert(c.count(5) == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/db_iterators_7.pass.cpp b/final/test/containers/unord/unord.set/db_iterators_7.pass.cpp
new file mode 100644
index 0000000..80b1a49
--- /dev/null
+++ b/final/test/containers/unord/unord.set/db_iterators_7.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_set<T> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_set<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/db_iterators_8.pass.cpp b/final/test/containers/unord/unord.set/db_iterators_8.pass.cpp
new file mode 100644
index 0000000..8b266bb
--- /dev/null
+++ b/final/test/containers/unord/unord.set/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_set<T> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_set<T, min_allocator<T>> C;
+    C c(1);
+    C::iterator i = c.end();
+    T j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp b/final/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp
new file mode 100644
index 0000000..b9fcb8c
--- /dev/null
+++ b/final/test/containers/unord/unord.set/db_local_iterators_7.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_set<T> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_set<T, min_allocator<T>> C;
+    C c(1);
+    C::local_iterator i = c.begin(0);
+    ++i;
+    ++i;
+    assert(false);
+    }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp b/final/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp
new file mode 100644
index 0000000..74d131b
--- /dev/null
+++ b/final/test/containers/unord/unord.set/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef int T;
+    typedef std::unordered_set<T> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    T j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef int T;
+    typedef std::unordered_set<T, min_allocator<T>> C;
+    C c(1);
+    C::local_iterator i = c.end(0);
+    T j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/emplace.pass.cpp b/final/test/containers/unord/unord.set/emplace.pass.cpp
new file mode 100644
index 0000000..d105e7a
--- /dev/null
+++ b/final/test/containers/unord/unord.set/emplace.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+//     pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_set<Emplaceable> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace();
+        assert(c.size() == 1);
+        assert(*r.first == Emplaceable());
+        assert(r.second);
+
+        r = c.emplace(Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r.first == Emplaceable(5, 6));
+        assert(r.second);
+
+        r = c.emplace(5, 6);
+        assert(c.size() == 2);
+        assert(*r.first == Emplaceable(5, 6));
+        assert(!r.second);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
+                      std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+        typedef std::pair<C::iterator, bool> R;
+        C c;
+        R r = c.emplace();
+        assert(c.size() == 1);
+        assert(*r.first == Emplaceable());
+        assert(r.second);
+
+        r = c.emplace(Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r.first == Emplaceable(5, 6));
+        assert(r.second);
+
+        r = c.emplace(5, 6);
+        assert(c.size() == 2);
+        assert(*r.first == Emplaceable(5, 6));
+        assert(!r.second);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.set/emplace_hint.pass.cpp b/final/test/containers/unord/unord.set/emplace_hint.pass.cpp
new file mode 100644
index 0000000..50b0035
--- /dev/null
+++ b/final/test/containers/unord/unord.set/emplace_hint.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+//     iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_set<Emplaceable> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e);
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace_hint(e, Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace_hint(r, 5, 6);
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
+                      std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+        typedef C::iterator R;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.emplace_hint(e);
+        assert(c.size() == 1);
+        assert(*r == Emplaceable());
+
+        r = c.emplace_hint(e, Emplaceable(5, 6));
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+
+        r = c.emplace_hint(r, 5, 6);
+        assert(c.size() == 2);
+        assert(*r == Emplaceable(5, 6));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_set<Emplaceable> C;
+        typedef C::iterator R;
+        C c1;
+        C c2;
+        R r = c1.emplace_hint(c2.begin(), 5, 6);
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.set/eq.pass.cpp b/final/test/containers/unord/unord.set/eq.pass.cpp
new file mode 100644
index 0000000..54a9c2e
--- /dev/null
+++ b/final/test/containers/unord/unord.set/eq.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_set<Key, Hash, Pred, Alloc>& x,
+//            const unordered_set<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_set<Key, Hash, Pred, Alloc>& x,
+//            const unordered_set<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2;
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c1(std::begin(a), std::end(a));
+        const C c2 = c1;
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a), std::end(a));
+        C c2 = c1;
+        c2.rehash(30);
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+        c2.insert(P(90));
+        assert(!(c1 == c2));
+        assert( (c1 != c2));
+        c1.insert(P(90));
+        assert( (c1 == c2));
+        assert(!(c1 != c2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/equal_range_const.pass.cpp b/final/test/containers/unord/unord.set/equal_range_const.pass.cpp
new file mode 100644
index 0000000..4168903
--- /dev/null
+++ b/final/test/containers/unord/unord.set/equal_range_const.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 50);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef C::const_iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 50);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/equal_range_non_const.pass.cpp b/final/test/containers/unord/unord.set/equal_range_non_const.pass.cpp
new file mode 100644
index 0000000..5a55083
--- /dev/null
+++ b/final/test/containers/unord/unord.set/equal_range_non_const.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef C::iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 50);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef C::iterator I;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(50),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        std::pair<I, I> r = c.equal_range(30);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 30);
+        r = c.equal_range(5);
+        assert(std::distance(r.first, r.second) == 0);
+        r = c.equal_range(50);
+        assert(std::distance(r.first, r.second) == 1);
+        assert(*r.first == 50);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/erase_const_iter.pass.cpp b/final/test/containers/unord/unord.set/erase_const_iter.pass.cpp
new file mode 100644
index 0000000..3a9cb58
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_const_iter.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::iterator j = c.erase(i);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/erase_iter_db1.pass.cpp b/final/test/containers/unord/unord.set/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000..231152d
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_iter_db1.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_set<int> l1(a1, a1+3);
+    std::unordered_set<int>::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/erase_iter_db2.pass.cpp b/final/test/containers/unord/unord.set/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000..06d61db
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_iter_db2.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_set<int> l1(a1, a1+3);
+    std::unordered_set<int> l2(a1, a1+3);
+    std::unordered_set<int>::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp b/final/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000..92c77f5
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_set<int> l1(a1, a1+3);
+    std::unordered_set<int> l2(a1, a1+3);
+    std::unordered_set<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp b/final/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000..d606658
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_set<int> l1(a1, a1+3);
+    std::unordered_set<int> l2(a1, a1+3);
+    std::unordered_set<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp b/final/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000..f7ff426
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_set<int> l1(a1, a1+3);
+    std::unordered_set<int> l2(a1, a1+3);
+    std::unordered_set<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp b/final/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000..6cde216
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+    {
+    int a1[] = {1, 2, 3};
+    std::unordered_set<int> l1(a1, a1+3);
+    std::unordered_set<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+    assert(false);
+    }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/containers/unord/unord.set/erase_key.pass.cpp b/final/test/containers/unord/unord.set/erase_key.pass.cpp
new file mode 100644
index 0000000..ca16508
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_key.pass.cpp
@@ -0,0 +1,175 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+    typename Unordered::const_iterator w = whole.begin();
+    typename Unordered::const_iterator p = part.begin();
+    
+    while ( w != whole.end () && p != part.end()) {
+        if ( *w == *p )
+            p++;
+        w++;
+        }
+
+    return p == part.end();
+}
+#endif
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.erase(5) == 0);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 1);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(2) == 0);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        assert(c.erase(4) == 1);
+        assert(c.size() == 2);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(4) == 0);
+        assert(c.size() == 2);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 1);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(1) == 0);
+        assert(c.size() == 1);
+        assert(c.count(3) == 1);
+
+        assert(c.erase(3) == 1);
+        assert(c.size() == 0);
+
+        assert(c.erase(3) == 0);
+        assert(c.size() == 0);
+    }
+    {
+    typedef std::unordered_set<int> C;
+    C m, m2;
+    for ( int i = 0; i < 10; ++i ) {
+        m.insert(i);
+        m2.insert(i);
+        }
+    
+    C::iterator i = m2.begin();
+    int ctr = 0;
+    while (i != m2.end()) {
+        if (ctr++ % 2 == 0)
+            m2.erase(i++);
+        else
+            ++i;
+        }
+
+    assert (only_deletions (m, m2));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/erase_range.pass.cpp b/final/test/containers/unord/unord.set/erase_range.pass.cpp
new file mode 100644
index 0000000..a8a9005
--- /dev/null
+++ b/final/test/containers/unord/unord.set/erase_range.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C::const_iterator i = c.find(2);
+        C::const_iterator j = next(i);
+        C::iterator k = c.erase(i, i);
+        assert(k == i);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(i, j);
+        assert(c.size() == 3);
+        assert(c.count(1) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+
+        k = c.erase(c.cbegin(), c.cend());
+        assert(c.size() == 0);
+        assert(k == c.end());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/find_const.pass.cpp b/final/test/containers/unord/unord.set/find_const.pass.cpp
new file mode 100644
index 0000000..e2238e5
--- /dev/null
+++ b/final/test/containers/unord/unord.set/find_const.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        C::const_iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/find_non_const.pass.cpp b/final/test/containers/unord/unord.set/find_non_const.pass.cpp
new file mode 100644
index 0000000..8afe32a
--- /dev/null
+++ b/final/test/containers/unord/unord.set/find_non_const.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c(std::begin(a), std::end(a));
+        C::iterator i = c.find(30);
+        assert(*i == 30);
+        i = c.find(5);
+        assert(i == c.cend());
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp b/final/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp
new file mode 100644
index 0000000..321e905
--- /dev/null
+++ b/final/test/containers/unord/unord.set/insert_const_lvalue.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(r.second);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(!r.second);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 2);
+        assert(*r.first == 4.5);
+        assert(r.second);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 3);
+        assert(*r.first == 5.5);
+        assert(r.second);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef C::value_type P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(r.second);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(!r.second);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 2);
+        assert(*r.first == 4.5);
+        assert(r.second);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 3);
+        assert(*r.first == 5.5);
+        assert(r.second);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/final/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 0000000..1393f54
--- /dev/null
+++ b/final/test/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 2);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 3);
+        assert(*r == 5.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 2);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 3);
+        assert(*r == 5.5);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_set<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        P v(3.5);
+        R r = c.insert(e, v);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/final/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
new file mode 100644
index 0000000..f612ec5
--- /dev/null
+++ b/final/test/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(r, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 2);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 3);
+        assert(*r == 5.5);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(r, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(e, P(4));
+        assert(c.size() == 2);
+        assert(*r == 4);
+
+        r = c.insert(e, P(5));
+        assert(c.size() == 3);
+        assert(*r == 5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef C::iterator R;
+        typedef double P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(r, P(3.5));
+        assert(c.size() == 1);
+        assert(*r == 3.5);
+
+        r = c.insert(e, P(4.5));
+        assert(c.size() == 2);
+        assert(*r == 4.5);
+
+        r = c.insert(e, P(5.5));
+        assert(c.size() == 3);
+        assert(*r == 5.5);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                            std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+        typedef C::iterator R;
+        typedef MoveOnly P;
+        C c;
+        C::const_iterator e = c.end();
+        R r = c.insert(e, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(r, P(3));
+        assert(c.size() == 1);
+        assert(*r == 3);
+
+        r = c.insert(e, P(4));
+        assert(c.size() == 2);
+        assert(*r == 4);
+
+        r = c.insert(e, P(5));
+        assert(c.size() == 3);
+        assert(*r == 5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::unordered_set<double> C;
+        typedef C::iterator R;
+        typedef C::value_type P;
+        C c;
+        C c2;
+        C::const_iterator e = c2.end();
+        R r = c.insert(e, P(3.5));
+        assert(false);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/insert_init.pass.cpp b/final/test/containers/unord/unord.set/insert_init.pass.cpp
new file mode 100644
index 0000000..2d8eafb
--- /dev/null
+++ b/final/test/containers/unord/unord.set/insert_init.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        C c;
+        c.insert(
+                    {
+                        P(1),
+                        P(2),
+                        P(3),
+                        P(4),
+                        P(1),
+                        P(2)
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        C c;
+        c.insert(
+                    {
+                        P(1),
+                        P(2),
+                        P(3),
+                        P(4),
+                        P(1),
+                        P(2)
+                    }
+                );
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.set/insert_range.pass.cpp b/final/test/containers/unord/unord.set/insert_range.pass.cpp
new file mode 100644
index 0000000..72a83ab
--- /dev/null
+++ b/final/test/containers/unord/unord.set/insert_range.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c;
+        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/insert_rvalue.pass.cpp b/final/test/containers/unord/unord.set/insert_rvalue.pass.cpp
new file mode 100644
index 0000000..d62308e
--- /dev/null
+++ b/final/test/containers/unord/unord.set/insert_rvalue.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<double> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef double P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(r.second);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(!r.second);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 2);
+        assert(*r.first == 4.5);
+        assert(r.second);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 3);
+        assert(*r.first == 5.5);
+        assert(r.second);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef MoveOnly P;
+        C c;
+        R r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r.first == 3);
+        assert(r.second);
+
+        r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r.first == 3);
+        assert(!r.second);
+
+        r = c.insert(P(4));
+        assert(c.size() == 2);
+        assert(*r.first == 4);
+        assert(r.second);
+
+        r = c.insert(P(5));
+        assert(c.size() == 3);
+        assert(*r.first == 5);
+        assert(r.second);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<double, std::hash<double>,
+                                std::equal_to<double>, min_allocator<double>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef double P;
+        C c;
+        R r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(r.second);
+
+        r = c.insert(P(3.5));
+        assert(c.size() == 1);
+        assert(*r.first == 3.5);
+        assert(!r.second);
+
+        r = c.insert(P(4.5));
+        assert(c.size() == 2);
+        assert(*r.first == 4.5);
+        assert(r.second);
+
+        r = c.insert(P(5.5));
+        assert(c.size() == 3);
+        assert(*r.first == 5.5);
+        assert(r.second);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                            std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+        typedef std::pair<C::iterator, bool> R;
+        typedef MoveOnly P;
+        C c;
+        R r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r.first == 3);
+        assert(r.second);
+
+        r = c.insert(P(3));
+        assert(c.size() == 1);
+        assert(*r.first == 3);
+        assert(!r.second);
+
+        r = c.insert(P(4));
+        assert(c.size() == 2);
+        assert(*r.first == 4);
+        assert(r.second);
+
+        r = c.insert(P(5));
+        assert(c.size() == 3);
+        assert(*r.first == 5);
+        assert(r.second);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/iterators.fail.cpp b/final/test/containers/unord/unord.set/iterators.fail.cpp
new file mode 100644
index 0000000..2bb180b
--- /dev/null
+++ b/final/test/containers/unord/unord.set/iterators.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i = c.begin();
+        assert(*i == 1);
+        *i = 2;
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 6);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+    }
+}
diff --git a/final/test/containers/unord/unord.set/iterators.pass.cpp b/final/test/containers/unord/unord.set/iterators.pass.cpp
new file mode 100644
index 0000000..d3a4580
--- /dev/null
+++ b/final/test/containers/unord/unord.set/iterators.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator       begin()        {return __table_.begin();}
+// iterator       end()          {return __table_.end();}
+// const_iterator begin()  const {return __table_.begin();}
+// const_iterator end()    const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend()   const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
+    }
+#endif
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::unordered_set<int> C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+
+        assert (!(ii1 != ii2 ));
+
+        assert ( (ii1 == cii ));
+        assert ( (cii == ii1 ));
+        assert (!(ii1 != cii ));
+        assert (!(cii != ii1 ));
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/load_factor.pass.cpp b/final/test/containers/unord/unord.set/load_factor.pass.cpp
new file mode 100644
index 0000000..e0ed169
--- /dev/null
+++ b/final/test/containers/unord/unord.set/load_factor.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        const C c(std::begin(a), std::end(a));
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        const C c;
+        assert(c.load_factor() == 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/local_iterators.fail.cpp b/final/test/containers/unord/unord.set/local_iterators.fail.cpp
new file mode 100644
index 0000000..eb671a4
--- /dev/null
+++ b/final/test/containers/unord/unord.set/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+        *i = 2;
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 1);
+        ++i;
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 2);
+        assert(*i == 2);
+        ++i;
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+
+        b = c.bucket(5);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(6);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+    }
+}
diff --git a/final/test/containers/unord/unord.set/local_iterators.pass.cpp b/final/test/containers/unord/unord.set/local_iterators.pass.cpp
new file mode 100644
index 0000000..2ffd93f
--- /dev/null
+++ b/final/test/containers/unord/unord.set/local_iterators.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator       begin (size_type n);
+// local_iterator       end   (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end   (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend  (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.begin(b);
+        I j = c.end(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.begin(b);
+        j = c.end(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        typedef C::const_local_iterator I;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        const C c(a, a + sizeof(a)/sizeof(a[0]));
+        assert(c.bucket_count() >= 5);
+        C::size_type b = c.bucket(0);
+        I i = c.cbegin(b);
+        I j = c.cend(b);
+        assert(std::distance(i, j) == 0);
+
+        b = c.bucket(1);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 1);
+
+        b = c.bucket(2);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 2);
+
+        b = c.bucket(3);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 3);
+
+        b = c.bucket(4);
+        i = c.cbegin(b);
+        j = c.cend(b);
+        assert(std::distance(i, j) == 1);
+        assert(*i == 4);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/max_bucket_count.pass.cpp b/final/test/containers/unord/unord.set/max_bucket_count.pass.cpp
new file mode 100644
index 0000000..8b5e265
--- /dev/null
+++ b/final/test/containers/unord/unord.set/max_bucket_count.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        const C c;
+        assert(c.max_bucket_count() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/max_load_factor.pass.cpp b/final/test/containers/unord/unord.set/max_load_factor.pass.cpp
new file mode 100644
index 0000000..d326f4a
--- /dev/null
+++ b/final/test/containers/unord/unord.set/max_load_factor.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        const C c;
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        C c;
+        assert(c.max_load_factor() == 1);
+        c.max_load_factor(2.5);
+        assert(c.max_load_factor() == 2.5);
+    }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+    {
+        typedef std::unordered_set<int> C;
+        C c;
+        c.max_load_factor(-0.5f);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/max_size.pass.cpp b/final/test/containers/unord/unord.set/max_size.pass.cpp
new file mode 100644
index 0000000..1c6e741
--- /dev/null
+++ b/final/test/containers/unord/unord.set/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::unordered_set<int> u;
+        assert(u.max_size() > 0);
+    }
+#if __cplusplus >= 201103L
+    {
+        std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> u;
+        assert(u.max_size() > 0);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/rehash.pass.cpp b/final/test/containers/unord/unord.set/rehash.pass.cpp
new file mode 100644
index 0000000..30fffa5
--- /dev/null
+++ b/final/test/containers/unord/unord.set/rehash.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 4);
+    assert(c.count(1) == 1);
+    assert(c.count(2) == 1);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.rehash(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.rehash(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.rehash(3);
+        assert(c.bucket_count() == 3);
+        test(c);
+        c.rehash(31);
+        assert(c.bucket_count() == 31);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/reserve.pass.cpp b/final/test/containers/unord/unord.set/reserve.pass.cpp
new file mode 100644
index 0000000..7d6656a
--- /dev/null
+++ b/final/test/containers/unord/unord.set/reserve.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+    assert(c.size() == 4);
+    assert(c.count(1) == 1);
+    assert(c.count(2) == 1);
+    assert(c.count(3) == 1);
+    assert(c.count(4) == 1);
+}
+
+int main()
+{
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.reserve(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() >= 2);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int, std::hash<int>,
+                                      std::equal_to<int>, min_allocator<int>> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        test(c);
+        assert(c.bucket_count() >= 5);
+        c.reserve(3);
+        assert(c.bucket_count() == 5);
+        test(c);
+        c.max_load_factor(2);
+        c.reserve(3);
+        assert(c.bucket_count() >= 2);
+        test(c);
+        c.reserve(31);
+        assert(c.bucket_count() >= 16);
+        test(c);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/swap_member.pass.cpp b/final/test/containers/unord/unord.set/swap_member.pass.cpp
new file mode 100644
index 0000000..89ec986
--- /dev/null
+++ b/final/test/containers/unord/unord.set/swap_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        c1.swap(c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/types.pass.cpp b/final/test/containers/unord/unord.set/types.pass.cpp
new file mode 100644
index 0000000..7e752a4
--- /dev/null
+++ b/final/test/containers/unord/unord.set/types.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+// {
+// public:
+//     // types
+//     typedef Value                                                      value_type;
+//     typedef value_type                                                 key_type;
+//     typedef Hash                                                       hasher;
+//     typedef Pred                                                       key_equal;
+//     typedef Alloc                                                      allocator_type;
+//     typedef value_type&                                                reference;
+//     typedef const value_type&                                          const_reference;
+//     typedef typename allocator_traits<allocator_type>::pointer         pointer;
+//     typedef typename allocator_traits<allocator_type>::const_pointer   const_pointer;
+//     typedef typename allocator_traits<allocator_type>::size_type       size_type;
+//     typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<short> C;
+        static_assert((std::is_same<C::value_type, short>::value), "");
+        static_assert((std::is_same<C::key_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+        static_assert((std::is_same<C::const_pointer, const C::value_type*>::value), "");
+        static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<short, std::hash<short>,
+                                  std::equal_to<short>, min_allocator<short>> C;
+        static_assert((std::is_same<C::value_type, short>::value), "");
+        static_assert((std::is_same<C::key_type, short>::value), "");
+        static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+        static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+        static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+        static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+        static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+        static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+        static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::value), "");
+    //  min_allocator doesn't have a size_type, so one gets synthesized
+        static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+        static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp
new file mode 100644
index 0000000..30905ae
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(test_allocator<NotConstructible>(10));
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(min_allocator<NotConstructible>{});
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == min_allocator<NotConstructible>());
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef NotConstructible T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_set<T, HF, Comp, A> C;
+
+        A a(43);
+        C c(3, a);
+        assert(c.bucket_count() == 3);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp ());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef NotConstructible T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_set<T, HF, Comp, A> C;
+
+        HF hf(42);
+        A a(43);
+        C c(4, hf, a);
+        assert(c.bucket_count() == 4);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp ());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
new file mode 100644
index 0000000..6925e30
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef std::unordered_set<int> C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(a, a + sizeof(a)/sizeof(a[0]));
+        C *p = &c;
+        c = *p;
+        assert(c.size() == 4);
+        assert(std::is_permutation(c.begin(), c.end(), a));
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = c0;
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
new file mode 100644
index 0000000..69d19a4
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        C c =   {
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        c =     {
+                    P(1),
+                    P(2),
+                    P(3),
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        C c =   {
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        c =     {
+                    P(1),
+                    P(2),
+                    P(3),
+                    P(4),
+                    P(1),
+                    P(2)
+                };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
new file mode 100644
index 0000000..e8712b7
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
@@ -0,0 +1,225 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(4));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(10)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef other_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A(4)
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef min_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(a, a + 2,
+            7,
+            test_hash<std::hash<int> >(2),
+            test_compare<std::equal_to<int> >(3),
+            A()
+           );
+        c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_set<int> s1 = {1, 2, 3};
+        std::unordered_set<int>::iterator i = s1.begin();
+        int k = *i;
+        std::unordered_set<int> s2;
+        s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..ee05acd
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   other_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            other_allocator<int>(10)
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == other_allocator<int>(-2));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c = c0;
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 0000000..8e1ecd8
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c(c0, test_allocator<int>(5));
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(5));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c(c0, min_allocator<int>());
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
new file mode 100644
index 0000000..6efa9ed
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c;
+        assert(c.bucket_count() == 0);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        std::unordered_set<int> c = {};
+        assert(c.bucket_count() == 0);
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 0000000..b3cd9c3
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set()
+//    noexcept(
+//        is_nothrow_default_constructible<allocator_type>::value &&
+//        is_nothrow_default_constructible<key_compare>::value &&
+//        is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp();
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..68ef7f4
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// ~unordered_set() // implied noexcept;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    ~some_comp() noexcept(false);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
new file mode 100644
index 0000000..2c31d57
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c = {
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c = {
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            };
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_set<T, HF, Comp, A> C;
+
+        A a(42);
+        C c({
+                T(1),
+                T(2),
+                T(3),
+                T(4),
+                T(1),
+                T(2)
+            }, 12, a);
+
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_set<T, HF, Comp, A> C;
+
+        A a(42);
+        HF hf(43);
+        C c({
+                T(1),
+                T(2),
+                T(3),
+                T(4),
+                T(1),
+                T(2)
+            }, 12, hf, a);
+
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
new file mode 100644
index 0000000..36dab79
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 0000000..81af2b4
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+//               const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..f35dd1a
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..34ff62e
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+//               const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        C c({
+                P(1),
+                P(2),
+                P(3),
+                P(4),
+                P(1),
+                P(2)
+            },
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
new file mode 100644
index 0000000..6bda4af
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 0);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        C c = std::move(c0);
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::unordered_set<int> s1 = {1, 2, 3};
+        std::unordered_set<int>::iterator i = s1.begin();
+        int k = *i;
+        std::unordered_set<int> s2 = std::move(s1);
+        assert(*i == k);
+        s2.erase(i);
+        assert(s2.size() == 2);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
new file mode 100644
index 0000000..229e799
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(12));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(12));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+    {
+        typedef int P;
+        typedef test_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A(10)
+           );
+        C c(std::move(c0), A(10));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef int P;
+        typedef min_allocator<int> A;
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   A
+                                   > C;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c0(a, a + sizeof(a)/sizeof(a[0]),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            A()
+           );
+        C c(std::move(c0), A());
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == A());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+
+        assert(c0.empty());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..c3c94fd
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set& operator=(unordered_set&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value &&
+//          is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp& operator=(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+    some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 0000000..791a67d
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set(unordered_set&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+//                 is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash();
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp
new file mode 100644
index 0000000..40f3f4f
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+        assert(c.bucket_count() >= 5);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_set<T, HF, Comp, A> C;
+        T arr[] =
+        {
+            T(1),
+            T(2),
+            T(3),
+            T(4),
+            T(1),
+            T(2)
+        };
+        A a(42);
+        C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a);
+        assert(c.bucket_count() >= 12);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == HF());
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+    {
+        typedef int T;
+        typedef test_hash<std::hash<T>> HF;
+        typedef test_compare<std::equal_to<T>> Comp;
+        typedef test_allocator<T> A;
+        typedef std::unordered_set<T, HF, Comp, A> C;
+        T arr[] =
+        {
+            T(1),
+            T(2),
+            T(3),
+            T(4),
+            T(1),
+            T(2)
+        };
+        HF hf(43);
+        A a(42);
+        C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a);
+        assert(c.bucket_count() >= 16);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == hf);
+        assert(!(c.hash_function() == HF()));
+        assert(c.key_eq() == Comp());
+        assert(c.get_allocator() == a);
+        assert(!(c.get_allocator() == A()));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+
+#endif
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp
new file mode 100644
index 0000000..179f73d
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >());
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 0000000..60350de
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >());
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 0000000..70e82d0
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..a6fb2e6
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+//     unordered_set(InputIterator first, InputIterator last, size_type n,
+//                   const hasher& hf, const key_equal& eql,
+//                   const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   test_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            test_allocator<int>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == test_allocator<int>(10));
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<int,
+                                   test_hash<std::hash<int> >,
+                                   test_compare<std::equal_to<int> >,
+                                   min_allocator<int>
+                                   > C;
+        typedef int P;
+        P a[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+            7,
+            test_hash<std::hash<int> >(8),
+            test_compare<std::equal_to<int> >(9),
+            min_allocator<int>()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.size() == 4);
+        assert(c.count(1) == 1);
+        assert(c.count(2) == 1);
+        assert(c.count(3) == 1);
+        assert(c.count(4) == 1);
+        assert(c.hash_function() == test_hash<std::hash<int> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+        assert(c.get_allocator() == min_allocator<int>());
+        assert(!c.empty());
+        assert(std::distance(c.begin(), c.end()) == c.size());
+        assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp
new file mode 100644
index 0000000..389c54c
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c = 7;
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp
new file mode 100644
index 0000000..8f6228a
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7);
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp
new file mode 100644
index 0000000..4c2c18e
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 0000000..e936878
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp b/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 0000000..96233e1
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   test_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            test_allocator<NotConstructible>(10)
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::unordered_set<NotConstructible,
+                                   test_hash<std::hash<NotConstructible> >,
+                                   test_compare<std::equal_to<NotConstructible> >,
+                                   min_allocator<NotConstructible>
+                                   > C;
+        C c(7,
+            test_hash<std::hash<NotConstructible> >(8),
+            test_compare<std::equal_to<NotConstructible> >(9),
+            min_allocator<NotConstructible>()
+           );
+        assert(c.bucket_count() == 7);
+        assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+        assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+        assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+        assert(c.size() == 0);
+        assert(c.empty());
+        assert(std::distance(c.begin(), c.end()) == 0);
+        assert(c.load_factor() == 0);
+        assert(c.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp b/final/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp
new file mode 100644
index 0000000..2e8250e
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+    {
+        int a1[] = {1, 3, 7, 9, 10};
+        int a2[] = {0, 2, 4, 5, 6, 8, 11};
+        std::unordered_set<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::unordered_set<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+        std::unordered_set<int>::iterator i1 = c1.begin();
+        std::unordered_set<int>::iterator i2 = c2.begin();
+        swap(c1, c2);
+        c1.erase(i2);
+        c2.erase(i1);
+        std::unordered_set<int>::iterator j = i1;
+        c1.erase(i1);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/final/test/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..359e296
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// void swap(unordered_set& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+    typedef T value_type;
+    
+    some_comp() {}
+    some_comp(const some_comp&) {}
+};
+
+template <class T>
+struct some_hash
+{
+    typedef T value_type;
+    some_hash() {}
+    some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::unordered_set<MoveOnly> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                           std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                          std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+                                                         some_comp<MoveOnly>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/final/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
new file mode 100644
index 0000000..7415e29
--- /dev/null
+++ b/final/test/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+//           class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef test_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(1));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(2));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef other_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc(2));
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc(1));
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() == 0);
+        assert(c2.size() == 0);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() == 0);
+        assert(c1.size() == 0);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+    {
+        typedef test_hash<std::hash<int> > Hash;
+        typedef test_compare<std::equal_to<int> > Compare;
+        typedef min_allocator<int> Alloc;
+        typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+        typedef int P;
+        P a1[] =
+        {
+            P(1),
+            P(2),
+            P(3),
+            P(4),
+            P(1),
+            P(2)
+        };
+        P a2[] =
+        {
+            P(10),
+            P(20),
+            P(30),
+            P(40),
+            P(50),
+            P(60),
+            P(70),
+            P(80)
+        };
+        C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+        C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+        c2.max_load_factor(2);
+        swap(c1, c2);
+
+        assert(c1.bucket_count() >= 11);
+        assert(c1.size() == 8);
+        assert(*c1.find(10) == 10);
+        assert(*c1.find(20) == 20);
+        assert(*c1.find(30) == 30);
+        assert(*c1.find(40) == 40);
+        assert(*c1.find(50) == 50);
+        assert(*c1.find(60) == 60);
+        assert(*c1.find(70) == 70);
+        assert(*c1.find(80) == 80);
+        assert(c1.hash_function() == Hash(2));
+        assert(c1.key_eq() == Compare(2));
+        assert(c1.get_allocator() == Alloc());
+        assert(std::distance(c1.begin(), c1.end()) == c1.size());
+        assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+        assert(c1.max_load_factor() == 2);
+
+        assert(c2.bucket_count() >= 5);
+        assert(c2.size() == 4);
+        assert(c2.count(1) == 1);
+        assert(c2.count(2) == 1);
+        assert(c2.count(3) == 1);
+        assert(c2.count(4) == 1);
+        assert(c2.hash_function() == Hash(1));
+        assert(c2.key_eq() == Compare(1));
+        assert(c2.get_allocator() == Alloc());
+        assert(std::distance(c2.begin(), c2.end()) == c2.size());
+        assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+        assert(c2.max_load_factor() == 1);
+    }
+#endif
+}
diff --git a/final/test/containers/unord/unord.set/version.pass.cpp b/final/test/containers/unord/unord.set/version.pass.cpp
new file mode 100644
index 0000000..d651ebd
--- /dev/null
+++ b/final/test/containers/unord/unord.set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+#include <unordered_set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/A.h b/final/test/depr/depr.auto.ptr/auto.ptr/A.h
new file mode 100644
index 0000000..cc16abe
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/A.h
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 A_H
+#define A_H
+
+#include <cassert>
+
+class A
+{
+    int id_;
+public:
+    explicit A(int id) : id_(id) {++count;}
+    A(const A& a) : id_(a.id_) {++count;}
+    ~A() {assert(id_ >= 0); id_ = -1; --count;}
+
+    int id() const {return id_;}
+
+    static int count;
+};
+
+int A::count = 0;
+
+#endif  // A_H
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/AB.h b/final/test/depr/depr.auto.ptr/auto.ptr/AB.h
new file mode 100644
index 0000000..b7ec988
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/AB.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 AB_H
+#define AB_H
+
+#include <cassert>
+
+class A
+{
+    int id_;
+public:
+    explicit A(int id) : id_(id) {++count;}
+    A(const A& a) : id_(a.id_) {++count;}
+    virtual ~A() {assert(id_ >= 0); id_ = -1; --count;}
+
+    static int count;
+};
+
+int A::count = 0;
+
+class B
+    : public A
+{
+public:
+    explicit B(int id) : A(id) {++count;}
+    B(const B& a) : A(a) {++count;}
+    virtual ~B() {--count;}
+
+    static int count;
+};
+
+int B::count = 0;
+
+#endif  // AB_H
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp
new file mode 100644
index 0000000..88f0904
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.fail.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p1 = new A(1);
+    const std::auto_ptr<A> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp
new file mode 100644
index 0000000..2c6acb5
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/assignment.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p1 = new A(1);
+    std::auto_ptr<A> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp
new file mode 100644
index 0000000..d5f38c1
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p = new B(1);
+    const std::auto_ptr<B> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
new file mode 100644
index 0000000..aeea7de
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p = new B(1);
+    std::auto_ptr<B> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp
new file mode 100644
index 0000000..be95d2c
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p1 = new B(1);
+    const std::auto_ptr<B> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(B::count == 1);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
new file mode 100644
index 0000000..6809073
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/convert_assignment.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p1 = new B(1);
+    std::auto_ptr<B> ap1(p1);
+    A* p2 = new A(2);
+    std::auto_ptr<A> ap2(p2);
+    assert(A::count == 2);
+    assert(B::count == 1);
+    assert(ap1.get() == p1);
+    assert(ap2.get() == p2);
+    std::auto_ptr<A>& apr = ap2 = ap1;
+    assert(&apr == &ap2);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp
new file mode 100644
index 0000000..78423e5
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    const std::auto_ptr<A> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
new file mode 100644
index 0000000..27ba0e5
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/copy.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr& a) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap1(p);
+    std::auto_ptr<A> ap2(ap1);
+    assert(ap1.get() == 0);
+    assert(ap2.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp
new file mode 100644
index 0000000..54eb162
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/explicit.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// explicit auto_ptr(X* p =0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap = p;
+    assert(ap.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    std::auto_ptr<A> ap;
+    assert(ap.get() == 0);
+    }
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
new file mode 100644
index 0000000..e29ff2e
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.cons/pointer.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// explicit auto_ptr(X* p =0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    assert(ap.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    std::auto_ptr<A> ap;
+    assert(ap.get() == 0);
+    }
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
new file mode 100644
index 0000000..6f53581
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/assign_from_auto_ptr_ref.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr& operator=(auto_ptr_ref<X> r) throw()
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p1 = new A(1);
+    std::auto_ptr<A> ap1(p1);
+    std::auto_ptr_ref<A> apr = ap1;
+    std::auto_ptr<A> ap2(new A(2));
+    ap2 = apr;
+    assert(A::count == 1);
+    assert(ap2.get() == p1);
+    assert(ap1.get() == 0);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
new file mode 100644
index 0000000..3757805
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_from_auto_ptr_ref.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// auto_ptr(auto_ptr_ref<X> r) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    {
+    B* p1 = new B(1);
+    std::auto_ptr<B> ap1(p1);
+    std::auto_ptr_ref<A> apr = ap1;
+    std::auto_ptr<A> ap2(apr);
+    assert(ap2.get() == p1);
+    assert(ap1.get() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp
new file mode 100644
index 0000000..00c0f6d
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> operator auto_ptr<Y>() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+std::auto_ptr<B>
+source()
+{
+    return std::auto_ptr<B>(new B(1));
+}
+
+void
+test()
+{
+    std::auto_ptr<A> ap2(source());
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
new file mode 100644
index 0000000..f61a28e
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// template<class Y> operator auto_ptr_ref<Y>() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../AB.h"
+
+void
+test()
+{
+    B* p1 = new B(1);
+    std::auto_ptr<B> ap1(p1);
+    std::auto_ptr_ref<A> apr = ap1;
+    delete p1;
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp
new file mode 100644
index 0000000..fce9332
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/arrow.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X& operator*() const throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    assert(ap->id() == 1);
+    *ap = A(3);
+    assert(ap->id() == 3);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
new file mode 100644
index 0000000..dd56695
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/deref.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X& operator*() const throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    const std::auto_ptr<A> ap(p);
+    assert((*ap).id() == 1);
+    *ap = A(3);
+    assert((*ap).id() == 3);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
new file mode 100644
index 0000000..5860eb4
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/release.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// X* release() throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    A* p2 = ap.release();
+    assert(p2 == p);
+    assert(ap.get() == 0);
+    delete p;
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
new file mode 100644
index 0000000..cdbdd73
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/auto.ptr.members/reset.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X> class auto_ptr;
+
+// void reset(X* p=0) throw();
+
+#include <memory>
+#include <cassert>
+
+#include "../A.h"
+
+void
+test()
+{
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    ap.reset();
+    assert(ap.get() == 0);
+    assert(A::count == 0);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    ap.reset(p);
+    assert(ap.get() == p);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A(1);
+    std::auto_ptr<A> ap(p);
+    A* p2 = new A(2);
+    ap.reset(p2);
+    assert(ap.get() == p2);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp b/final/test/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
new file mode 100644
index 0000000..2d1c2af
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class X>
+// class auto_ptr
+// {
+// public:
+//   typedef X element_type;
+//   ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_same<typename std::auto_ptr<T>::element_type, T>::value), "");
+}
+
+int main()
+{
+    test<int>();
+    test<double>();
+    test<void>();
+    std::auto_ptr<void> p;
+}
diff --git a/final/test/depr/depr.auto.ptr/nothing_to_do.pass.cpp b/final/test/depr/depr.auto.ptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/depr/depr.auto.ptr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/assert_h.pass.cpp b/final/test/depr/depr.c.headers/assert_h.pass.cpp
new file mode 100644
index 0000000..39a7346
--- /dev/null
+++ b/final/test/depr/depr.c.headers/assert_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <assert.h>
+
+#include <assert.h>
+
+#ifndef assert
+#error assert not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/ciso646.pass.cpp b/final/test/depr/depr.c.headers/ciso646.pass.cpp
new file mode 100644
index 0000000..725a7ab
--- /dev/null
+++ b/final/test/depr/depr.c.headers/ciso646.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ciso646>
+
+#include <ciso646>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/complex.h.pass.cpp b/final/test/depr/depr.c.headers/complex.h.pass.cpp
new file mode 100644
index 0000000..da07079
--- /dev/null
+++ b/final/test/depr/depr.c.headers/complex.h.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex.h>
+
+#include <complex.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> d;
+}
diff --git a/final/test/depr/depr.c.headers/ctype_h.pass.cpp b/final/test/depr/depr.c.headers/ctype_h.pass.cpp
new file mode 100644
index 0000000..042084e
--- /dev/null
+++ b/final/test/depr/depr.c.headers/ctype_h.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctype.h>
+
+#include <ctype.h>
+#include <type_traits>
+#include <cassert>
+
+#ifdef isalnum
+#error isalnum defined
+#endif
+
+#ifdef isalpha
+#error isalpha defined
+#endif
+
+#ifdef isblank
+#error isblank defined
+#endif
+
+#ifdef iscntrl
+#error iscntrl defined
+#endif
+
+#ifdef isdigit
+#error isdigit defined
+#endif
+
+#ifdef isgraph
+#error isgraph defined
+#endif
+
+#ifdef islower
+#error islower defined
+#endif
+
+#ifdef isprint
+#error isprint defined
+#endif
+
+#ifdef ispunct
+#error ispunct defined
+#endif
+
+#ifdef isspace
+#error isspace defined
+#endif
+
+#ifdef isupper
+#error isupper defined
+#endif
+
+#ifdef isxdigit
+#error isxdigit defined
+#endif
+
+#ifdef tolower
+#error tolower defined
+#endif
+
+#ifdef toupper
+#error toupper defined
+#endif
+
+int main()
+{
+    static_assert((std::is_same<decltype(isalnum(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isalpha(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isblank(0)), int>::value), "");
+    static_assert((std::is_same<decltype(iscntrl(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isgraph(0)), int>::value), "");
+    static_assert((std::is_same<decltype(islower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isprint(0)), int>::value), "");
+    static_assert((std::is_same<decltype(ispunct(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isspace(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isupper(0)), int>::value), "");
+    static_assert((std::is_same<decltype(isxdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(tolower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(toupper(0)), int>::value), "");
+
+    assert(isalnum('a'));
+    assert(isalpha('a'));
+    assert(isblank(' '));
+    assert(!iscntrl(' '));
+    assert(!isdigit('a'));
+    assert(isgraph('a'));
+    assert(islower('a'));
+    assert(isprint('a'));
+    assert(!ispunct('a'));
+    assert(!isspace('a'));
+    assert(!isupper('a'));
+    assert(isxdigit('a'));
+    assert(tolower('A') == 'a');
+    assert(toupper('a') == 'A');
+}
diff --git a/final/test/depr/depr.c.headers/errno_h.pass.cpp b/final/test/depr/depr.c.headers/errno_h.pass.cpp
new file mode 100644
index 0000000..4d955a5
--- /dev/null
+++ b/final/test/depr/depr.c.headers/errno_h.pass.cpp
@@ -0,0 +1,33 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <errno.h>
+
+#include <errno.h>
+
+#ifndef EDOM
+#error EDOM not defined
+#endif
+
+#ifndef EILSEQ
+#error EILSEQ not defined
+#endif
+
+#ifndef ERANGE
+#error ERANGE not defined
+#endif
+
+#ifndef errno
+#error errno not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/fenv_h.pass.cpp b/final/test/depr/depr.c.headers/fenv_h.pass.cpp
new file mode 100644
index 0000000..653eb93
--- /dev/null
+++ b/final/test/depr/depr.c.headers/fenv_h.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fenv.h>
+
+#include <fenv.h>
+#include <type_traits>
+
+#ifndef FE_DIVBYZERO
+#error FE_DIVBYZERO not defined
+#endif
+
+#ifndef FE_INEXACT
+#error FE_INEXACT not defined
+#endif
+
+#ifndef FE_INVALID
+#error FE_INVALID not defined
+#endif
+
+#ifndef FE_OVERFLOW
+#error FE_OVERFLOW not defined
+#endif
+
+#ifndef FE_UNDERFLOW
+#error FE_UNDERFLOW not defined
+#endif
+
+#ifndef FE_ALL_EXCEPT
+#error FE_ALL_EXCEPT not defined
+#endif
+
+#ifndef FE_DOWNWARD
+#error FE_DOWNWARD not defined
+#endif
+
+#ifndef FE_TONEAREST
+#error FE_TONEAREST not defined
+#endif
+
+#ifndef FE_TOWARDZERO
+#error FE_TOWARDZERO not defined
+#endif
+
+#ifndef FE_UPWARD
+#error FE_UPWARD not defined
+#endif
+
+#ifndef FE_DFL_ENV
+#error FE_DFL_ENV not defined
+#endif
+
+int main()
+{
+    fenv_t fenv = {0};
+    fexcept_t fex = 0;
+    static_assert((std::is_same<decltype(feclearexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fegetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(feraiseexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fesetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(fetestexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fegetround()), int>::value), "");
+    static_assert((std::is_same<decltype(fesetround(0)), int>::value), "");
+    static_assert((std::is_same<decltype(fegetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(feholdexcept(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(fesetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(feupdateenv(&fenv)), int>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/float_h.pass.cpp b/final/test/depr/depr.c.headers/float_h.pass.cpp
new file mode 100644
index 0000000..5b2e451
--- /dev/null
+++ b/final/test/depr/depr.c.headers/float_h.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test <float.h>
+
+#include <float.h>
+
+#ifndef FLT_ROUNDS
+#error FLT_ROUNDS not defined
+#endif
+
+#ifndef FLT_EVAL_METHOD
+#error FLT_EVAL_METHOD not defined
+#endif
+
+#ifndef FLT_RADIX
+#error FLT_RADIX not defined
+#endif
+
+#ifndef FLT_MANT_DIG
+#error FLT_MANT_DIG not defined
+#endif
+
+#ifndef DBL_MANT_DIG
+#error DBL_MANT_DIG not defined
+#endif
+
+#ifndef LDBL_MANT_DIG
+#error LDBL_MANT_DIG not defined
+#endif
+
+#ifndef DECIMAL_DIG
+#error DECIMAL_DIG not defined
+#endif
+
+#ifndef FLT_DIG
+#error FLT_DIG not defined
+#endif
+
+#ifndef DBL_DIG
+#error DBL_DIG not defined
+#endif
+
+#ifndef LDBL_DIG
+#error LDBL_DIG not defined
+#endif
+
+#ifndef FLT_MIN_EXP
+#error FLT_MIN_EXP not defined
+#endif
+
+#ifndef DBL_MIN_EXP
+#error DBL_MIN_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_EXP
+#error LDBL_MIN_EXP not defined
+#endif
+
+#ifndef FLT_MIN_10_EXP
+#error FLT_MIN_10_EXP not defined
+#endif
+
+#ifndef DBL_MIN_10_EXP
+#error DBL_MIN_10_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_10_EXP
+#error LDBL_MIN_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX_EXP
+#error FLT_MAX_EXP not defined
+#endif
+
+#ifndef DBL_MAX_EXP
+#error DBL_MAX_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_EXP
+#error LDBL_MAX_EXP not defined
+#endif
+
+#ifndef FLT_MAX_10_EXP
+#error FLT_MAX_10_EXP not defined
+#endif
+
+#ifndef DBL_MAX_10_EXP
+#error DBL_MAX_10_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_10_EXP
+#error LDBL_MAX_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX
+#error FLT_MAX not defined
+#endif
+
+#ifndef DBL_MAX
+#error DBL_MAX not defined
+#endif
+
+#ifndef LDBL_MAX
+#error LDBL_MAX not defined
+#endif
+
+#ifndef FLT_EPSILON
+#error FLT_EPSILON not defined
+#endif
+
+#ifndef DBL_EPSILON
+#error DBL_EPSILON not defined
+#endif
+
+#ifndef LDBL_EPSILON
+#error LDBL_EPSILON not defined
+#endif
+
+#ifndef FLT_MIN
+#error FLT_MIN not defined
+#endif
+
+#ifndef DBL_MIN
+#error DBL_MIN not defined
+#endif
+
+#ifndef LDBL_MIN
+#error LDBL_MIN not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/inttypes_h.pass.cpp b/final/test/depr/depr.c.headers/inttypes_h.pass.cpp
new file mode 100644
index 0000000..4adf82d
--- /dev/null
+++ b/final/test/depr/depr.c.headers/inttypes_h.pass.cpp
@@ -0,0 +1,643 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <inttypes.h>
+
+#include <inttypes.h>
+#include <type_traits>
+
+#ifndef PRId8
+#error PRId8 not defined
+#endif
+
+#ifndef PRId16
+#error PRId16 not defined
+#endif
+
+#ifndef PRId32
+#error PRId32 not defined
+#endif
+
+#ifndef PRId64
+#error PRId64 not defined
+#endif
+
+#ifndef PRIdLEAST8
+#error PRIdLEAST8 not defined
+#endif
+
+#ifndef PRIdLEAST16
+#error PRIdLEAST16 not defined
+#endif
+
+#ifndef PRIdLEAST32
+#error PRIdLEAST32 not defined
+#endif
+
+#ifndef PRIdLEAST64
+#error PRIdLEAST64 not defined
+#endif
+
+#ifndef PRIdFAST8
+#error PRIdFAST8 not defined
+#endif
+
+#ifndef PRIdFAST16
+#error PRIdFAST16 not defined
+#endif
+
+#ifndef PRIdFAST32
+#error PRIdFAST32 not defined
+#endif
+
+#ifndef PRIdFAST64
+#error PRIdFAST64 not defined
+#endif
+
+#ifndef PRIdMAX
+#error PRIdMAX not defined
+#endif
+
+#ifndef PRIdPTR
+#error PRIdPTR not defined
+#endif
+
+#ifndef PRIi8
+#error PRIi8 not defined
+#endif
+
+#ifndef PRIi16
+#error PRIi16 not defined
+#endif
+
+#ifndef PRIi32
+#error PRIi32 not defined
+#endif
+
+#ifndef PRIi64
+#error PRIi64 not defined
+#endif
+
+#ifndef PRIiLEAST8
+#error PRIiLEAST8 not defined
+#endif
+
+#ifndef PRIiLEAST16
+#error PRIiLEAST16 not defined
+#endif
+
+#ifndef PRIiLEAST32
+#error PRIiLEAST32 not defined
+#endif
+
+#ifndef PRIiLEAST64
+#error PRIiLEAST64 not defined
+#endif
+
+#ifndef PRIiFAST8
+#error PRIiFAST8 not defined
+#endif
+
+#ifndef PRIiFAST16
+#error PRIiFAST16 not defined
+#endif
+
+#ifndef PRIiFAST32
+#error PRIiFAST32 not defined
+#endif
+
+#ifndef PRIiFAST64
+#error PRIiFAST64 not defined
+#endif
+
+#ifndef PRIiMAX
+#error PRIiMAX not defined
+#endif
+
+#ifndef PRIiPTR
+#error PRIiPTR not defined
+#endif
+
+#ifndef PRIo8
+#error PRIo8 not defined
+#endif
+
+#ifndef PRIo16
+#error PRIo16 not defined
+#endif
+
+#ifndef PRIo32
+#error PRIo32 not defined
+#endif
+
+#ifndef PRIo64
+#error PRIo64 not defined
+#endif
+
+#ifndef PRIoLEAST8
+#error PRIoLEAST8 not defined
+#endif
+
+#ifndef PRIoLEAST16
+#error PRIoLEAST16 not defined
+#endif
+
+#ifndef PRIoLEAST32
+#error PRIoLEAST32 not defined
+#endif
+
+#ifndef PRIoLEAST64
+#error PRIoLEAST64 not defined
+#endif
+
+#ifndef PRIoFAST8
+#error PRIoFAST8 not defined
+#endif
+
+#ifndef PRIoFAST16
+#error PRIoFAST16 not defined
+#endif
+
+#ifndef PRIoFAST32
+#error PRIoFAST32 not defined
+#endif
+
+#ifndef PRIoFAST64
+#error PRIoFAST64 not defined
+#endif
+
+#ifndef PRIoMAX
+#error PRIoMAX not defined
+#endif
+
+#ifndef PRIoPTR
+#error PRIoPTR not defined
+#endif
+
+#ifndef PRIu8
+#error PRIu8 not defined
+#endif
+
+#ifndef PRIu16
+#error PRIu16 not defined
+#endif
+
+#ifndef PRIu32
+#error PRIu32 not defined
+#endif
+
+#ifndef PRIu64
+#error PRIu64 not defined
+#endif
+
+#ifndef PRIuLEAST8
+#error PRIuLEAST8 not defined
+#endif
+
+#ifndef PRIuLEAST16
+#error PRIuLEAST16 not defined
+#endif
+
+#ifndef PRIuLEAST32
+#error PRIuLEAST32 not defined
+#endif
+
+#ifndef PRIuLEAST64
+#error PRIuLEAST64 not defined
+#endif
+
+#ifndef PRIuFAST8
+#error PRIuFAST8 not defined
+#endif
+
+#ifndef PRIuFAST16
+#error PRIuFAST16 not defined
+#endif
+
+#ifndef PRIuFAST32
+#error PRIuFAST32 not defined
+#endif
+
+#ifndef PRIuFAST64
+#error PRIuFAST64 not defined
+#endif
+
+#ifndef PRIuMAX
+#error PRIuMAX not defined
+#endif
+
+#ifndef PRIuPTR
+#error PRIuPTR not defined
+#endif
+
+#ifndef PRIx8
+#error PRIx8 not defined
+#endif
+
+#ifndef PRIx16
+#error PRIx16 not defined
+#endif
+
+#ifndef PRIx32
+#error PRIx32 not defined
+#endif
+
+#ifndef PRIx64
+#error PRIx64 not defined
+#endif
+
+#ifndef PRIxLEAST8
+#error PRIxLEAST8 not defined
+#endif
+
+#ifndef PRIxLEAST16
+#error PRIxLEAST16 not defined
+#endif
+
+#ifndef PRIxLEAST32
+#error PRIxLEAST32 not defined
+#endif
+
+#ifndef PRIxLEAST64
+#error PRIxLEAST64 not defined
+#endif
+
+#ifndef PRIxFAST8
+#error PRIxFAST8 not defined
+#endif
+
+#ifndef PRIxFAST16
+#error PRIxFAST16 not defined
+#endif
+
+#ifndef PRIxFAST32
+#error PRIxFAST32 not defined
+#endif
+
+#ifndef PRIxFAST64
+#error PRIxFAST64 not defined
+#endif
+
+#ifndef PRIxMAX
+#error PRIxMAX not defined
+#endif
+
+#ifndef PRIxPTR
+#error PRIxPTR not defined
+#endif
+
+#ifndef PRIX8
+#error PRIX8 not defined
+#endif
+
+#ifndef PRIX16
+#error PRIX16 not defined
+#endif
+
+#ifndef PRIX32
+#error PRIX32 not defined
+#endif
+
+#ifndef PRIX64
+#error PRIX64 not defined
+#endif
+
+#ifndef PRIXLEAST8
+#error PRIXLEAST8 not defined
+#endif
+
+#ifndef PRIXLEAST16
+#error PRIXLEAST16 not defined
+#endif
+
+#ifndef PRIXLEAST32
+#error PRIXLEAST32 not defined
+#endif
+
+#ifndef PRIXLEAST64
+#error PRIXLEAST64 not defined
+#endif
+
+#ifndef PRIXFAST8
+#error PRIXFAST8 not defined
+#endif
+
+#ifndef PRIXFAST16
+#error PRIXFAST16 not defined
+#endif
+
+#ifndef PRIXFAST32
+#error PRIXFAST32 not defined
+#endif
+
+#ifndef PRIXFAST64
+#error PRIXFAST64 not defined
+#endif
+
+#ifndef PRIXMAX
+#error PRIXMAX not defined
+#endif
+
+#ifndef PRIXPTR
+#error PRIXPTR not defined
+#endif
+
+#ifndef SCNd8
+#error SCNd8 not defined
+#endif
+
+#ifndef SCNd16
+#error SCNd16 not defined
+#endif
+
+#ifndef SCNd32
+#error SCNd32 not defined
+#endif
+
+#ifndef SCNd64
+#error SCNd64 not defined
+#endif
+
+#ifndef SCNdLEAST8
+#error SCNdLEAST8 not defined
+#endif
+
+#ifndef SCNdLEAST16
+#error SCNdLEAST16 not defined
+#endif
+
+#ifndef SCNdLEAST32
+#error SCNdLEAST32 not defined
+#endif
+
+#ifndef SCNdLEAST64
+#error SCNdLEAST64 not defined
+#endif
+
+#ifndef SCNdFAST8
+#error SCNdFAST8 not defined
+#endif
+
+#ifndef SCNdFAST16
+#error SCNdFAST16 not defined
+#endif
+
+#ifndef SCNdFAST32
+#error SCNdFAST32 not defined
+#endif
+
+#ifndef SCNdFAST64
+#error SCNdFAST64 not defined
+#endif
+
+#ifndef SCNdMAX
+#error SCNdMAX not defined
+#endif
+
+#ifndef SCNdPTR
+#error SCNdPTR not defined
+#endif
+
+#ifndef SCNi8
+#error SCNi8 not defined
+#endif
+
+#ifndef SCNi16
+#error SCNi16 not defined
+#endif
+
+#ifndef SCNi32
+#error SCNi32 not defined
+#endif
+
+#ifndef SCNi64
+#error SCNi64 not defined
+#endif
+
+#ifndef SCNiLEAST8
+#error SCNiLEAST8 not defined
+#endif
+
+#ifndef SCNiLEAST16
+#error SCNiLEAST16 not defined
+#endif
+
+#ifndef SCNiLEAST32
+#error SCNiLEAST32 not defined
+#endif
+
+#ifndef SCNiLEAST64
+#error SCNiLEAST64 not defined
+#endif
+
+#ifndef SCNiFAST8
+#error SCNiFAST8 not defined
+#endif
+
+#ifndef SCNiFAST16
+#error SCNiFAST16 not defined
+#endif
+
+#ifndef SCNiFAST32
+#error SCNiFAST32 not defined
+#endif
+
+#ifndef SCNiFAST64
+#error SCNiFAST64 not defined
+#endif
+
+#ifndef SCNiMAX
+#error SCNiMAX not defined
+#endif
+
+#ifndef SCNiPTR
+#error SCNiPTR not defined
+#endif
+
+#ifndef SCNo8
+#error SCNo8 not defined
+#endif
+
+#ifndef SCNo16
+#error SCNo16 not defined
+#endif
+
+#ifndef SCNo32
+#error SCNo32 not defined
+#endif
+
+#ifndef SCNo64
+#error SCNo64 not defined
+#endif
+
+#ifndef SCNoLEAST8
+#error SCNoLEAST8 not defined
+#endif
+
+#ifndef SCNoLEAST16
+#error SCNoLEAST16 not defined
+#endif
+
+#ifndef SCNoLEAST32
+#error SCNoLEAST32 not defined
+#endif
+
+#ifndef SCNoLEAST64
+#error SCNoLEAST64 not defined
+#endif
+
+#ifndef SCNoFAST8
+#error SCNoFAST8 not defined
+#endif
+
+#ifndef SCNoFAST16
+#error SCNoFAST16 not defined
+#endif
+
+#ifndef SCNoFAST32
+#error SCNoFAST32 not defined
+#endif
+
+#ifndef SCNoFAST64
+#error SCNoFAST64 not defined
+#endif
+
+#ifndef SCNoMAX
+#error SCNoMAX not defined
+#endif
+
+#ifndef SCNoPTR
+#error SCNoPTR not defined
+#endif
+
+#ifndef SCNu8
+#error SCNu8 not defined
+#endif
+
+#ifndef SCNu16
+#error SCNu16 not defined
+#endif
+
+#ifndef SCNu32
+#error SCNu32 not defined
+#endif
+
+#ifndef SCNu64
+#error SCNu64 not defined
+#endif
+
+#ifndef SCNuLEAST8
+#error SCNuLEAST8 not defined
+#endif
+
+#ifndef SCNuLEAST16
+#error SCNuLEAST16 not defined
+#endif
+
+#ifndef SCNuLEAST32
+#error SCNuLEAST32 not defined
+#endif
+
+#ifndef SCNuLEAST64
+#error SCNuLEAST64 not defined
+#endif
+
+#ifndef SCNuFAST8
+#error SCNuFAST8 not defined
+#endif
+
+#ifndef SCNuFAST16
+#error SCNuFAST16 not defined
+#endif
+
+#ifndef SCNuFAST32
+#error SCNuFAST32 not defined
+#endif
+
+#ifndef SCNuFAST64
+#error SCNuFAST64 not defined
+#endif
+
+#ifndef SCNuMAX
+#error SCNuMAX not defined
+#endif
+
+#ifndef SCNuPTR
+#error SCNuPTR not defined
+#endif
+
+#ifndef SCNx8
+#error SCNx8 not defined
+#endif
+
+#ifndef SCNx16
+#error SCNx16 not defined
+#endif
+
+#ifndef SCNx32
+#error SCNx32 not defined
+#endif
+
+#ifndef SCNx64
+#error SCNx64 not defined
+#endif
+
+#ifndef SCNxLEAST8
+#error SCNxLEAST8 not defined
+#endif
+
+#ifndef SCNxLEAST16
+#error SCNxLEAST16 not defined
+#endif
+
+#ifndef SCNxLEAST32
+#error SCNxLEAST32 not defined
+#endif
+
+#ifndef SCNxLEAST64
+#error SCNxLEAST64 not defined
+#endif
+
+#ifndef SCNxFAST8
+#error SCNxFAST8 not defined
+#endif
+
+#ifndef SCNxFAST16
+#error SCNxFAST16 not defined
+#endif
+
+#ifndef SCNxFAST32
+#error SCNxFAST32 not defined
+#endif
+
+#ifndef SCNxFAST64
+#error SCNxFAST64 not defined
+#endif
+
+#ifndef SCNxMAX
+#error SCNxMAX not defined
+#endif
+
+#ifndef SCNxPTR
+#error SCNxPTR not defined
+#endif
+
+int main()
+{
+    {
+    imaxdiv_t  i1 = {0};
+    }
+    intmax_t i = 0;
+    static_assert((std::is_same<decltype(imaxabs(i)), intmax_t>::value), "");
+    static_assert((std::is_same<decltype(imaxdiv(i, i)), imaxdiv_t>::value), "");
+    static_assert((std::is_same<decltype(strtoimax("", (char**)0, 0)), intmax_t>::value), "");
+    static_assert((std::is_same<decltype(strtoumax("", (char**)0, 0)), uintmax_t>::value), "");
+    static_assert((std::is_same<decltype(wcstoimax(L"", (wchar_t**)0, 0)), intmax_t>::value), "");
+    static_assert((std::is_same<decltype(wcstoumax(L"", (wchar_t**)0, 0)), uintmax_t>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/iso646_h.pass.cpp b/final/test/depr/depr.c.headers/iso646_h.pass.cpp
new file mode 100644
index 0000000..b40a4e0
--- /dev/null
+++ b/final/test/depr/depr.c.headers/iso646_h.pass.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iso646.h>
+
+#include <iso646.h>
+
+int main()
+{
+    // Nothing to test
+}
diff --git a/final/test/depr/depr.c.headers/limits_h.pass.cpp b/final/test/depr/depr.c.headers/limits_h.pass.cpp
new file mode 100644
index 0000000..3b78a83
--- /dev/null
+++ b/final/test/depr/depr.c.headers/limits_h.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test limits.h
+
+#include <limits.h>
+
+#ifndef CHAR_BIT
+#error CHAR_BIT not defined
+#endif
+
+#ifndef SCHAR_MIN
+#error SCHAR_MIN not defined
+#endif
+
+#ifndef SCHAR_MAX
+#error SCHAR_MAX not defined
+#endif
+
+#ifndef UCHAR_MAX
+#error UCHAR_MAX not defined
+#endif
+
+#ifndef CHAR_MIN
+#error CHAR_MIN not defined
+#endif
+
+#ifndef CHAR_MAX
+#error CHAR_MAX not defined
+#endif
+
+#ifndef MB_LEN_MAX
+#error MB_LEN_MAX not defined
+#endif
+
+#ifndef SHRT_MIN
+#error SHRT_MIN not defined
+#endif
+
+#ifndef SHRT_MAX
+#error SHRT_MAX not defined
+#endif
+
+#ifndef USHRT_MAX
+#error USHRT_MAX not defined
+#endif
+
+#ifndef INT_MIN
+#error INT_MIN not defined
+#endif
+
+#ifndef INT_MAX
+#error INT_MAX not defined
+#endif
+
+#ifndef UINT_MAX
+#error UINT_MAX not defined
+#endif
+
+#ifndef LONG_MIN
+#error LONG_MIN not defined
+#endif
+
+#ifndef LONG_MAX
+#error LONG_MAX not defined
+#endif
+
+#ifndef ULONG_MAX
+#error ULONG_MAX not defined
+#endif
+
+#ifndef LLONG_MIN
+#error LLONG_MIN not defined
+#endif
+
+#ifndef LLONG_MAX
+#error LLONG_MAX not defined
+#endif
+
+#ifndef ULLONG_MAX
+#error ULLONG_MAX not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/locale_h.pass.cpp b/final/test/depr/depr.c.headers/locale_h.pass.cpp
new file mode 100644
index 0000000..eff9b2b
--- /dev/null
+++ b/final/test/depr/depr.c.headers/locale_h.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale.h>
+
+#include <locale.h>
+#include <type_traits>
+
+#ifndef LC_ALL
+#error LC_ALL not defined
+#endif
+
+#ifndef LC_COLLATE
+#error LC_COLLATE not defined
+#endif
+
+#ifndef LC_CTYPE
+#error LC_CTYPE not defined
+#endif
+
+#ifndef LC_MONETARY
+#error LC_MONETARY not defined
+#endif
+
+#ifndef LC_NUMERIC
+#error LC_NUMERIC not defined
+#endif
+
+#ifndef LC_TIME
+#error LC_TIME not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    lconv lc;
+    static_assert((std::is_same<__typeof__(setlocale(0, "")), char*>::value), "");
+    static_assert((std::is_same<__typeof__(localeconv()), lconv*>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/math_h.pass.cpp b/final/test/depr/depr.c.headers/math_h.pass.cpp
new file mode 100644
index 0000000..858e190
--- /dev/null
+++ b/final/test/depr/depr.c.headers/math_h.pass.cpp
@@ -0,0 +1,681 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <math.h>
+
+#include <math.h>
+#include <type_traits>
+#include <cassert>
+
+#include "hexfloat.h"
+
+void test_acos()
+{
+    static_assert((std::is_same<decltype(acos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(acosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(acosl(0)), long double>::value), "");
+    assert(acos(1) == 0);
+}
+
+void test_asin()
+{
+    static_assert((std::is_same<decltype(asin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(asinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(asinl(0)), long double>::value), "");
+    assert(asin(0) == 0);
+}
+
+void test_atan()
+{
+    static_assert((std::is_same<decltype(atan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(atanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(atanl(0)), long double>::value), "");
+    assert(atan(0) == 0);
+}
+
+void test_atan2()
+{
+    static_assert((std::is_same<decltype(atan2((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(atan2f(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(atan2l(0,0)), long double>::value), "");
+    assert(atan2(0,1) == 0);
+}
+
+void test_ceil()
+{
+    static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
+    assert(ceil(0) == 0);
+}
+
+void test_cos()
+{
+    static_assert((std::is_same<decltype(cos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(cosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(cosl(0)), long double>::value), "");
+    assert(cos(0) == 1);
+}
+
+void test_cosh()
+{
+    static_assert((std::is_same<decltype(cosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(coshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(coshl(0)), long double>::value), "");
+    assert(cosh(0) == 1);
+}
+
+void test_exp()
+{
+    static_assert((std::is_same<decltype(exp((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(expf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(expl(0)), long double>::value), "");
+    assert(exp(0) == 1);
+}
+
+void test_fabs()
+{
+    static_assert((std::is_same<decltype(fabs((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fabsf(0.f)), float>::value), "");
+    static_assert((std::is_same<decltype(fabsl(0.L)), long double>::value), "");
+    assert(fabs(-1.f) == 1);
+}
+
+void test_floor()
+{
+    static_assert((std::is_same<decltype(floor((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(floorf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(floorl(0)), long double>::value), "");
+    assert(floor(1) == 1);
+}
+
+void test_fmod()
+{
+    static_assert((std::is_same<decltype(fmod((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fmodf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fmodl(0,0)), long double>::value), "");
+    assert(fmod(1.5,1) == .5);
+}
+
+void test_frexp()
+{
+    int ip;
+    static_assert((std::is_same<decltype(frexp((double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(frexpf(0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(frexpl(0, &ip)), long double>::value), "");
+    assert(frexp(0, &ip) == 0);
+}
+
+void test_ldexp()
+{
+    int ip = 1;
+    static_assert((std::is_same<decltype(ldexp((double)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(ldexpf(0, ip)), float>::value), "");
+    static_assert((std::is_same<decltype(ldexpl(0, ip)), long double>::value), "");
+    assert(ldexp(1, ip) == 2);
+}
+
+void test_log()
+{
+    static_assert((std::is_same<decltype(log((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(logf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(logl(0)), long double>::value), "");
+    assert(log(1) == 0);
+}
+
+void test_log10()
+{
+    static_assert((std::is_same<decltype(log10((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(log10f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(log10l(0)), long double>::value), "");
+    assert(log10(1) == 0);
+}
+
+void test_modf()
+{
+    static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), "");
+    static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), "");
+    static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), "");
+    double i;
+    assert(modf(1., &i) == 0);
+}
+
+void test_pow()
+{
+    static_assert((std::is_same<decltype(pow((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(powf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(powl(0,0)), long double>::value), "");
+    assert(pow(1,1) == 1);
+}
+
+void test_sin()
+{
+    static_assert((std::is_same<decltype(sin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(sinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(sinl(0)), long double>::value), "");
+    assert(sin(0) == 0);
+}
+
+void test_sinh()
+{
+    static_assert((std::is_same<decltype(sinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(sinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(sinhl(0)), long double>::value), "");
+    assert(sinh(0) == 0);
+}
+
+void test_sqrt()
+{
+    static_assert((std::is_same<decltype(sqrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(sqrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(sqrtl(0)), long double>::value), "");
+    assert(sqrt(4) == 2);
+}
+
+void test_tan()
+{
+    static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
+    assert(tan(0) == 0);
+}
+
+void test_tanh()
+{
+    static_assert((std::is_same<decltype(tanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(tanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(tanhl(0)), long double>::value), "");
+    assert(tanh(0) == 0);
+}
+
+void test_signbit()
+{
+    static_assert((std::is_same<decltype(signbit((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(signbit((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(signbit((long double)0)), bool>::value), "");
+    assert(signbit(-1.0) == true);
+}
+
+void test_fpclassify()
+{
+    static_assert((std::is_same<decltype(fpclassify((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(fpclassify((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(fpclassify((long double)0)), int>::value), "");
+    assert(fpclassify(-1.0) == FP_NORMAL);
+}
+
+void test_isfinite()
+{
+    static_assert((std::is_same<decltype(isfinite((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isfinite((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isfinite((long double)0)), bool>::value), "");
+    assert(isfinite(-1.0) == true);
+}
+
+void test_isinf()
+{
+    static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isinf((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), "");
+    assert(isinf(-1.0) == false);
+}
+
+void test_isnan()
+{
+    static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isnan((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), "");
+    assert(isnan(-1.0) == false);
+}
+
+void test_isnormal()
+{
+    static_assert((std::is_same<decltype(isnormal((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isnormal((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isnormal((long double)0)), bool>::value), "");
+    assert(isnormal(-1.0) == true);
+}
+
+void test_isgreater()
+{
+    static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), bool>::value), "");
+    assert(isgreater(-1.0, 0.F) == false);
+}
+
+void test_isgreaterequal()
+{
+    static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), bool>::value), "");
+    assert(isgreaterequal(-1.0, 0.F) == false);
+}
+
+void test_isless()
+{
+    static_assert((std::is_same<decltype(isless((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isless((long double)0, (long double)0)), bool>::value), "");
+    assert(isless(-1.0, 0.F) == true);
+}
+
+void test_islessequal()
+{
+    static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), bool>::value), "");
+    assert(islessequal(-1.0, 0.F) == true);
+}
+
+void test_islessgreater()
+{
+    static_assert((std::is_same<decltype(islessgreater((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(islessgreater((long double)0, (long double)0)), bool>::value), "");
+    assert(islessgreater(-1.0, 0.F) == true);
+}
+
+void test_isunordered()
+{
+    static_assert((std::is_same<decltype(isunordered((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(isunordered((long double)0, (long double)0)), bool>::value), "");
+    assert(isunordered(-1.0, 0.F) == false);
+}
+
+void test_acosh()
+{
+    static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
+    assert(acosh(1) == 0);
+}
+
+void test_asinh()
+{
+    static_assert((std::is_same<decltype(asinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(asinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(asinhl(0)), long double>::value), "");
+    assert(asinh(0) == 0);
+}
+
+void test_atanh()
+{
+    static_assert((std::is_same<decltype(atanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(atanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(atanhl(0)), long double>::value), "");
+    assert(atanh(0) == 0);
+}
+
+void test_cbrt()
+{
+    static_assert((std::is_same<decltype(cbrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
+    assert(cbrt(1) == 1);
+}
+
+void test_copysign()
+{
+    static_assert((std::is_same<decltype(copysign((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(copysignf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(copysignl(0,0)), long double>::value), "");
+    assert(copysign(1,1) == 1);
+}
+
+void test_erf()
+{
+    static_assert((std::is_same<decltype(erf((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(erff(0)), float>::value), "");
+    static_assert((std::is_same<decltype(erfl(0)), long double>::value), "");
+    assert(erf(0) == 0);
+}
+
+void test_erfc()
+{
+    static_assert((std::is_same<decltype(erfc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(erfcf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(erfcl(0)), long double>::value), "");
+    assert(erfc(0) == 1);
+}
+
+void test_exp2()
+{
+    static_assert((std::is_same<decltype(exp2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(exp2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(exp2l(0)), long double>::value), "");
+    assert(exp2(1) == 2);
+}
+
+void test_expm1()
+{
+    static_assert((std::is_same<decltype(expm1((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(expm1f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(expm1l(0)), long double>::value), "");
+    assert(expm1(0) == 0);
+}
+
+void test_fdim()
+{
+    static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
+    assert(fdim(1,0) == 1);
+}
+
+void test_fma()
+{
+    static_assert((std::is_same<decltype(fma((double)0, (double)0,  (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fmaf(0,0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fmal(0,0,0)), long double>::value), "");
+    assert(fma(1,1,1) == 2);
+}
+
+void test_fmax()
+{
+    static_assert((std::is_same<decltype(fmax((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fmaxf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fmaxl(0,0)), long double>::value), "");
+    assert(fmax(1,0) == 1);
+}
+
+void test_fmin()
+{
+    static_assert((std::is_same<decltype(fmin((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(fminf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(fminl(0,0)), long double>::value), "");
+    assert(fmin(1,0) == 0);
+}
+
+void test_hypot()
+{
+    static_assert((std::is_same<decltype(hypot((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(hypotf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(hypotl(0,0)), long double>::value), "");
+    assert(hypot(3,4) == 5);
+}
+
+void test_ilogb()
+{
+    static_assert((std::is_same<decltype(ilogb((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(ilogbf(0)), int>::value), "");
+    static_assert((std::is_same<decltype(ilogbl(0)), int>::value), "");
+    assert(ilogb(1) == 0);
+}
+
+void test_lgamma()
+{
+    static_assert((std::is_same<decltype(lgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(lgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(lgammal(0)), long double>::value), "");
+    assert(lgamma(1) == 0);
+}
+
+void test_llrint()
+{
+    static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llrintf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llrintl(0)), long long>::value), "");
+    assert(llrint(1) == 1LL);
+}
+
+void test_llround()
+{
+    static_assert((std::is_same<decltype(llround((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llroundf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(llroundl(0)), long long>::value), "");
+    assert(llround(1) == 1LL);
+}
+
+void test_log1p()
+{
+    static_assert((std::is_same<decltype(log1p((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(log1pf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(log1pl(0)), long double>::value), "");
+    assert(log1p(0) == 0);
+}
+
+void test_log2()
+{
+    static_assert((std::is_same<decltype(log2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(log2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(log2l(0)), long double>::value), "");
+    assert(log2(1) == 0);
+}
+
+void test_logb()
+{
+    static_assert((std::is_same<decltype(logb((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(logbf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(logbl(0)), long double>::value), "");
+    assert(logb(1) == 0);
+}
+
+void test_lrint()
+{
+    static_assert((std::is_same<decltype(lrint((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(lrintf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(lrintl(0)), long>::value), "");
+    assert(lrint(1) == 1L);
+}
+
+void test_lround()
+{
+    static_assert((std::is_same<decltype(lround((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(lroundf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(lroundl(0)), long>::value), "");
+    assert(lround(1) == 1L);
+}
+
+void test_nan()
+{
+    static_assert((std::is_same<decltype(nan("")), double>::value), "");
+    static_assert((std::is_same<decltype(nanf("")), float>::value), "");
+    static_assert((std::is_same<decltype(nanl("")), long double>::value), "");
+}
+
+void test_nearbyint()
+{
+    static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
+    assert(nearbyint(1) == 1);
+}
+
+void test_nextafter()
+{
+    static_assert((std::is_same<decltype(nextafter((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(nextafterf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(nextafterl(0,0)), long double>::value), "");
+    assert(nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_nexttoward()
+{
+    static_assert((std::is_same<decltype(nexttoward((double)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(nexttowardf(0, (long double)0)), float>::value), "");
+    static_assert((std::is_same<decltype(nexttowardl(0, (long double)0)), long double>::value), "");
+    assert(nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_remainder()
+{
+    static_assert((std::is_same<decltype(remainder((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(remainderf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(remainderl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(remainder((int)0, (int)0)), double>::value), "");
+    assert(remainder(0.5,1) == 0.5);
+}
+
+void test_remquo()
+{
+    int ip;
+    static_assert((std::is_same<decltype(remquo((double)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(remquof(0,0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(remquol(0,0, &ip)), long double>::value), "");
+    assert(remquo(0.5,1, &ip) == 0.5);
+}
+
+void test_rint()
+{
+    static_assert((std::is_same<decltype(rint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(rintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(rintl(0)), long double>::value), "");
+    assert(rint(1) == 1);
+}
+
+void test_round()
+{
+    static_assert((std::is_same<decltype(round((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(roundf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(roundl(0)), long double>::value), "");
+    assert(round(1) == 1);
+}
+
+void test_scalbln()
+{
+    static_assert((std::is_same<decltype(scalbln((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(scalblnf(0, (long)0)), float>::value), "");
+    static_assert((std::is_same<decltype(scalblnl(0, (long)0)), long double>::value), "");
+    assert(scalbln(1, 1) == 2);
+}
+
+void test_scalbn()
+{
+    static_assert((std::is_same<decltype(scalbn((double)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(scalbnf(0, (int)0)), float>::value), "");
+    static_assert((std::is_same<decltype(scalbnl(0, (int)0)), long double>::value), "");
+    assert(scalbn(1, 1) == 2);
+}
+
+void test_tgamma()
+{
+    static_assert((std::is_same<decltype(tgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(tgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(tgammal(0)), long double>::value), "");
+    assert(tgamma(1) == 1);
+}
+
+void test_trunc()
+{
+    static_assert((std::is_same<decltype(trunc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(truncf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(truncl(0)), long double>::value), "");
+    assert(trunc(1) == 1);
+}
+
+int main()
+{
+    test_acos();
+    test_asin();
+    test_atan();
+    test_atan2();
+    test_ceil();
+    test_cos();
+    test_cosh();
+    test_exp();
+    test_fabs();
+    test_floor();
+    test_fmod();
+    test_frexp();
+    test_ldexp();
+    test_log();
+    test_log10();
+    test_modf();
+    test_pow();
+    test_sin();
+    test_sinh();
+    test_sqrt();
+    test_tan();
+    test_tanh();
+    test_signbit();
+    test_fpclassify();
+    test_isfinite();
+    test_isinf();
+    test_isnan();
+    test_isnormal();
+    test_isgreater();
+    test_isgreaterequal();
+    test_isless();
+    test_islessequal();
+    test_islessgreater();
+    test_isunordered();
+    test_acosh();
+    test_asinh();
+    test_atanh();
+    test_cbrt();
+    test_copysign();
+    test_erf();
+    test_erfc();
+    test_exp2();
+    test_expm1();
+    test_fdim();
+    test_fma();
+    test_fmax();
+    test_fmin();
+    test_hypot();
+    test_ilogb();
+    test_lgamma();
+    test_llrint();
+    test_llround();
+    test_log1p();
+    test_log2();
+    test_logb();
+    test_lrint();
+    test_lround();
+    test_nan();
+    test_nearbyint();
+    test_nextafter();
+    test_nexttoward();
+    test_remainder();
+    test_remquo();
+    test_rint();
+    test_round();
+    test_scalbln();
+    test_scalbn();
+    test_tgamma();
+    test_trunc();
+}
diff --git a/final/test/depr/depr.c.headers/setjmp_h.pass.cpp b/final/test/depr/depr.c.headers/setjmp_h.pass.cpp
new file mode 100644
index 0000000..2a8abe3
--- /dev/null
+++ b/final/test/depr/depr.c.headers/setjmp_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <setjmp.h>
+
+#include <setjmp.h>
+#include <type_traits>
+
+int main()
+{
+    jmp_buf jb;
+    static_assert((std::is_same<__typeof__(longjmp(jb, 0)), void>::value),
+                  "std::is_same<__typeof__(longjmp(jb, 0)), void>::value");
+}
diff --git a/final/test/depr/depr.c.headers/signal_h.pass.cpp b/final/test/depr/depr.c.headers/signal_h.pass.cpp
new file mode 100644
index 0000000..a8ef5f9
--- /dev/null
+++ b/final/test/depr/depr.c.headers/signal_h.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <signal.h>
+
+#include <signal.h>
+#include <type_traits>
+
+#ifndef SIG_DFL
+#error SIG_DFL not defined
+#endif
+
+#ifndef SIG_ERR
+#error SIG_ERR not defined
+#endif
+
+#ifndef SIG_IGN
+#error SIG_IGN not defined
+#endif
+
+#ifndef SIGABRT
+#error SIGABRT not defined
+#endif
+
+#ifndef SIGFPE
+#error SIGFPE not defined
+#endif
+
+#ifndef SIGILL
+#error SIGILL not defined
+#endif
+
+#ifndef SIGINT
+#error SIGINT not defined
+#endif
+
+#ifndef SIGSEGV
+#error SIGSEGV not defined
+#endif
+
+#ifndef SIGTERM
+#error SIGTERM not defined
+#endif
+
+int main()
+{
+    sig_atomic_t sig;
+    typedef void (*func)(int);
+    static_assert((std::is_same<decltype(signal(0, (func)0)), func>::value), "");
+    static_assert((std::is_same<decltype(raise(0)), int>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/stdarg_h.pass.cpp b/final/test/depr/depr.c.headers/stdarg_h.pass.cpp
new file mode 100644
index 0000000..2c18c5d
--- /dev/null
+++ b/final/test/depr/depr.c.headers/stdarg_h.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdarg.h>
+
+#include <stdarg.h>
+
+#ifndef va_arg
+#error va_arg not defined
+#endif
+
+#ifndef va_copy
+#error va_copy not defined
+#endif
+
+#ifndef va_end
+#error va_end not defined
+#endif
+
+#ifndef va_start
+#error va_start not defined
+#endif
+
+int main()
+{
+    va_list va;
+}
diff --git a/final/test/depr/depr.c.headers/stdbool_h.pass.cpp b/final/test/depr/depr.c.headers/stdbool_h.pass.cpp
new file mode 100644
index 0000000..cd4d4c4
--- /dev/null
+++ b/final/test/depr/depr.c.headers/stdbool_h.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdbool.h>
+
+#include <stdbool.h>
+
+#ifndef __bool_true_false_are_defined
+#error __bool_true_false_are_defined not defined
+#endif
+
+#ifdef bool
+#error bool should not be defined
+#endif
+
+#ifdef true
+#error true should not be defined
+#endif
+
+#ifdef false
+#error false should not be defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/stddef_h.pass.cpp b/final/test/depr/depr.c.headers/stddef_h.pass.cpp
new file mode 100644
index 0000000..140c91b
--- /dev/null
+++ b/final/test/depr/depr.c.headers/stddef_h.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stddef.h>
+
+#include <stddef.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef offsetof
+#error offsetof not defined
+#endif
+
+int main()
+{
+    static_assert(sizeof(size_t) == sizeof(void*),
+                  "sizeof(size_t) == sizeof(void*)");
+    static_assert(std::is_unsigned<size_t>::value,
+                  "std::is_unsigned<size_t>::value");
+    static_assert(std::is_integral<size_t>::value,
+                  "std::is_integral<size_t>::value");
+    static_assert(sizeof(ptrdiff_t) == sizeof(void*),
+                  "sizeof(ptrdiff_t) == sizeof(void*)");
+    static_assert(std::is_signed<ptrdiff_t>::value,
+                  "std::is_signed<ptrdiff_t>::value");
+    static_assert(std::is_integral<ptrdiff_t>::value,
+                  "std::is_integral<ptrdiff_t>::value");
+}
diff --git a/final/test/depr/depr.c.headers/stdint_h.pass.cpp b/final/test/depr/depr.c.headers/stdint_h.pass.cpp
new file mode 100644
index 0000000..9e3c329
--- /dev/null
+++ b/final/test/depr/depr.c.headers/stdint_h.pass.cpp
@@ -0,0 +1,290 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdint.h>
+
+#include <stdint.h>
+#include <csignal>
+#include <cwctype>
+#include <climits>
+#include <type_traits>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    // typedef int8_t
+    static_assert(sizeof(int8_t)*CHAR_BIT == 8,
+                 "sizeof(int8_t)*CHAR_BIT == 8");
+    static_assert(std::is_signed<int8_t>::value,
+                 "std::is_signed<int8_t>::value");
+    // typedef int16_t
+    static_assert(sizeof(int16_t)*CHAR_BIT == 16,
+                 "sizeof(int16_t)*CHAR_BIT == 16");
+    static_assert(std::is_signed<int16_t>::value,
+                 "std::is_signed<int16_t>::value");
+    // typedef int32_t
+    static_assert(sizeof(int32_t)*CHAR_BIT == 32,
+                 "sizeof(int32_t)*CHAR_BIT == 32");
+    static_assert(std::is_signed<int32_t>::value,
+                 "std::is_signed<int32_t>::value");
+    // typedef int64_t
+    static_assert(sizeof(int64_t)*CHAR_BIT == 64,
+                 "sizeof(int64_t)*CHAR_BIT == 64");
+    static_assert(std::is_signed<int64_t>::value,
+                 "std::is_signed<int64_t>::value");
+
+    // typedef uint8_t
+    static_assert(sizeof(uint8_t)*CHAR_BIT == 8,
+                 "sizeof(uint8_t)*CHAR_BIT == 8");
+    static_assert(std::is_unsigned<uint8_t>::value,
+                 "std::is_unsigned<uint8_t>::value");
+    // typedef uint16_t
+    static_assert(sizeof(uint16_t)*CHAR_BIT == 16,
+                 "sizeof(uint16_t)*CHAR_BIT == 16");
+    static_assert(std::is_unsigned<uint16_t>::value,
+                 "std::is_unsigned<uint16_t>::value");
+    // typedef uint32_t
+    static_assert(sizeof(uint32_t)*CHAR_BIT == 32,
+                 "sizeof(uint32_t)*CHAR_BIT == 32");
+    static_assert(std::is_unsigned<uint32_t>::value,
+                 "std::is_unsigned<uint32_t>::value");
+    // typedef uint64_t
+    static_assert(sizeof(uint64_t)*CHAR_BIT == 64,
+                 "sizeof(uint64_t)*CHAR_BIT == 64");
+    static_assert(std::is_unsigned<uint64_t>::value,
+                 "std::is_unsigned<uint64_t>::value");
+
+    // typedef int_least8_t
+    static_assert(sizeof(int_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(int_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<int_least8_t>::value,
+                 "std::is_signed<int_least8_t>::value");
+    // typedef int_least16_t
+    static_assert(sizeof(int_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(int_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<int_least16_t>::value,
+                 "std::is_signed<int_least16_t>::value");
+    // typedef int_least32_t
+    static_assert(sizeof(int_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(int_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<int_least32_t>::value,
+                 "std::is_signed<int_least32_t>::value");
+    // typedef int_least64_t
+    static_assert(sizeof(int_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(int_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<int_least64_t>::value,
+                 "std::is_signed<int_least64_t>::value");
+
+    // typedef uint_least8_t
+    static_assert(sizeof(uint_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(uint_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<uint_least8_t>::value,
+                 "std::is_unsigned<uint_least8_t>::value");
+    // typedef uint_least16_t
+    static_assert(sizeof(uint_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(uint_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<uint_least16_t>::value,
+                 "std::is_unsigned<uint_least16_t>::value");
+    // typedef uint_least32_t
+    static_assert(sizeof(uint_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(uint_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<uint_least32_t>::value,
+                 "std::is_unsigned<uint_least32_t>::value");
+    // typedef uint_least64_t
+    static_assert(sizeof(uint_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(uint_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<uint_least64_t>::value,
+                 "std::is_unsigned<uint_least64_t>::value");
+
+    // typedef int_fast8_t
+    static_assert(sizeof(int_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(int_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<int_fast8_t>::value,
+                 "std::is_signed<int_fast8_t>::value");
+    // typedef int_fast16_t
+    static_assert(sizeof(int_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(int_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<int_fast16_t>::value,
+                 "std::is_signed<int_fast16_t>::value");
+    // typedef int_fast32_t
+    static_assert(sizeof(int_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(int_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<int_fast32_t>::value,
+                 "std::is_signed<int_fast32_t>::value");
+    // typedef int_fast64_t
+    static_assert(sizeof(int_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(int_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<int_fast64_t>::value,
+                 "std::is_signed<int_fast64_t>::value");
+
+    // typedef uint_fast8_t
+    static_assert(sizeof(uint_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(uint_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<uint_fast8_t>::value,
+                 "std::is_unsigned<uint_fast8_t>::value");
+    // typedef uint_fast16_t
+    static_assert(sizeof(uint_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(uint_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<uint_fast16_t>::value,
+                 "std::is_unsigned<uint_fast16_t>::value");
+    // typedef uint_fast32_t
+    static_assert(sizeof(uint_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(uint_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<uint_fast32_t>::value,
+                 "std::is_unsigned<uint_fast32_t>::value");
+    // typedef uint_fast64_t
+    static_assert(sizeof(uint_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(uint_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<uint_fast64_t>::value,
+                 "std::is_unsigned<uint_fast64_t>::value");
+
+    // typedef intptr_t
+    static_assert(sizeof(intptr_t) >= sizeof(void*),
+                 "sizeof(intptr_t) >= sizeof(void*)");
+    static_assert(std::is_signed<intptr_t>::value,
+                 "std::is_signed<intptr_t>::value");
+    // typedef uintptr_t
+    static_assert(sizeof(uintptr_t) >= sizeof(void*),
+                 "sizeof(uintptr_t) >= sizeof(void*)");
+    static_assert(std::is_unsigned<uintptr_t>::value,
+                 "std::is_unsigned<uintptr_t>::value");
+
+    // typedef intmax_t
+    static_assert(sizeof(intmax_t) >= sizeof(long long),
+                 "sizeof(intmax_t) >= sizeof(long long)");
+    static_assert(std::is_signed<intmax_t>::value,
+                 "std::is_signed<intmax_t>::value");
+    // typedef uintmax_t
+    static_assert(sizeof(uintmax_t) >= sizeof(unsigned long long),
+                 "sizeof(uintmax_t) >= sizeof(unsigned long long)");
+    static_assert(std::is_unsigned<uintmax_t>::value,
+                 "std::is_unsigned<uintmax_t>::value");
+
+    // INTN_MIN
+    static_assert(INT8_MIN == -128, "INT8_MIN == -128");
+    static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
+    static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
+    static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
+
+    // INTN_MAX
+    static_assert(INT8_MAX == 127, "INT8_MAX == 127");
+    static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
+    static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
+    static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
+
+    // UINTN_MAX
+    static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
+    static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
+    static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
+    static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
+
+    // INT_FASTN_MIN
+    static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
+    static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
+    static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
+    static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
+
+    // INT_FASTN_MAX
+    static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
+    static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
+    static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
+    static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
+
+    // UINT_FASTN_MAX
+    static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
+    static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
+    static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
+    static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
+
+    // INTPTR_MIN
+    assert(INTPTR_MIN == std::numeric_limits<intptr_t>::min());
+
+    // INTPTR_MAX
+    assert(INTPTR_MAX == std::numeric_limits<intptr_t>::max());
+
+    // UINTPTR_MAX
+    assert(UINTPTR_MAX == std::numeric_limits<uintptr_t>::max());
+
+    // INTMAX_MIN
+    assert(INTMAX_MIN == std::numeric_limits<intmax_t>::min());
+
+    // INTMAX_MAX
+    assert(INTMAX_MAX == std::numeric_limits<intmax_t>::max());
+
+    // UINTMAX_MAX
+    assert(UINTMAX_MAX == std::numeric_limits<uintmax_t>::max());
+
+    // PTRDIFF_MIN
+    assert(PTRDIFF_MIN == std::numeric_limits<ptrdiff_t>::min());
+
+    // PTRDIFF_MAX
+    assert(PTRDIFF_MAX == std::numeric_limits<ptrdiff_t>::max());
+
+    // SIG_ATOMIC_MIN
+    assert(SIG_ATOMIC_MIN == std::numeric_limits<sig_atomic_t>::min());
+
+    // SIG_ATOMIC_MAX
+    assert(SIG_ATOMIC_MAX == std::numeric_limits<sig_atomic_t>::max());
+
+    // SIZE_MAX
+    assert(SIZE_MAX == std::numeric_limits<size_t>::max());
+
+    // WCHAR_MIN
+    assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
+
+    // WCHAR_MAX
+    assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
+
+    // WINT_MIN
+    assert(WINT_MIN == std::numeric_limits<wint_t>::min());
+
+    // WINT_MAX
+    assert(WINT_MAX == std::numeric_limits<wint_t>::max());
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+}
diff --git a/final/test/depr/depr.c.headers/stdio_h.pass.cpp b/final/test/depr/depr.c.headers/stdio_h.pass.cpp
new file mode 100644
index 0000000..8e236e3
--- /dev/null
+++ b/final/test/depr/depr.c.headers/stdio_h.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdio.h>
+
+#include <stdio.h>
+#include <type_traits>
+
+#ifndef BUFSIZ
+#error BUFSIZ not defined
+#endif
+
+#ifndef EOF
+#error EOF not defined
+#endif
+
+#ifndef FILENAME_MAX
+#error FILENAME_MAX not defined
+#endif
+
+#ifndef FOPEN_MAX
+#error FOPEN_MAX not defined
+#endif
+
+#ifndef L_tmpnam
+#error L_tmpnam not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef SEEK_CUR
+#error SEEK_CUR not defined
+#endif
+
+#ifndef SEEK_END
+#error SEEK_END not defined
+#endif
+
+#ifndef SEEK_SET
+#error SEEK_SET not defined
+#endif
+
+#ifndef TMP_MAX
+#error TMP_MAX not defined
+#endif
+
+#ifndef _IOFBF
+#error _IOFBF not defined
+#endif
+
+#ifndef _IOLBF
+#error _IOLBF not defined
+#endif
+
+#ifndef _IONBF
+#error _IONBF not defined
+#endif
+
+#ifndef stderr
+#error stderr not defined
+#endif
+
+#ifndef stdin
+#error stdin not defined
+#endif
+
+#ifndef stdout
+#error stdout not defined
+#endif
+
+#include <cstdarg>
+
+#pragma clang diagnostic ignored "-Wformat-zero-length"
+
+int main()
+{
+    FILE* fp = 0;
+    fpos_t fpos = {0};
+    size_t s = 0;
+    char* cp = 0;
+    va_list va;
+    static_assert((std::is_same<decltype(remove("")), int>::value), "");
+    static_assert((std::is_same<decltype(rename("","")), int>::value), "");
+    static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), "");
+    static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
+    static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
+    static_assert((std::is_same<decltype(freopen("", "", fp)), FILE*>::value), "");
+    static_assert((std::is_same<decltype(setbuf(fp,cp)), void>::value), "");
+    static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(fprintf(fp," ")), int>::value), "");
+    static_assert((std::is_same<decltype(fscanf(fp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(printf("\n")), int>::value), "");
+    static_assert((std::is_same<decltype(scanf("\n")), int>::value), "");
+    static_assert((std::is_same<decltype(snprintf(cp,0,"p")), int>::value), "");
+    static_assert((std::is_same<decltype(sprintf(cp," ")), int>::value), "");
+    static_assert((std::is_same<decltype(sscanf("","")), int>::value), "");
+    static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vfscanf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vprintf(" ",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vscanf("",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vsnprintf(cp,0," ",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vsprintf(cp," ",va)), int>::value), "");
+    static_assert((std::is_same<decltype(vsscanf("","",va)), int>::value), "");
+    static_assert((std::is_same<decltype(fgetc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fgets(cp,0,fp)), char*>::value), "");
+    static_assert((std::is_same<decltype(fputc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fputs("",fp)), int>::value), "");
+    static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(getchar()), int>::value), "");
+    static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
+    static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(putchar(0)), int>::value), "");
+    static_assert((std::is_same<decltype(puts("")), int>::value), "");
+    static_assert((std::is_same<decltype(ungetc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fread((void*)0,0,0,fp)), size_t>::value), "");
+    static_assert((std::is_same<decltype(fwrite((const void*)0,0,0,fp)), size_t>::value), "");
+    static_assert((std::is_same<decltype(fgetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(fseek(fp, 0,0)), int>::value), "");
+    static_assert((std::is_same<decltype(fsetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(ftell(fp)), long>::value), "");
+    static_assert((std::is_same<decltype(rewind(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(clearerr(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(feof(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(ferror(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(perror("")), void>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/stdlib_h.pass.cpp b/final/test/depr/depr.c.headers/stdlib_h.pass.cpp
new file mode 100644
index 0000000..98b19c6
--- /dev/null
+++ b/final/test/depr/depr.c.headers/stdlib_h.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdlib.h>
+
+#include <stdlib.h>
+#include <type_traits>
+
+#ifndef EXIT_FAILURE
+#error EXIT_FAILURE not defined
+#endif
+
+#ifndef EXIT_SUCCESS
+#error EXIT_SUCCESS not defined
+#endif
+
+#ifndef MB_CUR_MAX
+#error MB_CUR_MAX not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef RAND_MAX
+#error RAND_MAX not defined
+#endif
+
+int main()
+{
+    size_t s = 0;
+    div_t d;
+    ldiv_t ld;
+    lldiv_t lld;
+    char** endptr = 0;
+    static_assert((std::is_same<decltype(atof("")), double>::value), "");
+    static_assert((std::is_same<decltype(atoi("")), int>::value), "");
+    static_assert((std::is_same<decltype(atol("")), long>::value), "");
+    static_assert((std::is_same<decltype(atoll("")), long long>::value), "");
+    static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(strtod("", endptr)), double>::value), "");
+    static_assert((std::is_same<decltype(strtof("", endptr)), float>::value), "");
+    static_assert((std::is_same<decltype(strtold("", endptr)), long double>::value), "");
+    static_assert((std::is_same<decltype(strtol("", endptr,0)), long>::value), "");
+    static_assert((std::is_same<decltype(strtoll("", endptr,0)), long long>::value), "");
+    static_assert((std::is_same<decltype(strtoul("", endptr,0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(strtoull("", endptr,0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(rand()), int>::value), "");
+    static_assert((std::is_same<decltype(srand(0)), void>::value), "");
+    static_assert((std::is_same<decltype(calloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(free(0)), void>::value), "");
+    static_assert((std::is_same<decltype(malloc(0)), void*>::value), "");
+    static_assert((std::is_same<decltype(realloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(abort()), void>::value), "");
+    static_assert((std::is_same<decltype(atexit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(_Exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(system("")), int>::value), "");
+    static_assert((std::is_same<decltype(bsearch(0,0,0,0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(qsort(0,0,0,0)), void>::value), "");
+    static_assert((std::is_same<decltype(abs(0)), int>::value), "");
+    static_assert((std::is_same<decltype(labs((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(llabs((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(div(0,0)), div_t>::value), "");
+    static_assert((std::is_same<decltype(ldiv(0L,0L)), ldiv_t>::value), "");
+    static_assert((std::is_same<decltype(lldiv(0LL,0LL)), lldiv_t>::value), "");
+    static_assert((std::is_same<decltype(mblen("",0)), int>::value), "");
+    wchar_t* pw = 0;
+    const wchar_t* pwc = 0;
+    char* pc = 0;
+    static_assert((std::is_same<decltype(mbtowc(pw,"",0)), int>::value), "");
+    static_assert((std::is_same<decltype(wctomb(pc,L' ')), int>::value), "");
+    static_assert((std::is_same<decltype(mbstowcs(pw,"",0)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcstombs(pc,pwc,0)), size_t>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/string_h.pass.cpp b/final/test/depr/depr.c.headers/string_h.pass.cpp
new file mode 100644
index 0000000..fc7f65d
--- /dev/null
+++ b/final/test/depr/depr.c.headers/string_h.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string.h>
+
+#include <string.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    size_t s = 0;
+    void* vp = 0;
+    const void* vpc = 0;
+    char* cp = 0;
+    const char* cpc = 0;
+    static_assert((std::is_same<decltype(memcpy(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(memmove(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(strcpy(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strncpy(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(strcat(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strncat(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(memcmp(vpc, vpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(strcmp(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(strncmp(cpc, cpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(strcoll(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(strxfrm(cp, cpc, s)), size_t>::value), "");
+    static_assert((std::is_same<decltype(memchr(vp, 0, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(strchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(strcspn(cpc, cpc)), size_t>::value), "");
+    static_assert((std::is_same<decltype(strpbrk(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strrchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(strspn(cpc, cpc)), size_t>::value), "");
+    static_assert((std::is_same<decltype(strstr(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(strtok(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(memset(vp, 0, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(strerror(0)), char*>::value), "");
+    static_assert((std::is_same<decltype(strlen(cpc)), size_t>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/tgmath_h.pass.cpp b/final/test/depr/depr.c.headers/tgmath_h.pass.cpp
new file mode 100644
index 0000000..c4c9e85
--- /dev/null
+++ b/final/test/depr/depr.c.headers/tgmath_h.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tgmath.h>
+
+#include <tgmath.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> cd;
+    double x = sin(1.0);
+}
diff --git a/final/test/depr/depr.c.headers/time_h.pass.cpp b/final/test/depr/depr.c.headers/time_h.pass.cpp
new file mode 100644
index 0000000..c468693
--- /dev/null
+++ b/final/test/depr/depr.c.headers/time_h.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <time.h>
+
+#include <time.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+    clock_t c = 0;
+    size_t s = 0;
+    time_t t = 0;
+    tm tmv = {0};
+    static_assert((std::is_same<decltype(clock()), clock_t>::value), "");
+    static_assert((std::is_same<decltype(difftime(t,t)), double>::value), "");
+    static_assert((std::is_same<decltype(mktime(&tmv)), time_t>::value), "");
+    static_assert((std::is_same<decltype(time(&t)), time_t>::value), "");
+    static_assert((std::is_same<decltype(asctime(&tmv)), char*>::value), "");
+    static_assert((std::is_same<decltype(ctime(&t)), char*>::value), "");
+    static_assert((std::is_same<decltype(gmtime(&t)), tm*>::value), "");
+    static_assert((std::is_same<decltype(localtime(&t)), tm*>::value), "");
+    char* c1 = 0;
+    const char* c2 = 0;
+    static_assert((std::is_same<decltype(strftime(c1,s,c2,&tmv)), size_t>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/uchar_h.pass.cpp b/final/test/depr/depr.c.headers/uchar_h.pass.cpp
new file mode 100644
index 0000000..14803ff
--- /dev/null
+++ b/final/test/depr/depr.c.headers/uchar_h.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <uchar.h>
+
+#include <uchar.h>
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.c.headers/wchar_h.pass.cpp b/final/test/depr/depr.c.headers/wchar_h.pass.cpp
new file mode 100644
index 0000000..68bea49
--- /dev/null
+++ b/final/test/depr/depr.c.headers/wchar_h.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <wchar.h>
+
+#include <wchar.h>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+int main()
+{
+    mbstate_t mb = {0};
+    size_t s = 0;
+    tm *tm = 0;
+    wint_t w = 0;
+    ::FILE* fp = 0;
+#ifdef __APPLE__
+    __darwin_va_list va;
+#else
+    __builtin_va_list va;
+#endif
+    char* ns = 0;
+    wchar_t* ws = 0;
+    static_assert((std::is_same<decltype(fwprintf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(fwscanf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(swprintf(ws, s, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(swscanf(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(vfwprintf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vfwscanf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vswprintf(ws, s, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vswscanf(L"", L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(wprintf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(wscanf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(fgetwc(fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(fgetws(ws, 0, fp)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(fputwc(L' ', fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(fputws(L"", fp)), int>::value), "");
+    static_assert((std::is_same<decltype(fwide(fp, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(getwc(fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(getwchar()), wint_t>::value), "");
+    static_assert((std::is_same<decltype(putwc(L' ', fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), "");
+    static_assert((std::is_same<decltype(ungetwc(L' ', fp)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(wcstod(L"", (wchar_t**)0)), double>::value), "");
+    static_assert((std::is_same<decltype(wcstof(L"", (wchar_t**)0)), float>::value), "");
+    static_assert((std::is_same<decltype(wcstold(L"", (wchar_t**)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
+    static_assert((std::is_same<decltype(wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
+    static_assert((std::is_same<decltype(wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(wcscpy(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsncpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcscat(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsncat(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcscmp(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemmove(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wmemset(ws, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(wcsftime(ws, s, L"", tm)), size_t>::value), "");
+    static_assert((std::is_same<decltype(btowc(0)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(wctob(w)), int>::value), "");
+    static_assert((std::is_same<decltype(mbsinit(&mb)), int>::value), "");
+    static_assert((std::is_same<decltype(mbrlen("", s, &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(mbrtowc(ws, "", s, &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcrtomb(ns, L' ', &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), "");
+    static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), "");
+}
diff --git a/final/test/depr/depr.c.headers/wctype_h.pass.cpp b/final/test/depr/depr.c.headers/wctype_h.pass.cpp
new file mode 100644
index 0000000..ad31071
--- /dev/null
+++ b/final/test/depr/depr.c.headers/wctype_h.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <wctype.h>
+
+#include <wctype.h>
+#include <type_traits>
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+#ifdef iswalnum
+#error iswalnum defined
+#endif
+
+#ifdef iswalpha
+#error iswalpha defined
+#endif
+
+#ifdef iswblank
+#error iswblank defined
+#endif
+
+#ifdef iswcntrl
+#error iswcntrl defined
+#endif
+
+#ifdef iswdigit
+#error iswdigit defined
+#endif
+
+#ifdef iswgraph
+#error iswgraph defined
+#endif
+
+#ifdef iswlower
+#error iswlower defined
+#endif
+
+#ifdef iswprint
+#error iswprint defined
+#endif
+
+#ifdef iswpunct
+#error iswpunct defined
+#endif
+
+#ifdef iswspace
+#error iswspace defined
+#endif
+
+#ifdef iswupper
+#error iswupper defined
+#endif
+
+#ifdef iswxdigit
+#error iswxdigit defined
+#endif
+
+#ifdef iswctype
+#error iswctype defined
+#endif
+
+#ifdef wctype
+#error wctype defined
+#endif
+
+#ifdef towlower
+#error towlower defined
+#endif
+
+#ifdef towupper
+#error towupper defined
+#endif
+
+#ifdef towctrans
+#error towctrans defined
+#endif
+
+#ifdef wctrans
+#error wctrans defined
+#endif
+
+int main()
+{
+    wint_t w = 0;
+    wctrans_t wctr = 0;
+    wctype_t wct = 0;
+    static_assert((std::is_same<decltype(iswalnum(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswalpha(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswblank(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswcntrl(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswgraph(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswlower(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswprint(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswpunct(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswspace(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswupper(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswxdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(iswctype(w, wct)), int>::value), "");
+    static_assert((std::is_same<decltype(wctype("")), wctype_t>::value), "");
+    static_assert((std::is_same<decltype(towlower(w)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(towupper(w)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(towctrans(w, wctr)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(wctrans("")), wctrans_t>::value), "");
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp
new file mode 100644
index 0000000..41c9999
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// pointer_to_binary_function
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double binary_f(int i, short j) {return i - j + .75;}
+
+int main()
+{
+    typedef std::pointer_to_binary_function<int, short, double> F;
+    static_assert((std::is_base_of<std::binary_function<int, short, double>, F>::value), "");
+    const F f(binary_f);
+    assert(f(36, 27) == 9.75);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp
new file mode 100644
index 0000000..126cf32
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// pointer_to_unary_function
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double unary_f(int i) {return 0.5 - i;}
+
+int main()
+{
+    typedef std::pointer_to_unary_function<int, double> F;
+    static_assert((std::is_base_of<std::unary_function<int, double>, F>::value), "");
+    const F f(unary_f);
+    assert(f(36) == -35.5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp
new file mode 100644
index 0000000..c7ce90d
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <CopyConstructible Arg, Returnable Result>
+// pointer_to_unary_function<Arg, Result>
+// ptr_fun(Result (*f)(Arg));
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double unary_f(int i) {return 0.5 - i;}
+
+int main()
+{
+    assert(std::ptr_fun(unary_f)(36) == -35.5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp
new file mode 100644
index 0000000..17c4b61
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result>
+// pointer_to_binary_function<Arg1,Arg2,Result>
+// ptr_fun(Result (*f)(Arg1, Arg2));
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+double binary_f(int i, short j) {return i - j + .75;}
+
+int main()
+{
+    assert(std::ptr_fun(binary_f)(36, 27) == 9.75);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp
new file mode 100644
index 0000000..455eed9
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<cReturnable S, ClassType T>
+//   const_mem_fun_t<S,T>
+//   mem_fun(S (T::*f)() const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    const A a = A();
+    assert(std::mem_fun(&A::a3)(&a) == 1);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp
new file mode 100644
index 0000000..46fd6d2
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+//   const_mem_fun1_t<S,T,A>
+//   mem_fun(S (T::*f)(A) const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    const A a = A();
+    assert(std::mem_fun(&A::a4)(&a, 6) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp
new file mode 100644
index 0000000..0c4bb93
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun1_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::const_mem_fun1_ref_t<double, A, unsigned> F;
+    static_assert((std::is_base_of<std::binary_function<A, unsigned, double>, F>::value), "");
+    const F f(&A::a4);
+    const A a = A();
+    assert(f(a, 6) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp
new file mode 100644
index 0000000..ca670bc
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun1_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::const_mem_fun1_t<double, A, unsigned> F;
+    static_assert((std::is_base_of<std::binary_function<const A*, unsigned, double>, F>::value), "");
+    const F f(&A::a4);
+    const A a = A();
+    assert(f(&a, 6) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp
new file mode 100644
index 0000000..74d8950
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T>
+//   const_mem_fun_ref_t<S,T>
+//   mem_fun_ref(S (T::*f)() const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    const A a = A();
+    assert(std::mem_fun_ref(&A::a3)(a) == 1);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp
new file mode 100644
index 0000000..b858561
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+//   const_mem_fun1_ref_t<S,T,A>
+//   mem_fun_ref(S (T::*f)(A) const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    const A a = A();
+    assert(std::mem_fun_ref(&A::a4)(a, 6) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp
new file mode 100644
index 0000000..9eec24e
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::const_mem_fun_ref_t<int, A> F;
+    static_assert((std::is_base_of<std::unary_function<A, int>, F>::value), "");
+    const F f(&A::a3);
+    const A a = A();
+    assert(f(a) == 1);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp
new file mode 100644
index 0000000..9681b74
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// const_mem_fun_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::const_mem_fun_t<int, A> F;
+    static_assert((std::is_base_of<std::unary_function<const A*, int>, F>::value), "");
+    const F f(&A::a3);
+    const A a = A();
+    assert(f(&a) == 1);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp
new file mode 100644
index 0000000..d0d2860
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T>
+//   mem_fun_t<S,T>
+//   mem_fun(S (T::*f)());
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    A a;
+    assert(std::mem_fun(&A::a1)(&a) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp
new file mode 100644
index 0000000..acee9af
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+//   mem_fun1_t<S,T,A>
+//   mem_fun(S (T::*f)(A));
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    A a;
+    assert(std::mem_fun(&A::a2)(&a, 5) == 6);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp
new file mode 100644
index 0000000..a78cbf2
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun1_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::mem_fun1_ref_t<short, A, int> F;
+    static_assert((std::is_base_of<std::binary_function<A, int, short>, F>::value), "");
+    const F f(&A::a2);
+    A a;
+    assert(f(a, 5) == 6);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp
new file mode 100644
index 0000000..90ba9bb
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun1_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::mem_fun1_t<short, A, int> F;
+    static_assert((std::is_base_of<std::binary_function<A*, int, short>, F>::value), "");
+    const F f(&A::a2);
+    A a;
+    assert(f(&a, 5) == 6);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp
new file mode 100644
index 0000000..d3843fc
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T>
+//   mem_fun_ref_t<S,T>
+//   mem_fun_ref(S (T::*f)());
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    A a;
+    assert(std::mem_fun_ref(&A::a1)(a) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp
new file mode 100644
index 0000000..39a324d
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable S, ClassType T, CopyConstructible A>
+//   mem_fun1_ref_t<S,T,A>
+//   mem_fun_ref(S (T::*f)(A));
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    A a;
+    assert(std::mem_fun_ref(&A::a2)(a, 5) == 6);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp
new file mode 100644
index 0000000..236d8d0
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun_ref_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::mem_fun_ref_t<char, A> F;
+    static_assert((std::is_base_of<std::unary_function<A, char>, F>::value), "");
+    const F f(&A::a1);
+    A a;
+    assert(f(a) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp
new file mode 100644
index 0000000..3fc84cd
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// mem_fun_t
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+struct A
+{
+    char a1() {return 5;}
+    short a2(int i) {return short(i+1);}
+    int a3() const {return 1;}
+    double a4(unsigned i) const {return i-1;}
+};
+
+int main()
+{
+    typedef std::mem_fun_t<char, A> F;
+    static_assert((std::is_base_of<std::unary_function<A*, char>, F>::value), "");
+    const F f(&A::a1);
+    A a;
+    assert(f(&a) == 5);
+}
diff --git a/final/test/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp b/final/test/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.adaptors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.function.objects/depr.base/binary_function.pass.cpp b/final/test/depr/depr.function.objects/depr.base/binary_function.pass.cpp
new file mode 100644
index 0000000..ddca8fd
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.base/binary_function.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Arg1, class Arg2, class Result>
+// struct binary_function
+// {
+//     typedef Arg1   first_argument_type;
+//     typedef Arg2   second_argument_type;
+//     typedef Result result_type;
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::binary_function<int, unsigned, char>::first_argument_type, int>::value), "");
+    static_assert((std::is_same<std::binary_function<int, unsigned, char>::second_argument_type, unsigned>::value), "");
+    static_assert((std::is_same<std::binary_function<int, unsigned, char>::result_type, char>::value), "");
+}
diff --git a/final/test/depr/depr.function.objects/depr.base/unary_function.pass.cpp b/final/test/depr/depr.function.objects/depr.base/unary_function.pass.cpp
new file mode 100644
index 0000000..87cfe09
--- /dev/null
+++ b/final/test/depr/depr.function.objects/depr.base/unary_function.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Arg, class Result>
+// struct unary_function
+// {
+//     typedef Arg    argument_type;
+//     typedef Result result_type;
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::unary_function<unsigned, char>::argument_type, unsigned>::value), "");
+    static_assert((std::is_same<std::unary_function<unsigned, char>::result_type, char>::value), "");
+}
diff --git a/final/test/depr/depr.function.objects/nothing_to_do.pass.cpp b/final/test/depr/depr.function.objects/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/depr/depr.function.objects/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.ios.members/io_state.pass.cpp b/final/test/depr/depr.ios.members/io_state.pass.cpp
new file mode 100644
index 0000000..15bfbf1
--- /dev/null
+++ b/final/test/depr/depr.ios.members/io_state.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+//     typedef T1 io_state;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream::io_state b = std::strstream::eofbit;
+    assert(b == std::ios::eofbit);
+}
diff --git a/final/test/depr/depr.ios.members/open_mode.pass.cpp b/final/test/depr/depr.ios.members/open_mode.pass.cpp
new file mode 100644
index 0000000..12a8e94
--- /dev/null
+++ b/final/test/depr/depr.ios.members/open_mode.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+//     typedef T2 open_mode;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream::open_mode b = std::strstream::app;
+    assert(b == std::ios::app);
+}
diff --git a/final/test/depr/depr.ios.members/seek_dir.pass.cpp b/final/test/depr/depr.ios.members/seek_dir.pass.cpp
new file mode 100644
index 0000000..891a7a3
--- /dev/null
+++ b/final/test/depr/depr.ios.members/seek_dir.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+//     typedef T3 seek_dir;
+// };
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream::seek_dir b = std::strstream::cur;
+    assert(b == std::ios::cur);
+}
diff --git a/final/test/depr/depr.ios.members/streamoff.pass.cpp b/final/test/depr/depr.ios.members/streamoff.pass.cpp
new file mode 100644
index 0000000..4ccfd1f
--- /dev/null
+++ b/final/test/depr/depr.ios.members/streamoff.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+//     typedef OFF_T streamoff;
+// };
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_integral<std::ios_base::streamoff>::value), "");
+    static_assert((std::is_signed<std::ios_base::streamoff>::value), "");
+}
diff --git a/final/test/depr/depr.ios.members/streampos.pass.cpp b/final/test/depr/depr.ios.members/streampos.pass.cpp
new file mode 100644
index 0000000..315118c
--- /dev/null
+++ b/final/test/depr/depr.ios.members/streampos.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+//
+// class ios_base
+// {
+// public:
+//     typedef POS_T streampos;
+// };
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::ios_base::streampos, std::streampos>::value), "");
+}
diff --git a/final/test/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp b/final/test/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp
new file mode 100644
index 0000000..b6b7526
--- /dev/null
+++ b/final/test/depr/depr.lib.binders/depr.lib.bind.1st/bind1st.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn, class T>
+//   binder1st<Fn>
+//   bind1st(const Fn& fn, const T& x);
+
+#include <functional>
+#include <cassert>
+
+#include "../test_func.h"
+
+int main()
+{
+    assert(std::bind1st(test_func(1), 5)(10.) == -5.);
+}
diff --git a/final/test/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp b/final/test/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp
new file mode 100644
index 0000000..b7feb24
--- /dev/null
+++ b/final/test/depr/depr.lib.binders/depr.lib.bind.2nd/bind2nd.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn, class T>
+//   binder2nd<Fn>
+//   bind2nd(const Fn& op, const T& x);
+
+#include <functional>
+#include <cassert>
+
+#include "../test_func.h"
+
+int main()
+{
+    assert(std::bind2nd(test_func(1), 5)(10) == 5.);
+}
diff --git a/final/test/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp b/final/test/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp
new file mode 100644
index 0000000..8b7aaf0
--- /dev/null
+++ b/final/test/depr/depr.lib.binders/depr.lib.binder.1st/binder1st.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn>
+// class binder1st
+//   : public unary_function<typename Fn::second_argument_type, typename Fn::result_type>
+// {
+// protected:
+//   Fn op;
+//   typename Fn::first_argument_type value;
+// public:
+//   binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
+//
+//   typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const;
+//   typename Fn::result_type operator()(typename Fn::first_argument_type& x) const;
+// };
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "../test_func.h"
+
+class test
+    : public std::binder1st<test_func>
+{
+    typedef std::binder1st<test_func> base;
+public:
+    test() : std::binder1st<test_func>(test_func(2), 30) {}
+
+    void do_test()
+    {
+        static_assert((std::is_base_of<
+                         std::unary_function<test_func::second_argument_type,
+                                             test_func::result_type>,
+                         test>::value), "");
+        assert(op.id() == 2);
+        assert(value == 30);
+
+        double d = 5;
+        assert((*this)(d) == 35);
+        assert((*this)(5) == 25);
+    }
+};
+
+int main()
+{
+    test t;
+    t.do_test();
+}
diff --git a/final/test/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp b/final/test/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp
new file mode 100644
index 0000000..645c168
--- /dev/null
+++ b/final/test/depr/depr.lib.binders/depr.lib.binder.2nd/binder2nd.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class Fn>
+// class binder2nd
+//   : public unary_function<typename Fn::first_argument_type, typename Fn::result_type>
+// {
+// protected:
+//   Fn op;
+//   typename Fn::second_argument_type value;
+// public:
+//   binder2nd(const Fn& x, const typename Fn::second_argument_type& y);
+//
+//   typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const;
+//   typename Fn::result_type operator()(typename Fn::first_argument_type& x) const;
+// };
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+#include "../test_func.h"
+
+class test
+    : public std::binder2nd<test_func>
+{
+    typedef std::binder2nd<test_func> base;
+public:
+    test() : std::binder2nd<test_func>(test_func(3), 4.5) {}
+
+    void do_test()
+    {
+        static_assert((std::is_base_of<
+                         std::unary_function<test_func::first_argument_type,
+                                             test_func::result_type>,
+                         test>::value), "");
+        assert(op.id() == 3);
+        assert(value == 4.5);
+
+        int i = 5;
+        assert((*this)(i) == 22.5);
+        assert((*this)(5) == 0.5);
+    }
+};
+
+int main()
+{
+    test t;
+    t.do_test();
+}
diff --git a/final/test/depr/depr.lib.binders/nothing_to_do.pass.cpp b/final/test/depr/depr.lib.binders/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/depr/depr.lib.binders/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/depr/depr.lib.binders/test_func.h b/final/test/depr/depr.lib.binders/test_func.h
new file mode 100644
index 0000000..1c1a467
--- /dev/null
+++ b/final/test/depr/depr.lib.binders/test_func.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 TEST_FUNC_H
+#define TEST_FUNC_H
+
+class test_func
+{
+    int id_;
+public:
+    typedef int first_argument_type;
+    typedef double second_argument_type;
+    typedef long double result_type;
+
+    explicit test_func(int id) : id_(id) {}
+
+    int id() const {return id_;}
+
+    result_type operator() (const first_argument_type& x, second_argument_type& y) const
+        {return x+y;}
+    result_type operator() (const first_argument_type& x, const second_argument_type& y) const
+        {return x-y;}
+    result_type operator() (first_argument_type& x, const second_argument_type& y) const
+        {return x*y;}
+};
+
+#endif  // TEST_FUNC_H
diff --git a/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
new file mode 100644
index 0000000..9911df7
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(const char* s);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        std::istrstream in(buf);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "dog");
+        assert(in.eof());
+        assert(!in.fail());
+        in.clear();
+        in.putback('g');
+        assert(!in.fail());
+        in.putback('g');
+        assert(in.fail());
+        assert(buf[9] == 'o');
+        assert(buf[10] == 'g');
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
new file mode 100644
index 0000000..a800950
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/ccp_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(const char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        std::istrstream in(buf, 7);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "");
+        assert(in.eof());
+        assert(in.fail());
+        in.clear();
+        in.putback('5');
+        assert(!in.fail());
+        in.putback('5');
+        assert(in.fail());
+        assert(buf[5] == '.');
+        assert(buf[6] == '5');
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
new file mode 100644
index 0000000..edd6c1f
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(char* s);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::istrstream in(buf);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "dog");
+        assert(in.eof());
+        assert(!in.fail());
+        in.clear();
+        in.putback('g');
+        assert(!in.fail());
+        in.putback('g');
+        assert(!in.fail());
+        assert(buf[9] == 'g');
+        assert(buf[10] == 'g');
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
new file mode 100644
index 0000000..5d01715
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.cons/cp_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// explicit istrstream(char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::istrstream in(buf, 7);
+        int i;
+        in >> i;
+        assert(i == 123);
+        double d;
+        in >> d;
+        assert(d == 4.5);
+        std::string s;
+        in >> s;
+        assert(s == "");
+        assert(in.eof());
+        assert(in.fail());
+        in.clear();
+        in.putback('5');
+        assert(!in.fail());
+        in.putback('5');
+        assert(!in.fail());
+        assert(buf[5] == '5');
+        assert(buf[6] == '5');
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..0c273b3
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/rdbuf.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        const std::istrstream in(buf);
+        std::strstreambuf* sb = in.rdbuf();
+        assert(sb->sgetc() == '1');
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp
new file mode 100644
index 0000000..deb43d6
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.istrstream/depr.istrstream.members/str.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "123 4.5 dog";
+        std::istrstream in(buf);
+        assert(in.str() == std::string("123 4.5 dog"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp b/final/test/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp
new file mode 100644
index 0000000..4e158c6
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.istrstream/types.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class istrstream
+//     : public basic_istream<char>
+// {
+//     ...
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::istream, std::istrstream>::value), "");
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
new file mode 100644
index 0000000..1ad0bfa
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/cp_size_mode.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::ostrstream out(buf, 0);
+        assert(out.str() == std::string("123 4.5 dog"));
+        int i = 321;
+        double d = 5.5;
+        std::string s("cat");
+        out << i << ' ' << d << ' ' << s << std::ends;
+        assert(out.str() == std::string("321 5.5 cat"));
+    }
+    {
+        char buf[23] = "123 4.5 dog";
+        std::ostrstream out(buf, 11, std::ios::app);
+        assert(out.str() == std::string("123 4.5 dog"));
+        int i = 321;
+        double d = 5.5;
+        std::string s("cat");
+        out << i << ' ' << d << ' ' << s << std::ends;
+        assert(out.str() == std::string("123 4.5 dog321 5.5 cat"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
new file mode 100644
index 0000000..78343f8
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.cons/default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// ostrstream();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::ostrstream out;
+    int i = 123;
+    double d = 4.5;
+    std::string s("dog");
+    out << i << ' ' << d << ' ' << s << std::ends;
+    assert(out.str() == std::string("123 4.5 dog"));
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
new file mode 100644
index 0000000..97869f6
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/freeze.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostrstream out;
+        out.freeze();
+        assert(!out.fail());
+        out << 'a';
+        assert(out.fail());
+        out.clear();
+        out.freeze(false);
+        out << 'a';
+        out << char(0);
+        assert(out.str() == std::string("a"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp
new file mode 100644
index 0000000..4a752d6
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/pcount.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostrstream out;
+        assert(out.pcount() == 0);
+        out << 123 << ' ' << 4.5 << ' ' << "dog";
+        assert(out.pcount() == 11);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..b8a23b2
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/rdbuf.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        const std::ostrstream out(buf, 0);
+        std::strstreambuf* sb = out.rdbuf();
+        assert(sb->sputc('a') == 'a');
+        assert(buf == std::string("a23 4.5 dog"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
new file mode 100644
index 0000000..9a5542a
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.ostrstream/depr.ostrstream.members/str.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostrstream out;
+        out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
+        assert(out.str() == std::string("123 4.5 dog"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp b/final/test/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp
new file mode 100644
index 0000000..88ab272
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.ostrstream/types.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class ostrstream
+//     : public basic_ostream<char>
+// {
+//     ...
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::ostream, std::ostrstream>::value), "");
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
new file mode 100644
index 0000000..2a4c0ec
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/cp_size_mode.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        std::strstream inout(buf, 0);
+        assert(inout.str() == std::string("123 4.5 dog"));
+        int i = 321;
+        double d = 5.5;
+        std::string s("cat");
+        inout >> i;
+        assert(inout.fail());
+        inout.clear();
+        inout << i << ' ' << d << ' ' << s;
+        assert(inout.str() == std::string("321 5.5 cat"));
+        i = 0;
+        d = 0;
+        s = "";
+        inout >> i >> d >> s;
+        assert(i == 321);
+        assert(d == 5.5);
+        assert(s == "cat");
+    }
+    {
+        char buf[23] = "123 4.5 dog";
+        std::strstream inout(buf, 11, std::ios::app);
+        assert(inout.str() == std::string("123 4.5 dog"));
+        int i = 0;
+        double d = 0;
+        std::string s;
+        inout >> i >> d >> s;
+        assert(i == 123);
+        assert(d == 4.5);
+        assert(s == "dog");
+        i = 321;
+        d = 5.5;
+        s = "cat";
+        inout.clear();
+        inout << i << ' ' << d << ' ' << s;
+        assert(inout.str() == std::string("123 4.5 dog321 5.5 cat"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
new file mode 100644
index 0000000..374f430
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.cons/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstream();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    std::strstream inout;
+    int i = 123;
+    double d = 4.5;
+    std::string s("dog");
+    inout << i << ' ' << d << ' ' << s << std::ends;
+    assert(inout.str() == std::string("123 4.5 dog"));
+    i = 0;
+    d = 0;
+    s = "";
+    inout >> i >> d >> s;
+    assert(i == 123);
+    assert(d == 4.5);
+    assert(strcmp(s.c_str(), "dog") == 0);
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp
new file mode 100644
index 0000000..4adb179
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.dest/rdbuf.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// strstreambuf* rdbuf() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "123 4.5 dog";
+        const std::strstream out(buf, 0);
+        std::strstreambuf* sb = out.rdbuf();
+        assert(sb->sputc('a') == 'a');
+        assert(buf == std::string("a23 4.5 dog"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
new file mode 100644
index 0000000..525073c
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/freeze.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstream out;
+        out.freeze();
+        assert(!out.fail());
+        out << 'a';
+        assert(out.fail());
+        out.clear();
+        out.freeze(false);
+        out << 'a';
+        out << char(0);
+        assert(out.str() == std::string("a"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp
new file mode 100644
index 0000000..18b6350
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/pcount.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstream out;
+        assert(out.pcount() == 0);
+        out << 123 << ' ' << 4.5 << ' ' << "dog";
+        assert(out.pcount() == 11);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
new file mode 100644
index 0000000..4ac1c44
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstream/depr.strstream.oper/str.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstream out;
+        out << 123 << ' ' << 4.5 << ' ' << "dog" << std::ends;
+        assert(out.str() == std::string("123 4.5 dog"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstream/types.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstream/types.pass.cpp
new file mode 100644
index 0000000..67ea324
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstream/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstream
+//     : public basic_iostream<char>
+// {
+// public:
+//     // Types
+//     typedef char                        char_type;
+//     typedef char_traits<char>::int_type int_type;
+//     typedef char_traits<char>::pos_type pos_type;
+//     typedef char_traits<char>::off_type off_type;
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::iostream, std::strstream>::value), "");
+    static_assert((std::is_same<std::strstream::char_type, char>::value), "");
+    static_assert((std::is_same<std::strstream::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::strstream::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::strstream::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp
new file mode 100644
index 0000000..04eaab5
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ccp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        const char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
new file mode 100644
index 0000000..5d345f1
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cp_size_cp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        char buf[10] = "abcd";
+        int s = std::strlen(buf);
+        std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == 'j');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == 'j');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp
new file mode 100644
index 0000000..13ae427
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cscp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const signed char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        const signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        const signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp
new file mode 100644
index 0000000..3a09711
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/cucp_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(const unsigned char* gnext_arg, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp
new file mode 100644
index 0000000..12a1fb8
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/custom_alloc.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
+
+#include <strstream>
+#include <cassert>
+
+int called = 0;
+
+void* my_alloc(std::size_t n)
+{
+    static char buf[10000];
+    ++called;
+    return buf;
+}
+
+void my_free(void*)
+{
+    ++called;
+}
+
+struct test
+    : std::strstreambuf
+{
+    test(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*))
+        : std::strstreambuf(palloc_arg, pfree_arg) {}
+    virtual int_type overflow(int_type c)
+        {return std::strstreambuf::overflow(c);}
+};
+
+int main()
+{
+    {
+        test s(my_alloc, my_free);
+        assert(called == 0);
+        s.overflow('a');
+        assert(called == 1);
+    }
+    assert(called == 2);
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp
new file mode 100644
index 0000000..1e5635e
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// explicit strstreambuf(streamsize alsize_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf s;
+        assert(s.str() == nullptr);
+        assert(s.pcount() == 0);
+    }
+    {
+        std::strstreambuf s(1024);
+        assert(s.str() == nullptr);
+        assert(s.pcount() == 0);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
new file mode 100644
index 0000000..c827850
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/scp_size_scp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        signed char buf[10] = "abcd";
+        int s = std::strlen((char*)buf);
+        std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == 'j');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == 'j');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
new file mode 100644
index 0000000..46c11e4
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/ucp_size_ucp.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf));
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == 0);
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[] = "abcd";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.sgetc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == EOF);
+    }
+    {
+        unsigned char buf[10] = "abcd";
+        int s = std::strlen((char*)buf);
+        std::strstreambuf sb(buf, sizeof(buf)-s, buf + s);
+        assert(sb.sgetc() == 'a');
+        assert(sb.snextc() == 'b');
+        assert(sb.snextc() == 'c');
+        assert(sb.snextc() == 'd');
+        assert(sb.snextc() == EOF);
+        assert(sb.sputc('e') == 'e');
+        assert(sb.sputc('f') == 'f');
+        assert(sb.sputc('g') == 'g');
+        assert(sb.sputc('h') == 'h');
+        assert(sb.sputc('i') == 'i');
+        assert(sb.sputc('j') == 'j');
+        assert(sb.sputc('j') == EOF);
+        assert(sb.sgetc() == 'e');
+        assert(sb.snextc() == 'f');
+        assert(sb.snextc() == 'g');
+        assert(sb.snextc() == 'h');
+        assert(sb.snextc() == 'i');
+        assert(sb.snextc() == 'j');
+        assert(sb.snextc() == EOF);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp
new file mode 100644
index 0000000..9572ef3
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/freeze.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// void freeze(bool freezefl = true);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf sb;
+        sb.freeze(true);
+        assert(sb.sputc('a') == EOF);
+        sb.freeze(false);
+        assert(sb.sputc('a') == 'a');
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
new file mode 100644
index 0000000..03e58cb
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/pcount.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int pcount() const;
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf sb;
+        assert(sb.pcount() == 0);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.pcount() == 1);
+        assert(sb.sputc(0) == 0);
+        assert(sb.pcount() == 2);
+        assert(sb.str() == std::string("a"));
+        assert(sb.pcount() == 2);
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
new file mode 100644
index 0000000..dce29c9
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.members/str.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// char* str();
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::strstreambuf sb;
+        assert(sb.sputc('a') == 'a');
+        assert(sb.sputc(0) == 0);
+        assert(sb.str() == std::string("a"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp
new file mode 100644
index 0000000..843450b
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type overflow(int_type c = EOF);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[12] = "abc";
+        std::strstreambuf sb(buf, sizeof(buf), buf);
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == std::string("1bc"));
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == std::string("12c"));
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == std::string("123"));
+        assert(sb.sputc('4') == '4');
+        assert(sb.str() == std::string("1234"));
+        assert(sb.sputc('5') == '5');
+        assert(sb.str() == std::string("12345"));
+        assert(sb.sputc('6') == '6');
+        assert(sb.str() == std::string("123456"));
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == std::string("1234567"));
+        assert(sb.sputc('8') == '8');
+        assert(sb.str() == std::string("12345678"));
+        assert(sb.sputc('9') == '9');
+        assert(sb.str() == std::string("123456789"));
+        assert(sb.sputc('0') == '0');
+        assert(sb.str() == std::string("1234567890"));
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == std::string("12345678901"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 0000000..2a3fe20
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type pbackfail(int_type c = EOF);
+
+#include <strstream>
+#include <cassert>
+
+struct test
+    : public std::strstreambuf
+{
+    typedef std::strstreambuf base;
+    test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0)
+        : base(gnext_arg, n, pbeg_arg) {}
+    test(const char* gnext_arg, std::streamsize n)
+        : base(gnext_arg, n) {}
+
+    virtual int_type pbackfail(int_type c = EOF) {return base::pbackfail(c);}
+};
+
+int main()
+{
+    {
+        const char buf[] = "123";
+        test sb(buf, 0);
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == EOF);
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == EOF);
+        assert(sb.pbackfail('2') == '2');
+        assert(sb.pbackfail(EOF) != EOF);
+        assert(sb.pbackfail(EOF) == EOF);
+        assert(sb.str() == std::string("123"));
+    }
+    {
+        char buf[] = "123";
+        test sb(buf, 0);
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == EOF);
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail(EOF) != EOF);
+        assert(sb.pbackfail(EOF) == EOF);
+        assert(sb.str() == std::string("133"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 0000000..27d5d29
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+    }
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == std::string("012a456789"));
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('b') == 'b');
+        assert(sb.str() == std::string("012a456b89"));
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == std::string("012a456c89"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp
new file mode 100644
index 0000000..d412479
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/seekpos.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// pos_type seekpos(pos_type sp,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+    }
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0, buf);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == std::string("012a456789"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp
new file mode 100644
index 0000000..99eb9e9
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/setbuf.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// streambuf* setbuf(char* s, streamsize n);
+
+#include <strstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[] = "0123456789";
+        std::strstreambuf sb(buf, 0);
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == std::string("0123456789"));
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp
new file mode 100644
index 0000000..1b16a37
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+
+// int_type underflow();
+
+#include <strstream>
+#include <cassert>
+
+struct test
+    : public std::strstreambuf
+{
+    typedef std::strstreambuf base;
+    test(char* gnext_arg, std::streamsize n, char* pbeg_arg = 0)
+        : base(gnext_arg, n, pbeg_arg) {}
+    test(const char* gnext_arg, std::streamsize n)
+        : base(gnext_arg, n) {}
+
+    base::int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+    {
+        char buf[10] = "123";
+        test sb(buf, 0, buf + 3);
+        assert(sb.underflow() == '1');
+        assert(sb.underflow() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.snextc() == EOF);
+        assert(sb.underflow() == EOF);
+        assert(sb.underflow() == EOF);
+        sb.sputc('4');
+        assert(sb.underflow() == '4');
+        assert(sb.underflow() == '4');
+    }
+}
diff --git a/final/test/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp b/final/test/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp
new file mode 100644
index 0000000..c4a1562
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/depr.strstreambuf/types.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+// class strstreambuf
+//     : public basic_streambuf<char>
+
+#include <strstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::streambuf, std::strstreambuf>::value), "");
+}
diff --git a/final/test/depr/depr.str.strstreams/version.pass.cpp b/final/test/depr/depr.str.strstreams/version.pass.cpp
new file mode 100644
index 0000000..f27665f
--- /dev/null
+++ b/final/test/depr/depr.str.strstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <strstream>
+
+#include <strstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/depr/exception.unexpected/nothing_to_do.pass.cpp b/final/test/depr/exception.unexpected/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/depr/exception.unexpected/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp b/final/test/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
new file mode 100644
index 0000000..8b0a0b9
--- /dev/null
+++ b/final/test/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test get_unexpected
+
+#include <exception>
+#include <cassert>
+#include <cstdlib>
+
+void f1() {}
+void f2() {}
+
+void f3()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    
+    std::unexpected_handler old = std::get_unexpected();
+    // verify there is a previous unexpected handler
+    assert(old);
+    std::set_unexpected(f1);
+    assert(std::get_unexpected() == f1);
+    // verify f1 was replace with f2
+    std::set_unexpected(f2);
+    assert(std::get_unexpected() == f2);
+    // verify calling original unexpected handler calls terminate
+    std::set_terminate(f3);
+    (*old)();
+    assert(0);
+}
diff --git a/final/test/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp b/final/test/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
new file mode 100644
index 0000000..ed02fa6
--- /dev/null
+++ b/final/test/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_unexpected
+
+#include <exception>
+#include <cassert>
+#include <cstdlib>
+
+void f1() {}
+void f2() {}
+
+void f3()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::unexpected_handler old = std::set_unexpected(f1);
+    // verify there is a previous unexpected handler
+    assert(old);
+    // verify f1 was replace with f2
+    assert(std::set_unexpected(f2) == f1);
+    // verify calling original unexpected handler calls terminate
+    std::set_terminate(f3);
+    (*old)();
+    assert(0);
+}
diff --git a/final/test/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp b/final/test/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
new file mode 100644
index 0000000..7fab500
--- /dev/null
+++ b/final/test/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test unexpected_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+    std::unexpected_handler p = f;
+}
diff --git a/final/test/depr/exception.unexpected/unexpected/unexpected.pass.cpp b/final/test/depr/exception.unexpected/unexpected/unexpected.pass.cpp
new file mode 100644
index 0000000..03b484f
--- /dev/null
+++ b/final/test/depr/exception.unexpected/unexpected/unexpected.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test unexpected
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::set_unexpected(f1);
+    std::unexpected();
+    assert(false);
+}
diff --git a/final/test/depr/nothing_to_do.pass.cpp b/final/test/depr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/depr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/assertions/cassert.pass.cpp b/final/test/diagnostics/assertions/cassert.pass.cpp
new file mode 100644
index 0000000..bed7a39
--- /dev/null
+++ b/final/test/diagnostics/assertions/cassert.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cassert>
+
+#include <cassert>
+
+#ifndef assert
+#error assert not defined
+#endif
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/diagnostics.general/nothing_to_do.pass.cpp b/final/test/diagnostics/diagnostics.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/diagnostics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/errno/cerrno.pass.cpp b/final/test/diagnostics/errno/cerrno.pass.cpp
new file mode 100644
index 0000000..c6743fb
--- /dev/null
+++ b/final/test/diagnostics/errno/cerrno.pass.cpp
@@ -0,0 +1,349 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cerrno>
+
+#include <cerrno>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+#ifndef E2BIG
+#error E2BIG not defined
+#endif
+
+#ifndef EACCES
+#error EACCES not defined
+#endif
+
+#ifndef EACCES
+#error EACCES not defined
+#endif
+
+#ifndef EADDRINUSE
+#error EADDRINUSE not defined
+#endif
+
+#ifndef EADDRNOTAVAIL
+#error EADDRNOTAVAIL not defined
+#endif
+
+#ifndef EAFNOSUPPORT
+#error EAFNOSUPPORT not defined
+#endif
+
+#ifndef EAGAIN
+#error EAGAIN not defined
+#endif
+
+#ifndef EALREADY
+#error EALREADY not defined
+#endif
+
+#ifndef EBADF
+#error EBADF not defined
+#endif
+
+#ifndef EBADMSG
+#error EBADMSG not defined
+#endif
+
+#ifndef EBUSY
+#error EBUSY not defined
+#endif
+
+#ifndef ECANCELED
+#error ECANCELED not defined
+#endif
+
+#ifndef ECHILD
+#error ECHILD not defined
+#endif
+
+#ifndef ECONNABORTED
+#error ECONNABORTED not defined
+#endif
+
+#ifndef ECONNREFUSED
+#error ECONNREFUSED not defined
+#endif
+
+#ifndef ECONNRESET
+#error ECONNRESET not defined
+#endif
+
+#ifndef EDEADLK
+#error EDEADLK not defined
+#endif
+
+#ifndef EDESTADDRREQ
+#error EDESTADDRREQ not defined
+#endif
+
+#ifndef EDOM
+#error EDOM not defined
+#endif
+
+#ifndef EEXIST
+#error EEXIST not defined
+#endif
+
+#ifndef EFAULT
+#error EFAULT not defined
+#endif
+
+#ifndef EFBIG
+#error EFBIG not defined
+#endif
+
+#ifndef EHOSTUNREACH
+#error EHOSTUNREACH not defined
+#endif
+
+#ifndef EIDRM
+#error EIDRM not defined
+#endif
+
+#ifndef EILSEQ
+#error EILSEQ not defined
+#endif
+
+#ifndef EINPROGRESS
+#error EINPROGRESS not defined
+#endif
+
+#ifndef EINTR
+#error EINTR not defined
+#endif
+
+#ifndef EINVAL
+#error EINVAL not defined
+#endif
+
+#ifndef EIO
+#error EIO not defined
+#endif
+
+#ifndef EISCONN
+#error EISCONN not defined
+#endif
+
+#ifndef EISDIR
+#error EISDIR not defined
+#endif
+
+#ifndef ELOOP
+#error ELOOP not defined
+#endif
+
+#ifndef EMFILE
+#error EMFILE not defined
+#endif
+
+#ifndef EMLINK
+#error EMLINK not defined
+#endif
+
+#ifndef EMSGSIZE
+#error EMSGSIZE not defined
+#endif
+
+#ifndef ENAMETOOLONG
+#error ENAMETOOLONG not defined
+#endif
+
+#ifndef ENETDOWN
+#error ENETDOWN not defined
+#endif
+
+#ifndef ENETRESET
+#error ENETRESET not defined
+#endif
+
+#ifndef ENETUNREACH
+#error ENETUNREACH not defined
+#endif
+
+#ifndef ENFILE
+#error ENFILE not defined
+#endif
+
+#ifndef ENOBUFS
+#error ENOBUFS not defined
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ENODATA
+#error ENODATA not defined
+#endif
+#endif
+
+#ifndef ENODEV
+#error ENODEV not defined
+#endif
+
+#ifndef ENOENT
+#error ENOENT not defined
+#endif
+
+#ifndef ENOEXEC
+#error ENOEXEC not defined
+#endif
+
+#ifndef ENOLCK
+#error ENOLCK not defined
+#endif
+
+#ifndef ENOLINK
+#error ENOLINK not defined
+#endif
+
+#ifndef ENOMEM
+#error ENOMEM not defined
+#endif
+
+#ifndef ENOMSG
+#error ENOMSG not defined
+#endif
+
+#ifndef ENOPROTOOPT
+#error ENOPROTOOPT not defined
+#endif
+
+#ifndef ENOSPC
+#error ENOSPC not defined
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ENOSR
+#error ENOSR not defined
+#endif
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ENOSTR
+#error ENOSTR not defined
+#endif
+#endif
+
+#ifndef ENOSYS
+#error ENOSYS not defined
+#endif
+
+#ifndef ENOTCONN
+#error ENOTCONN not defined
+#endif
+
+#ifndef ENOTDIR
+#error ENOTDIR not defined
+#endif
+
+#ifndef ENOTEMPTY
+#error ENOTEMPTY not defined
+#endif
+
+#ifndef ENOTRECOVERABLE
+#error ENOTRECOVERABLE not defined
+#endif
+
+#ifndef ENOTSOCK
+#error ENOTSOCK not defined
+#endif
+
+#ifndef ENOTSUP
+#error ENOTSUP not defined
+#endif
+
+#ifndef ENOTTY
+#error ENOTTY not defined
+#endif
+
+#ifndef ENXIO
+#error ENXIO not defined
+#endif
+
+#ifndef EOPNOTSUPP
+#error EOPNOTSUPP not defined
+#endif
+
+#ifndef EOVERFLOW
+#error EOVERFLOW not defined
+#endif
+
+#ifndef EOWNERDEAD
+#error EOWNERDEAD not defined
+#endif
+
+#ifndef EPERM
+#error EPERM not defined
+#endif
+
+#ifndef EPIPE
+#error EPIPE not defined
+#endif
+
+#ifndef EPROTO
+#error EPROTO not defined
+#endif
+
+#ifndef EPROTONOSUPPORT
+#error EPROTONOSUPPORT not defined
+#endif
+
+#ifndef EPROTOTYPE
+#error EPROTOTYPE not defined
+#endif
+
+#ifndef ERANGE
+#error ERANGE not defined
+#endif
+
+#ifndef EROFS
+#error EROFS not defined
+#endif
+
+#ifndef ESPIPE
+#error ESPIPE not defined
+#endif
+
+#ifndef ESRCH
+#error ESRCH not defined
+#endif
+
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+#ifndef ETIME
+#error ETIME not defined
+#endif
+#endif
+
+#ifndef ETIMEDOUT
+#error ETIMEDOUT not defined
+#endif
+
+#ifndef ETXTBSY
+#error ETXTBSY not defined
+#endif
+
+#ifndef EWOULDBLOCK
+#error EWOULDBLOCK not defined
+#endif
+
+#ifndef EXDEV
+#error EXDEV not defined
+#endif
+
+#ifndef errno
+#error errno not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/nothing_to_do.pass.cpp b/final/test/diagnostics/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp b/final/test/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp
new file mode 100644
index 0000000..5769d25
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/domain.error/domain_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test domain_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::domain_error>::value),
+                 "std::is_base_of<std::logic_error, std::domain_error>::value");
+    static_assert(std::is_polymorphic<std::domain_error>::value,
+                 "std::is_polymorphic<std::domain_error>::value");
+    {
+    const char* msg = "domain_error message";
+    std::domain_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::domain_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another domain_error message");
+    std::domain_error e(msg);
+    assert(e.what() == msg);
+    std::domain_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp b/final/test/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp
new file mode 100644
index 0000000..e360275
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/invalid.argument/invalid_argument.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test invalid_argument
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::invalid_argument>::value),
+                 "std::is_base_of<std::logic_error, std::invalid_argument>::value");
+    static_assert(std::is_polymorphic<std::invalid_argument>::value,
+                 "std::is_polymorphic<std::invalid_argument>::value");
+    {
+    const char* msg = "invalid_argument message";
+    std::invalid_argument e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::invalid_argument e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another invalid_argument message");
+    std::invalid_argument e(msg);
+    assert(e.what() == msg);
+    std::invalid_argument e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/length.error/length_error.pass.cpp b/final/test/diagnostics/std.exceptions/length.error/length_error.pass.cpp
new file mode 100644
index 0000000..3a91441
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/length.error/length_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test length_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::length_error>::value),
+                 "std::is_base_of<std::logic_error, std::length_error>::value");
+    static_assert(std::is_polymorphic<std::length_error>::value,
+                 "std::is_polymorphic<std::length_error>::value");
+    {
+    const char* msg = "length_error message";
+    std::length_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::length_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another length_error message");
+    std::length_error e(msg);
+    assert(e.what() == msg);
+    std::length_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp b/final/test/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp
new file mode 100644
index 0000000..3c3d4f4
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/logic.error/logic_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test logic_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::logic_error>::value),
+                 "std::is_base_of<std::exception, std::logic_error>::value");
+    static_assert(std::is_polymorphic<std::logic_error>::value,
+                 "std::is_polymorphic<std::logic_error>::value");
+    {
+    const char* msg = "logic_error message";
+    std::logic_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::logic_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another logic_error message");
+    std::logic_error e(msg);
+    assert(e.what() == msg);
+    std::logic_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp b/final/test/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp
new file mode 100644
index 0000000..f358d2b
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/out.of.range/out_of_range.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test out_of_range
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::logic_error, std::out_of_range>::value),
+                 "std::is_base_of<std::logic_error, std::out_of_range>::value");
+    static_assert(std::is_polymorphic<std::out_of_range>::value,
+                 "std::is_polymorphic<std::out_of_range>::value");
+    {
+    const char* msg = "out_of_range message";
+    std::out_of_range e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::out_of_range e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another out_of_range message");
+    std::out_of_range e(msg);
+    assert(e.what() == msg);
+    std::out_of_range e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp b/final/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
new file mode 100644
index 0000000..47f75eb
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/overflow.error/overflow_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test overflow_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::runtime_error, std::overflow_error>::value),
+                 "std::is_base_of<std::runtime_error, std::overflow_error>::value");
+    static_assert(std::is_polymorphic<std::overflow_error>::value,
+                 "std::is_polymorphic<std::overflow_error>::value");
+    {
+    const char* msg = "overflow_error message";
+    std::overflow_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::overflow_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another overflow_error message");
+    std::overflow_error e(msg);
+    assert(e.what() == msg);
+    std::overflow_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/range.error/range_error.pass.cpp b/final/test/diagnostics/std.exceptions/range.error/range_error.pass.cpp
new file mode 100644
index 0000000..8c82a91
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/range.error/range_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test range_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::runtime_error, std::range_error>::value),
+                 "std::is_base_of<std::runtime_error, std::range_error>::value");
+    static_assert(std::is_polymorphic<std::range_error>::value,
+                 "std::is_polymorphic<std::range_error>::value");
+    {
+    const char* msg = "range_error message";
+    std::range_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::range_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another range_error message");
+    std::range_error e(msg);
+    assert(e.what() == msg);
+    std::range_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp b/final/test/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp
new file mode 100644
index 0000000..2b2fe20
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/runtime.error/runtime_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test runtime_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::runtime_error>::value),
+                 "std::is_base_of<std::exception, std::runtime_error>::value");
+    static_assert(std::is_polymorphic<std::runtime_error>::value,
+                 "std::is_polymorphic<std::runtime_error>::value");
+    {
+    const char* msg = "runtime_error message";
+    std::runtime_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::runtime_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another runtime_error message");
+    std::runtime_error e(msg);
+    assert(e.what() == msg);
+    std::runtime_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp b/final/test/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp
new file mode 100644
index 0000000..103c290
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/underflow.error/underflow_error.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test underflow_error
+
+#include <stdexcept>
+#include <type_traits>
+#include <cstring>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::runtime_error, std::underflow_error>::value),
+                 "std::is_base_of<std::runtime_error, std::underflow_error>::value");
+    static_assert(std::is_polymorphic<std::underflow_error>::value,
+                 "std::is_polymorphic<std::underflow_error>::value");
+    {
+    const char* msg = "underflow_error message";
+    std::underflow_error e(msg);
+    assert(std::strcmp(e.what(), msg) == 0);
+    std::underflow_error e2(e);
+    assert(std::strcmp(e2.what(), msg) == 0);
+    e2 = e;
+    assert(std::strcmp(e2.what(), msg) == 0);
+    }
+    {
+    std::string msg("another underflow_error message");
+    std::underflow_error e(msg);
+    assert(e.what() == msg);
+    std::underflow_error e2(e);
+    assert(e2.what() == msg);
+    e2 = e;
+    assert(e2.what() == msg);
+    }
+}
diff --git a/final/test/diagnostics/std.exceptions/version.pass.cpp b/final/test/diagnostics/std.exceptions/version.pass.cpp
new file mode 100644
index 0000000..d9ab009
--- /dev/null
+++ b/final/test/diagnostics/std.exceptions/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stdexcept>
+
+#include <stdexcept>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/errc.pass.cpp b/final/test/diagnostics/syserr/errc.pass.cpp
new file mode 100644
index 0000000..247e10b
--- /dev/null
+++ b/final/test/diagnostics/syserr/errc.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// enum errc {...}
+
+#include <system_error>
+
+int main()
+{
+    static_assert(static_cast<int>(std::errc::address_family_not_supported) == EAFNOSUPPORT, "");
+    static_assert(static_cast<int>(std::errc::address_in_use) == EADDRINUSE, "");
+    static_assert(static_cast<int>(std::errc::address_not_available) == EADDRNOTAVAIL, "");
+    static_assert(static_cast<int>(std::errc::already_connected) == EISCONN, "");
+    static_assert(static_cast<int>(std::errc::argument_list_too_long) == E2BIG, "");
+    static_assert(static_cast<int>(std::errc::argument_out_of_domain) == EDOM, "");
+    static_assert(static_cast<int>(std::errc::bad_address) == EFAULT, "");
+    static_assert(static_cast<int>(std::errc::bad_file_descriptor) == EBADF, "");
+    static_assert(static_cast<int>(std::errc::bad_message) == EBADMSG, "");
+    static_assert(static_cast<int>(std::errc::broken_pipe) == EPIPE, "");
+    static_assert(static_cast<int>(std::errc::connection_aborted) == ECONNABORTED, "");
+    static_assert(static_cast<int>(std::errc::connection_already_in_progress) == EALREADY, "");
+    static_assert(static_cast<int>(std::errc::connection_refused) == ECONNREFUSED, "");
+    static_assert(static_cast<int>(std::errc::connection_reset) == ECONNRESET, "");
+    static_assert(static_cast<int>(std::errc::cross_device_link) == EXDEV, "");
+    static_assert(static_cast<int>(std::errc::destination_address_required) == EDESTADDRREQ, "");
+    static_assert(static_cast<int>(std::errc::device_or_resource_busy) == EBUSY, "");
+    static_assert(static_cast<int>(std::errc::directory_not_empty) == ENOTEMPTY, "");
+    static_assert(static_cast<int>(std::errc::executable_format_error) == ENOEXEC, "");
+    static_assert(static_cast<int>(std::errc::file_exists) == EEXIST, "");
+    static_assert(static_cast<int>(std::errc::file_too_large) == EFBIG, "");
+    static_assert(static_cast<int>(std::errc::filename_too_long) == ENAMETOOLONG, "");
+    static_assert(static_cast<int>(std::errc::function_not_supported) == ENOSYS, "");
+    static_assert(static_cast<int>(std::errc::host_unreachable) == EHOSTUNREACH, "");
+    static_assert(static_cast<int>(std::errc::identifier_removed) == EIDRM, "");
+    static_assert(static_cast<int>(std::errc::illegal_byte_sequence) == EILSEQ, "");
+    static_assert(static_cast<int>(std::errc::inappropriate_io_control_operation) == ENOTTY, "");
+    static_assert(static_cast<int>(std::errc::interrupted) == EINTR, "");
+    static_assert(static_cast<int>(std::errc::invalid_argument) == EINVAL, "");
+    static_assert(static_cast<int>(std::errc::invalid_seek) == ESPIPE, "");
+    static_assert(static_cast<int>(std::errc::io_error) == EIO, "");
+    static_assert(static_cast<int>(std::errc::is_a_directory) == EISDIR, "");
+    static_assert(static_cast<int>(std::errc::message_size) == EMSGSIZE, "");
+    static_assert(static_cast<int>(std::errc::network_down) == ENETDOWN, "");
+    static_assert(static_cast<int>(std::errc::network_reset) == ENETRESET, "");
+    static_assert(static_cast<int>(std::errc::network_unreachable) == ENETUNREACH, "");
+    static_assert(static_cast<int>(std::errc::no_buffer_space) == ENOBUFS, "");
+    static_assert(static_cast<int>(std::errc::no_child_process) == ECHILD, "");
+    static_assert(static_cast<int>(std::errc::no_link) == ENOLINK, "");
+    static_assert(static_cast<int>(std::errc::no_lock_available) == ENOLCK, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+    static_assert(static_cast<int>(std::errc::no_message_available) == ENODATA, "");
+#endif
+    static_assert(static_cast<int>(std::errc::no_message) == ENOMSG, "");
+    static_assert(static_cast<int>(std::errc::no_protocol_option) == ENOPROTOOPT, "");
+    static_assert(static_cast<int>(std::errc::no_space_on_device) == ENOSPC, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+    static_assert(static_cast<int>(std::errc::no_stream_resources) == ENOSR, "");
+#endif
+    static_assert(static_cast<int>(std::errc::no_such_device_or_address) == ENXIO, "");
+    static_assert(static_cast<int>(std::errc::no_such_device) == ENODEV, "");
+    static_assert(static_cast<int>(std::errc::no_such_file_or_directory) == ENOENT, "");
+    static_assert(static_cast<int>(std::errc::no_such_process) == ESRCH, "");
+    static_assert(static_cast<int>(std::errc::not_a_directory) == ENOTDIR, "");
+    static_assert(static_cast<int>(std::errc::not_a_socket) == ENOTSOCK, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+    static_assert(static_cast<int>(std::errc::not_a_stream) == ENOSTR, "");
+#endif
+    static_assert(static_cast<int>(std::errc::not_connected) == ENOTCONN, "");
+    static_assert(static_cast<int>(std::errc::not_enough_memory) == ENOMEM, "");
+    static_assert(static_cast<int>(std::errc::not_supported) == ENOTSUP, "");
+    static_assert(static_cast<int>(std::errc::operation_canceled) == ECANCELED, "");
+    static_assert(static_cast<int>(std::errc::operation_in_progress) == EINPROGRESS, "");
+    static_assert(static_cast<int>(std::errc::operation_not_permitted) == EPERM, "");
+    static_assert(static_cast<int>(std::errc::operation_not_supported) == EOPNOTSUPP, "");
+    static_assert(static_cast<int>(std::errc::operation_would_block) == EWOULDBLOCK, "");
+    static_assert(static_cast<int>(std::errc::owner_dead) == EOWNERDEAD, "");
+    static_assert(static_cast<int>(std::errc::permission_denied) == EACCES, "");
+    static_assert(static_cast<int>(std::errc::protocol_error) == EPROTO, "");
+    static_assert(static_cast<int>(std::errc::protocol_not_supported) == EPROTONOSUPPORT, "");
+    static_assert(static_cast<int>(std::errc::read_only_file_system) == EROFS, "");
+    static_assert(static_cast<int>(std::errc::resource_deadlock_would_occur) == EDEADLK, "");
+    static_assert(static_cast<int>(std::errc::resource_unavailable_try_again) == EAGAIN, "");
+    static_assert(static_cast<int>(std::errc::result_out_of_range) == ERANGE, "");
+    static_assert(static_cast<int>(std::errc::state_not_recoverable) == ENOTRECOVERABLE, "");
+#if (defined(_XOPEN_STREAMS) && _XOPEN_STREAMS != -1)
+    static_assert(static_cast<int>(std::errc::stream_timeout) == ETIME, "");
+#endif
+    static_assert(static_cast<int>(std::errc::text_file_busy) == ETXTBSY, "");
+    static_assert(static_cast<int>(std::errc::timed_out) == ETIMEDOUT, "");
+    static_assert(static_cast<int>(std::errc::too_many_files_open_in_system) == ENFILE, "");
+    static_assert(static_cast<int>(std::errc::too_many_files_open) == EMFILE, "");
+    static_assert(static_cast<int>(std::errc::too_many_links) == EMLINK, "");
+    static_assert(static_cast<int>(std::errc::too_many_symbolic_link_levels) == ELOOP, "");
+    static_assert(static_cast<int>(std::errc::value_too_large) == EOVERFLOW, "");
+    static_assert(static_cast<int>(std::errc::wrong_protocol_type) == EPROTOTYPE, "");
+}
diff --git a/final/test/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp b/final/test/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp
new file mode 100644
index 0000000..e2e7aed
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.compare/eq_error_code_error_code.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// bool operator==(const error_code&      lhs, const error_code&      rhs);
+// bool operator==(const error_code&      lhs, const error_condition& rhs);
+// bool operator==(const error_condition& lhs, const error_code&      rhs);
+// bool operator==(const error_condition& lhs, const error_condition& rhs);
+// bool operator!=(const error_code&      lhs, const error_code&      rhs);
+// bool operator!=(const error_code&      lhs, const error_condition& rhs);
+// bool operator!=(const error_condition& lhs, const error_code&      rhs);
+// bool operator!=(const error_condition& lhs, const error_condition& rhs);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    std::error_code e_code1(5, std::generic_category());
+    std::error_code e_code2(5, std::system_category());
+    std::error_code e_code3(6, std::generic_category());
+    std::error_code e_code4(6, std::system_category());
+    std::error_condition e_condition1(5, std::generic_category());
+    std::error_condition e_condition2(5, std::system_category());
+    std::error_condition e_condition3(6, std::generic_category());
+    std::error_condition e_condition4(6, std::system_category());
+
+    assert(e_code1 == e_code1);
+    assert(e_code1 != e_code2);
+    assert(e_code1 != e_code3);
+    assert(e_code1 != e_code4);
+    assert(e_code1 == e_condition1);
+    assert(e_code1 != e_condition2);
+    assert(e_code1 != e_condition3);
+    assert(e_code1 != e_condition4);
+
+    assert(e_code2 != e_code1);
+    assert(e_code2 == e_code2);
+    assert(e_code2 != e_code3);
+    assert(e_code2 != e_code4);
+    assert(e_code2 == e_condition1);  // ?
+    assert(e_code2 == e_condition2);
+    assert(e_code2 != e_condition3);
+    assert(e_code2 != e_condition4);
+
+    assert(e_code3 != e_code1);
+    assert(e_code3 != e_code2);
+    assert(e_code3 == e_code3);
+    assert(e_code3 != e_code4);
+    assert(e_code3 != e_condition1);
+    assert(e_code3 != e_condition2);
+    assert(e_code3 == e_condition3);
+    assert(e_code3 != e_condition4);
+
+    assert(e_code4 != e_code1);
+    assert(e_code4 != e_code2);
+    assert(e_code4 != e_code3);
+    assert(e_code4 == e_code4);
+    assert(e_code4 != e_condition1);
+    assert(e_code4 != e_condition2);
+    assert(e_code4 == e_condition3);  // ?
+    assert(e_code4 == e_condition4);
+
+    assert(e_condition1 == e_code1);
+    assert(e_condition1 == e_code2);  // ?
+    assert(e_condition1 != e_code3);
+    assert(e_condition1 != e_code4);
+    assert(e_condition1 == e_condition1);
+    assert(e_condition1 != e_condition2);
+    assert(e_condition1 != e_condition3);
+    assert(e_condition1 != e_condition4);
+
+    assert(e_condition2 != e_code1);
+    assert(e_condition2 == e_code2);
+    assert(e_condition2 != e_code3);
+    assert(e_condition2 != e_code4);
+    assert(e_condition2 != e_condition1);
+    assert(e_condition2 == e_condition2);
+    assert(e_condition2 != e_condition3);
+    assert(e_condition2 != e_condition4);
+
+    assert(e_condition3 != e_code1);
+    assert(e_condition3 != e_code2);
+    assert(e_condition3 == e_code3);
+    assert(e_condition3 == e_code4);  // ?
+    assert(e_condition3 != e_condition1);
+    assert(e_condition3 != e_condition2);
+    assert(e_condition3 == e_condition3);
+    assert(e_condition3 != e_condition4);
+
+    assert(e_condition4 != e_code1);
+    assert(e_condition4 != e_code2);
+    assert(e_condition4 != e_code3);
+    assert(e_condition4 == e_code4);
+    assert(e_condition4 != e_condition1);
+    assert(e_condition4 != e_condition2);
+    assert(e_condition4 != e_condition3);
+    assert(e_condition4 == e_condition4);
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp
new file mode 100644
index 0000000..82770fb
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.derived/message.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual string message(int ev) const = 0;
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+#include <stdio.h>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::system_category();
+    std::string m1 = e_cat1.message(5);
+    std::string m2 = e_cat2.message(5);
+    std::string m3 = e_cat2.message(6);
+    assert(!m1.empty());
+    assert(!m2.empty());
+    assert(!m3.empty());
+    assert(m1 == m2);
+    assert(m1 != m3);
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp
new file mode 100644
index 0000000..0573ef8
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/default_ctor.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// constexpr error_category() noexcept;
+
+#include <system_error>
+#include <type_traits>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+class test1
+    : public std::error_category
+{
+public:
+    constexpr test1() = default;  // won't compile if error_category() is not constexpr
+    virtual const char* name() const noexcept {return nullptr;}
+    virtual std::string message(int ev) const {return std::string();}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_nothrow_default_constructible<test1>::value,
+                                 "error_category() must exist and be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp
new file mode 100644
index 0000000..bec5e63
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/eq.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator==(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::generic_category();
+    const std::error_category& e_cat3 = std::system_category();
+    assert(e_cat1 == e_cat2);
+    assert(!(e_cat1 == e_cat3));
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp
new file mode 100644
index 0000000..707604e
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/lt.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator<(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::generic_category();
+    const std::error_category& e_cat3 = std::system_category();
+    assert(!(e_cat1 < e_cat2) && !(e_cat2 < e_cat1));
+    assert((e_cat1 < e_cat3) || (e_cat3 < e_cat1));
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp
new file mode 100644
index 0000000..e74458f
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.nonvirtuals/neq.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// bool operator!=(const error_category& rhs) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    const std::error_category& e_cat2 = std::generic_category();
+    const std::error_category& e_cat3 = std::system_category();
+    assert(!(e_cat1 != e_cat2));
+    assert(e_cat1 != e_cat3);
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
new file mode 100644
index 0000000..9722999
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// const error_category& generic_category();
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::generic_category();
+    std::string m1 = e_cat1.name();
+    assert(m1 == "generic");
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
new file mode 100644
index 0000000..b5cb18a
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// const error_category& system_category();
+
+#include <system_error>
+#include <cassert>
+#include <string>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::system_category();
+    std::error_condition e_cond = e_cat1.default_error_condition(5);
+    assert(e_cond.value() == 5);
+    assert(e_cond.category() == std::generic_category());
+    e_cond = e_cat1.default_error_condition(5000);
+    assert(e_cond.value() == 5000);
+    assert(e_cond.category() == std::system_category());
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
new file mode 100644
index 0000000..2353058
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+#include <system_error>
+
+int main()
+{
+    std::error_category* p = 0;
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp
new file mode 100644
index 0000000..dd51827
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/default_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual error_condition default_error_condition(int ev) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::generic_category();
+    std::error_condition e_cond = e_cat.default_error_condition(static_cast<int>(std::errc::not_a_directory));
+    assert(e_cond.category() == e_cat);
+    assert(e_cond.value() == static_cast<int>(std::errc::not_a_directory));
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp
new file mode 100644
index 0000000..d26541d
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_error_code_int.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual bool equivalent(const error_code& code, int condition) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::generic_category();
+    assert(e_cat.equivalent(std::error_code(5, e_cat), 5));
+    assert(!e_cat.equivalent(std::error_code(5, e_cat), 6));
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp
new file mode 100644
index 0000000..d7cf844
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcat/syserr.errcat.virtuals/equivalent_int_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_category
+
+// virtual bool equivalent(int code, const error_condition& condition) const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::generic_category();
+    std::error_condition e_cond = e_cat.default_error_condition(5);
+    assert(e_cat.equivalent(5, e_cond));
+    assert(!e_cat.equivalent(6, e_cond));
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
new file mode 100644
index 0000000..0100b1c
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code(E e);
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+    zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+    return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+    {
+        std::error_code ec(two);
+        assert(ec.value() == 2);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp
new file mode 100644
index 0000000..569681b
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    std::error_code ec;
+    assert(ec.value() == 0);
+    assert(ec.category() == std::system_category());
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp
new file mode 100644
index 0000000..56489bb
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/int_error_category.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_code ec(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
new file mode 100644
index 0000000..6c073c9
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <ErrorCodeEnum E> error_code& operator=(E e);
+
+#include <system_error>
+#include <cassert>
+
+enum testing
+{
+    zero, one, two
+};
+
+namespace std
+{
+
+template <> struct is_error_code_enum<testing> : public std::true_type {};
+
+}
+
+std::error_code
+make_error_code(testing x)
+{
+    return std::error_code(static_cast<int>(x), std::generic_category());
+}
+
+int main()
+{
+    {
+        std::error_code ec;
+        ec = two;
+        assert(ec.value() == 2);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp
new file mode 100644
index 0000000..967692a
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void assign(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec;
+        ec.assign(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_code ec;
+        ec.assign(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..83faa03
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/clear.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// void clear();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec;
+        ec.assign(6, std::generic_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::generic_category());
+        ec.clear();
+        assert(ec.value() == 0);
+        assert(ec.category() == std::system_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp
new file mode 100644
index 0000000..01abc42
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/lt.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// bool operator<(const error_code& lhs, const error_code& rhs);
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_code ec1(6, std::generic_category());
+        const std::error_code ec2(7, std::generic_category());
+        assert(ec1 < ec2);
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp
new file mode 100644
index 0000000..fc4e0f2
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/make_error_code.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_code make_error_code(errc e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec = make_error_code(std::errc::operation_canceled);
+        assert(ec.value() == static_cast<int>(std::errc::operation_canceled));
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp
new file mode 100644
index 0000000..09c87e5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.nonmembers/stream_inserter.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// template <class charT, class traits>
+//   basic_ostream<charT,traits>&
+//   operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
+
+#include <system_error>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream out;
+    out << std::error_code(std::io_errc::stream);
+    assert(out.str() == "iostream:1");
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp
new file mode 100644
index 0000000..0b20024
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// explicit operator bool() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_code ec(6, std::generic_category());
+        assert(static_cast<bool>(ec));
+    }
+    {
+        const std::error_code ec(0, std::generic_category());
+        assert(!static_cast<bool>(ec));
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp
new file mode 100644
index 0000000..f2e50cf
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/category.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// const error_category& category() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_code ec(6, std::generic_category());
+    assert(ec.category() == std::generic_category());
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp
new file mode 100644
index 0000000..0a67cd5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/default_error_condition.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// error_condition default_error_condition() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_code ec(6, std::generic_category());
+        std::error_condition e_cond = ec.default_error_condition();
+        assert(e_cond == ec);
+    }
+    {
+        const std::error_code ec(6, std::system_category());
+        std::error_condition e_cond = ec.default_error_condition();
+        assert(e_cond == ec);
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp
new file mode 100644
index 0000000..530f42c
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/message.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// string message() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    const std::error_code ec(6, std::generic_category());
+    assert(ec.message() == std::generic_category().message(6));
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp
new file mode 100644
index 0000000..1047b7d
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/value.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_code
+
+// int value() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_code ec(6, std::system_category());
+    assert(ec.value() == 6);
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp
new file mode 100644
index 0000000..fbc03f1
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/ErrorConditionEnum.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// template <ErrorConditionEnum E> error_condition(E e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec(std::errc::not_a_directory);
+        assert(ec.value() == static_cast<int>(std::errc::not_a_directory));
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp
new file mode 100644
index 0000000..a430ee2
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    std::error_condition ec;
+    assert(ec.value() == 0);
+    assert(ec.category() == std::generic_category());
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp
new file mode 100644
index 0000000..f3b9ead
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/int_error_category.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_condition ec(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp
new file mode 100644
index 0000000..3773872
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/ErrorConditionEnum.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// template <ErrorConditionEnum E> error_condition& operator=(E e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec;
+        ec = std::errc::not_enough_memory;
+        assert(ec.value() == static_cast<int>(std::errc::not_enough_memory));
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp
new file mode 100644
index 0000000..8fcfcc3
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// void assign(int val, const error_category& cat);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec;
+        ec.assign(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+    }
+    {
+        std::error_condition ec;
+        ec.assign(8, std::generic_category());
+        assert(ec.value() == 8);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..509a8b9
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/clear.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// void clear();
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_condition ec;
+        ec.assign(6, std::system_category());
+        assert(ec.value() == 6);
+        assert(ec.category() == std::system_category());
+        ec.clear();
+        assert(ec.value() == 0);
+        assert(ec.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp
new file mode 100644
index 0000000..7ab0638
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/lt.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// bool operator<(const error_condition& lhs, const error_condition& rhs);
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec1(6, std::generic_category());
+        const std::error_condition ec2(7, std::generic_category());
+        assert(ec1 < ec2);
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp
new file mode 100644
index 0000000..acefc46
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.nonmembers/make_error_condition.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// error_condition make_error_condition(errc e);
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec1 = std::make_error_condition(std::errc::message_size);
+        assert(ec1.value() == static_cast<int>(std::errc::message_size));
+        assert(ec1.category() == std::generic_category());
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp
new file mode 100644
index 0000000..edeca06
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/bool.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// explicit operator bool() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec(6, std::generic_category());
+        assert(static_cast<bool>(ec));
+    }
+    {
+        const std::error_condition ec(0, std::generic_category());
+        assert(!static_cast<bool>(ec));
+    }
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp
new file mode 100644
index 0000000..fd3e698
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/category.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// const error_category& category() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_condition ec(6, std::generic_category());
+    assert(ec.category() == std::generic_category());
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp
new file mode 100644
index 0000000..6a60f50
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/message.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// string message() const;
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    const std::error_condition ec(6, std::generic_category());
+    assert(ec.message() == std::generic_category().message(6));
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp
new file mode 100644
index 0000000..c755673
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.observers/value.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class error_condition
+
+// int value() const;
+
+#include <system_error>
+#include <cassert>
+
+int main()
+{
+    const std::error_condition ec(6, std::system_category());
+    assert(ec.value() == 6);
+}
diff --git a/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/syserr.hash/error_code.pass.cpp b/final/test/diagnostics/syserr/syserr.hash/error_code.pass.cpp
new file mode 100644
index 0000000..14d7b2d
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.hash/error_code.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <system_error>
+#include <cassert>
+#include <type_traits>
+
+void
+test(int i)
+{
+    typedef std::error_code T;
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    H h;
+    T ec(i, std::system_category());
+    assert(h(ec) == i);
+}
+
+int main()
+{
+    test(0);
+    test(2);
+    test(10);
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp
new file mode 100644
index 0000000..c059ba3
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category(), "some text");
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp
new file mode 100644
index 0000000..cd8e3fe
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_const_char_pointer.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec, const char* what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(make_error_code(std::errc::not_a_directory), what_arg.c_str());
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp
new file mode 100644
index 0000000..b891a6d
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_error_code_string.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(error_code ec, const string& what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(make_error_code(std::errc::not_a_directory), what_arg);
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp
new file mode 100644
index 0000000..acf6387
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category());
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp
new file mode 100644
index 0000000..4f69701
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_const_char_pointer.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat, const char* what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category(), what_arg.c_str());
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp
new file mode 100644
index 0000000..87814b1
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.members/ctor_int_error_category_string.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+// class system_error
+
+// system_error(int ev, const error_category& ecat, const string& what_arg);
+
+// Test is slightly non-portable
+
+#include <system_error>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::string what_arg("test message");
+    std::system_error se(static_cast<int>(std::errc::not_a_directory),
+                         std::generic_category(), what_arg);
+    assert(se.code() == std::make_error_code(std::errc::not_a_directory));
+    std::string what_message(se.what());
+    assert(what_message.find(what_arg) != std::string::npos);
+    assert(what_message.find("Not a directory") != std::string::npos);
+}
diff --git a/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/diagnostics/syserr/syserr.syserr/syserr.syserr.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/diagnostics/syserr/version.pass.cpp b/final/test/diagnostics/syserr/version.pass.cpp
new file mode 100644
index 0000000..3851150
--- /dev/null
+++ b/final/test/diagnostics/syserr/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <system_error>
+
+#include <system_error>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/experimental/nothing_to_do.pass.cpp b/final/test/experimental/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..c21f8a7
--- /dev/null
+++ b/final/test/experimental/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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/string_view>
+
+int main () {}
diff --git a/final/test/experimental/string.view/nothing_to_do.pass.cpp b/final/test/experimental/string.view/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..c21f8a7
--- /dev/null
+++ b/final/test/experimental/string.view/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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/string_view>
+
+int main () {}
diff --git a/final/test/experimental/string.view/string.view.access/at.pass.cpp b/final/test/experimental/string.view/string.view.access/at.pass.cpp
new file mode 100644
index 0000000..90c4ac8
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.access/at.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT& at(size_type _pos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+void test ( const CharT *s, size_t len ) {
+    std::experimental::basic_string_view<CharT> sv ( s, len );
+    assert ( sv.length() == len );
+    for ( size_t i = 0; i < len; ++i ) {
+        assert (  sv.at(i) == s[i] );
+        assert ( &sv.at(i) == s + i );
+        }
+
+    try { sv.at(len); } catch ( const std::out_of_range & ) { return ; }
+    assert ( false );
+    }
+    
+int main () {
+    test ( "ABCDE", 5 );
+    test ( "a", 1 );
+
+    test ( L"ABCDE", 5 );
+    test ( L"a", 1 );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDE", 5 );
+    test ( u"a", 1 );
+
+    test ( U"ABCDE", 5 );
+    test ( U"a", 1 );
+#endif
+
+#if __cplusplus >= 201103L
+    {
+    constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+    static_assert ( sv.length() ==  2,  "" );
+    static_assert ( sv.at(0) == 'A', "" );
+    static_assert ( sv.at(1) == 'B', "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.access/back.pass.cpp b/final/test/experimental/string.view/string.view.access/back.pass.cpp
new file mode 100644
index 0000000..093a858
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.access/back.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT& front();
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+bool test ( const CharT *s, size_t len ) {
+    std::experimental::basic_string_view<CharT> sv ( s, len );
+    assert ( sv.length() == len );
+    assert ( sv.back() == s[len-1] );
+    return &sv.back() == s + len - 1;
+    }
+    
+int main () {
+    assert ( test ( "ABCDE", 5 ));
+    assert ( test ( "a", 1 ));
+
+    assert ( test ( L"ABCDE", 5 ));
+    assert ( test ( L"a", 1 ));
+
+#if __cplusplus >= 201103L
+    assert ( test ( u"ABCDE", 5 ));
+    assert ( test ( u"a", 1 ));
+
+    assert ( test ( U"ABCDE", 5 ));
+    assert ( test ( U"a", 1 ));
+#endif
+
+#if __cplusplus >= 201103L
+    {
+    constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+    static_assert ( sv.length() ==  2,  "" );
+    static_assert ( sv.back()  == 'B', "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.access/data.pass.cpp b/final/test/experimental/string.view/string.view.access/data.pass.cpp
new file mode 100644
index 0000000..562a765
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.access/data.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT* data() const noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+void test ( const CharT *s, size_t len ) {
+    std::experimental::basic_string_view<CharT> sv ( s, len );
+    assert ( sv.length() == len );
+    assert ( sv.data() == s );
+    }
+    
+int main () {
+    test ( "ABCDE", 5 );
+    test ( "a", 1 );
+
+    test ( L"ABCDE", 5 );
+    test ( L"a", 1 );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDE", 5 );
+    test ( u"a", 1 );
+
+    test ( U"ABCDE", 5 );
+    test ( U"a", 1 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr const char *s = "ABC";
+    constexpr std::experimental::basic_string_view<char> sv( s, 2 );
+    static_assert( sv.length() ==  2,  "" );
+    static_assert( sv.data() == s, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.access/front.pass.cpp b/final/test/experimental/string.view/string.view.access/front.pass.cpp
new file mode 100644
index 0000000..e9df44b
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.access/front.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT& back();
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+bool test ( const CharT *s, size_t len ) {
+    std::experimental::basic_string_view<CharT> sv ( s, len );
+    assert ( sv.length() == len );
+    assert ( sv.front() == s[0] );
+    return &sv.front() == s;
+    }
+    
+int main () {
+    assert ( test ( "ABCDE", 5 ));
+    assert ( test ( "a", 1 ));
+
+    assert ( test ( L"ABCDE", 5 ));
+    assert ( test ( L"a", 1 ));
+
+#if __cplusplus >= 201103L
+    assert ( test ( u"ABCDE", 5 ));
+    assert ( test ( u"a", 1 ));
+
+    assert ( test ( U"ABCDE", 5 ));
+    assert ( test ( U"a", 1 ));
+#endif
+
+#if __cplusplus >= 201103L
+    {
+    constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+    static_assert ( sv.length() ==  2,  "" );
+    static_assert ( sv.front()  == 'A', "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.access/index.pass.cpp b/final/test/experimental/string.view/string.view.access/index.pass.cpp
new file mode 100644
index 0000000..4491207
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.access/index.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr const _CharT& operator[](size_type _pos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <typename CharT>
+void test ( const CharT *s, size_t len ) {
+    std::experimental::basic_string_view<CharT> sv ( s, len );
+    assert ( sv.length() == len );
+    for ( size_t i = 0; i < len; ++i ) {
+        assert ( sv[i] == s[i] );
+        assert ( &sv[i] == s + i );
+        }
+    }
+    
+int main () {
+    test ( "ABCDE", 5 );
+    test ( "a", 1 );
+
+    test ( L"ABCDE", 5 );
+    test ( L"a", 1 );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDE", 5 );
+    test ( u"a", 1 );
+
+    test ( U"ABCDE", 5 );
+    test ( U"a", 1 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::experimental::basic_string_view<char> sv ( "ABC", 2 );
+    static_assert ( sv.length() ==  2,  "" );
+    static_assert ( sv[0]  == 'A', "" );
+    static_assert ( sv[1]  == 'B', "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.capacity/capacity.pass.cpp b/final/test/experimental/string.view/string.view.capacity/capacity.pass.cpp
new file mode 100644
index 0000000..eb80216
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.capacity/capacity.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// [string.view.capacity], capacity
+// constexpr size_type size()     const noexcept;
+// constexpr size_type length()   const noexcept;
+// constexpr size_type max_size() const noexcept;
+// constexpr bool empty()         const noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename SV>
+void test1 () {
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr SV sv1;
+    static_assert ( sv1.size() == 0, "" );
+    static_assert ( sv1.empty(), "");
+    static_assert ( sv1.size() == sv1.length(), "" );
+    static_assert ( sv1.max_size() > sv1.size(), "");
+    }
+#endif
+    
+    {
+    SV sv1;
+    assert ( sv1.size() == 0 );
+    assert ( sv1.empty());
+    assert ( sv1.size() == sv1.length());
+    assert ( sv1.max_size() > sv1.size());
+    }
+}
+
+template<typename CharT>
+void test2 ( const CharT *s, size_t len ) {
+    {
+    std::experimental::basic_string_view<CharT> sv1 ( s );
+    assert ( sv1.size() == len );
+    assert ( sv1.data() == s );
+    assert ( sv1.empty() == (len == 0));
+    assert ( sv1.size() == sv1.length());
+    assert ( sv1.max_size() > sv1.size());
+    }
+}
+
+int main () {
+    typedef std::experimental::string_view    string_view;
+    typedef std::experimental::u16string_view u16string_view;
+    typedef std::experimental::u32string_view u32string_view;
+    typedef std::experimental::wstring_view   wstring_view;
+
+    test1<string_view> ();
+    test1<u16string_view> ();
+    test1<u32string_view> ();
+    test1<wstring_view> ();
+
+    test2 ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+    test2 ( "ABCDE", 5 );
+    test2 ( "a", 1 );
+    test2 ( "", 0 );
+
+    test2 ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+    test2 ( L"ABCDE", 5 );
+    test2 ( L"a", 1 );
+    test2 ( L"", 0 );
+
+#if __cplusplus >= 201103L
+    test2 ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+    test2 ( u"ABCDE", 5 );
+    test2 ( u"a", 1 );
+    test2 ( u"", 0 );
+
+    test2 ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE", 105 );
+    test2 ( U"ABCDE", 5 );
+    test2 ( U"a", 1 );
+    test2 ( U"", 0 );
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp
new file mode 100644
index 0000000..148dc18
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opeq.string_view.pointer.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+//   constexpr bool operator==(basic_string_view<charT,traits> lhs, const charT* rhs);
+// template<class charT, class traits>
+//   constexpr bool operator==(const charT* lhs, basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+    assert((rhs == lhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), "", true);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+    static_assert (  sv1     == "", "" );
+    static_assert (  ""      == sv1, "" );
+    static_assert (!(sv1     == "abcde"), "" );
+    static_assert (!("abcde" == sv1), "" );
+    
+    static_assert (  sv2      == "abcde", "" );
+    static_assert (  "abcde"  == sv2, "" );
+    static_assert (!(sv2      == "abcde0"), "" );
+    static_assert (!("abcde0" == sv2), "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp
new file mode 100644
index 0000000..23a2aef
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opeq.string_view.string.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator==(const charT* lhs, const basic_string<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+//   bool operator==(const basic_string_view<charT,traits> lhs, const CharT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+template <class S>
+void
+test(const std::string &lhs, S rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+    assert((rhs == lhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test("", S(""), true);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+    }
+}
+#else
+int main () {}
+#endif
diff --git a/final/test/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp
new file mode 100644
index 0000000..5971f69
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opeq.string_view.string_view.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator==(const basic_string_view<charT,traits> lhs,
+//                   const basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, S rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+    assert((rhs == lhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2;
+    constexpr SV  sv3 { "abcde", 5 };
+    static_assert (  sv1 == sv2, "" );
+    static_assert (!(sv1 == sv3), "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp
new file mode 100644
index 0000000..f02459b
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opge.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator>=(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator>=(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs >= rhs) == x);
+    assert((rhs >= lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test("", S(""), true, true);
+    test("", S("abcde"), false, true);
+    test("", S("abcdefghij"), false, true);
+    test("", S("abcdefghijklmnopqrst"), false, true);
+    test("abcde", S(""), true, false);
+    test("abcde", S("abcde"), true, true);
+    test("abcde", S("abcdefghij"), false, true);
+    test("abcde", S("abcdefghijklmnopqrst"), false, true);
+    test("abcdefghij", S(""), true, false);
+    test("abcdefghij", S("abcde"), true, false);
+    test("abcdefghij", S("abcdefghij"), true, true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
+    test("abcdefghijklmnopqrst", S(""), true, false);
+    test("abcdefghijklmnopqrst", S("abcde"), true, false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (  sv1     >= "", "" );
+    static_assert (  ""      >= sv1, "" );
+    static_assert (!(sv1     >= "abcde"), "" );
+    static_assert (  "abcde" >= sv1, "" );
+    
+    static_assert (  sv2      >= "", "" );
+    static_assert (!(""       >= sv2), "" );
+    static_assert (  sv2      >= "abcde", "" );
+    static_assert (  "abcde"  >= sv2, "" );
+    static_assert (!(sv2      >= "abcde0"), "" );
+    static_assert (  "abcde0" >= sv2, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp
new file mode 100644
index 0000000..0790f80
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opge.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+//                   basic_string_view<charT,traits> rhs);
+//   bool operator>=(basic_string_view<charT,traits> lhs,
+//            const basic_string<charT,traits,Allocator>&  rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+    assert((lhs >= rhs) == x);
+    assert((rhs >= lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), "", true, true);
+    test(S(""), "abcde", false, true);
+    test(S(""), "abcdefghij", false, true);
+    test(S(""), "abcdefghijklmnopqrst", false, true);
+    test(S("abcde"), "", true, false);
+    test(S("abcde"), "abcde", true, true);
+    test(S("abcde"), "abcdefghij", false, true);
+    test(S("abcde"), "abcdefghijklmnopqrst", false, true);
+    test(S("abcdefghij"), "", true, false);
+    test(S("abcdefghij"), "abcde", true, false);
+    test(S("abcdefghij"), "abcdefghij", true, true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
+    test(S("abcdefghijklmnopqrst"), "", true, false);
+    test(S("abcdefghijklmnopqrst"), "abcde", true, false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp
new file mode 100644
index 0000000..e13a4ea
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opge.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+//   constexpr bool operator>=(basic_string_view<charT,traits> lhs,
+//                  basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs >= rhs) == x);
+    assert((rhs >= lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), S(""), true, true);
+    test(S(""), S("abcde"), false, true);
+    test(S(""), S("abcdefghij"), false, true);
+    test(S(""), S("abcdefghijklmnopqrst"), false, true);
+    test(S("abcde"), S(""), true, false);
+    test(S("abcde"), S("abcde"), true, true);
+    test(S("abcde"), S("abcdefghij"), false, true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
+    test(S("abcdefghij"), S(""), true, false);
+    test(S("abcdefghij"), S("abcde"), true, false);
+    test(S("abcdefghij"), S("abcdefghij"), true, true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
+    test(S("abcdefghijklmnopqrst"), S(""), true, false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (  sv1 >= sv1,  "" );
+    static_assert (  sv2 >= sv2,  "" );
+
+    static_assert (!(sv1 >= sv2), "" );
+    static_assert (  sv2 >= sv1,  "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp
new file mode 100644
index 0000000..48703ca
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opgt.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr template<class charT, class traits, class Allocator>
+//   bool operator>(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// constexpr template<class charT, class traits, class Allocator>
+//   bool operator>(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs > rhs) == x);
+    assert((rhs > lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test("", S(""), false, false);
+    test("", S("abcde"), false, true);
+    test("", S("abcdefghij"), false, true);
+    test("", S("abcdefghijklmnopqrst"), false, true);
+    test("abcde", S(""), true, false);
+    test("abcde", S("abcde"), false, false);
+    test("abcde", S("abcdefghij"), false, true);
+    test("abcde", S("abcdefghijklmnopqrst"), false, true);
+    test("abcdefghij", S(""), true, false);
+    test("abcdefghij", S("abcde"), true, false);
+    test("abcdefghij", S("abcdefghij"), false, false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false, true);
+    test("abcdefghijklmnopqrst", S(""), true, false);
+    test("abcdefghijklmnopqrst", S("abcde"), true, false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true, false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (!(sv1     > ""), "" );
+    static_assert (!(""      > sv1), "" );
+    static_assert (!(sv1     > "abcde"), "" );
+    static_assert (  "abcde" > sv1, "" );
+    
+    static_assert (  sv2      > "", "" );
+    static_assert (!(""       > sv2), "" );
+    static_assert (!(sv2      > "abcde"), "" );
+    static_assert (!("abcde"  > sv2), "" );
+    static_assert (!(sv2      > "abcde0"), "" );
+    static_assert (  "abcde0" > sv2, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp
new file mode 100644
index 0000000..92f812f
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opgt.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>(const basic_string<charT,traits,Allocator>& lhs,
+//                   basic_string_view<charT,traits> rhs);
+//   bool operator>(basic_string_view<charT,traits> lhs,
+//            const basic_string<charT,traits,Allocator>&  rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+    assert((lhs > rhs) == x);
+    assert((rhs > lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), "", false, false);
+    test(S(""), "abcde", false, true);
+    test(S(""), "abcdefghij", false, true);
+    test(S(""), "abcdefghijklmnopqrst", false, true);
+    test(S("abcde"), "", true, false);
+    test(S("abcde"), "abcde", false, false);
+    test(S("abcde"), "abcdefghij", false, true);
+    test(S("abcde"), "abcdefghijklmnopqrst", false, true);
+    test(S("abcdefghij"), "", true, false);
+    test(S("abcdefghij"), "abcde", true, false);
+    test(S("abcdefghij"), "abcdefghij", false, false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false, true);
+    test(S("abcdefghijklmnopqrst"), "", true, false);
+    test(S("abcdefghijklmnopqrst"), "abcde", true, false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true, false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp
new file mode 100644
index 0000000..3047cc7
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opgt.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+//  constexpr bool operator>(basic_string_view<charT,traits> lhs,
+//                  basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs > rhs) == x);
+    assert((rhs > lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), S(""), false, false);
+    test(S(""), S("abcde"), false, true);
+    test(S(""), S("abcdefghij"), false, true);
+    test(S(""), S("abcdefghijklmnopqrst"), false, true);
+    test(S("abcde"), S(""), true, false);
+    test(S("abcde"), S("abcde"), false, false);
+    test(S("abcde"), S("abcdefghij"), false, true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false, true);
+    test(S("abcdefghij"), S(""), true, false);
+    test(S("abcdefghij"), S("abcde"), true, false);
+    test(S("abcdefghij"), S("abcdefghij"), false, false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false, true);
+    test(S("abcdefghijklmnopqrst"), S(""), true, false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true, false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true, false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (!(sv1 > sv1), "" );
+    static_assert (!(sv2 > sv2), "" );
+
+    static_assert (!(sv1 > sv2), "" );
+    static_assert (  sv2 > sv1, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp b/final/test/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp
new file mode 100644
index 0000000..539f5fa
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/ople.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator<=(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator<=(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs <= rhs) == x);
+    assert((rhs <= lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test("", S(""), true, true);
+    test("", S("abcde"), true, false);
+    test("", S("abcdefghij"), true, false);
+    test("", S("abcdefghijklmnopqrst"), true, false);
+    test("abcde", S(""), false, true);
+    test("abcde", S("abcde"), true, true);
+    test("abcde", S("abcdefghij"), true, false);
+    test("abcde", S("abcdefghijklmnopqrst"), true, false);
+    test("abcdefghij", S(""), false, true);
+    test("abcdefghij", S("abcde"), false, true);
+    test("abcdefghij", S("abcdefghij"), true, true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
+    test("abcdefghijklmnopqrst", S(""), false, true);
+    test("abcdefghijklmnopqrst", S("abcde"), false, true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true, true);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (  sv1     <= "", "" );
+    static_assert (  ""      <= sv1, "" );
+    static_assert (  sv1     <= "abcde", "" );
+    static_assert (!("abcde" <= sv1), "" );
+    
+    static_assert (!(sv2      <= ""), "" );
+    static_assert (  ""       <= sv2, "" );
+    static_assert (  sv2      <= "abcde", "" );
+    static_assert (  "abcde"  <= sv2, "" );
+    static_assert (  sv2      <= "abcde0", "" );
+    static_assert (!("abcde0" <= sv2), "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp b/final/test/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp
new file mode 100644
index 0000000..39abbd0
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/ople.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+//                   basic_string_view<charT,traits> rhs);
+//   bool operator<=(basic_string_view<charT,traits> lhs,
+//            const basic_string<charT,traits,Allocator>&  rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+    assert((lhs <= rhs) == x);
+    assert((rhs <= lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), "", true, true);
+    test(S(""), "abcde", true, false);
+    test(S(""), "abcdefghij", true, false);
+    test(S(""), "abcdefghijklmnopqrst", true, false);
+    test(S("abcde"), "", false, true);
+    test(S("abcde"), "abcde", true, true);
+    test(S("abcde"), "abcdefghij", true, false);
+    test(S("abcde"), "abcdefghijklmnopqrst", true, false);
+    test(S("abcdefghij"), "", false, true);
+    test(S("abcdefghij"), "abcde", false, true);
+    test(S("abcdefghij"), "abcdefghij", true, true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
+    test(S("abcdefghijklmnopqrst"), "", false, true);
+    test(S("abcdefghijklmnopqrst"), "abcde", false, true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true, true);
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp b/final/test/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp
new file mode 100644
index 0000000..17219a4
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/ople.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+//   constexpr bool operator<=(basic_string_view<charT,traits> lhs,
+//                  basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs <= rhs) == x);
+    assert((rhs <= lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), S(""), true, true);
+    test(S(""), S("abcde"), true, false);
+    test(S(""), S("abcdefghij"), true, false);
+    test(S(""), S("abcdefghijklmnopqrst"), true, false);
+    test(S("abcde"), S(""), false, true);
+    test(S("abcde"), S("abcde"), true, true);
+    test(S("abcde"), S("abcdefghij"), true, false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
+    test(S("abcdefghij"), S(""), false, true);
+    test(S("abcdefghij"), S("abcde"), false, true);
+    test(S("abcdefghij"), S("abcdefghij"), true, true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
+    test(S("abcdefghijklmnopqrst"), S(""), false, true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true, true);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (  sv1 <= sv1,  "" );
+    static_assert (  sv2 <= sv2,  "" );
+
+    static_assert (  sv1 <= sv2,  "" );
+    static_assert (!(sv2 <= sv1), "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp b/final/test/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp
new file mode 100644
index 0000000..a1013e4
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/oplt.string_view.pointer.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator<(const charT* lhs, basic_string_wiew<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator<(basic_string_wiew<charT,traits> lhs, const charT* rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs < rhs) == x);
+    assert((rhs < lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test("", S(""), false, false);
+    test("", S("abcde"), true, false);
+    test("", S("abcdefghij"), true, false);
+    test("", S("abcdefghijklmnopqrst"), true, false);
+    test("abcde", S(""), false, true);
+    test("abcde", S("abcde"), false, false);
+    test("abcde", S("abcdefghij"), true, false);
+    test("abcde", S("abcdefghijklmnopqrst"), true, false);
+    test("abcdefghij", S(""), false, true);
+    test("abcdefghij", S("abcde"), false, true);
+    test("abcdefghij", S("abcdefghij"), false, false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true, false);
+    test("abcdefghijklmnopqrst", S(""), false, true);
+    test("abcdefghijklmnopqrst", S("abcde"), false, true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false, true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false, false);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (!(sv1     < ""), "" );
+    static_assert (!(""      < sv1), "" );
+    static_assert (  sv1     < "abcde", "" );
+    static_assert (!("abcde" < sv1), "" );
+    
+    static_assert (!(sv2      < ""), "" );
+    static_assert (  ""       < sv2, "" );
+    static_assert (!(sv2      < "abcde"), "" );
+    static_assert (!("abcde"  < sv2), "" );
+    static_assert (  sv2      < "abcde0", "" );
+    static_assert (!("abcde0" < sv2), "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp b/final/test/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp
new file mode 100644
index 0000000..51ea639
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/oplt.string_view.string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<(const basic_string<charT,traits,Allocator>& lhs,
+//                   basic_string_view<charT,traits> rhs);
+//   bool operator<(basic_string_view<charT,traits> lhs,
+//            const basic_string<charT,traits,Allocator>&  rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x, bool y)
+{
+    assert((lhs < rhs) == x);
+    assert((rhs < lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), "", false, false);
+    test(S(""), "abcde", true, false);
+    test(S(""), "abcdefghij", true, false);
+    test(S(""), "abcdefghijklmnopqrst", true, false);
+    test(S("abcde"), "", false, true);
+    test(S("abcde"), "abcde", false, false);
+    test(S("abcde"), "abcdefghij", true, false);
+    test(S("abcde"), "abcdefghijklmnopqrst", true, false);
+    test(S("abcdefghij"), "", false, true);
+    test(S("abcdefghij"), "abcde", false, true);
+    test(S("abcdefghij"), "abcdefghij", false, false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true, false);
+    test(S("abcdefghijklmnopqrst"), "", false, true);
+    test(S("abcdefghijklmnopqrst"), "abcde", false, true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false, true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false, false);
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp b/final/test/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp
new file mode 100644
index 0000000..df9e908
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/oplt.string_view.string_view.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+//   constexpr bool operator<(basic_string_view<charT,traits> lhs,
+//                  basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x, bool y)
+{
+    assert((lhs < rhs) == x);
+    assert((rhs < lhs) == y);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), S(""), false, false);
+    test(S(""), S("abcde"), true, false);
+    test(S(""), S("abcdefghij"), true, false);
+    test(S(""), S("abcdefghijklmnopqrst"), true, false);
+    test(S("abcde"), S(""), false, true);
+    test(S("abcde"), S("abcde"), false, false);
+    test(S("abcde"), S("abcdefghij"), true, false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true, false);
+    test(S("abcdefghij"), S(""), false, true);
+    test(S("abcdefghij"), S("abcde"), false, true);
+    test(S("abcdefghij"), S("abcdefghij"), false, false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true, false);
+    test(S("abcdefghijklmnopqrst"), S(""), false, true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false, true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false, true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false, false);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (!(sv1 < sv1), "" );
+    static_assert (!(sv2 < sv2), "" );
+
+    static_assert (  sv1 < sv2,  "" );
+    static_assert (!(sv2 < sv1), "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp
new file mode 100644
index 0000000..299be93
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opne.string_view.pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits>
+//   constexpr bool operator!=(basic_string_view<charT,traits> lhs, const charT* rhs);
+// template<class charT, class traits>
+//   constexpr bool operator!=(const charT* lhs, basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+    assert((rhs != lhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), "", false);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (!(sv1     != ""), "" );
+    static_assert (!(""      != sv1), "" );
+    static_assert (  sv1     != "abcde", "" );
+    static_assert (  "abcde" != sv1, "" );
+    
+    static_assert (!(sv2      != "abcde"), "" );
+    static_assert (!("abcde"  != sv2), "" );
+    static_assert (  sv2      != "abcde0",   "" );
+    static_assert (  "abcde0" != sv2, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp
new file mode 100644
index 0000000..9ed0ac1
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opne.string_view.string.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator!=(const basic_string<charT, traits, Allocator> &lhs, basic_string_view<charT,traits> rhs);
+// template<class charT, class traits, class Allocator>
+//   bool operator!=(basic_string_view<charT,traits> lhs, const basic_string<charT, traits, Allocator> &rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const std::string &lhs, S rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+    assert((rhs != lhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test("", S(""), false);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp b/final/test/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp
new file mode 100644
index 0000000..c99489e
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.comparison/opne.string_view.string_view.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// template<class charT, class traits, class Allocator>
+//   constexpr bool operator!=(const basic_string_view<charT,traits> lhs,
+//                   const basic_string_view<charT,traits> rhs);
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(S lhs, S rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+    assert((rhs != lhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2;
+    constexpr SV  sv3 { "abcde", 5 };
+    static_assert (!( sv1 != sv2), "" );
+    static_assert (   sv1 != sv3,  "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.cons/default.pass.cpp b/final/test/experimental/string.view/string.view.cons/default.pass.cpp
new file mode 100644
index 0000000..e1d69f4
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr basic_string_view () noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename T>
+void test () {
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr T sv1;
+    static_assert ( sv1.size() == 0, "" );
+    static_assert ( sv1.empty(), "");
+    }
+#endif
+    
+    {
+    T sv1;
+    assert ( sv1.size() == 0 );
+    assert ( sv1.empty());
+    }
+}
+
+int main () {
+    typedef std::experimental::string_view    string_view;
+    typedef std::experimental::u16string_view u16string_view;
+    typedef std::experimental::u32string_view u32string_view;
+    typedef std::experimental::wstring_view   wstring_view;
+
+    test<string_view> ();
+    test<u16string_view> ();
+    test<u32string_view> ();
+    test<wstring_view> ();
+
+}
diff --git a/final/test/experimental/string.view/string.view.cons/from_literal.pass.cpp b/final/test/experimental/string.view/string.view.cons/from_literal.pass.cpp
new file mode 100644
index 0000000..82d0d79
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.cons/from_literal.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr basic_string_view(const _CharT* _s)
+//    : __data (_s), __size(_Traits::length(_s)) {}
+
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template<typename CharT>
+size_t StrLen ( const CharT *s ) {
+    size_t retVal = 0;
+    while ( *s != 0 ) { ++retVal; ++s; }
+    return retVal;
+    }
+
+template<typename CharT>
+void test ( const CharT *s ) {
+    std::experimental::basic_string_view<CharT> sv1 ( s );
+    assert ( sv1.size() == StrLen( s ));
+    assert ( sv1.data() == s );
+    }
+
+
+int main () {
+
+    test ( "QBCDE" );
+    test ( "A" );
+    test ( "" );
+    
+    test ( L"QBCDE" );
+    test ( L"A" );
+    test ( L"" );
+
+#if __cplusplus >= 201103L
+    test ( u"QBCDE" );
+    test ( u"A" );
+    test ( u"" );
+
+    test ( U"QBCDE" );
+    test ( U"A" );
+    test ( U"" );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::experimental::basic_string_view<char, constexpr_char_traits<char>> sv1 ( "ABCDE" );
+    static_assert ( sv1.size() == 5, "");
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp b/final/test/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp
new file mode 100644
index 0000000..1038d04
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.cons/from_ptr_len.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+//  constexpr basic_string_view(const _CharT* _s, size_type _len)
+//      : __data (_s), __size(_len) {}
+
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t sz ) {
+    {
+    std::experimental::basic_string_view<CharT> sv1 ( s, sz );
+    assert ( sv1.size() == sz );
+    assert ( sv1.data() == s );
+    }
+}
+
+int main () {
+
+    test ( "QBCDE", 5 );
+    test ( "QBCDE", 2 );
+    test ( "", 0 );
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr const char *s = "QBCDE";
+    constexpr std::experimental::basic_string_view<char> sv1 ( s, 2 );
+    static_assert ( sv1.size() == 2, "" );
+    static_assert ( sv1.data() == s, "" );
+    }
+#endif
+
+    test ( L"QBCDE", 5 );
+    test ( L"QBCDE", 2 );
+    test ( L"", 0 );
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr const wchar_t *s = L"QBCDE";
+    constexpr std::experimental::basic_string_view<wchar_t> sv1 ( s, 2 );
+    static_assert ( sv1.size() == 2, "" );
+    static_assert ( sv1.data() == s, "" );
+    }
+#endif
+
+#if __cplusplus >= 201103L
+    test ( u"QBCDE", 5 );
+    test ( u"QBCDE", 2 );
+    test ( u"", 0 );
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr const char16_t *s = u"QBCDE";
+    constexpr std::experimental::basic_string_view<char16_t> sv1 ( s, 2 );
+    static_assert ( sv1.size() == 2, "" );
+    static_assert ( sv1.data() == s, "" );
+    }
+#endif
+
+    test ( U"QBCDE", 5 );
+    test ( U"QBCDE", 2 );
+    test ( U"", 0 );
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr const char32_t *s = U"QBCDE";
+    constexpr std::experimental::basic_string_view<char32_t> sv1 ( s, 2 );
+    static_assert ( sv1.size() == 2, "" );
+    static_assert ( sv1.data() == s, "" );
+    }
+#endif
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.cons/from_string.pass.cpp b/final/test/experimental/string.view/string.view.cons/from_string.pass.cpp
new file mode 100644
index 0000000..670c033
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.cons/from_string.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class Allocator>
+// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
+
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+struct dummy_char_traits : public std::char_traits<char> {};
+
+template<typename CharT, typename Traits>
+void test ( const std::basic_string<CharT, Traits> &str ) {
+    std::experimental::basic_string_view<CharT, Traits> sv1 ( str );
+    assert ( sv1.size() == str.size());
+    assert ( sv1.data() == str.data());
+}
+
+int main () {
+
+    test ( std::string("QBCDE") );
+    test ( std::string("") );
+    test ( std::string() );
+    
+    test ( std::wstring(L"QBCDE") );
+    test ( std::wstring(L"") );
+    test ( std::wstring() );
+
+#if __cplusplus >= 201103L
+    test ( std::u16string{u"QBCDE"} );
+    test ( std::u16string{u""} );
+    test ( std::u16string{} );
+
+    test ( std::u32string{U"QBCDE"} );
+    test ( std::u32string{U""} );
+    test ( std::u32string{} );
+#endif
+    
+    test ( std::basic_string<char, dummy_char_traits>("QBCDE") );
+    test ( std::basic_string<char, dummy_char_traits>("") );
+    test ( std::basic_string<char, dummy_char_traits>() );
+
+}
diff --git a/final/test/experimental/string.view/string.view.cons/from_string1.fail.cpp b/final/test/experimental/string.view/string.view.cons/from_string1.fail.cpp
new file mode 100644
index 0000000..6ef4b96
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.cons/from_string1.fail.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class Allocator>
+// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+struct dummy_char_traits : public std::char_traits<char> {};
+
+int main () {
+    using string_view = std::experimental::basic_string_view<char>;
+    using string      = std::              basic_string     <char, dummy_char_traits>;
+    
+    {
+    string s{"QBCDE"};
+    string_view sv1 ( s );
+    assert ( sv1.size() == s.size());
+    assert ( sv1.data() == s.data());
+    }
+}
\ No newline at end of file
diff --git a/final/test/experimental/string.view/string.view.cons/from_string2.fail.cpp b/final/test/experimental/string.view/string.view.cons/from_string2.fail.cpp
new file mode 100644
index 0000000..6c77a3f
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.cons/from_string2.fail.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class Allocator>
+// basic_string_view(const basic_string<_CharT, _Traits, Allocator>& _str) noexcept
+
+#include <experimental/string_view>
+#include <string>
+#include <cassert>
+
+struct dummy_char_traits : public std::char_traits<char> {};
+
+int main () {
+    using string_view = std::experimental::basic_string_view<char, dummy_char_traits>;
+    using string      = std::              basic_string     <char>;
+    
+    {
+    string s{"QBCDE"};
+    string_view sv1 ( s );
+    assert ( sv1.size() == s.size());
+    assert ( sv1.data() == s.data());
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_char_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_char_size.pass.cpp
new file mode 100644
index 0000000..6e6a1f5
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_char_size.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find(charT c, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find(c) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + 1 <= s.size());
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), 'c', 0, S::npos);
+    test(S(""), 'c', 1, S::npos);
+    test(S("abcde"), 'c', 0, 2);
+    test(S("abcde"), 'c', 1, 2);
+    test(S("abcde"), 'c', 2, 2);
+    test(S("abcde"), 'c', 4, S::npos);
+    test(S("abcde"), 'c', 5, S::npos);
+    test(S("abcde"), 'c', 6, S::npos);
+    test(S("abcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcde"), 'c', 5, 7);
+    test(S("abcdeabcde"), 'c', 9, S::npos);
+    test(S("abcdeabcde"), 'c', 10, S::npos);
+    test(S("abcdeabcde"), 'c', 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+
+    test(S(""), 'c', S::npos);
+    test(S("abcde"), 'c', 2);
+    test(S("abcdeabcde"), 'c', 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find( 'c', 0 ) == SV::npos, "" );
+    static_assert (sv1.find( 'c', 1 ) == SV::npos, "" );
+    static_assert (sv2.find( 'c', 0 ) == 2, "" );
+    static_assert (sv2.find( 'c', 1 ) == 2, "" );
+    static_assert (sv2.find( 'c', 2 ) == 2, "" );
+    static_assert (sv2.find( 'c', 3 ) == SV::npos, "" );
+    static_assert (sv2.find( 'c', 4 ) == SV::npos, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp
new file mode 100644
index 0000000..73580ae
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_not_of_char_size.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_first_not_of(charT c, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_not_of(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_first_not_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), 'q', 0, S::npos);
+    test(S(""), 'q', 1, S::npos);
+    test(S("kitcj"), 'q', 0, 0);
+    test(S("qkamf"), 'q', 1, 1);
+    test(S("nhmko"), 'q', 2, 2);
+    test(S("tpsaf"), 'q', 4, 4);
+    test(S("lahfb"), 'q', 5, S::npos);
+    test(S("irkhs"), 'q', 6, S::npos);
+    test(S("gmfhdaipsr"), 'q', 0, 0);
+    test(S("kantesmpgj"), 'q', 1, 1);
+    test(S("odaftiegpm"), 'q', 5, 5);
+    test(S("oknlrstdpi"), 'q', 9, 9);
+    test(S("eolhfgpjqk"), 'q', 10, S::npos);
+    test(S("pcdrofikas"), 'q', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+    test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+
+    test(S(""), 'q', S::npos);
+    test(S("q"), 'q', S::npos);
+    test(S("qqq"), 'q', S::npos);
+    test(S("csope"), 'q', 0);
+    test(S("gfsmthlkon"), 'q', 0);
+    test(S("laenfsbridchgotmkqpj"), 'q', 0);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_first_not_of( 'q', 0 ) == SV::npos, "" );
+    static_assert (sv1.find_first_not_of( 'q', 1 ) == SV::npos, "" );
+    static_assert (sv2.find_first_not_of( 'q', 0 ) == 0, "" );
+    static_assert (sv2.find_first_not_of( 'q', 1 ) == 1, "" );
+    static_assert (sv2.find_first_not_of( 'q', 5 ) == SV::npos, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp
new file mode 100644
index 0000000..de93288
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_not_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, 0);
+    test(S("qanej"), "dfkap", 0, 0);
+    test(S("clbao"), "ihqrfebgad", 0, 0);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+    test(S("srdfq"), "", 1, 1);
+    test(S("oemth"), "ikcrq", 1, 1);
+    test(S("cdaih"), "dmajblfhsg", 1, 3);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+    test(S("cshmd"), "", 2, 2);
+    test(S("lhcdo"), "oebqi", 2, 2);
+    test(S("qnsoh"), "kojhpmbsfe", 2, S::npos);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+    test(S("fmtsp"), "", 4, 4);
+    test(S("khbpm"), "aobjd", 4, 4);
+    test(S("pbsji"), "pcbahntsje", 4, 4);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, S::npos);
+    test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, S::npos);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, 0);
+    test(S("daiprenocl"), "ashjd", 0, 2);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 1);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+    test(S("qpghtfbaji"), "", 1, 1);
+    test(S("gfshlcmdjr"), "nadkh", 1, 1);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 4);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+    test(S("crnklpmegd"), "", 5, 5);
+    test(S("jsbtafedoc"), "prqgn", 5, 5);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 6);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+    test(S("lmofqdhpki"), "", 9, 9);
+    test(S("hnefkqimca"), "rtjpa", 9, S::npos);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, S::npos);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 1);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 3);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 11);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 13);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, S::npos);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", 0);
+    test(S("lahfb"), "irkhs", 0);
+    test(S("gmfhd"), "kantesmpgj", 2);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+    test(S("eolhfgpjqk"), "", 0);
+    test(S("nbatdlmekr"), "bnrpe", 2);
+    test(S("jdmciepkaq"), "jtdaefblso", 2);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), "", 0);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 0);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 1);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_first_not_of( "",      0) == SV::npos, "" );
+    static_assert (sv1.find_first_not_of( "irkhs", 0) == SV::npos, "" );
+    static_assert (sv2.find_first_not_of( "",      0) == 0, "" );
+    static_assert (sv2.find_first_not_of( "gfsrt", 0) == 0, "" );
+    static_assert (sv2.find_first_not_of( "lecar", 0) == 1, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp
new file mode 100644
index 0000000..cfb0029
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_not_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, 0);
+    test(S("binja"), "gfsrt", 0, 0, 0);
+    test(S("latkm"), "pfsoc", 0, 1, 0);
+    test(S("lecfr"), "tpflm", 0, 2, 0);
+    test(S("eqkst"), "sgkec", 0, 4, 1);
+    test(S("cdafr"), "romds", 0, 5, 0);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+    test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 1);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+    test(S("clrgb"), "", 1, 0, 1);
+    test(S("tjmek"), "osmia", 1, 0, 1);
+    test(S("bgstp"), "ckonl", 1, 1, 1);
+    test(S("hstrk"), "ilcaj", 1, 2, 1);
+    test(S("kmspj"), "lasiq", 1, 4, 1);
+    test(S("tjboh"), "kfqmr", 1, 5, 1);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 3);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+    test(S("ndrhl"), "", 2, 0, 2);
+    test(S("mrecp"), "otkgb", 2, 0, 2);
+    test(S("qlasf"), "cqsjl", 2, 1, 2);
+    test(S("smaqd"), "dpifl", 2, 2, 2);
+    test(S("hjeni"), "oapht", 2, 4, 2);
+    test(S("ocmfj"), "cifts", 2, 5, 2);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+    test(S("fklad"), "tpksqhamle", 2, 1, 2);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 3);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 3);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+    test(S("cjgao"), "", 4, 0, 4);
+    test(S("kjplq"), "mabns", 4, 0, 4);
+    test(S("herni"), "bdnrp", 4, 1, 4);
+    test(S("tadrb"), "scidp", 4, 2, 4);
+    test(S("pkfeo"), "agbjl", 4, 4, 4);
+    test(S("hoser"), "jfmpr", 4, 5, S::npos);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, S::npos);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, S::npos);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, S::npos);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, S::npos);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, S::npos);
+    test(S("ktdor"), "kipnf", 5, 5, S::npos);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+    test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, S::npos);
+    test(S("bhlki"), "heatr", 6, 5, S::npos);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+    test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, 0);
+    test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 2);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 4);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 1);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+    test(S("shbcqnmoar"), "", 1, 0, 1);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 2);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 4);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 3);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 5);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 5);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 5);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+    test(S("ectnhskflp"), "", 5, 0, 5);
+    test(S("fgtianblpq"), "pijag", 5, 0, 5);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+    test(S("astedncjhk"), "qcloh", 5, 2, 5);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 6);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 6);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 6);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 8);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+    test(S("shoiedtcjb"), "", 9, 0, 9);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+    test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, S::npos);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, S::npos);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, S::npos);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+    test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+    test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 11);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 2);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 2);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 3);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 2);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 2);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 13);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 11);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 11);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 11);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 11);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, S::npos);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, S::npos);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, S::npos);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_first_not_of( "",      0, 0) == SV::npos, "" );
+    static_assert (sv1.find_first_not_of( "irkhs", 0, 5) == SV::npos, "" );
+    static_assert (sv2.find_first_not_of( "",      0, 0) == 0, "" );
+    static_assert (sv2.find_first_not_of( "gfsrt", 0, 5) == 0, "" );
+    static_assert (sv2.find_first_not_of( "lecar", 0, 5) == 1, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp
new file mode 100644
index 0000000..7002312
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_not_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, 0);
+    test(S("qanej"), S("dfkap"), 0, 0);
+    test(S("clbao"), S("ihqrfebgad"), 0, 0);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+    test(S("srdfq"), S(""), 1, 1);
+    test(S("oemth"), S("ikcrq"), 1, 1);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 3);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+    test(S("cshmd"), S(""), 2, 2);
+    test(S("lhcdo"), S("oebqi"), 2, 2);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, S::npos);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+    test(S("fmtsp"), S(""), 4, 4);
+    test(S("khbpm"), S("aobjd"), 4, 4);
+    test(S("pbsji"), S("pcbahntsje"), 4, 4);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, S::npos);
+    test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, S::npos);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, 0);
+    test(S("daiprenocl"), S("ashjd"), 0, 2);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 1);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+    test(S("qpghtfbaji"), S(""), 1, 1);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 4);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+    test(S("crnklpmegd"), S(""), 5, 5);
+    test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 6);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+    test(S("lmofqdhpki"), S(""), 9, 9);
+    test(S("hnefkqimca"), S("rtjpa"), 9, S::npos);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 1);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 3);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 11);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 13);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, S::npos);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), 0);
+    test(S("lahfb"), S("irkhs"), 0);
+    test(S("gmfhd"), S("kantesmpgj"), 2);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+    test(S("eolhfgpjqk"), S(""), 0);
+    test(S("nbatdlmekr"), S("bnrpe"), 2);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 2);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), 0);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 0);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 1);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp
new file mode 100644
index 0000000..dde2f2c
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_of_char_size.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_first_of(charT c, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_of(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_first_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), 'e', 0, S::npos);
+    test(S(""), 'e', 1, S::npos);
+    test(S("kitcj"), 'e', 0, S::npos);
+    test(S("qkamf"), 'e', 1, S::npos);
+    test(S("nhmko"), 'e', 2, S::npos);
+    test(S("tpsaf"), 'e', 4, S::npos);
+    test(S("lahfb"), 'e', 5, S::npos);
+    test(S("irkhs"), 'e', 6, S::npos);
+    test(S("gmfhdaipsr"), 'e', 0, S::npos);
+    test(S("kantesmpgj"), 'e', 1, 4);
+    test(S("odaftiegpm"), 'e', 5, 6);
+    test(S("oknlrstdpi"), 'e', 9, S::npos);
+    test(S("eolhfgpjqk"), 'e', 10, S::npos);
+    test(S("pcdrofikas"), 'e', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+    test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+    test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+    test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+    test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+
+    test(S(""), 'e', S::npos);
+    test(S("csope"), 'e', 4);
+    test(S("gfsmthlkon"), 'e', S::npos);
+    test(S("laenfsbridchgotmkqpj"), 'e', 2);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_first_of( 'e', 0 ) == SV::npos, "" );
+    static_assert (sv1.find_first_of( 'e', 1 ) == SV::npos, "" );
+    static_assert (sv2.find_first_of( 'q', 0 ) == SV::npos, "" );
+    static_assert (sv2.find_first_of( 'e', 1 ) == 4, "" );
+    static_assert (sv2.find_first_of( 'e', 5 ) == SV::npos, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp
new file mode 100644
index 0000000..e49e82c
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_first_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, S::npos);
+    test(S("qanej"), "dfkap", 0, 1);
+    test(S("clbao"), "ihqrfebgad", 0, 2);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+    test(S("srdfq"), "", 1, S::npos);
+    test(S("oemth"), "ikcrq", 1, S::npos);
+    test(S("cdaih"), "dmajblfhsg", 1, 1);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+    test(S("cshmd"), "", 2, S::npos);
+    test(S("lhcdo"), "oebqi", 2, 4);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+    test(S("fmtsp"), "", 4, S::npos);
+    test(S("khbpm"), "aobjd", 4, S::npos);
+    test(S("pbsji"), "pcbahntsje", 4, S::npos);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, S::npos);
+    test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, S::npos);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, S::npos);
+    test(S("daiprenocl"), "ashjd", 0, 0);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+    test(S("qpghtfbaji"), "", 1, S::npos);
+    test(S("gfshlcmdjr"), "nadkh", 1, 3);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+    test(S("crnklpmegd"), "", 5, S::npos);
+    test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+    test(S("lmofqdhpki"), "", 9, S::npos);
+    test(S("hnefkqimca"), "rtjpa", 9, 9);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, S::npos);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+    test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", S::npos);
+    test(S("lahfb"), "irkhs", 2);
+    test(S("gmfhd"), "kantesmpgj", 0);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0);
+    test(S("eolhfgpjqk"), "", S::npos);
+    test(S("nbatdlmekr"), "bnrpe", 0);
+    test(S("jdmciepkaq"), "jtdaefblso", 0);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0);
+    test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 1);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_first_of( "",      0) == SV::npos, "" );
+    static_assert (sv1.find_first_of( "irkhs", 0) == SV::npos, "" );
+    static_assert (sv2.find_first_of( "",      0) == SV::npos, "" );
+    static_assert (sv2.find_first_of( "gfsrt", 0) == SV::npos, "" );
+    static_assert (sv2.find_first_of( "lecar", 0) == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp
new file mode 100644
index 0000000..1dc8d85
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, S::npos);
+    test(S("binja"), "gfsrt", 0, 0, S::npos);
+    test(S("latkm"), "pfsoc", 0, 1, S::npos);
+    test(S("lecfr"), "tpflm", 0, 2, S::npos);
+    test(S("eqkst"), "sgkec", 0, 4, 0);
+    test(S("cdafr"), "romds", 0, 5, 1);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+    test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 1);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+    test(S("clrgb"), "", 1, 0, S::npos);
+    test(S("tjmek"), "osmia", 1, 0, S::npos);
+    test(S("bgstp"), "ckonl", 1, 1, S::npos);
+    test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+    test(S("kmspj"), "lasiq", 1, 4, 2);
+    test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 3);
+    test(S("gfcql"), "skbgtahqej", 1, 5, S::npos);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 2);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 4);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+    test(S("ndrhl"), "", 2, 0, S::npos);
+    test(S("mrecp"), "otkgb", 2, 0, S::npos);
+    test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+    test(S("smaqd"), "dpifl", 2, 2, 4);
+    test(S("hjeni"), "oapht", 2, 4, S::npos);
+    test(S("ocmfj"), "cifts", 2, 5, 3);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+    test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 3);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 3);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+    test(S("cjgao"), "", 4, 0, S::npos);
+    test(S("kjplq"), "mabns", 4, 0, S::npos);
+    test(S("herni"), "bdnrp", 4, 1, S::npos);
+    test(S("tadrb"), "scidp", 4, 2, S::npos);
+    test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+    test(S("hoser"), "jfmpr", 4, 5, 4);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, S::npos);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, S::npos);
+    test(S("ktdor"), "kipnf", 5, 5, S::npos);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+    test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, S::npos);
+    test(S("bhlki"), "heatr", 6, 5, S::npos);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+    test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+    test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 8);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 8);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 1);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 3);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 5);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 1);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 4);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+    test(S("shbcqnmoar"), "", 1, 0, S::npos);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 4);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 4);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+    test(S("ectnhskflp"), "", 5, 0, S::npos);
+    test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+    test(S("astedncjhk"), "qcloh", 5, 2, 6);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, S::npos);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 6);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 7);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, S::npos);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+    test(S("shoiedtcjb"), "", 9, 0, S::npos);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+    test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, S::npos);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, S::npos);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, S::npos);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, S::npos);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, S::npos);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, S::npos);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, S::npos);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+    test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+    test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 4);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 3);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 3);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 3);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 19);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 2);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 2);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 2);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 16);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 1);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 6);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 6);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 19);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 4);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 7);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 12);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, S::npos);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 15);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, S::npos);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 11);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 11);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 18);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, S::npos);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, S::npos);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, S::npos);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, S::npos);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, S::npos);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, S::npos);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, S::npos);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, S::npos);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_first_of( "",      0, 0) == SV::npos, "" );
+    static_assert (sv1.find_first_of( "irkhs", 0, 5) == SV::npos, "" );
+    static_assert (sv2.find_first_of( "",      0, 0) == SV::npos, "" );
+    static_assert (sv2.find_first_of( "gfsrt", 0, 5) == SV::npos, "" );
+    static_assert (sv2.find_first_of( "lecar", 0, 5) == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp
new file mode 100644
index 0000000..fddd471
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_first_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const basic_string_view& str, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_first_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, S::npos);
+    test(S("qanej"), S("dfkap"), 0, 1);
+    test(S("clbao"), S("ihqrfebgad"), 0, 2);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+    test(S("srdfq"), S(""), 1, S::npos);
+    test(S("oemth"), S("ikcrq"), 1, S::npos);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+    test(S("cshmd"), S(""), 2, S::npos);
+    test(S("lhcdo"), S("oebqi"), 2, 4);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+    test(S("fmtsp"), S(""), 4, S::npos);
+    test(S("khbpm"), S("aobjd"), 4, S::npos);
+    test(S("pbsji"), S("pcbahntsje"), 4, S::npos);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, S::npos);
+    test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, S::npos);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, S::npos);
+    test(S("daiprenocl"), S("ashjd"), 0, 0);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+    test(S("qpghtfbaji"), S(""), 1, S::npos);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 3);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+    test(S("crnklpmegd"), S(""), 5, S::npos);
+    test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+    test(S("lmofqdhpki"), S(""), 9, S::npos);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, S::npos);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 3);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 3);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, S::npos);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), S::npos);
+    test(S("lahfb"), S("irkhs"), 2);
+    test(S("gmfhd"), S("kantesmpgj"), 0);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 0);
+    test(S("eolhfgpjqk"), S(""), S::npos);
+    test(S("nbatdlmekr"), S("bnrpe"), 0);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 0);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 0);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 1);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 0);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp
new file mode 100644
index 0000000..ed1a35e
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_not_of_char_size.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// const size_type find_last_not_of(charT c, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_not_of(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_last_not_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), 'i', 0, S::npos);
+    test(S(""), 'i', 1, S::npos);
+    test(S("kitcj"), 'i', 0, 0);
+    test(S("qkamf"), 'i', 1, 1);
+    test(S("nhmko"), 'i', 2, 2);
+    test(S("tpsaf"), 'i', 4, 4);
+    test(S("lahfb"), 'i', 5, 4);
+    test(S("irkhs"), 'i', 6, 4);
+    test(S("gmfhdaipsr"), 'i', 0, 0);
+    test(S("kantesmpgj"), 'i', 1, 1);
+    test(S("odaftiegpm"), 'i', 5, 4);
+    test(S("oknlrstdpi"), 'i', 9, 8);
+    test(S("eolhfgpjqk"), 'i', 10, 9);
+    test(S("pcdrofikas"), 'i', 11, 9);
+    test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+    test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+    test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+
+    test(S(""), 'i', S::npos);
+    test(S("csope"), 'i', 4);
+    test(S("gfsmthlkon"), 'i', 9);
+    test(S("laenfsbridchgotmkqpj"), 'i', 19);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_last_not_of( 'i', 0 ) == SV::npos, "" );
+    static_assert (sv1.find_last_not_of( 'i', 1 ) == SV::npos, "" );
+    static_assert (sv2.find_last_not_of( 'a', 0 ) == SV::npos, "" );
+    static_assert (sv2.find_last_not_of( 'a', 1 ) == 1, "" );
+    static_assert (sv2.find_last_not_of( 'e', 5 ) == 3, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp
new file mode 100644
index 0000000..e07c4f3
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_not_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, 0);
+    test(S("qanej"), "dfkap", 0, 0);
+    test(S("clbao"), "ihqrfebgad", 0, 0);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+    test(S("srdfq"), "", 1, 1);
+    test(S("oemth"), "ikcrq", 1, 1);
+    test(S("cdaih"), "dmajblfhsg", 1, 0);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+    test(S("cshmd"), "", 2, 2);
+    test(S("lhcdo"), "oebqi", 2, 2);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 1);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+    test(S("fmtsp"), "", 4, 4);
+    test(S("khbpm"), "aobjd", 4, 4);
+    test(S("pbsji"), "pcbahntsje", 4, 4);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+    test(S("eqmpa"), "", 5, 4);
+    test(S("omigs"), "kocgb", 5, 4);
+    test(S("onmje"), "fbslrjiqkm", 5, 4);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, 4);
+    test(S("igdsc"), "qngpd", 6, 4);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, 0);
+    test(S("daiprenocl"), "ashjd", 0, S::npos);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, S::npos);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+    test(S("qpghtfbaji"), "", 1, 1);
+    test(S("gfshlcmdjr"), "nadkh", 1, 1);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 0);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+    test(S("crnklpmegd"), "", 5, 5);
+    test(S("jsbtafedoc"), "prqgn", 5, 5);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 4);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+    test(S("lmofqdhpki"), "", 9, 9);
+    test(S("hnefkqimca"), "rtjpa", 9, 8);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+    test(S("elgofjmbrq"), "", 10, 9);
+    test(S("mjqdgalkpc"), "dplqa", 10, 9);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, 9);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, 9);
+    test(S("akiteljmoh"), "lofbc", 11, 9);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, 8);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, S::npos);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 0);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 9);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 9);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 16);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, 19);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 18);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 19);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, 19);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 19);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 19);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", 4);
+    test(S("lahfb"), "irkhs", 4);
+    test(S("gmfhd"), "kantesmpgj", 4);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+    test(S("eolhfgpjqk"), "", 9);
+    test(S("nbatdlmekr"), "bnrpe", 8);
+    test(S("jdmciepkaq"), "jtdaefblso", 9);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), "", 19);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 18);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 17);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_last_not_of( "",      0) == SV::npos, "" );
+    static_assert (sv1.find_last_not_of( "irkhs", 5) == SV::npos, "" );
+    static_assert (sv2.find_last_not_of( "",      0) == 0, "" );
+    static_assert (sv2.find_last_not_of( "gfsrt", 5) == 4, "" );
+    static_assert (sv2.find_last_not_of( "lecar", 5) == 3, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp
new file mode 100644
index 0000000..3ddf033
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_not_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, 0);
+    test(S("binja"), "gfsrt", 0, 0, 0);
+    test(S("latkm"), "pfsoc", 0, 1, 0);
+    test(S("lecfr"), "tpflm", 0, 2, 0);
+    test(S("eqkst"), "sgkec", 0, 4, S::npos);
+    test(S("cdafr"), "romds", 0, 5, 0);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+    test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+    test(S("ehmja"), "dabckmepqj", 0, 9, S::npos);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+    test(S("clrgb"), "", 1, 0, 1);
+    test(S("tjmek"), "osmia", 1, 0, 1);
+    test(S("bgstp"), "ckonl", 1, 1, 1);
+    test(S("hstrk"), "ilcaj", 1, 2, 1);
+    test(S("kmspj"), "lasiq", 1, 4, 1);
+    test(S("tjboh"), "kfqmr", 1, 5, 1);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, S::npos);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+    test(S("ndrhl"), "", 2, 0, 2);
+    test(S("mrecp"), "otkgb", 2, 0, 2);
+    test(S("qlasf"), "cqsjl", 2, 1, 2);
+    test(S("smaqd"), "dpifl", 2, 2, 2);
+    test(S("hjeni"), "oapht", 2, 4, 2);
+    test(S("ocmfj"), "cifts", 2, 5, 2);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+    test(S("fklad"), "tpksqhamle", 2, 1, 2);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 1);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 1);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+    test(S("cjgao"), "", 4, 0, 4);
+    test(S("kjplq"), "mabns", 4, 0, 4);
+    test(S("herni"), "bdnrp", 4, 1, 4);
+    test(S("tadrb"), "scidp", 4, 2, 4);
+    test(S("pkfeo"), "agbjl", 4, 4, 4);
+    test(S("hoser"), "jfmpr", 4, 5, 3);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 3);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 2);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 3);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 2);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+    test(S("klopi"), "", 5, 0, 4);
+    test(S("dajhn"), "psthd", 5, 0, 4);
+    test(S("jbgno"), "rpmjd", 5, 1, 4);
+    test(S("hkjae"), "dfsmk", 5, 2, 4);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, 4);
+    test(S("ktdor"), "kipnf", 5, 5, 4);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, 4);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, 4);
+    test(S("armql"), "pcdgltbrfj", 5, 5, 3);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, 4);
+    test(S("jcons"), "ledihrsgpf", 5, 10, 3);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, 4);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, 4);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 1);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 2);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, 4);
+    test(S("stedk"), "hrnat", 6, 0, 4);
+    test(S("tjkaf"), "gsqdt", 6, 1, 4);
+    test(S("dthpe"), "bspkd", 6, 2, 4);
+    test(S("klhde"), "ohcmb", 6, 4, 4);
+    test(S("bhlki"), "heatr", 6, 5, 4);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, 4);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, 4);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, 4);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, 4);
+    test(S("jblqp"), "njolbmspac", 6, 10, 3);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, 4);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, 4);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 1);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, 0);
+    test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, S::npos);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, S::npos);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, S::npos);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+    test(S("shbcqnmoar"), "", 1, 0, 1);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 0);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 0);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 0);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, S::npos);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, S::npos);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, S::npos);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+    test(S("ectnhskflp"), "", 5, 0, 5);
+    test(S("fgtianblpq"), "pijag", 5, 0, 5);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+    test(S("astedncjhk"), "qcloh", 5, 2, 5);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 4);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 3);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 1);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, S::npos);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+    test(S("shoiedtcjb"), "", 9, 0, 9);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+    test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 8);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 8);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 3);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+    test(S("ncjpmaekbs"), "", 10, 0, 9);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, 9);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, 9);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, 9);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, 9);
+    test(S("beanrfodgj"), "odpte", 10, 5, 9);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, 9);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 9);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 8);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 9);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 8);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, 9);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 9);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 7);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 5);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, 9);
+    test(S("hobitmpsan"), "aocjb", 11, 0, 9);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, 9);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, 9);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, 9);
+    test(S("qghptonrea"), "eaqkl", 11, 5, 7);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, 9);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 9);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 9);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 7);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 8);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, 9);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, 9);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 8);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, S::npos);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 0);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 0);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 0);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 0);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 0);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, S::npos);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 9);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 8);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 8);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, S::npos);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 17);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 18);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 7);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, 19);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, 19);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 19);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 19);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 18);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 18);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, 19);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 19);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 18);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 18);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 17);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, 19);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 19);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 19);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 1);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, 19);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, 19);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 19);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 19);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 19);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 19);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, 19);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 19);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 18);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 19);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 19);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, 19);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 19);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 19);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 7);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_last_not_of( "",      0, 0) == SV::npos, "" );
+    static_assert (sv1.find_last_not_of( "irkhs", 0, 5) == SV::npos, "" );
+    static_assert (sv2.find_last_not_of( "",      0, 0) == 0, "" );
+    static_assert (sv2.find_last_not_of( "gfsrt", 5, 0) == 4, "" );
+    static_assert (sv2.find_last_not_of( "lecar", 5, 0) == 4, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp
new file mode 100644
index 0000000..40c867d
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_not_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, 0);
+    test(S("qanej"), S("dfkap"), 0, 0);
+    test(S("clbao"), S("ihqrfebgad"), 0, 0);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+    test(S("srdfq"), S(""), 1, 1);
+    test(S("oemth"), S("ikcrq"), 1, 1);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 0);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+    test(S("cshmd"), S(""), 2, 2);
+    test(S("lhcdo"), S("oebqi"), 2, 2);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 1);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+    test(S("fmtsp"), S(""), 4, 4);
+    test(S("khbpm"), S("aobjd"), 4, 4);
+    test(S("pbsji"), S("pcbahntsje"), 4, 4);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+    test(S("eqmpa"), S(""), 5, 4);
+    test(S("omigs"), S("kocgb"), 5, 4);
+    test(S("onmje"), S("fbslrjiqkm"), 5, 4);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, 4);
+    test(S("igdsc"), S("qngpd"), 6, 4);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, 0);
+    test(S("daiprenocl"), S("ashjd"), 0, S::npos);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, S::npos);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+    test(S("qpghtfbaji"), S(""), 1, 1);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 0);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+    test(S("crnklpmegd"), S(""), 5, 5);
+    test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 4);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+    test(S("lmofqdhpki"), S(""), 9, 9);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 8);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+    test(S("elgofjmbrq"), S(""), 10, 9);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, 9);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, 9);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, 9);
+    test(S("akiteljmoh"), S("lofbc"), 11, 9);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 8);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, S::npos);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 0);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 9);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 9);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 16);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, 19);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 18);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 19);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, 19);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 19);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 19);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), 4);
+    test(S("lahfb"), S("irkhs"), 4);
+    test(S("gmfhd"), S("kantesmpgj"), 4);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+    test(S("eolhfgpjqk"), S(""), 9);
+    test(S("nbatdlmekr"), S("bnrpe"), 8);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 9);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), 19);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 18);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 17);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp
new file mode 100644
index 0000000..d28e007
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_of_char_size.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_of(charT c, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_of(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_last_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), 'm', 0, S::npos);
+    test(S(""), 'm', 1, S::npos);
+    test(S("kitcj"), 'm', 0, S::npos);
+    test(S("qkamf"), 'm', 1, S::npos);
+    test(S("nhmko"), 'm', 2, 2);
+    test(S("tpsaf"), 'm', 4, S::npos);
+    test(S("lahfb"), 'm', 5, S::npos);
+    test(S("irkhs"), 'm', 6, S::npos);
+    test(S("gmfhdaipsr"), 'm', 0, S::npos);
+    test(S("kantesmpgj"), 'm', 1, S::npos);
+    test(S("odaftiegpm"), 'm', 5, S::npos);
+    test(S("oknlrstdpi"), 'm', 9, S::npos);
+    test(S("eolhfgpjqk"), 'm', 10, S::npos);
+    test(S("pcdrofikas"), 'm', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+    test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+    test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+    test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+    test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+    test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+
+    test(S(""), 'm', S::npos);
+    test(S("csope"), 'm', S::npos);
+    test(S("gfsmthlkon"), 'm', 3);
+    test(S("laenfsbridchgotmkqpj"), 'm', 15);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_last_of( 'i', 0 ) == SV::npos, "" );
+    static_assert (sv1.find_last_of( 'i', 1 ) == SV::npos, "" );
+    static_assert (sv2.find_last_of( 'a', 0 ) == 0, "" );
+    static_assert (sv2.find_last_of( 'a', 1 ) == 0, "" );
+    static_assert (sv2.find_last_of( 'e', 5 ) == 4, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp
new file mode 100644
index 0000000..f01e277
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_of_pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_last_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, S::npos);
+    test(S("qanej"), "dfkap", 0, S::npos);
+    test(S("clbao"), "ihqrfebgad", 0, S::npos);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+    test(S("srdfq"), "", 1, S::npos);
+    test(S("oemth"), "ikcrq", 1, S::npos);
+    test(S("cdaih"), "dmajblfhsg", 1, 1);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+    test(S("cshmd"), "", 2, S::npos);
+    test(S("lhcdo"), "oebqi", 2, S::npos);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+    test(S("fmtsp"), "", 4, S::npos);
+    test(S("khbpm"), "aobjd", 4, 2);
+    test(S("pbsji"), "pcbahntsje", 4, 3);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, 3);
+    test(S("onmje"), "fbslrjiqkm", 5, 3);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, 4);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, 2);
+    test(S("brqgo"), "rodhqklgmb", 6, 4);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, 4);
+    test(S("hcjitbfapl"), "", 0, S::npos);
+    test(S("daiprenocl"), "ashjd", 0, 0);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+    test(S("qpghtfbaji"), "", 1, S::npos);
+    test(S("gfshlcmdjr"), "nadkh", 1, S::npos);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+    test(S("crnklpmegd"), "", 5, S::npos);
+    test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+    test(S("lmofqdhpki"), "", 9, S::npos);
+    test(S("hnefkqimca"), "rtjpa", 9, 9);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 7);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, 8);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, 6);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, 9);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, 8);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, 9);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, 9);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, S::npos);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, S::npos);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+    test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 16);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 19);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 18);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, 19);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 12);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 17);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, 19);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", S::npos);
+    test(S("lahfb"), "irkhs", 2);
+    test(S("gmfhd"), "kantesmpgj", 1);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", 4);
+    test(S("eolhfgpjqk"), "", S::npos);
+    test(S("nbatdlmekr"), "bnrpe", 9);
+    test(S("jdmciepkaq"), "jtdaefblso", 8);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 9);
+    test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 19);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 19);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 19);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_last_of( "",      0) == SV::npos, "" );
+    static_assert (sv1.find_last_of( "irkhs", 5) == SV::npos, "" );
+    static_assert (sv2.find_last_of( "",      0) == SV::npos, "" );
+    static_assert (sv2.find_last_of( "gfsrt", 5) == SV::npos, "" );
+    static_assert (sv2.find_last_of( "lecar", 5) == 4, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp
new file mode 100644
index 0000000..a38ffa6
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_of_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, S::npos);
+    test(S("binja"), "gfsrt", 0, 0, S::npos);
+    test(S("latkm"), "pfsoc", 0, 1, S::npos);
+    test(S("lecfr"), "tpflm", 0, 2, S::npos);
+    test(S("eqkst"), "sgkec", 0, 4, 0);
+    test(S("cdafr"), "romds", 0, 5, S::npos);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+    test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, S::npos);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+    test(S("clrgb"), "", 1, 0, S::npos);
+    test(S("tjmek"), "osmia", 1, 0, S::npos);
+    test(S("bgstp"), "ckonl", 1, 1, S::npos);
+    test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+    test(S("kmspj"), "lasiq", 1, 4, S::npos);
+    test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, S::npos);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 0);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 0);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 0);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+    test(S("ndrhl"), "", 2, 0, S::npos);
+    test(S("mrecp"), "otkgb", 2, 0, S::npos);
+    test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+    test(S("smaqd"), "dpifl", 2, 2, S::npos);
+    test(S("hjeni"), "oapht", 2, 4, 0);
+    test(S("ocmfj"), "cifts", 2, 5, 1);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+    test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 0);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 1);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+    test(S("cjgao"), "", 4, 0, S::npos);
+    test(S("kjplq"), "mabns", 4, 0, S::npos);
+    test(S("herni"), "bdnrp", 4, 1, S::npos);
+    test(S("tadrb"), "scidp", 4, 2, S::npos);
+    test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+    test(S("hoser"), "jfmpr", 4, 5, 4);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 3);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, 3);
+    test(S("ktdor"), "kipnf", 5, 5, 0);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, 4);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, 0);
+    test(S("jcons"), "ledihrsgpf", 5, 10, 4);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 4);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 4);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, 4);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, 2);
+    test(S("bhlki"), "heatr", 6, 5, 1);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, 3);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, 3);
+    test(S("jblqp"), "njolbmspac", 6, 10, 4);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 4);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, 4);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, 4);
+    test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+    test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, S::npos);
+    test(S("skrflobnqm"), "jqirk", 0, 2, S::npos);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, S::npos);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, S::npos);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, S::npos);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, S::npos);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, S::npos);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+    test(S("shbcqnmoar"), "", 1, 0, S::npos);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, S::npos);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 0);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+    test(S("ectnhskflp"), "", 5, 0, S::npos);
+    test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+    test(S("astedncjhk"), "qcloh", 5, 2, S::npos);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 2);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 4);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, S::npos);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 4);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+    test(S("shoiedtcjb"), "", 9, 0, S::npos);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+    test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 6);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 8);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 7);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 6);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 5);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 6);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 7);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, 1);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, 2);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, 7);
+    test(S("beanrfodgj"), "odpte", 10, 5, 7);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 1);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 9);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 8);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 9);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 8);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 9);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 9);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, 9);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, 1);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, 7);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, 3);
+    test(S("qghptonrea"), "eaqkl", 11, 5, 9);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 1);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 7);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 9);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 9);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 9);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, 9);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, 9);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, S::npos);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, S::npos);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, S::npos);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, S::npos);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, S::npos);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, S::npos);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, S::npos);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, S::npos);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, S::npos);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, S::npos);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, S::npos);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, S::npos);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, S::npos);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, S::npos);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, S::npos);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, S::npos);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 7);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 6);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 9);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 5);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 9);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, S::npos);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 16);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 7);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 16);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 15);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 17);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 16);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 16);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 10);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 15);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 12);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 19);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 19);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 3);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 19);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 19);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 19);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 4);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 17);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 19);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, 19);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 6);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 13);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 10);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 17);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 14);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 19);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 14);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 16);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 17);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 17);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 19);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, 19);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find_last_of( "",      0, 0) == SV::npos, "" );
+    static_assert (sv1.find_last_of( "irkhs", 0, 5) == SV::npos, "" );
+    static_assert (sv2.find_last_of( "",      0, 0) == SV::npos, "" );
+    static_assert (sv2.find_last_of( "gfsrt", 5, 5) == SV::npos, "" );
+    static_assert (sv2.find_last_of( "lecar", 5, 5) == 4, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp
new file mode 100644
index 0000000..6fd3772
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_last_of_string_view_size.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// size_type find_last_of(const basic_string& str, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_last_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, S::npos);
+    test(S("qanej"), S("dfkap"), 0, S::npos);
+    test(S("clbao"), S("ihqrfebgad"), 0, S::npos);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+    test(S("srdfq"), S(""), 1, S::npos);
+    test(S("oemth"), S("ikcrq"), 1, S::npos);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+    test(S("cshmd"), S(""), 2, S::npos);
+    test(S("lhcdo"), S("oebqi"), 2, S::npos);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+    test(S("fmtsp"), S(""), 4, S::npos);
+    test(S("khbpm"), S("aobjd"), 4, 2);
+    test(S("pbsji"), S("pcbahntsje"), 4, 3);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, 3);
+    test(S("onmje"), S("fbslrjiqkm"), 5, 3);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, 4);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, 2);
+    test(S("brqgo"), S("rodhqklgmb"), 6, 4);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, 4);
+    test(S("hcjitbfapl"), S(""), 0, S::npos);
+    test(S("daiprenocl"), S("ashjd"), 0, 0);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+    test(S("qpghtfbaji"), S(""), 1, S::npos);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, S::npos);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+    test(S("crnklpmegd"), S(""), 5, S::npos);
+    test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+    test(S("lmofqdhpki"), S(""), 9, S::npos);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 7);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, 8);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, 6);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, 9);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, 8);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 9);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, 9);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, S::npos);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, S::npos);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 16);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 19);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 18);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, 19);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 12);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 17);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, 19);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), S::npos);
+    test(S("lahfb"), S("irkhs"), 2);
+    test(S("gmfhd"), S("kantesmpgj"), 1);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 4);
+    test(S("eolhfgpjqk"), S(""), S::npos);
+    test(S("nbatdlmekr"), S("bnrpe"), 9);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 8);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 9);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 19);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 19);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 19);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_pointer_size.pass.cpp
new file mode 100644
index 0000000..5ebe414
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_pointer_size.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// constexpr size_type find(const charT* s, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find(str, pos) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(pos <= x && x + n <= s.size());
+    }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find(str) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(0 <= x && x + n <= s.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0);
+    test(S(""), "abcde", 0, S::npos);
+    test(S(""), "abcdeabcde", 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "abcde", 1, S::npos);
+    test(S(""), "abcdeabcde", 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 0, 0);
+    test(S("abcde"), "abcde", 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcde"), "", 1, 1);
+    test(S("abcde"), "abcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 2, 2);
+    test(S("abcde"), "abcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+    test(S("abcde"), "", 4, 4);
+    test(S("abcde"), "abcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+    test(S("abcde"), "", 5, 5);
+    test(S("abcde"), "abcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcde"), "", 6, S::npos);
+    test(S("abcde"), "abcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+    test(S("abcdeabcde"), "", 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcdeabcde"), "", 1, 1);
+    test(S("abcdeabcde"), "abcde", 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "", 5, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "", 9, 9);
+    test(S("abcdeabcde"), "abcde", 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "", 10, 10);
+    test(S("abcdeabcde"), "abcde", 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "", 11, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", 0);
+    test(S(""), "abcde", S::npos);
+    test(S(""), "abcdeabcde", S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcde"), "", 0);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdeabcde", S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcde"), "", 0);
+    test(S("abcdeabcde"), "abcde", 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find( "") == 0, "" );
+    static_assert (sv1.find( "abcde") == SV::npos, "" );
+    static_assert (sv2.find( "") == 0, "" );
+    static_assert (sv2.find( "abcde") == 0, "" );
+    static_assert (sv2.find( "abcde", 1) == SV::npos, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp
new file mode 100644
index 0000000..382cbaf
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_pointer_size_size.pass.cpp
@@ -0,0 +1,393 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, 0);
+    test(S(""), "abcde", 0, 0, 0);
+    test(S(""), "abcde", 0, 1, S::npos);
+    test(S(""), "abcde", 0, 2, S::npos);
+    test(S(""), "abcde", 0, 4, S::npos);
+    test(S(""), "abcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 9, S::npos);
+    test(S(""), "abcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "abcde", 1, 0, S::npos);
+    test(S(""), "abcde", 1, 1, S::npos);
+    test(S(""), "abcde", 1, 2, S::npos);
+    test(S(""), "abcde", 1, 4, S::npos);
+    test(S(""), "abcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 0, S::npos);
+    test(S(""), "abcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 9, S::npos);
+    test(S(""), "abcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 1, 0);
+    test(S("abcde"), "abcde", 0, 2, 0);
+    test(S("abcde"), "abcde", 0, 4, 0);
+    test(S("abcde"), "abcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcde"), "", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 1, S::npos);
+    test(S("abcde"), "abcde", 1, 2, S::npos);
+    test(S("abcde"), "abcde", 1, 4, S::npos);
+    test(S("abcde"), "abcde", 1, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcde", 1, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 1, S::npos);
+    test(S("abcde"), "abcde", 2, 2, S::npos);
+    test(S("abcde"), "abcde", 2, 4, S::npos);
+    test(S("abcde"), "abcde", 2, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcde", 2, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+    test(S("abcde"), "", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 1, S::npos);
+    test(S("abcde"), "abcde", 4, 2, S::npos);
+    test(S("abcde"), "abcde", 4, 4, S::npos);
+    test(S("abcde"), "abcde", 4, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcde", 4, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+    test(S("abcde"), "", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 1, S::npos);
+    test(S("abcde"), "abcde", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), "abcde", 5, 4, S::npos);
+    test(S("abcde"), "abcde", 5, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcde", 5, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcde"), "", 6, 0, S::npos);
+    test(S("abcde"), "abcde", 6, 0, S::npos);
+    test(S("abcde"), "abcde", 6, 1, S::npos);
+    test(S("abcde"), "abcde", 6, 2, S::npos);
+    test(S("abcde"), "abcde", 6, 4, S::npos);
+    test(S("abcde"), "abcde", 6, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 0, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+    test(S("abcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcde", 1, 2, 5);
+    test(S("abcdeabcde"), "abcde", 1, 4, 5);
+    test(S("abcdeabcde"), "abcde", 1, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcde"), "", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcde", 5, 2, 5);
+    test(S("abcdeabcde"), "abcde", 5, 4, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcdeabcde"), "", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+    test(S("abcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdeabcde"), "abcdeabcde", 10, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcde"), "", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find( "",      0, 0 ) == 0, "" );
+    static_assert (sv1.find( "abcde", 0, 0 ) == 0, "" );
+    static_assert (sv1.find( "abcde", 0, 1 ) == SV::npos, "" );
+    static_assert (sv2.find( "",      0, 0 ) == 0, "" );
+    static_assert (sv2.find( "abcde", 0, 0 ) == 0, "" );
+    static_assert (sv2.find( "abcde", 0, 1 ) == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/find_string_view_size.pass.cpp b/final/test/experimental/string.view/string.view.find/find_string_view_size.pass.cpp
new file mode 100644
index 0000000..84132ac
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/find_string_view_size.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type find(const basic_string_view& str, size_type pos = 0) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find(str) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, 0);
+    test(S(""), S("abcde"), 0, S::npos);
+    test(S(""), S("abcdeabcde"), 0, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("abcde"), 1, S::npos);
+    test(S(""), S("abcdeabcde"), 1, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 0, 0);
+    test(S("abcde"), S("abcde"), 0, 0);
+    test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcde"), S(""), 1, 1);
+    test(S("abcde"), S("abcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 2, 2);
+    test(S("abcde"), S("abcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+    test(S("abcde"), S(""), 4, 4);
+    test(S("abcde"), S("abcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+    test(S("abcde"), S(""), 5, 5);
+    test(S("abcde"), S("abcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcde"), S(""), 6, S::npos);
+    test(S("abcde"), S("abcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+    test(S("abcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcde"), S("abcde"), 1, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S(""), 5, 5);
+    test(S("abcdeabcde"), S("abcde"), 5, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S(""), 9, 9);
+    test(S("abcdeabcde"), S("abcde"), 9, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcde"), S("abcde"), 10, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S(""), 11, S::npos);
+    test(S("abcdeabcde"), S("abcde"), 11, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 11, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), S::npos);
+    test(S(""), S("abcdeabcde"), S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcde"), S(""), 0);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdeabcde"), S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcde"), S(""), 0);
+    test(S("abcdeabcde"), S("abcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.find(sv1) == 0, "" );
+    static_assert (sv1.find(sv2) == SV::npos, "" );
+    static_assert (sv2.find(sv1) == 0, "" );
+    static_assert (sv2.find(sv2) == 0, "" );
+    static_assert (sv2.find(sv2, 1 ) == SV::npos, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/rfind_char_size.pass.cpp b/final/test/experimental/string.view/string.view.find/rfind_char_size.pass.cpp
new file mode 100644
index 0000000..9014d88
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/rfind_char_size.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+// constexpr size_type rfind(charT c, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.rfind(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.rfind(c) == x);
+    if (x != S::npos)
+        assert(x + 1 <= s.size());
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test(S(""), 'b', 0, S::npos);
+    test(S(""), 'b', 1, S::npos);
+    test(S("abcde"), 'b', 0, S::npos);
+    test(S("abcde"), 'b', 1, 1);
+    test(S("abcde"), 'b', 2, 1);
+    test(S("abcde"), 'b', 4, 1);
+    test(S("abcde"), 'b', 5, 1);
+    test(S("abcde"), 'b', 6, 1);
+    test(S("abcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcde"), 'b', 5, 1);
+    test(S("abcdeabcde"), 'b', 9, 6);
+    test(S("abcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcde"), 'b', 11, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+    test(S(""), 'b', S::npos);
+    test(S("abcde"), 'b', 1);
+    test(S("abcdeabcde"), 'b', 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.rfind( 'b', 0 ) == SV::npos, "" );
+    static_assert (sv1.rfind( 'b', 1 ) == SV::npos, "" );
+    static_assert (sv2.rfind( 'b', 0 ) == SV::npos, "" );
+    static_assert (sv2.rfind( 'b', 1 ) == 1, "" );
+    static_assert (sv2.rfind( 'b', 2 ) == 1, "" );
+    static_assert (sv2.rfind( 'b', 3 ) == 1, "" );
+    static_assert (sv2.rfind( 'b', 4 ) == 1, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp
new file mode 100644
index 0000000..0559d31
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/rfind_pointer_size.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+// constexpr size_type rfind(const charT* s, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.rfind(str, pos) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(x <= pos && x + n <= s.size());
+    }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.rfind(str) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type pos = s.size();
+        typename S::size_type n = S::traits_type::length(str);
+        assert(x <= pos && x + n <= s.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0);
+    test(S(""), "abcde", 0, S::npos);
+    test(S(""), "abcdeabcde", 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S(""), "", 1, 0);
+    test(S(""), "abcde", 1, S::npos);
+    test(S(""), "abcdeabcde", 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 0, 0);
+    test(S("abcde"), "abcde", 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcde"), "", 1, 1);
+    test(S("abcde"), "abcde", 1, 0);
+    test(S("abcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 2, 2);
+    test(S("abcde"), "abcde", 2, 0);
+    test(S("abcde"), "abcdeabcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+    test(S("abcde"), "", 4, 4);
+    test(S("abcde"), "abcde", 4, 0);
+    test(S("abcde"), "abcdeabcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+    test(S("abcde"), "", 5, 5);
+    test(S("abcde"), "abcde", 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcde"), "", 6, 5);
+    test(S("abcde"), "abcde", 6, 0);
+    test(S("abcde"), "abcdeabcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+    test(S("abcdeabcde"), "", 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcdeabcde"), "", 1, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "", 5, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "", 9, 9);
+    test(S("abcdeabcde"), "abcde", 9, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "", 10, 10);
+    test(S("abcdeabcde"), "abcde", 10, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "", 11, 10);
+    test(S("abcdeabcde"), "abcde", 11, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", 0);
+    test(S(""), "abcde", S::npos);
+    test(S(""), "abcdeabcde", S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcde"), "", 5);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdeabcde", S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcde"), "", 10);
+    test(S("abcdeabcde"), "abcde", 5);
+    test(S("abcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.rfind( "") == 0, "" );
+    static_assert (sv1.rfind( "abcde") == SV::npos, "" );
+    static_assert (sv2.rfind( "") == 5, "" );
+    static_assert (sv2.rfind( "abcde") == 0, "" );
+    static_assert (sv2.rfind( "abcde", 1) == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp b/final/test/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp
new file mode 100644
index 0000000..9116e3a
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/rfind_pointer_size_size.pass.cpp
@@ -0,0 +1,392 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+// constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+      typename S::size_type n, typename S::size_type x)
+{
+    assert(s.rfind(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, 0);
+    test(S(""), "abcde", 0, 0, 0);
+    test(S(""), "abcde", 0, 1, S::npos);
+    test(S(""), "abcde", 0, 2, S::npos);
+    test(S(""), "abcde", 0, 4, S::npos);
+    test(S(""), "abcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 9, S::npos);
+    test(S(""), "abcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S(""), "", 1, 0, 0);
+    test(S(""), "abcde", 1, 0, 0);
+    test(S(""), "abcde", 1, 1, S::npos);
+    test(S(""), "abcde", 1, 2, S::npos);
+    test(S(""), "abcde", 1, 4, S::npos);
+    test(S(""), "abcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 0, 0);
+    test(S(""), "abcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 9, S::npos);
+    test(S(""), "abcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 1, 0);
+    test(S("abcde"), "abcde", 0, 2, 0);
+    test(S("abcde"), "abcde", 0, 4, 0);
+    test(S("abcde"), "abcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcde"), "", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 1, 0);
+    test(S("abcde"), "abcde", 1, 2, 0);
+    test(S("abcde"), "abcde", 1, 4, 0);
+    test(S("abcde"), "abcde", 1, 5, 0);
+    test(S("abcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 1, 0);
+    test(S("abcde"), "abcde", 2, 2, 0);
+    test(S("abcde"), "abcde", 2, 4, 0);
+    test(S("abcde"), "abcde", 2, 5, 0);
+    test(S("abcde"), "abcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcde", 2, 1, 0);
+    test(S("abcde"), "abcdeabcde", 2, 5, 0);
+    test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+    test(S("abcde"), "", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 1, 0);
+    test(S("abcde"), "abcde", 4, 2, 0);
+    test(S("abcde"), "abcde", 4, 4, 0);
+    test(S("abcde"), "abcde", 4, 5, 0);
+    test(S("abcde"), "abcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcde", 4, 1, 0);
+    test(S("abcde"), "abcdeabcde", 4, 5, 0);
+    test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+    test(S("abcde"), "", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 1, 0);
+    test(S("abcde"), "abcde", 5, 2, 0);
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), "abcde", 5, 4, 0);
+    test(S("abcde"), "abcde", 5, 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcde", 5, 1, 0);
+    test(S("abcde"), "abcdeabcde", 5, 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcde"), "", 6, 0, 5);
+    test(S("abcde"), "abcde", 6, 0, 5);
+    test(S("abcde"), "abcde", 6, 1, 0);
+    test(S("abcde"), "abcde", 6, 2, 0);
+    test(S("abcde"), "abcde", 6, 4, 0);
+    test(S("abcde"), "abcde", 6, 5, 0);
+    test(S("abcde"), "abcdeabcde", 6, 0, 5);
+    test(S("abcde"), "abcdeabcde", 6, 1, 0);
+    test(S("abcde"), "abcdeabcde", 6, 5, 0);
+    test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+    test(S("abcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcde", 1, 2, 0);
+    test(S("abcdeabcde"), "abcde", 1, 4, 0);
+    test(S("abcdeabcde"), "abcde", 1, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcde"), "", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcde", 5, 2, 5);
+    test(S("abcdeabcde"), "abcde", 5, 4, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcdeabcde"), "", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcde", 9, 2, 5);
+    test(S("abcdeabcde"), "abcde", 9, 4, 5);
+    test(S("abcdeabcde"), "abcde", 9, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+    test(S("abcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 1, 5);
+    test(S("abcdeabcde"), "abcde", 10, 2, 5);
+    test(S("abcdeabcde"), "abcde", 10, 4, 5);
+    test(S("abcdeabcde"), "abcde", 10, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 1, 5);
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdeabcde"), "abcdeabcde", 10, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcde"), "", 11, 0, 10);
+    test(S("abcdeabcde"), "abcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcde", 11, 2, 5);
+    test(S("abcdeabcde"), "abcde", 11, 4, 5);
+    test(S("abcdeabcde"), "abcde", 11, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, 0);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.rfind( "",      0, 0 ) == 0, "" );
+    static_assert (sv1.rfind( "abcde", 0, 0 ) == 0, "" );
+    static_assert (sv1.rfind( "abcde", 0, 1 ) == SV::npos, "" );
+    static_assert (sv2.rfind( "",      0, 0 ) == 0, "" );
+    static_assert (sv2.rfind( "abcde", 0, 0 ) == 0, "" );
+    static_assert (sv2.rfind( "abcde", 0, 1 ) == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp b/final/test/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp
new file mode 100644
index 0000000..88457c6
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.find/rfind_string_view_size.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr size_type rfind(const basic_string& str, size_type pos = npos) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.rfind(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.rfind(str) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, 0);
+    test(S(""), S("abcde"), 0, S::npos);
+    test(S(""), S("abcdeabcde"), 0, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S(""), S(""), 1, 0);
+    test(S(""), S("abcde"), 1, S::npos);
+    test(S(""), S("abcdeabcde"), 1, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 0, 0);
+    test(S("abcde"), S("abcde"), 0, 0);
+    test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcde"), S(""), 1, 1);
+    test(S("abcde"), S("abcde"), 1, 0);
+    test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 2, 2);
+    test(S("abcde"), S("abcde"), 2, 0);
+    test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+    test(S("abcde"), S(""), 4, 4);
+    test(S("abcde"), S("abcde"), 4, 0);
+    test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+    test(S("abcde"), S(""), 5, 5);
+    test(S("abcde"), S("abcde"), 5, 0);
+    test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcde"), S(""), 6, 5);
+    test(S("abcde"), S("abcde"), 6, 0);
+    test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+    test(S("abcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcde"), S("abcde"), 1, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 1, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S(""), 5, 5);
+    test(S("abcdeabcde"), S("abcde"), 5, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 5, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S(""), 9, 9);
+    test(S("abcdeabcde"), S("abcde"), 9, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 9, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcde"), S("abcde"), 10, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 10, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S(""), 11, 10);
+    test(S("abcdeabcde"), S("abcde"), 11, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 11, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), S::npos);
+    test(S(""), S("abcdeabcde"), S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcde"), S(""), 5);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdeabcde"), S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcde"), S(""), 10);
+    test(S("abcdeabcde"), S("abcde"), 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+    {
+    typedef std::experimental::string_view S;
+    test0<S>();
+    test1<S>();
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+
+    static_assert (sv1.rfind(sv1) == 0, "" );
+    static_assert (sv1.rfind(sv2) == SV::npos, "" );
+    static_assert (sv2.rfind(sv1) == 5, "" );
+    static_assert (sv2.rfind(sv2) == 0, "" );
+    static_assert (sv2.rfind(sv2, 1) == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.hash/string_view.pass.cpp b/final/test/experimental/string.view/string.view.hash/string_view.pass.cpp
new file mode 100644
index 0000000..03e0db2
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.hash/string_view.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <experimental/string_view>
+#include <cassert>
+#include <type_traits>
+
+using std::experimental::string_view;
+
+template <class T>
+void
+test()
+{
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    H h;
+//     std::string g1 = "1234567890";
+//     std::string g2 = "1234567891";
+    typedef typename T::value_type char_type;
+    char_type g1 [ 10 ];
+    char_type g2 [ 10 ];
+    for ( int i = 0; i < 10; ++i )
+        g1[i] = g2[9-i] = '0' + i;
+    T s1(g1, 10);
+    T s2(g2, 10);
+    assert(h(s1) != h(s2));
+}
+
+int main()
+{
+    test<std::experimental::string_view>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<std::experimental::u16string_view>();
+    test<std::experimental::u32string_view>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<std::experimental::wstring_view>();
+}
diff --git a/final/test/experimental/string.view/string.view.io/stream_insert.pass.cpp b/final/test/experimental/string.view/string.view.io/stream_insert.pass.cpp
new file mode 100644
index 0000000..4f3f962
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.io/stream_insert.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& os,
+//              const basic_string_view<charT,traits> str);
+
+#include <experimental/string_view>
+#include <sstream>
+#include <cassert>
+
+using std::experimental::string_view;
+using std::experimental::wstring_view;
+
+int main()
+{
+    {
+        std::ostringstream out;
+        string_view sv("some text");
+        out << sv;
+        assert(out.good());
+        assert(sv == out.str());
+    }
+    {
+        std::ostringstream out;
+        std::string s("some text");
+        string_view sv(s);
+        out.width(12);
+        out << sv;
+        assert(out.good());
+        assert("   " + s == out.str());
+    }
+    {
+        std::wostringstream out;
+        wstring_view sv(L"some text");
+        out << sv;
+        assert(out.good());
+        assert(sv == out.str());
+    }
+    {
+        std::wostringstream out;
+        std::wstring s(L"some text");
+        wstring_view sv(s);
+        out.width(12);
+        out << sv;
+        assert(out.good());
+        assert(L"   " + s == out.str());
+    }
+}
diff --git a/final/test/experimental/string.view/string.view.iterators/begin.pass.cpp b/final/test/experimental/string.view/string.view.iterators/begin.pass.cpp
new file mode 100644
index 0000000..07f3b36
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.iterators/begin.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr const_iterator begin() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::iterator b = s.begin();
+    typename S::const_iterator cb1 = cs.begin();
+    typename S::const_iterator cb2 = s.cbegin();
+    if (!s.empty())
+    {
+        assert(   *b ==  s[0]);
+        assert(  &*b == &s[0]);
+        assert( *cb1 ==  s[0]);
+        assert(&*cb1 == &s[0]);
+        assert( *cb2 ==  s[0]);
+        assert(&*cb2 == &s[0]);
+        
+    }
+    assert(  b == cb1);
+    assert(  b == cb2);
+    assert(cb1 == cb2);
+}
+
+
+int main()
+{
+    typedef std::experimental::string_view    string_view;
+    typedef std::experimental::u16string_view u16string_view;
+    typedef std::experimental::u32string_view u32string_view;
+    typedef std::experimental::wstring_view   wstring_view;
+
+    test(string_view   ());
+    test(u16string_view());
+    test(u32string_view());
+    test(wstring_view  ());
+    test(string_view   ( "123"));
+    test(wstring_view  (L"123"));
+#if __cplusplus >= 201103L
+    test(u16string_view{u"123"});
+    test(u32string_view{U"123"});
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr string_view       sv { "123", 3 };
+    constexpr u16string_view u16sv {u"123", 3 };
+    constexpr u32string_view u32sv {U"123", 3 };
+    constexpr wstring_view     wsv {L"123", 3 };
+    
+    static_assert (    *sv.begin() ==    sv[0], "" );
+    static_assert ( *u16sv.begin() == u16sv[0], "" );
+    static_assert ( *u32sv.begin() == u32sv[0], "" );
+    static_assert (   *wsv.begin() ==   wsv[0], "" );
+
+    static_assert (    *sv.cbegin() ==    sv[0], "" );
+    static_assert ( *u16sv.cbegin() == u16sv[0], "" );
+    static_assert ( *u32sv.cbegin() == u32sv[0], "" );
+    static_assert (   *wsv.cbegin() ==   wsv[0], "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.iterators/end.pass.cpp b/final/test/experimental/string.view/string.view.iterators/end.pass.cpp
new file mode 100644
index 0000000..2ed52b8
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.iterators/end.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr const_iterator end() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::iterator e = s.end();
+    typename S::const_iterator ce1 = cs.end();
+    typename S::const_iterator ce2 = s.cend();
+
+    if (s.empty())
+    {
+        assert(  e ==  s.begin());
+        assert(ce1 == cs.begin());
+        assert(ce2 ==  s.begin());
+    }
+    else
+    {
+        assert(  e !=  s.begin());
+        assert(ce1 != cs.begin());
+        assert(ce2 !=  s.begin());
+    }
+    
+    assert(  e -  s.begin() == s.size());
+    assert(ce1 - cs.begin() == cs.size());
+    assert(ce2 - s.cbegin() == s.size());
+
+    assert(  e == ce1);
+    assert(  e == ce2);
+    assert(ce1 == ce2);
+}
+
+
+int main()
+{
+    typedef std::experimental::string_view    string_view;
+    typedef std::experimental::u16string_view u16string_view;
+    typedef std::experimental::u32string_view u32string_view;
+    typedef std::experimental::wstring_view   wstring_view;
+
+    test(string_view   ());
+    test(u16string_view());
+    test(u32string_view());
+    test(wstring_view  ());
+    test(string_view   ( "123"));
+    test(wstring_view  (L"123"));
+#if __cplusplus >= 201103L
+    test(u16string_view{u"123"});
+    test(u32string_view{U"123"});
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr string_view       sv { "123", 3 };
+    constexpr u16string_view u16sv {u"123", 3 };
+    constexpr u32string_view u32sv {U"123", 3 };
+    constexpr wstring_view     wsv {L"123", 3 };
+    
+    static_assert (    sv.begin() !=    sv.end(), "" );
+    static_assert ( u16sv.begin() != u16sv.end(), "" );
+    static_assert ( u32sv.begin() != u32sv.end(), "" );
+    static_assert (   wsv.begin() !=   wsv.end(), "" );
+
+    static_assert (    sv.begin() !=    sv.cend(), "" );
+    static_assert ( u16sv.begin() != u16sv.cend(), "" );
+    static_assert ( u32sv.begin() != u32sv.cend(), "" );
+    static_assert (   wsv.begin() !=   wsv.cend(), "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.iterators/rbegin.pass.cpp b/final/test/experimental/string.view/string.view.iterators/rbegin.pass.cpp
new file mode 100644
index 0000000..7d1c700
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.iterators/rbegin.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// const_iterator rbegin() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::reverse_iterator b = s.rbegin();
+    typename S::const_reverse_iterator cb1 = cs.rbegin();
+    typename S::const_reverse_iterator cb2 = s.crbegin();
+    if (!s.empty())
+    {
+        const size_t last = s.size() - 1;
+        assert(   *b ==  s[last]);
+        assert(  &*b == &s[last]);
+        assert( *cb1 ==  s[last]);
+        assert(&*cb1 == &s[last]);
+        assert( *cb2 ==  s[last]);
+        assert(&*cb2 == &s[last]);
+        
+    }
+    assert(  b == cb1);
+    assert(  b == cb2);
+    assert(cb1 == cb2);
+}
+
+
+int main()
+{
+    typedef std::experimental::string_view    string_view;
+    typedef std::experimental::u16string_view u16string_view;
+    typedef std::experimental::u32string_view u32string_view;
+    typedef std::experimental::wstring_view   wstring_view;
+
+    test(string_view   ());
+    test(u16string_view());
+    test(u32string_view());
+    test(wstring_view  ());
+    test(string_view   ( "123"));
+    test(wstring_view  (L"123"));
+#if __cplusplus >= 201103L
+    test(u16string_view{u"123"});
+    test(u32string_view{U"123"});
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.iterators/rend.pass.cpp b/final/test/experimental/string.view/string.view.iterators/rend.pass.cpp
new file mode 100644
index 0000000..57002f3
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.iterators/rend.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr const_iterator rend() const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::reverse_iterator e = s.rend();
+    typename S::const_reverse_iterator ce1 = cs.rend();
+    typename S::const_reverse_iterator ce2 = s.crend();
+
+    if (s.empty())
+    {
+        assert(  e ==  s.rbegin());
+        assert(ce1 == cs.rbegin());
+        assert(ce2 ==  s.rbegin());
+    }
+    else
+    {
+        assert(  e !=  s.rbegin());
+        assert(ce1 != cs.rbegin());
+        assert(ce2 !=  s.rbegin());
+    }
+    
+    assert(  e -  s.rbegin() == s.size());
+    assert(ce1 - cs.rbegin() == cs.size());
+    assert(ce2 - s.crbegin() == s.size());
+
+    assert(  e == ce1);
+    assert(  e == ce2);
+    assert(ce1 == ce2);
+}
+
+
+int main()
+{
+    typedef std::experimental::string_view    string_view;
+    typedef std::experimental::u16string_view u16string_view;
+    typedef std::experimental::u32string_view u32string_view;
+    typedef std::experimental::wstring_view   wstring_view;
+    
+    test(string_view   ());
+    test(u16string_view());
+    test(u32string_view());
+    test(wstring_view  ());
+    test(string_view   ( "123"));
+    test(wstring_view  (L"123"));
+#if __cplusplus >= 201103L
+    test(u16string_view{u"123"});
+    test(u32string_view{U"123"});
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.modifiers/clear.pass.cpp b/final/test/experimental/string.view/string.view.modifiers/clear.pass.cpp
new file mode 100644
index 0000000..6a9982e
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.modifiers/clear.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void clear() noexcept
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+    typedef std::experimental::basic_string_view<CharT> SV;
+    {
+    SV sv1 ( s );
+    assert ( sv1.size() == len );
+    assert ( sv1.data() == s );
+
+    sv1.clear ();
+    assert ( sv1.data() == nullptr );
+    assert ( sv1.size() == 0 );
+    assert ( sv1 == SV());
+    }
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n ) {
+    typedef std::experimental::basic_string_view<char> SV;
+    SV sv1{ "ABCDEFGHIJKL", n };
+    sv1.clear();
+    return sv1.size();
+}
+#endif
+
+int main () {
+    test ( "ABCDE", 5 );
+    test ( "a", 1 );
+    test ( "", 0 );
+
+    test ( L"ABCDE", 5 );
+    test ( L"a", 1 );
+    test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDE", 5 );
+    test ( u"a", 1 );
+    test ( u"", 0 );
+
+    test ( U"ABCDE", 5 );
+    test ( U"a", 1 );
+    test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    static_assert ( test_ce (5) == 0, "" );
+#endif
+
+}
diff --git a/final/test/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp b/final/test/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp
new file mode 100644
index 0000000..e99514a
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.modifiers/remove_prefix.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void remove_prefix(size_type _n)
+
+#include <experimental/string_view>
+#include <cassert>
+#include <iostream>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+    typedef std::experimental::basic_string_view<CharT> SV;
+    {
+    SV sv1 ( s );
+    assert ( sv1.size() == len );
+    assert ( sv1.data() == s );
+
+    if ( len > 0 ) {
+        sv1.remove_prefix ( 1 );
+        assert ( sv1.size() == (len - 1));
+        assert ( sv1.data() == (s + 1));
+    }
+    
+    sv1.remove_prefix ( len - 1 );
+    assert ( sv1.size() == 0 );
+
+    SV sv2 ( s );
+    sv2.remove_prefix ( len << 1 );
+    assert ( sv1.size() == 0 ); 
+    }
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n, size_t k ) {
+    typedef std::experimental::basic_string_view<char> SV;
+    SV sv1{ "ABCDEFGHIJKL", n };
+    sv1.remove_prefix ( k );
+    return sv1.size();
+}
+#endif
+
+int main () {
+    test ( "ABCDE", 5 );
+    test ( "a", 1 );
+    test ( "", 0 );
+
+    test ( L"ABCDE", 5 );
+    test ( L"a", 1 );
+    test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDE", 5 );
+    test ( u"a", 1 );
+    test ( u"", 0 );
+
+    test ( U"ABCDE", 5 );
+    test ( U"a", 1 );
+    test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert ( test_ce ( 5, 0 ) == 5, "" );
+    static_assert ( test_ce ( 5, 1 ) == 4, "" );
+    static_assert ( test_ce ( 5, 5 ) == 0, "" );
+    static_assert ( test_ce ( 5, 9 ) == 0, "" );
+    static_assert ( test_ce ( 9, 3 ) == 6, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp b/final/test/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp
new file mode 100644
index 0000000..5baaab0
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.modifiers/remove_suffix.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void remove_suffix(size_type _n)
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+    typedef std::experimental::basic_string_view<CharT> SV;
+    {
+    SV sv1 ( s );
+    assert ( sv1.size() == len );
+    assert ( sv1.data() == s );
+
+    if ( len > 0 ) {
+        sv1.remove_suffix ( 1 );
+        assert ( sv1.size() == (len - 1));
+        assert ( sv1.data() == s);
+        }
+        
+    sv1.remove_suffix ( len - 1 );
+    assert ( sv1.size() == 0 );
+
+    SV sv2 ( s );
+    sv2.remove_suffix ( len << 1 );
+    assert ( sv1.size() == 0 ); 
+    }
+
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n, size_t k ) {
+    typedef std::experimental::basic_string_view<char> SV;
+    SV sv1{ "ABCDEFGHIJKL", n };
+    sv1.remove_suffix ( k );
+    return sv1.size();
+}
+#endif
+
+int main () {
+    test ( "ABCDE", 5 );
+    test ( "a", 1 );
+    test ( "", 0 );
+
+    test ( L"ABCDE", 5 );
+    test ( L"a", 1 );
+    test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDE", 5 );
+    test ( u"a", 1 );
+    test ( u"", 0 );
+
+    test ( U"ABCDE", 5 );
+    test ( U"a", 1 );
+    test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert ( test_ce ( 5, 0 ) == 5, "" );
+    static_assert ( test_ce ( 5, 1 ) == 4, "" );
+    static_assert ( test_ce ( 5, 5 ) == 0, "" );
+    static_assert ( test_ce ( 5, 9 ) == 0, "" );
+    static_assert ( test_ce ( 9, 3 ) == 6, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.modifiers/swap.pass.cpp b/final/test/experimental/string.view/string.view.modifiers/swap.pass.cpp
new file mode 100644
index 0000000..cacb8ed
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.modifiers/swap.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// void swap(basic_string_view& _other) noexcept
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s, size_t len ) {
+    typedef std::experimental::basic_string_view<CharT> SV;
+    {
+    SV sv1(s);
+    SV sv2;
+    
+    assert ( sv1.size() == len );
+    assert ( sv1.data() == s );
+    assert ( sv2.size() == 0 );
+
+    sv1.swap ( sv2 );
+    assert ( sv1.size() == 0 );
+    assert ( sv2.size() == len );
+    assert ( sv2.data() == s );
+    }
+
+}
+
+#if _LIBCPP_STD_VER > 11
+constexpr size_t test_ce ( size_t n, size_t k ) {
+    typedef std::experimental::basic_string_view<char> SV;
+    SV sv1{ "ABCDEFGHIJKL", n };
+    SV sv2 { sv1.data(), k };
+    sv1.swap ( sv2 );
+    return sv1.size();
+}
+#endif
+
+
+int main () {
+    test ( "ABCDE", 5 );
+    test ( "a", 1 );
+    test ( "", 0 );
+
+    test ( L"ABCDE", 5 );
+    test ( L"a", 1 );
+    test ( L"", 0 );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDE", 5 );
+    test ( u"a", 1 );
+    test ( u"", 0 );
+
+    test ( U"ABCDE", 5 );
+    test ( U"a", 1 );
+    test ( U"", 0 );
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    static_assert ( test_ce (2, 3) == 3, "" );
+    static_assert ( test_ce (5, 3) == 3, "" );
+    static_assert ( test_ce (0, 1) == 1, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.nonmem/quoted.pass.cpp b/final/test/experimental/string.view/string.view.nonmem/quoted.pass.cpp
new file mode 100644
index 0000000..c86e961
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.nonmem/quoted.pass.cpp
@@ -0,0 +1,212 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <experimental/string_view>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+// quoted is C++14 only
+
+bool is_skipws ( const std::istream *is ) {
+    return ( is->flags() & std::ios_base::skipws ) != 0;
+    }
+
+
+bool is_skipws ( const std::wistream *is ) {
+    return ( is->flags() & std::ios_base::skipws ) != 0;
+    }
+
+void round_trip ( const char *p ) {
+    std::stringstream ss;
+    bool skippingws = is_skipws ( &ss );
+    std::experimental::string_view sv {p};
+
+    ss << std::quoted(sv);
+    std::string s;
+    ss >> std::quoted(s);
+    assert ( s == sv );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+
+void round_trip_ws ( const char *p ) {
+    std::stringstream ss;
+    std::noskipws ( ss );
+    bool skippingws = is_skipws ( &ss );
+    std::experimental::string_view sv {p};
+
+    ss << std::quoted(sv);
+    std::string s;
+    ss >> std::quoted(s);
+    assert ( s == sv );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+
+void round_trip_d ( const char *p, char delim ) {
+    std::stringstream ss;
+    std::experimental::string_view sv {p};
+
+    ss << std::quoted(sv, delim);
+    std::string s;
+    ss >> std::quoted(s, delim);
+    assert ( s == sv );
+    }
+
+void round_trip_e ( const char *p, char escape ) {
+    std::stringstream ss;
+    std::experimental::string_view sv {p};
+
+    ss << std::quoted(sv, '"', escape );
+    std::string s;
+    ss >> std::quoted(s, '"', escape );
+    assert ( s == sv );
+    }
+
+
+
+std::string quote ( const char *p, char delim='"', char escape='\\' ) {
+    std::stringstream ss;
+    ss << std::quoted(p, delim, escape);
+    std::string s;
+    ss >> s;    // no quote
+    return s;
+}
+
+std::string unquote ( const char *p, char delim='"', char escape='\\' ) {
+    std::stringstream ss;
+    ss << p;
+    std::string s;
+    ss >> std::quoted(s, delim, escape);
+    return s;
+}
+
+
+void round_trip ( const wchar_t *p ) {
+    std::wstringstream ss;
+    bool skippingws = is_skipws ( &ss );
+    std::experimental::wstring_view sv {p};
+
+    ss << std::quoted(sv);
+    std::wstring s;
+    ss >> std::quoted(s);
+    assert ( s == sv );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+    
+
+void round_trip_ws ( const wchar_t *p ) {
+    std::wstringstream ss;
+    std::noskipws ( ss );
+    bool skippingws = is_skipws ( &ss );
+    std::experimental::wstring_view sv {p};
+
+    ss << std::quoted(sv);
+    std::wstring s;
+    ss >> std::quoted(s);
+    assert ( s == sv );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+
+void round_trip_d ( const wchar_t *p, wchar_t delim ) {
+    std::wstringstream ss;
+    std::experimental::wstring_view sv {p};
+
+    ss << std::quoted(sv, delim);
+    std::wstring s;
+    ss >> std::quoted(s, delim);
+    assert ( s == sv );
+    }
+
+void round_trip_e ( const wchar_t *p, wchar_t escape ) {
+    std::wstringstream ss;
+    std::experimental::wstring_view sv {p};
+
+    ss << std::quoted(sv, wchar_t('"'), escape );
+    std::wstring s;
+    ss >> std::quoted(s, wchar_t('"'), escape );
+    assert ( s == sv );
+    }
+
+
+std::wstring quote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+    std::wstringstream ss;
+    std::experimental::wstring_view sv {p};
+
+    ss << std::quoted(sv, delim, escape);
+    std::wstring s;
+    ss >> s;    // no quote
+    return s;
+}
+
+std::wstring unquote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+    std::wstringstream ss;
+    std::experimental::wstring_view sv {p};
+
+    ss << sv;
+    std::wstring s;
+    ss >> std::quoted(s, delim, escape);
+    return s;
+}
+
+int main()
+{
+    round_trip    (  "" );
+    round_trip_ws (  "" );
+    round_trip_d  (  "", 'q' );
+    round_trip_e  (  "", 'q' );
+    
+    round_trip    ( L"" );
+    round_trip_ws ( L"" );
+    round_trip_d  ( L"", 'q' );
+    round_trip_e  ( L"", 'q' );
+    
+    round_trip    (  "Hi" );
+    round_trip_ws (  "Hi" );
+    round_trip_d  (  "Hi", '!' );
+    round_trip_e  (  "Hi", '!' );
+    assert ( quote ( "Hi", '!' ) == "!Hi!" );
+    assert ( quote ( "Hi!", '!' ) == R"(!Hi\!!)" );
+    
+    round_trip    ( L"Hi" );
+    round_trip_ws ( L"Hi" );
+    round_trip_d  ( L"Hi", '!' );
+    round_trip_e  ( L"Hi", '!' );
+    assert ( quote ( L"Hi", '!' )  == L"!Hi!" );
+    assert ( quote ( L"Hi!", '!' ) == LR"(!Hi\!!)" );
+    
+    round_trip    (  "Hi Mom" );
+    round_trip_ws (  "Hi Mom" );
+    round_trip    ( L"Hi Mom" );
+    round_trip_ws ( L"Hi Mom" );
+    
+    assert ( quote (  "" )  ==  "\"\"" );
+    assert ( quote ( L"" )  == L"\"\"" );
+    assert ( quote (  "a" ) ==  "\"a\"" );
+    assert ( quote ( L"a" ) == L"\"a\"" );
+
+//  missing end quote - must not hang
+    assert ( unquote (  "\"abc" ) ==  "abc" );
+    assert ( unquote ( L"\"abc" ) == L"abc" );
+    
+    assert ( unquote (  "abc" ) == "abc" ); // no delimiter
+    assert ( unquote ( L"abc" ) == L"abc" ); // no delimiter
+    assert ( unquote (  "abc def" ) ==  "abc" ); // no delimiter
+    assert ( unquote ( L"abc def" ) == L"abc" ); // no delimiter
+
+    assert ( unquote (  "" ) ==  "" ); // nothing there
+    assert ( unquote ( L"" ) == L"" ); // nothing there
+    }
+#else
+int main() {}
+#endif
diff --git a/final/test/experimental/string.view/string.view.ops/basic_string.pass.cpp b/final/test/experimental/string.view/string.view.ops/basic_string.pass.cpp
new file mode 100644
index 0000000..64000d6
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/basic_string.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// template<class _Allocator>
+// explicit operator basic_string<_CharT, _Traits, _Allocator>() const
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test ( const CharT *s ) {
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    typedef std::basic_string<CharT> string_t;
+    
+    {
+    string_view_t sv1 ( s );
+    string_t      str = (string_t) sv1;
+
+    assert ( sv1.size() == str.size ());
+    assert ( std::char_traits<CharT>::compare ( sv1.data(), str.data(), sv1.size()) == 0 );
+    }
+
+    {
+    string_view_t sv1;
+    string_t      str = (string_t) sv1;
+
+    assert ( sv1.size() == str.size ());
+    assert ( std::char_traits<CharT>::compare ( sv1.data(), str.data(), sv1.size()) == 0 );
+    }
+}
+
+int main () {
+    test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( "ABCDE");
+    test ( "a" );
+    test ( "" );
+
+    test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( L"ABCDE" );
+    test ( L"a" );
+    test ( L"" );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( u"ABCDE" );
+    test ( u"a" );
+    test ( u"" );
+
+    test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( U"ABCDE" );
+    test ( U"a" );
+    test ( U"" );
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.ops/compare.pointer.pass.cpp b/final/test/experimental/string.view/string.view.ops/compare.pointer.pass.cpp
new file mode 100644
index 0000000..6ccec9b
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/compare.pointer.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr int compare(const charT* s) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, const CharT *s, int expected ) {
+    assert ( sign( sv1.compare(s)) == sign(expected));
+}
+
+template<typename CharT>
+void
+test( const CharT *s1, const CharT *s2, int expected)
+{
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    string_view_t sv1 ( s1 );
+    test1 ( sv1, s2, expected );
+}
+
+int main()
+{
+    {
+    test("", "", 0);
+    test("", "abcde", -5);
+    test("", "abcdefghij", -10);
+    test("", "abcdefghijklmnopqrst", -20);
+    test("abcde", "", 5);
+    test("abcde", "abcde", 0);
+    test("abcde", "abcdefghij", -5);
+    test("abcde", "abcdefghijklmnopqrst", -15);
+    test("abcdefghij", "", 10);
+    test("abcdefghij", "abcde", 5);
+    test("abcdefghij", "abcdefghij", 0);
+    test("abcdefghij", "abcdefghijklmnopqrst", -10);
+    test("abcdefghijklmnopqrst", "", 20);
+    test("abcdefghijklmnopqrst", "abcde", 15);
+    test("abcdefghijklmnopqrst", "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", "abcdefghijklmnopqrst", 0);
+    }
+
+    {
+    test(L"", L"", 0);
+    test(L"", L"abcde", -5);
+    test(L"", L"abcdefghij", -10);
+    test(L"", L"abcdefghijklmnopqrst", -20);
+    test(L"abcde", L"", 5);
+    test(L"abcde", L"abcde", 0);
+    test(L"abcde", L"abcdefghij", -5);
+    test(L"abcde", L"abcdefghijklmnopqrst", -15);
+    test(L"abcdefghij", L"", 10);
+    test(L"abcdefghij", L"abcde", 5);
+    test(L"abcdefghij", L"abcdefghij", 0);
+    test(L"abcdefghij", L"abcdefghijklmnopqrst", -10);
+    test(L"abcdefghijklmnopqrst", L"", 20);
+    test(L"abcdefghijklmnopqrst", L"abcde", 15);
+    test(L"abcdefghijklmnopqrst", L"abcdefghij", 10);
+    test(L"abcdefghijklmnopqrst", L"abcdefghijklmnopqrst", 0);
+    }
+
+#if __cplusplus >= 201103L
+    {
+    test(U"", U"", 0);
+    test(U"", U"abcde", -5);
+    test(U"", U"abcdefghij", -10);
+    test(U"", U"abcdefghijklmnopqrst", -20);
+    test(U"abcde", U"", 5);
+    test(U"abcde", U"abcde", 0);
+    test(U"abcde", U"abcdefghij", -5);
+    test(U"abcde", U"abcdefghijklmnopqrst", -15);
+    test(U"abcdefghij", U"", 10);
+    test(U"abcdefghij", U"abcde", 5);
+    test(U"abcdefghij", U"abcdefghij", 0);
+    test(U"abcdefghij", U"abcdefghijklmnopqrst", -10);
+    test(U"abcdefghijklmnopqrst", U"", 20);
+    test(U"abcdefghijklmnopqrst", U"abcde", 15);
+    test(U"abcdefghijklmnopqrst", U"abcdefghij", 10);
+    test(U"abcdefghijklmnopqrst", U"abcdefghijklmnopqrst", 0);
+    }
+
+    {
+    test(u"", u"", 0);
+    test(u"", u"abcde", -5);
+    test(u"", u"abcdefghij", -10);
+    test(u"", u"abcdefghijklmnopqrst", -20);
+    test(u"abcde", u"", 5);
+    test(u"abcde", u"abcde", 0);
+    test(u"abcde", u"abcdefghij", -5);
+    test(u"abcde", u"abcdefghijklmnopqrst", -15);
+    test(u"abcdefghij", u"", 10);
+    test(u"abcdefghij", u"abcde", 5);
+    test(u"abcdefghij", u"abcdefghij", 0);
+    test(u"abcdefghij", u"abcdefghijklmnopqrst", -10);
+    test(u"abcdefghijklmnopqrst", u"", 20);
+    test(u"abcdefghijklmnopqrst", u"abcde", 15);
+    test(u"abcdefghijklmnopqrst", u"abcdefghij", 10);
+    test(u"abcdefghijklmnopqrst", u"abcdefghijklmnopqrst", 0);
+    }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+    static_assert ( sv1.compare("") == 0, "" );
+    static_assert ( sv1.compare("abcde") == -1, "" );
+    static_assert ( sv2.compare("") == 1, "" );
+    static_assert ( sv2.compare("abcde") == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
new file mode 100644
index 0000000..6b20639
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp
@@ -0,0 +1,444 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, 
+             size_t pos1, size_t n1, const CharT *s, int expected ) {
+    try {
+        assert(sign(sv1.compare(pos1, n1, s)) == sign(expected));
+        assert(pos1 <= sv1.size());
+    }
+    catch (const std::out_of_range&) { assert(pos1 > sv1.size()); }
+}
+
+template<typename CharT>
+void
+test( const CharT *s1, size_t pos1, size_t n1, const CharT *s2, int expected)
+{
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    string_view_t sv1 ( s1 );
+    test1 ( sv1, pos1, n1, s2, expected );
+}
+
+void test0()
+{
+    test("", 0, 0, "", 0);
+    test("", 0, 0, "abcde", -5);
+    test("", 0, 0, "abcdefghij", -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("", 0, 1, "", 0);
+    test("", 0, 1, "abcde", -5);
+    test("", 0, 1, "abcdefghij", -10);
+    test("", 0, 1, "abcdefghijklmnopqrst", -20);
+    test("", 1, 0, "", 0);
+    test("", 1, 0, "abcde", 0);
+    test("", 1, 0, "abcdefghij", 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0);
+    test("abcde", 0, 0, "", 0);
+    test("abcde", 0, 0, "abcde", -5);
+    test("abcde", 0, 0, "abcdefghij", -10);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 0, 1, "", 1);
+    test("abcde", 0, 1, "abcde", -4);
+    test("abcde", 0, 1, "abcdefghij", -9);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", -19);
+    test("abcde", 0, 2, "", 2);
+    test("abcde", 0, 2, "abcde", -3);
+    test("abcde", 0, 2, "abcdefghij", -8);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", -18);
+    test("abcde", 0, 4, "", 4);
+    test("abcde", 0, 4, "abcde", -1);
+    test("abcde", 0, 4, "abcdefghij", -6);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", -16);
+    test("abcde", 0, 5, "", 5);
+    test("abcde", 0, 5, "abcde", 0);
+    test("abcde", 0, 5, "abcdefghij", -5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", -15);
+    test("abcde", 0, 6, "", 5);
+    test("abcde", 0, 6, "abcde", 0);
+    test("abcde", 0, 6, "abcdefghij", -5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", -15);
+    test("abcde", 1, 0, "", 0);
+    test("abcde", 1, 0, "abcde", -5);
+    test("abcde", 1, 0, "abcdefghij", -10);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 1, 1, "", 1);
+    test("abcde", 1, 1, "abcde", 1);
+    test("abcde", 1, 1, "abcdefghij", 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 2, "", 2);
+    test("abcde", 1, 2, "abcde", 1);
+    test("abcde", 1, 2, "abcdefghij", 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 3, "", 3);
+    test("abcde", 1, 3, "abcde", 1);
+    test("abcde", 1, 3, "abcdefghij", 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 4, "", 4);
+    test("abcde", 1, 4, "abcde", 1);
+    test("abcde", 1, 4, "abcdefghij", 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 5, "", 4);
+    test("abcde", 1, 5, "abcde", 1);
+    test("abcde", 1, 5, "abcdefghij", 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1);
+    test("abcde", 2, 0, "", 0);
+    test("abcde", 2, 0, "abcde", -5);
+    test("abcde", 2, 0, "abcdefghij", -10);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 2, 1, "", 1);
+    test("abcde", 2, 1, "abcde", 2);
+    test("abcde", 2, 1, "abcdefghij", 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 2);
+    test("abcde", 2, 2, "", 2);
+    test("abcde", 2, 2, "abcde", 2);
+    test("abcde", 2, 2, "abcdefghij", 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 2);
+    test("abcde", 2, 3, "", 3);
+    test("abcde", 2, 3, "abcde", 2);
+    test("abcde", 2, 3, "abcdefghij", 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 2);
+    test("abcde", 2, 4, "", 3);
+    test("abcde", 2, 4, "abcde", 2);
+    test("abcde", 2, 4, "abcdefghij", 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 2);
+    test("abcde", 4, 0, "", 0);
+    test("abcde", 4, 0, "abcde", -5);
+    test("abcde", 4, 0, "abcdefghij", -10);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 4, 1, "", 1);
+    test("abcde", 4, 1, "abcde", 4);
+    test("abcde", 4, 1, "abcdefghij", 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 4);
+    test("abcde", 4, 2, "", 1);
+    test("abcde", 4, 2, "abcde", 4);
+    test("abcde", 4, 2, "abcdefghij", 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 4);
+    test("abcde", 5, 0, "", 0);
+    test("abcde", 5, 0, "abcde", -5);
+    test("abcde", 5, 0, "abcdefghij", -10);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 5, 1, "", 0);
+    test("abcde", 5, 1, "abcde", -5);
+    test("abcde", 5, 1, "abcdefghij", -10);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", -20);
+}
+
+void test1()
+{
+    test("abcde", 6, 0, "", 0);
+    test("abcde", 6, 0, "abcde", 0);
+    test("abcde", 6, 0, "abcdefghij", 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0);
+    test("abcdefghij", 0, 0, "", 0);
+    test("abcdefghij", 0, 0, "abcde", -5);
+    test("abcdefghij", 0, 0, "abcdefghij", -10);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 0, 1, "", 1);
+    test("abcdefghij", 0, 1, "abcde", -4);
+    test("abcdefghij", 0, 1, "abcdefghij", -9);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", -19);
+    test("abcdefghij", 0, 5, "", 5);
+    test("abcdefghij", 0, 5, "abcde", 0);
+    test("abcdefghij", 0, 5, "abcdefghij", -5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", -15);
+    test("abcdefghij", 0, 9, "", 9);
+    test("abcdefghij", 0, 9, "abcde", 4);
+    test("abcdefghij", 0, 9, "abcdefghij", -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", -11);
+    test("abcdefghij", 0, 10, "", 10);
+    test("abcdefghij", 0, 10, "abcde", 5);
+    test("abcdefghij", 0, 10, "abcdefghij", 0);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", -10);
+    test("abcdefghij", 0, 11, "", 10);
+    test("abcdefghij", 0, 11, "abcde", 5);
+    test("abcdefghij", 0, 11, "abcdefghij", 0);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", -10);
+    test("abcdefghij", 1, 0, "", 0);
+    test("abcdefghij", 1, 0, "abcde", -5);
+    test("abcdefghij", 1, 0, "abcdefghij", -10);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 1, 1, "", 1);
+    test("abcdefghij", 1, 1, "abcde", 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 4, "", 4);
+    test("abcdefghij", 1, 4, "abcde", 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 8, "", 8);
+    test("abcdefghij", 1, 8, "abcde", 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 9, "", 9);
+    test("abcdefghij", 1, 9, "abcde", 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 10, "", 9);
+    test("abcdefghij", 1, 10, "abcde", 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 5, 0, "", 0);
+    test("abcdefghij", 5, 0, "abcde", -5);
+    test("abcdefghij", 5, 0, "abcdefghij", -10);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 5, 1, "", 1);
+    test("abcdefghij", 5, 1, "abcde", 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 2, "", 2);
+    test("abcdefghij", 5, 2, "abcde", 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 4, "", 4);
+    test("abcdefghij", 5, 4, "abcde", 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 5, "", 5);
+    test("abcdefghij", 5, 5, "abcde", 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 6, "", 5);
+    test("abcdefghij", 5, 6, "abcde", 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 9, 0, "", 0);
+    test("abcdefghij", 9, 0, "abcde", -5);
+    test("abcdefghij", 9, 0, "abcdefghij", -10);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 9, 1, "", 1);
+    test("abcdefghij", 9, 1, "abcde", 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 9);
+    test("abcdefghij", 9, 2, "", 1);
+    test("abcdefghij", 9, 2, "abcde", 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 9);
+    test("abcdefghij", 10, 0, "", 0);
+    test("abcdefghij", 10, 0, "abcde", -5);
+    test("abcdefghij", 10, 0, "abcdefghij", -10);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 10, 1, "", 0);
+    test("abcdefghij", 10, 1, "abcde", -5);
+    test("abcdefghij", 10, 1, "abcdefghij", -10);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 11, 0, "", 0);
+    test("abcdefghij", 11, 0, "abcde", 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0);
+}
+
+void test2()
+{
+    test("abcdefghijklmnopqrst", 0, 0, "", 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 0, 1, "", 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", -19);
+    test("abcdefghijklmnopqrst", 0, 10, "", 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", -10);
+    test("abcdefghijklmnopqrst", 0, 19, "", 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 14);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", -1);
+    test("abcdefghijklmnopqrst", 0, 20, "", 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 15);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0);
+    test("abcdefghijklmnopqrst", 0, 21, "", 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 15);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0);
+    test("abcdefghijklmnopqrst", 1, 0, "", 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 1, 1, "", 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 9, "", 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 18, "", 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 19, "", 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 20, "", 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 10, 0, "", 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 10, 1, "", 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 5, "", 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 9, "", 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 19, 0, "", 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 19, 1, "", 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19);
+    test("abcdefghijklmnopqrst", 19, 2, "", 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19);
+    test("abcdefghijklmnopqrst", 20, 0, "", 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 20, 1, "", 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 21, 0, "", 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0);
+}
+
+
+int main()
+{
+    test0();
+    test1();
+    test2();
+
+    {
+    test("", 0, 0, "", 0);
+    test("", 0, 0, "abcde", -5);
+    test("", 0, 0, "abcdefghij", -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 0, 2, "", 5);
+    test("abcde", 0, 6,"abcde", 0);
+    test("abcde", 0, 6, "abcdefghij", -5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", -15);
+    test("abcdefghij", 3, 3, "", 10);
+    test("abcdefghij", 3, 3,"abcde", 5);
+    test("abcdefghij", 3, 3, "def", 0);
+    test("abcdefghij", 0, 4, "abcdefghijklmnopqrst", -10);
+    test("abcdefghijklmnopqrst", 5, 5, "", 20);
+    test("abcdefghijklmnopqrst", 0, 8, "abcde", 15);
+    test("abcdefghijklmnopqrst", 0, 12, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 0, -1, "abcdefghijklmnopqrst", 0);
+    }
+
+    {
+    test(L"", 0, 0, L"", 0);
+    test(L"", 0, 0, L"abcde", -5);
+    test(L"", 0, 0, L"abcdefghij", -10);
+    test(L"", 0, 0, L"abcdefghijklmnopqrst", -20);
+    test(L"abcde", 0, 2, L"", 5);
+    test(L"abcde", 0, 6, L"abcde", 0);
+    test(L"abcde", 0, 6, L"abcdefghij", -5);
+    test(L"abcde", 0, 6, L"abcdefghijklmnopqrst", -15);
+    test(L"abcdefghij", 3, 3, L"", 10);
+    test(L"abcdefghij", 3, 3, L"abcde", 5);
+    test(L"abcdefghij", 3, 3, L"def", 0);
+    test(L"abcdefghij", 0, 4, L"abcdefghijklmnopqrst", -10);
+    test(L"abcdefghijklmnopqrst", 5, 5, L"", 20);
+    test(L"abcdefghijklmnopqrst", 0, 8, L"abcde", 15);
+    test(L"abcdefghijklmnopqrst", 0, 12, L"abcdefghij", 10);
+    test(L"abcdefghijklmnopqrst", 0, -1, L"abcdefghijklmnopqrst", 0);
+    }
+
+#if __cplusplus >= 201103L
+    {
+    test(U"", 0, 0, U"", 0);
+    test(U"", 0, 0, U"abcde", -5);
+    test(U"", 0, 0, U"abcdefghij", -10);
+    test(U"", 0, 0, U"abcdefghijklmnopqrst", -20);
+    test(U"abcde", 0, 2, U"", 5);
+    test(U"abcde", 0, 6, U"abcde", 0);
+    test(U"abcde", 0, 6, U"abcdefghij", -5);
+    test(U"abcde", 0, 6, U"abcdefghijklmnopqrst", -15);
+    test(U"abcdefghij", 3, 3, U"", 10);
+    test(U"abcdefghij", 3, 3, U"abcde", 5);
+    test(U"abcdefghij", 3, 3, U"def", 0);
+    test(U"abcdefghij", 0, 4, U"abcdefghijklmnopqrst", -10);
+    test(U"abcdefghijklmnopqrst", 5, 5, U"", 20);
+    test(U"abcdefghijklmnopqrst", 0, 8, U"abcde", 15);
+    test(U"abcdefghijklmnopqrst", 0, 12, U"abcdefghij", 10);
+    test(U"abcdefghijklmnopqrst", 0, -1, U"abcdefghijklmnopqrst", 0);
+    }
+ 
+    {
+    test(u"", 0, 0, u"", 0);
+    test(u"", 0, 0, u"abcde", -5);
+    test(u"", 0, 0, u"abcdefghij", -10);
+    test(u"", 0, 0, u"abcdefghijklmnopqrst", -20);
+    test(u"abcde", 0, 2, u"", 5);
+    test(u"abcde", 0, 6, u"abcde", 0);
+    test(u"abcde", 0, 6, u"abcdefghij", -5);
+    test(u"abcde", 0, 6, u"abcdefghijklmnopqrst", -15);
+    test(u"abcdefghij", 3, 3, u"", 10);
+    test(u"abcdefghij", 3, 3, u"abcde", 5);
+    test(u"abcdefghij", 3, 3, u"def", 0);
+    test(u"abcdefghij", 0, 4, u"abcdefghijklmnopqrst", -10);
+    test(u"abcdefghijklmnopqrst", 5, 5, u"", 20);
+    test(u"abcdefghijklmnopqrst", 0, 8, u"abcde", 15);
+    test(u"abcdefghijklmnopqrst", 0, 12, u"abcdefghij", 10);
+    test(u"abcdefghijklmnopqrst", 0, -1, u"abcdefghijklmnopqrst", 0);
+    }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcde", 5 };
+    static_assert ( sv1.compare(0, 0, "") == 0, "" );
+    static_assert ( sv1.compare(0, 0, "abcde") == -1, "" );
+    static_assert ( sv2.compare(0, 2, "") == 1, "" );
+    static_assert ( sv2.compare(0, 6, "abcde") == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp b/final/test/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp
new file mode 100644
index 0000000..2047862
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp
@@ -0,0 +1,397 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
+            std::experimental::basic_string_view<CharT> sv2, int expected ) {
+
+    try
+    {
+        assert ( sign( sv1.compare(pos1, n1, sv2)) == sign(expected));
+        assert(pos1 <= sv1.size());
+    }
+    catch (const std::out_of_range&) { assert(pos1 > sv1.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, size_t pos1, size_t n1, const CharT  *s2, int expected ) {
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    
+    string_view_t sv1 ( s1 );
+    string_view_t sv2 ( s2 );
+    test1(sv1, pos1, n1, sv2, expected);
+}
+
+void test0()
+{
+    test("", 0, 0, "", 0);
+    test("", 0, 0, "abcde", -5);
+    test("", 0, 0, "abcdefghij", -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("", 0, 1, "", 0);
+    test("", 0, 1, "abcde", -5);
+    test("", 0, 1, "abcdefghij", -10);
+    test("", 0, 1, "abcdefghijklmnopqrst", -20);
+    test("", 1, 0, "", 0);
+    test("", 1, 0, "abcde", 0);
+    test("", 1, 0, "abcdefghij", 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0);
+    test("abcde", 0, 0, "", 0);
+    test("abcde", 0, 0, "abcde", -5);
+    test("abcde", 0, 0, "abcdefghij", -10);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 0, 1, "", 1);
+    test("abcde", 0, 1, "abcde", -4);
+    test("abcde", 0, 1, "abcdefghij", -9);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", -19);
+    test("abcde", 0, 2, "", 2);
+    test("abcde", 0, 2, "abcde", -3);
+    test("abcde", 0, 2, "abcdefghij", -8);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", -18);
+    test("abcde", 0, 4, "", 4);
+    test("abcde", 0, 4, "abcde", -1);
+    test("abcde", 0, 4, "abcdefghij", -6);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", -16);
+    test("abcde", 0, 5, "", 5);
+    test("abcde", 0, 5, "abcde", 0);
+    test("abcde", 0, 5, "abcdefghij", -5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", -15);
+    test("abcde", 0, 6, "", 5);
+    test("abcde", 0, 6, "abcde", 0);
+    test("abcde", 0, 6, "abcdefghij", -5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", -15);
+    test("abcde", 1, 0, "", 0);
+    test("abcde", 1, 0, "abcde", -5);
+    test("abcde", 1, 0, "abcdefghij", -10);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 1, 1, "", 1);
+    test("abcde", 1, 1, "abcde", 1);
+    test("abcde", 1, 1, "abcdefghij", 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 2, "", 2);
+    test("abcde", 1, 2, "abcde", 1);
+    test("abcde", 1, 2, "abcdefghij", 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 3, "", 3);
+    test("abcde", 1, 3, "abcde", 1);
+    test("abcde", 1, 3, "abcdefghij", 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 4, "", 4);
+    test("abcde", 1, 4, "abcde", 1);
+    test("abcde", 1, 4, "abcdefghij", 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1);
+    test("abcde", 1, 5, "", 4);
+    test("abcde", 1, 5, "abcde", 1);
+    test("abcde", 1, 5, "abcdefghij", 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1);
+    test("abcde", 2, 0, "", 0);
+    test("abcde", 2, 0, "abcde", -5);
+    test("abcde", 2, 0, "abcdefghij", -10);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 2, 1, "", 1);
+    test("abcde", 2, 1, "abcde", 2);
+    test("abcde", 2, 1, "abcdefghij", 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 2);
+    test("abcde", 2, 2, "", 2);
+    test("abcde", 2, 2, "abcde", 2);
+    test("abcde", 2, 2, "abcdefghij", 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 2);
+    test("abcde", 2, 3, "", 3);
+    test("abcde", 2, 3, "abcde", 2);
+    test("abcde", 2, 3, "abcdefghij", 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 2);
+    test("abcde", 2, 4, "", 3);
+    test("abcde", 2, 4, "abcde", 2);
+    test("abcde", 2, 4, "abcdefghij", 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 2);
+    test("abcde", 4, 0, "", 0);
+    test("abcde", 4, 0, "abcde", -5);
+    test("abcde", 4, 0, "abcdefghij", -10);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 4, 1, "", 1);
+    test("abcde", 4, 1, "abcde", 4);
+    test("abcde", 4, 1, "abcdefghij", 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 4);
+    test("abcde", 4, 2, "", 1);
+    test("abcde", 4, 2, "abcde", 4);
+    test("abcde", 4, 2, "abcdefghij", 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 4);
+    test("abcde", 5, 0, "", 0);
+    test("abcde", 5, 0, "abcde", -5);
+    test("abcde", 5, 0, "abcdefghij", -10);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", -20);
+    test("abcde", 5, 1, "", 0);
+    test("abcde", 5, 1, "abcde", -5);
+    test("abcde", 5, 1, "abcdefghij", -10);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", -20);
+}
+
+void test1()
+{
+    test("abcde", 6, 0, "", 0);
+    test("abcde", 6, 0, "abcde", 0);
+    test("abcde", 6, 0, "abcdefghij", 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0);
+    test("abcdefghij", 0, 0, "", 0);
+    test("abcdefghij", 0, 0, "abcde", -5);
+    test("abcdefghij", 0, 0, "abcdefghij", -10);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 0, 1, "", 1);
+    test("abcdefghij", 0, 1, "abcde", -4);
+    test("abcdefghij", 0, 1, "abcdefghij", -9);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", -19);
+    test("abcdefghij", 0, 5, "", 5);
+    test("abcdefghij", 0, 5, "abcde", 0);
+    test("abcdefghij", 0, 5, "abcdefghij", -5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", -15);
+    test("abcdefghij", 0, 9, "", 9);
+    test("abcdefghij", 0, 9, "abcde", 4);
+    test("abcdefghij", 0, 9, "abcdefghij", -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", -11);
+    test("abcdefghij", 0, 10, "", 10);
+    test("abcdefghij", 0, 10, "abcde", 5);
+    test("abcdefghij", 0, 10, "abcdefghij", 0);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", -10);
+    test("abcdefghij", 0, 11, "", 10);
+    test("abcdefghij", 0, 11, "abcde", 5);
+    test("abcdefghij", 0, 11, "abcdefghij", 0);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", -10);
+    test("abcdefghij", 1, 0, "", 0);
+    test("abcdefghij", 1, 0, "abcde", -5);
+    test("abcdefghij", 1, 0, "abcdefghij", -10);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 1, 1, "", 1);
+    test("abcdefghij", 1, 1, "abcde", 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 4, "", 4);
+    test("abcdefghij", 1, 4, "abcde", 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 8, "", 8);
+    test("abcdefghij", 1, 8, "abcde", 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 9, "", 9);
+    test("abcdefghij", 1, 9, "abcde", 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 1, 10, "", 9);
+    test("abcdefghij", 1, 10, "abcde", 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1);
+    test("abcdefghij", 5, 0, "", 0);
+    test("abcdefghij", 5, 0, "abcde", -5);
+    test("abcdefghij", 5, 0, "abcdefghij", -10);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 5, 1, "", 1);
+    test("abcdefghij", 5, 1, "abcde", 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 2, "", 2);
+    test("abcdefghij", 5, 2, "abcde", 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 4, "", 4);
+    test("abcdefghij", 5, 4, "abcde", 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 5, "", 5);
+    test("abcdefghij", 5, 5, "abcde", 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 5, 6, "", 5);
+    test("abcdefghij", 5, 6, "abcde", 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 5);
+    test("abcdefghij", 9, 0, "", 0);
+    test("abcdefghij", 9, 0, "abcde", -5);
+    test("abcdefghij", 9, 0, "abcdefghij", -10);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 9, 1, "", 1);
+    test("abcdefghij", 9, 1, "abcde", 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 9);
+    test("abcdefghij", 9, 2, "", 1);
+    test("abcdefghij", 9, 2, "abcde", 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 9);
+    test("abcdefghij", 10, 0, "", 0);
+    test("abcdefghij", 10, 0, "abcde", -5);
+    test("abcdefghij", 10, 0, "abcdefghij", -10);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 10, 1, "", 0);
+    test("abcdefghij", 10, 1, "abcde", -5);
+    test("abcdefghij", 10, 1, "abcdefghij", -10);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", -20);
+    test("abcdefghij", 11, 0, "", 0);
+    test("abcdefghij", 11, 0, "abcde", 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0);
+}
+
+void test2()
+{
+    test("abcdefghijklmnopqrst", 0, 0, "", 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 0, 1, "", 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", -19);
+    test("abcdefghijklmnopqrst", 0, 10, "", 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", -10);
+    test("abcdefghijklmnopqrst", 0, 19, "", 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 14);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", -1);
+    test("abcdefghijklmnopqrst", 0, 20, "", 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 15);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0);
+    test("abcdefghijklmnopqrst", 0, 21, "", 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 15);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0);
+    test("abcdefghijklmnopqrst", 1, 0, "", 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 1, 1, "", 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 9, "", 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 18, "", 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 19, "", 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 1, 20, "", 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1);
+    test("abcdefghijklmnopqrst", 10, 0, "", 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 10, 1, "", 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 5, "", 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 9, "", 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10);
+    test("abcdefghijklmnopqrst", 19, 0, "", 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 19, 1, "", 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19);
+    test("abcdefghijklmnopqrst", 19, 2, "", 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19);
+    test("abcdefghijklmnopqrst", 20, 0, "", 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 20, 1, "", 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", -20);
+    test("abcdefghijklmnopqrst", 21, 0, "", 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0);
+}
+
+
+int main () {
+    test0();
+    test1();
+    test2();
+    
+    {
+    test("abcde", 5, 1, "", 0);
+    test("abcde", 2, 4, "", 3);
+    test("abcde", 2, 4, "abcde", 2);
+    test("ABCde", 2, 4, "abcde", -1);
+    }
+
+    {
+    test(L"abcde", 5, 1, L"", 0);
+    test(L"abcde", 2, 4, L"", 3);
+    test(L"abcde", 2, 4, L"abcde", 2);
+    test(L"ABCde", 2, 4, L"abcde", -1);
+    }
+
+#if __cplusplus >= 201103L
+    {
+    test(u"abcde", 5, 1, u"", 0);
+    test(u"abcde", 2, 4, u"", 3);
+    test(u"abcde", 2, 4, u"abcde", 2);
+    test(u"ABCde", 2, 4, u"abcde", -1);
+    }
+
+    {
+    test(U"abcde", 5, 1, U"", 0);
+    test(U"abcde", 2, 4, U"", 3);
+    test(U"abcde", 2, 4, U"abcde", 2);
+    test(U"ABCde", 2, 4, U"abcde", -1);
+    }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1 { "abcde", 5 };
+    constexpr SV  sv2 { "abcde", 0 };
+    static_assert ( sv1.compare(5, 1, sv2) == 0, "" );
+    static_assert ( sv1.compare(2, 4, sv2) == 1, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp b/final/test/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp
new file mode 100644
index 0000000..acb48f5
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp
@@ -0,0 +1,1349 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1,
+//             const charT* s, size_type n2) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
+             const CharT *s2, size_t n2,
+             int expected ) {
+
+    try
+    {
+        assert ( sign( sv1.compare(pos1, n1, s2, n2)) == sign(expected));
+        assert(pos1 <= sv1.size());
+    }
+    catch (const std::out_of_range&) { assert(pos1 > sv1.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, size_t pos1, size_t n1, 
+            const CharT *s2, size_t n2, 
+            int expected ) {
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    
+    string_view_t sv1 ( s1 );
+    test1 (sv1, pos1, n1, s2, n2, expected);
+}
+
+
+void test0()
+{
+    test("", 0, 0, "", 0, 0);
+    test("", 0, 0, "abcde", 0, 0);
+    test("", 0, 0, "abcde", 1, -1);
+    test("", 0, 0, "abcde", 2, -2);
+    test("", 0, 0, "abcde", 4, -4);
+    test("", 0, 0, "abcde", 5, -5);
+    test("", 0, 0, "abcdefghij", 0, 0);
+    test("", 0, 0, "abcdefghij", 1, -1);
+    test("", 0, 0, "abcdefghij", 5, -5);
+    test("", 0, 0, "abcdefghij", 9, -9);
+    test("", 0, 0, "abcdefghij", 10, -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("", 0, 1, "", 0, 0);
+    test("", 0, 1, "abcde", 0, 0);
+    test("", 0, 1, "abcde", 1, -1);
+    test("", 0, 1, "abcde", 2, -2);
+    test("", 0, 1, "abcde", 4, -4);
+    test("", 0, 1, "abcde", 5, -5);
+    test("", 0, 1, "abcdefghij", 0, 0);
+    test("", 0, 1, "abcdefghij", 1, -1);
+    test("", 0, 1, "abcdefghij", 5, -5);
+    test("", 0, 1, "abcdefghij", 9, -9);
+    test("", 0, 1, "abcdefghij", 10, -10);
+    test("", 0, 1, "abcdefghijklmnopqrst", 0, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 1, -1);
+    test("", 0, 1, "abcdefghijklmnopqrst", 10, -10);
+    test("", 0, 1, "abcdefghijklmnopqrst", 19, -19);
+    test("", 0, 1, "abcdefghijklmnopqrst", 20, -20);
+    test("", 1, 0, "", 0, 0);
+    test("", 1, 0, "abcde", 0, 0);
+    test("", 1, 0, "abcde", 1, 0);
+    test("", 1, 0, "abcde", 2, 0);
+    test("", 1, 0, "abcde", 4, 0);
+    test("", 1, 0, "abcde", 5, 0);
+    test("", 1, 0, "abcdefghij", 0, 0);
+    test("", 1, 0, "abcdefghij", 1, 0);
+    test("", 1, 0, "abcdefghij", 5, 0);
+    test("", 1, 0, "abcdefghij", 9, 0);
+    test("", 1, 0, "abcdefghij", 10, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 1, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 10, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 19, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 20, 0);
+    test("abcde", 0, 0, "", 0, 0);
+    test("abcde", 0, 0, "abcde", 0, 0);
+    test("abcde", 0, 0, "abcde", 1, -1);
+    test("abcde", 0, 0, "abcde", 2, -2);
+    test("abcde", 0, 0, "abcde", 4, -4);
+    test("abcde", 0, 0, "abcde", 5, -5);
+    test("abcde", 0, 0, "abcdefghij", 0, 0);
+    test("abcde", 0, 0, "abcdefghij", 1, -1);
+    test("abcde", 0, 0, "abcdefghij", 5, -5);
+    test("abcde", 0, 0, "abcdefghij", 9, -9);
+    test("abcde", 0, 0, "abcdefghij", 10, -10);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcde", 0, 1, "", 0, 1);
+    test("abcde", 0, 1, "abcde", 0, 1);
+    test("abcde", 0, 1, "abcde", 1, 0);
+    test("abcde", 0, 1, "abcde", 2, -1);
+    test("abcde", 0, 1, "abcde", 4, -3);
+    test("abcde", 0, 1, "abcde", 5, -4);
+    test("abcde", 0, 1, "abcdefghij", 0, 1);
+    test("abcde", 0, 1, "abcdefghij", 1, 0);
+    test("abcde", 0, 1, "abcdefghij", 5, -4);
+    test("abcde", 0, 1, "abcdefghij", 9, -8);
+    test("abcde", 0, 1, "abcdefghij", 10, -9);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test("abcde", 0, 2, "", 0, 2);
+    test("abcde", 0, 2, "abcde", 0, 2);
+    test("abcde", 0, 2, "abcde", 1, 1);
+    test("abcde", 0, 2, "abcde", 2, 0);
+    test("abcde", 0, 2, "abcde", 4, -2);
+    test("abcde", 0, 2, "abcde", 5, -3);
+    test("abcde", 0, 2, "abcdefghij", 0, 2);
+    test("abcde", 0, 2, "abcdefghij", 1, 1);
+    test("abcde", 0, 2, "abcdefghij", 5, -3);
+    test("abcde", 0, 2, "abcdefghij", 9, -7);
+    test("abcde", 0, 2, "abcdefghij", 10, -8);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 2);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 1);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, -8);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, -17);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 20, -18);
+    test("abcde", 0, 4, "", 0, 4);
+    test("abcde", 0, 4, "abcde", 0, 4);
+    test("abcde", 0, 4, "abcde", 1, 3);
+    test("abcde", 0, 4, "abcde", 2, 2);
+}
+
+
+void test1()
+{
+    test("abcde", 0, 4, "abcde", 4, 0);
+    test("abcde", 0, 4, "abcde", 5, -1);
+    test("abcde", 0, 4, "abcdefghij", 0, 4);
+    test("abcde", 0, 4, "abcdefghij", 1, 3);
+    test("abcde", 0, 4, "abcdefghij", 5, -1);
+    test("abcde", 0, 4, "abcdefghij", 9, -5);
+    test("abcde", 0, 4, "abcdefghij", 10, -6);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 4);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 3);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, -6);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, -15);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 20, -16);
+    test("abcde", 0, 5, "", 0, 5);
+    test("abcde", 0, 5, "abcde", 0, 5);
+    test("abcde", 0, 5, "abcde", 1, 4);
+    test("abcde", 0, 5, "abcde", 2, 3);
+    test("abcde", 0, 5, "abcde", 4, 1);
+    test("abcde", 0, 5, "abcde", 5, 0);
+    test("abcde", 0, 5, "abcdefghij", 0, 5);
+    test("abcde", 0, 5, "abcdefghij", 1, 4);
+    test("abcde", 0, 5, "abcdefghij", 5, 0);
+    test("abcde", 0, 5, "abcdefghij", 9, -4);
+    test("abcde", 0, 5, "abcdefghij", 10, -5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 4);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, -5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, -14);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 20, -15);
+    test("abcde", 0, 6, "", 0, 5);
+    test("abcde", 0, 6, "abcde", 0, 5);
+    test("abcde", 0, 6, "abcde", 1, 4);
+    test("abcde", 0, 6, "abcde", 2, 3);
+    test("abcde", 0, 6, "abcde", 4, 1);
+    test("abcde", 0, 6, "abcde", 5, 0);
+    test("abcde", 0, 6, "abcdefghij", 0, 5);
+    test("abcde", 0, 6, "abcdefghij", 1, 4);
+    test("abcde", 0, 6, "abcdefghij", 5, 0);
+    test("abcde", 0, 6, "abcdefghij", 9, -4);
+    test("abcde", 0, 6, "abcdefghij", 10, -5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 4);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, -5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, -14);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 20, -15);
+    test("abcde", 1, 0, "", 0, 0);
+    test("abcde", 1, 0, "abcde", 0, 0);
+    test("abcde", 1, 0, "abcde", 1, -1);
+    test("abcde", 1, 0, "abcde", 2, -2);
+    test("abcde", 1, 0, "abcde", 4, -4);
+    test("abcde", 1, 0, "abcde", 5, -5);
+    test("abcde", 1, 0, "abcdefghij", 0, 0);
+    test("abcde", 1, 0, "abcdefghij", 1, -1);
+    test("abcde", 1, 0, "abcdefghij", 5, -5);
+    test("abcde", 1, 0, "abcdefghij", 9, -9);
+    test("abcde", 1, 0, "abcdefghij", 10, -10);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcde", 1, 1, "", 0, 1);
+    test("abcde", 1, 1, "abcde", 0, 1);
+    test("abcde", 1, 1, "abcde", 1, 1);
+    test("abcde", 1, 1, "abcde", 2, 1);
+    test("abcde", 1, 1, "abcde", 4, 1);
+    test("abcde", 1, 1, "abcde", 5, 1);
+    test("abcde", 1, 1, "abcdefghij", 0, 1);
+    test("abcde", 1, 1, "abcdefghij", 1, 1);
+    test("abcde", 1, 1, "abcdefghij", 5, 1);
+    test("abcde", 1, 1, "abcdefghij", 9, 1);
+    test("abcde", 1, 1, "abcdefghij", 10, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test("abcde", 1, 2, "", 0, 2);
+    test("abcde", 1, 2, "abcde", 0, 2);
+    test("abcde", 1, 2, "abcde", 1, 1);
+    test("abcde", 1, 2, "abcde", 2, 1);
+    test("abcde", 1, 2, "abcde", 4, 1);
+    test("abcde", 1, 2, "abcde", 5, 1);
+    test("abcde", 1, 2, "abcdefghij", 0, 2);
+    test("abcde", 1, 2, "abcdefghij", 1, 1);
+    test("abcde", 1, 2, "abcdefghij", 5, 1);
+    test("abcde", 1, 2, "abcdefghij", 9, 1);
+    test("abcde", 1, 2, "abcdefghij", 10, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 2);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 20, 1);
+    test("abcde", 1, 3, "", 0, 3);
+    test("abcde", 1, 3, "abcde", 0, 3);
+    test("abcde", 1, 3, "abcde", 1, 1);
+    test("abcde", 1, 3, "abcde", 2, 1);
+    test("abcde", 1, 3, "abcde", 4, 1);
+    test("abcde", 1, 3, "abcde", 5, 1);
+    test("abcde", 1, 3, "abcdefghij", 0, 3);
+    test("abcde", 1, 3, "abcdefghij", 1, 1);
+}
+
+
+void test2()
+{
+    test("abcde", 1, 3, "abcdefghij", 5, 1);
+    test("abcde", 1, 3, "abcdefghij", 9, 1);
+    test("abcde", 1, 3, "abcdefghij", 10, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 3);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 20, 1);
+    test("abcde", 1, 4, "", 0, 4);
+    test("abcde", 1, 4, "abcde", 0, 4);
+    test("abcde", 1, 4, "abcde", 1, 1);
+    test("abcde", 1, 4, "abcde", 2, 1);
+    test("abcde", 1, 4, "abcde", 4, 1);
+    test("abcde", 1, 4, "abcde", 5, 1);
+    test("abcde", 1, 4, "abcdefghij", 0, 4);
+    test("abcde", 1, 4, "abcdefghij", 1, 1);
+    test("abcde", 1, 4, "abcdefghij", 5, 1);
+    test("abcde", 1, 4, "abcdefghij", 9, 1);
+    test("abcde", 1, 4, "abcdefghij", 10, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 4);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 20, 1);
+    test("abcde", 1, 5, "", 0, 4);
+    test("abcde", 1, 5, "abcde", 0, 4);
+    test("abcde", 1, 5, "abcde", 1, 1);
+    test("abcde", 1, 5, "abcde", 2, 1);
+    test("abcde", 1, 5, "abcde", 4, 1);
+    test("abcde", 1, 5, "abcde", 5, 1);
+    test("abcde", 1, 5, "abcdefghij", 0, 4);
+    test("abcde", 1, 5, "abcdefghij", 1, 1);
+    test("abcde", 1, 5, "abcdefghij", 5, 1);
+    test("abcde", 1, 5, "abcdefghij", 9, 1);
+    test("abcde", 1, 5, "abcdefghij", 10, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 4);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 20, 1);
+    test("abcde", 2, 0, "", 0, 0);
+    test("abcde", 2, 0, "abcde", 0, 0);
+    test("abcde", 2, 0, "abcde", 1, -1);
+    test("abcde", 2, 0, "abcde", 2, -2);
+    test("abcde", 2, 0, "abcde", 4, -4);
+    test("abcde", 2, 0, "abcde", 5, -5);
+    test("abcde", 2, 0, "abcdefghij", 0, 0);
+    test("abcde", 2, 0, "abcdefghij", 1, -1);
+    test("abcde", 2, 0, "abcdefghij", 5, -5);
+    test("abcde", 2, 0, "abcdefghij", 9, -9);
+    test("abcde", 2, 0, "abcdefghij", 10, -10);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcde", 2, 1, "", 0, 1);
+    test("abcde", 2, 1, "abcde", 0, 1);
+    test("abcde", 2, 1, "abcde", 1, 2);
+    test("abcde", 2, 1, "abcde", 2, 2);
+    test("abcde", 2, 1, "abcde", 4, 2);
+    test("abcde", 2, 1, "abcde", 5, 2);
+    test("abcde", 2, 1, "abcdefghij", 0, 1);
+    test("abcde", 2, 1, "abcdefghij", 1, 2);
+    test("abcde", 2, 1, "abcdefghij", 5, 2);
+    test("abcde", 2, 1, "abcdefghij", 9, 2);
+    test("abcde", 2, 1, "abcdefghij", 10, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 20, 2);
+    test("abcde", 2, 2, "", 0, 2);
+    test("abcde", 2, 2, "abcde", 0, 2);
+    test("abcde", 2, 2, "abcde", 1, 2);
+    test("abcde", 2, 2, "abcde", 2, 2);
+    test("abcde", 2, 2, "abcde", 4, 2);
+    test("abcde", 2, 2, "abcde", 5, 2);
+    test("abcde", 2, 2, "abcdefghij", 0, 2);
+    test("abcde", 2, 2, "abcdefghij", 1, 2);
+    test("abcde", 2, 2, "abcdefghij", 5, 2);
+    test("abcde", 2, 2, "abcdefghij", 9, 2);
+    test("abcde", 2, 2, "abcdefghij", 10, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 20, 2);
+    test("abcde", 2, 3, "", 0, 3);
+    test("abcde", 2, 3, "abcde", 0, 3);
+    test("abcde", 2, 3, "abcde", 1, 2);
+    test("abcde", 2, 3, "abcde", 2, 2);
+    test("abcde", 2, 3, "abcde", 4, 2);
+    test("abcde", 2, 3, "abcde", 5, 2);
+    test("abcde", 2, 3, "abcdefghij", 0, 3);
+    test("abcde", 2, 3, "abcdefghij", 1, 2);
+    test("abcde", 2, 3, "abcdefghij", 5, 2);
+    test("abcde", 2, 3, "abcdefghij", 9, 2);
+    test("abcde", 2, 3, "abcdefghij", 10, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 3);
+}
+
+
+void test3()
+{
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 20, 2);
+    test("abcde", 2, 4, "", 0, 3);
+    test("abcde", 2, 4, "abcde", 0, 3);
+    test("abcde", 2, 4, "abcde", 1, 2);
+    test("abcde", 2, 4, "abcde", 2, 2);
+    test("abcde", 2, 4, "abcde", 4, 2);
+    test("abcde", 2, 4, "abcde", 5, 2);
+    test("abcde", 2, 4, "abcdefghij", 0, 3);
+    test("abcde", 2, 4, "abcdefghij", 1, 2);
+    test("abcde", 2, 4, "abcdefghij", 5, 2);
+    test("abcde", 2, 4, "abcdefghij", 9, 2);
+    test("abcde", 2, 4, "abcdefghij", 10, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 3);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 20, 2);
+    test("abcde", 4, 0, "", 0, 0);
+    test("abcde", 4, 0, "abcde", 0, 0);
+    test("abcde", 4, 0, "abcde", 1, -1);
+    test("abcde", 4, 0, "abcde", 2, -2);
+    test("abcde", 4, 0, "abcde", 4, -4);
+    test("abcde", 4, 0, "abcde", 5, -5);
+    test("abcde", 4, 0, "abcdefghij", 0, 0);
+    test("abcde", 4, 0, "abcdefghij", 1, -1);
+    test("abcde", 4, 0, "abcdefghij", 5, -5);
+    test("abcde", 4, 0, "abcdefghij", 9, -9);
+    test("abcde", 4, 0, "abcdefghij", 10, -10);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcde", 4, 1, "", 0, 1);
+    test("abcde", 4, 1, "abcde", 0, 1);
+    test("abcde", 4, 1, "abcde", 1, 4);
+    test("abcde", 4, 1, "abcde", 2, 4);
+    test("abcde", 4, 1, "abcde", 4, 4);
+    test("abcde", 4, 1, "abcde", 5, 4);
+    test("abcde", 4, 1, "abcdefghij", 0, 1);
+    test("abcde", 4, 1, "abcdefghij", 1, 4);
+    test("abcde", 4, 1, "abcdefghij", 5, 4);
+    test("abcde", 4, 1, "abcdefghij", 9, 4);
+    test("abcde", 4, 1, "abcdefghij", 10, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 20, 4);
+    test("abcde", 4, 2, "", 0, 1);
+    test("abcde", 4, 2, "abcde", 0, 1);
+    test("abcde", 4, 2, "abcde", 1, 4);
+    test("abcde", 4, 2, "abcde", 2, 4);
+    test("abcde", 4, 2, "abcde", 4, 4);
+    test("abcde", 4, 2, "abcde", 5, 4);
+    test("abcde", 4, 2, "abcdefghij", 0, 1);
+    test("abcde", 4, 2, "abcdefghij", 1, 4);
+    test("abcde", 4, 2, "abcdefghij", 5, 4);
+    test("abcde", 4, 2, "abcdefghij", 9, 4);
+    test("abcde", 4, 2, "abcdefghij", 10, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 1);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 20, 4);
+    test("abcde", 5, 0, "", 0, 0);
+    test("abcde", 5, 0, "abcde", 0, 0);
+    test("abcde", 5, 0, "abcde", 1, -1);
+    test("abcde", 5, 0, "abcde", 2, -2);
+    test("abcde", 5, 0, "abcde", 4, -4);
+    test("abcde", 5, 0, "abcde", 5, -5);
+    test("abcde", 5, 0, "abcdefghij", 0, 0);
+    test("abcde", 5, 0, "abcdefghij", 1, -1);
+    test("abcde", 5, 0, "abcdefghij", 5, -5);
+    test("abcde", 5, 0, "abcdefghij", 9, -9);
+    test("abcde", 5, 0, "abcdefghij", 10, -10);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcde", 5, 1, "", 0, 0);
+    test("abcde", 5, 1, "abcde", 0, 0);
+    test("abcde", 5, 1, "abcde", 1, -1);
+    test("abcde", 5, 1, "abcde", 2, -2);
+    test("abcde", 5, 1, "abcde", 4, -4);
+    test("abcde", 5, 1, "abcde", 5, -5);
+    test("abcde", 5, 1, "abcdefghij", 0, 0);
+    test("abcde", 5, 1, "abcdefghij", 1, -1);
+    test("abcde", 5, 1, "abcdefghij", 5, -5);
+    test("abcde", 5, 1, "abcdefghij", 9, -9);
+    test("abcde", 5, 1, "abcdefghij", 10, -10);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, -1);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, -10);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, -19);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 20, -20);
+}
+
+
+void test4()
+{
+    test("abcde", 6, 0, "", 0, 0);
+    test("abcde", 6, 0, "abcde", 0, 0);
+    test("abcde", 6, 0, "abcde", 1, 0);
+    test("abcde", 6, 0, "abcde", 2, 0);
+    test("abcde", 6, 0, "abcde", 4, 0);
+    test("abcde", 6, 0, "abcde", 5, 0);
+    test("abcde", 6, 0, "abcdefghij", 0, 0);
+    test("abcde", 6, 0, "abcdefghij", 1, 0);
+    test("abcde", 6, 0, "abcdefghij", 5, 0);
+    test("abcde", 6, 0, "abcdefghij", 9, 0);
+    test("abcde", 6, 0, "abcdefghij", 10, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 20, 0);
+    test("abcdefghij", 0, 0, "", 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 1, -1);
+    test("abcdefghij", 0, 0, "abcde", 2, -2);
+    test("abcdefghij", 0, 0, "abcde", 4, -4);
+    test("abcdefghij", 0, 0, "abcde", 5, -5);
+    test("abcdefghij", 0, 0, "abcdefghij", 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghij", 5, -5);
+    test("abcdefghij", 0, 0, "abcdefghij", 9, -9);
+    test("abcdefghij", 0, 0, "abcdefghij", 10, -10);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghij", 0, 1, "", 0, 1);
+    test("abcdefghij", 0, 1, "abcde", 0, 1);
+    test("abcdefghij", 0, 1, "abcde", 1, 0);
+    test("abcdefghij", 0, 1, "abcde", 2, -1);
+    test("abcdefghij", 0, 1, "abcde", 4, -3);
+    test("abcdefghij", 0, 1, "abcde", 5, -4);
+    test("abcdefghij", 0, 1, "abcdefghij", 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghij", 1, 0);
+    test("abcdefghij", 0, 1, "abcdefghij", 5, -4);
+    test("abcdefghij", 0, 1, "abcdefghij", 9, -8);
+    test("abcdefghij", 0, 1, "abcdefghij", 10, -9);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test("abcdefghij", 0, 5, "", 0, 5);
+    test("abcdefghij", 0, 5, "abcde", 0, 5);
+    test("abcdefghij", 0, 5, "abcde", 1, 4);
+    test("abcdefghij", 0, 5, "abcde", 2, 3);
+    test("abcdefghij", 0, 5, "abcde", 4, 1);
+    test("abcdefghij", 0, 5, "abcde", 5, 0);
+    test("abcdefghij", 0, 5, "abcdefghij", 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghij", 1, 4);
+    test("abcdefghij", 0, 5, "abcdefghij", 5, 0);
+    test("abcdefghij", 0, 5, "abcdefghij", 9, -4);
+    test("abcdefghij", 0, 5, "abcdefghij", 10, -5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 4);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, -5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, -14);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 20, -15);
+    test("abcdefghij", 0, 9, "", 0, 9);
+    test("abcdefghij", 0, 9, "abcde", 0, 9);
+    test("abcdefghij", 0, 9, "abcde", 1, 8);
+    test("abcdefghij", 0, 9, "abcde", 2, 7);
+    test("abcdefghij", 0, 9, "abcde", 4, 5);
+    test("abcdefghij", 0, 9, "abcde", 5, 4);
+    test("abcdefghij", 0, 9, "abcdefghij", 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghij", 1, 8);
+    test("abcdefghij", 0, 9, "abcdefghij", 5, 4);
+    test("abcdefghij", 0, 9, "abcdefghij", 9, 0);
+    test("abcdefghij", 0, 9, "abcdefghij", 10, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 8);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, -10);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 20, -11);
+    test("abcdefghij", 0, 10, "", 0, 10);
+    test("abcdefghij", 0, 10, "abcde", 0, 10);
+    test("abcdefghij", 0, 10, "abcde", 1, 9);
+    test("abcdefghij", 0, 10, "abcde", 2, 8);
+    test("abcdefghij", 0, 10, "abcde", 4, 6);
+    test("abcdefghij", 0, 10, "abcde", 5, 5);
+    test("abcdefghij", 0, 10, "abcdefghij", 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghij", 1, 9);
+    test("abcdefghij", 0, 10, "abcdefghij", 5, 5);
+    test("abcdefghij", 0, 10, "abcdefghij", 9, 1);
+    test("abcdefghij", 0, 10, "abcdefghij", 10, 0);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 9);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 0);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, -9);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 20, -10);
+    test("abcdefghij", 0, 11, "", 0, 10);
+    test("abcdefghij", 0, 11, "abcde", 0, 10);
+    test("abcdefghij", 0, 11, "abcde", 1, 9);
+    test("abcdefghij", 0, 11, "abcde", 2, 8);
+}
+
+
+void test5()
+{
+    test("abcdefghij", 0, 11, "abcde", 4, 6);
+    test("abcdefghij", 0, 11, "abcde", 5, 5);
+    test("abcdefghij", 0, 11, "abcdefghij", 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghij", 1, 9);
+    test("abcdefghij", 0, 11, "abcdefghij", 5, 5);
+    test("abcdefghij", 0, 11, "abcdefghij", 9, 1);
+    test("abcdefghij", 0, 11, "abcdefghij", 10, 0);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 9);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 0);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, -9);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 20, -10);
+    test("abcdefghij", 1, 0, "", 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 1, -1);
+    test("abcdefghij", 1, 0, "abcde", 2, -2);
+    test("abcdefghij", 1, 0, "abcde", 4, -4);
+    test("abcdefghij", 1, 0, "abcde", 5, -5);
+    test("abcdefghij", 1, 0, "abcdefghij", 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghij", 5, -5);
+    test("abcdefghij", 1, 0, "abcdefghij", 9, -9);
+    test("abcdefghij", 1, 0, "abcdefghij", 10, -10);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghij", 1, 1, "", 0, 1);
+    test("abcdefghij", 1, 1, "abcde", 0, 1);
+    test("abcdefghij", 1, 1, "abcde", 1, 1);
+    test("abcdefghij", 1, 1, "abcde", 2, 1);
+    test("abcdefghij", 1, 1, "abcde", 4, 1);
+    test("abcdefghij", 1, 1, "abcde", 5, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 1, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 5, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 9, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 10, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghij", 1, 4, "", 0, 4);
+    test("abcdefghij", 1, 4, "abcde", 0, 4);
+    test("abcdefghij", 1, 4, "abcde", 1, 1);
+    test("abcdefghij", 1, 4, "abcde", 2, 1);
+    test("abcdefghij", 1, 4, "abcde", 4, 1);
+    test("abcdefghij", 1, 4, "abcde", 5, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghij", 1, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 5, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 9, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 10, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghij", 1, 8, "", 0, 8);
+    test("abcdefghij", 1, 8, "abcde", 0, 8);
+    test("abcdefghij", 1, 8, "abcde", 1, 1);
+    test("abcdefghij", 1, 8, "abcde", 2, 1);
+    test("abcdefghij", 1, 8, "abcde", 4, 1);
+    test("abcdefghij", 1, 8, "abcde", 5, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghij", 1, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 5, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 9, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 10, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghij", 1, 9, "", 0, 9);
+    test("abcdefghij", 1, 9, "abcde", 0, 9);
+    test("abcdefghij", 1, 9, "abcde", 1, 1);
+    test("abcdefghij", 1, 9, "abcde", 2, 1);
+    test("abcdefghij", 1, 9, "abcde", 4, 1);
+    test("abcdefghij", 1, 9, "abcde", 5, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghij", 1, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 5, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 9, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 10, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghij", 1, 10, "", 0, 9);
+    test("abcdefghij", 1, 10, "abcde", 0, 9);
+    test("abcdefghij", 1, 10, "abcde", 1, 1);
+    test("abcdefghij", 1, 10, "abcde", 2, 1);
+    test("abcdefghij", 1, 10, "abcde", 4, 1);
+    test("abcdefghij", 1, 10, "abcde", 5, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghij", 1, 1);
+}
+
+
+void test6()
+{
+    test("abcdefghij", 1, 10, "abcdefghij", 5, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 9, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 10, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghij", 5, 0, "", 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 1, -1);
+    test("abcdefghij", 5, 0, "abcde", 2, -2);
+    test("abcdefghij", 5, 0, "abcde", 4, -4);
+    test("abcdefghij", 5, 0, "abcde", 5, -5);
+    test("abcdefghij", 5, 0, "abcdefghij", 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghij", 5, -5);
+    test("abcdefghij", 5, 0, "abcdefghij", 9, -9);
+    test("abcdefghij", 5, 0, "abcdefghij", 10, -10);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghij", 5, 1, "", 0, 1);
+    test("abcdefghij", 5, 1, "abcde", 0, 1);
+    test("abcdefghij", 5, 1, "abcde", 1, 5);
+    test("abcdefghij", 5, 1, "abcde", 2, 5);
+    test("abcdefghij", 5, 1, "abcde", 4, 5);
+    test("abcdefghij", 5, 1, "abcde", 5, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghij", 1, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 5, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 9, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 10, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 20, 5);
+    test("abcdefghij", 5, 2, "", 0, 2);
+    test("abcdefghij", 5, 2, "abcde", 0, 2);
+    test("abcdefghij", 5, 2, "abcde", 1, 5);
+    test("abcdefghij", 5, 2, "abcde", 2, 5);
+    test("abcdefghij", 5, 2, "abcde", 4, 5);
+    test("abcdefghij", 5, 2, "abcde", 5, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghij", 1, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 5, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 9, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 10, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 20, 5);
+    test("abcdefghij", 5, 4, "", 0, 4);
+    test("abcdefghij", 5, 4, "abcde", 0, 4);
+    test("abcdefghij", 5, 4, "abcde", 1, 5);
+    test("abcdefghij", 5, 4, "abcde", 2, 5);
+    test("abcdefghij", 5, 4, "abcde", 4, 5);
+    test("abcdefghij", 5, 4, "abcde", 5, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 1, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 5, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 9, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 10, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 20, 5);
+    test("abcdefghij", 5, 5, "", 0, 5);
+    test("abcdefghij", 5, 5, "abcde", 0, 5);
+    test("abcdefghij", 5, 5, "abcde", 1, 5);
+    test("abcdefghij", 5, 5, "abcde", 2, 5);
+    test("abcdefghij", 5, 5, "abcde", 4, 5);
+    test("abcdefghij", 5, 5, "abcde", 5, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 1, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 5, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 9, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 10, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 20, 5);
+    test("abcdefghij", 5, 6, "", 0, 5);
+    test("abcdefghij", 5, 6, "abcde", 0, 5);
+    test("abcdefghij", 5, 6, "abcde", 1, 5);
+    test("abcdefghij", 5, 6, "abcde", 2, 5);
+    test("abcdefghij", 5, 6, "abcde", 4, 5);
+    test("abcdefghij", 5, 6, "abcde", 5, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 1, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 5, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 9, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 10, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 5);
+}
+
+
+void test7()
+{
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 20, 5);
+    test("abcdefghij", 9, 0, "", 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 1, -1);
+    test("abcdefghij", 9, 0, "abcde", 2, -2);
+    test("abcdefghij", 9, 0, "abcde", 4, -4);
+    test("abcdefghij", 9, 0, "abcde", 5, -5);
+    test("abcdefghij", 9, 0, "abcdefghij", 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghij", 5, -5);
+    test("abcdefghij", 9, 0, "abcdefghij", 9, -9);
+    test("abcdefghij", 9, 0, "abcdefghij", 10, -10);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghij", 9, 1, "", 0, 1);
+    test("abcdefghij", 9, 1, "abcde", 0, 1);
+    test("abcdefghij", 9, 1, "abcde", 1, 9);
+    test("abcdefghij", 9, 1, "abcde", 2, 9);
+    test("abcdefghij", 9, 1, "abcde", 4, 9);
+    test("abcdefghij", 9, 1, "abcde", 5, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghij", 1, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 5, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 9, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 10, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 20, 9);
+    test("abcdefghij", 9, 2, "", 0, 1);
+    test("abcdefghij", 9, 2, "abcde", 0, 1);
+    test("abcdefghij", 9, 2, "abcde", 1, 9);
+    test("abcdefghij", 9, 2, "abcde", 2, 9);
+    test("abcdefghij", 9, 2, "abcde", 4, 9);
+    test("abcdefghij", 9, 2, "abcde", 5, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghij", 1, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 5, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 9, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 10, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 20, 9);
+    test("abcdefghij", 10, 0, "", 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 1, -1);
+    test("abcdefghij", 10, 0, "abcde", 2, -2);
+    test("abcdefghij", 10, 0, "abcde", 4, -4);
+    test("abcdefghij", 10, 0, "abcde", 5, -5);
+    test("abcdefghij", 10, 0, "abcdefghij", 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghij", 5, -5);
+    test("abcdefghij", 10, 0, "abcdefghij", 9, -9);
+    test("abcdefghij", 10, 0, "abcdefghij", 10, -10);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghij", 10, 1, "", 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 1, -1);
+    test("abcdefghij", 10, 1, "abcde", 2, -2);
+    test("abcdefghij", 10, 1, "abcde", 4, -4);
+    test("abcdefghij", 10, 1, "abcde", 5, -5);
+    test("abcdefghij", 10, 1, "abcdefghij", 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghij", 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghij", 5, -5);
+    test("abcdefghij", 10, 1, "abcdefghij", 9, -9);
+    test("abcdefghij", 10, 1, "abcdefghij", 10, -10);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghij", 11, 0, "", 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 1, 0);
+    test("abcdefghij", 11, 0, "abcde", 2, 0);
+    test("abcdefghij", 11, 0, "abcde", 4, 0);
+    test("abcdefghij", 11, 0, "abcde", 5, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 5, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 9, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 10, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+void test8()
+{
+    test("abcdefghijklmnopqrst", 0, 0, "", 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, -2);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, -4);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 5, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, -9);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 10, -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghijklmnopqrst", 0, 1, "", 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, -3);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 5, -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, -8);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 10, -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test("abcdefghijklmnopqrst", 0, 10, "", 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 8);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 6);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 5, 5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 10, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, -9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 20, -10);
+    test("abcdefghijklmnopqrst", 0, 19, "", 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 18);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 17);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 15);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 5, 14);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 18);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 14);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 10);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 10, 9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 18);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 0);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 20, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 18);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 16);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 5, 15);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 15);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 11);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10, 10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 20, 0);
+    test("abcdefghijklmnopqrst", 0, 21, "", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 18);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 16);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 5, 15);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 15);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 11);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10, 10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 20, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "", 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, -2);
+}
+
+
+void test9()
+{
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, -4);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 5, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, -9);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 10, -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghijklmnopqrst", 1, 1, "", 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "", 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "", 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 20, 1);
+    test("abcdefghijklmnopqrst", 10, 0, "", 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, -2);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, -4);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 5, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, -1);
+}
+
+
+void test10()
+{
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, -9);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghijklmnopqrst", 10, 1, "", 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 20, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "", 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 20, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "", 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 20, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 20, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 20, 10);
+    test("abcdefghijklmnopqrst", 19, 0, "", 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, -2);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, -4);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 5, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, -9);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 10, -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 0);
+}
+
+
+void test11()
+{
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghijklmnopqrst", 19, 1, "", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 5, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 10, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 20, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 5, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 10, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 20, 19);
+    test("abcdefghijklmnopqrst", 20, 0, "", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, -2);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, -4);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 5, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, -9);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 10, -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghijklmnopqrst", 20, 1, "", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, -2);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, -4);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 5, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, -9);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 10, -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, -19);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 20, -20);
+    test("abcdefghijklmnopqrst", 21, 0, "", 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 5, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 10, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 20, 0);
+    }
+
+
+int main () {
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+    
+    {
+    test("", 0, 0, "abcde", 0, 0);
+    test("", 0, 0, "abcde", 1, -1);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, -10);
+    }
+
+    {
+    test(L"", 0, 0, L"abcde", 0, 0);
+    test(L"", 0, 0, L"abcde", 1, -1);
+    test(L"abcdefghijklmnopqrst", 21, 0, L"abcde", 0, 0);
+    test(L"abcdefghijklmnopqrst", 21, 0, L"abcde", 1, 0);
+    test(L"abcdefghijklmnopqrst", 10, 0, L"abcdefghij", 10, -10);
+    }
+
+#if __cplusplus >= 201103L
+    {
+    test(U"", 0, 0, U"abcde", 0, 0);
+    test(U"", 0, 0, U"abcde", 1, -1);
+    test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 0, 0);
+    test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 1, 0);
+    test(U"abcdefghijklmnopqrst", 10, 0, U"abcdefghij", 10, -10);
+    }
+
+    {
+    test(U"", 0, 0, U"abcde", 0, 0);
+    test(U"", 0, 0, U"abcde", 1, -1);
+    test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 0, 0);
+    test(U"abcdefghijklmnopqrst", 21, 0, U"abcde", 1, 0);
+    test(U"abcdefghijklmnopqrst", 10, 0, U"abcdefghij", 10, -10);
+    }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1;
+    constexpr SV  sv2 { "abcdefghijklmnopqrst", 21 };
+    static_assert ( sv1.compare(0, 0, "abcde", 0) == 0, "" );
+    static_assert ( sv1.compare(0, 0, "abcde", 1) == -1, "" );
+    static_assert ( sv2.compare(0, 0, "abcde", 1, 0) == 0, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp b/final/test/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp
new file mode 100644
index 0000000..33407ef
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp
@@ -0,0 +1,5843 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr int compare(size_type pos1, size_type n1, basic_string_view str,
+//             size_type pos2, size_type n2) const;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, size_t pos1, size_t n1,
+             std::experimental::basic_string_view<CharT> sv2, size_t pos2, size_t n2,
+             int expected ) {
+
+    try
+    {
+        assert ( sign( sv1.compare(pos1, n1, sv2, pos2, n2)) == sign(expected));
+        assert(pos1 <= sv1.size());
+        assert(pos2 <= sv2.size());
+    }
+    catch (const std::out_of_range&) { assert(pos1 > sv1.size() || pos2 > sv2.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, size_t pos1, size_t n1, 
+            const CharT *s2, size_t pos2, size_t n2, 
+            int expected ) {
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    
+    string_view_t sv1 ( s1 );
+    string_view_t sv2 ( s2 );
+    test1(sv1, pos1, n1, sv2, pos2, n2, expected);
+}
+
+void test0()
+{
+    test("", 0, 0, "", 0, 0, 0);
+    test("", 0, 0, "", 0, 1, 0);
+    test("", 0, 0, "", 1, 0, 0);
+    test("", 0, 0, "abcde", 0, 0, 0);
+    test("", 0, 0, "abcde", 0, 1, -1);
+    test("", 0, 0, "abcde", 0, 2, -2);
+    test("", 0, 0, "abcde", 0, 4, -4);
+    test("", 0, 0, "abcde", 0, 5, -5);
+    test("", 0, 0, "abcde", 0, 6, -5);
+    test("", 0, 0, "abcde", 1, 0, 0);
+    test("", 0, 0, "abcde", 1, 1, -1);
+    test("", 0, 0, "abcde", 1, 2, -2);
+    test("", 0, 0, "abcde", 1, 3, -3);
+    test("", 0, 0, "abcde", 1, 4, -4);
+    test("", 0, 0, "abcde", 1, 5, -4);
+    test("", 0, 0, "abcde", 2, 0, 0);
+    test("", 0, 0, "abcde", 2, 1, -1);
+    test("", 0, 0, "abcde", 2, 2, -2);
+    test("", 0, 0, "abcde", 2, 3, -3);
+    test("", 0, 0, "abcde", 2, 4, -3);
+    test("", 0, 0, "abcde", 4, 0, 0);
+    test("", 0, 0, "abcde", 4, 1, -1);
+    test("", 0, 0, "abcde", 4, 2, -1);
+    test("", 0, 0, "abcde", 5, 0, 0);
+    test("", 0, 0, "abcde", 5, 1, 0);
+    test("", 0, 0, "abcde", 6, 0, 0);
+    test("", 0, 0, "abcdefghij", 0, 0, 0);
+    test("", 0, 0, "abcdefghij", 0, 1, -1);
+    test("", 0, 0, "abcdefghij", 0, 5, -5);
+    test("", 0, 0, "abcdefghij", 0, 9, -9);
+    test("", 0, 0, "abcdefghij", 0, 10, -10);
+    test("", 0, 0, "abcdefghij", 0, 11, -10);
+    test("", 0, 0, "abcdefghij", 1, 0, 0);
+    test("", 0, 0, "abcdefghij", 1, 1, -1);
+    test("", 0, 0, "abcdefghij", 1, 4, -4);
+    test("", 0, 0, "abcdefghij", 1, 8, -8);
+    test("", 0, 0, "abcdefghij", 1, 9, -9);
+    test("", 0, 0, "abcdefghij", 1, 10, -9);
+    test("", 0, 0, "abcdefghij", 5, 0, 0);
+    test("", 0, 0, "abcdefghij", 5, 1, -1);
+    test("", 0, 0, "abcdefghij", 5, 2, -2);
+    test("", 0, 0, "abcdefghij", 5, 4, -4);
+    test("", 0, 0, "abcdefghij", 5, 5, -5);
+    test("", 0, 0, "abcdefghij", 5, 6, -5);
+    test("", 0, 0, "abcdefghij", 9, 0, 0);
+    test("", 0, 0, "abcdefghij", 9, 1, -1);
+    test("", 0, 0, "abcdefghij", 9, 2, -1);
+    test("", 0, 0, "abcdefghij", 10, 0, 0);
+    test("", 0, 0, "abcdefghij", 10, 1, 0);
+    test("", 0, 0, "abcdefghij", 11, 0, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("", 0, 1, "", 0, 0, 0);
+    test("", 0, 1, "", 0, 1, 0);
+    test("", 0, 1, "", 1, 0, 0);
+    test("", 0, 1, "abcde", 0, 0, 0);
+    test("", 0, 1, "abcde", 0, 1, -1);
+    test("", 0, 1, "abcde", 0, 2, -2);
+    test("", 0, 1, "abcde", 0, 4, -4);
+    test("", 0, 1, "abcde", 0, 5, -5);
+    test("", 0, 1, "abcde", 0, 6, -5);
+    test("", 0, 1, "abcde", 1, 0, 0);
+    test("", 0, 1, "abcde", 1, 1, -1);
+    test("", 0, 1, "abcde", 1, 2, -2);
+    test("", 0, 1, "abcde", 1, 3, -3);
+    test("", 0, 1, "abcde", 1, 4, -4);
+    test("", 0, 1, "abcde", 1, 5, -4);
+    test("", 0, 1, "abcde", 2, 0, 0);
+    test("", 0, 1, "abcde", 2, 1, -1);
+    test("", 0, 1, "abcde", 2, 2, -2);
+    test("", 0, 1, "abcde", 2, 3, -3);
+    test("", 0, 1, "abcde", 2, 4, -3);
+    test("", 0, 1, "abcde", 4, 0, 0);
+    test("", 0, 1, "abcde", 4, 1, -1);
+    test("", 0, 1, "abcde", 4, 2, -1);
+    test("", 0, 1, "abcde", 5, 0, 0);
+    test("", 0, 1, "abcde", 5, 1, 0);
+    test("", 0, 1, "abcde", 6, 0, 0);
+}
+
+void test1()
+{
+    test("", 0, 1, "abcdefghij", 0, 0, 0);
+    test("", 0, 1, "abcdefghij", 0, 1, -1);
+    test("", 0, 1, "abcdefghij", 0, 5, -5);
+    test("", 0, 1, "abcdefghij", 0, 9, -9);
+    test("", 0, 1, "abcdefghij", 0, 10, -10);
+    test("", 0, 1, "abcdefghij", 0, 11, -10);
+    test("", 0, 1, "abcdefghij", 1, 0, 0);
+    test("", 0, 1, "abcdefghij", 1, 1, -1);
+    test("", 0, 1, "abcdefghij", 1, 4, -4);
+    test("", 0, 1, "abcdefghij", 1, 8, -8);
+    test("", 0, 1, "abcdefghij", 1, 9, -9);
+    test("", 0, 1, "abcdefghij", 1, 10, -9);
+    test("", 0, 1, "abcdefghij", 5, 0, 0);
+    test("", 0, 1, "abcdefghij", 5, 1, -1);
+    test("", 0, 1, "abcdefghij", 5, 2, -2);
+    test("", 0, 1, "abcdefghij", 5, 4, -4);
+    test("", 0, 1, "abcdefghij", 5, 5, -5);
+    test("", 0, 1, "abcdefghij", 5, 6, -5);
+    test("", 0, 1, "abcdefghij", 9, 0, 0);
+    test("", 0, 1, "abcdefghij", 9, 1, -1);
+    test("", 0, 1, "abcdefghij", 9, 2, -1);
+    test("", 0, 1, "abcdefghij", 10, 0, 0);
+    test("", 0, 1, "abcdefghij", 10, 1, 0);
+    test("", 0, 1, "abcdefghij", 11, 0, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("", 0, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("", 0, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("", 0, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("", 0, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("", 0, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("", 0, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("", 0, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("", 0, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("", 0, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("", 0, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("", 0, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("", 0, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("", 0, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("", 0, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("", 0, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("", 1, 0, "", 0, 0, 0);
+    test("", 1, 0, "", 0, 1, 0);
+    test("", 1, 0, "", 1, 0, 0);
+    test("", 1, 0, "abcde", 0, 0, 0);
+    test("", 1, 0, "abcde", 0, 1, 0);
+    test("", 1, 0, "abcde", 0, 2, 0);
+    test("", 1, 0, "abcde", 0, 4, 0);
+    test("", 1, 0, "abcde", 0, 5, 0);
+    test("", 1, 0, "abcde", 0, 6, 0);
+    test("", 1, 0, "abcde", 1, 0, 0);
+    test("", 1, 0, "abcde", 1, 1, 0);
+    test("", 1, 0, "abcde", 1, 2, 0);
+    test("", 1, 0, "abcde", 1, 3, 0);
+    test("", 1, 0, "abcde", 1, 4, 0);
+    test("", 1, 0, "abcde", 1, 5, 0);
+    test("", 1, 0, "abcde", 2, 0, 0);
+    test("", 1, 0, "abcde", 2, 1, 0);
+    test("", 1, 0, "abcde", 2, 2, 0);
+    test("", 1, 0, "abcde", 2, 3, 0);
+    test("", 1, 0, "abcde", 2, 4, 0);
+    test("", 1, 0, "abcde", 4, 0, 0);
+    test("", 1, 0, "abcde", 4, 1, 0);
+    test("", 1, 0, "abcde", 4, 2, 0);
+    test("", 1, 0, "abcde", 5, 0, 0);
+    test("", 1, 0, "abcde", 5, 1, 0);
+    test("", 1, 0, "abcde", 6, 0, 0);
+    test("", 1, 0, "abcdefghij", 0, 0, 0);
+    test("", 1, 0, "abcdefghij", 0, 1, 0);
+    test("", 1, 0, "abcdefghij", 0, 5, 0);
+    test("", 1, 0, "abcdefghij", 0, 9, 0);
+    test("", 1, 0, "abcdefghij", 0, 10, 0);
+    test("", 1, 0, "abcdefghij", 0, 11, 0);
+    test("", 1, 0, "abcdefghij", 1, 0, 0);
+    test("", 1, 0, "abcdefghij", 1, 1, 0);
+    test("", 1, 0, "abcdefghij", 1, 4, 0);
+    test("", 1, 0, "abcdefghij", 1, 8, 0);
+    test("", 1, 0, "abcdefghij", 1, 9, 0);
+    test("", 1, 0, "abcdefghij", 1, 10, 0);
+    test("", 1, 0, "abcdefghij", 5, 0, 0);
+    test("", 1, 0, "abcdefghij", 5, 1, 0);
+    test("", 1, 0, "abcdefghij", 5, 2, 0);
+    test("", 1, 0, "abcdefghij", 5, 4, 0);
+    test("", 1, 0, "abcdefghij", 5, 5, 0);
+    test("", 1, 0, "abcdefghij", 5, 6, 0);
+    test("", 1, 0, "abcdefghij", 9, 0, 0);
+    test("", 1, 0, "abcdefghij", 9, 1, 0);
+    test("", 1, 0, "abcdefghij", 9, 2, 0);
+    test("", 1, 0, "abcdefghij", 10, 0, 0);
+    test("", 1, 0, "abcdefghij", 10, 1, 0);
+    test("", 1, 0, "abcdefghij", 11, 0, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+}
+
+void test2()
+{
+    test("", 1, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 0, 0, "", 0, 0, 0);
+    test("abcde", 0, 0, "", 0, 1, 0);
+    test("abcde", 0, 0, "", 1, 0, 0);
+    test("abcde", 0, 0, "abcde", 0, 0, 0);
+    test("abcde", 0, 0, "abcde", 0, 1, -1);
+    test("abcde", 0, 0, "abcde", 0, 2, -2);
+    test("abcde", 0, 0, "abcde", 0, 4, -4);
+    test("abcde", 0, 0, "abcde", 0, 5, -5);
+    test("abcde", 0, 0, "abcde", 0, 6, -5);
+    test("abcde", 0, 0, "abcde", 1, 0, 0);
+    test("abcde", 0, 0, "abcde", 1, 1, -1);
+    test("abcde", 0, 0, "abcde", 1, 2, -2);
+    test("abcde", 0, 0, "abcde", 1, 3, -3);
+    test("abcde", 0, 0, "abcde", 1, 4, -4);
+    test("abcde", 0, 0, "abcde", 1, 5, -4);
+    test("abcde", 0, 0, "abcde", 2, 0, 0);
+    test("abcde", 0, 0, "abcde", 2, 1, -1);
+    test("abcde", 0, 0, "abcde", 2, 2, -2);
+    test("abcde", 0, 0, "abcde", 2, 3, -3);
+    test("abcde", 0, 0, "abcde", 2, 4, -3);
+    test("abcde", 0, 0, "abcde", 4, 0, 0);
+    test("abcde", 0, 0, "abcde", 4, 1, -1);
+    test("abcde", 0, 0, "abcde", 4, 2, -1);
+    test("abcde", 0, 0, "abcde", 5, 0, 0);
+    test("abcde", 0, 0, "abcde", 5, 1, 0);
+    test("abcde", 0, 0, "abcde", 6, 0, 0);
+    test("abcde", 0, 0, "abcdefghij", 0, 0, 0);
+    test("abcde", 0, 0, "abcdefghij", 0, 1, -1);
+    test("abcde", 0, 0, "abcdefghij", 0, 5, -5);
+    test("abcde", 0, 0, "abcdefghij", 0, 9, -9);
+    test("abcde", 0, 0, "abcdefghij", 0, 10, -10);
+    test("abcde", 0, 0, "abcdefghij", 0, 11, -10);
+    test("abcde", 0, 0, "abcdefghij", 1, 0, 0);
+    test("abcde", 0, 0, "abcdefghij", 1, 1, -1);
+    test("abcde", 0, 0, "abcdefghij", 1, 4, -4);
+    test("abcde", 0, 0, "abcdefghij", 1, 8, -8);
+    test("abcde", 0, 0, "abcdefghij", 1, 9, -9);
+    test("abcde", 0, 0, "abcdefghij", 1, 10, -9);
+    test("abcde", 0, 0, "abcdefghij", 5, 0, 0);
+    test("abcde", 0, 0, "abcdefghij", 5, 1, -1);
+    test("abcde", 0, 0, "abcdefghij", 5, 2, -2);
+    test("abcde", 0, 0, "abcdefghij", 5, 4, -4);
+    test("abcde", 0, 0, "abcdefghij", 5, 5, -5);
+    test("abcde", 0, 0, "abcdefghij", 5, 6, -5);
+    test("abcde", 0, 0, "abcdefghij", 9, 0, 0);
+    test("abcde", 0, 0, "abcdefghij", 9, 1, -1);
+    test("abcde", 0, 0, "abcdefghij", 9, 2, -1);
+    test("abcde", 0, 0, "abcdefghij", 10, 0, 0);
+    test("abcde", 0, 0, "abcdefghij", 10, 1, 0);
+    test("abcde", 0, 0, "abcdefghij", 11, 0, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcde", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 0, 1, "", 0, 0, 1);
+    test("abcde", 0, 1, "", 0, 1, 1);
+    test("abcde", 0, 1, "", 1, 0, 0);
+    test("abcde", 0, 1, "abcde", 0, 0, 1);
+}
+
+void test3()
+{
+    test("abcde", 0, 1, "abcde", 0, 1, 0);
+    test("abcde", 0, 1, "abcde", 0, 2, -1);
+    test("abcde", 0, 1, "abcde", 0, 4, -3);
+    test("abcde", 0, 1, "abcde", 0, 5, -4);
+    test("abcde", 0, 1, "abcde", 0, 6, -4);
+    test("abcde", 0, 1, "abcde", 1, 0, 1);
+    test("abcde", 0, 1, "abcde", 1, 1, -1);
+    test("abcde", 0, 1, "abcde", 1, 2, -1);
+    test("abcde", 0, 1, "abcde", 1, 3, -1);
+    test("abcde", 0, 1, "abcde", 1, 4, -1);
+    test("abcde", 0, 1, "abcde", 1, 5, -1);
+    test("abcde", 0, 1, "abcde", 2, 0, 1);
+    test("abcde", 0, 1, "abcde", 2, 1, -2);
+    test("abcde", 0, 1, "abcde", 2, 2, -2);
+    test("abcde", 0, 1, "abcde", 2, 3, -2);
+    test("abcde", 0, 1, "abcde", 2, 4, -2);
+    test("abcde", 0, 1, "abcde", 4, 0, 1);
+    test("abcde", 0, 1, "abcde", 4, 1, -4);
+    test("abcde", 0, 1, "abcde", 4, 2, -4);
+    test("abcde", 0, 1, "abcde", 5, 0, 1);
+    test("abcde", 0, 1, "abcde", 5, 1, 1);
+    test("abcde", 0, 1, "abcde", 6, 0, 0);
+    test("abcde", 0, 1, "abcdefghij", 0, 0, 1);
+    test("abcde", 0, 1, "abcdefghij", 0, 1, 0);
+    test("abcde", 0, 1, "abcdefghij", 0, 5, -4);
+    test("abcde", 0, 1, "abcdefghij", 0, 9, -8);
+    test("abcde", 0, 1, "abcdefghij", 0, 10, -9);
+    test("abcde", 0, 1, "abcdefghij", 0, 11, -9);
+    test("abcde", 0, 1, "abcdefghij", 1, 0, 1);
+    test("abcde", 0, 1, "abcdefghij", 1, 1, -1);
+    test("abcde", 0, 1, "abcdefghij", 1, 4, -1);
+    test("abcde", 0, 1, "abcdefghij", 1, 8, -1);
+    test("abcde", 0, 1, "abcdefghij", 1, 9, -1);
+    test("abcde", 0, 1, "abcdefghij", 1, 10, -1);
+    test("abcde", 0, 1, "abcdefghij", 5, 0, 1);
+    test("abcde", 0, 1, "abcdefghij", 5, 1, -5);
+    test("abcde", 0, 1, "abcdefghij", 5, 2, -5);
+    test("abcde", 0, 1, "abcdefghij", 5, 4, -5);
+    test("abcde", 0, 1, "abcdefghij", 5, 5, -5);
+    test("abcde", 0, 1, "abcdefghij", 5, 6, -5);
+    test("abcde", 0, 1, "abcdefghij", 9, 0, 1);
+    test("abcde", 0, 1, "abcdefghij", 9, 1, -9);
+    test("abcde", 0, 1, "abcdefghij", 9, 2, -9);
+    test("abcde", 0, 1, "abcdefghij", 10, 0, 1);
+    test("abcde", 0, 1, "abcdefghij", 10, 1, 1);
+    test("abcde", 0, 1, "abcdefghij", 11, 0, 0);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 1, 0);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 10, -9);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 19, -18);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 20, -19);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 0, 21, -19);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcde", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 0, 2, "", 0, 0, 2);
+    test("abcde", 0, 2, "", 0, 1, 2);
+    test("abcde", 0, 2, "", 1, 0, 0);
+    test("abcde", 0, 2, "abcde", 0, 0, 2);
+    test("abcde", 0, 2, "abcde", 0, 1, 1);
+    test("abcde", 0, 2, "abcde", 0, 2, 0);
+    test("abcde", 0, 2, "abcde", 0, 4, -2);
+    test("abcde", 0, 2, "abcde", 0, 5, -3);
+    test("abcde", 0, 2, "abcde", 0, 6, -3);
+    test("abcde", 0, 2, "abcde", 1, 0, 2);
+    test("abcde", 0, 2, "abcde", 1, 1, -1);
+    test("abcde", 0, 2, "abcde", 1, 2, -1);
+    test("abcde", 0, 2, "abcde", 1, 3, -1);
+    test("abcde", 0, 2, "abcde", 1, 4, -1);
+    test("abcde", 0, 2, "abcde", 1, 5, -1);
+    test("abcde", 0, 2, "abcde", 2, 0, 2);
+    test("abcde", 0, 2, "abcde", 2, 1, -2);
+    test("abcde", 0, 2, "abcde", 2, 2, -2);
+    test("abcde", 0, 2, "abcde", 2, 3, -2);
+    test("abcde", 0, 2, "abcde", 2, 4, -2);
+    test("abcde", 0, 2, "abcde", 4, 0, 2);
+    test("abcde", 0, 2, "abcde", 4, 1, -4);
+    test("abcde", 0, 2, "abcde", 4, 2, -4);
+    test("abcde", 0, 2, "abcde", 5, 0, 2);
+    test("abcde", 0, 2, "abcde", 5, 1, 2);
+    test("abcde", 0, 2, "abcde", 6, 0, 0);
+    test("abcde", 0, 2, "abcdefghij", 0, 0, 2);
+    test("abcde", 0, 2, "abcdefghij", 0, 1, 1);
+    test("abcde", 0, 2, "abcdefghij", 0, 5, -3);
+    test("abcde", 0, 2, "abcdefghij", 0, 9, -7);
+}
+
+void test4()
+{
+    test("abcde", 0, 2, "abcdefghij", 0, 10, -8);
+    test("abcde", 0, 2, "abcdefghij", 0, 11, -8);
+    test("abcde", 0, 2, "abcdefghij", 1, 0, 2);
+    test("abcde", 0, 2, "abcdefghij", 1, 1, -1);
+    test("abcde", 0, 2, "abcdefghij", 1, 4, -1);
+    test("abcde", 0, 2, "abcdefghij", 1, 8, -1);
+    test("abcde", 0, 2, "abcdefghij", 1, 9, -1);
+    test("abcde", 0, 2, "abcdefghij", 1, 10, -1);
+    test("abcde", 0, 2, "abcdefghij", 5, 0, 2);
+    test("abcde", 0, 2, "abcdefghij", 5, 1, -5);
+    test("abcde", 0, 2, "abcdefghij", 5, 2, -5);
+    test("abcde", 0, 2, "abcdefghij", 5, 4, -5);
+    test("abcde", 0, 2, "abcdefghij", 5, 5, -5);
+    test("abcde", 0, 2, "abcdefghij", 5, 6, -5);
+    test("abcde", 0, 2, "abcdefghij", 9, 0, 2);
+    test("abcde", 0, 2, "abcdefghij", 9, 1, -9);
+    test("abcde", 0, 2, "abcdefghij", 9, 2, -9);
+    test("abcde", 0, 2, "abcdefghij", 10, 0, 2);
+    test("abcde", 0, 2, "abcdefghij", 10, 1, 2);
+    test("abcde", 0, 2, "abcdefghij", 11, 0, 0);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 10, -8);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 19, -17);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 20, -18);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 0, 21, -18);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+    test("abcde", 0, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 0, 4, "", 0, 0, 4);
+    test("abcde", 0, 4, "", 0, 1, 4);
+    test("abcde", 0, 4, "", 1, 0, 0);
+    test("abcde", 0, 4, "abcde", 0, 0, 4);
+    test("abcde", 0, 4, "abcde", 0, 1, 3);
+    test("abcde", 0, 4, "abcde", 0, 2, 2);
+    test("abcde", 0, 4, "abcde", 0, 4, 0);
+    test("abcde", 0, 4, "abcde", 0, 5, -1);
+    test("abcde", 0, 4, "abcde", 0, 6, -1);
+    test("abcde", 0, 4, "abcde", 1, 0, 4);
+    test("abcde", 0, 4, "abcde", 1, 1, -1);
+    test("abcde", 0, 4, "abcde", 1, 2, -1);
+    test("abcde", 0, 4, "abcde", 1, 3, -1);
+    test("abcde", 0, 4, "abcde", 1, 4, -1);
+    test("abcde", 0, 4, "abcde", 1, 5, -1);
+    test("abcde", 0, 4, "abcde", 2, 0, 4);
+    test("abcde", 0, 4, "abcde", 2, 1, -2);
+    test("abcde", 0, 4, "abcde", 2, 2, -2);
+    test("abcde", 0, 4, "abcde", 2, 3, -2);
+    test("abcde", 0, 4, "abcde", 2, 4, -2);
+    test("abcde", 0, 4, "abcde", 4, 0, 4);
+    test("abcde", 0, 4, "abcde", 4, 1, -4);
+    test("abcde", 0, 4, "abcde", 4, 2, -4);
+    test("abcde", 0, 4, "abcde", 5, 0, 4);
+    test("abcde", 0, 4, "abcde", 5, 1, 4);
+    test("abcde", 0, 4, "abcde", 6, 0, 0);
+    test("abcde", 0, 4, "abcdefghij", 0, 0, 4);
+    test("abcde", 0, 4, "abcdefghij", 0, 1, 3);
+    test("abcde", 0, 4, "abcdefghij", 0, 5, -1);
+    test("abcde", 0, 4, "abcdefghij", 0, 9, -5);
+    test("abcde", 0, 4, "abcdefghij", 0, 10, -6);
+    test("abcde", 0, 4, "abcdefghij", 0, 11, -6);
+    test("abcde", 0, 4, "abcdefghij", 1, 0, 4);
+    test("abcde", 0, 4, "abcdefghij", 1, 1, -1);
+    test("abcde", 0, 4, "abcdefghij", 1, 4, -1);
+    test("abcde", 0, 4, "abcdefghij", 1, 8, -1);
+    test("abcde", 0, 4, "abcdefghij", 1, 9, -1);
+    test("abcde", 0, 4, "abcdefghij", 1, 10, -1);
+    test("abcde", 0, 4, "abcdefghij", 5, 0, 4);
+    test("abcde", 0, 4, "abcdefghij", 5, 1, -5);
+    test("abcde", 0, 4, "abcdefghij", 5, 2, -5);
+    test("abcde", 0, 4, "abcdefghij", 5, 4, -5);
+    test("abcde", 0, 4, "abcdefghij", 5, 5, -5);
+    test("abcde", 0, 4, "abcdefghij", 5, 6, -5);
+    test("abcde", 0, 4, "abcdefghij", 9, 0, 4);
+    test("abcde", 0, 4, "abcdefghij", 9, 1, -9);
+    test("abcde", 0, 4, "abcdefghij", 9, 2, -9);
+    test("abcde", 0, 4, "abcdefghij", 10, 0, 4);
+    test("abcde", 0, 4, "abcdefghij", 10, 1, 4);
+    test("abcde", 0, 4, "abcdefghij", 11, 0, 0);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 1, 3);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 10, -6);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 19, -15);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 20, -16);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 0, 21, -16);
+}
+
+void test5()
+{
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+    test("abcde", 0, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 0, 5, "", 0, 0, 5);
+    test("abcde", 0, 5, "", 0, 1, 5);
+    test("abcde", 0, 5, "", 1, 0, 0);
+    test("abcde", 0, 5, "abcde", 0, 0, 5);
+    test("abcde", 0, 5, "abcde", 0, 1, 4);
+    test("abcde", 0, 5, "abcde", 0, 2, 3);
+    test("abcde", 0, 5, "abcde", 0, 4, 1);
+    test("abcde", 0, 5, "abcde", 0, 5, 0);
+    test("abcde", 0, 5, "abcde", 0, 6, 0);
+    test("abcde", 0, 5, "abcde", 1, 0, 5);
+    test("abcde", 0, 5, "abcde", 1, 1, -1);
+    test("abcde", 0, 5, "abcde", 1, 2, -1);
+    test("abcde", 0, 5, "abcde", 1, 3, -1);
+    test("abcde", 0, 5, "abcde", 1, 4, -1);
+    test("abcde", 0, 5, "abcde", 1, 5, -1);
+    test("abcde", 0, 5, "abcde", 2, 0, 5);
+    test("abcde", 0, 5, "abcde", 2, 1, -2);
+    test("abcde", 0, 5, "abcde", 2, 2, -2);
+    test("abcde", 0, 5, "abcde", 2, 3, -2);
+    test("abcde", 0, 5, "abcde", 2, 4, -2);
+    test("abcde", 0, 5, "abcde", 4, 0, 5);
+    test("abcde", 0, 5, "abcde", 4, 1, -4);
+    test("abcde", 0, 5, "abcde", 4, 2, -4);
+    test("abcde", 0, 5, "abcde", 5, 0, 5);
+    test("abcde", 0, 5, "abcde", 5, 1, 5);
+    test("abcde", 0, 5, "abcde", 6, 0, 0);
+    test("abcde", 0, 5, "abcdefghij", 0, 0, 5);
+    test("abcde", 0, 5, "abcdefghij", 0, 1, 4);
+    test("abcde", 0, 5, "abcdefghij", 0, 5, 0);
+    test("abcde", 0, 5, "abcdefghij", 0, 9, -4);
+    test("abcde", 0, 5, "abcdefghij", 0, 10, -5);
+    test("abcde", 0, 5, "abcdefghij", 0, 11, -5);
+    test("abcde", 0, 5, "abcdefghij", 1, 0, 5);
+    test("abcde", 0, 5, "abcdefghij", 1, 1, -1);
+    test("abcde", 0, 5, "abcdefghij", 1, 4, -1);
+    test("abcde", 0, 5, "abcdefghij", 1, 8, -1);
+    test("abcde", 0, 5, "abcdefghij", 1, 9, -1);
+    test("abcde", 0, 5, "abcdefghij", 1, 10, -1);
+    test("abcde", 0, 5, "abcdefghij", 5, 0, 5);
+    test("abcde", 0, 5, "abcdefghij", 5, 1, -5);
+    test("abcde", 0, 5, "abcdefghij", 5, 2, -5);
+    test("abcde", 0, 5, "abcdefghij", 5, 4, -5);
+    test("abcde", 0, 5, "abcdefghij", 5, 5, -5);
+    test("abcde", 0, 5, "abcdefghij", 5, 6, -5);
+    test("abcde", 0, 5, "abcdefghij", 9, 0, 5);
+    test("abcde", 0, 5, "abcdefghij", 9, 1, -9);
+    test("abcde", 0, 5, "abcdefghij", 9, 2, -9);
+    test("abcde", 0, 5, "abcdefghij", 10, 0, 5);
+    test("abcde", 0, 5, "abcdefghij", 10, 1, 5);
+    test("abcde", 0, 5, "abcdefghij", 11, 0, 0);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 1, 4);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 10, -5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 19, -14);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 20, -15);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 0, 21, -15);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+    test("abcde", 0, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 0, 6, "", 0, 0, 5);
+    test("abcde", 0, 6, "", 0, 1, 5);
+    test("abcde", 0, 6, "", 1, 0, 0);
+    test("abcde", 0, 6, "abcde", 0, 0, 5);
+    test("abcde", 0, 6, "abcde", 0, 1, 4);
+    test("abcde", 0, 6, "abcde", 0, 2, 3);
+    test("abcde", 0, 6, "abcde", 0, 4, 1);
+    test("abcde", 0, 6, "abcde", 0, 5, 0);
+}
+
+void test6()
+{
+    test("abcde", 0, 6, "abcde", 0, 6, 0);
+    test("abcde", 0, 6, "abcde", 1, 0, 5);
+    test("abcde", 0, 6, "abcde", 1, 1, -1);
+    test("abcde", 0, 6, "abcde", 1, 2, -1);
+    test("abcde", 0, 6, "abcde", 1, 3, -1);
+    test("abcde", 0, 6, "abcde", 1, 4, -1);
+    test("abcde", 0, 6, "abcde", 1, 5, -1);
+    test("abcde", 0, 6, "abcde", 2, 0, 5);
+    test("abcde", 0, 6, "abcde", 2, 1, -2);
+    test("abcde", 0, 6, "abcde", 2, 2, -2);
+    test("abcde", 0, 6, "abcde", 2, 3, -2);
+    test("abcde", 0, 6, "abcde", 2, 4, -2);
+    test("abcde", 0, 6, "abcde", 4, 0, 5);
+    test("abcde", 0, 6, "abcde", 4, 1, -4);
+    test("abcde", 0, 6, "abcde", 4, 2, -4);
+    test("abcde", 0, 6, "abcde", 5, 0, 5);
+    test("abcde", 0, 6, "abcde", 5, 1, 5);
+    test("abcde", 0, 6, "abcde", 6, 0, 0);
+    test("abcde", 0, 6, "abcdefghij", 0, 0, 5);
+    test("abcde", 0, 6, "abcdefghij", 0, 1, 4);
+    test("abcde", 0, 6, "abcdefghij", 0, 5, 0);
+    test("abcde", 0, 6, "abcdefghij", 0, 9, -4);
+    test("abcde", 0, 6, "abcdefghij", 0, 10, -5);
+    test("abcde", 0, 6, "abcdefghij", 0, 11, -5);
+    test("abcde", 0, 6, "abcdefghij", 1, 0, 5);
+    test("abcde", 0, 6, "abcdefghij", 1, 1, -1);
+    test("abcde", 0, 6, "abcdefghij", 1, 4, -1);
+    test("abcde", 0, 6, "abcdefghij", 1, 8, -1);
+    test("abcde", 0, 6, "abcdefghij", 1, 9, -1);
+    test("abcde", 0, 6, "abcdefghij", 1, 10, -1);
+    test("abcde", 0, 6, "abcdefghij", 5, 0, 5);
+    test("abcde", 0, 6, "abcdefghij", 5, 1, -5);
+    test("abcde", 0, 6, "abcdefghij", 5, 2, -5);
+    test("abcde", 0, 6, "abcdefghij", 5, 4, -5);
+    test("abcde", 0, 6, "abcdefghij", 5, 5, -5);
+    test("abcde", 0, 6, "abcdefghij", 5, 6, -5);
+    test("abcde", 0, 6, "abcdefghij", 9, 0, 5);
+    test("abcde", 0, 6, "abcdefghij", 9, 1, -9);
+    test("abcde", 0, 6, "abcdefghij", 9, 2, -9);
+    test("abcde", 0, 6, "abcdefghij", 10, 0, 5);
+    test("abcde", 0, 6, "abcdefghij", 10, 1, 5);
+    test("abcde", 0, 6, "abcdefghij", 11, 0, 0);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 0, 5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 1, 4);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 10, -5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 19, -14);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 20, -15);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 0, 21, -15);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 0, 5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 0, 5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, 0, 5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 20, 0, 5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 20, 1, 5);
+    test("abcde", 0, 6, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 1, 0, "", 0, 0, 0);
+    test("abcde", 1, 0, "", 0, 1, 0);
+    test("abcde", 1, 0, "", 1, 0, 0);
+    test("abcde", 1, 0, "abcde", 0, 0, 0);
+    test("abcde", 1, 0, "abcde", 0, 1, -1);
+    test("abcde", 1, 0, "abcde", 0, 2, -2);
+    test("abcde", 1, 0, "abcde", 0, 4, -4);
+    test("abcde", 1, 0, "abcde", 0, 5, -5);
+    test("abcde", 1, 0, "abcde", 0, 6, -5);
+    test("abcde", 1, 0, "abcde", 1, 0, 0);
+    test("abcde", 1, 0, "abcde", 1, 1, -1);
+    test("abcde", 1, 0, "abcde", 1, 2, -2);
+    test("abcde", 1, 0, "abcde", 1, 3, -3);
+    test("abcde", 1, 0, "abcde", 1, 4, -4);
+    test("abcde", 1, 0, "abcde", 1, 5, -4);
+    test("abcde", 1, 0, "abcde", 2, 0, 0);
+    test("abcde", 1, 0, "abcde", 2, 1, -1);
+    test("abcde", 1, 0, "abcde", 2, 2, -2);
+    test("abcde", 1, 0, "abcde", 2, 3, -3);
+    test("abcde", 1, 0, "abcde", 2, 4, -3);
+    test("abcde", 1, 0, "abcde", 4, 0, 0);
+    test("abcde", 1, 0, "abcde", 4, 1, -1);
+    test("abcde", 1, 0, "abcde", 4, 2, -1);
+    test("abcde", 1, 0, "abcde", 5, 0, 0);
+    test("abcde", 1, 0, "abcde", 5, 1, 0);
+    test("abcde", 1, 0, "abcde", 6, 0, 0);
+    test("abcde", 1, 0, "abcdefghij", 0, 0, 0);
+    test("abcde", 1, 0, "abcdefghij", 0, 1, -1);
+    test("abcde", 1, 0, "abcdefghij", 0, 5, -5);
+    test("abcde", 1, 0, "abcdefghij", 0, 9, -9);
+    test("abcde", 1, 0, "abcdefghij", 0, 10, -10);
+    test("abcde", 1, 0, "abcdefghij", 0, 11, -10);
+    test("abcde", 1, 0, "abcdefghij", 1, 0, 0);
+    test("abcde", 1, 0, "abcdefghij", 1, 1, -1);
+}
+
+void test7()
+{
+    test("abcde", 1, 0, "abcdefghij", 1, 4, -4);
+    test("abcde", 1, 0, "abcdefghij", 1, 8, -8);
+    test("abcde", 1, 0, "abcdefghij", 1, 9, -9);
+    test("abcde", 1, 0, "abcdefghij", 1, 10, -9);
+    test("abcde", 1, 0, "abcdefghij", 5, 0, 0);
+    test("abcde", 1, 0, "abcdefghij", 5, 1, -1);
+    test("abcde", 1, 0, "abcdefghij", 5, 2, -2);
+    test("abcde", 1, 0, "abcdefghij", 5, 4, -4);
+    test("abcde", 1, 0, "abcdefghij", 5, 5, -5);
+    test("abcde", 1, 0, "abcdefghij", 5, 6, -5);
+    test("abcde", 1, 0, "abcdefghij", 9, 0, 0);
+    test("abcde", 1, 0, "abcdefghij", 9, 1, -1);
+    test("abcde", 1, 0, "abcdefghij", 9, 2, -1);
+    test("abcde", 1, 0, "abcdefghij", 10, 0, 0);
+    test("abcde", 1, 0, "abcdefghij", 10, 1, 0);
+    test("abcde", 1, 0, "abcdefghij", 11, 0, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcde", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 1, 1, "", 0, 0, 1);
+    test("abcde", 1, 1, "", 0, 1, 1);
+    test("abcde", 1, 1, "", 1, 0, 0);
+    test("abcde", 1, 1, "abcde", 0, 0, 1);
+    test("abcde", 1, 1, "abcde", 0, 1, 1);
+    test("abcde", 1, 1, "abcde", 0, 2, 1);
+    test("abcde", 1, 1, "abcde", 0, 4, 1);
+    test("abcde", 1, 1, "abcde", 0, 5, 1);
+    test("abcde", 1, 1, "abcde", 0, 6, 1);
+    test("abcde", 1, 1, "abcde", 1, 0, 1);
+    test("abcde", 1, 1, "abcde", 1, 1, 0);
+    test("abcde", 1, 1, "abcde", 1, 2, -1);
+    test("abcde", 1, 1, "abcde", 1, 3, -2);
+    test("abcde", 1, 1, "abcde", 1, 4, -3);
+    test("abcde", 1, 1, "abcde", 1, 5, -3);
+    test("abcde", 1, 1, "abcde", 2, 0, 1);
+    test("abcde", 1, 1, "abcde", 2, 1, -1);
+    test("abcde", 1, 1, "abcde", 2, 2, -1);
+    test("abcde", 1, 1, "abcde", 2, 3, -1);
+    test("abcde", 1, 1, "abcde", 2, 4, -1);
+    test("abcde", 1, 1, "abcde", 4, 0, 1);
+    test("abcde", 1, 1, "abcde", 4, 1, -3);
+    test("abcde", 1, 1, "abcde", 4, 2, -3);
+    test("abcde", 1, 1, "abcde", 5, 0, 1);
+    test("abcde", 1, 1, "abcde", 5, 1, 1);
+    test("abcde", 1, 1, "abcde", 6, 0, 0);
+    test("abcde", 1, 1, "abcdefghij", 0, 0, 1);
+    test("abcde", 1, 1, "abcdefghij", 0, 1, 1);
+    test("abcde", 1, 1, "abcdefghij", 0, 5, 1);
+    test("abcde", 1, 1, "abcdefghij", 0, 9, 1);
+    test("abcde", 1, 1, "abcdefghij", 0, 10, 1);
+    test("abcde", 1, 1, "abcdefghij", 0, 11, 1);
+    test("abcde", 1, 1, "abcdefghij", 1, 0, 1);
+    test("abcde", 1, 1, "abcdefghij", 1, 1, 0);
+    test("abcde", 1, 1, "abcdefghij", 1, 4, -3);
+    test("abcde", 1, 1, "abcdefghij", 1, 8, -7);
+    test("abcde", 1, 1, "abcdefghij", 1, 9, -8);
+    test("abcde", 1, 1, "abcdefghij", 1, 10, -8);
+    test("abcde", 1, 1, "abcdefghij", 5, 0, 1);
+    test("abcde", 1, 1, "abcdefghij", 5, 1, -4);
+    test("abcde", 1, 1, "abcdefghij", 5, 2, -4);
+    test("abcde", 1, 1, "abcdefghij", 5, 4, -4);
+    test("abcde", 1, 1, "abcdefghij", 5, 5, -4);
+    test("abcde", 1, 1, "abcdefghij", 5, 6, -4);
+    test("abcde", 1, 1, "abcdefghij", 9, 0, 1);
+    test("abcde", 1, 1, "abcdefghij", 9, 1, -8);
+    test("abcde", 1, 1, "abcdefghij", 9, 2, -8);
+    test("abcde", 1, 1, "abcdefghij", 10, 0, 1);
+    test("abcde", 1, 1, "abcdefghij", 10, 1, 1);
+    test("abcde", 1, 1, "abcdefghij", 11, 0, 0);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 1, 0);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 9, -8);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 18, -17);
+}
+
+void test8()
+{
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 19, -18);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 1, 20, -18);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcde", 1, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 1, 2, "", 0, 0, 2);
+    test("abcde", 1, 2, "", 0, 1, 2);
+    test("abcde", 1, 2, "", 1, 0, 0);
+    test("abcde", 1, 2, "abcde", 0, 0, 2);
+    test("abcde", 1, 2, "abcde", 0, 1, 1);
+    test("abcde", 1, 2, "abcde", 0, 2, 1);
+    test("abcde", 1, 2, "abcde", 0, 4, 1);
+    test("abcde", 1, 2, "abcde", 0, 5, 1);
+    test("abcde", 1, 2, "abcde", 0, 6, 1);
+    test("abcde", 1, 2, "abcde", 1, 0, 2);
+    test("abcde", 1, 2, "abcde", 1, 1, 1);
+    test("abcde", 1, 2, "abcde", 1, 2, 0);
+    test("abcde", 1, 2, "abcde", 1, 3, -1);
+    test("abcde", 1, 2, "abcde", 1, 4, -2);
+    test("abcde", 1, 2, "abcde", 1, 5, -2);
+    test("abcde", 1, 2, "abcde", 2, 0, 2);
+    test("abcde", 1, 2, "abcde", 2, 1, -1);
+    test("abcde", 1, 2, "abcde", 2, 2, -1);
+    test("abcde", 1, 2, "abcde", 2, 3, -1);
+    test("abcde", 1, 2, "abcde", 2, 4, -1);
+    test("abcde", 1, 2, "abcde", 4, 0, 2);
+    test("abcde", 1, 2, "abcde", 4, 1, -3);
+    test("abcde", 1, 2, "abcde", 4, 2, -3);
+    test("abcde", 1, 2, "abcde", 5, 0, 2);
+    test("abcde", 1, 2, "abcde", 5, 1, 2);
+    test("abcde", 1, 2, "abcde", 6, 0, 0);
+    test("abcde", 1, 2, "abcdefghij", 0, 0, 2);
+    test("abcde", 1, 2, "abcdefghij", 0, 1, 1);
+    test("abcde", 1, 2, "abcdefghij", 0, 5, 1);
+    test("abcde", 1, 2, "abcdefghij", 0, 9, 1);
+    test("abcde", 1, 2, "abcdefghij", 0, 10, 1);
+    test("abcde", 1, 2, "abcdefghij", 0, 11, 1);
+    test("abcde", 1, 2, "abcdefghij", 1, 0, 2);
+    test("abcde", 1, 2, "abcdefghij", 1, 1, 1);
+    test("abcde", 1, 2, "abcdefghij", 1, 4, -2);
+    test("abcde", 1, 2, "abcdefghij", 1, 8, -6);
+    test("abcde", 1, 2, "abcdefghij", 1, 9, -7);
+    test("abcde", 1, 2, "abcdefghij", 1, 10, -7);
+    test("abcde", 1, 2, "abcdefghij", 5, 0, 2);
+    test("abcde", 1, 2, "abcdefghij", 5, 1, -4);
+    test("abcde", 1, 2, "abcdefghij", 5, 2, -4);
+    test("abcde", 1, 2, "abcdefghij", 5, 4, -4);
+    test("abcde", 1, 2, "abcdefghij", 5, 5, -4);
+    test("abcde", 1, 2, "abcdefghij", 5, 6, -4);
+    test("abcde", 1, 2, "abcdefghij", 9, 0, 2);
+    test("abcde", 1, 2, "abcdefghij", 9, 1, -8);
+    test("abcde", 1, 2, "abcdefghij", 9, 2, -8);
+    test("abcde", 1, 2, "abcdefghij", 10, 0, 2);
+    test("abcde", 1, 2, "abcdefghij", 10, 1, 2);
+    test("abcde", 1, 2, "abcdefghij", 11, 0, 0);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 1, 1);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 9, -7);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 18, -16);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 19, -17);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 1, 20, -17);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+    test("abcde", 1, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 1, 3, "", 0, 0, 3);
+    test("abcde", 1, 3, "", 0, 1, 3);
+    test("abcde", 1, 3, "", 1, 0, 0);
+    test("abcde", 1, 3, "abcde", 0, 0, 3);
+    test("abcde", 1, 3, "abcde", 0, 1, 1);
+    test("abcde", 1, 3, "abcde", 0, 2, 1);
+    test("abcde", 1, 3, "abcde", 0, 4, 1);
+    test("abcde", 1, 3, "abcde", 0, 5, 1);
+    test("abcde", 1, 3, "abcde", 0, 6, 1);
+    test("abcde", 1, 3, "abcde", 1, 0, 3);
+    test("abcde", 1, 3, "abcde", 1, 1, 2);
+    test("abcde", 1, 3, "abcde", 1, 2, 1);
+}
+
+void test9()
+{
+    test("abcde", 1, 3, "abcde", 1, 3, 0);
+    test("abcde", 1, 3, "abcde", 1, 4, -1);
+    test("abcde", 1, 3, "abcde", 1, 5, -1);
+    test("abcde", 1, 3, "abcde", 2, 0, 3);
+    test("abcde", 1, 3, "abcde", 2, 1, -1);
+    test("abcde", 1, 3, "abcde", 2, 2, -1);
+    test("abcde", 1, 3, "abcde", 2, 3, -1);
+    test("abcde", 1, 3, "abcde", 2, 4, -1);
+    test("abcde", 1, 3, "abcde", 4, 0, 3);
+    test("abcde", 1, 3, "abcde", 4, 1, -3);
+    test("abcde", 1, 3, "abcde", 4, 2, -3);
+    test("abcde", 1, 3, "abcde", 5, 0, 3);
+    test("abcde", 1, 3, "abcde", 5, 1, 3);
+    test("abcde", 1, 3, "abcde", 6, 0, 0);
+    test("abcde", 1, 3, "abcdefghij", 0, 0, 3);
+    test("abcde", 1, 3, "abcdefghij", 0, 1, 1);
+    test("abcde", 1, 3, "abcdefghij", 0, 5, 1);
+    test("abcde", 1, 3, "abcdefghij", 0, 9, 1);
+    test("abcde", 1, 3, "abcdefghij", 0, 10, 1);
+    test("abcde", 1, 3, "abcdefghij", 0, 11, 1);
+    test("abcde", 1, 3, "abcdefghij", 1, 0, 3);
+    test("abcde", 1, 3, "abcdefghij", 1, 1, 2);
+    test("abcde", 1, 3, "abcdefghij", 1, 4, -1);
+    test("abcde", 1, 3, "abcdefghij", 1, 8, -5);
+    test("abcde", 1, 3, "abcdefghij", 1, 9, -6);
+    test("abcde", 1, 3, "abcdefghij", 1, 10, -6);
+    test("abcde", 1, 3, "abcdefghij", 5, 0, 3);
+    test("abcde", 1, 3, "abcdefghij", 5, 1, -4);
+    test("abcde", 1, 3, "abcdefghij", 5, 2, -4);
+    test("abcde", 1, 3, "abcdefghij", 5, 4, -4);
+    test("abcde", 1, 3, "abcdefghij", 5, 5, -4);
+    test("abcde", 1, 3, "abcdefghij", 5, 6, -4);
+    test("abcde", 1, 3, "abcdefghij", 9, 0, 3);
+    test("abcde", 1, 3, "abcdefghij", 9, 1, -8);
+    test("abcde", 1, 3, "abcdefghij", 9, 2, -8);
+    test("abcde", 1, 3, "abcdefghij", 10, 0, 3);
+    test("abcde", 1, 3, "abcdefghij", 10, 1, 3);
+    test("abcde", 1, 3, "abcdefghij", 11, 0, 0);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 0, 3);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 0, 3);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 1, 2);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 9, -6);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 18, -15);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 19, -16);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 1, 20, -16);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 0, 3);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 0, 3);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 20, 0, 3);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 20, 1, 3);
+    test("abcde", 1, 3, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 1, 4, "", 0, 0, 4);
+    test("abcde", 1, 4, "", 0, 1, 4);
+    test("abcde", 1, 4, "", 1, 0, 0);
+    test("abcde", 1, 4, "abcde", 0, 0, 4);
+    test("abcde", 1, 4, "abcde", 0, 1, 1);
+    test("abcde", 1, 4, "abcde", 0, 2, 1);
+    test("abcde", 1, 4, "abcde", 0, 4, 1);
+    test("abcde", 1, 4, "abcde", 0, 5, 1);
+    test("abcde", 1, 4, "abcde", 0, 6, 1);
+    test("abcde", 1, 4, "abcde", 1, 0, 4);
+    test("abcde", 1, 4, "abcde", 1, 1, 3);
+    test("abcde", 1, 4, "abcde", 1, 2, 2);
+    test("abcde", 1, 4, "abcde", 1, 3, 1);
+    test("abcde", 1, 4, "abcde", 1, 4, 0);
+    test("abcde", 1, 4, "abcde", 1, 5, 0);
+    test("abcde", 1, 4, "abcde", 2, 0, 4);
+    test("abcde", 1, 4, "abcde", 2, 1, -1);
+    test("abcde", 1, 4, "abcde", 2, 2, -1);
+    test("abcde", 1, 4, "abcde", 2, 3, -1);
+    test("abcde", 1, 4, "abcde", 2, 4, -1);
+    test("abcde", 1, 4, "abcde", 4, 0, 4);
+    test("abcde", 1, 4, "abcde", 4, 1, -3);
+    test("abcde", 1, 4, "abcde", 4, 2, -3);
+    test("abcde", 1, 4, "abcde", 5, 0, 4);
+    test("abcde", 1, 4, "abcde", 5, 1, 4);
+    test("abcde", 1, 4, "abcde", 6, 0, 0);
+    test("abcde", 1, 4, "abcdefghij", 0, 0, 4);
+    test("abcde", 1, 4, "abcdefghij", 0, 1, 1);
+    test("abcde", 1, 4, "abcdefghij", 0, 5, 1);
+    test("abcde", 1, 4, "abcdefghij", 0, 9, 1);
+    test("abcde", 1, 4, "abcdefghij", 0, 10, 1);
+    test("abcde", 1, 4, "abcdefghij", 0, 11, 1);
+    test("abcde", 1, 4, "abcdefghij", 1, 0, 4);
+    test("abcde", 1, 4, "abcdefghij", 1, 1, 3);
+    test("abcde", 1, 4, "abcdefghij", 1, 4, 0);
+    test("abcde", 1, 4, "abcdefghij", 1, 8, -4);
+    test("abcde", 1, 4, "abcdefghij", 1, 9, -5);
+    test("abcde", 1, 4, "abcdefghij", 1, 10, -5);
+}
+
+void test10()
+{
+    test("abcde", 1, 4, "abcdefghij", 5, 0, 4);
+    test("abcde", 1, 4, "abcdefghij", 5, 1, -4);
+    test("abcde", 1, 4, "abcdefghij", 5, 2, -4);
+    test("abcde", 1, 4, "abcdefghij", 5, 4, -4);
+    test("abcde", 1, 4, "abcdefghij", 5, 5, -4);
+    test("abcde", 1, 4, "abcdefghij", 5, 6, -4);
+    test("abcde", 1, 4, "abcdefghij", 9, 0, 4);
+    test("abcde", 1, 4, "abcdefghij", 9, 1, -8);
+    test("abcde", 1, 4, "abcdefghij", 9, 2, -8);
+    test("abcde", 1, 4, "abcdefghij", 10, 0, 4);
+    test("abcde", 1, 4, "abcdefghij", 10, 1, 4);
+    test("abcde", 1, 4, "abcdefghij", 11, 0, 0);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 1, 3);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 9, -5);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 18, -14);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 19, -15);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 1, 20, -15);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+    test("abcde", 1, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 1, 5, "", 0, 0, 4);
+    test("abcde", 1, 5, "", 0, 1, 4);
+    test("abcde", 1, 5, "", 1, 0, 0);
+    test("abcde", 1, 5, "abcde", 0, 0, 4);
+    test("abcde", 1, 5, "abcde", 0, 1, 1);
+    test("abcde", 1, 5, "abcde", 0, 2, 1);
+    test("abcde", 1, 5, "abcde", 0, 4, 1);
+    test("abcde", 1, 5, "abcde", 0, 5, 1);
+    test("abcde", 1, 5, "abcde", 0, 6, 1);
+    test("abcde", 1, 5, "abcde", 1, 0, 4);
+    test("abcde", 1, 5, "abcde", 1, 1, 3);
+    test("abcde", 1, 5, "abcde", 1, 2, 2);
+    test("abcde", 1, 5, "abcde", 1, 3, 1);
+    test("abcde", 1, 5, "abcde", 1, 4, 0);
+    test("abcde", 1, 5, "abcde", 1, 5, 0);
+    test("abcde", 1, 5, "abcde", 2, 0, 4);
+    test("abcde", 1, 5, "abcde", 2, 1, -1);
+    test("abcde", 1, 5, "abcde", 2, 2, -1);
+    test("abcde", 1, 5, "abcde", 2, 3, -1);
+    test("abcde", 1, 5, "abcde", 2, 4, -1);
+    test("abcde", 1, 5, "abcde", 4, 0, 4);
+    test("abcde", 1, 5, "abcde", 4, 1, -3);
+    test("abcde", 1, 5, "abcde", 4, 2, -3);
+    test("abcde", 1, 5, "abcde", 5, 0, 4);
+    test("abcde", 1, 5, "abcde", 5, 1, 4);
+    test("abcde", 1, 5, "abcde", 6, 0, 0);
+    test("abcde", 1, 5, "abcdefghij", 0, 0, 4);
+    test("abcde", 1, 5, "abcdefghij", 0, 1, 1);
+    test("abcde", 1, 5, "abcdefghij", 0, 5, 1);
+    test("abcde", 1, 5, "abcdefghij", 0, 9, 1);
+    test("abcde", 1, 5, "abcdefghij", 0, 10, 1);
+    test("abcde", 1, 5, "abcdefghij", 0, 11, 1);
+    test("abcde", 1, 5, "abcdefghij", 1, 0, 4);
+    test("abcde", 1, 5, "abcdefghij", 1, 1, 3);
+    test("abcde", 1, 5, "abcdefghij", 1, 4, 0);
+    test("abcde", 1, 5, "abcdefghij", 1, 8, -4);
+    test("abcde", 1, 5, "abcdefghij", 1, 9, -5);
+    test("abcde", 1, 5, "abcdefghij", 1, 10, -5);
+    test("abcde", 1, 5, "abcdefghij", 5, 0, 4);
+    test("abcde", 1, 5, "abcdefghij", 5, 1, -4);
+    test("abcde", 1, 5, "abcdefghij", 5, 2, -4);
+    test("abcde", 1, 5, "abcdefghij", 5, 4, -4);
+    test("abcde", 1, 5, "abcdefghij", 5, 5, -4);
+    test("abcde", 1, 5, "abcdefghij", 5, 6, -4);
+    test("abcde", 1, 5, "abcdefghij", 9, 0, 4);
+    test("abcde", 1, 5, "abcdefghij", 9, 1, -8);
+    test("abcde", 1, 5, "abcdefghij", 9, 2, -8);
+    test("abcde", 1, 5, "abcdefghij", 10, 0, 4);
+    test("abcde", 1, 5, "abcdefghij", 10, 1, 4);
+    test("abcde", 1, 5, "abcdefghij", 11, 0, 0);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 0, 4);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 0, 4);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 1, 3);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 9, -5);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 18, -14);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 19, -15);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 1, 20, -15);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 0, 4);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 1, -9);
+}
+
+void test11()
+{
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 0, 4);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 20, 0, 4);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 20, 1, 4);
+    test("abcde", 1, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 2, 0, "", 0, 0, 0);
+    test("abcde", 2, 0, "", 0, 1, 0);
+    test("abcde", 2, 0, "", 1, 0, 0);
+    test("abcde", 2, 0, "abcde", 0, 0, 0);
+    test("abcde", 2, 0, "abcde", 0, 1, -1);
+    test("abcde", 2, 0, "abcde", 0, 2, -2);
+    test("abcde", 2, 0, "abcde", 0, 4, -4);
+    test("abcde", 2, 0, "abcde", 0, 5, -5);
+    test("abcde", 2, 0, "abcde", 0, 6, -5);
+    test("abcde", 2, 0, "abcde", 1, 0, 0);
+    test("abcde", 2, 0, "abcde", 1, 1, -1);
+    test("abcde", 2, 0, "abcde", 1, 2, -2);
+    test("abcde", 2, 0, "abcde", 1, 3, -3);
+    test("abcde", 2, 0, "abcde", 1, 4, -4);
+    test("abcde", 2, 0, "abcde", 1, 5, -4);
+    test("abcde", 2, 0, "abcde", 2, 0, 0);
+    test("abcde", 2, 0, "abcde", 2, 1, -1);
+    test("abcde", 2, 0, "abcde", 2, 2, -2);
+    test("abcde", 2, 0, "abcde", 2, 3, -3);
+    test("abcde", 2, 0, "abcde", 2, 4, -3);
+    test("abcde", 2, 0, "abcde", 4, 0, 0);
+    test("abcde", 2, 0, "abcde", 4, 1, -1);
+    test("abcde", 2, 0, "abcde", 4, 2, -1);
+    test("abcde", 2, 0, "abcde", 5, 0, 0);
+    test("abcde", 2, 0, "abcde", 5, 1, 0);
+    test("abcde", 2, 0, "abcde", 6, 0, 0);
+    test("abcde", 2, 0, "abcdefghij", 0, 0, 0);
+    test("abcde", 2, 0, "abcdefghij", 0, 1, -1);
+    test("abcde", 2, 0, "abcdefghij", 0, 5, -5);
+    test("abcde", 2, 0, "abcdefghij", 0, 9, -9);
+    test("abcde", 2, 0, "abcdefghij", 0, 10, -10);
+    test("abcde", 2, 0, "abcdefghij", 0, 11, -10);
+    test("abcde", 2, 0, "abcdefghij", 1, 0, 0);
+    test("abcde", 2, 0, "abcdefghij", 1, 1, -1);
+    test("abcde", 2, 0, "abcdefghij", 1, 4, -4);
+    test("abcde", 2, 0, "abcdefghij", 1, 8, -8);
+    test("abcde", 2, 0, "abcdefghij", 1, 9, -9);
+    test("abcde", 2, 0, "abcdefghij", 1, 10, -9);
+    test("abcde", 2, 0, "abcdefghij", 5, 0, 0);
+    test("abcde", 2, 0, "abcdefghij", 5, 1, -1);
+    test("abcde", 2, 0, "abcdefghij", 5, 2, -2);
+    test("abcde", 2, 0, "abcdefghij", 5, 4, -4);
+    test("abcde", 2, 0, "abcdefghij", 5, 5, -5);
+    test("abcde", 2, 0, "abcdefghij", 5, 6, -5);
+    test("abcde", 2, 0, "abcdefghij", 9, 0, 0);
+    test("abcde", 2, 0, "abcdefghij", 9, 1, -1);
+    test("abcde", 2, 0, "abcdefghij", 9, 2, -1);
+    test("abcde", 2, 0, "abcdefghij", 10, 0, 0);
+    test("abcde", 2, 0, "abcdefghij", 10, 1, 0);
+    test("abcde", 2, 0, "abcdefghij", 11, 0, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcde", 2, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 2, 1, "", 0, 0, 1);
+    test("abcde", 2, 1, "", 0, 1, 1);
+    test("abcde", 2, 1, "", 1, 0, 0);
+    test("abcde", 2, 1, "abcde", 0, 0, 1);
+    test("abcde", 2, 1, "abcde", 0, 1, 2);
+    test("abcde", 2, 1, "abcde", 0, 2, 2);
+    test("abcde", 2, 1, "abcde", 0, 4, 2);
+    test("abcde", 2, 1, "abcde", 0, 5, 2);
+    test("abcde", 2, 1, "abcde", 0, 6, 2);
+    test("abcde", 2, 1, "abcde", 1, 0, 1);
+    test("abcde", 2, 1, "abcde", 1, 1, 1);
+    test("abcde", 2, 1, "abcde", 1, 2, 1);
+    test("abcde", 2, 1, "abcde", 1, 3, 1);
+    test("abcde", 2, 1, "abcde", 1, 4, 1);
+    test("abcde", 2, 1, "abcde", 1, 5, 1);
+    test("abcde", 2, 1, "abcde", 2, 0, 1);
+}
+
+void test12()
+{
+    test("abcde", 2, 1, "abcde", 2, 1, 0);
+    test("abcde", 2, 1, "abcde", 2, 2, -1);
+    test("abcde", 2, 1, "abcde", 2, 3, -2);
+    test("abcde", 2, 1, "abcde", 2, 4, -2);
+    test("abcde", 2, 1, "abcde", 4, 0, 1);
+    test("abcde", 2, 1, "abcde", 4, 1, -2);
+    test("abcde", 2, 1, "abcde", 4, 2, -2);
+    test("abcde", 2, 1, "abcde", 5, 0, 1);
+    test("abcde", 2, 1, "abcde", 5, 1, 1);
+    test("abcde", 2, 1, "abcde", 6, 0, 0);
+    test("abcde", 2, 1, "abcdefghij", 0, 0, 1);
+    test("abcde", 2, 1, "abcdefghij", 0, 1, 2);
+    test("abcde", 2, 1, "abcdefghij", 0, 5, 2);
+    test("abcde", 2, 1, "abcdefghij", 0, 9, 2);
+    test("abcde", 2, 1, "abcdefghij", 0, 10, 2);
+    test("abcde", 2, 1, "abcdefghij", 0, 11, 2);
+    test("abcde", 2, 1, "abcdefghij", 1, 0, 1);
+    test("abcde", 2, 1, "abcdefghij", 1, 1, 1);
+    test("abcde", 2, 1, "abcdefghij", 1, 4, 1);
+    test("abcde", 2, 1, "abcdefghij", 1, 8, 1);
+    test("abcde", 2, 1, "abcdefghij", 1, 9, 1);
+    test("abcde", 2, 1, "abcdefghij", 1, 10, 1);
+    test("abcde", 2, 1, "abcdefghij", 5, 0, 1);
+    test("abcde", 2, 1, "abcdefghij", 5, 1, -3);
+    test("abcde", 2, 1, "abcdefghij", 5, 2, -3);
+    test("abcde", 2, 1, "abcdefghij", 5, 4, -3);
+    test("abcde", 2, 1, "abcdefghij", 5, 5, -3);
+    test("abcde", 2, 1, "abcdefghij", 5, 6, -3);
+    test("abcde", 2, 1, "abcdefghij", 9, 0, 1);
+    test("abcde", 2, 1, "abcdefghij", 9, 1, -7);
+    test("abcde", 2, 1, "abcdefghij", 9, 2, -7);
+    test("abcde", 2, 1, "abcdefghij", 10, 0, 1);
+    test("abcde", 2, 1, "abcdefghij", 10, 1, 1);
+    test("abcde", 2, 1, "abcdefghij", 11, 0, 0);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 1, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 10, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 19, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 20, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 0, 21, 2);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 1, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 9, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 18, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 19, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 1, 20, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 1, -8);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 5, -8);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 9, -8);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 10, -8);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 10, 11, -8);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 1, -17);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 19, 2, -17);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcde", 2, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 2, 2, "", 0, 0, 2);
+    test("abcde", 2, 2, "", 0, 1, 2);
+    test("abcde", 2, 2, "", 1, 0, 0);
+    test("abcde", 2, 2, "abcde", 0, 0, 2);
+    test("abcde", 2, 2, "abcde", 0, 1, 2);
+    test("abcde", 2, 2, "abcde", 0, 2, 2);
+    test("abcde", 2, 2, "abcde", 0, 4, 2);
+    test("abcde", 2, 2, "abcde", 0, 5, 2);
+    test("abcde", 2, 2, "abcde", 0, 6, 2);
+    test("abcde", 2, 2, "abcde", 1, 0, 2);
+    test("abcde", 2, 2, "abcde", 1, 1, 1);
+    test("abcde", 2, 2, "abcde", 1, 2, 1);
+    test("abcde", 2, 2, "abcde", 1, 3, 1);
+    test("abcde", 2, 2, "abcde", 1, 4, 1);
+    test("abcde", 2, 2, "abcde", 1, 5, 1);
+    test("abcde", 2, 2, "abcde", 2, 0, 2);
+    test("abcde", 2, 2, "abcde", 2, 1, 1);
+    test("abcde", 2, 2, "abcde", 2, 2, 0);
+    test("abcde", 2, 2, "abcde", 2, 3, -1);
+    test("abcde", 2, 2, "abcde", 2, 4, -1);
+    test("abcde", 2, 2, "abcde", 4, 0, 2);
+    test("abcde", 2, 2, "abcde", 4, 1, -2);
+    test("abcde", 2, 2, "abcde", 4, 2, -2);
+    test("abcde", 2, 2, "abcde", 5, 0, 2);
+    test("abcde", 2, 2, "abcde", 5, 1, 2);
+    test("abcde", 2, 2, "abcde", 6, 0, 0);
+    test("abcde", 2, 2, "abcdefghij", 0, 0, 2);
+    test("abcde", 2, 2, "abcdefghij", 0, 1, 2);
+    test("abcde", 2, 2, "abcdefghij", 0, 5, 2);
+    test("abcde", 2, 2, "abcdefghij", 0, 9, 2);
+    test("abcde", 2, 2, "abcdefghij", 0, 10, 2);
+    test("abcde", 2, 2, "abcdefghij", 0, 11, 2);
+    test("abcde", 2, 2, "abcdefghij", 1, 0, 2);
+    test("abcde", 2, 2, "abcdefghij", 1, 1, 1);
+    test("abcde", 2, 2, "abcdefghij", 1, 4, 1);
+    test("abcde", 2, 2, "abcdefghij", 1, 8, 1);
+    test("abcde", 2, 2, "abcdefghij", 1, 9, 1);
+    test("abcde", 2, 2, "abcdefghij", 1, 10, 1);
+    test("abcde", 2, 2, "abcdefghij", 5, 0, 2);
+    test("abcde", 2, 2, "abcdefghij", 5, 1, -3);
+    test("abcde", 2, 2, "abcdefghij", 5, 2, -3);
+    test("abcde", 2, 2, "abcdefghij", 5, 4, -3);
+}
+
+void test13()
+{
+    test("abcde", 2, 2, "abcdefghij", 5, 5, -3);
+    test("abcde", 2, 2, "abcdefghij", 5, 6, -3);
+    test("abcde", 2, 2, "abcdefghij", 9, 0, 2);
+    test("abcde", 2, 2, "abcdefghij", 9, 1, -7);
+    test("abcde", 2, 2, "abcdefghij", 9, 2, -7);
+    test("abcde", 2, 2, "abcdefghij", 10, 0, 2);
+    test("abcde", 2, 2, "abcdefghij", 10, 1, 2);
+    test("abcde", 2, 2, "abcdefghij", 11, 0, 0);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 1, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 10, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 19, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 20, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 0, 21, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 1, 1);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 9, 1);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 18, 1);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 19, 1);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 1, 20, 1);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 1, -8);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 5, -8);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 9, -8);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 10, -8);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 10, 11, -8);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 1, -17);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 19, 2, -17);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+    test("abcde", 2, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 2, 3, "", 0, 0, 3);
+    test("abcde", 2, 3, "", 0, 1, 3);
+    test("abcde", 2, 3, "", 1, 0, 0);
+    test("abcde", 2, 3, "abcde", 0, 0, 3);
+    test("abcde", 2, 3, "abcde", 0, 1, 2);
+    test("abcde", 2, 3, "abcde", 0, 2, 2);
+    test("abcde", 2, 3, "abcde", 0, 4, 2);
+    test("abcde", 2, 3, "abcde", 0, 5, 2);
+    test("abcde", 2, 3, "abcde", 0, 6, 2);
+    test("abcde", 2, 3, "abcde", 1, 0, 3);
+    test("abcde", 2, 3, "abcde", 1, 1, 1);
+    test("abcde", 2, 3, "abcde", 1, 2, 1);
+    test("abcde", 2, 3, "abcde", 1, 3, 1);
+    test("abcde", 2, 3, "abcde", 1, 4, 1);
+    test("abcde", 2, 3, "abcde", 1, 5, 1);
+    test("abcde", 2, 3, "abcde", 2, 0, 3);
+    test("abcde", 2, 3, "abcde", 2, 1, 2);
+    test("abcde", 2, 3, "abcde", 2, 2, 1);
+    test("abcde", 2, 3, "abcde", 2, 3, 0);
+    test("abcde", 2, 3, "abcde", 2, 4, 0);
+    test("abcde", 2, 3, "abcde", 4, 0, 3);
+    test("abcde", 2, 3, "abcde", 4, 1, -2);
+    test("abcde", 2, 3, "abcde", 4, 2, -2);
+    test("abcde", 2, 3, "abcde", 5, 0, 3);
+    test("abcde", 2, 3, "abcde", 5, 1, 3);
+    test("abcde", 2, 3, "abcde", 6, 0, 0);
+    test("abcde", 2, 3, "abcdefghij", 0, 0, 3);
+    test("abcde", 2, 3, "abcdefghij", 0, 1, 2);
+    test("abcde", 2, 3, "abcdefghij", 0, 5, 2);
+    test("abcde", 2, 3, "abcdefghij", 0, 9, 2);
+    test("abcde", 2, 3, "abcdefghij", 0, 10, 2);
+    test("abcde", 2, 3, "abcdefghij", 0, 11, 2);
+    test("abcde", 2, 3, "abcdefghij", 1, 0, 3);
+    test("abcde", 2, 3, "abcdefghij", 1, 1, 1);
+    test("abcde", 2, 3, "abcdefghij", 1, 4, 1);
+    test("abcde", 2, 3, "abcdefghij", 1, 8, 1);
+    test("abcde", 2, 3, "abcdefghij", 1, 9, 1);
+    test("abcde", 2, 3, "abcdefghij", 1, 10, 1);
+    test("abcde", 2, 3, "abcdefghij", 5, 0, 3);
+    test("abcde", 2, 3, "abcdefghij", 5, 1, -3);
+    test("abcde", 2, 3, "abcdefghij", 5, 2, -3);
+    test("abcde", 2, 3, "abcdefghij", 5, 4, -3);
+    test("abcde", 2, 3, "abcdefghij", 5, 5, -3);
+    test("abcde", 2, 3, "abcdefghij", 5, 6, -3);
+    test("abcde", 2, 3, "abcdefghij", 9, 0, 3);
+    test("abcde", 2, 3, "abcdefghij", 9, 1, -7);
+    test("abcde", 2, 3, "abcdefghij", 9, 2, -7);
+    test("abcde", 2, 3, "abcdefghij", 10, 0, 3);
+    test("abcde", 2, 3, "abcdefghij", 10, 1, 3);
+    test("abcde", 2, 3, "abcdefghij", 11, 0, 0);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 0, 3);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 1, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 10, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 19, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 20, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 0, 21, 2);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 0, 3);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 1, 1);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 9, 1);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 18, 1);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 19, 1);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 1, 20, 1);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 0, 3);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 1, -8);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 5, -8);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 9, -8);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 10, -8);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 10, 11, -8);
+}
+
+void test14()
+{
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 0, 3);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 1, -17);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 19, 2, -17);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 20, 0, 3);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 20, 1, 3);
+    test("abcde", 2, 3, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 2, 4, "", 0, 0, 3);
+    test("abcde", 2, 4, "", 0, 1, 3);
+    test("abcde", 2, 4, "", 1, 0, 0);
+    test("abcde", 2, 4, "abcde", 0, 0, 3);
+    test("abcde", 2, 4, "abcde", 0, 1, 2);
+    test("abcde", 2, 4, "abcde", 0, 2, 2);
+    test("abcde", 2, 4, "abcde", 0, 4, 2);
+    test("abcde", 2, 4, "abcde", 0, 5, 2);
+    test("abcde", 2, 4, "abcde", 0, 6, 2);
+    test("abcde", 2, 4, "abcde", 1, 0, 3);
+    test("abcde", 2, 4, "abcde", 1, 1, 1);
+    test("abcde", 2, 4, "abcde", 1, 2, 1);
+    test("abcde", 2, 4, "abcde", 1, 3, 1);
+    test("abcde", 2, 4, "abcde", 1, 4, 1);
+    test("abcde", 2, 4, "abcde", 1, 5, 1);
+    test("abcde", 2, 4, "abcde", 2, 0, 3);
+    test("abcde", 2, 4, "abcde", 2, 1, 2);
+    test("abcde", 2, 4, "abcde", 2, 2, 1);
+    test("abcde", 2, 4, "abcde", 2, 3, 0);
+    test("abcde", 2, 4, "abcde", 2, 4, 0);
+    test("abcde", 2, 4, "abcde", 4, 0, 3);
+    test("abcde", 2, 4, "abcde", 4, 1, -2);
+    test("abcde", 2, 4, "abcde", 4, 2, -2);
+    test("abcde", 2, 4, "abcde", 5, 0, 3);
+    test("abcde", 2, 4, "abcde", 5, 1, 3);
+    test("abcde", 2, 4, "abcde", 6, 0, 0);
+    test("abcde", 2, 4, "abcdefghij", 0, 0, 3);
+    test("abcde", 2, 4, "abcdefghij", 0, 1, 2);
+    test("abcde", 2, 4, "abcdefghij", 0, 5, 2);
+    test("abcde", 2, 4, "abcdefghij", 0, 9, 2);
+    test("abcde", 2, 4, "abcdefghij", 0, 10, 2);
+    test("abcde", 2, 4, "abcdefghij", 0, 11, 2);
+    test("abcde", 2, 4, "abcdefghij", 1, 0, 3);
+    test("abcde", 2, 4, "abcdefghij", 1, 1, 1);
+    test("abcde", 2, 4, "abcdefghij", 1, 4, 1);
+    test("abcde", 2, 4, "abcdefghij", 1, 8, 1);
+    test("abcde", 2, 4, "abcdefghij", 1, 9, 1);
+    test("abcde", 2, 4, "abcdefghij", 1, 10, 1);
+    test("abcde", 2, 4, "abcdefghij", 5, 0, 3);
+    test("abcde", 2, 4, "abcdefghij", 5, 1, -3);
+    test("abcde", 2, 4, "abcdefghij", 5, 2, -3);
+    test("abcde", 2, 4, "abcdefghij", 5, 4, -3);
+    test("abcde", 2, 4, "abcdefghij", 5, 5, -3);
+    test("abcde", 2, 4, "abcdefghij", 5, 6, -3);
+    test("abcde", 2, 4, "abcdefghij", 9, 0, 3);
+    test("abcde", 2, 4, "abcdefghij", 9, 1, -7);
+    test("abcde", 2, 4, "abcdefghij", 9, 2, -7);
+    test("abcde", 2, 4, "abcdefghij", 10, 0, 3);
+    test("abcde", 2, 4, "abcdefghij", 10, 1, 3);
+    test("abcde", 2, 4, "abcdefghij", 11, 0, 0);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 0, 3);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 1, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 10, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 19, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 20, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 0, 21, 2);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 0, 3);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 1, 1);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 9, 1);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 18, 1);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 19, 1);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 1, 20, 1);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 0, 3);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 1, -8);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 5, -8);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 9, -8);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 10, -8);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 10, 11, -8);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 0, 3);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 1, -17);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 19, 2, -17);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 20, 0, 3);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 20, 1, 3);
+    test("abcde", 2, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 4, 0, "", 0, 0, 0);
+    test("abcde", 4, 0, "", 0, 1, 0);
+    test("abcde", 4, 0, "", 1, 0, 0);
+    test("abcde", 4, 0, "abcde", 0, 0, 0);
+    test("abcde", 4, 0, "abcde", 0, 1, -1);
+    test("abcde", 4, 0, "abcde", 0, 2, -2);
+    test("abcde", 4, 0, "abcde", 0, 4, -4);
+    test("abcde", 4, 0, "abcde", 0, 5, -5);
+    test("abcde", 4, 0, "abcde", 0, 6, -5);
+    test("abcde", 4, 0, "abcde", 1, 0, 0);
+    test("abcde", 4, 0, "abcde", 1, 1, -1);
+    test("abcde", 4, 0, "abcde", 1, 2, -2);
+    test("abcde", 4, 0, "abcde", 1, 3, -3);
+    test("abcde", 4, 0, "abcde", 1, 4, -4);
+    test("abcde", 4, 0, "abcde", 1, 5, -4);
+    test("abcde", 4, 0, "abcde", 2, 0, 0);
+    test("abcde", 4, 0, "abcde", 2, 1, -1);
+    test("abcde", 4, 0, "abcde", 2, 2, -2);
+    test("abcde", 4, 0, "abcde", 2, 3, -3);
+    test("abcde", 4, 0, "abcde", 2, 4, -3);
+}
+
+void test15()
+{
+    test("abcde", 4, 0, "abcde", 4, 0, 0);
+    test("abcde", 4, 0, "abcde", 4, 1, -1);
+    test("abcde", 4, 0, "abcde", 4, 2, -1);
+    test("abcde", 4, 0, "abcde", 5, 0, 0);
+    test("abcde", 4, 0, "abcde", 5, 1, 0);
+    test("abcde", 4, 0, "abcde", 6, 0, 0);
+    test("abcde", 4, 0, "abcdefghij", 0, 0, 0);
+    test("abcde", 4, 0, "abcdefghij", 0, 1, -1);
+    test("abcde", 4, 0, "abcdefghij", 0, 5, -5);
+    test("abcde", 4, 0, "abcdefghij", 0, 9, -9);
+    test("abcde", 4, 0, "abcdefghij", 0, 10, -10);
+    test("abcde", 4, 0, "abcdefghij", 0, 11, -10);
+    test("abcde", 4, 0, "abcdefghij", 1, 0, 0);
+    test("abcde", 4, 0, "abcdefghij", 1, 1, -1);
+    test("abcde", 4, 0, "abcdefghij", 1, 4, -4);
+    test("abcde", 4, 0, "abcdefghij", 1, 8, -8);
+    test("abcde", 4, 0, "abcdefghij", 1, 9, -9);
+    test("abcde", 4, 0, "abcdefghij", 1, 10, -9);
+    test("abcde", 4, 0, "abcdefghij", 5, 0, 0);
+    test("abcde", 4, 0, "abcdefghij", 5, 1, -1);
+    test("abcde", 4, 0, "abcdefghij", 5, 2, -2);
+    test("abcde", 4, 0, "abcdefghij", 5, 4, -4);
+    test("abcde", 4, 0, "abcdefghij", 5, 5, -5);
+    test("abcde", 4, 0, "abcdefghij", 5, 6, -5);
+    test("abcde", 4, 0, "abcdefghij", 9, 0, 0);
+    test("abcde", 4, 0, "abcdefghij", 9, 1, -1);
+    test("abcde", 4, 0, "abcdefghij", 9, 2, -1);
+    test("abcde", 4, 0, "abcdefghij", 10, 0, 0);
+    test("abcde", 4, 0, "abcdefghij", 10, 1, 0);
+    test("abcde", 4, 0, "abcdefghij", 11, 0, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcde", 4, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 4, 1, "", 0, 0, 1);
+    test("abcde", 4, 1, "", 0, 1, 1);
+    test("abcde", 4, 1, "", 1, 0, 0);
+    test("abcde", 4, 1, "abcde", 0, 0, 1);
+    test("abcde", 4, 1, "abcde", 0, 1, 4);
+    test("abcde", 4, 1, "abcde", 0, 2, 4);
+    test("abcde", 4, 1, "abcde", 0, 4, 4);
+    test("abcde", 4, 1, "abcde", 0, 5, 4);
+    test("abcde", 4, 1, "abcde", 0, 6, 4);
+    test("abcde", 4, 1, "abcde", 1, 0, 1);
+    test("abcde", 4, 1, "abcde", 1, 1, 3);
+    test("abcde", 4, 1, "abcde", 1, 2, 3);
+    test("abcde", 4, 1, "abcde", 1, 3, 3);
+    test("abcde", 4, 1, "abcde", 1, 4, 3);
+    test("abcde", 4, 1, "abcde", 1, 5, 3);
+    test("abcde", 4, 1, "abcde", 2, 0, 1);
+    test("abcde", 4, 1, "abcde", 2, 1, 2);
+    test("abcde", 4, 1, "abcde", 2, 2, 2);
+    test("abcde", 4, 1, "abcde", 2, 3, 2);
+    test("abcde", 4, 1, "abcde", 2, 4, 2);
+    test("abcde", 4, 1, "abcde", 4, 0, 1);
+    test("abcde", 4, 1, "abcde", 4, 1, 0);
+    test("abcde", 4, 1, "abcde", 4, 2, 0);
+    test("abcde", 4, 1, "abcde", 5, 0, 1);
+    test("abcde", 4, 1, "abcde", 5, 1, 1);
+    test("abcde", 4, 1, "abcde", 6, 0, 0);
+    test("abcde", 4, 1, "abcdefghij", 0, 0, 1);
+    test("abcde", 4, 1, "abcdefghij", 0, 1, 4);
+    test("abcde", 4, 1, "abcdefghij", 0, 5, 4);
+    test("abcde", 4, 1, "abcdefghij", 0, 9, 4);
+    test("abcde", 4, 1, "abcdefghij", 0, 10, 4);
+    test("abcde", 4, 1, "abcdefghij", 0, 11, 4);
+    test("abcde", 4, 1, "abcdefghij", 1, 0, 1);
+    test("abcde", 4, 1, "abcdefghij", 1, 1, 3);
+    test("abcde", 4, 1, "abcdefghij", 1, 4, 3);
+    test("abcde", 4, 1, "abcdefghij", 1, 8, 3);
+    test("abcde", 4, 1, "abcdefghij", 1, 9, 3);
+    test("abcde", 4, 1, "abcdefghij", 1, 10, 3);
+    test("abcde", 4, 1, "abcdefghij", 5, 0, 1);
+    test("abcde", 4, 1, "abcdefghij", 5, 1, -1);
+    test("abcde", 4, 1, "abcdefghij", 5, 2, -1);
+    test("abcde", 4, 1, "abcdefghij", 5, 4, -1);
+    test("abcde", 4, 1, "abcdefghij", 5, 5, -1);
+    test("abcde", 4, 1, "abcdefghij", 5, 6, -1);
+    test("abcde", 4, 1, "abcdefghij", 9, 0, 1);
+    test("abcde", 4, 1, "abcdefghij", 9, 1, -5);
+}
+
+void test16()
+{
+    test("abcde", 4, 1, "abcdefghij", 9, 2, -5);
+    test("abcde", 4, 1, "abcdefghij", 10, 0, 1);
+    test("abcde", 4, 1, "abcdefghij", 10, 1, 1);
+    test("abcde", 4, 1, "abcdefghij", 11, 0, 0);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 1, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 10, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 19, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 20, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 0, 21, 4);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 1, 3);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 9, 3);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 18, 3);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 19, 3);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 1, 20, 3);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 1, -6);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 5, -6);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 9, -6);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 10, -6);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 10, 11, -6);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 1, -15);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 19, 2, -15);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcde", 4, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 4, 2, "", 0, 0, 1);
+    test("abcde", 4, 2, "", 0, 1, 1);
+    test("abcde", 4, 2, "", 1, 0, 0);
+    test("abcde", 4, 2, "abcde", 0, 0, 1);
+    test("abcde", 4, 2, "abcde", 0, 1, 4);
+    test("abcde", 4, 2, "abcde", 0, 2, 4);
+    test("abcde", 4, 2, "abcde", 0, 4, 4);
+    test("abcde", 4, 2, "abcde", 0, 5, 4);
+    test("abcde", 4, 2, "abcde", 0, 6, 4);
+    test("abcde", 4, 2, "abcde", 1, 0, 1);
+    test("abcde", 4, 2, "abcde", 1, 1, 3);
+    test("abcde", 4, 2, "abcde", 1, 2, 3);
+    test("abcde", 4, 2, "abcde", 1, 3, 3);
+    test("abcde", 4, 2, "abcde", 1, 4, 3);
+    test("abcde", 4, 2, "abcde", 1, 5, 3);
+    test("abcde", 4, 2, "abcde", 2, 0, 1);
+    test("abcde", 4, 2, "abcde", 2, 1, 2);
+    test("abcde", 4, 2, "abcde", 2, 2, 2);
+    test("abcde", 4, 2, "abcde", 2, 3, 2);
+    test("abcde", 4, 2, "abcde", 2, 4, 2);
+    test("abcde", 4, 2, "abcde", 4, 0, 1);
+    test("abcde", 4, 2, "abcde", 4, 1, 0);
+    test("abcde", 4, 2, "abcde", 4, 2, 0);
+    test("abcde", 4, 2, "abcde", 5, 0, 1);
+    test("abcde", 4, 2, "abcde", 5, 1, 1);
+    test("abcde", 4, 2, "abcde", 6, 0, 0);
+    test("abcde", 4, 2, "abcdefghij", 0, 0, 1);
+    test("abcde", 4, 2, "abcdefghij", 0, 1, 4);
+    test("abcde", 4, 2, "abcdefghij", 0, 5, 4);
+    test("abcde", 4, 2, "abcdefghij", 0, 9, 4);
+    test("abcde", 4, 2, "abcdefghij", 0, 10, 4);
+    test("abcde", 4, 2, "abcdefghij", 0, 11, 4);
+    test("abcde", 4, 2, "abcdefghij", 1, 0, 1);
+    test("abcde", 4, 2, "abcdefghij", 1, 1, 3);
+    test("abcde", 4, 2, "abcdefghij", 1, 4, 3);
+    test("abcde", 4, 2, "abcdefghij", 1, 8, 3);
+    test("abcde", 4, 2, "abcdefghij", 1, 9, 3);
+    test("abcde", 4, 2, "abcdefghij", 1, 10, 3);
+    test("abcde", 4, 2, "abcdefghij", 5, 0, 1);
+    test("abcde", 4, 2, "abcdefghij", 5, 1, -1);
+    test("abcde", 4, 2, "abcdefghij", 5, 2, -1);
+    test("abcde", 4, 2, "abcdefghij", 5, 4, -1);
+    test("abcde", 4, 2, "abcdefghij", 5, 5, -1);
+    test("abcde", 4, 2, "abcdefghij", 5, 6, -1);
+    test("abcde", 4, 2, "abcdefghij", 9, 0, 1);
+    test("abcde", 4, 2, "abcdefghij", 9, 1, -5);
+    test("abcde", 4, 2, "abcdefghij", 9, 2, -5);
+    test("abcde", 4, 2, "abcdefghij", 10, 0, 1);
+    test("abcde", 4, 2, "abcdefghij", 10, 1, 1);
+    test("abcde", 4, 2, "abcdefghij", 11, 0, 0);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 1, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 10, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 19, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 20, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 0, 21, 4);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 1, 3);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 9, 3);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 18, 3);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 19, 3);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 1, 20, 3);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 1, -6);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 5, -6);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 9, -6);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 10, -6);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 10, 11, -6);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 1, -15);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 19, 2, -15);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 20, 0, 1);
+}
+
+void test17()
+{
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcde", 4, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 5, 0, "", 0, 0, 0);
+    test("abcde", 5, 0, "", 0, 1, 0);
+    test("abcde", 5, 0, "", 1, 0, 0);
+    test("abcde", 5, 0, "abcde", 0, 0, 0);
+    test("abcde", 5, 0, "abcde", 0, 1, -1);
+    test("abcde", 5, 0, "abcde", 0, 2, -2);
+    test("abcde", 5, 0, "abcde", 0, 4, -4);
+    test("abcde", 5, 0, "abcde", 0, 5, -5);
+    test("abcde", 5, 0, "abcde", 0, 6, -5);
+    test("abcde", 5, 0, "abcde", 1, 0, 0);
+    test("abcde", 5, 0, "abcde", 1, 1, -1);
+    test("abcde", 5, 0, "abcde", 1, 2, -2);
+    test("abcde", 5, 0, "abcde", 1, 3, -3);
+    test("abcde", 5, 0, "abcde", 1, 4, -4);
+    test("abcde", 5, 0, "abcde", 1, 5, -4);
+    test("abcde", 5, 0, "abcde", 2, 0, 0);
+    test("abcde", 5, 0, "abcde", 2, 1, -1);
+    test("abcde", 5, 0, "abcde", 2, 2, -2);
+    test("abcde", 5, 0, "abcde", 2, 3, -3);
+    test("abcde", 5, 0, "abcde", 2, 4, -3);
+    test("abcde", 5, 0, "abcde", 4, 0, 0);
+    test("abcde", 5, 0, "abcde", 4, 1, -1);
+    test("abcde", 5, 0, "abcde", 4, 2, -1);
+    test("abcde", 5, 0, "abcde", 5, 0, 0);
+    test("abcde", 5, 0, "abcde", 5, 1, 0);
+    test("abcde", 5, 0, "abcde", 6, 0, 0);
+    test("abcde", 5, 0, "abcdefghij", 0, 0, 0);
+    test("abcde", 5, 0, "abcdefghij", 0, 1, -1);
+    test("abcde", 5, 0, "abcdefghij", 0, 5, -5);
+    test("abcde", 5, 0, "abcdefghij", 0, 9, -9);
+    test("abcde", 5, 0, "abcdefghij", 0, 10, -10);
+    test("abcde", 5, 0, "abcdefghij", 0, 11, -10);
+    test("abcde", 5, 0, "abcdefghij", 1, 0, 0);
+    test("abcde", 5, 0, "abcdefghij", 1, 1, -1);
+    test("abcde", 5, 0, "abcdefghij", 1, 4, -4);
+    test("abcde", 5, 0, "abcdefghij", 1, 8, -8);
+    test("abcde", 5, 0, "abcdefghij", 1, 9, -9);
+    test("abcde", 5, 0, "abcdefghij", 1, 10, -9);
+    test("abcde", 5, 0, "abcdefghij", 5, 0, 0);
+    test("abcde", 5, 0, "abcdefghij", 5, 1, -1);
+    test("abcde", 5, 0, "abcdefghij", 5, 2, -2);
+    test("abcde", 5, 0, "abcdefghij", 5, 4, -4);
+    test("abcde", 5, 0, "abcdefghij", 5, 5, -5);
+    test("abcde", 5, 0, "abcdefghij", 5, 6, -5);
+    test("abcde", 5, 0, "abcdefghij", 9, 0, 0);
+    test("abcde", 5, 0, "abcdefghij", 9, 1, -1);
+    test("abcde", 5, 0, "abcdefghij", 9, 2, -1);
+    test("abcde", 5, 0, "abcdefghij", 10, 0, 0);
+    test("abcde", 5, 0, "abcdefghij", 10, 1, 0);
+    test("abcde", 5, 0, "abcdefghij", 11, 0, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcde", 5, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 5, 1, "", 0, 0, 0);
+    test("abcde", 5, 1, "", 0, 1, 0);
+    test("abcde", 5, 1, "", 1, 0, 0);
+    test("abcde", 5, 1, "abcde", 0, 0, 0);
+    test("abcde", 5, 1, "abcde", 0, 1, -1);
+    test("abcde", 5, 1, "abcde", 0, 2, -2);
+    test("abcde", 5, 1, "abcde", 0, 4, -4);
+    test("abcde", 5, 1, "abcde", 0, 5, -5);
+    test("abcde", 5, 1, "abcde", 0, 6, -5);
+    test("abcde", 5, 1, "abcde", 1, 0, 0);
+    test("abcde", 5, 1, "abcde", 1, 1, -1);
+    test("abcde", 5, 1, "abcde", 1, 2, -2);
+    test("abcde", 5, 1, "abcde", 1, 3, -3);
+    test("abcde", 5, 1, "abcde", 1, 4, -4);
+    test("abcde", 5, 1, "abcde", 1, 5, -4);
+    test("abcde", 5, 1, "abcde", 2, 0, 0);
+    test("abcde", 5, 1, "abcde", 2, 1, -1);
+    test("abcde", 5, 1, "abcde", 2, 2, -2);
+    test("abcde", 5, 1, "abcde", 2, 3, -3);
+    test("abcde", 5, 1, "abcde", 2, 4, -3);
+    test("abcde", 5, 1, "abcde", 4, 0, 0);
+    test("abcde", 5, 1, "abcde", 4, 1, -1);
+    test("abcde", 5, 1, "abcde", 4, 2, -1);
+    test("abcde", 5, 1, "abcde", 5, 0, 0);
+}
+
+void test18()
+{
+    test("abcde", 5, 1, "abcde", 5, 1, 0);
+    test("abcde", 5, 1, "abcde", 6, 0, 0);
+    test("abcde", 5, 1, "abcdefghij", 0, 0, 0);
+    test("abcde", 5, 1, "abcdefghij", 0, 1, -1);
+    test("abcde", 5, 1, "abcdefghij", 0, 5, -5);
+    test("abcde", 5, 1, "abcdefghij", 0, 9, -9);
+    test("abcde", 5, 1, "abcdefghij", 0, 10, -10);
+    test("abcde", 5, 1, "abcdefghij", 0, 11, -10);
+    test("abcde", 5, 1, "abcdefghij", 1, 0, 0);
+    test("abcde", 5, 1, "abcdefghij", 1, 1, -1);
+    test("abcde", 5, 1, "abcdefghij", 1, 4, -4);
+    test("abcde", 5, 1, "abcdefghij", 1, 8, -8);
+    test("abcde", 5, 1, "abcdefghij", 1, 9, -9);
+    test("abcde", 5, 1, "abcdefghij", 1, 10, -9);
+    test("abcde", 5, 1, "abcdefghij", 5, 0, 0);
+    test("abcde", 5, 1, "abcdefghij", 5, 1, -1);
+    test("abcde", 5, 1, "abcdefghij", 5, 2, -2);
+    test("abcde", 5, 1, "abcdefghij", 5, 4, -4);
+    test("abcde", 5, 1, "abcdefghij", 5, 5, -5);
+    test("abcde", 5, 1, "abcdefghij", 5, 6, -5);
+    test("abcde", 5, 1, "abcdefghij", 9, 0, 0);
+    test("abcde", 5, 1, "abcdefghij", 9, 1, -1);
+    test("abcde", 5, 1, "abcdefghij", 9, 2, -1);
+    test("abcde", 5, 1, "abcdefghij", 10, 0, 0);
+    test("abcde", 5, 1, "abcdefghij", 10, 1, 0);
+    test("abcde", 5, 1, "abcdefghij", 11, 0, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcde", 5, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcde", 6, 0, "", 0, 0, 0);
+    test("abcde", 6, 0, "", 0, 1, 0);
+    test("abcde", 6, 0, "", 1, 0, 0);
+    test("abcde", 6, 0, "abcde", 0, 0, 0);
+    test("abcde", 6, 0, "abcde", 0, 1, 0);
+    test("abcde", 6, 0, "abcde", 0, 2, 0);
+    test("abcde", 6, 0, "abcde", 0, 4, 0);
+    test("abcde", 6, 0, "abcde", 0, 5, 0);
+    test("abcde", 6, 0, "abcde", 0, 6, 0);
+    test("abcde", 6, 0, "abcde", 1, 0, 0);
+    test("abcde", 6, 0, "abcde", 1, 1, 0);
+    test("abcde", 6, 0, "abcde", 1, 2, 0);
+    test("abcde", 6, 0, "abcde", 1, 3, 0);
+    test("abcde", 6, 0, "abcde", 1, 4, 0);
+    test("abcde", 6, 0, "abcde", 1, 5, 0);
+    test("abcde", 6, 0, "abcde", 2, 0, 0);
+    test("abcde", 6, 0, "abcde", 2, 1, 0);
+    test("abcde", 6, 0, "abcde", 2, 2, 0);
+    test("abcde", 6, 0, "abcde", 2, 3, 0);
+    test("abcde", 6, 0, "abcde", 2, 4, 0);
+    test("abcde", 6, 0, "abcde", 4, 0, 0);
+    test("abcde", 6, 0, "abcde", 4, 1, 0);
+    test("abcde", 6, 0, "abcde", 4, 2, 0);
+    test("abcde", 6, 0, "abcde", 5, 0, 0);
+    test("abcde", 6, 0, "abcde", 5, 1, 0);
+    test("abcde", 6, 0, "abcde", 6, 0, 0);
+    test("abcde", 6, 0, "abcdefghij", 0, 0, 0);
+    test("abcde", 6, 0, "abcdefghij", 0, 1, 0);
+    test("abcde", 6, 0, "abcdefghij", 0, 5, 0);
+    test("abcde", 6, 0, "abcdefghij", 0, 9, 0);
+    test("abcde", 6, 0, "abcdefghij", 0, 10, 0);
+    test("abcde", 6, 0, "abcdefghij", 0, 11, 0);
+    test("abcde", 6, 0, "abcdefghij", 1, 0, 0);
+    test("abcde", 6, 0, "abcdefghij", 1, 1, 0);
+    test("abcde", 6, 0, "abcdefghij", 1, 4, 0);
+    test("abcde", 6, 0, "abcdefghij", 1, 8, 0);
+    test("abcde", 6, 0, "abcdefghij", 1, 9, 0);
+    test("abcde", 6, 0, "abcdefghij", 1, 10, 0);
+    test("abcde", 6, 0, "abcdefghij", 5, 0, 0);
+    test("abcde", 6, 0, "abcdefghij", 5, 1, 0);
+    test("abcde", 6, 0, "abcdefghij", 5, 2, 0);
+    test("abcde", 6, 0, "abcdefghij", 5, 4, 0);
+    test("abcde", 6, 0, "abcdefghij", 5, 5, 0);
+    test("abcde", 6, 0, "abcdefghij", 5, 6, 0);
+    test("abcde", 6, 0, "abcdefghij", 9, 0, 0);
+    test("abcde", 6, 0, "abcdefghij", 9, 1, 0);
+    test("abcde", 6, 0, "abcdefghij", 9, 2, 0);
+    test("abcde", 6, 0, "abcdefghij", 10, 0, 0);
+    test("abcde", 6, 0, "abcdefghij", 10, 1, 0);
+    test("abcde", 6, 0, "abcdefghij", 11, 0, 0);
+}
+
+void test19()
+{
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcde", 6, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 0, 0, "", 0, 0, 0);
+    test("abcdefghij", 0, 0, "", 0, 1, 0);
+    test("abcdefghij", 0, 0, "", 1, 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 0, 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 0, 1, -1);
+    test("abcdefghij", 0, 0, "abcde", 0, 2, -2);
+    test("abcdefghij", 0, 0, "abcde", 0, 4, -4);
+    test("abcdefghij", 0, 0, "abcde", 0, 5, -5);
+    test("abcdefghij", 0, 0, "abcde", 0, 6, -5);
+    test("abcdefghij", 0, 0, "abcde", 1, 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 1, 1, -1);
+    test("abcdefghij", 0, 0, "abcde", 1, 2, -2);
+    test("abcdefghij", 0, 0, "abcde", 1, 3, -3);
+    test("abcdefghij", 0, 0, "abcde", 1, 4, -4);
+    test("abcdefghij", 0, 0, "abcde", 1, 5, -4);
+    test("abcdefghij", 0, 0, "abcde", 2, 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 2, 1, -1);
+    test("abcdefghij", 0, 0, "abcde", 2, 2, -2);
+    test("abcdefghij", 0, 0, "abcde", 2, 3, -3);
+    test("abcdefghij", 0, 0, "abcde", 2, 4, -3);
+    test("abcdefghij", 0, 0, "abcde", 4, 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 4, 1, -1);
+    test("abcdefghij", 0, 0, "abcde", 4, 2, -1);
+    test("abcdefghij", 0, 0, "abcde", 5, 0, 0);
+    test("abcdefghij", 0, 0, "abcde", 5, 1, 0);
+    test("abcdefghij", 0, 0, "abcde", 6, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghij", 0, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghij", 0, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghij", 0, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghij", 0, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghij", 0, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghij", 0, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghij", 0, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghij", 0, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghij", 0, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 0, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 0, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 0, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghij", 0, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghij", 0, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghij", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 0, 1, "", 0, 0, 1);
+    test("abcdefghij", 0, 1, "", 0, 1, 1);
+}
+
+void test20()
+{
+    test("abcdefghij", 0, 1, "", 1, 0, 0);
+    test("abcdefghij", 0, 1, "abcde", 0, 0, 1);
+    test("abcdefghij", 0, 1, "abcde", 0, 1, 0);
+    test("abcdefghij", 0, 1, "abcde", 0, 2, -1);
+    test("abcdefghij", 0, 1, "abcde", 0, 4, -3);
+    test("abcdefghij", 0, 1, "abcde", 0, 5, -4);
+    test("abcdefghij", 0, 1, "abcde", 0, 6, -4);
+    test("abcdefghij", 0, 1, "abcde", 1, 0, 1);
+    test("abcdefghij", 0, 1, "abcde", 1, 1, -1);
+    test("abcdefghij", 0, 1, "abcde", 1, 2, -1);
+    test("abcdefghij", 0, 1, "abcde", 1, 3, -1);
+    test("abcdefghij", 0, 1, "abcde", 1, 4, -1);
+    test("abcdefghij", 0, 1, "abcde", 1, 5, -1);
+    test("abcdefghij", 0, 1, "abcde", 2, 0, 1);
+    test("abcdefghij", 0, 1, "abcde", 2, 1, -2);
+    test("abcdefghij", 0, 1, "abcde", 2, 2, -2);
+    test("abcdefghij", 0, 1, "abcde", 2, 3, -2);
+    test("abcdefghij", 0, 1, "abcde", 2, 4, -2);
+    test("abcdefghij", 0, 1, "abcde", 4, 0, 1);
+    test("abcdefghij", 0, 1, "abcde", 4, 1, -4);
+    test("abcdefghij", 0, 1, "abcde", 4, 2, -4);
+    test("abcdefghij", 0, 1, "abcde", 5, 0, 1);
+    test("abcdefghij", 0, 1, "abcde", 5, 1, 1);
+    test("abcdefghij", 0, 1, "abcde", 6, 0, 0);
+    test("abcdefghij", 0, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghij", 0, 1, 0);
+    test("abcdefghij", 0, 1, "abcdefghij", 0, 5, -4);
+    test("abcdefghij", 0, 1, "abcdefghij", 0, 9, -8);
+    test("abcdefghij", 0, 1, "abcdefghij", 0, 10, -9);
+    test("abcdefghij", 0, 1, "abcdefghij", 0, 11, -9);
+    test("abcdefghij", 0, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 0, 1, "abcdefghij", 1, 4, -1);
+    test("abcdefghij", 0, 1, "abcdefghij", 1, 8, -1);
+    test("abcdefghij", 0, 1, "abcdefghij", 1, 9, -1);
+    test("abcdefghij", 0, 1, "abcdefghij", 1, 10, -1);
+    test("abcdefghij", 0, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghij", 5, 1, -5);
+    test("abcdefghij", 0, 1, "abcdefghij", 5, 2, -5);
+    test("abcdefghij", 0, 1, "abcdefghij", 5, 4, -5);
+    test("abcdefghij", 0, 1, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 0, 1, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 0, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghij", 9, 1, -9);
+    test("abcdefghij", 0, 1, "abcdefghij", 9, 2, -9);
+    test("abcdefghij", 0, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghij", 0, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 1, 0);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 10, -9);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 19, -18);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 20, -19);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 0, 21, -19);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghij", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 0, 5, "", 0, 0, 5);
+    test("abcdefghij", 0, 5, "", 0, 1, 5);
+    test("abcdefghij", 0, 5, "", 1, 0, 0);
+    test("abcdefghij", 0, 5, "abcde", 0, 0, 5);
+    test("abcdefghij", 0, 5, "abcde", 0, 1, 4);
+    test("abcdefghij", 0, 5, "abcde", 0, 2, 3);
+    test("abcdefghij", 0, 5, "abcde", 0, 4, 1);
+    test("abcdefghij", 0, 5, "abcde", 0, 5, 0);
+    test("abcdefghij", 0, 5, "abcde", 0, 6, 0);
+    test("abcdefghij", 0, 5, "abcde", 1, 0, 5);
+    test("abcdefghij", 0, 5, "abcde", 1, 1, -1);
+    test("abcdefghij", 0, 5, "abcde", 1, 2, -1);
+    test("abcdefghij", 0, 5, "abcde", 1, 3, -1);
+    test("abcdefghij", 0, 5, "abcde", 1, 4, -1);
+    test("abcdefghij", 0, 5, "abcde", 1, 5, -1);
+    test("abcdefghij", 0, 5, "abcde", 2, 0, 5);
+    test("abcdefghij", 0, 5, "abcde", 2, 1, -2);
+    test("abcdefghij", 0, 5, "abcde", 2, 2, -2);
+    test("abcdefghij", 0, 5, "abcde", 2, 3, -2);
+    test("abcdefghij", 0, 5, "abcde", 2, 4, -2);
+    test("abcdefghij", 0, 5, "abcde", 4, 0, 5);
+    test("abcdefghij", 0, 5, "abcde", 4, 1, -4);
+    test("abcdefghij", 0, 5, "abcde", 4, 2, -4);
+    test("abcdefghij", 0, 5, "abcde", 5, 0, 5);
+    test("abcdefghij", 0, 5, "abcde", 5, 1, 5);
+    test("abcdefghij", 0, 5, "abcde", 6, 0, 0);
+    test("abcdefghij", 0, 5, "abcdefghij", 0, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghij", 0, 1, 4);
+}
+
+void test21()
+{
+    test("abcdefghij", 0, 5, "abcdefghij", 0, 5, 0);
+    test("abcdefghij", 0, 5, "abcdefghij", 0, 9, -4);
+    test("abcdefghij", 0, 5, "abcdefghij", 0, 10, -5);
+    test("abcdefghij", 0, 5, "abcdefghij", 0, 11, -5);
+    test("abcdefghij", 0, 5, "abcdefghij", 1, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 0, 5, "abcdefghij", 1, 4, -1);
+    test("abcdefghij", 0, 5, "abcdefghij", 1, 8, -1);
+    test("abcdefghij", 0, 5, "abcdefghij", 1, 9, -1);
+    test("abcdefghij", 0, 5, "abcdefghij", 1, 10, -1);
+    test("abcdefghij", 0, 5, "abcdefghij", 5, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghij", 5, 1, -5);
+    test("abcdefghij", 0, 5, "abcdefghij", 5, 2, -5);
+    test("abcdefghij", 0, 5, "abcdefghij", 5, 4, -5);
+    test("abcdefghij", 0, 5, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 0, 5, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 0, 5, "abcdefghij", 9, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghij", 9, 1, -9);
+    test("abcdefghij", 0, 5, "abcdefghij", 9, 2, -9);
+    test("abcdefghij", 0, 5, "abcdefghij", 10, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghij", 10, 1, 5);
+    test("abcdefghij", 0, 5, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 1, 4);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 10, -5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 19, -14);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 20, -15);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 0, 21, -15);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+    test("abcdefghij", 0, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 0, 9, "", 0, 0, 9);
+    test("abcdefghij", 0, 9, "", 0, 1, 9);
+    test("abcdefghij", 0, 9, "", 1, 0, 0);
+    test("abcdefghij", 0, 9, "abcde", 0, 0, 9);
+    test("abcdefghij", 0, 9, "abcde", 0, 1, 8);
+    test("abcdefghij", 0, 9, "abcde", 0, 2, 7);
+    test("abcdefghij", 0, 9, "abcde", 0, 4, 5);
+    test("abcdefghij", 0, 9, "abcde", 0, 5, 4);
+    test("abcdefghij", 0, 9, "abcde", 0, 6, 4);
+    test("abcdefghij", 0, 9, "abcde", 1, 0, 9);
+    test("abcdefghij", 0, 9, "abcde", 1, 1, -1);
+    test("abcdefghij", 0, 9, "abcde", 1, 2, -1);
+    test("abcdefghij", 0, 9, "abcde", 1, 3, -1);
+    test("abcdefghij", 0, 9, "abcde", 1, 4, -1);
+    test("abcdefghij", 0, 9, "abcde", 1, 5, -1);
+    test("abcdefghij", 0, 9, "abcde", 2, 0, 9);
+    test("abcdefghij", 0, 9, "abcde", 2, 1, -2);
+    test("abcdefghij", 0, 9, "abcde", 2, 2, -2);
+    test("abcdefghij", 0, 9, "abcde", 2, 3, -2);
+    test("abcdefghij", 0, 9, "abcde", 2, 4, -2);
+    test("abcdefghij", 0, 9, "abcde", 4, 0, 9);
+    test("abcdefghij", 0, 9, "abcde", 4, 1, -4);
+    test("abcdefghij", 0, 9, "abcde", 4, 2, -4);
+    test("abcdefghij", 0, 9, "abcde", 5, 0, 9);
+    test("abcdefghij", 0, 9, "abcde", 5, 1, 9);
+    test("abcdefghij", 0, 9, "abcde", 6, 0, 0);
+    test("abcdefghij", 0, 9, "abcdefghij", 0, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghij", 0, 1, 8);
+    test("abcdefghij", 0, 9, "abcdefghij", 0, 5, 4);
+    test("abcdefghij", 0, 9, "abcdefghij", 0, 9, 0);
+    test("abcdefghij", 0, 9, "abcdefghij", 0, 10, -1);
+    test("abcdefghij", 0, 9, "abcdefghij", 0, 11, -1);
+    test("abcdefghij", 0, 9, "abcdefghij", 1, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 0, 9, "abcdefghij", 1, 4, -1);
+    test("abcdefghij", 0, 9, "abcdefghij", 1, 8, -1);
+    test("abcdefghij", 0, 9, "abcdefghij", 1, 9, -1);
+    test("abcdefghij", 0, 9, "abcdefghij", 1, 10, -1);
+    test("abcdefghij", 0, 9, "abcdefghij", 5, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghij", 5, 1, -5);
+    test("abcdefghij", 0, 9, "abcdefghij", 5, 2, -5);
+    test("abcdefghij", 0, 9, "abcdefghij", 5, 4, -5);
+    test("abcdefghij", 0, 9, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 0, 9, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 0, 9, "abcdefghij", 9, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghij", 9, 1, -9);
+    test("abcdefghij", 0, 9, "abcdefghij", 9, 2, -9);
+    test("abcdefghij", 0, 9, "abcdefghij", 10, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghij", 10, 1, 9);
+    test("abcdefghij", 0, 9, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 1, 8);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 10, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 19, -10);
+}
+
+void test22()
+{
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 20, -11);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 0, 21, -11);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+    test("abcdefghij", 0, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 0, 10, "", 0, 0, 10);
+    test("abcdefghij", 0, 10, "", 0, 1, 10);
+    test("abcdefghij", 0, 10, "", 1, 0, 0);
+    test("abcdefghij", 0, 10, "abcde", 0, 0, 10);
+    test("abcdefghij", 0, 10, "abcde", 0, 1, 9);
+    test("abcdefghij", 0, 10, "abcde", 0, 2, 8);
+    test("abcdefghij", 0, 10, "abcde", 0, 4, 6);
+    test("abcdefghij", 0, 10, "abcde", 0, 5, 5);
+    test("abcdefghij", 0, 10, "abcde", 0, 6, 5);
+    test("abcdefghij", 0, 10, "abcde", 1, 0, 10);
+    test("abcdefghij", 0, 10, "abcde", 1, 1, -1);
+    test("abcdefghij", 0, 10, "abcde", 1, 2, -1);
+    test("abcdefghij", 0, 10, "abcde", 1, 3, -1);
+    test("abcdefghij", 0, 10, "abcde", 1, 4, -1);
+    test("abcdefghij", 0, 10, "abcde", 1, 5, -1);
+    test("abcdefghij", 0, 10, "abcde", 2, 0, 10);
+    test("abcdefghij", 0, 10, "abcde", 2, 1, -2);
+    test("abcdefghij", 0, 10, "abcde", 2, 2, -2);
+    test("abcdefghij", 0, 10, "abcde", 2, 3, -2);
+    test("abcdefghij", 0, 10, "abcde", 2, 4, -2);
+    test("abcdefghij", 0, 10, "abcde", 4, 0, 10);
+    test("abcdefghij", 0, 10, "abcde", 4, 1, -4);
+    test("abcdefghij", 0, 10, "abcde", 4, 2, -4);
+    test("abcdefghij", 0, 10, "abcde", 5, 0, 10);
+    test("abcdefghij", 0, 10, "abcde", 5, 1, 10);
+    test("abcdefghij", 0, 10, "abcde", 6, 0, 0);
+    test("abcdefghij", 0, 10, "abcdefghij", 0, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghij", 0, 1, 9);
+    test("abcdefghij", 0, 10, "abcdefghij", 0, 5, 5);
+    test("abcdefghij", 0, 10, "abcdefghij", 0, 9, 1);
+    test("abcdefghij", 0, 10, "abcdefghij", 0, 10, 0);
+    test("abcdefghij", 0, 10, "abcdefghij", 0, 11, 0);
+    test("abcdefghij", 0, 10, "abcdefghij", 1, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 0, 10, "abcdefghij", 1, 4, -1);
+    test("abcdefghij", 0, 10, "abcdefghij", 1, 8, -1);
+    test("abcdefghij", 0, 10, "abcdefghij", 1, 9, -1);
+    test("abcdefghij", 0, 10, "abcdefghij", 1, 10, -1);
+    test("abcdefghij", 0, 10, "abcdefghij", 5, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghij", 5, 1, -5);
+    test("abcdefghij", 0, 10, "abcdefghij", 5, 2, -5);
+    test("abcdefghij", 0, 10, "abcdefghij", 5, 4, -5);
+    test("abcdefghij", 0, 10, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 0, 10, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 0, 10, "abcdefghij", 9, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghij", 9, 1, -9);
+    test("abcdefghij", 0, 10, "abcdefghij", 9, 2, -9);
+    test("abcdefghij", 0, 10, "abcdefghij", 10, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghij", 10, 1, 10);
+    test("abcdefghij", 0, 10, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 1, 9);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 10, 0);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 19, -9);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 20, -10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 0, 21, -10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 20, 0, 10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 20, 1, 10);
+    test("abcdefghij", 0, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 0, 11, "", 0, 0, 10);
+    test("abcdefghij", 0, 11, "", 0, 1, 10);
+    test("abcdefghij", 0, 11, "", 1, 0, 0);
+    test("abcdefghij", 0, 11, "abcde", 0, 0, 10);
+    test("abcdefghij", 0, 11, "abcde", 0, 1, 9);
+    test("abcdefghij", 0, 11, "abcde", 0, 2, 8);
+}
+
+void test23()
+{
+    test("abcdefghij", 0, 11, "abcde", 0, 4, 6);
+    test("abcdefghij", 0, 11, "abcde", 0, 5, 5);
+    test("abcdefghij", 0, 11, "abcde", 0, 6, 5);
+    test("abcdefghij", 0, 11, "abcde", 1, 0, 10);
+    test("abcdefghij", 0, 11, "abcde", 1, 1, -1);
+    test("abcdefghij", 0, 11, "abcde", 1, 2, -1);
+    test("abcdefghij", 0, 11, "abcde", 1, 3, -1);
+    test("abcdefghij", 0, 11, "abcde", 1, 4, -1);
+    test("abcdefghij", 0, 11, "abcde", 1, 5, -1);
+    test("abcdefghij", 0, 11, "abcde", 2, 0, 10);
+    test("abcdefghij", 0, 11, "abcde", 2, 1, -2);
+    test("abcdefghij", 0, 11, "abcde", 2, 2, -2);
+    test("abcdefghij", 0, 11, "abcde", 2, 3, -2);
+    test("abcdefghij", 0, 11, "abcde", 2, 4, -2);
+    test("abcdefghij", 0, 11, "abcde", 4, 0, 10);
+    test("abcdefghij", 0, 11, "abcde", 4, 1, -4);
+    test("abcdefghij", 0, 11, "abcde", 4, 2, -4);
+    test("abcdefghij", 0, 11, "abcde", 5, 0, 10);
+    test("abcdefghij", 0, 11, "abcde", 5, 1, 10);
+    test("abcdefghij", 0, 11, "abcde", 6, 0, 0);
+    test("abcdefghij", 0, 11, "abcdefghij", 0, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghij", 0, 1, 9);
+    test("abcdefghij", 0, 11, "abcdefghij", 0, 5, 5);
+    test("abcdefghij", 0, 11, "abcdefghij", 0, 9, 1);
+    test("abcdefghij", 0, 11, "abcdefghij", 0, 10, 0);
+    test("abcdefghij", 0, 11, "abcdefghij", 0, 11, 0);
+    test("abcdefghij", 0, 11, "abcdefghij", 1, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 0, 11, "abcdefghij", 1, 4, -1);
+    test("abcdefghij", 0, 11, "abcdefghij", 1, 8, -1);
+    test("abcdefghij", 0, 11, "abcdefghij", 1, 9, -1);
+    test("abcdefghij", 0, 11, "abcdefghij", 1, 10, -1);
+    test("abcdefghij", 0, 11, "abcdefghij", 5, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghij", 5, 1, -5);
+    test("abcdefghij", 0, 11, "abcdefghij", 5, 2, -5);
+    test("abcdefghij", 0, 11, "abcdefghij", 5, 4, -5);
+    test("abcdefghij", 0, 11, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 0, 11, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 0, 11, "abcdefghij", 9, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghij", 9, 1, -9);
+    test("abcdefghij", 0, 11, "abcdefghij", 9, 2, -9);
+    test("abcdefghij", 0, 11, "abcdefghij", 10, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghij", 10, 1, 10);
+    test("abcdefghij", 0, 11, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 1, 9);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 10, 0);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 19, -9);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 20, -10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 0, 21, -10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 20, 0, 10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 20, 1, 10);
+    test("abcdefghij", 0, 11, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 1, 0, "", 0, 0, 0);
+    test("abcdefghij", 1, 0, "", 0, 1, 0);
+    test("abcdefghij", 1, 0, "", 1, 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 0, 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 0, 1, -1);
+    test("abcdefghij", 1, 0, "abcde", 0, 2, -2);
+    test("abcdefghij", 1, 0, "abcde", 0, 4, -4);
+    test("abcdefghij", 1, 0, "abcde", 0, 5, -5);
+    test("abcdefghij", 1, 0, "abcde", 0, 6, -5);
+    test("abcdefghij", 1, 0, "abcde", 1, 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 1, 1, -1);
+    test("abcdefghij", 1, 0, "abcde", 1, 2, -2);
+    test("abcdefghij", 1, 0, "abcde", 1, 3, -3);
+    test("abcdefghij", 1, 0, "abcde", 1, 4, -4);
+    test("abcdefghij", 1, 0, "abcde", 1, 5, -4);
+    test("abcdefghij", 1, 0, "abcde", 2, 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 2, 1, -1);
+    test("abcdefghij", 1, 0, "abcde", 2, 2, -2);
+    test("abcdefghij", 1, 0, "abcde", 2, 3, -3);
+    test("abcdefghij", 1, 0, "abcde", 2, 4, -3);
+    test("abcdefghij", 1, 0, "abcde", 4, 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 4, 1, -1);
+    test("abcdefghij", 1, 0, "abcde", 4, 2, -1);
+    test("abcdefghij", 1, 0, "abcde", 5, 0, 0);
+    test("abcdefghij", 1, 0, "abcde", 5, 1, 0);
+    test("abcdefghij", 1, 0, "abcde", 6, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghij", 1, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghij", 1, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghij", 1, 0, "abcdefghij", 0, 11, -10);
+}
+
+void test24()
+{
+    test("abcdefghij", 1, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghij", 1, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghij", 1, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghij", 1, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghij", 1, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghij", 1, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 1, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 1, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 1, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghij", 1, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghij", 1, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghij", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 1, 1, "", 0, 0, 1);
+    test("abcdefghij", 1, 1, "", 0, 1, 1);
+    test("abcdefghij", 1, 1, "", 1, 0, 0);
+    test("abcdefghij", 1, 1, "abcde", 0, 0, 1);
+    test("abcdefghij", 1, 1, "abcde", 0, 1, 1);
+    test("abcdefghij", 1, 1, "abcde", 0, 2, 1);
+    test("abcdefghij", 1, 1, "abcde", 0, 4, 1);
+    test("abcdefghij", 1, 1, "abcde", 0, 5, 1);
+    test("abcdefghij", 1, 1, "abcde", 0, 6, 1);
+    test("abcdefghij", 1, 1, "abcde", 1, 0, 1);
+    test("abcdefghij", 1, 1, "abcde", 1, 1, 0);
+    test("abcdefghij", 1, 1, "abcde", 1, 2, -1);
+    test("abcdefghij", 1, 1, "abcde", 1, 3, -2);
+    test("abcdefghij", 1, 1, "abcde", 1, 4, -3);
+    test("abcdefghij", 1, 1, "abcde", 1, 5, -3);
+    test("abcdefghij", 1, 1, "abcde", 2, 0, 1);
+    test("abcdefghij", 1, 1, "abcde", 2, 1, -1);
+    test("abcdefghij", 1, 1, "abcde", 2, 2, -1);
+    test("abcdefghij", 1, 1, "abcde", 2, 3, -1);
+    test("abcdefghij", 1, 1, "abcde", 2, 4, -1);
+    test("abcdefghij", 1, 1, "abcde", 4, 0, 1);
+    test("abcdefghij", 1, 1, "abcde", 4, 1, -3);
+    test("abcdefghij", 1, 1, "abcde", 4, 2, -3);
+    test("abcdefghij", 1, 1, "abcde", 5, 0, 1);
+    test("abcdefghij", 1, 1, "abcde", 5, 1, 1);
+    test("abcdefghij", 1, 1, "abcde", 6, 0, 0);
+    test("abcdefghij", 1, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 0, 1, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 0, 5, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 0, 9, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 0, 10, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 0, 11, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 1, 1, 0);
+    test("abcdefghij", 1, 1, "abcdefghij", 1, 4, -3);
+    test("abcdefghij", 1, 1, "abcdefghij", 1, 8, -7);
+    test("abcdefghij", 1, 1, "abcdefghij", 1, 9, -8);
+    test("abcdefghij", 1, 1, "abcdefghij", 1, 10, -8);
+    test("abcdefghij", 1, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 5, 1, -4);
+    test("abcdefghij", 1, 1, "abcdefghij", 5, 2, -4);
+    test("abcdefghij", 1, 1, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 1, 1, "abcdefghij", 5, 5, -4);
+    test("abcdefghij", 1, 1, "abcdefghij", 5, 6, -4);
+    test("abcdefghij", 1, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 9, 1, -8);
+    test("abcdefghij", 1, 1, "abcdefghij", 9, 2, -8);
+    test("abcdefghij", 1, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghij", 1, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 1, 0);
+}
+
+void test25()
+{
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 9, -8);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 18, -17);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 19, -18);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 1, 20, -18);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghij", 1, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 1, 4, "", 0, 0, 4);
+    test("abcdefghij", 1, 4, "", 0, 1, 4);
+    test("abcdefghij", 1, 4, "", 1, 0, 0);
+    test("abcdefghij", 1, 4, "abcde", 0, 0, 4);
+    test("abcdefghij", 1, 4, "abcde", 0, 1, 1);
+    test("abcdefghij", 1, 4, "abcde", 0, 2, 1);
+    test("abcdefghij", 1, 4, "abcde", 0, 4, 1);
+    test("abcdefghij", 1, 4, "abcde", 0, 5, 1);
+    test("abcdefghij", 1, 4, "abcde", 0, 6, 1);
+    test("abcdefghij", 1, 4, "abcde", 1, 0, 4);
+    test("abcdefghij", 1, 4, "abcde", 1, 1, 3);
+    test("abcdefghij", 1, 4, "abcde", 1, 2, 2);
+    test("abcdefghij", 1, 4, "abcde", 1, 3, 1);
+    test("abcdefghij", 1, 4, "abcde", 1, 4, 0);
+    test("abcdefghij", 1, 4, "abcde", 1, 5, 0);
+    test("abcdefghij", 1, 4, "abcde", 2, 0, 4);
+    test("abcdefghij", 1, 4, "abcde", 2, 1, -1);
+    test("abcdefghij", 1, 4, "abcde", 2, 2, -1);
+    test("abcdefghij", 1, 4, "abcde", 2, 3, -1);
+    test("abcdefghij", 1, 4, "abcde", 2, 4, -1);
+    test("abcdefghij", 1, 4, "abcde", 4, 0, 4);
+    test("abcdefghij", 1, 4, "abcde", 4, 1, -3);
+    test("abcdefghij", 1, 4, "abcde", 4, 2, -3);
+    test("abcdefghij", 1, 4, "abcde", 5, 0, 4);
+    test("abcdefghij", 1, 4, "abcde", 5, 1, 4);
+    test("abcdefghij", 1, 4, "abcde", 6, 0, 0);
+    test("abcdefghij", 1, 4, "abcdefghij", 0, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghij", 0, 1, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 0, 5, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 0, 9, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 0, 10, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 0, 11, 1);
+    test("abcdefghij", 1, 4, "abcdefghij", 1, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghij", 1, 1, 3);
+    test("abcdefghij", 1, 4, "abcdefghij", 1, 4, 0);
+    test("abcdefghij", 1, 4, "abcdefghij", 1, 8, -4);
+    test("abcdefghij", 1, 4, "abcdefghij", 1, 9, -5);
+    test("abcdefghij", 1, 4, "abcdefghij", 1, 10, -5);
+    test("abcdefghij", 1, 4, "abcdefghij", 5, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghij", 5, 1, -4);
+    test("abcdefghij", 1, 4, "abcdefghij", 5, 2, -4);
+    test("abcdefghij", 1, 4, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 1, 4, "abcdefghij", 5, 5, -4);
+    test("abcdefghij", 1, 4, "abcdefghij", 5, 6, -4);
+    test("abcdefghij", 1, 4, "abcdefghij", 9, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghij", 9, 1, -8);
+    test("abcdefghij", 1, 4, "abcdefghij", 9, 2, -8);
+    test("abcdefghij", 1, 4, "abcdefghij", 10, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghij", 10, 1, 4);
+    test("abcdefghij", 1, 4, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 1, 3);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 9, -5);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 18, -14);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 19, -15);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 1, 20, -15);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+    test("abcdefghij", 1, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 1, 8, "", 0, 0, 8);
+    test("abcdefghij", 1, 8, "", 0, 1, 8);
+    test("abcdefghij", 1, 8, "", 1, 0, 0);
+    test("abcdefghij", 1, 8, "abcde", 0, 0, 8);
+    test("abcdefghij", 1, 8, "abcde", 0, 1, 1);
+    test("abcdefghij", 1, 8, "abcde", 0, 2, 1);
+    test("abcdefghij", 1, 8, "abcde", 0, 4, 1);
+    test("abcdefghij", 1, 8, "abcde", 0, 5, 1);
+    test("abcdefghij", 1, 8, "abcde", 0, 6, 1);
+    test("abcdefghij", 1, 8, "abcde", 1, 0, 8);
+}
+
+void test26()
+{
+    test("abcdefghij", 1, 8, "abcde", 1, 1, 7);
+    test("abcdefghij", 1, 8, "abcde", 1, 2, 6);
+    test("abcdefghij", 1, 8, "abcde", 1, 3, 5);
+    test("abcdefghij", 1, 8, "abcde", 1, 4, 4);
+    test("abcdefghij", 1, 8, "abcde", 1, 5, 4);
+    test("abcdefghij", 1, 8, "abcde", 2, 0, 8);
+    test("abcdefghij", 1, 8, "abcde", 2, 1, -1);
+    test("abcdefghij", 1, 8, "abcde", 2, 2, -1);
+    test("abcdefghij", 1, 8, "abcde", 2, 3, -1);
+    test("abcdefghij", 1, 8, "abcde", 2, 4, -1);
+    test("abcdefghij", 1, 8, "abcde", 4, 0, 8);
+    test("abcdefghij", 1, 8, "abcde", 4, 1, -3);
+    test("abcdefghij", 1, 8, "abcde", 4, 2, -3);
+    test("abcdefghij", 1, 8, "abcde", 5, 0, 8);
+    test("abcdefghij", 1, 8, "abcde", 5, 1, 8);
+    test("abcdefghij", 1, 8, "abcde", 6, 0, 0);
+    test("abcdefghij", 1, 8, "abcdefghij", 0, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghij", 0, 1, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 0, 5, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 0, 9, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 0, 10, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 0, 11, 1);
+    test("abcdefghij", 1, 8, "abcdefghij", 1, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghij", 1, 1, 7);
+    test("abcdefghij", 1, 8, "abcdefghij", 1, 4, 4);
+    test("abcdefghij", 1, 8, "abcdefghij", 1, 8, 0);
+    test("abcdefghij", 1, 8, "abcdefghij", 1, 9, -1);
+    test("abcdefghij", 1, 8, "abcdefghij", 1, 10, -1);
+    test("abcdefghij", 1, 8, "abcdefghij", 5, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghij", 5, 1, -4);
+    test("abcdefghij", 1, 8, "abcdefghij", 5, 2, -4);
+    test("abcdefghij", 1, 8, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 1, 8, "abcdefghij", 5, 5, -4);
+    test("abcdefghij", 1, 8, "abcdefghij", 5, 6, -4);
+    test("abcdefghij", 1, 8, "abcdefghij", 9, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghij", 9, 1, -8);
+    test("abcdefghij", 1, 8, "abcdefghij", 9, 2, -8);
+    test("abcdefghij", 1, 8, "abcdefghij", 10, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghij", 10, 1, 8);
+    test("abcdefghij", 1, 8, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 1, 7);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 18, -10);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 19, -11);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 1, 20, -11);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 20, 0, 8);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 20, 1, 8);
+    test("abcdefghij", 1, 8, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 1, 9, "", 0, 0, 9);
+    test("abcdefghij", 1, 9, "", 0, 1, 9);
+    test("abcdefghij", 1, 9, "", 1, 0, 0);
+    test("abcdefghij", 1, 9, "abcde", 0, 0, 9);
+    test("abcdefghij", 1, 9, "abcde", 0, 1, 1);
+    test("abcdefghij", 1, 9, "abcde", 0, 2, 1);
+    test("abcdefghij", 1, 9, "abcde", 0, 4, 1);
+    test("abcdefghij", 1, 9, "abcde", 0, 5, 1);
+    test("abcdefghij", 1, 9, "abcde", 0, 6, 1);
+    test("abcdefghij", 1, 9, "abcde", 1, 0, 9);
+    test("abcdefghij", 1, 9, "abcde", 1, 1, 8);
+    test("abcdefghij", 1, 9, "abcde", 1, 2, 7);
+    test("abcdefghij", 1, 9, "abcde", 1, 3, 6);
+    test("abcdefghij", 1, 9, "abcde", 1, 4, 5);
+    test("abcdefghij", 1, 9, "abcde", 1, 5, 5);
+    test("abcdefghij", 1, 9, "abcde", 2, 0, 9);
+    test("abcdefghij", 1, 9, "abcde", 2, 1, -1);
+    test("abcdefghij", 1, 9, "abcde", 2, 2, -1);
+    test("abcdefghij", 1, 9, "abcde", 2, 3, -1);
+    test("abcdefghij", 1, 9, "abcde", 2, 4, -1);
+    test("abcdefghij", 1, 9, "abcde", 4, 0, 9);
+    test("abcdefghij", 1, 9, "abcde", 4, 1, -3);
+    test("abcdefghij", 1, 9, "abcde", 4, 2, -3);
+    test("abcdefghij", 1, 9, "abcde", 5, 0, 9);
+    test("abcdefghij", 1, 9, "abcde", 5, 1, 9);
+    test("abcdefghij", 1, 9, "abcde", 6, 0, 0);
+    test("abcdefghij", 1, 9, "abcdefghij", 0, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghij", 0, 1, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 0, 5, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 0, 9, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 0, 10, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 0, 11, 1);
+    test("abcdefghij", 1, 9, "abcdefghij", 1, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghij", 1, 1, 8);
+    test("abcdefghij", 1, 9, "abcdefghij", 1, 4, 5);
+    test("abcdefghij", 1, 9, "abcdefghij", 1, 8, 1);
+}
+
+void test27()
+{
+    test("abcdefghij", 1, 9, "abcdefghij", 1, 9, 0);
+    test("abcdefghij", 1, 9, "abcdefghij", 1, 10, 0);
+    test("abcdefghij", 1, 9, "abcdefghij", 5, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghij", 5, 1, -4);
+    test("abcdefghij", 1, 9, "abcdefghij", 5, 2, -4);
+    test("abcdefghij", 1, 9, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 1, 9, "abcdefghij", 5, 5, -4);
+    test("abcdefghij", 1, 9, "abcdefghij", 5, 6, -4);
+    test("abcdefghij", 1, 9, "abcdefghij", 9, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghij", 9, 1, -8);
+    test("abcdefghij", 1, 9, "abcdefghij", 9, 2, -8);
+    test("abcdefghij", 1, 9, "abcdefghij", 10, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghij", 10, 1, 9);
+    test("abcdefghij", 1, 9, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 1, 8);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 9, 0);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 18, -9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 19, -10);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 1, 20, -10);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+    test("abcdefghij", 1, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 1, 10, "", 0, 0, 9);
+    test("abcdefghij", 1, 10, "", 0, 1, 9);
+    test("abcdefghij", 1, 10, "", 1, 0, 0);
+    test("abcdefghij", 1, 10, "abcde", 0, 0, 9);
+    test("abcdefghij", 1, 10, "abcde", 0, 1, 1);
+    test("abcdefghij", 1, 10, "abcde", 0, 2, 1);
+    test("abcdefghij", 1, 10, "abcde", 0, 4, 1);
+    test("abcdefghij", 1, 10, "abcde", 0, 5, 1);
+    test("abcdefghij", 1, 10, "abcde", 0, 6, 1);
+    test("abcdefghij", 1, 10, "abcde", 1, 0, 9);
+    test("abcdefghij", 1, 10, "abcde", 1, 1, 8);
+    test("abcdefghij", 1, 10, "abcde", 1, 2, 7);
+    test("abcdefghij", 1, 10, "abcde", 1, 3, 6);
+    test("abcdefghij", 1, 10, "abcde", 1, 4, 5);
+    test("abcdefghij", 1, 10, "abcde", 1, 5, 5);
+    test("abcdefghij", 1, 10, "abcde", 2, 0, 9);
+    test("abcdefghij", 1, 10, "abcde", 2, 1, -1);
+    test("abcdefghij", 1, 10, "abcde", 2, 2, -1);
+    test("abcdefghij", 1, 10, "abcde", 2, 3, -1);
+    test("abcdefghij", 1, 10, "abcde", 2, 4, -1);
+    test("abcdefghij", 1, 10, "abcde", 4, 0, 9);
+    test("abcdefghij", 1, 10, "abcde", 4, 1, -3);
+    test("abcdefghij", 1, 10, "abcde", 4, 2, -3);
+    test("abcdefghij", 1, 10, "abcde", 5, 0, 9);
+    test("abcdefghij", 1, 10, "abcde", 5, 1, 9);
+    test("abcdefghij", 1, 10, "abcde", 6, 0, 0);
+    test("abcdefghij", 1, 10, "abcdefghij", 0, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghij", 0, 1, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 0, 5, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 0, 9, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 0, 10, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 0, 11, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 1, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghij", 1, 1, 8);
+    test("abcdefghij", 1, 10, "abcdefghij", 1, 4, 5);
+    test("abcdefghij", 1, 10, "abcdefghij", 1, 8, 1);
+    test("abcdefghij", 1, 10, "abcdefghij", 1, 9, 0);
+    test("abcdefghij", 1, 10, "abcdefghij", 1, 10, 0);
+    test("abcdefghij", 1, 10, "abcdefghij", 5, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghij", 5, 1, -4);
+    test("abcdefghij", 1, 10, "abcdefghij", 5, 2, -4);
+    test("abcdefghij", 1, 10, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 1, 10, "abcdefghij", 5, 5, -4);
+    test("abcdefghij", 1, 10, "abcdefghij", 5, 6, -4);
+    test("abcdefghij", 1, 10, "abcdefghij", 9, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghij", 9, 1, -8);
+    test("abcdefghij", 1, 10, "abcdefghij", 9, 2, -8);
+    test("abcdefghij", 1, 10, "abcdefghij", 10, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghij", 10, 1, 9);
+    test("abcdefghij", 1, 10, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 1, 8);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 9, 0);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 18, -9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 19, -10);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 1, 20, -10);
+}
+
+void test28()
+{
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 20, 0, 9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 20, 1, 9);
+    test("abcdefghij", 1, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 5, 0, "", 0, 0, 0);
+    test("abcdefghij", 5, 0, "", 0, 1, 0);
+    test("abcdefghij", 5, 0, "", 1, 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 0, 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 0, 1, -1);
+    test("abcdefghij", 5, 0, "abcde", 0, 2, -2);
+    test("abcdefghij", 5, 0, "abcde", 0, 4, -4);
+    test("abcdefghij", 5, 0, "abcde", 0, 5, -5);
+    test("abcdefghij", 5, 0, "abcde", 0, 6, -5);
+    test("abcdefghij", 5, 0, "abcde", 1, 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 1, 1, -1);
+    test("abcdefghij", 5, 0, "abcde", 1, 2, -2);
+    test("abcdefghij", 5, 0, "abcde", 1, 3, -3);
+    test("abcdefghij", 5, 0, "abcde", 1, 4, -4);
+    test("abcdefghij", 5, 0, "abcde", 1, 5, -4);
+    test("abcdefghij", 5, 0, "abcde", 2, 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 2, 1, -1);
+    test("abcdefghij", 5, 0, "abcde", 2, 2, -2);
+    test("abcdefghij", 5, 0, "abcde", 2, 3, -3);
+    test("abcdefghij", 5, 0, "abcde", 2, 4, -3);
+    test("abcdefghij", 5, 0, "abcde", 4, 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 4, 1, -1);
+    test("abcdefghij", 5, 0, "abcde", 4, 2, -1);
+    test("abcdefghij", 5, 0, "abcde", 5, 0, 0);
+    test("abcdefghij", 5, 0, "abcde", 5, 1, 0);
+    test("abcdefghij", 5, 0, "abcde", 6, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghij", 5, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghij", 5, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghij", 5, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghij", 5, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghij", 5, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghij", 5, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghij", 5, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghij", 5, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghij", 5, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 5, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 5, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 5, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghij", 5, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghij", 5, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghij", 5, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 5, 1, "", 0, 0, 1);
+    test("abcdefghij", 5, 1, "", 0, 1, 1);
+    test("abcdefghij", 5, 1, "", 1, 0, 0);
+    test("abcdefghij", 5, 1, "abcde", 0, 0, 1);
+    test("abcdefghij", 5, 1, "abcde", 0, 1, 5);
+    test("abcdefghij", 5, 1, "abcde", 0, 2, 5);
+    test("abcdefghij", 5, 1, "abcde", 0, 4, 5);
+    test("abcdefghij", 5, 1, "abcde", 0, 5, 5);
+    test("abcdefghij", 5, 1, "abcde", 0, 6, 5);
+    test("abcdefghij", 5, 1, "abcde", 1, 0, 1);
+    test("abcdefghij", 5, 1, "abcde", 1, 1, 4);
+    test("abcdefghij", 5, 1, "abcde", 1, 2, 4);
+    test("abcdefghij", 5, 1, "abcde", 1, 3, 4);
+    test("abcdefghij", 5, 1, "abcde", 1, 4, 4);
+}
+
+void test29()
+{
+    test("abcdefghij", 5, 1, "abcde", 1, 5, 4);
+    test("abcdefghij", 5, 1, "abcde", 2, 0, 1);
+    test("abcdefghij", 5, 1, "abcde", 2, 1, 3);
+    test("abcdefghij", 5, 1, "abcde", 2, 2, 3);
+    test("abcdefghij", 5, 1, "abcde", 2, 3, 3);
+    test("abcdefghij", 5, 1, "abcde", 2, 4, 3);
+    test("abcdefghij", 5, 1, "abcde", 4, 0, 1);
+    test("abcdefghij", 5, 1, "abcde", 4, 1, 1);
+    test("abcdefghij", 5, 1, "abcde", 4, 2, 1);
+    test("abcdefghij", 5, 1, "abcde", 5, 0, 1);
+    test("abcdefghij", 5, 1, "abcde", 5, 1, 1);
+    test("abcdefghij", 5, 1, "abcde", 6, 0, 0);
+    test("abcdefghij", 5, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghij", 0, 1, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 0, 5, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 0, 9, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 0, 10, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 0, 11, 5);
+    test("abcdefghij", 5, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghij", 1, 1, 4);
+    test("abcdefghij", 5, 1, "abcdefghij", 1, 4, 4);
+    test("abcdefghij", 5, 1, "abcdefghij", 1, 8, 4);
+    test("abcdefghij", 5, 1, "abcdefghij", 1, 9, 4);
+    test("abcdefghij", 5, 1, "abcdefghij", 1, 10, 4);
+    test("abcdefghij", 5, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghij", 5, 1, 0);
+    test("abcdefghij", 5, 1, "abcdefghij", 5, 2, -1);
+    test("abcdefghij", 5, 1, "abcdefghij", 5, 4, -3);
+    test("abcdefghij", 5, 1, "abcdefghij", 5, 5, -4);
+    test("abcdefghij", 5, 1, "abcdefghij", 5, 6, -4);
+    test("abcdefghij", 5, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghij", 9, 1, -4);
+    test("abcdefghij", 5, 1, "abcdefghij", 9, 2, -4);
+    test("abcdefghij", 5, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghij", 5, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 1, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 10, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 19, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 20, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 0, 21, 5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 1, 4);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 9, 4);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 18, 4);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 19, 4);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 1, 20, 4);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 1, -5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 9, -5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 10, -5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 10, 11, -5);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 1, -14);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 19, 2, -14);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghij", 5, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 5, 2, "", 0, 0, 2);
+    test("abcdefghij", 5, 2, "", 0, 1, 2);
+    test("abcdefghij", 5, 2, "", 1, 0, 0);
+    test("abcdefghij", 5, 2, "abcde", 0, 0, 2);
+    test("abcdefghij", 5, 2, "abcde", 0, 1, 5);
+    test("abcdefghij", 5, 2, "abcde", 0, 2, 5);
+    test("abcdefghij", 5, 2, "abcde", 0, 4, 5);
+    test("abcdefghij", 5, 2, "abcde", 0, 5, 5);
+    test("abcdefghij", 5, 2, "abcde", 0, 6, 5);
+    test("abcdefghij", 5, 2, "abcde", 1, 0, 2);
+    test("abcdefghij", 5, 2, "abcde", 1, 1, 4);
+    test("abcdefghij", 5, 2, "abcde", 1, 2, 4);
+    test("abcdefghij", 5, 2, "abcde", 1, 3, 4);
+    test("abcdefghij", 5, 2, "abcde", 1, 4, 4);
+    test("abcdefghij", 5, 2, "abcde", 1, 5, 4);
+    test("abcdefghij", 5, 2, "abcde", 2, 0, 2);
+    test("abcdefghij", 5, 2, "abcde", 2, 1, 3);
+    test("abcdefghij", 5, 2, "abcde", 2, 2, 3);
+    test("abcdefghij", 5, 2, "abcde", 2, 3, 3);
+    test("abcdefghij", 5, 2, "abcde", 2, 4, 3);
+    test("abcdefghij", 5, 2, "abcde", 4, 0, 2);
+    test("abcdefghij", 5, 2, "abcde", 4, 1, 1);
+    test("abcdefghij", 5, 2, "abcde", 4, 2, 1);
+    test("abcdefghij", 5, 2, "abcde", 5, 0, 2);
+    test("abcdefghij", 5, 2, "abcde", 5, 1, 2);
+    test("abcdefghij", 5, 2, "abcde", 6, 0, 0);
+    test("abcdefghij", 5, 2, "abcdefghij", 0, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghij", 0, 1, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 0, 5, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 0, 9, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 0, 10, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 0, 11, 5);
+    test("abcdefghij", 5, 2, "abcdefghij", 1, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghij", 1, 1, 4);
+    test("abcdefghij", 5, 2, "abcdefghij", 1, 4, 4);
+    test("abcdefghij", 5, 2, "abcdefghij", 1, 8, 4);
+    test("abcdefghij", 5, 2, "abcdefghij", 1, 9, 4);
+    test("abcdefghij", 5, 2, "abcdefghij", 1, 10, 4);
+    test("abcdefghij", 5, 2, "abcdefghij", 5, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghij", 5, 1, 1);
+}
+
+void test30()
+{
+    test("abcdefghij", 5, 2, "abcdefghij", 5, 2, 0);
+    test("abcdefghij", 5, 2, "abcdefghij", 5, 4, -2);
+    test("abcdefghij", 5, 2, "abcdefghij", 5, 5, -3);
+    test("abcdefghij", 5, 2, "abcdefghij", 5, 6, -3);
+    test("abcdefghij", 5, 2, "abcdefghij", 9, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghij", 9, 1, -4);
+    test("abcdefghij", 5, 2, "abcdefghij", 9, 2, -4);
+    test("abcdefghij", 5, 2, "abcdefghij", 10, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghij", 10, 1, 2);
+    test("abcdefghij", 5, 2, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 1, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 10, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 19, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 20, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 0, 21, 5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 1, 4);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 9, 4);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 18, 4);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 19, 4);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 1, 20, 4);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 1, -5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 9, -5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 10, -5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 10, 11, -5);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 1, -14);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 19, 2, -14);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 20, 0, 2);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 20, 1, 2);
+    test("abcdefghij", 5, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 5, 4, "", 0, 0, 4);
+    test("abcdefghij", 5, 4, "", 0, 1, 4);
+    test("abcdefghij", 5, 4, "", 1, 0, 0);
+    test("abcdefghij", 5, 4, "abcde", 0, 0, 4);
+    test("abcdefghij", 5, 4, "abcde", 0, 1, 5);
+    test("abcdefghij", 5, 4, "abcde", 0, 2, 5);
+    test("abcdefghij", 5, 4, "abcde", 0, 4, 5);
+    test("abcdefghij", 5, 4, "abcde", 0, 5, 5);
+    test("abcdefghij", 5, 4, "abcde", 0, 6, 5);
+    test("abcdefghij", 5, 4, "abcde", 1, 0, 4);
+    test("abcdefghij", 5, 4, "abcde", 1, 1, 4);
+    test("abcdefghij", 5, 4, "abcde", 1, 2, 4);
+    test("abcdefghij", 5, 4, "abcde", 1, 3, 4);
+    test("abcdefghij", 5, 4, "abcde", 1, 4, 4);
+    test("abcdefghij", 5, 4, "abcde", 1, 5, 4);
+    test("abcdefghij", 5, 4, "abcde", 2, 0, 4);
+    test("abcdefghij", 5, 4, "abcde", 2, 1, 3);
+    test("abcdefghij", 5, 4, "abcde", 2, 2, 3);
+    test("abcdefghij", 5, 4, "abcde", 2, 3, 3);
+    test("abcdefghij", 5, 4, "abcde", 2, 4, 3);
+    test("abcdefghij", 5, 4, "abcde", 4, 0, 4);
+    test("abcdefghij", 5, 4, "abcde", 4, 1, 1);
+    test("abcdefghij", 5, 4, "abcde", 4, 2, 1);
+    test("abcdefghij", 5, 4, "abcde", 5, 0, 4);
+    test("abcdefghij", 5, 4, "abcde", 5, 1, 4);
+    test("abcdefghij", 5, 4, "abcde", 6, 0, 0);
+    test("abcdefghij", 5, 4, "abcdefghij", 0, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 0, 1, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 0, 5, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 0, 9, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 0, 10, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 0, 11, 5);
+    test("abcdefghij", 5, 4, "abcdefghij", 1, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 1, 1, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 1, 4, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 1, 8, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 1, 9, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 1, 10, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 5, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 5, 1, 3);
+    test("abcdefghij", 5, 4, "abcdefghij", 5, 2, 2);
+    test("abcdefghij", 5, 4, "abcdefghij", 5, 4, 0);
+    test("abcdefghij", 5, 4, "abcdefghij", 5, 5, -1);
+    test("abcdefghij", 5, 4, "abcdefghij", 5, 6, -1);
+    test("abcdefghij", 5, 4, "abcdefghij", 9, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 9, 1, -4);
+    test("abcdefghij", 5, 4, "abcdefghij", 9, 2, -4);
+    test("abcdefghij", 5, 4, "abcdefghij", 10, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 10, 1, 4);
+    test("abcdefghij", 5, 4, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 1, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 10, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 19, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 20, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 0, 21, 5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 1, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 9, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 18, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 19, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 1, 20, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 1, -5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 9, -5);
+}
+
+void test31()
+{
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 10, -5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 10, 11, -5);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 1, -14);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 19, 2, -14);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 20, 0, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 20, 1, 4);
+    test("abcdefghij", 5, 4, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 5, 5, "", 0, 0, 5);
+    test("abcdefghij", 5, 5, "", 0, 1, 5);
+    test("abcdefghij", 5, 5, "", 1, 0, 0);
+    test("abcdefghij", 5, 5, "abcde", 0, 0, 5);
+    test("abcdefghij", 5, 5, "abcde", 0, 1, 5);
+    test("abcdefghij", 5, 5, "abcde", 0, 2, 5);
+    test("abcdefghij", 5, 5, "abcde", 0, 4, 5);
+    test("abcdefghij", 5, 5, "abcde", 0, 5, 5);
+    test("abcdefghij", 5, 5, "abcde", 0, 6, 5);
+    test("abcdefghij", 5, 5, "abcde", 1, 0, 5);
+    test("abcdefghij", 5, 5, "abcde", 1, 1, 4);
+    test("abcdefghij", 5, 5, "abcde", 1, 2, 4);
+    test("abcdefghij", 5, 5, "abcde", 1, 3, 4);
+    test("abcdefghij", 5, 5, "abcde", 1, 4, 4);
+    test("abcdefghij", 5, 5, "abcde", 1, 5, 4);
+    test("abcdefghij", 5, 5, "abcde", 2, 0, 5);
+    test("abcdefghij", 5, 5, "abcde", 2, 1, 3);
+    test("abcdefghij", 5, 5, "abcde", 2, 2, 3);
+    test("abcdefghij", 5, 5, "abcde", 2, 3, 3);
+    test("abcdefghij", 5, 5, "abcde", 2, 4, 3);
+    test("abcdefghij", 5, 5, "abcde", 4, 0, 5);
+    test("abcdefghij", 5, 5, "abcde", 4, 1, 1);
+    test("abcdefghij", 5, 5, "abcde", 4, 2, 1);
+    test("abcdefghij", 5, 5, "abcde", 5, 0, 5);
+    test("abcdefghij", 5, 5, "abcde", 5, 1, 5);
+    test("abcdefghij", 5, 5, "abcde", 6, 0, 0);
+    test("abcdefghij", 5, 5, "abcdefghij", 0, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 0, 1, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 0, 5, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 0, 9, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 0, 10, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 0, 11, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 1, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 1, 1, 4);
+    test("abcdefghij", 5, 5, "abcdefghij", 1, 4, 4);
+    test("abcdefghij", 5, 5, "abcdefghij", 1, 8, 4);
+    test("abcdefghij", 5, 5, "abcdefghij", 1, 9, 4);
+    test("abcdefghij", 5, 5, "abcdefghij", 1, 10, 4);
+    test("abcdefghij", 5, 5, "abcdefghij", 5, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 5, 1, 4);
+    test("abcdefghij", 5, 5, "abcdefghij", 5, 2, 3);
+    test("abcdefghij", 5, 5, "abcdefghij", 5, 4, 1);
+    test("abcdefghij", 5, 5, "abcdefghij", 5, 5, 0);
+    test("abcdefghij", 5, 5, "abcdefghij", 5, 6, 0);
+    test("abcdefghij", 5, 5, "abcdefghij", 9, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 9, 1, -4);
+    test("abcdefghij", 5, 5, "abcdefghij", 9, 2, -4);
+    test("abcdefghij", 5, 5, "abcdefghij", 10, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 10, 1, 5);
+    test("abcdefghij", 5, 5, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 1, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 10, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 19, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 20, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 0, 21, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 1, 4);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 9, 4);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 18, 4);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 19, 4);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 1, 20, 4);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 1, -5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 9, -5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 10, -5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 10, 11, -5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 1, -14);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 19, 2, -14);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+    test("abcdefghij", 5, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 5, 6, "", 0, 0, 5);
+    test("abcdefghij", 5, 6, "", 0, 1, 5);
+    test("abcdefghij", 5, 6, "", 1, 0, 0);
+    test("abcdefghij", 5, 6, "abcde", 0, 0, 5);
+    test("abcdefghij", 5, 6, "abcde", 0, 1, 5);
+    test("abcdefghij", 5, 6, "abcde", 0, 2, 5);
+    test("abcdefghij", 5, 6, "abcde", 0, 4, 5);
+    test("abcdefghij", 5, 6, "abcde", 0, 5, 5);
+    test("abcdefghij", 5, 6, "abcde", 0, 6, 5);
+    test("abcdefghij", 5, 6, "abcde", 1, 0, 5);
+    test("abcdefghij", 5, 6, "abcde", 1, 1, 4);
+    test("abcdefghij", 5, 6, "abcde", 1, 2, 4);
+    test("abcdefghij", 5, 6, "abcde", 1, 3, 4);
+    test("abcdefghij", 5, 6, "abcde", 1, 4, 4);
+    test("abcdefghij", 5, 6, "abcde", 1, 5, 4);
+    test("abcdefghij", 5, 6, "abcde", 2, 0, 5);
+    test("abcdefghij", 5, 6, "abcde", 2, 1, 3);
+    test("abcdefghij", 5, 6, "abcde", 2, 2, 3);
+}
+
+void test32()
+{
+    test("abcdefghij", 5, 6, "abcde", 2, 3, 3);
+    test("abcdefghij", 5, 6, "abcde", 2, 4, 3);
+    test("abcdefghij", 5, 6, "abcde", 4, 0, 5);
+    test("abcdefghij", 5, 6, "abcde", 4, 1, 1);
+    test("abcdefghij", 5, 6, "abcde", 4, 2, 1);
+    test("abcdefghij", 5, 6, "abcde", 5, 0, 5);
+    test("abcdefghij", 5, 6, "abcde", 5, 1, 5);
+    test("abcdefghij", 5, 6, "abcde", 6, 0, 0);
+    test("abcdefghij", 5, 6, "abcdefghij", 0, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 0, 1, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 0, 5, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 0, 9, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 0, 10, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 0, 11, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 1, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 1, 1, 4);
+    test("abcdefghij", 5, 6, "abcdefghij", 1, 4, 4);
+    test("abcdefghij", 5, 6, "abcdefghij", 1, 8, 4);
+    test("abcdefghij", 5, 6, "abcdefghij", 1, 9, 4);
+    test("abcdefghij", 5, 6, "abcdefghij", 1, 10, 4);
+    test("abcdefghij", 5, 6, "abcdefghij", 5, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 5, 1, 4);
+    test("abcdefghij", 5, 6, "abcdefghij", 5, 2, 3);
+    test("abcdefghij", 5, 6, "abcdefghij", 5, 4, 1);
+    test("abcdefghij", 5, 6, "abcdefghij", 5, 5, 0);
+    test("abcdefghij", 5, 6, "abcdefghij", 5, 6, 0);
+    test("abcdefghij", 5, 6, "abcdefghij", 9, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 9, 1, -4);
+    test("abcdefghij", 5, 6, "abcdefghij", 9, 2, -4);
+    test("abcdefghij", 5, 6, "abcdefghij", 10, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 10, 1, 5);
+    test("abcdefghij", 5, 6, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 1, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 10, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 19, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 20, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 0, 21, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 1, 4);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 9, 4);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 18, 4);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 19, 4);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 1, 20, 4);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 1, -5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 9, -5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 10, -5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 10, 11, -5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 1, -14);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 19, 2, -14);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 20, 0, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 20, 1, 5);
+    test("abcdefghij", 5, 6, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 9, 0, "", 0, 0, 0);
+    test("abcdefghij", 9, 0, "", 0, 1, 0);
+    test("abcdefghij", 9, 0, "", 1, 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 0, 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 0, 1, -1);
+    test("abcdefghij", 9, 0, "abcde", 0, 2, -2);
+    test("abcdefghij", 9, 0, "abcde", 0, 4, -4);
+    test("abcdefghij", 9, 0, "abcde", 0, 5, -5);
+    test("abcdefghij", 9, 0, "abcde", 0, 6, -5);
+    test("abcdefghij", 9, 0, "abcde", 1, 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 1, 1, -1);
+    test("abcdefghij", 9, 0, "abcde", 1, 2, -2);
+    test("abcdefghij", 9, 0, "abcde", 1, 3, -3);
+    test("abcdefghij", 9, 0, "abcde", 1, 4, -4);
+    test("abcdefghij", 9, 0, "abcde", 1, 5, -4);
+    test("abcdefghij", 9, 0, "abcde", 2, 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 2, 1, -1);
+    test("abcdefghij", 9, 0, "abcde", 2, 2, -2);
+    test("abcdefghij", 9, 0, "abcde", 2, 3, -3);
+    test("abcdefghij", 9, 0, "abcde", 2, 4, -3);
+    test("abcdefghij", 9, 0, "abcde", 4, 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 4, 1, -1);
+    test("abcdefghij", 9, 0, "abcde", 4, 2, -1);
+    test("abcdefghij", 9, 0, "abcde", 5, 0, 0);
+    test("abcdefghij", 9, 0, "abcde", 5, 1, 0);
+    test("abcdefghij", 9, 0, "abcde", 6, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghij", 9, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghij", 9, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghij", 9, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghij", 9, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghij", 9, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghij", 9, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghij", 9, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghij", 9, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghij", 9, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 9, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 9, 0, "abcdefghij", 5, 6, -5);
+}
+
+void test33()
+{
+    test("abcdefghij", 9, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghij", 9, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghij", 9, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghij", 9, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 9, 1, "", 0, 0, 1);
+    test("abcdefghij", 9, 1, "", 0, 1, 1);
+    test("abcdefghij", 9, 1, "", 1, 0, 0);
+    test("abcdefghij", 9, 1, "abcde", 0, 0, 1);
+    test("abcdefghij", 9, 1, "abcde", 0, 1, 9);
+    test("abcdefghij", 9, 1, "abcde", 0, 2, 9);
+    test("abcdefghij", 9, 1, "abcde", 0, 4, 9);
+    test("abcdefghij", 9, 1, "abcde", 0, 5, 9);
+    test("abcdefghij", 9, 1, "abcde", 0, 6, 9);
+    test("abcdefghij", 9, 1, "abcde", 1, 0, 1);
+    test("abcdefghij", 9, 1, "abcde", 1, 1, 8);
+    test("abcdefghij", 9, 1, "abcde", 1, 2, 8);
+    test("abcdefghij", 9, 1, "abcde", 1, 3, 8);
+    test("abcdefghij", 9, 1, "abcde", 1, 4, 8);
+    test("abcdefghij", 9, 1, "abcde", 1, 5, 8);
+    test("abcdefghij", 9, 1, "abcde", 2, 0, 1);
+    test("abcdefghij", 9, 1, "abcde", 2, 1, 7);
+    test("abcdefghij", 9, 1, "abcde", 2, 2, 7);
+    test("abcdefghij", 9, 1, "abcde", 2, 3, 7);
+    test("abcdefghij", 9, 1, "abcde", 2, 4, 7);
+    test("abcdefghij", 9, 1, "abcde", 4, 0, 1);
+    test("abcdefghij", 9, 1, "abcde", 4, 1, 5);
+    test("abcdefghij", 9, 1, "abcde", 4, 2, 5);
+    test("abcdefghij", 9, 1, "abcde", 5, 0, 1);
+    test("abcdefghij", 9, 1, "abcde", 5, 1, 1);
+    test("abcdefghij", 9, 1, "abcde", 6, 0, 0);
+    test("abcdefghij", 9, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghij", 0, 1, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 0, 5, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 0, 9, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 0, 10, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 0, 11, 9);
+    test("abcdefghij", 9, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghij", 1, 1, 8);
+    test("abcdefghij", 9, 1, "abcdefghij", 1, 4, 8);
+    test("abcdefghij", 9, 1, "abcdefghij", 1, 8, 8);
+    test("abcdefghij", 9, 1, "abcdefghij", 1, 9, 8);
+    test("abcdefghij", 9, 1, "abcdefghij", 1, 10, 8);
+    test("abcdefghij", 9, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghij", 5, 1, 4);
+    test("abcdefghij", 9, 1, "abcdefghij", 5, 2, 4);
+    test("abcdefghij", 9, 1, "abcdefghij", 5, 4, 4);
+    test("abcdefghij", 9, 1, "abcdefghij", 5, 5, 4);
+    test("abcdefghij", 9, 1, "abcdefghij", 5, 6, 4);
+    test("abcdefghij", 9, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghij", 9, 1, 0);
+    test("abcdefghij", 9, 1, "abcdefghij", 9, 2, 0);
+    test("abcdefghij", 9, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghij", 9, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 1, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 10, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 19, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 20, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 0, 21, 9);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 1, 8);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 9, 8);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 18, 8);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 19, 8);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 1, 20, 8);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 5, -1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 9, -1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 10, -1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 10, 11, -1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 1, -10);
+}
+
+void test34()
+{
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 19, 2, -10);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghij", 9, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 9, 2, "", 0, 0, 1);
+    test("abcdefghij", 9, 2, "", 0, 1, 1);
+    test("abcdefghij", 9, 2, "", 1, 0, 0);
+    test("abcdefghij", 9, 2, "abcde", 0, 0, 1);
+    test("abcdefghij", 9, 2, "abcde", 0, 1, 9);
+    test("abcdefghij", 9, 2, "abcde", 0, 2, 9);
+    test("abcdefghij", 9, 2, "abcde", 0, 4, 9);
+    test("abcdefghij", 9, 2, "abcde", 0, 5, 9);
+    test("abcdefghij", 9, 2, "abcde", 0, 6, 9);
+    test("abcdefghij", 9, 2, "abcde", 1, 0, 1);
+    test("abcdefghij", 9, 2, "abcde", 1, 1, 8);
+    test("abcdefghij", 9, 2, "abcde", 1, 2, 8);
+    test("abcdefghij", 9, 2, "abcde", 1, 3, 8);
+    test("abcdefghij", 9, 2, "abcde", 1, 4, 8);
+    test("abcdefghij", 9, 2, "abcde", 1, 5, 8);
+    test("abcdefghij", 9, 2, "abcde", 2, 0, 1);
+    test("abcdefghij", 9, 2, "abcde", 2, 1, 7);
+    test("abcdefghij", 9, 2, "abcde", 2, 2, 7);
+    test("abcdefghij", 9, 2, "abcde", 2, 3, 7);
+    test("abcdefghij", 9, 2, "abcde", 2, 4, 7);
+    test("abcdefghij", 9, 2, "abcde", 4, 0, 1);
+    test("abcdefghij", 9, 2, "abcde", 4, 1, 5);
+    test("abcdefghij", 9, 2, "abcde", 4, 2, 5);
+    test("abcdefghij", 9, 2, "abcde", 5, 0, 1);
+    test("abcdefghij", 9, 2, "abcde", 5, 1, 1);
+    test("abcdefghij", 9, 2, "abcde", 6, 0, 0);
+    test("abcdefghij", 9, 2, "abcdefghij", 0, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghij", 0, 1, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 0, 5, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 0, 9, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 0, 10, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 0, 11, 9);
+    test("abcdefghij", 9, 2, "abcdefghij", 1, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghij", 1, 1, 8);
+    test("abcdefghij", 9, 2, "abcdefghij", 1, 4, 8);
+    test("abcdefghij", 9, 2, "abcdefghij", 1, 8, 8);
+    test("abcdefghij", 9, 2, "abcdefghij", 1, 9, 8);
+    test("abcdefghij", 9, 2, "abcdefghij", 1, 10, 8);
+    test("abcdefghij", 9, 2, "abcdefghij", 5, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghij", 5, 1, 4);
+    test("abcdefghij", 9, 2, "abcdefghij", 5, 2, 4);
+    test("abcdefghij", 9, 2, "abcdefghij", 5, 4, 4);
+    test("abcdefghij", 9, 2, "abcdefghij", 5, 5, 4);
+    test("abcdefghij", 9, 2, "abcdefghij", 5, 6, 4);
+    test("abcdefghij", 9, 2, "abcdefghij", 9, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghij", 9, 1, 0);
+    test("abcdefghij", 9, 2, "abcdefghij", 9, 2, 0);
+    test("abcdefghij", 9, 2, "abcdefghij", 10, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghij", 10, 1, 1);
+    test("abcdefghij", 9, 2, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 1, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 10, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 19, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 20, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 0, 21, 9);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 1, 8);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 9, 8);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 18, 8);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 19, 8);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 1, 20, 8);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 5, -1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 9, -1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 10, -1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 10, 11, -1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 1, -10);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 19, 2, -10);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghij", 9, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 10, 0, "", 0, 0, 0);
+    test("abcdefghij", 10, 0, "", 0, 1, 0);
+    test("abcdefghij", 10, 0, "", 1, 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 0, 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 0, 1, -1);
+    test("abcdefghij", 10, 0, "abcde", 0, 2, -2);
+    test("abcdefghij", 10, 0, "abcde", 0, 4, -4);
+    test("abcdefghij", 10, 0, "abcde", 0, 5, -5);
+    test("abcdefghij", 10, 0, "abcde", 0, 6, -5);
+    test("abcdefghij", 10, 0, "abcde", 1, 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 1, 1, -1);
+    test("abcdefghij", 10, 0, "abcde", 1, 2, -2);
+    test("abcdefghij", 10, 0, "abcde", 1, 3, -3);
+    test("abcdefghij", 10, 0, "abcde", 1, 4, -4);
+    test("abcdefghij", 10, 0, "abcde", 1, 5, -4);
+    test("abcdefghij", 10, 0, "abcde", 2, 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 2, 1, -1);
+    test("abcdefghij", 10, 0, "abcde", 2, 2, -2);
+    test("abcdefghij", 10, 0, "abcde", 2, 3, -3);
+    test("abcdefghij", 10, 0, "abcde", 2, 4, -3);
+    test("abcdefghij", 10, 0, "abcde", 4, 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 4, 1, -1);
+}
+
+void test35()
+{
+    test("abcdefghij", 10, 0, "abcde", 4, 2, -1);
+    test("abcdefghij", 10, 0, "abcde", 5, 0, 0);
+    test("abcdefghij", 10, 0, "abcde", 5, 1, 0);
+    test("abcdefghij", 10, 0, "abcde", 6, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghij", 10, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghij", 10, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghij", 10, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghij", 10, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghij", 10, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghij", 10, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghij", 10, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghij", 10, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghij", 10, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 10, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 10, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 10, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghij", 10, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghij", 10, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghij", 10, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 10, 1, "", 0, 0, 0);
+    test("abcdefghij", 10, 1, "", 0, 1, 0);
+    test("abcdefghij", 10, 1, "", 1, 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 0, 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 0, 1, -1);
+    test("abcdefghij", 10, 1, "abcde", 0, 2, -2);
+    test("abcdefghij", 10, 1, "abcde", 0, 4, -4);
+    test("abcdefghij", 10, 1, "abcde", 0, 5, -5);
+    test("abcdefghij", 10, 1, "abcde", 0, 6, -5);
+    test("abcdefghij", 10, 1, "abcde", 1, 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 1, 1, -1);
+    test("abcdefghij", 10, 1, "abcde", 1, 2, -2);
+    test("abcdefghij", 10, 1, "abcde", 1, 3, -3);
+    test("abcdefghij", 10, 1, "abcde", 1, 4, -4);
+    test("abcdefghij", 10, 1, "abcde", 1, 5, -4);
+    test("abcdefghij", 10, 1, "abcde", 2, 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 2, 1, -1);
+    test("abcdefghij", 10, 1, "abcde", 2, 2, -2);
+    test("abcdefghij", 10, 1, "abcde", 2, 3, -3);
+    test("abcdefghij", 10, 1, "abcde", 2, 4, -3);
+    test("abcdefghij", 10, 1, "abcde", 4, 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 4, 1, -1);
+    test("abcdefghij", 10, 1, "abcde", 4, 2, -1);
+    test("abcdefghij", 10, 1, "abcde", 5, 0, 0);
+    test("abcdefghij", 10, 1, "abcde", 5, 1, 0);
+    test("abcdefghij", 10, 1, "abcde", 6, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghij", 0, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghij", 0, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghij", 0, 5, -5);
+    test("abcdefghij", 10, 1, "abcdefghij", 0, 9, -9);
+    test("abcdefghij", 10, 1, "abcdefghij", 0, 10, -10);
+    test("abcdefghij", 10, 1, "abcdefghij", 0, 11, -10);
+    test("abcdefghij", 10, 1, "abcdefghij", 1, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghij", 1, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghij", 1, 4, -4);
+    test("abcdefghij", 10, 1, "abcdefghij", 1, 8, -8);
+    test("abcdefghij", 10, 1, "abcdefghij", 1, 9, -9);
+    test("abcdefghij", 10, 1, "abcdefghij", 1, 10, -9);
+    test("abcdefghij", 10, 1, "abcdefghij", 5, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghij", 5, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghij", 5, 2, -2);
+    test("abcdefghij", 10, 1, "abcdefghij", 5, 4, -4);
+    test("abcdefghij", 10, 1, "abcdefghij", 5, 5, -5);
+    test("abcdefghij", 10, 1, "abcdefghij", 5, 6, -5);
+    test("abcdefghij", 10, 1, "abcdefghij", 9, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghij", 9, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghij", 9, 2, -1);
+    test("abcdefghij", 10, 1, "abcdefghij", 10, 0, 0);
+}
+
+void test36()
+{
+    test("abcdefghij", 10, 1, "abcdefghij", 10, 1, 0);
+    test("abcdefghij", 10, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghij", 10, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghij", 11, 0, "", 0, 0, 0);
+    test("abcdefghij", 11, 0, "", 0, 1, 0);
+    test("abcdefghij", 11, 0, "", 1, 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 0, 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 0, 1, 0);
+    test("abcdefghij", 11, 0, "abcde", 0, 2, 0);
+    test("abcdefghij", 11, 0, "abcde", 0, 4, 0);
+    test("abcdefghij", 11, 0, "abcde", 0, 5, 0);
+    test("abcdefghij", 11, 0, "abcde", 0, 6, 0);
+    test("abcdefghij", 11, 0, "abcde", 1, 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 1, 1, 0);
+    test("abcdefghij", 11, 0, "abcde", 1, 2, 0);
+    test("abcdefghij", 11, 0, "abcde", 1, 3, 0);
+    test("abcdefghij", 11, 0, "abcde", 1, 4, 0);
+    test("abcdefghij", 11, 0, "abcde", 1, 5, 0);
+    test("abcdefghij", 11, 0, "abcde", 2, 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 2, 1, 0);
+    test("abcdefghij", 11, 0, "abcde", 2, 2, 0);
+    test("abcdefghij", 11, 0, "abcde", 2, 3, 0);
+    test("abcdefghij", 11, 0, "abcde", 2, 4, 0);
+    test("abcdefghij", 11, 0, "abcde", 4, 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 4, 1, 0);
+    test("abcdefghij", 11, 0, "abcde", 4, 2, 0);
+    test("abcdefghij", 11, 0, "abcde", 5, 0, 0);
+    test("abcdefghij", 11, 0, "abcde", 5, 1, 0);
+    test("abcdefghij", 11, 0, "abcde", 6, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0, 5, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0, 9, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0, 10, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 0, 11, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 1, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 1, 4, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 1, 8, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 1, 9, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 1, 10, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 5, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 5, 2, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 5, 4, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 5, 5, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 5, 6, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 9, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 9, 2, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghij", 11, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+}
+
+void test37()
+{
+    test("abcdefghijklmnopqrst", 0, 0, "", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 4, -4);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 0, 6, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 3, -3);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 1, 5, -4);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 3, -3);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 2, 4, -3);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 4, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghijklmnopqrst", 0, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 4, -3);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 5, -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 0, 6, -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 3, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 1, 5, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 1, -2);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 3, -2);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 2, 4, -2);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, 1, -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 4, 2, -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 5, 1, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcde", 6, 0, 0);
+}
+
+void test38()
+{
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 5, -4);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 9, -8);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 10, -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 0, 11, -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 8, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 1, 10, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 1, -5);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 2, -5);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 4, -5);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, 1, -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 9, 2, -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 10, -9);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 19, -18);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 20, -19);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 0, 21, -19);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghijklmnopqrst", 0, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 1, 9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 2, 8);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 4, 6);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 5, 5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 0, 6, 5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 3, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 1, 5, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 1, -2);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 3, -2);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 2, 4, -2);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 1, -4);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 4, 2, -4);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 5, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 5, 1, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 1, 9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 5, 5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 9, 1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 10, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 0, 11, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 8, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 1, 10, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 1, -5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 2, -5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 4, -5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 1, -9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 9, 2, -9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 10, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 10, 1, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 1, 9);
+}
+
+void test39()
+{
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 10, 0);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 19, -9);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 20, -10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 0, 21, -10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 20, 0, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 20, 1, 10);
+    test("abcdefghijklmnopqrst", 0, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 19, "", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 1, 18);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 2, 17);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 4, 15);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 5, 14);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 0, 6, 14);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 3, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 1, 5, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 1, -2);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 3, -2);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 2, 4, -2);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 1, -4);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 4, 2, -4);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 5, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 5, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 1, 18);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 5, 14);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 9, 10);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 10, 9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 0, 11, 9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 8, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 1, 10, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 1, -5);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 2, -5);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 4, -5);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 1, -9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 9, 2, -9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 10, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 10, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 1, 18);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 10, 9);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 19, 0);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 20, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 0, 21, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 20, 0, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 20, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 19, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 20, "", 0, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "", 0, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 0, 20);
+}
+
+void test40()
+{
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 2, 18);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 4, 16);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 5, 15);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 0, 6, 15);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 3, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 1, 5, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 1, -2);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 3, -2);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 2, 4, -2);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 1, -4);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 4, 2, -4);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 5, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 5, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 5, 15);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 9, 11);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 0, 11, 10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 8, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 1, 10, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 1, -5);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 2, -5);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 4, -5);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 1, -9);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 9, 2, -9);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 10, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 20, 0);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 0, 21, 0);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 20, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 20, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 20, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 21, "", 0, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "", 0, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 2, 18);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 4, 16);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 5, 15);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 0, 6, 15);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 2, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 3, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 1, 5, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 1, -2);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 3, -2);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 2, 4, -2);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 1, -4);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 4, 2, -4);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 5, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 5, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 5, 15);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 9, 11);
+}
+
+void test41()
+{
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 0, 11, 10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 4, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 8, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 1, 10, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 1, -5);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 2, -5);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 4, -5);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 1, -9);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 9, 2, -9);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 10, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 20, 0);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 0, 21, 0);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 9, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 18, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 1, -10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 5, -10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 9, -10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 1, -19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 19, 2, -19);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 20, 0, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 20, 1, 20);
+    test("abcdefghijklmnopqrst", 0, 21, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 2, -2);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 0, 6, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 2, -2);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 3, -3);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 1, 5, -4);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 3, -3);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 2, 4, -3);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 4, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+}
+
+void test42()
+{
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghijklmnopqrst", 1, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 1, "", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 2, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 4, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 0, 6, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 1, 0);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 3, -2);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 4, -3);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 1, 5, -3);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 3, -1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 2, 4, -1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 1, -3);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 4, 2, -3);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 5, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 9, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 0, 11, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 1, 0);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 4, -3);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 8, -7);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 9, -8);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 1, 10, -8);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 1, -4);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 2, -4);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 5, -4);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 5, 6, -4);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 1, -8);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 9, 2, -8);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 1, 0);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 9, -8);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 18, -17);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 19, -18);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 1, 20, -18);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 9, "", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "", 0, 1, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 2, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 4, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 5, 1);
+}
+
+void test43()
+{
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 0, 6, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 1, 8);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 2, 7);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 3, 6);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 4, 5);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 1, 5, 5);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 3, -1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 2, 4, -1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 1, -3);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 4, 2, -3);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 5, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 5, 1, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 9, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 0, 11, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 1, 8);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 4, 5);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 8, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 9, 0);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 1, 10, 0);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 1, -4);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 2, -4);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 5, -4);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 5, 6, -4);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 1, -8);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 9, 2, -8);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 10, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 10, 1, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 1, 8);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 9, 0);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 18, -9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 19, -10);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 1, 20, -10);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+    test("abcdefghijklmnopqrst", 1, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 18, "", 0, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "", 0, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 2, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 4, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 0, 6, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 1, 17);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 2, 16);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 3, 15);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 4, 14);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 1, 5, 14);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 3, -1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 2, 4, -1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 1, -3);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 4, 2, -3);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 5, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 5, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 9, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 0, 11, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 1, 17);
+}
+
+void test44()
+{
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 4, 14);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 8, 10);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 1, 10, 9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 1, -4);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 2, -4);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 5, -4);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 5, 6, -4);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 1, -8);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 9, 2, -8);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 10, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 10, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 1, 17);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 18, 0);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 19, -1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 1, 20, -1);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 20, 0, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 20, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 18, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 19, "", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 2, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 4, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 0, 6, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 2, 17);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 3, 16);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 4, 15);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 1, 5, 15);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 3, -1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 2, 4, -1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 1, -3);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 4, 2, -3);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 5, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 5, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 9, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 0, 11, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 4, 15);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 8, 11);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 9, 10);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 1, 10, 10);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 1, -4);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 2, -4);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 5, -4);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 5, 6, -4);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 1, -8);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 9, 2, -8);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 10, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 10, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 9, 10);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 18, 1);
+}
+
+void test45()
+{
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 19, 0);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 1, 20, 0);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 20, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 20, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 19, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 20, "", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 2, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 4, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 0, 6, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 2, 17);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 3, 16);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 4, 15);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 1, 5, 15);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 2, -1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 3, -1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 2, 4, -1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 1, -3);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 4, 2, -3);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 5, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 5, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 5, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 9, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 0, 11, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 4, 15);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 8, 11);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 9, 10);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 1, 10, 10);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 1, -4);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 2, -4);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 5, -4);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 5, 6, -4);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 1, -8);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 9, 2, -8);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 10, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 10, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 10, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 19, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 20, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 0, 21, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 9, 10);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 18, 1);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 19, 0);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 1, 20, 0);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 1, -9);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 5, -9);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 1, -18);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 19, 2, -18);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 20, 0, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 20, 1, 19);
+    test("abcdefghijklmnopqrst", 1, 20, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 2, -2);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 4, -4);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 0, 6, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 2, -2);
+}
+
+void test46()
+{
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 3, -3);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 1, 5, -4);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 3, -3);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 2, 4, -3);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 4, 2, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghijklmnopqrst", 10, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 1, "", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 2, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 4, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 0, 6, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 2, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 3, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 1, 5, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 1, 8);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 2, 8);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 3, 8);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 2, 4, 8);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 1, 6);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 4, 2, 6);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 5, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 9, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 0, 11, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 8, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 1, 10, 9);
+}
+
+void test47()
+{
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 2, 5);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 4, 5);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 5, 5);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 5, 6, 5);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 9, 2, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 19, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 20, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 0, 21, 10);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 18, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 19, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 1, 20, 9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 5, -4);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 9, -8);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 10, -9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 10, 11, -9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 1, -9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 19, 2, -9);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 5, "", 0, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "", 0, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 2, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 4, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 0, 6, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 2, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 3, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 1, 5, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 1, 8);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 2, 8);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 3, 8);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 2, 4, 8);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 1, 6);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 4, 2, 6);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 5, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 5, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 9, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 0, 11, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 8, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 1, 10, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 2, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 4, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 5, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 5, 6, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 9, 2, 1);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 10, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 19, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 20, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 0, 21, 10);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 18, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 19, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 1, 20, 9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 1, 4);
+}
+
+void test48()
+{
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 5, 0);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 9, -4);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 10, -5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 10, 11, -5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 1, -9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 19, 2, -9);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 20, 0, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 20, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 5, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 9, "", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "", 0, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 2, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 4, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 0, 6, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 2, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 3, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 1, 5, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 1, 8);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 2, 8);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 3, 8);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 2, 4, 8);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 1, 6);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 4, 2, 6);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 5, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 5, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 9, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 0, 11, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 8, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 1, 10, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 2, 5);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 4, 5);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 5, 5);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 5, 6, 5);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 9, 2, 1);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 10, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 19, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 20, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 0, 21, 10);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 18, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 19, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 1, 20, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 1, 8);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 5, 4);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 9, 0);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 10, -1);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 10, 11, -1);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 1, -9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 19, 2, -9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 20, 0, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 20, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 9, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 10, "", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 2, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 4, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 0, 6, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 2, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 3, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 1, 5, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 0, 10);
+}
+
+void test49()
+{
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 1, 8);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 2, 8);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 3, 8);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 2, 4, 8);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 1, 6);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 4, 2, 6);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 5, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 5, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 9, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 0, 11, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 8, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 1, 10, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 2, 5);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 4, 5);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 5, 5);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 5, 6, 5);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 9, 2, 1);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 10, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 19, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 20, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 0, 21, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 18, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 19, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 1, 20, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 5, 5);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 9, 1);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 10, 0);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 10, 11, 0);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 1, -9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 19, 2, -9);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 20, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 20, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 10, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 11, "", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 2, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 4, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 0, 6, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 2, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 3, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 1, 5, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 1, 8);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 2, 8);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 3, 8);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 2, 4, 8);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 1, 6);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 4, 2, 6);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 5, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 5, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 5, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 9, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 0, 11, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 4, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 8, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 1, 10, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 1, 5);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 2, 5);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 4, 5);
+}
+
+void test50()
+{
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 5, 5);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 5, 6, 5);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 1, 1);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 9, 2, 1);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 10, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 10, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 19, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 20, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 0, 21, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 9, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 18, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 19, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 1, 20, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 1, 9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 5, 5);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 9, 1);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 10, 0);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 10, 11, 0);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 1, -9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 19, 2, -9);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 20, 0, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 20, 1, 10);
+    test("abcdefghijklmnopqrst", 10, 11, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 2, -2);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 4, -4);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 0, 6, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 2, -2);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 3, -3);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 1, 5, -4);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 3, -3);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 2, 4, -3);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 4, 2, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+}
+
+void test51()
+{
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghijklmnopqrst", 19, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 1, "", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 2, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 4, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 5, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 0, 6, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 2, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 3, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 4, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 1, 5, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 1, 17);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 2, 17);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 3, 17);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 2, 4, 17);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 1, 15);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 4, 2, 15);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 5, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 5, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 9, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 10, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 0, 11, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 4, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 8, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 9, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 1, 10, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 1, 14);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 2, 14);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 4, 14);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 5, 14);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 5, 6, 14);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 1, 10);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 9, 2, 10);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 10, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 10, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 19, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 20, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 0, 21, 19);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 9, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 18, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 19, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 1, 20, 18);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 1, 9);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 5, 9);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 9, 9);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 10, 9);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 10, 11, 9);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 1, 0);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 19, 2, 0);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 2, "", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "", 0, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 2, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 4, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 5, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 0, 6, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 2, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 3, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 4, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 1, 5, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 1, 17);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 2, 17);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 3, 17);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 2, 4, 17);
+}
+
+void test52()
+{
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 1, 15);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 4, 2, 15);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 5, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 5, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 9, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 10, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 0, 11, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 4, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 8, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 9, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 1, 10, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 1, 14);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 2, 14);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 4, 14);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 5, 14);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 5, 6, 14);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 1, 10);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 9, 2, 10);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 10, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 1, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 10, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 19, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 20, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 0, 21, 19);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 1, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 9, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 18, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 19, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 1, 20, 18);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 1, 9);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 5, 9);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 9, 9);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 10, 9);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 10, 11, 9);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 1, 0);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 19, 2, 0);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 20, 0, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 20, 1, 1);
+    test("abcdefghijklmnopqrst", 19, 2, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 0, 6, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 3, -3);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 1, 5, -4);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 3, -3);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 2, 4, -3);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 4, 2, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 0, 11, -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 8, -8);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 1, 10, -9);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, 1, -1);
+}
+
+void test53()
+{
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 9, 2, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 0, 6, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 3, -3);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 1, 5, -4);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 3, -3);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 2, 4, -3);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 4, 2, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 0, 11, -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 8, -8);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 1, 10, -9);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 2, -2);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 4, -4);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 5, 6, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 9, 2, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 10, -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 19, -19);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 20, -20);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 0, 21, -20);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 18, -18);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 19, -19);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 1, 20, -19);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 5, -5);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 9, -9);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 10, -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 10, 11, -10);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, 1, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 19, 2, -1);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 20, 0, 0);
+}
+
+void test54()
+{
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghijklmnopqrst", 20, 1, "abcdefghijklmnopqrst", 21, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 4, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 5, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 0, 6, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 3, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 4, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 1, 5, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 3, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 2, 4, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 4, 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcde", 6, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 5, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 9, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 10, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 0, 11, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 4, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 8, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 9, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 1, 10, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 4, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 5, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 5, 6, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 9, 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghij", 11, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 10, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 19, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 20, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 0, 21, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 9, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 18, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 19, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 1, 20, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 5, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 9, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 10, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 10, 11, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 19, 2, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 20, 0, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 20, 1, 0);
+    test("abcdefghijklmnopqrst", 21, 0, "abcdefghijklmnopqrst", 21, 0, 0);
+}
+
+
+int main () {
+    test0();
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+    test12();
+    test13();
+    test14();
+    test15();
+    test16();
+    test17();
+    test18();
+    test19();
+    test20();
+    test21();
+    test22();
+    test23();
+    test24();
+    test25();
+    test26();
+    test27();
+    test28();
+    test29();
+    test30();
+    test31();
+    test32();
+    test33();
+    test34();
+    test35();
+    test36();
+    test37();
+    test38();
+    test39();
+    test40();
+    test41();
+    test42();
+    test43();
+    test44();
+    test45();
+    test46();
+    test47();
+    test48();
+    test49();
+    test50();
+    test51();
+    test52();
+    test53();
+    test54();
+
+    
+    {
+    test("abcde", 5, 1, "", 0, 0, 0);
+    test("abcde", 2, 4, "", 0, 0, 3);
+    test("abcde", 2, 4, "abcde", 3, 4, -2);
+    test("ABCde", 2, 4, "abcde", 2, 4, -1);
+    }
+
+    {
+    test(L"abcde", 5, 1, L"", 0, 0, 0);
+    test(L"abcde", 2, 4, L"", 0, 0, 3);
+    test(L"abcde", 2, 4, L"abcde", 3, 4, -2);
+    test(L"ABCde", 2, 4, L"abcde", 2, 4, -1);
+    }
+
+#if __cplusplus >= 201103L
+    {
+    test(u"abcde", 5, 1, u"", 0, 0, 0);
+    test(u"abcde", 2, 4, u"", 0, 0, 3);
+    test(u"abcde", 2, 4, u"abcde", 3, 4, -2);
+    test(u"ABCde", 2, 4, u"abcde", 2, 4, -1);
+    }
+
+    {
+    test(U"abcde", 5, 1, U"", 0, 0, 0);
+    test(U"abcde", 2, 4, U"", 0, 0, 3);
+    test(U"abcde", 2, 4, U"abcde", 3, 4, -2);
+    test(U"ABCde", 2, 4, U"abcde", 2, 4, -1);
+    }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1 { "abcde", 5 };
+    static_assert ( sv1.compare(5, 1, "", 0, 0) == 0, "" );
+    static_assert ( sv1.compare(2, 4, "", 0, 0) == 1, "" );
+    static_assert ( sv1.compare(2, 4, "abcde", 3, 4) == -1, "" );
+    }
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.ops/compare.sv.pass.cpp b/final/test/experimental/string.view/string.view.ops/compare.sv.pass.cpp
new file mode 100644
index 0000000..3f68669
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/compare.sv.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+// constexpr int compare(basic_string_view str) const noexcept;
+
+#include <experimental/string_view>
+#include <cassert>
+
+#include "constexpr_char_traits.hpp"
+
+int sign ( int x ) { return x > 0 ? 1 : ( x < 0 ? -1 : 0 ); }
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv1, 
+            std::experimental::basic_string_view<CharT> sv2, int expected ) {
+    assert ( sign( sv1.compare(sv2)) == sign(expected));
+}
+
+
+template<typename CharT>
+void test ( const CharT *s1, const CharT  *s2, int expected ) {
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    
+    string_view_t sv1 ( s1 );
+    string_view_t sv2 ( s2 );
+    test1(sv1, sv2, expected);
+}
+
+int main () {
+
+    test("",                     "", 0);
+    test("",                     "abcde", -5);
+    test("",                     "abcdefghij", -10);
+    test("",                     "abcdefghijklmnopqrst", -20);
+    test("abcde",                "", 5);
+    test("abcde",                "abcde", 0);
+    test("abcde",                "abcdefghij", -5);
+    test("abcde",                "abcdefghijklmnopqrst", -15);
+    test("abcdefghij",           "", 10);
+    test("abcdefghij",           "abcde", 5);
+    test("abcdefghij",           "abcdefghij", 0);
+    test("abcdefghij",           "abcdefghijklmnopqrst", -10);
+    test("abcdefghijklmnopqrst", "", 20);
+    test("abcdefghijklmnopqrst", "abcde", 15);
+    test("abcdefghijklmnopqrst", "abcdefghij", 10);
+    test("abcdefghijklmnopqrst", "abcdefghijklmnopqrst", 0);
+
+    test(L"",                     L"", 0);
+    test(L"",                     L"abcde", -5);
+    test(L"",                     L"abcdefghij", -10);
+    test(L"",                     L"abcdefghijklmnopqrst", -20);
+    test(L"abcde",                L"", 5);
+    test(L"abcde",                L"abcde", 0);
+    test(L"abcde",                L"abcdefghij", -5);
+    test(L"abcde",                L"abcdefghijklmnopqrst", -15);
+    test(L"abcdefghij",           L"", 10);
+    test(L"abcdefghij",           L"abcde", 5);
+    test(L"abcdefghij",           L"abcdefghij", 0);
+    test(L"abcdefghij",           L"abcdefghijklmnopqrst", -10);
+    test(L"abcdefghijklmnopqrst", L"", 20);
+    test(L"abcdefghijklmnopqrst", L"abcde", 15);
+    test(L"abcdefghijklmnopqrst", L"abcdefghij", 10);
+    test(L"abcdefghijklmnopqrst", L"abcdefghijklmnopqrst", 0);
+
+#if __cplusplus >= 201103L
+    test(u"",                     u"", 0);
+    test(u"",                     u"abcde", -5);
+    test(u"",                     u"abcdefghij", -10);
+    test(u"",                     u"abcdefghijklmnopqrst", -20);
+    test(u"abcde",                u"", 5);
+    test(u"abcde",                u"abcde", 0);
+    test(u"abcde",                u"abcdefghij", -5);
+    test(u"abcde",                u"abcdefghijklmnopqrst", -15);
+    test(u"abcdefghij",           u"", 10);
+    test(u"abcdefghij",           u"abcde", 5);
+    test(u"abcdefghij",           u"abcdefghij", 0);
+    test(u"abcdefghij",           u"abcdefghijklmnopqrst", -10);
+    test(u"abcdefghijklmnopqrst", u"", 20);
+    test(u"abcdefghijklmnopqrst", u"abcde", 15);
+    test(u"abcdefghijklmnopqrst", u"abcdefghij", 10);
+    test(u"abcdefghijklmnopqrst", u"abcdefghijklmnopqrst", 0);
+
+    test(U"",                     U"", 0);
+    test(U"",                     U"abcde", -5);
+    test(U"",                     U"abcdefghij", -10);
+    test(U"",                     U"abcdefghijklmnopqrst", -20);
+    test(U"abcde",                U"", 5);
+    test(U"abcde",                U"abcde", 0);
+    test(U"abcde",                U"abcdefghij", -5);
+    test(U"abcde",                U"abcdefghijklmnopqrst", -15);
+    test(U"abcdefghij",           U"", 10);
+    test(U"abcdefghij",           U"abcde", 5);
+    test(U"abcdefghij",           U"abcdefghij", 0);
+    test(U"abcdefghij",           U"abcdefghijklmnopqrst", -10);
+    test(U"abcdefghijklmnopqrst", U"", 20);
+    test(U"abcdefghijklmnopqrst", U"abcde", 15);
+    test(U"abcdefghijklmnopqrst", U"abcdefghij", 10);
+    test(U"abcdefghijklmnopqrst", U"abcdefghijklmnopqrst", 0);
+#endif
+    
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::experimental::basic_string_view<char, constexpr_char_traits<char>> SV;
+    constexpr SV  sv1 { "abcde", 5 };
+    constexpr SV  sv2 { "abcde", 5 };
+    constexpr SV  sv3 { "edcba0", 6 };
+    static_assert ( sv1.compare(sv2) == 0, "" );
+    static_assert ( sv2.compare(sv1) == 0, "" );
+    static_assert ( sv3.compare(sv2)  > 0, "" );
+    static_assert ( sv2.compare(sv3)  < 0, "" );
+    }
+#endif    
+}
diff --git a/final/test/experimental/string.view/string.view.ops/copy.pass.cpp b/final/test/experimental/string.view/string.view.ops/copy.pass.cpp
new file mode 100644
index 0000000..96246d2
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/copy.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+// Throws: out_of_range if pos > size().
+// Remarks: Let rlen be the smaller of n and size() - pos.
+// Requires: [s, s+rlen) is a valid range.
+// Effects: Equivalent to std::copy_n(begin() + pos, rlen, s).
+// Returns: rlen.
+
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv, size_t n, size_t pos ) {
+    const size_t rlen = std::min ( n, sv.size() - pos );
+
+    CharT *dest1 = new CharT [rlen + 1];    dest1[rlen] = 0;
+    CharT *dest2 = new CharT [rlen + 1];    dest2[rlen] = 0;
+    
+    try {
+        sv.copy(dest1, n, pos);
+        std::copy_n(sv.begin() + pos, rlen, dest2);
+
+        for ( size_t i = 0; i <= rlen; ++i )
+            assert ( dest1[i] == dest2[i] );
+        }
+    catch ( const std::out_of_range & ) { assert ( pos > sv.size()); }
+    delete [] dest1;
+    delete [] dest2;    
+}
+
+
+template<typename CharT>
+void test ( const CharT *s ) {
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    
+    string_view_t sv1 ( s );
+
+    test1(sv1,  0, 0);
+    test1(sv1,  1, 0);
+    test1(sv1, 20, 0);
+    test1(sv1, sv1.size(), 0);
+    test1(sv1, 20, string_view_t::npos);
+    
+    test1(sv1,   0, 3);
+    test1(sv1,   2, 3);
+    test1(sv1, 100, 3);
+    test1(sv1, 100, string_view_t::npos);
+
+    test1(sv1, sv1.size(), string_view_t::npos);
+
+    test1(sv1, sv1.size() + 1, 0);
+    test1(sv1, sv1.size() + 1, 1);
+    test1(sv1, sv1.size() + 1, string_view_t::npos);
+
+}
+
+int main () {
+    test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( "ABCDE");
+    test ( "a" );
+    test ( "" );
+
+    test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( L"ABCDE" );
+    test ( L"a" );
+    test ( L"" );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( u"ABCDE" );
+    test ( u"a" );
+    test ( u"" );
+
+    test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( U"ABCDE" );
+    test ( U"a" );
+    test ( U"" );
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.ops/substr.pass.cpp b/final/test/experimental/string.view/string.view.ops/substr.pass.cpp
new file mode 100644
index 0000000..2b134ea
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/substr.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+// constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
+
+// Throws: out_of_range if pos > size().
+// Effects: Determines the effective length rlen of the string to reference as the smaller of n and size() - pos.
+// Returns: basic_string_view(data()+pos, rlen).
+
+#include <experimental/string_view>
+#include <cassert>
+
+template<typename CharT>
+void test1 ( std::experimental::basic_string_view<CharT> sv, size_t n, size_t pos ) {
+    try {
+        std::experimental::basic_string_view<CharT> sv1 = sv.substr(pos, n);
+        const size_t rlen = std::min ( n, sv.size() - pos );
+        assert ( sv1.size() == rlen );
+        for ( size_t i = 0; i <= rlen; ++i )
+            assert ( sv[pos+i] == sv1[i] );
+        }
+    catch ( const std::out_of_range & ) { assert ( pos > sv.size()); }
+}
+
+
+template<typename CharT>
+void test ( const CharT *s ) {
+    typedef std::experimental::basic_string_view<CharT> string_view_t;
+    
+    string_view_t sv1 ( s );
+
+    test1(sv1,  0, 0);
+    test1(sv1,  1, 0);
+    test1(sv1, 20, 0);
+    test1(sv1, sv1.size(), 0);
+    
+    test1(sv1,   0, 3);
+    test1(sv1,   2, 3);
+    test1(sv1, 100, 3);
+
+    test1(sv1, 0, string_view_t::npos);
+    test1(sv1, 2, string_view_t::npos);
+    test1(sv1, sv1.size(), string_view_t::npos);
+
+    test1(sv1, sv1.size() + 1, 0);
+    test1(sv1, sv1.size() + 1, 1);
+    test1(sv1, sv1.size() + 1, string_view_t::npos);
+}
+
+int main () {
+    test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( "ABCDE");
+    test ( "a" );
+    test ( "" );
+
+    test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( L"ABCDE" );
+    test ( L"a" );
+    test ( L"" );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( u"ABCDE" );
+    test ( u"a" );
+    test ( u"" );
+
+    test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( U"ABCDE" );
+    test ( U"a" );
+    test ( U"" );
+#endif
+    
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::experimental::string_view sv1 { "ABCDE", 5 };
+
+    {
+    constexpr std::experimental::string_view sv2 = sv1.substr ( 0, 3 );
+    static_assert ( sv2.size() == 3, "" );
+    static_assert ( sv2[0] == 'A', "" );
+    static_assert ( sv2[1] == 'B', "" );
+    static_assert ( sv2[2] == 'C', "" );
+    }
+    
+    {
+    constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 0 );
+    static_assert ( sv2.size() == 0, "" );
+    }
+
+    {
+    constexpr std::experimental::string_view sv2 = sv1.substr ( 3, 3 );
+    static_assert ( sv2.size() == 2, "" );
+    static_assert ( sv2[0] == 'D', "" );
+    static_assert ( sv2[1] == 'E', "" );
+    }
+    }
+#endif
+}
\ No newline at end of file
diff --git a/final/test/experimental/string.view/string.view.ops/to_string.pass.cpp b/final/test/experimental/string.view/string.view.ops/to_string.pass.cpp
new file mode 100644
index 0000000..e69cb95
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.ops/to_string.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <string_view>
+
+//  template<class Allocator>
+//  explicit operator basic_string<_CharT, _Traits, Allocator> () const;
+//  template<class _CharT, class _Traits = char_traits<_CharT>, class Allocator = allocator<_CharT> >
+//  basic_string<_CharT, _Traits, Allocator> to_string (
+//          basic_string_view<_CharT, _Traits> _sv, const Allocator& _a = Allocator()) const;
+
+#include <experimental/string_view>
+#include <cassert>
+#include "min_allocator.h"
+
+template<typename CharT>
+void test ( const CharT *s ) {
+    typedef std::basic_string<CharT> String ;
+    {
+    std::experimental::basic_string_view<CharT> sv1 ( s );
+    String                                      str1 = (String) sv1;
+    
+    assert ( sv1.size() == str1.size ());
+    assert ( std::char_traits<CharT>::compare ( sv1.data(), str1.data(),  sv1.size()) == 0 );
+
+#if __cplusplus >= 201103L
+    auto str2 = sv1.to_string(min_allocator<CharT>());
+    assert ( sv1.size() == str2.size ());
+    assert ( std::char_traits<CharT>::compare ( sv1.data(), str2.data(), sv1.size()) == 0 );
+#endif
+    }
+
+    {
+    std::experimental::basic_string_view<CharT> sv1;
+    String                                      str1 = (String) sv1;
+
+    assert ( sv1.size() == str1.size ());
+    assert ( std::char_traits<CharT>::compare ( sv1.data(), str1.data(), sv1.size()) == 0 );
+
+#if __cplusplus >= 201103L
+    auto str2 = sv1.to_string(min_allocator<CharT>());
+    assert ( sv1.size() == str2.size ());
+    assert ( std::char_traits<CharT>::compare ( sv1.data(), str2.data(), sv1.size()) == 0 );
+#endif
+    }
+}
+
+int main () {
+    test ( "ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( "ABCDE");
+    test ( "a" );
+    test ( "" );
+
+    test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( L"ABCDE" );
+    test ( L"a" );
+    test ( L"" );
+
+#if __cplusplus >= 201103L
+    test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( u"ABCDE" );
+    test ( u"a" );
+    test ( u"" );
+
+    test ( U"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
+    test ( U"ABCDE" );
+    test ( U"a" );
+    test ( U"" );
+#endif
+}
diff --git a/final/test/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp b/final/test/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..c21f8a7
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.synop/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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/string_view>
+
+int main () {}
diff --git a/final/test/experimental/string.view/string.view.template/nothing_to_do.pass.cpp b/final/test/experimental/string.view/string.view.template/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..c21f8a7
--- /dev/null
+++ b/final/test/experimental/string.view/string.view.template/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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/string_view>
+
+int main () {}
diff --git a/final/test/experimental/utilities/nothing_to_do.pass.cpp b/final/test/experimental/utilities/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/experimental/utilities/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp b/final/test/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp
new file mode 100644
index 0000000..5f89e53
--- /dev/null
+++ b/final/test/experimental/utilities/utility/utility.erased.type/erased_type.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/utility>
+
+#include <experimental/utility>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::erased_type;
+    constexpr erased_type e{};
+#endif
+}
diff --git a/final/test/experimental/utilities/utility/utility.synop/includes.pass.cpp b/final/test/experimental/utilities/utility/utility.synop/includes.pass.cpp
new file mode 100644
index 0000000..bcdd8b3
--- /dev/null
+++ b/final/test/experimental/utilities/utility/utility.synop/includes.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/utility>
+
+#include <experimental/utility>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+# ifndef _LIBCPP_UTILITY
+#   error "<experimental/utility> must include <utility>"
+# endif
+#endif /* _LIBCPP_STD_VER > 11 */
+}
diff --git a/final/test/experimental/utilities/utility/version.pass.cpp b/final/test/experimental/utilities/utility/version.pass.cpp
new file mode 100644
index 0000000..4377124
--- /dev/null
+++ b/final/test/experimental/utilities/utility/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <experimental/utility>
+
+#include <experimental/utility>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/extensions/hash/specializations.fail.cpp b/final/test/extensions/hash/specializations.fail.cpp
new file mode 100644
index 0000000..8eeffb5
--- /dev/null
+++ b/final/test/extensions/hash/specializations.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <assert.h>
+#include <ext/hash_map>
+#include <string>
+
+int main()
+{
+    assert(__gnu_cxx::hash<std::string>()(std::string()) == 0);  // error
+}
diff --git a/final/test/extensions/hash/specializations.pass.cpp b/final/test/extensions/hash/specializations.pass.cpp
new file mode 100644
index 0000000..884614e
--- /dev/null
+++ b/final/test/extensions/hash/specializations.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <assert.h>
+#include <ext/hash_map>
+#include <string>
+
+int main()
+{
+    char str[] = "test";
+    assert(__gnu_cxx::hash<const char *>()("test") ==
+           std::hash<std::string>()("test"));
+    assert(__gnu_cxx::hash<char *>()(str) == std::hash<std::string>()("test"));
+    assert(__gnu_cxx::hash<char>()(42) == 42);
+    assert(__gnu_cxx::hash<signed char>()(42) == 42);
+    assert(__gnu_cxx::hash<unsigned char>()(42) == 42);
+    assert(__gnu_cxx::hash<short>()(42) == 42);
+    assert(__gnu_cxx::hash<unsigned short>()(42) == 42);
+    assert(__gnu_cxx::hash<int>()(42) == 42);
+    assert(__gnu_cxx::hash<unsigned int>()(42) == 42);
+    assert(__gnu_cxx::hash<long>()(42) == 42);
+    assert(__gnu_cxx::hash<unsigned long>()(42) == 42);
+}
diff --git a/final/test/extensions/hash_map/const_iterator.fail.cpp b/final/test/extensions/hash_map/const_iterator.fail.cpp
new file mode 100644
index 0000000..e4c536e
--- /dev/null
+++ b/final/test/extensions/hash_map/const_iterator.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <ext/hash_map>
+
+int main()
+{
+    __gnu_cxx::hash_map<int, int> m;
+    m[1] = 1;
+    const __gnu_cxx::hash_map<int, int> &cm = m;
+    cm.find(1)->second = 2;  // error
+}
diff --git a/final/test/extensions/nothing_to_do.pass.cpp b/final/test/extensions/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/extensions/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/file.streams/c.files/cinttypes.pass.cpp b/final/test/input.output/file.streams/c.files/cinttypes.pass.cpp
new file mode 100644
index 0000000..4cb2c4c
--- /dev/null
+++ b/final/test/input.output/file.streams/c.files/cinttypes.pass.cpp
@@ -0,0 +1,929 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cinttypes>
+
+#include <cinttypes>
+#include <type_traits>
+
+#ifndef INT8_MIN
+#error INT8_MIN not defined
+#endif
+
+#ifndef INT16_MIN
+#error INT16_MIN not defined
+#endif
+
+#ifndef INT32_MIN
+#error INT32_MIN not defined
+#endif
+
+#ifndef INT64_MIN
+#error INT64_MIN not defined
+#endif
+
+#ifndef INT8_MAX
+#error INT8_MAX not defined
+#endif
+
+#ifndef INT16_MAX
+#error INT16_MAX not defined
+#endif
+
+#ifndef INT32_MAX
+#error INT32_MAX not defined
+#endif
+
+#ifndef INT64_MAX
+#error INT64_MAX not defined
+#endif
+
+#ifndef UINT8_MAX
+#error UINT8_MAX not defined
+#endif
+
+#ifndef UINT16_MAX
+#error UINT16_MAX not defined
+#endif
+
+#ifndef UINT32_MAX
+#error UINT32_MAX not defined
+#endif
+
+#ifndef UINT64_MAX
+#error UINT64_MAX not defined
+#endif
+
+#ifndef INT_LEAST8_MIN
+#error INT_LEAST8_MIN not defined
+#endif
+
+#ifndef INT_LEAST16_MIN
+#error INT_LEAST16_MIN not defined
+#endif
+
+#ifndef INT_LEAST32_MIN
+#error INT_LEAST32_MIN not defined
+#endif
+
+#ifndef INT_LEAST64_MIN
+#error INT_LEAST64_MIN not defined
+#endif
+
+#ifndef INT_LEAST8_MAX
+#error INT_LEAST8_MAX not defined
+#endif
+
+#ifndef INT_LEAST16_MAX
+#error INT_LEAST16_MAX not defined
+#endif
+
+#ifndef INT_LEAST32_MAX
+#error INT_LEAST32_MAX not defined
+#endif
+
+#ifndef INT_LEAST64_MAX
+#error INT_LEAST64_MAX not defined
+#endif
+
+#ifndef UINT_LEAST8_MAX
+#error UINT_LEAST8_MAX not defined
+#endif
+
+#ifndef UINT_LEAST16_MAX
+#error UINT_LEAST16_MAX not defined
+#endif
+
+#ifndef UINT_LEAST32_MAX
+#error UINT_LEAST32_MAX not defined
+#endif
+
+#ifndef UINT_LEAST64_MAX
+#error UINT_LEAST64_MAX not defined
+#endif
+
+#ifndef INT_FAST8_MIN
+#error INT_FAST8_MIN not defined
+#endif
+
+#ifndef INT_FAST16_MIN
+#error INT_FAST16_MIN not defined
+#endif
+
+#ifndef INT_FAST32_MIN
+#error INT_FAST32_MIN not defined
+#endif
+
+#ifndef INT_FAST64_MIN
+#error INT_FAST64_MIN not defined
+#endif
+
+#ifndef INT_FAST8_MAX
+#error INT_FAST8_MAX not defined
+#endif
+
+#ifndef INT_FAST16_MAX
+#error INT_FAST16_MAX not defined
+#endif
+
+#ifndef INT_FAST32_MAX
+#error INT_FAST32_MAX not defined
+#endif
+
+#ifndef INT_FAST64_MAX
+#error INT_FAST64_MAX not defined
+#endif
+
+#ifndef UINT_FAST8_MAX
+#error UINT_FAST8_MAX not defined
+#endif
+
+#ifndef UINT_FAST16_MAX
+#error UINT_FAST16_MAX not defined
+#endif
+
+#ifndef UINT_FAST32_MAX
+#error UINT_FAST32_MAX not defined
+#endif
+
+#ifndef UINT_FAST64_MAX
+#error UINT_FAST64_MAX not defined
+#endif
+
+#ifndef INTPTR_MIN
+#error INTPTR_MIN not defined
+#endif
+
+#ifndef INTPTR_MAX
+#error INTPTR_MAX not defined
+#endif
+
+#ifndef UINTPTR_MAX
+#error UINTPTR_MAX not defined
+#endif
+
+#ifndef INTMAX_MIN
+#error INTMAX_MIN not defined
+#endif
+
+#ifndef INTMAX_MAX
+#error INTMAX_MAX not defined
+#endif
+
+#ifndef UINTMAX_MAX
+#error UINTMAX_MAX not defined
+#endif
+
+#ifndef PTRDIFF_MIN
+#error PTRDIFF_MIN not defined
+#endif
+
+#ifndef PTRDIFF_MAX
+#error PTRDIFF_MAX not defined
+#endif
+
+#ifndef SIG_ATOMIC_MIN
+#error SIG_ATOMIC_MIN not defined
+#endif
+
+#ifndef SIG_ATOMIC_MAX
+#error SIG_ATOMIC_MAX not defined
+#endif
+
+#ifndef SIZE_MAX
+#error SIZE_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WINT_MIN
+#error WINT_MIN not defined
+#endif
+
+#ifndef WINT_MAX
+#error WINT_MAX not defined
+#endif
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+
+#ifndef PRId8
+#error PRId8 not defined
+#endif
+
+#ifndef PRId16
+#error PRId16 not defined
+#endif
+
+#ifndef PRId32
+#error PRId32 not defined
+#endif
+
+#ifndef PRId64
+#error PRId64 not defined
+#endif
+
+#ifndef PRIdLEAST8
+#error PRIdLEAST8 not defined
+#endif
+
+#ifndef PRIdLEAST16
+#error PRIdLEAST16 not defined
+#endif
+
+#ifndef PRIdLEAST32
+#error PRIdLEAST32 not defined
+#endif
+
+#ifndef PRIdLEAST64
+#error PRIdLEAST64 not defined
+#endif
+
+#ifndef PRIdFAST8
+#error PRIdFAST8 not defined
+#endif
+
+#ifndef PRIdFAST16
+#error PRIdFAST16 not defined
+#endif
+
+#ifndef PRIdFAST32
+#error PRIdFAST32 not defined
+#endif
+
+#ifndef PRIdFAST64
+#error PRIdFAST64 not defined
+#endif
+
+#ifndef PRIdMAX
+#error PRIdMAX not defined
+#endif
+
+#ifndef PRIdPTR
+#error PRIdPTR not defined
+#endif
+
+#ifndef PRIi8
+#error PRIi8 not defined
+#endif
+
+#ifndef PRIi16
+#error PRIi16 not defined
+#endif
+
+#ifndef PRIi32
+#error PRIi32 not defined
+#endif
+
+#ifndef PRIi64
+#error PRIi64 not defined
+#endif
+
+#ifndef PRIiLEAST8
+#error PRIiLEAST8 not defined
+#endif
+
+#ifndef PRIiLEAST16
+#error PRIiLEAST16 not defined
+#endif
+
+#ifndef PRIiLEAST32
+#error PRIiLEAST32 not defined
+#endif
+
+#ifndef PRIiLEAST64
+#error PRIiLEAST64 not defined
+#endif
+
+#ifndef PRIiFAST8
+#error PRIiFAST8 not defined
+#endif
+
+#ifndef PRIiFAST16
+#error PRIiFAST16 not defined
+#endif
+
+#ifndef PRIiFAST32
+#error PRIiFAST32 not defined
+#endif
+
+#ifndef PRIiFAST64
+#error PRIiFAST64 not defined
+#endif
+
+#ifndef PRIiMAX
+#error PRIiMAX not defined
+#endif
+
+#ifndef PRIiPTR
+#error PRIiPTR not defined
+#endif
+
+#ifndef PRIo8
+#error PRIo8 not defined
+#endif
+
+#ifndef PRIo16
+#error PRIo16 not defined
+#endif
+
+#ifndef PRIo32
+#error PRIo32 not defined
+#endif
+
+#ifndef PRIo64
+#error PRIo64 not defined
+#endif
+
+#ifndef PRIoLEAST8
+#error PRIoLEAST8 not defined
+#endif
+
+#ifndef PRIoLEAST16
+#error PRIoLEAST16 not defined
+#endif
+
+#ifndef PRIoLEAST32
+#error PRIoLEAST32 not defined
+#endif
+
+#ifndef PRIoLEAST64
+#error PRIoLEAST64 not defined
+#endif
+
+#ifndef PRIoFAST8
+#error PRIoFAST8 not defined
+#endif
+
+#ifndef PRIoFAST16
+#error PRIoFAST16 not defined
+#endif
+
+#ifndef PRIoFAST32
+#error PRIoFAST32 not defined
+#endif
+
+#ifndef PRIoFAST64
+#error PRIoFAST64 not defined
+#endif
+
+#ifndef PRIoMAX
+#error PRIoMAX not defined
+#endif
+
+#ifndef PRIoPTR
+#error PRIoPTR not defined
+#endif
+
+#ifndef PRIu8
+#error PRIu8 not defined
+#endif
+
+#ifndef PRIu16
+#error PRIu16 not defined
+#endif
+
+#ifndef PRIu32
+#error PRIu32 not defined
+#endif
+
+#ifndef PRIu64
+#error PRIu64 not defined
+#endif
+
+#ifndef PRIuLEAST8
+#error PRIuLEAST8 not defined
+#endif
+
+#ifndef PRIuLEAST16
+#error PRIuLEAST16 not defined
+#endif
+
+#ifndef PRIuLEAST32
+#error PRIuLEAST32 not defined
+#endif
+
+#ifndef PRIuLEAST64
+#error PRIuLEAST64 not defined
+#endif
+
+#ifndef PRIuFAST8
+#error PRIuFAST8 not defined
+#endif
+
+#ifndef PRIuFAST16
+#error PRIuFAST16 not defined
+#endif
+
+#ifndef PRIuFAST32
+#error PRIuFAST32 not defined
+#endif
+
+#ifndef PRIuFAST64
+#error PRIuFAST64 not defined
+#endif
+
+#ifndef PRIuMAX
+#error PRIuMAX not defined
+#endif
+
+#ifndef PRIuPTR
+#error PRIuPTR not defined
+#endif
+
+#ifndef PRIx8
+#error PRIx8 not defined
+#endif
+
+#ifndef PRIx16
+#error PRIx16 not defined
+#endif
+
+#ifndef PRIx32
+#error PRIx32 not defined
+#endif
+
+#ifndef PRIx64
+#error PRIx64 not defined
+#endif
+
+#ifndef PRIxLEAST8
+#error PRIxLEAST8 not defined
+#endif
+
+#ifndef PRIxLEAST16
+#error PRIxLEAST16 not defined
+#endif
+
+#ifndef PRIxLEAST32
+#error PRIxLEAST32 not defined
+#endif
+
+#ifndef PRIxLEAST64
+#error PRIxLEAST64 not defined
+#endif
+
+#ifndef PRIxFAST8
+#error PRIxFAST8 not defined
+#endif
+
+#ifndef PRIxFAST16
+#error PRIxFAST16 not defined
+#endif
+
+#ifndef PRIxFAST32
+#error PRIxFAST32 not defined
+#endif
+
+#ifndef PRIxFAST64
+#error PRIxFAST64 not defined
+#endif
+
+#ifndef PRIxMAX
+#error PRIxMAX not defined
+#endif
+
+#ifndef PRIxPTR
+#error PRIxPTR not defined
+#endif
+
+#ifndef PRIX8
+#error PRIX8 not defined
+#endif
+
+#ifndef PRIX16
+#error PRIX16 not defined
+#endif
+
+#ifndef PRIX32
+#error PRIX32 not defined
+#endif
+
+#ifndef PRIX64
+#error PRIX64 not defined
+#endif
+
+#ifndef PRIXLEAST8
+#error PRIXLEAST8 not defined
+#endif
+
+#ifndef PRIXLEAST16
+#error PRIXLEAST16 not defined
+#endif
+
+#ifndef PRIXLEAST32
+#error PRIXLEAST32 not defined
+#endif
+
+#ifndef PRIXLEAST64
+#error PRIXLEAST64 not defined
+#endif
+
+#ifndef PRIXFAST8
+#error PRIXFAST8 not defined
+#endif
+
+#ifndef PRIXFAST16
+#error PRIXFAST16 not defined
+#endif
+
+#ifndef PRIXFAST32
+#error PRIXFAST32 not defined
+#endif
+
+#ifndef PRIXFAST64
+#error PRIXFAST64 not defined
+#endif
+
+#ifndef PRIXMAX
+#error PRIXMAX not defined
+#endif
+
+#ifndef PRIXPTR
+#error PRIXPTR not defined
+#endif
+
+#ifndef SCNd8
+#error SCNd8 not defined
+#endif
+
+#ifndef SCNd16
+#error SCNd16 not defined
+#endif
+
+#ifndef SCNd32
+#error SCNd32 not defined
+#endif
+
+#ifndef SCNd64
+#error SCNd64 not defined
+#endif
+
+#ifndef SCNdLEAST8
+#error SCNdLEAST8 not defined
+#endif
+
+#ifndef SCNdLEAST16
+#error SCNdLEAST16 not defined
+#endif
+
+#ifndef SCNdLEAST32
+#error SCNdLEAST32 not defined
+#endif
+
+#ifndef SCNdLEAST64
+#error SCNdLEAST64 not defined
+#endif
+
+#ifndef SCNdFAST8
+#error SCNdFAST8 not defined
+#endif
+
+#ifndef SCNdFAST16
+#error SCNdFAST16 not defined
+#endif
+
+#ifndef SCNdFAST32
+#error SCNdFAST32 not defined
+#endif
+
+#ifndef SCNdFAST64
+#error SCNdFAST64 not defined
+#endif
+
+#ifndef SCNdMAX
+#error SCNdMAX not defined
+#endif
+
+#ifndef SCNdPTR
+#error SCNdPTR not defined
+#endif
+
+#ifndef SCNi8
+#error SCNi8 not defined
+#endif
+
+#ifndef SCNi16
+#error SCNi16 not defined
+#endif
+
+#ifndef SCNi32
+#error SCNi32 not defined
+#endif
+
+#ifndef SCNi64
+#error SCNi64 not defined
+#endif
+
+#ifndef SCNiLEAST8
+#error SCNiLEAST8 not defined
+#endif
+
+#ifndef SCNiLEAST16
+#error SCNiLEAST16 not defined
+#endif
+
+#ifndef SCNiLEAST32
+#error SCNiLEAST32 not defined
+#endif
+
+#ifndef SCNiLEAST64
+#error SCNiLEAST64 not defined
+#endif
+
+#ifndef SCNiFAST8
+#error SCNiFAST8 not defined
+#endif
+
+#ifndef SCNiFAST16
+#error SCNiFAST16 not defined
+#endif
+
+#ifndef SCNiFAST32
+#error SCNiFAST32 not defined
+#endif
+
+#ifndef SCNiFAST64
+#error SCNiFAST64 not defined
+#endif
+
+#ifndef SCNiMAX
+#error SCNiMAX not defined
+#endif
+
+#ifndef SCNiPTR
+#error SCNiPTR not defined
+#endif
+
+#ifndef SCNo8
+#error SCNo8 not defined
+#endif
+
+#ifndef SCNo16
+#error SCNo16 not defined
+#endif
+
+#ifndef SCNo32
+#error SCNo32 not defined
+#endif
+
+#ifndef SCNo64
+#error SCNo64 not defined
+#endif
+
+#ifndef SCNoLEAST8
+#error SCNoLEAST8 not defined
+#endif
+
+#ifndef SCNoLEAST16
+#error SCNoLEAST16 not defined
+#endif
+
+#ifndef SCNoLEAST32
+#error SCNoLEAST32 not defined
+#endif
+
+#ifndef SCNoLEAST64
+#error SCNoLEAST64 not defined
+#endif
+
+#ifndef SCNoFAST8
+#error SCNoFAST8 not defined
+#endif
+
+#ifndef SCNoFAST16
+#error SCNoFAST16 not defined
+#endif
+
+#ifndef SCNoFAST32
+#error SCNoFAST32 not defined
+#endif
+
+#ifndef SCNoFAST64
+#error SCNoFAST64 not defined
+#endif
+
+#ifndef SCNoMAX
+#error SCNoMAX not defined
+#endif
+
+#ifndef SCNoPTR
+#error SCNoPTR not defined
+#endif
+
+#ifndef SCNu8
+#error SCNu8 not defined
+#endif
+
+#ifndef SCNu16
+#error SCNu16 not defined
+#endif
+
+#ifndef SCNu32
+#error SCNu32 not defined
+#endif
+
+#ifndef SCNu64
+#error SCNu64 not defined
+#endif
+
+#ifndef SCNuLEAST8
+#error SCNuLEAST8 not defined
+#endif
+
+#ifndef SCNuLEAST16
+#error SCNuLEAST16 not defined
+#endif
+
+#ifndef SCNuLEAST32
+#error SCNuLEAST32 not defined
+#endif
+
+#ifndef SCNuLEAST64
+#error SCNuLEAST64 not defined
+#endif
+
+#ifndef SCNuFAST8
+#error SCNuFAST8 not defined
+#endif
+
+#ifndef SCNuFAST16
+#error SCNuFAST16 not defined
+#endif
+
+#ifndef SCNuFAST32
+#error SCNuFAST32 not defined
+#endif
+
+#ifndef SCNuFAST64
+#error SCNuFAST64 not defined
+#endif
+
+#ifndef SCNuMAX
+#error SCNuMAX not defined
+#endif
+
+#ifndef SCNuPTR
+#error SCNuPTR not defined
+#endif
+
+#ifndef SCNx8
+#error SCNx8 not defined
+#endif
+
+#ifndef SCNx16
+#error SCNx16 not defined
+#endif
+
+#ifndef SCNx32
+#error SCNx32 not defined
+#endif
+
+#ifndef SCNx64
+#error SCNx64 not defined
+#endif
+
+#ifndef SCNxLEAST8
+#error SCNxLEAST8 not defined
+#endif
+
+#ifndef SCNxLEAST16
+#error SCNxLEAST16 not defined
+#endif
+
+#ifndef SCNxLEAST32
+#error SCNxLEAST32 not defined
+#endif
+
+#ifndef SCNxLEAST64
+#error SCNxLEAST64 not defined
+#endif
+
+#ifndef SCNxFAST8
+#error SCNxFAST8 not defined
+#endif
+
+#ifndef SCNxFAST16
+#error SCNxFAST16 not defined
+#endif
+
+#ifndef SCNxFAST32
+#error SCNxFAST32 not defined
+#endif
+
+#ifndef SCNxFAST64
+#error SCNxFAST64 not defined
+#endif
+
+#ifndef SCNxMAX
+#error SCNxMAX not defined
+#endif
+
+#ifndef SCNxPTR
+#error SCNxPTR not defined
+#endif
+
+int main()
+{
+    {
+    std::int8_t  i1 = 0;
+    std::int16_t i2 = 0;
+    std::int32_t i3 = 0;
+    std::int64_t i4 = 0;
+    }
+    {
+    std::uint8_t  i1 = 0;
+    std::uint16_t i2 = 0;
+    std::uint32_t i3 = 0;
+    std::uint64_t i4 = 0;
+    }
+    {
+    std::int_least8_t  i1 = 0;
+    std::int_least16_t i2 = 0;
+    std::int_least32_t i3 = 0;
+    std::int_least64_t i4 = 0;
+    }
+    {
+    std::uint_least8_t  i1 = 0;
+    std::uint_least16_t i2 = 0;
+    std::uint_least32_t i3 = 0;
+    std::uint_least64_t i4 = 0;
+    }
+    {
+    std::int_fast8_t  i1 = 0;
+    std::int_fast16_t i2 = 0;
+    std::int_fast32_t i3 = 0;
+    std::int_fast64_t i4 = 0;
+    }
+    {
+    std::uint_fast8_t  i1 = 0;
+    std::uint_fast16_t i2 = 0;
+    std::uint_fast32_t i3 = 0;
+    std::uint_fast64_t i4 = 0;
+    }
+    {
+    std::intptr_t  i1 = 0;
+    std::uintptr_t i2 = 0;
+    std::intmax_t  i3 = 0;
+    std::uintmax_t i4 = 0;
+    }
+    {
+    std::imaxdiv_t  i1 = {0};
+    }
+    std::intmax_t i = 0;
+    static_assert((std::is_same<decltype(std::imaxabs(i)), std::intmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::imaxdiv(i, i)), std::imaxdiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::strtoimax("", (char**)0, 0)), std::intmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::strtoumax("", (char**)0, 0)), std::uintmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoimax(L"", (wchar_t**)0, 0)), std::intmax_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoumax(L"", (wchar_t**)0, 0)), std::uintmax_t>::value), "");
+}
diff --git a/final/test/input.output/file.streams/c.files/cstdio.pass.cpp b/final/test/input.output/file.streams/c.files/cstdio.pass.cpp
new file mode 100644
index 0000000..1a60dd6
--- /dev/null
+++ b/final/test/input.output/file.streams/c.files/cstdio.pass.cpp
@@ -0,0 +1,139 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdio>
+
+#include <cstdio>
+#include <type_traits>
+
+#ifndef BUFSIZ
+#error BUFSIZ not defined
+#endif
+
+#ifndef EOF
+#error EOF not defined
+#endif
+
+#ifndef FILENAME_MAX
+#error FILENAME_MAX not defined
+#endif
+
+#ifndef FOPEN_MAX
+#error FOPEN_MAX not defined
+#endif
+
+#ifndef L_tmpnam
+#error L_tmpnam not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef SEEK_CUR
+#error SEEK_CUR not defined
+#endif
+
+#ifndef SEEK_END
+#error SEEK_END not defined
+#endif
+
+#ifndef SEEK_SET
+#error SEEK_SET not defined
+#endif
+
+#ifndef TMP_MAX
+#error TMP_MAX not defined
+#endif
+
+#ifndef _IOFBF
+#error _IOFBF not defined
+#endif
+
+#ifndef _IOLBF
+#error _IOLBF not defined
+#endif
+
+#ifndef _IONBF
+#error _IONBF not defined
+#endif
+
+#ifndef stderr
+#error stderr not defined
+#endif
+
+#ifndef stdin
+#error stdin not defined
+#endif
+
+#ifndef stdout
+#error stdout not defined
+#endif
+
+#include <cstdarg>
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-zero-length"
+
+int main()
+{
+    std::FILE* fp = 0;
+    std::fpos_t fpos = {0};
+    std::size_t s = 0;
+    char* cp = 0;
+    std::va_list va;
+    static_assert((std::is_same<decltype(std::remove("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::rename("","")), int>::value), "");
+    static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), "");
+    static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::fclose(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), "");
+    static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), "");
+    static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), "");
+    static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fprintf(fp," ")), int>::value), "");
+    static_assert((std::is_same<decltype(std::fscanf(fp,"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::printf(" ")), int>::value), "");
+    static_assert((std::is_same<decltype(std::scanf(" ")), int>::value), "");
+    static_assert((std::is_same<decltype(std::snprintf(cp,0," ")), int>::value), "");
+    static_assert((std::is_same<decltype(std::sprintf(cp," ")), int>::value), "");
+    static_assert((std::is_same<decltype(std::sscanf("","")), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfscanf(fp,"",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vprintf(" ",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vscanf("",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vsnprintf(cp,0," ",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vsprintf(cp," ",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vsscanf("","",va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fgetc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fgets(cp,0,fp)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::fputc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::getc(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::getchar()), int>::value), "");
+#if _LIBCPP_STD_VER <= 11
+    static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
+#endif
+    static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::putchar(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::puts("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::ungetc(0,fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fread((void*)0,0,0,fp)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::fwrite((const void*)0,0,0,fp)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::fgetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fseek(fp, 0,0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fsetpos(fp, &fpos)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ftell(fp)), long>::value), "");
+    static_assert((std::is_same<decltype(std::rewind(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(std::clearerr(fp)), void>::value), "");
+    static_assert((std::is_same<decltype(std::feof(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ferror(fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::perror("")), void>::value), "");
+}
diff --git a/final/test/input.output/file.streams/c.files/gets.fail.cpp b/final/test/input.output/file.streams/c.files/gets.fail.cpp
new file mode 100644
index 0000000..4250e23
--- /dev/null
+++ b/final/test/input.output/file.streams/c.files/gets.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdio>
+
+// gets 
+
+#include <cstdio>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    (void) std::gets((char *) NULL);
+#else
+#error
+#endif
+}
diff --git a/final/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp b/final/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp
new file mode 100644
index 0000000..0d7fc56
--- /dev/null
+++ b/final/test/input.output/file.streams/c.files/version_ccstdio.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdio>
+
+#include <cstdio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp b/final/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp
new file mode 100644
index 0000000..bfd379e
--- /dev/null
+++ b/final/test/input.output/file.streams/c.files/version_cinttypes.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cinttypes>
+
+#include <cinttypes>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..8684434
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.assign/member_swap.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// void swap(basic_filebuf& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::filebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2;
+        f2.swap(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfilebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2;
+        f2.swap(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..a92ec87
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.assign/move_assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf& operator=(basic_filebuf&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::string temp = get_temp_file_name();
+    {
+        std::filebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2;
+        f2 = move(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfilebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2;
+        f2 = move(f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    std::remove(temp.c_str());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..084d001
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// template <class charT, class traits>
+// void
+// swap(basic_filebuf<charT, traits>& x, basic_filebuf<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::filebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2;
+        swap(f2, f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfilebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2;
+        swap(f2, f);
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp
new file mode 100644
index 0000000..f4fbbf6
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::filebuf f;
+        assert(!f.is_open());
+    }
+    {
+        std::wfilebuf f;
+        assert(!f.is_open());
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
new file mode 100644
index 0000000..f13ee44
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.cons/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+
+// basic_filebuf(basic_filebuf&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::string temp = get_temp_file_name();
+    {
+        std::filebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == '2');
+        std::filebuf f2(move(f));
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == '2');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfilebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out | std::ios_base::in
+                                               | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+        f.pubseekoff(1, std::ios_base::beg);
+        assert(f.sgetc() == L'2');
+        std::wfilebuf f2(move(f));
+        assert(!f.is_open());
+        assert(f2.is_open());
+        assert(f2.sgetc() == L'2');
+    }
+    std::remove(temp.c_str());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..9d2d567
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.members/open_pointer.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// basic_filebuf<charT,traits>* open(const char* s, ios_base::openmode mode);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::filebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.sputn("123", 3) == 3);
+    }
+    {
+        std::filebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == '1');
+        assert(f.sbumpc() == '2');
+        assert(f.sbumpc() == '3');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfilebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.sputn(L"123", 3) == 3);
+    }
+    {
+        std::wfilebuf f;
+        assert(f.open(temp.c_str(), std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == L'1');
+        assert(f.sbumpc() == L'2');
+        assert(f.sbumpc() == L'3');
+    }
+    remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp
new file mode 100644
index 0000000..1da3856
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type overflow(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test_buf
+    : public std::basic_filebuf<CharT>
+{
+    typedef std::basic_filebuf<CharT>  base;
+    typedef typename base::char_type   char_type;
+    typedef typename base::int_type    int_type;
+    typedef typename base::traits_type traits_type;
+
+    char_type* pbase() const {return base::pbase();}
+    char_type* pptr()  const {return base::pptr();}
+    char_type* epptr() const {return base::epptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);}
+};
+
+int main()
+{
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow('a') == 'a');
+        assert(f.pbase() != 0);
+        assert(f.pptr() == f.pbase());
+        assert(f.epptr() - f.pbase() == 4095);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == 'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<char> f;
+        f.pubsetbuf(0, 0);
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow('a') == 'a');
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == 'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow(L'a') == L'a');
+        assert(f.pbase() != 0);
+        assert(f.pptr() == f.pbase());
+        assert(f.epptr() - f.pbase() == 4095);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == L'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<wchar_t> f;
+        f.pubsetbuf(0, 0);
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow(L'a') == L'a');
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sgetc() == L'a');
+    }
+    std::remove("overflow.dat");
+    {
+        test_buf<wchar_t> f;
+        f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
+        assert(f.open("overflow.dat", std::ios_base::out) != 0);
+        assert(f.sputc(0x4E51) == 0x4E51);
+        assert(f.sputc(0x4E52) == 0x4E52);
+        assert(f.sputc(0x4E53) == 0x4E53);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("overflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == 0xE4);
+        assert(f.sbumpc() == 0xB9);
+        assert(f.sbumpc() == 0x91);
+        assert(f.sbumpc() == 0xE4);
+        assert(f.sbumpc() == 0xB9);
+        assert(f.sbumpc() == 0x92);
+        assert(f.sbumpc() == 0xE4);
+        assert(f.sbumpc() == 0xB9);
+        assert(f.sbumpc() == 0x93);
+        assert(f.sbumpc() == -1);
+    }
+    std::remove("overflow.dat");
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 0000000..4419cb5
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type pbackfail(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+template <class CharT>
+struct test_buf
+    : public std::basic_filebuf<CharT>
+{
+    typedef std::basic_filebuf<CharT>  base;
+    typedef typename base::char_type   char_type;
+    typedef typename base::int_type    int_type;
+    typedef typename base::traits_type traits_type;
+
+    char_type* eback() const {return base::eback();}
+    char_type* gptr()  const {return base::gptr();}
+    char_type* egptr() const {return base::egptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
+};
+
+int main()
+{
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == '1');
+        assert(f.sgetc() == '2');
+        assert(f.pbackfail('a') == -1);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in | std::ios_base::out) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == '1');
+        assert(f.sgetc() == '2');
+        assert(f.pbackfail('a') == 'a');
+        assert(f.sbumpc() == 'a');
+        assert(f.sgetc() == '2');
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 0000000..eb15fac
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+// pos_type seekpos(pos_type sp,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        char buf[10];
+        typedef std::filebuf::pos_type pos_type;
+        std::filebuf f;
+        f.pubsetbuf(buf, sizeof(buf));
+        assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
+                                                       | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        f.sputn("abcdefghijklmnopqrstuvwxyz", 26);
+        assert(buf[0] == 'v');
+        pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+        assert(p == 11);
+        assert(f.sgetc() == 'l');
+        f.pubseekoff(0, std::ios_base::beg);
+        assert(f.sgetc() == 'a');
+        f.pubseekoff(-1, std::ios_base::end);
+        assert(f.sgetc() == 'z');
+        assert(f.pubseekpos(p) == p);
+        assert(f.sgetc() == 'l');
+    }
+    std::remove("seekoff.dat");
+    {
+        wchar_t buf[10];
+        typedef std::filebuf::pos_type pos_type;
+        std::wfilebuf f;
+        f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
+        assert(f.open("seekoff.dat", std::ios_base::in | std::ios_base::out
+                                                       | std::ios_base::trunc) != 0);
+        assert(f.is_open());
+        f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
+        assert(buf[0] == L'v');
+        pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+        assert(p == 11);
+        assert(f.sgetc() == L'l');
+        f.pubseekoff(0, std::ios_base::beg);
+        assert(f.sgetc() == L'a');
+        f.pubseekoff(-1, std::ios_base::end);
+        assert(f.sgetc() == L'z');
+        assert(f.pubseekpos(p) == p);
+        assert(f.sgetc() == L'l');
+    }
+    std::remove("seekoff.dat");
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat
new file mode 100644
index 0000000..e2e107a
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.dat
@@ -0,0 +1 @@
+123456789
\ No newline at end of file
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp
new file mode 100644
index 0000000..e34bc84
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// int_type underflow();
+
+// This test is not entirely portable
+
+#include <fstream>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test_buf
+    : public std::basic_filebuf<CharT>
+{
+    typedef std::basic_filebuf<CharT> base;
+    typedef typename base::char_type  char_type;
+    typedef typename base::int_type   int_type;
+
+    char_type* eback() const {return base::eback();}
+    char_type* gptr()  const {return base::gptr();}
+    char_type* egptr() const {return base::egptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == '1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == '1');
+        assert(f.egptr() - f.eback() == 9);
+    }
+    {
+        test_buf<char> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.pubsetbuf(0, 0));
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == '1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == '1');
+        assert(f.egptr() - f.eback() == 8);
+        f.gbump(8);
+        assert(f.sgetc() == '9');
+        assert(f.eback()[0] == '5');
+        assert(f.eback()[1] == '6');
+        assert(f.eback()[2] == '7');
+        assert(f.eback()[3] == '8');
+        assert(f.gptr() - f.eback() == 4);
+        assert(*f.gptr() == '9');
+        assert(f.egptr() - f.gptr() == 1);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == L'1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == L'1');
+        assert(f.egptr() - f.eback() == 9);
+    }
+    {
+        test_buf<wchar_t> f;
+        assert(f.pubsetbuf(0, 0));
+        assert(f.open("underflow.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == L'1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == L'1');
+        assert(f.egptr() - f.eback() == 8);
+        f.gbump(8);
+        assert(f.sgetc() == L'9');
+        assert(f.eback()[0] == L'5');
+        assert(f.eback()[1] == L'6');
+        assert(f.eback()[2] == L'7');
+        assert(f.eback()[3] == L'8');
+        assert(f.gptr() - f.eback() == 4);
+        assert(*f.gptr() == L'9');
+        assert(f.egptr() - f.gptr() == 1);
+    }
+    {
+        test_buf<wchar_t> f;
+        f.pubimbue(std::locale(LOCALE_en_US_UTF_8));
+        assert(f.open("underflow_utf8.dat", std::ios_base::in) != 0);
+        assert(f.is_open());
+        assert(f.sbumpc() == 0x4E51);
+        assert(f.sbumpc() == 0x4E52);
+        assert(f.sbumpc() == 0x4E53);
+        assert(f.sbumpc() == -1);
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat
new file mode 100644
index 0000000..ee7063e
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf.virtuals/underflow_utf8.dat
@@ -0,0 +1 @@
+乑乒乓
\ No newline at end of file
diff --git a/final/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp b/final/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp
new file mode 100644
index 0000000..5d77e00
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/filebuf/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_filebuf
+//     : public basic_streambuf<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_filebuf<char> >::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_filebuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..fcc86a1
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.assign/member_swap.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void swap(basic_fstream& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp1 = get_temp_file_name();
+    std::string temp2 = get_temp_file_name();
+    {
+        std::fstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        std::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        fs1.swap(fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove(temp1.c_str());
+    std::remove(temp2.c_str());
+    {
+        std::wfstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
+        std::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        fs1.swap(fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove(temp1.c_str());
+    std::remove(temp2.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..b5157e9
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.assign/move_assign.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream& operator=(basic_fstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::string temp = get_temp_file_name();
+    {
+        std::fstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
+                                                 | std::ios_base::trunc);
+        std::fstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfstream fso(temp.c_str(), std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        std::wfstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..0a4f724
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// template <class charT, class traits>
+//   void swap(basic_fstream<charT, traits>& x, basic_fstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp1 = get_temp_file_name();
+    std::string temp2 = get_temp_file_name();
+    {
+        std::fstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        std::fstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        swap(fs1, fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove(temp1.c_str());
+    std::remove(temp2.c_str());
+    {
+        std::wfstream fs1(temp1.c_str(), std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
+        std::wfstream fs2(temp2.c_str(), std::ios_base::in | std::ios_base::out
+                                                   | std::ios_base::trunc);
+        fs1 << 1 << ' ' << 2;
+        fs2 << 2 << ' ' << 1;
+        fs1.seekg(0);
+        swap(fs1, fs2);
+        fs1.seekg(0);
+        int i;
+        fs1 >> i;
+        assert(i == 2);
+        fs1 >> i;
+        assert(i == 1);
+        i = 0;
+        fs2 >> i;
+        assert(i == 1);
+        fs2 >> i;
+        assert(i == 2);
+    }
+    std::remove(temp1.c_str());
+    std::remove(temp2.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
new file mode 100644
index 0000000..cfd5a03
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    {
+        std::fstream fs;
+    }
+    {
+        std::wfstream fs;
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
new file mode 100644
index 0000000..d2ae302
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.cons/move.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_fstream(basic_fstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::string temp = get_temp_file_name();
+    {
+        std::fstream fso(temp, std::ios_base::in | std::ios_base::out
+                                                 | std::ios_base::trunc);
+        std::fstream fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfstream fso(temp, std::ios_base::in | std::ios_base::out
+                                                  | std::ios_base::trunc);
+        std::wfstream fs = move(fso);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
new file mode 100644
index 0000000..06a6b77
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.cons/pointer.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in | ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::fstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
+                                                | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfstream fs(temp.c_str(), std::ios_base::in | std::ios_base::out
+                                                 | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
new file mode 100644
index 0000000..4b0819f
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.cons/string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::fstream fs(temp,
+                        std::ios_base::in | std::ios_base::out
+                                          | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfstream fs(temp,
+                         std::ios_base::in | std::ios_base::out
+                                           | std::ios_base::trunc);
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
new file mode 100644
index 0000000..0e4bc71
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.members/close.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::fstream fs;
+        assert(!fs.is_open());
+        fs.open(temp.c_str(), std::ios_base::out);
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfstream fs;
+        assert(!fs.is_open());
+        fs.open(temp.c_str(), std::ios_base::out);
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..231bb82
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.members/open_pointer.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::fstream fs;
+        assert(!fs.is_open());
+        fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
+                                        | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfstream fs;
+        assert(!fs.is_open());
+        fs.open(temp.c_str(), std::ios_base::in | std::ios_base::out
+                                        | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
new file mode 100644
index 0000000..182f12c
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.members/open_string.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::fstream fs;
+        assert(!fs.is_open());
+        fs.open(temp, std::ios_base::in | std::ios_base::out
+                                                     | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wfstream fs;
+        assert(!fs.is_open());
+        fs.open(temp, std::ios_base::in | std::ios_base::out
+                                                     | std::ios_base::trunc);
+        assert(fs.is_open());
+        double x = 0;
+        fs << 3.25;
+        fs.seekg(0);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..d839832
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream.members/rdbuf.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::fstream fs;
+        assert(fs.rdbuf());
+    }
+    {
+        std::wfstream fs;
+        assert(fs.rdbuf());
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/fstream/types.pass.cpp b/final/test/input.output/file.streams/fstreams/fstream/types.pass.cpp
new file mode 100644
index 0000000..6ced241
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/fstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_fstream
+//     : public basic_iostream<charT,traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_fstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_fstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..18443ce
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void swap(basic_ifstream& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs1("test.dat");
+        std::ifstream fs2("test2.dat");
+        fs1.swap(fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs1("test.dat");
+        std::wifstream fs2("test2.dat");
+        fs1.swap(fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..9c2fcad
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream& operator=(basic_ifstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::ifstream fso("test.dat");
+        std::ifstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fso("test.dat");
+        std::wifstream fs;
+        fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..5700720
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// template <class charT, class traits>
+//   void swap(basic_ifstream<charT, traits>& x, basic_ifstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs1("test.dat");
+        std::ifstream fs2("test2.dat");
+        swap(fs1, fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs1("test.dat");
+        std::wifstream fs2("test2.dat");
+        swap(fs1, fs2);
+        double x = 0;
+        fs1 >> x;
+        assert(x == 4.5);
+        fs2 >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.assign/test.dat b/final/test/input.output/file.streams/fstreams/ifstream.assign/test.dat
new file mode 100644
index 0000000..64064d3
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.assign/test.dat
@@ -0,0 +1 @@
+3.25
\ No newline at end of file
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat b/final/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat
new file mode 100644
index 0000000..958d30d
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.assign/test2.dat
@@ -0,0 +1 @@
+4.5
\ No newline at end of file
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
new file mode 100644
index 0000000..41e6780
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    {
+        std::ifstream fs;
+    }
+    {
+        std::wifstream fs;
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp
new file mode 100644
index 0000000..aaac121
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_ifstream(basic_ifstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::ifstream fso("test.dat");
+        std::ifstream fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fso("test.dat");
+        std::wifstream fs = move(fso);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
new file mode 100644
index 0000000..f43df3c
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::ifstream fs("test.dat", std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs("test.dat");
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs("test.dat", std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
new file mode 100644
index 0000000..ad5fe51
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs(std::string("test.dat"));
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::ifstream fs(std::string("test.dat"), std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs(std::string("test.dat"));
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    {
+        std::wifstream fs(std::string("test.dat"), std::ios_base::out);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.cons/test.dat b/final/test/input.output/file.streams/fstreams/ifstream.cons/test.dat
new file mode 100644
index 0000000..64064d3
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.cons/test.dat
@@ -0,0 +1 @@
+3.25
\ No newline at end of file
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp
new file mode 100644
index 0000000..3e39332
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    {
+        std::wifstream fs;
+        assert(!fs.is_open());
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..47dc85f
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == 'a');
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == 'r');
+    }
+    {
+        std::wifstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == L'a');
+        fs.open("test.dat");
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == L'r');
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp
new file mode 100644
index 0000000..619694e
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::in);
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == 'a');
+        fs.open(std::string("test.dat"));
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == 'r');
+    }
+    {
+        std::wifstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs >> c;
+        assert(fs.fail());
+        assert(c == L'a');
+        fs.open(std::string("test.dat"));
+        assert(fs.is_open());
+        fs >> c;
+        assert(c == L'r');
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..53fd294
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ifstream fs("test.dat");
+        std::filebuf* fb = fs.rdbuf();
+        assert(fb->sgetc() == 'r');
+    }
+    {
+        std::wifstream fs("test.dat");
+        std::wfilebuf* fb = fs.rdbuf();
+        assert(fb->sgetc() == L'r');
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ifstream.members/test.dat b/final/test/input.output/file.streams/fstreams/ifstream.members/test.dat
new file mode 100644
index 0000000..1d2f014
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream.members/test.dat
@@ -0,0 +1 @@
+r
\ No newline at end of file
diff --git a/final/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp b/final/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp
new file mode 100644
index 0000000..dd39eee
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ifstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ifstream
+//     : public basic_istream<charT,traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_istream<char>, std::basic_ifstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ifstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..519b84f
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.assign/member_swap.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void swap(basic_ofstream& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp1 = get_temp_file_name();
+    std::string temp2 = get_temp_file_name();
+    {
+        std::ofstream fs1(temp1.c_str());
+        std::ofstream fs2(temp2.c_str());
+        fs1 << 3.25;
+        fs2 << 4.5;
+        fs1.swap(fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::ifstream fs(temp1.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    std::remove(temp1.c_str());
+    {
+        std::ifstream fs(temp2.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp2.c_str());
+    {
+        std::wofstream fs1(temp1.c_str());
+        std::wofstream fs2(temp2.c_str());
+        fs1 << 3.25;
+        fs2 << 4.5;
+        fs1.swap(fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::wifstream fs(temp1.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    std::remove(temp1.c_str());
+    {
+        std::wifstream fs(temp2.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp2.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..0f21eb8
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.assign/move_assign.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream& operator=(basic_ofstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fso(temp.c_str());
+        std::ofstream fs;
+        fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs(temp.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fso(temp.c_str());
+        std::wofstream fs;
+        fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs(temp.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..d58f5f2
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// template <class charT, class traits>
+//   void swap(basic_ofstream<charT, traits>& x, basic_ofstream<charT, traits>& y);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp1 = get_temp_file_name();
+    std::string temp2 = get_temp_file_name();
+    {
+        std::ofstream fs1(temp1.c_str());
+        std::ofstream fs2(temp2.c_str());
+        fs1 << 3.25;
+        fs2 << 4.5;
+        swap(fs1, fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::ifstream fs(temp1.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    std::remove(temp1.c_str());
+    {
+        std::ifstream fs(temp2.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp2.c_str());
+    {
+        std::wofstream fs1(temp1.c_str());
+        std::wofstream fs2(temp2.c_str());
+        fs1 << 3.25;
+        fs2 << 4.5;
+        swap(fs1, fs2);
+        fs1 << ' ' << 3.25;
+        fs2 << ' ' << 4.5;
+    }
+    {
+        std::wifstream fs(temp1.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+        fs >> x;
+        assert(x == 4.5);
+    }
+    std::remove(temp1.c_str());
+    {
+        std::wifstream fs(temp2.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 4.5);
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp2.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
new file mode 100644
index 0000000..f8308ab
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.cons/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream();
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    {
+        std::ofstream fs;
+    }
+    {
+        std::wofstream fs;
+    }
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
new file mode 100644
index 0000000..8645358
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.cons/move.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_ofstream(basic_ofstream&& rhs);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fso(temp.c_str());
+        std::ofstream fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs(temp.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fso(temp.c_str());
+        std::wofstream fs = move(fso);
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs(temp.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
new file mode 100644
index 0000000..bd5832a
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.cons/pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fs(temp.c_str());
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs(temp.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fs(temp.c_str());
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs(temp.c_str());
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
new file mode 100644
index 0000000..7112b17
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.cons/string.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fs(temp);
+        fs << 3.25;
+    }
+    {
+        std::ifstream fs(temp);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fs(temp);
+        fs << 3.25;
+    }
+    {
+        std::wifstream fs(temp);
+        double x = 0;
+        fs >> x;
+        assert(x == 3.25);
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
new file mode 100644
index 0000000..b8c358d
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.members/close.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void close();
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fs;
+        assert(!fs.is_open());
+        fs.open(temp.c_str());
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fs;
+        assert(!fs.is_open());
+        fs.open(temp.c_str());
+        assert(fs.is_open());
+        fs.close();
+        assert(!fs.is_open());
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
new file mode 100644
index 0000000..e5cddc9
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.members/open_pointer.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void open(const char* s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open(temp.c_str());
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::ifstream fs(temp.c_str());
+        char c = 0;
+        fs >> c;
+        assert(c == 'a');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open(temp.c_str());
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::wifstream fs(temp.c_str());
+        wchar_t c = 0;
+        fs >> c;
+        assert(c == L'a');
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
new file mode 100644
index 0000000..d54aa18
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.members/open_string.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// void open(const string& s, ios_base::openmode mode = ios_base::out);
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fs;
+        assert(!fs.is_open());
+        char c = 'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open(temp);
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::ifstream fs(temp.c_str());
+        char c = 0;
+        fs >> c;
+        assert(c == 'a');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fs;
+        assert(!fs.is_open());
+        wchar_t c = L'a';
+        fs << c;
+        assert(fs.fail());
+        fs.open(temp);
+        assert(fs.is_open());
+        fs << c;
+    }
+    {
+        std::wifstream fs(temp.c_str());
+        wchar_t c = 0;
+        fs >> c;
+        assert(c == L'a');
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..d707e0a
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream.members/rdbuf.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+
+// basic_filebuf<charT,traits>* rdbuf() const;
+
+#include <fstream>
+#include <cassert>
+#include "platform_support.h"
+
+int main()
+{
+    std::string temp = get_temp_file_name();
+    {
+        std::ofstream fs(temp.c_str());
+        std::filebuf* fb = fs.rdbuf();
+        assert(fb->sputc('r') == 'r');
+    }
+    std::remove(temp.c_str());
+    {
+        std::wofstream fs(temp.c_str());
+        std::wfilebuf* fb = fs.rdbuf();
+        assert(fb->sputc(L'r') == L'r');
+    }
+    std::remove(temp.c_str());
+}
diff --git a/final/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp b/final/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp
new file mode 100644
index 0000000..243994a
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/ofstream/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ofstream
+//     : public basic_ostream<charT,traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <fstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ofstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ofstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/file.streams/fstreams/version.pass.cpp b/final/test/input.output/file.streams/fstreams/version.pass.cpp
new file mode 100644
index 0000000..44b8514
--- /dev/null
+++ b/final/test/input.output/file.streams/fstreams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <fstream>
+
+#include <fstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/file.streams/nothing_to_do.pass.cpp b/final/test/input.output/file.streams/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/file.streams/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/input.output.general/nothing_to_do.pass.cpp b/final/test/input.output/input.output.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/input.output.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/ext.manip/get_money.pass.cpp b/final/test/input.output/iostream.format/ext.manip/get_money.pass.cpp
new file mode 100644
index 0000000..cdd762a
--- /dev/null
+++ b/final/test/input.output/iostream.format/ext.manip/get_money.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  -$1,234,567.89");
+        std::istream is(&sb);
+        is.imbue(std::locale(LOCALE_en_US_UTF_8));
+        long double x = 0;
+        is >> std::get_money(x, false);
+        assert(x == -123456789);
+    }
+    {
+        testbuf<char> sb("  -USD 1,234,567.89");
+        std::istream is(&sb);
+        is.imbue(std::locale(LOCALE_en_US_UTF_8));
+        long double x = 0;
+        is >> std::get_money(x, true);
+        assert(x == -123456789);
+    }
+    {
+        testbuf<wchar_t> sb(L"  -$1,234,567.89");
+        std::wistream is(&sb);
+        is.imbue(std::locale(LOCALE_en_US_UTF_8));
+        long double x = 0;
+        is >> std::get_money(x, false);
+        assert(x == -123456789);
+    }
+    {
+        testbuf<wchar_t> sb(L"  -USD 1,234,567.89");
+        std::wistream is(&sb);
+        is.imbue(std::locale(LOCALE_en_US_UTF_8));
+        long double x = 0;
+        is >> std::get_money(x, true);
+        assert(x == -123456789);
+    }
+}
diff --git a/final/test/input.output/iostream.format/ext.manip/get_time.pass.cpp b/final/test/input.output/iostream.format/ext.manip/get_time.pass.cpp
new file mode 100644
index 0000000..6866552
--- /dev/null
+++ b/final/test/input.output/iostream.format/ext.manip/get_time.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  Sat Dec 31 23:55:59 2061");
+        std::istream is(&sb);
+        is.imbue(std::locale(LOCALE_en_US_UTF_8));
+        std::tm t = {0};
+        is >> std::get_time(&t, "%c");
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L"  Sat Dec 31 23:55:59 2061");
+        std::wistream is(&sb);
+        is.imbue(std::locale(LOCALE_en_US_UTF_8));
+        std::tm t = {0};
+        is >> std::get_time(&t, L"%c");
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/ext.manip/put_money.pass.cpp b/final/test/input.output/iostream.format/ext.manip/put_money.pass.cpp
new file mode 100644
index 0000000..8d15dd9
--- /dev/null
+++ b/final/test/input.output/iostream.format/ext.manip/put_money.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.imbue(std::locale(LOCALE_en_US_UTF_8));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, false);
+        assert(sb.str() == "-$1,234,567.89");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.imbue(std::locale(LOCALE_en_US_UTF_8));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, true);
+        assert(sb.str() == "-USD 1,234,567.89");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.imbue(std::locale(LOCALE_en_US_UTF_8));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, false);
+        assert(sb.str() == L"-$1,234,567.89");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.imbue(std::locale(LOCALE_en_US_UTF_8));
+        showbase(os);
+        long double x = -123456789;
+        os << std::put_money(x, true);
+        assert(sb.str() == L"-USD 1,234,567.89");
+    }
+}
diff --git a/final/test/input.output/iostream.format/ext.manip/put_time.pass.cpp b/final/test/input.output/iostream.format/ext.manip/put_time.pass.cpp
new file mode 100644
index 0000000..d64ca07
--- /dev/null
+++ b/final/test/input.output/iostream.format/ext.manip/put_time.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
+
+#include <iomanip>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.imbue(std::locale(LOCALE_en_US_UTF_8));
+        std::tm t = {0};
+        t.tm_sec = 59;
+        t.tm_min = 55;
+        t.tm_hour = 23;
+        t.tm_mday = 31;
+        t.tm_mon = 11;
+        t.tm_year = 161;
+        t.tm_wday = 6;
+        os << std::put_time(&t, "%c");
+        assert(sb.str() == "Sat Dec 31 23:55:59 2061");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.imbue(std::locale(LOCALE_en_US_UTF_8));
+        std::tm t = {0};
+        t.tm_sec = 59;
+        t.tm_min = 55;
+        t.tm_hour = 23;
+        t.tm_mday = 31;
+        t.tm_mon = 11;
+        t.tm_year = 161;
+        t.tm_wday = 6;
+        os << std::put_time(&t, L"%c");
+        assert(sb.str() == L"Sat Dec 31 23:55:59 2061");
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..f4d4257
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// void swap(basic_iostream& rhs);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+    : public std::basic_iostream<CharT>
+{
+    typedef std::basic_iostream<CharT> base;
+    test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+    void swap(test_iostream& s) {base::swap(s);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_iostream<char> is1(&sb1);
+        test_iostream<char> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_iostream<wchar_t> is1(&sb1);
+        test_iostream<wchar_t> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..2032e93
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// basic_iostream& operator=(basic_iostream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+    : public std::basic_iostream<CharT>
+{
+    typedef std::basic_iostream<CharT> base;
+    test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_iostream& operator=(test_iostream&& s)
+        {base::operator=(std::move(s)); return *this;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_iostream<char> is1(&sb1);
+        test_iostream<char> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_iostream<wchar_t> is1(&sb1);
+        test_iostream<wchar_t> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp
new file mode 100644
index 0000000..c0592e9
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/move.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// basic_iostream(basic_iostream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_iostream
+    : public std::basic_iostream<CharT>
+{
+    typedef std::basic_iostream<CharT> base;
+    test_iostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_iostream(test_iostream&& s)
+        : base(std::move(s)) {}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb;
+        test_iostream<char> is1(&sb);
+        test_iostream<char> is(std::move(is1));
+        assert(is1.rdbuf() == &sb);
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        test_iostream<wchar_t> is1(&sb);
+        test_iostream<wchar_t> is(std::move(is1));
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is1.rdbuf() == &sb);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..dacc8d2
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.cons/streambuf.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream;
+
+// explicit basic_iostream(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::basic_iostream<char> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::basic_iostream<wchar_t> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/iostreamclass/iostream.dest/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp b/final/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp
new file mode 100644
index 0000000..6890f1c
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/iostreamclass/types.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_iostream :
+//     public basic_istream<charT,traits>,
+//     public basic_ostream<charT,traits>
+// {
+// public:
+//     // types:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <istream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_istream<char>, std::basic_iostream<char> >::value), "");
+    static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_iostream<char> >::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_iostream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp
new file mode 100644
index 0000000..beaebfe
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/bool.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(bool& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        bool n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        bool n = true;
+        is >> n;
+        assert(n == false);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 1 ");
+        std::istream is(&sb);
+        bool n = 0;
+        is >> n;
+        assert(n == true);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 1 ");
+        std::wistream is(&sb);
+        bool n = 0;
+        is >> n;
+        assert(n == true);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp
new file mode 100644
index 0000000..1c8716e
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/double.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(double& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        double n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        double n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        double n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123.5 ");
+        std::wistream is(&sb);
+        double n = 10;
+        is >> n;
+        assert(n == -123.5);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp
new file mode 100644
index 0000000..f5ef23e
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/float.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(float& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        float n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        float n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        float n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123.5 ");
+        std::wistream is(&sb);
+        float n = 10;
+        is >> n;
+        assert(n == -123.5);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp
new file mode 100644
index 0000000..25687db
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/int.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(int& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        int n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        int n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        int n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -1234567890123456 ");
+        std::wistream is(&sb);
+        int n = 10;
+        is >> n;
+        assert(n == std::numeric_limits<int>::min());
+        assert(!is.eof());
+        assert( is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp
new file mode 100644
index 0000000..4b47654
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123 ");
+        std::wistream is(&sb);
+        long n = 10;
+        is >> n;
+        assert(n == -123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp
new file mode 100644
index 0000000..cc70fae
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_double.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(long double& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        long double n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        long double n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        long double n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123.5 ");
+        std::wistream is(&sb);
+        long double n = 10;
+        is >> n;
+        assert(n == -123.5);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp
new file mode 100644
index 0000000..c37e175
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/long_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(long long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        long long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        long long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        long long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -123 ");
+        std::wistream is(&sb);
+        long long n = 10;
+        is >> n;
+        assert(n == -123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp
new file mode 100644
index 0000000..52b3566
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/pointer.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(void*& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        void* n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        void* n = (void*)1;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 1 ");
+        std::istream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)1);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 1 ");
+        std::wistream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)1);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb("12345678");
+        std::istream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)0x12345678);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L"12345678");
+        std::wistream is(&sb);
+        void* n = 0;
+        is >> n;
+        assert(n == (void*)0x12345678);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp
new file mode 100644
index 0000000..62e44f5
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/short.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(short& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        short n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        short n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        short n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" -1234567890 ");
+        std::wistream is(&sb);
+        short n = 10;
+        is >> n;
+        assert(n == std::numeric_limits<short>::min());
+        assert(!is.eof());
+        assert( is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp
new file mode 100644
index 0000000..6f10916
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_int.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned int& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned int n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned int n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned int n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned int n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp
new file mode 100644
index 0000000..eb8a723
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..1db250e
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_long_long.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned long long& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned long long n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned long long n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned long long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned long long n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp
new file mode 100644
index 0000000..78fdc66
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.arithmetic/unsigned_short.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// operator>>(unsigned short& val);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        unsigned short n = 0;
+        is >> n;
+        assert(is.fail());
+    }
+    {
+        testbuf<char> sb("0");
+        std::istream is(&sb);
+        unsigned short n = 10;
+        is >> n;
+        assert(n == 0);
+        assert( is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<char> sb(" 123 ");
+        std::istream is(&sb);
+        unsigned short n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123 ");
+        std::wistream is(&sb);
+        unsigned short n = 10;
+        is >> n;
+        assert(n == 123);
+        assert(!is.eof());
+        assert(!is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream.formatted.reqmts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp
new file mode 100644
index 0000000..0d4516d
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/basic_ios.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(basic_ios<charT,traits>&
+//                                         (*pf)(basic_ios<charT,traits>&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+template <class CharT>
+std::basic_ios<CharT>&
+f(std::basic_ios<CharT>& is)
+{
+    ++f_called;
+    return is;
+}
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        is >> f;
+        assert(f_called == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp
new file mode 100644
index 0000000..b506822
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/chart.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class charT, class traits>
+//   basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        char c = 'z';
+        is >> c;
+        assert( is.eof());
+        assert( is.fail());
+        assert(c == 'z');
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        char c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+    }
+    {
+        testbuf<wchar_t> sb(L"   abc");
+        std::wistream is(&sb);
+        wchar_t c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'b');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'c');
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp
new file mode 100644
index 0000000..d4cb2bb
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/ios_base.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(ios_base& (*pf)(ios_base&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+std::ios_base&
+f(std::ios_base& is)
+{
+    ++f_called;
+    return is;
+}
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        is >> f;
+        assert(f_called == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp
new file mode 100644
index 0000000..4c3aef4
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/istream.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&
+//                                         (*pf)(basic_istream<charT,traits>&));
+
+#include <istream>
+#include <cassert>
+
+int f_called = 0;
+
+template <class CharT>
+std::basic_istream<CharT>&
+f(std::basic_istream<CharT>& is)
+{
+    ++f_called;
+    return is;
+}
+
+int main()
+{
+    {
+        std::istream is((std::streambuf*)0);
+        is >> f;
+        assert(f_called == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp
new file mode 100644
index 0000000..a02fe2c
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        signed char c = 'z';
+        is >> c;
+        assert( is.eof());
+        assert( is.fail());
+        assert(c == 'z');
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        signed char c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp
new file mode 100644
index 0000000..70f1c20
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/signed_char_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, signed char* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        signed char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        is.width(4);
+        signed char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abc");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        signed char s[20];
+        is >> s;
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        signed char s[20];
+        is.width(1);
+        is >> s;
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string((char*)s) == "");
+        assert(is.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
new file mode 100644
index 0000000..29ed68e
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_istream;
+
+// basic_istream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("testing...");
+        std::istream is(&sb);
+        testbuf<char> sb2;
+        is >> &sb2;
+        assert(sb2.str() == "testing...");
+        assert(is.gcount() == 10);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp
new file mode 100644
index 0000000..8f19cea
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        unsigned char c = 'z';
+        is >> c;
+        assert( is.eof());
+        assert( is.fail());
+        assert(c == 'z');
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        unsigned char c;
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        is >> c;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp
new file mode 100644
index 0000000..07fa5a7
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/unsigned_char_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class traits>
+//   basic_istream<char,traits>& operator>>(basic_istream<char,traits>&& in, unsigned char* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        unsigned char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+    }
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        is.width(4);
+        unsigned char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abc");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        unsigned char s[20];
+        is >> s;
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string((char*)s) == "abcdefghijk");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        unsigned char s[20];
+        is.width(1);
+        is >> s;
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string((char*)s) == "");
+        assert(is.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp
new file mode 100644
index 0000000..a00c7a1
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/wchar_t_pointer.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template<class charT, class traits>
+//   basic_istream<charT,traits>& operator>>(basic_istream<charT,traits>&& in, charT* s);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   abcdefghijk    ");
+        std::istream is(&sb);
+        char s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "abcdefghijk");
+    }
+    {
+        testbuf<wchar_t> sb(L"   abcdefghijk    ");
+        std::wistream is(&sb);
+        is.width(4);
+        wchar_t s[20];
+        is >> s;
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"abc");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L"   abcdefghijk");
+        std::wistream is(&sb);
+        wchar_t s[20];
+        is >> s;
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"abcdefghijk");
+        assert(is.width() == 0);
+    }
+    {
+        testbuf<char> sb("   abcdefghijk");
+        std::istream is(&sb);
+        char s[20];
+        is.width(1);
+        is >> s;
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string(s) == "");
+        assert(is.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.formatted/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp
new file mode 100644
index 0000000..3c8159a
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.manip/ws.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits>
+//   basic_istream<charT,traits>&
+//   ws(basic_istream<charT,traits>& is);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("   123");
+        std::istream is(&sb);
+        ws(is);
+        assert(is.good());
+        assert(is.peek() == '1');
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        std::wistream is(&sb);
+        ws(is);
+        assert(is.good());
+        assert(is.peek() == L'1');
+    }
+    {
+        testbuf<char> sb("  ");
+        std::istream is(&sb);
+        ws(is);
+        assert(!is.fail());
+        assert(is.eof());
+        ws(is);
+        assert(is.eof());
+        assert(is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L"  ");
+        std::wistream is(&sb);
+        ws(is);
+        assert(!is.fail());
+        assert(is.eof());
+        ws(is);
+        assert(is.eof());
+        assert(is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
new file mode 100644
index 0000000..5b7664e
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.rvalue/rvalue.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits, class T>
+//   basic_istream<charT, traits>&
+//   operator>>(basic_istream<charT, traits>&& is, T& x);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb("   123");
+        int i = 0;
+        std::istream(&sb) >> i;
+        assert(i == 123);
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        int i = 0;
+        std::wistream(&sb) >> i;
+        assert(i == 123);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
new file mode 100644
index 0000000..41a721d
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int_type get();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        char c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<char> sb(" abc");
+        std::istream is(&sb);
+        char c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L" abc");
+        std::wistream is(&sb);
+        wchar_t c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L' ');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'a');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'b');
+        assert(is.gcount() == 1);
+        c = is.get();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'c');
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp
new file mode 100644
index 0000000..cf06e34
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_chart.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type& c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("          ");
+        std::istream is(&sb);
+        char c;
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<char> sb(" abc");
+        std::istream is(&sb);
+        char c;
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == ' ');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'a');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'b');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == 'c');
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L" abc");
+        std::wistream is(&sb);
+        wchar_t c;
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L' ');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'a');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'b');
+        assert(is.gcount() == 1);
+        is.get(c);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(c == L'c');
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
new file mode 100644
index 0000000..1691a2d
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  \n    \n ");
+        std::istream is(&sb);
+        char s[5];
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5);
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string(s) == "");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == '\n');
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == '\n');
+        is.get(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  \n    \n ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5);
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::wstring(s) == L"");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == L'\n');
+        is.get(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == L'\n');
+        is.get(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
new file mode 100644
index 0000000..c9389ec
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_pointer_size_chart.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(char_type* s, streamsize n, char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  *    * ");
+        std::istream is(&sb);
+        char s[5];
+        is.get(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5, '*');
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::string(s) == "");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == '*');
+        is.get(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == '*');
+        is.get(s, 5, '*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  *    * ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.get(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 2);
+        is.get(s, 5, L'*');
+        assert(!is.eof());
+        assert( is.fail());
+        assert(std::wstring(s) == L"");
+        assert(is.gcount() == 0);
+        is.clear();
+        assert(is.get() == L'*');
+        is.get(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 4);
+        assert(is.get() == L'*');
+        is.get(s, 5, L'*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp
new file mode 100644
index 0000000..7a55f84
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("testing\n...");
+        std::istream is(&sb);
+        testbuf<char> sb2;
+        is.get(sb2);
+        assert(sb2.str() == "testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == '\n');
+        is.get(sb2);
+        assert(sb2.str() == "testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+    {
+        testbuf<wchar_t> sb(L"testing\n...");
+        std::wistream is(&sb);
+        testbuf<wchar_t> sb2;
+        is.get(sb2);
+        assert(sb2.str() == L"testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == L'\n');
+        is.get(sb2);
+        assert(sb2.str() == L"testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp
new file mode 100644
index 0000000..cbc0075
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& get(basic_streambuf<char_type,traits>& sb,
+//                                  char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("testing*...");
+        std::istream is(&sb);
+        testbuf<char> sb2;
+        is.get(sb2, '*');
+        assert(sb2.str() == "testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == '*');
+        is.get(sb2, '*');
+        assert(sb2.str() == "testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+    {
+        testbuf<wchar_t> sb(L"testing*...");
+        std::wistream is(&sb);
+        testbuf<wchar_t> sb2;
+        is.get(sb2, L'*');
+        assert(sb2.str() == L"testing");
+        assert(is.good());
+        assert(is.gcount() == 7);
+        assert(is.get() == L'*');
+        is.get(sb2, L'*');
+        assert(sb2.str() == L"testing...");
+        assert(is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 3);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
new file mode 100644
index 0000000..465824a
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& getline(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  \n    \n ");
+        std::istream is(&sb);
+        char s[5];
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  \n    \n ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
new file mode 100644
index 0000000..7362959
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& getline(char_type* s, streamsize n, char_type delim);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("  *    * ");
+        std::istream is(&sb);
+        char s[5];
+        is.getline(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5, '*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == "    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5, '*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::string(s) == " ");
+        assert(is.gcount() == 1);
+    }
+    {
+        testbuf<wchar_t> sb(L"  *    * ");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.getline(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"  ");
+        assert(is.gcount() == 3);
+        is.getline(s, 5, L'*');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L"    ");
+        assert(is.gcount() == 5);
+        is.getline(s, 5, L'*');
+        assert( is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s) == L" ");
+        assert(is.gcount() == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp
new file mode 100644
index 0000000..9510961
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/ignore.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>&
+//    ignore(streamsize n = 1, int_type delim = traits::eof());
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 1\n2345\n6");
+        std::istream is(&sb);
+        is.ignore();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        is.ignore(5, '\n');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 2);
+        is.ignore(15);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 6);
+    }
+    {
+        testbuf<wchar_t> sb(L" 1\n2345\n6");
+        std::wistream is(&sb);
+        is.ignore();
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        is.ignore(5, '\n');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 2);
+        is.ignore(15);
+        assert( is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 6);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
new file mode 100644
index 0000000..ccc3545
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>&
+//    ignore(streamsize n = 1, int_type delim = traits::eof());
+
+// http://llvm.org/bugs/show_bug.cgi?id=16427
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    int bad=-1;
+    std::ostringstream os;
+    os << "aaaabbbb" << static_cast<char>(bad) 
+       << "ccccdddd" << std::endl;
+    std::string s=os.str();
+    
+    std::istringstream is(s);
+    const unsigned int ignoreLen=10;
+    size_t a=is.tellg();
+    is.ignore(ignoreLen);
+    size_t b=is.tellg();
+    assert((b-a)==ignoreLen);
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp
new file mode 100644
index 0000000..4264849
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/peek.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int_type peek();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 1\n2345\n6");
+        std::istream is(&sb);
+        assert(is.peek() == ' ');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+        is.get();
+        assert(is.peek() == '1');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 1\n2345\n6");
+        std::wistream is(&sb);
+        assert(is.peek() == L' ');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+        is.get();
+        assert(is.peek() == L'1');
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp
new file mode 100644
index 0000000..3564d71
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/putback.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& putback(char_type c);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.putback('a');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+        is.clear();
+        is.putback('2');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback('1');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(' ');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(' ');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.putback(L'a');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+        is.clear();
+        is.putback(L'2');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(L'1');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(L' ');
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.putback(L' ');
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp
new file mode 100644
index 0000000..20e70cf
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/read.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& read(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        char s[5];
+        is.read(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == " 1234");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == "56789");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert( is.eof());
+        assert( is.fail());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        is.read(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L" 1234");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L"56789");
+        assert(is.gcount() == 5);
+        is.read(s, 5);
+        assert( is.eof());
+        assert( is.fail());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp
new file mode 100644
index 0000000..01eecb5
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/readsome.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// streamsize readsome(char_type* s, streamsize n);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 1234567890");
+        std::istream is(&sb);
+        char s[5];
+        assert(is.readsome(s, 5) == 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == " 1234");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::string(s, 5) == "56789");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        assert(std::string(s, 1) == "0");
+        assert(is.readsome(s, 5) == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 1234567890");
+        std::wistream is(&sb);
+        wchar_t s[5];
+        assert(is.readsome(s, 5) == 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L" 1234");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(std::wstring(s, 5) == L"56789");
+        assert(is.gcount() == 5);
+        is.readsome(s, 5);
+        assert(!is.eof());
+        assert(!is.fail());
+        assert(is.gcount() == 1);
+        assert(std::wstring(s, 1) == L"0");
+        assert(is.readsome(s, 5) == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp
new file mode 100644
index 0000000..e6f4e1e
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& seekg(pos_type pos);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+    typename base::pos_type seekpos(typename base::pos_type sp,
+                                    std::ios_base::openmode which)
+    {
+        assert(which == std::ios_base::in);
+        return sp;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.seekg(5);
+        assert(is.good());
+        is.seekg(-1);
+        assert(is.fail());
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.seekg(5);
+        assert(is.good());
+        is.seekg(-1);
+        assert(is.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
new file mode 100644
index 0000000..73f3da1
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& seekg(off_type off, ios_base::seekdir dir);
+
+#include <istream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+    typename base::pos_type seekoff(typename base::off_type off,
+                                    std::ios_base::seekdir way,
+                                    std::ios_base::openmode which)
+    {
+        assert(which == std::ios_base::in);
+        ++seekoff_called;
+        return off;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.seekg(5, std::ios_base::cur);
+        assert(is.good());
+        assert(seekoff_called == 1);
+        is.seekg(-1, std::ios_base::beg);
+        assert(is.fail());
+        assert(seekoff_called == 2);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.seekg(5, std::ios_base::cur);
+        assert(is.good());
+        assert(seekoff_called == 3);
+        is.seekg(-1, std::ios_base::beg);
+        assert(is.fail());
+        assert(seekoff_called == 4);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
new file mode 100644
index 0000000..59f381c
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/sync.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// int sync();
+
+#include <istream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+
+protected:
+    int sync()
+    {
+        ++sync_called;
+        return 5;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        assert(is.sync() == 0);
+        assert(sync_called = 1);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        assert(is.sync() == 0);
+        assert(sync_called = 2);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp
new file mode 100644
index 0000000..799b46b
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/tellg.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// pos_type tellg();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+    typename base::pos_type seekoff(typename base::off_type off,
+                                    std::ios_base::seekdir way,
+                                    std::ios_base::openmode which)
+    {
+        assert(off == 0);
+        assert(way == std::ios_base::cur);
+        assert(which == std::ios_base::in);
+        return 5;
+    }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        assert(is.tellg() == 5);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        assert(is.tellg() == 5);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp
new file mode 100644
index 0000000..adf0a61
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream.unformatted/unget.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// basic_istream<charT,traits>& unget();
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb(" 123456789");
+        std::istream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb(L" 123456789");
+        std::wistream is(&sb);
+        is.get();
+        is.get();
+        is.get();
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.good());
+        assert(is.gcount() == 0);
+        is.unget();
+        assert(is.bad());
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..a0734b8
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream/istream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// void swap(basic_istream& rhs);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+    : public std::basic_istream<CharT>
+{
+    typedef std::basic_istream<CharT> base;
+    test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+    void swap(test_istream& s) {base::swap(s);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_istream<char> is1(&sb1);
+        test_istream<char> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_istream<wchar_t> is1(&sb1);
+        test_istream<wchar_t> is2(&sb2);
+        is1.swap(is2);
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..2876d76
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream/istream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream& operator=(basic_istream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+    : public std::basic_istream<CharT>
+{
+    typedef std::basic_istream<CharT> base;
+    test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_istream& operator=(test_istream&& s)
+        {base::operator=(std::move(s)); return *this;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_istream<char> is1(&sb1);
+        test_istream<char> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_istream<wchar_t> is1(&sb1);
+        test_istream<wchar_t> is2(&sb2);
+        is2 = (std::move(is1));
+        assert(is1.rdbuf() == &sb1);
+        assert(is1.tie() == 0);
+        assert(is1.fill() == ' ');
+        assert(is1.rdstate() == is1.goodbit);
+        assert(is1.exceptions() == is1.goodbit);
+        assert(is1.flags() == (is1.skipws | is1.dec));
+        assert(is1.precision() == 6);
+        assert(is1.getloc().name() == "C");
+        assert(is2.rdbuf() == &sb2);
+        assert(is2.tie() == 0);
+        assert(is2.fill() == ' ');
+        assert(is2.rdstate() == is2.goodbit);
+        assert(is2.exceptions() == is2.goodbit);
+        assert(is2.flags() == (is2.skipws | is2.dec));
+        assert(is2.precision() == 6);
+        assert(is2.getloc().name() == "C");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp
new file mode 100644
index 0000000..04cb9d3
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream/istream.cons/move.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// basic_istream(basic_istream&& rhs);
+
+#include <istream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_istream
+    : public std::basic_istream<CharT>
+{
+    typedef std::basic_istream<CharT> base;
+    test_istream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_istream(test_istream&& s)
+        : base(std::move(s)) {}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb;
+        test_istream<char> is1(&sb);
+        test_istream<char> is(std::move(is1));
+        assert(is1.rdbuf() == &sb);
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        test_istream<wchar_t> is1(&sb);
+        test_istream<wchar_t> is(std::move(is1));
+        assert(is1.gcount() == 0);
+        assert(is.gcount() == 0);
+        assert(is1.rdbuf() == &sb);
+        assert(is.rdbuf() == 0);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..74ed57d
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream/istream.cons/streambuf.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream;
+
+// explicit basic_istream(basic_streambuf<charT,traits>* sb);
+
+#include <istream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::basic_istream<char> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == ' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::basic_istream<wchar_t> is(&sb);
+        assert(is.rdbuf() == &sb);
+        assert(is.tie() == 0);
+        assert(is.fill() == L' ');
+        assert(is.rdstate() == is.goodbit);
+        assert(is.exceptions() == is.goodbit);
+        assert(is.flags() == (is.skipws | is.dec));
+        assert(is.precision() == 6);
+        assert(is.getloc().name() == "C");
+        assert(is.gcount() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp
new file mode 100644
index 0000000..910b369
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream/istream_sentry/ctor.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream::sentry;
+
+// explicit sentry(basic_istream<charT,traits>& is, bool noskipws = false);
+
+#include <istream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_string<CharT> string_type;
+    typedef std::basic_streambuf<CharT> base;
+private:
+    string_type str_;
+public:
+
+    testbuf() {}
+    testbuf(const string_type& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()) + str_.size());
+    }
+
+    CharT* eback() const {return base::eback();}
+    CharT* gptr() const {return base::gptr();}
+    CharT* egptr() const {return base::egptr();}
+protected:
+
+    int virtual sync()
+    {
+        ++sync_called;
+        return 1;
+    }
+};
+
+int main()
+{
+    {
+        std::istream is((testbuf<char>*)0);
+        std::istream::sentry sen(is, true);
+        assert(!(bool)sen);
+        assert(!is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+    }
+    {
+        std::wistream is((testbuf<wchar_t>*)0);
+        std::wistream::sentry sen(is, true);
+        assert(!(bool)sen);
+        assert(!is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+    }
+    {
+        testbuf<char> sb("   123");
+        std::istream is(&sb);
+        std::istream::sentry sen(is, true);
+        assert((bool)sen);
+        assert(is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback());
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        std::wistream is(&sb);
+        std::wistream::sentry sen(is, true);
+        assert((bool)sen);
+        assert(is.good());
+        assert(is.gcount() == 0);
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback());
+    }
+    {
+        testbuf<char> sb("   123");
+        std::istream is(&sb);
+        std::istream::sentry sen(is);
+        assert((bool)sen);
+        assert(is.good());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback() + 3);
+    }
+    {
+        testbuf<wchar_t> sb(L"   123");
+        std::wistream is(&sb);
+        std::wistream::sentry sen(is);
+        assert((bool)sen);
+        assert(is.good());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback() + 3);
+    }
+    {
+        testbuf<char> sb("      ");
+        std::istream is(&sb);
+        std::istream::sentry sen(is);
+        assert(!(bool)sen);
+        assert(is.fail());
+        assert(is.eof());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback() + 6);
+    }
+    {
+        testbuf<char> sb("      ");
+        std::istream is(&sb);
+        std::istream::sentry sen(is, true);
+        assert((bool)sen);
+        assert(is.good());
+        assert(sync_called == 0);
+        assert(sb.gptr() == sb.eback());
+    }
+}
diff --git a/final/test/input.output/iostream.format/input.streams/istream/types.pass.cpp b/final/test/input.output/iostream.format/input.streams/istream/types.pass.cpp
new file mode 100644
index 0000000..36cc202
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/istream/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_istream
+//     : virtual public basic_ios<charT,traits>
+// {
+// public:
+//     // types (inherited from basic_ios (27.5.4)):
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <istream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ios<char>, std::basic_istream<char> >::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_istream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/iostream.format/input.streams/version.pass.cpp b/final/test/input.output/iostream.format/input.streams/version.pass.cpp
new file mode 100644
index 0000000..b03ef2a
--- /dev/null
+++ b/final/test/input.output/iostream.format/input.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <istream>
+
+#include <istream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/nothing_to_do.pass.cpp b/final/test/input.output/iostream.format/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostream.format/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..8214d6c
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.assign/member_swap.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// void swap(basic_ostream& rhs);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+    : public std::basic_ostream<CharT>
+{
+    typedef std::basic_ostream<CharT> base;
+    test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+    void swap(test_ostream& s) {base::swap(s);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_ostream<char> os1(&sb1);
+        test_ostream<char> os2(&sb2);
+        os1.swap(os2);
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_ostream<wchar_t> os1(&sb1);
+        test_ostream<wchar_t> os2(&sb2);
+        os1.swap(os2);
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..40fe079
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.assign/move_assign.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream& operator=(basic_ostream&& rhs);
+
+#include <ostream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+    : public std::basic_ostream<CharT>
+{
+    typedef std::basic_ostream<CharT> base;
+    test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_ostream& operator=(test_ostream&& s)
+        {base::operator=(std::move(s)); return *this;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb1;
+        testbuf<char> sb2;
+        test_ostream<char> os1(&sb1);
+        test_ostream<char> os2(&sb2);
+        os2 = (std::move(os1));
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb1;
+        testbuf<wchar_t> sb2;
+        test_ostream<wchar_t> os1(&sb1);
+        test_ostream<wchar_t> os2(&sb2);
+        os2 = (std::move(os1));
+        assert(os1.rdbuf() == &sb1);
+        assert(os1.tie() == 0);
+        assert(os1.fill() == ' ');
+        assert(os1.rdstate() == os1.goodbit);
+        assert(os1.exceptions() == os1.goodbit);
+        assert(os1.flags() == (os1.skipws | os1.dec));
+        assert(os1.precision() == 6);
+        assert(os1.getloc().name() == "C");
+        assert(os2.rdbuf() == &sb2);
+        assert(os2.tie() == 0);
+        assert(os2.fill() == ' ');
+        assert(os2.rdstate() == os2.goodbit);
+        assert(os2.exceptions() == os2.goodbit);
+        assert(os2.flags() == (os2.skipws | os2.dec));
+        assert(os2.precision() == 6);
+        assert(os2.getloc().name() == "C");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp
new file mode 100644
index 0000000..b3045b3
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.cons/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// basic_ostream(basic_ostream&& rhs);
+
+#include <ostream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+template <class CharT>
+struct test_ostream
+    : public std::basic_ostream<CharT>
+{
+    typedef std::basic_ostream<CharT> base;
+    test_ostream(testbuf<CharT>* sb) : base(sb) {}
+
+    test_ostream(test_ostream&& s)
+        : base(std::move(s)) {}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb;
+        test_ostream<char> os1(&sb);
+        test_ostream<char> os(std::move(os1));
+        assert(os1.rdbuf() == &sb);
+        assert(os.rdbuf() == 0);
+        assert(os.tie() == 0);
+        assert(os.fill() == ' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        test_ostream<wchar_t> os1(&sb);
+        test_ostream<wchar_t> os(std::move(os1));
+        assert(os1.rdbuf() == &sb);
+        assert(os.rdbuf() == 0);
+        assert(os.tie() == 0);
+        assert(os.fill() == L' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..7929e18
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.cons/streambuf.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream;
+
+// explicit basic_ostream(basic_streambuf<charT,traits>* sb);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::basic_ostream<char> os(&sb);
+        assert(os.rdbuf() == &sb);
+        assert(os.tie() == 0);
+        assert(os.fill() == ' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::basic_ostream<wchar_t> os(&sb);
+        assert(os.rdbuf() == &sb);
+        assert(os.tie() == 0);
+        assert(os.fill() == L' ');
+        assert(os.rdstate() == os.goodbit);
+        assert(os.exceptions() == os.goodbit);
+        assert(os.flags() == (os.skipws | os.dec));
+        assert(os.precision() == 6);
+        assert(os.getloc().name() == "C");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.reqmts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp
new file mode 100644
index 0000000..13035b7
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(bool val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        bool b = false;
+        os << b;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        bool b = false;
+        os << b;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        bool b = true;
+        os << b;
+        assert(sb.str() == "1");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        boolalpha(os);
+        bool b = true;
+        os << b;
+        assert(sb.str() == "true");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        boolalpha(os);
+        bool b = false;
+        os << b;
+        assert(sb.str() == "false");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp
new file mode 100644
index 0000000..38ee37f
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(double val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        double n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        double n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        double n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        double n = -10.5;
+        os << n;
+        assert(sb.str() == "-10.5");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp
new file mode 100644
index 0000000..1da0ac6
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(float val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        float n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        float n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        float n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        float n = -10.5;
+        os << n;
+        assert(sb.str() == "-10.5");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp
new file mode 100644
index 0000000..efcb08a
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(int val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        int n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        int n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        int n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        int n = -10;
+        os << n;
+        assert(sb.str() == "fffffff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp
new file mode 100644
index 0000000..6d617a4
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        long n = 0xfffffff6;
+        os << n;
+        assert(sb.str() == "fffffff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp
new file mode 100644
index 0000000..20b20b2
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(long double val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        long double n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long double n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long double n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        long double n = -10.5;
+        os << n;
+        assert(sb.str() == "-10.5");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp
new file mode 100644
index 0000000..dc77eb7
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(long long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        long long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        long long n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        long long n = -10;
+        os << n;
+        assert(sb.str() == "fffffffffffffff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
new file mode 100644
index 0000000..114bba9
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(const void* val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const void* n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const void* n = 0;
+        os << n;
+        assert(os.good());
+        // %p is implementation defined.
+        // On some platforms (Windows), it's a hex number without
+        // any leading 0x like prefix.
+        // In that format, we assume a null pointer will yield 2 '0' hex digits
+        // for each 8 bits of address space.
+        assert(sb.str() == "0x0" || sb.str() == "(nil)" ||
+                                  sb.str() == std::string(sizeof(void*)*2,'0'));
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const void* n = &sb;
+        os << n;
+        assert(os.good());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp
new file mode 100644
index 0000000..ebd349b
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(short val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        short n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        short n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        short n = -10;
+        os << n;
+        assert(sb.str() == "-10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        short n = -10;
+        os << n;
+        assert(sb.str() == "fff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp
new file mode 100644
index 0000000..ac60fa9
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned int val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned int n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned int n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned int n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned int n = 0xFFF6;
+        os << n;
+        assert(sb.str() == "fff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp
new file mode 100644
index 0000000..b5a3801
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned long n = 0xfffffff6;
+        os << n;
+        assert(sb.str() == "fffffff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..25dc4d8
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned long long val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned long long n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long long n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned long long n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned long long n = -10;
+        os << n;
+        assert(sb.str() == "fffffffffffffff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp
new file mode 100644
index 0000000..7c28a8e
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// operator<<(unsigned short val);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned short n = 0;
+        os << n;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned short n = 0;
+        os << n;
+        assert(sb.str() == "0");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned short n = 10;
+        os << n;
+        assert(sb.str() == "10");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        hex(os);
+        unsigned short n = 0xFFF6;
+        os << n;
+        assert(sb.str() == "fff6");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp
new file mode 100644
index 0000000..f74e2a4
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits>
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, charT c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        wchar_t c = L'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        wchar_t c = L'a';
+        os << c;
+        assert(sb.str() == L"a");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        wchar_t c = L'a';
+        os << c;
+        assert(sb.str() == L"    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        wchar_t c = L'a';
+        os << c;
+        assert(sb.str() == L"a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp
new file mode 100644
index 0000000..2b78fa7
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits>
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const charT* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(sb.str() == L"123");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(sb.str() == L"  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        const wchar_t* c = L"123";
+        os << c;
+        assert(sb.str() == L"123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp
new file mode 100644
index 0000000..253b524
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class char, class traits>
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == "a");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == "    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == "a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp
new file mode 100644
index 0000000..c544554
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class traits>
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const char* c = "123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == "  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == "123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp
new file mode 100644
index 0000000..6449a13
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits>
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == L"a");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == L"    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        char c = 'a';
+        os << c;
+        assert(sb.str() == L"a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp
new file mode 100644
index 0000000..e679a5c
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class charT, class traits>
+//   basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out, const char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        const char* c = "123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == L"123");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == L"  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os.width(5);
+        left(os);
+        const char* c = "123";
+        os << c;
+        assert(sb.str() == L"123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp
new file mode 100644
index 0000000..dc0ee42
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class char, class traits>
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, signed char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        signed char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        signed char c = 'a';
+        os << c;
+        assert(sb.str() == "a");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        signed char c = 'a';
+        os << c;
+        assert(sb.str() == "    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        signed char c = 'a';
+        os << c;
+        assert(sb.str() == "a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp
new file mode 100644
index 0000000..e465b94
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class traits>
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const signed char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(sb.str() == "  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        const signed char* c = (const signed char*)"123";
+        os << c;
+        assert(sb.str() == "123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp
new file mode 100644
index 0000000..d818c5f
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class char, class traits>
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, unsigned char c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        unsigned char c = 'a';
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        unsigned char c = 'a';
+        os << c;
+        assert(sb.str() == "a");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        unsigned char c = 'a';
+        os << c;
+        assert(sb.str() == "    a");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        unsigned char c = 'a';
+        os << c;
+        assert(sb.str() == "a    ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp
new file mode 100644
index 0000000..3257f4a
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template<class traits>
+//   basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out, const unsigned char* s);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(os.bad());
+        assert(os.fail());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(sb.str() == "  123");
+        assert(os.width() == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.width(5);
+        left(os);
+        const unsigned char* c = (const unsigned char*)"123";
+        os << c;
+        assert(sb.str() == "123  ");
+        assert(os.width() == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp
new file mode 100644
index 0000000..e26466e
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(basic_ios<charT,traits>&
+//                                         (*pf)(basic_ios<charT,traits>&));
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+template <class CharT>
+std::basic_ios<CharT>&
+f(std::basic_ios<CharT>& os)
+{
+    std::uppercase(os);
+    return os;
+}
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(!(os.flags() & std::ios_base::uppercase));
+        os << f;
+        assert( (os.flags() & std::ios_base::uppercase));
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp
new file mode 100644
index 0000000..238a621
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(ios_base& (*pf)(ios_base&));
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(!(os.flags() & std::ios_base::uppercase));
+        os << std::uppercase;
+        assert( (os.flags() & std::ios_base::uppercase));
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp
new file mode 100644
index 0000000..3ed400a
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<
+//           (basic_ostream<charT,traits>& (*pf)(basic_ostream<charT,traits>&))
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+template <class CharT>
+std::basic_ostream<CharT>&
+f(std::basic_ostream<CharT>& os)
+{
+    os << "testing...";
+    return os;
+}
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << f;
+        assert(sb.str() == "testing...");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
new file mode 100644
index 0000000..1cb9413
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& operator<<(basic_streambuf<charT,traits>* sb);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+    testbuf(const std::basic_string<CharT>& str)
+        : str_(str)
+    {
+        base::setg(const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data()),
+                   const_cast<CharT*>(str_.data() + str_.size()));
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        testbuf<char> sb2("testing...");
+        assert(sb.str() == "");
+        os << &sb2;
+        assert(sb.str() == "testing...");
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp
new file mode 100644
index 0000000..d503544
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits>
+//   basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+
+    virtual int
+        sync()
+        {
+            ++sync_called;
+            return 0;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        endl(os);
+        assert(sb.str() == "\n");
+        assert(sync_called == 1);
+        assert(os.good());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        endl(os);
+        assert(sb.str() == L"\n");
+        assert(sync_called == 2);
+        assert(os.good());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp
new file mode 100644
index 0000000..975b660
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits>
+//   basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        ends(os);
+        assert(sb.str().size() == 1);
+        assert(sb.str().back() == 0);
+        assert(os.good());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        ends(os);
+        assert(sb.str().size() == 1);
+        assert(sb.str().back() == 0);
+        assert(os.good());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp
new file mode 100644
index 0000000..088826c
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.manip/flush.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits>
+//   basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+public:
+    testbuf()
+    {
+    }
+
+protected:
+
+    virtual int
+        sync()
+        {
+            ++sync_called;
+            return 0;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        flush(os);
+        assert(sync_called == 1);
+        assert(os.good());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        flush(os);
+        assert(sync_called == 2);
+        assert(os.good());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp
new file mode 100644
index 0000000..ec0e8e1
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// template <class charT, class traits, class T>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>&& os, const T& x);
+
+#include <ostream>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        testbuf<char> sb;
+        std::ostream(&sb) << "testing...";
+        assert(sb.str() == "testing...");
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream(&sb) << L"123";
+        assert(sb.str() == L"123");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp
new file mode 100644
index 0000000..e09627b
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& seekp(pos_type pos);
+
+#include <ostream>
+#include <cassert>
+
+int seekpos_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    testbuf() {}
+
+protected:
+
+    typename base::pos_type
+    seekpos(typename base::pos_type sp, std::ios_base::openmode which)
+    {
+        ++seekpos_called;
+        assert(which == std::ios_base::out);
+        return sp;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        assert(&os.seekp(5) == &os);
+        assert(seekpos_called == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(&os.seekp(10) == &os);
+        assert(seekpos_called == 1);
+        assert(os.good());
+        assert(&os.seekp(-1) == &os);
+        assert(seekpos_called == 2);
+        assert(os.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
new file mode 100644
index 0000000..69b26f3
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);
+
+#include <ostream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    testbuf() {}
+
+protected:
+
+    typename base::pos_type
+    seekoff(typename base::off_type off, std::ios_base::seekdir way,
+                                         std::ios_base::openmode which)
+    {
+        ++seekoff_called;
+        assert(way == std::ios_base::beg);
+        assert(which == std::ios_base::out);
+        return off;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        assert(&os.seekp(5, std::ios_base::beg) == &os);
+        assert(seekoff_called == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(&os.seekp(10, std::ios_base::beg) == &os);
+        assert(seekoff_called == 1);
+        assert(os.good());
+        assert(&os.seekp(-1, std::ios_base::beg) == &os);
+        assert(seekoff_called == 2);
+        assert(os.fail());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp
new file mode 100644
index 0000000..10a229d
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.seeks/tellp.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// pos_type tellp();
+
+#include <ostream>
+#include <cassert>
+
+int seekoff_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    testbuf() {}
+
+protected:
+
+    typename base::pos_type
+    seekoff(typename base::off_type off, std::ios_base::seekdir way, std::ios_base::openmode which)
+    {
+        assert(off == 0);
+        assert(way == std::ios_base::cur);
+        assert(which == std::ios_base::out);
+        ++seekoff_called;
+        return 10;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        assert(os.tellp() == -1);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(os.tellp() == 10);
+        assert(seekoff_called == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp
new file mode 100644
index 0000000..97791f4
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.unformatted/flush.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream& flush();
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+public:
+    testbuf()
+    {
+    }
+
+protected:
+
+    virtual int
+        sync()
+        {
+            if (sync_called++ == 1)
+                return -1;
+            return 0;
+        }
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os.flush();
+        assert(os.good());
+        assert(sync_called == 1);
+        os.flush();
+        assert(os.bad());
+        assert(sync_called == 2);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp
new file mode 100644
index 0000000..396bb09
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream<charT,traits>& put(char_type c);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        wchar_t c = L'a';
+        os.put(c);
+        assert(os.bad());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        wchar_t c = L'a';
+        os.put(c);
+        assert(sb.str() == L"a");
+        assert(os.good());
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        char c = 'a';
+        os.put(c);
+        assert(sb.str() == "a");
+        assert(os.good());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp
new file mode 100644
index 0000000..8dd4e4c
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+//   class basic_ostream;
+
+// basic_ostream& write(const char_type* s, streamsize n);
+
+#include <ostream>
+#include <cassert>
+
+template <class CharT>
+class testbuf
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    std::basic_string<CharT> str_;
+public:
+    testbuf()
+    {
+    }
+
+    std::basic_string<CharT> str() const
+        {return std::basic_string<CharT>(base::pbase(), base::pptr());}
+
+protected:
+
+    virtual typename base::int_type
+        overflow(typename base::int_type __c = base::traits_type::eof())
+        {
+            if (__c != base::traits_type::eof())
+            {
+                int n = str_.size();
+                str_.push_back(__c);
+                str_.resize(str_.capacity());
+                base::setp(const_cast<CharT*>(str_.data()),
+                           const_cast<CharT*>(str_.data() + str_.size()));
+                base::pbump(n+1);
+            }
+            return __c;
+        }
+};
+
+int main()
+{
+    {
+        std::wostream os((std::wstreambuf*)0);
+        const wchar_t s[] = L"123456790";
+        os.write(s, sizeof(s)/sizeof(s[0])-1);
+        assert(os.bad());
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        const wchar_t s[] = L"123456790";
+        os.write(s, sizeof(s)/sizeof(s[0])-1);
+        assert(os.good());
+        assert(sb.str() == s);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        const char s[] = "123456790";
+        os.write(s, sizeof(s)/sizeof(s[0])-1);
+        assert(sb.str() == s);
+        assert(os.good());
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp
new file mode 100644
index 0000000..41ce034
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream
+//     : virtual public basic_ios<charT,traits>
+// {
+// public:
+//     // types (inherited from basic_ios (27.5.4)):
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <ostream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ios<char>, std::basic_ostream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ostream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp
new file mode 100644
index 0000000..991fdfb
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream_sentry/construct.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream::sentry;
+
+// explicit sentry(basic_ostream<charT,traits>& os);
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf1
+    : public std::basic_streambuf<CharT>
+{
+    testbuf1() {}
+
+protected:
+
+    int virtual sync()
+    {
+        ++sync_called;
+        return 1;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        std::ostream::sentry s(os);
+        assert(!bool(s));
+    }
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+    }
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        testbuf1<char> sb2;
+        std::ostream os2(&sb2);
+        os.tie(&os2);
+        assert(sync_called == 0);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+        assert(sync_called == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp b/final/test/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
new file mode 100644
index 0000000..112928c
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ostream::sentry;
+
+// ~sentry();
+
+#include <ostream>
+#include <cassert>
+
+int sync_called = 0;
+
+template <class CharT>
+struct testbuf1
+    : public std::basic_streambuf<CharT>
+{
+    testbuf1() {}
+
+protected:
+
+    int virtual sync()
+    {
+        ++sync_called;
+        return 1;
+    }
+};
+
+int main()
+{
+    {
+        std::ostream os((std::streambuf*)0);
+        std::ostream::sentry s(os);
+        assert(!bool(s));
+    }
+    assert(sync_called == 0);
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+    }
+    assert(sync_called == 0);
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        std::ostream::sentry s(os);
+        assert(bool(s));
+        unitbuf(os);
+    }
+    assert(sync_called == 1);
+    {
+        testbuf1<char> sb;
+        std::ostream os(&sb);
+        try
+        {
+            std::ostream::sentry s(os);
+            assert(bool(s));
+            unitbuf(os);
+            throw 1;
+        }
+        catch (...)
+        {
+        }
+        assert(sync_called == 1);
+    }
+}
diff --git a/final/test/input.output/iostream.format/output.streams/version.pass.cpp b/final/test/input.output/iostream.format/output.streams/version.pass.cpp
new file mode 100644
index 0000000..662b698
--- /dev/null
+++ b/final/test/input.output/iostream.format/output.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ostream>
+
+#include <ostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp b/final/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp
new file mode 100644
index 0000000..d09b3ca
--- /dev/null
+++ b/final/test/input.output/iostream.format/quoted.manip/quoted.pass.cpp
@@ -0,0 +1,219 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool is_skipws ( const std::istream *is ) {
+    return ( is->flags() & std::ios_base::skipws ) != 0;
+    }
+
+
+bool is_skipws ( const std::wistream *is ) {
+    return ( is->flags() & std::ios_base::skipws ) != 0;
+    }
+
+void both_ways ( const char *p ) {
+    std::string str(p);
+    auto q = std::quoted(str);
+
+    std::stringstream ss;
+    bool skippingws = is_skipws ( &ss );
+    ss << q;
+    ss >> q;
+    }
+
+void round_trip ( const char *p ) {
+    std::stringstream ss;
+    bool skippingws = is_skipws ( &ss );
+    ss << std::quoted(p);
+    std::string s;
+    ss >> std::quoted(s);
+    assert ( s == p );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+
+void round_trip_ws ( const char *p ) {
+    std::stringstream ss;
+    std::noskipws ( ss );
+    bool skippingws = is_skipws ( &ss );
+    ss << std::quoted(p);
+    std::string s;
+    ss >> std::quoted(s);
+    assert ( s == p );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+
+void round_trip_d ( const char *p, char delim ) {
+    std::stringstream ss;
+    ss << std::quoted(p, delim);
+    std::string s;
+    ss >> std::quoted(s, delim);
+    assert ( s == p );
+    }
+
+void round_trip_e ( const char *p, char escape ) {
+    std::stringstream ss;
+    ss << std::quoted(p, '"', escape );
+    std::string s;
+    ss >> std::quoted(s, '"', escape );
+    assert ( s == p );
+    }
+
+
+
+std::string quote ( const char *p, char delim='"', char escape='\\' ) {
+    std::stringstream ss;
+    ss << std::quoted(p, delim, escape);
+    std::string s;
+    ss >> s;    // no quote
+    return s;
+}
+
+std::string unquote ( const char *p, char delim='"', char escape='\\' ) {
+    std::stringstream ss;
+    ss << p;
+    std::string s;
+    ss >> std::quoted(s, delim, escape);
+    return s;
+}
+
+void test_padding () {
+    {
+    std::stringstream ss;
+    ss << std::left << std::setw(10) << std::setfill('!') << std::quoted("abc", '`');
+    assert ( ss.str() == "`abc`!!!!!" );
+    }
+    
+    {
+    std::stringstream ss;
+    ss << std::right << std::setw(10) << std::setfill('!') << std::quoted("abc", '`');
+    assert ( ss.str() == "!!!!!`abc`" );
+    }
+}
+
+
+void round_trip ( const wchar_t *p ) {
+    std::wstringstream ss;
+    bool skippingws = is_skipws ( &ss );
+    ss << std::quoted(p);
+    std::wstring s;
+    ss >> std::quoted(s);
+    assert ( s == p );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+    
+
+void round_trip_ws ( const wchar_t *p ) {
+    std::wstringstream ss;
+    std::noskipws ( ss );
+    bool skippingws = is_skipws ( &ss );
+    ss << std::quoted(p);
+    std::wstring s;
+    ss >> std::quoted(s);
+    assert ( s == p );
+    assert ( skippingws == is_skipws ( &ss ));
+    }
+
+void round_trip_d ( const wchar_t *p, wchar_t delim ) {
+    std::wstringstream ss;
+    ss << std::quoted(p, delim);
+    std::wstring s;
+    ss >> std::quoted(s, delim);
+    assert ( s == p );
+    }
+
+void round_trip_e ( const wchar_t *p, wchar_t escape ) {
+    std::wstringstream ss;
+    ss << std::quoted(p, wchar_t('"'), escape );
+    std::wstring s;
+    ss >> std::quoted(s, wchar_t('"'), escape );
+    assert ( s == p );
+    }
+
+
+std::wstring quote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+    std::wstringstream ss;
+    ss << std::quoted(p, delim, escape);
+    std::wstring s;
+    ss >> s;    // no quote
+    return s;
+}
+
+std::wstring unquote ( const wchar_t *p, wchar_t delim='"', wchar_t escape='\\' ) {
+    std::wstringstream ss;
+    ss << p;
+    std::wstring s;
+    ss >> std::quoted(s, delim, escape);
+    return s;
+}
+
+int main()
+{
+    both_ways ( "" );   // This is a compilation check
+
+    round_trip    (  "" );
+    round_trip_ws (  "" );
+    round_trip_d  (  "", 'q' );
+    round_trip_e  (  "", 'q' );
+    
+    round_trip    ( L"" );
+    round_trip_ws ( L"" );
+    round_trip_d  ( L"", 'q' );
+    round_trip_e  ( L"", 'q' );
+    
+    round_trip    (  "Hi" );
+    round_trip_ws (  "Hi" );
+    round_trip_d  (  "Hi", '!' );
+    round_trip_e  (  "Hi", '!' );
+    assert ( quote ( "Hi", '!' ) == "!Hi!" );
+    assert ( quote ( "Hi!", '!' ) == R"(!Hi\!!)" );
+    
+    round_trip    ( L"Hi" );
+    round_trip_ws ( L"Hi" );
+    round_trip_d  ( L"Hi", '!' );
+    round_trip_e  ( L"Hi", '!' );
+    assert ( quote ( L"Hi", '!' )  == L"!Hi!" );
+    assert ( quote ( L"Hi!", '!' ) == LR"(!Hi\!!)" );
+    
+    round_trip    (  "Hi Mom" );
+    round_trip_ws (  "Hi Mom" );
+    round_trip    ( L"Hi Mom" );
+    round_trip_ws ( L"Hi Mom" );
+    
+    assert ( quote (  "" )  ==  "\"\"" );
+    assert ( quote ( L"" )  == L"\"\"" );
+    assert ( quote (  "a" ) ==  "\"a\"" );
+    assert ( quote ( L"a" ) == L"\"a\"" );
+
+//  missing end quote - must not hang
+    assert ( unquote (  "\"abc" ) ==  "abc" );
+    assert ( unquote ( L"\"abc" ) == L"abc" );
+    
+    assert ( unquote (  "abc" ) == "abc" ); // no delimiter
+    assert ( unquote ( L"abc" ) == L"abc" ); // no delimiter
+    assert ( unquote (  "abc def" ) ==  "abc" ); // no delimiter
+    assert ( unquote ( L"abc def" ) == L"abc" ); // no delimiter
+
+    assert ( unquote (  "" ) ==  "" ); // nothing there
+    assert ( unquote ( L"" ) == L"" ); // nothing there
+    test_padding ();
+    }
+
+#else
+int main() {}
+#endif
diff --git a/final/test/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp b/final/test/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp
new file mode 100644
index 0000000..2f516f8
--- /dev/null
+++ b/final/test/input.output/iostream.format/quoted.manip/quoted_char.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+void round_trip ( const char *p ) {
+    std::wstringstream ss;
+    ss << std::quoted(p);
+    std::string s;
+    ss >> std::quoted(s);
+    }
+
+
+
+int main()
+{
+    round_trip ( "Hi Mom" );   
+}
+#else
+#error
+#endif
diff --git a/final/test/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp b/final/test/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp
new file mode 100644
index 0000000..bdd362d
--- /dev/null
+++ b/final/test/input.output/iostream.format/quoted.manip/quoted_traits.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// quoted
+
+#include <iomanip>
+#include <sstream>
+#include <string>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+template <class charT>
+struct test_traits
+{
+    typedef charT     char_type;
+};
+
+void round_trip ( const char *p ) {
+    std::stringstream ss;
+    ss << std::quoted(p);
+    std::basic_string<char, test_traits<char>> s;
+    ss >> std::quoted(s);
+    }
+
+
+
+int main()
+{
+    round_trip ( "Hi Mom" );   
+}
+#else
+#error
+#endif
diff --git a/final/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp b/final/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp
new file mode 100644
index 0000000..6c01fc0
--- /dev/null
+++ b/final/test/input.output/iostream.format/std.manip/resetiosflags.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T1 resetiosflags(ios_base::fmtflags mask);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        assert(is.flags() & std::ios_base::skipws);
+        is >> std::resetiosflags(std::ios_base::skipws);
+        assert(!(is.flags() & std::ios_base::skipws));
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(os.flags() & std::ios_base::skipws);
+        os << std::resetiosflags(std::ios_base::skipws);
+        assert(!(os.flags() & std::ios_base::skipws));
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        assert(is.flags() & std::ios_base::skipws);
+        is >> std::resetiosflags(std::ios_base::skipws);
+        assert(!(is.flags() & std::ios_base::skipws));
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        assert(os.flags() & std::ios_base::skipws);
+        os << std::resetiosflags(std::ios_base::skipws);
+        assert(!(os.flags() & std::ios_base::skipws));
+    }
+}
diff --git a/final/test/input.output/iostream.format/std.manip/setbase.pass.cpp b/final/test/input.output/iostream.format/std.manip/setbase.pass.cpp
new file mode 100644
index 0000000..e2776a5
--- /dev/null
+++ b/final/test/input.output/iostream.format/std.manip/setbase.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T3 setbase(int base);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        is >> std::setbase(8);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        is >> std::setbase(10);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        is >> std::setbase(16);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        is >> std::setbase(15);
+        assert((is.flags() & std::ios_base::basefield) == 0);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setbase(8);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        os << std::setbase(10);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        os << std::setbase(16);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        os << std::setbase(15);
+        assert((os.flags() & std::ios_base::basefield) == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        is >> std::setbase(8);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        is >> std::setbase(10);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        is >> std::setbase(16);
+        assert((is.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        is >> std::setbase(15);
+        assert((is.flags() & std::ios_base::basefield) == 0);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setbase(8);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::oct);
+        os << std::setbase(10);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::dec);
+        os << std::setbase(16);
+        assert((os.flags() & std::ios_base::basefield) == std::ios_base::hex);
+        os << std::setbase(15);
+        assert((os.flags() & std::ios_base::basefield) == 0);
+    }
+}
diff --git a/final/test/input.output/iostream.format/std.manip/setfill.pass.cpp b/final/test/input.output/iostream.format/std.manip/setfill.pass.cpp
new file mode 100644
index 0000000..a4d923d
--- /dev/null
+++ b/final/test/input.output/iostream.format/std.manip/setfill.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// template<charT> T4 setfill(charT c);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setfill('*');
+        assert(os.fill() == '*');
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setfill(L'*');
+        assert(os.fill() == L'*');
+    }
+}
diff --git a/final/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp b/final/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp
new file mode 100644
index 0000000..5aaf384
--- /dev/null
+++ b/final/test/input.output/iostream.format/std.manip/setiosflags.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T2 setiosflags (ios_base::fmtflags mask);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        assert(!(is.flags() & std::ios_base::oct));
+        is >> std::setiosflags(std::ios_base::oct);
+        assert(is.flags() & std::ios_base::oct);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        assert(!(os.flags() & std::ios_base::oct));
+        os << std::setiosflags(std::ios_base::oct);
+        assert(os.flags() & std::ios_base::oct);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        assert(!(is.flags() & std::ios_base::oct));
+        is >> std::setiosflags(std::ios_base::oct);
+        assert(is.flags() & std::ios_base::oct);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        assert(!(os.flags() & std::ios_base::oct));
+        os << std::setiosflags(std::ios_base::oct);
+        assert(os.flags() & std::ios_base::oct);
+    }
+}
diff --git a/final/test/input.output/iostream.format/std.manip/setprecision.pass.cpp b/final/test/input.output/iostream.format/std.manip/setprecision.pass.cpp
new file mode 100644
index 0000000..0bea4b9
--- /dev/null
+++ b/final/test/input.output/iostream.format/std.manip/setprecision.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T5 setprecision(int n);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        is >> std::setprecision(10);
+        assert(is.precision() == 10);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setprecision(10);
+        assert(os.precision() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        is >> std::setprecision(10);
+        assert(is.precision() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setprecision(10);
+        assert(os.precision() == 10);
+    }
+}
diff --git a/final/test/input.output/iostream.format/std.manip/setw.pass.cpp b/final/test/input.output/iostream.format/std.manip/setw.pass.cpp
new file mode 100644
index 0000000..9bd9698
--- /dev/null
+++ b/final/test/input.output/iostream.format/std.manip/setw.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+// T6 setw(int n);
+
+#include <iomanip>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_streambuf<CharT>
+{
+    testbuf() {}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb;
+        std::istream is(&sb);
+        is >> std::setw(10);
+        assert(is.width() == 10);
+    }
+    {
+        testbuf<char> sb;
+        std::ostream os(&sb);
+        os << std::setw(10);
+        assert(os.width() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wistream is(&sb);
+        is >> std::setw(10);
+        assert(is.width() == 10);
+    }
+    {
+        testbuf<wchar_t> sb;
+        std::wostream os(&sb);
+        os << std::setw(10);
+        assert(os.width() == 10);
+    }
+}
diff --git a/final/test/input.output/iostream.format/std.manip/version.pass.cpp b/final/test/input.output/iostream.format/std.manip/version.pass.cpp
new file mode 100644
index 0000000..ca4fd3d
--- /dev/null
+++ b/final/test/input.output/iostream.format/std.manip/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iomanip>
+
+#include <iomanip>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.forward/iosfwd.pass.cpp b/final/test/input.output/iostream.forward/iosfwd.pass.cpp
new file mode 100644
index 0000000..7250c2a
--- /dev/null
+++ b/final/test/input.output/iostream.forward/iosfwd.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iosfwd>
+
+#include <iosfwd>
+#include <cwchar>  // for mbstate_t
+
+int main()
+{
+    {
+    std::char_traits<char>*               t1 = 0;
+    std::char_traits<wchar_t>*            t2 = 0;
+    std::char_traits<unsigned short>*     t3 = 0;
+    }
+    {
+    std::basic_ios<char>*                 t1 = 0;
+    std::basic_ios<wchar_t>*              t2 = 0;
+    std::basic_ios<unsigned short>*       t3 = 0;
+    }
+    {
+    std::basic_streambuf<char>*           t1 = 0;
+    std::basic_streambuf<wchar_t>*        t2 = 0;
+    std::basic_streambuf<unsigned short>* t3 = 0;
+    }
+    {
+    std::basic_istream<char>*             t1 = 0;
+    std::basic_istream<wchar_t>*          t2 = 0;
+    std::basic_istream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ostream<char>*             t1 = 0;
+    std::basic_ostream<wchar_t>*          t2 = 0;
+    std::basic_ostream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_iostream<char>*             t1 = 0;
+    std::basic_iostream<wchar_t>*          t2 = 0;
+    std::basic_iostream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_stringbuf<char>*             t1 = 0;
+    std::basic_stringbuf<wchar_t>*          t2 = 0;
+    std::basic_stringbuf<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_istringstream<char>*             t1 = 0;
+    std::basic_istringstream<wchar_t>*          t2 = 0;
+    std::basic_istringstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ostringstream<char>*             t1 = 0;
+    std::basic_ostringstream<wchar_t>*          t2 = 0;
+    std::basic_ostringstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_stringstream<char>*             t1 = 0;
+    std::basic_stringstream<wchar_t>*          t2 = 0;
+    std::basic_stringstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_filebuf<char>*             t1 = 0;
+    std::basic_filebuf<wchar_t>*          t2 = 0;
+    std::basic_filebuf<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ifstream<char>*             t1 = 0;
+    std::basic_ifstream<wchar_t>*          t2 = 0;
+    std::basic_ifstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_ofstream<char>*             t1 = 0;
+    std::basic_ofstream<wchar_t>*          t2 = 0;
+    std::basic_ofstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::basic_fstream<char>*             t1 = 0;
+    std::basic_fstream<wchar_t>*          t2 = 0;
+    std::basic_fstream<unsigned short>*   t3 = 0;
+    }
+    {
+    std::istreambuf_iterator<char>*             t1 = 0;
+    std::istreambuf_iterator<wchar_t>*          t2 = 0;
+    std::istreambuf_iterator<unsigned short>*   t3 = 0;
+    }
+    {
+    std::ostreambuf_iterator<char>*             t1 = 0;
+    std::ostreambuf_iterator<wchar_t>*          t2 = 0;
+    std::ostreambuf_iterator<unsigned short>*   t3 = 0;
+    }
+    {
+    std::ios*           t1 = 0;
+    std::wios*          t2 = 0;
+    }
+    {
+    std::streambuf*        t1 = 0;
+    std::istream*          t2 = 0;
+    std::ostream*          t3 = 0;
+    std::iostream*         t4 = 0;
+    }
+    {
+    std::stringbuf*            t1 = 0;
+    std::istringstream*        t2 = 0;
+    std::ostringstream*        t3 = 0;
+    std::stringstream*         t4 = 0;
+    }
+    {
+    std::filebuf*         t1 = 0;
+    std::ifstream*        t2 = 0;
+    std::ofstream*        t3 = 0;
+    std::fstream*         t4 = 0;
+    }
+    {
+    std::wstreambuf*        t1 = 0;
+    std::wistream*          t2 = 0;
+    std::wostream*          t3 = 0;
+    std::wiostream*         t4 = 0;
+    }
+    {
+    std::wstringbuf*            t1 = 0;
+    std::wistringstream*        t2 = 0;
+    std::wostringstream*        t3 = 0;
+    std::wstringstream*         t4 = 0;
+    }
+    {
+    std::wfilebuf*         t1 = 0;
+    std::wifstream*        t2 = 0;
+    std::wofstream*        t3 = 0;
+    std::wfstream*         t4 = 0;
+    }
+    {
+    std::fpos<std::mbstate_t>*   t1 = 0;
+    std::streampos*              t2 = 0;
+    std::wstreampos*             t3 = 0;
+    }
+}
diff --git a/final/test/input.output/iostream.forward/version.pass.cpp b/final/test/input.output/iostream.forward/version.pass.cpp
new file mode 100644
index 0000000..cf91332
--- /dev/null
+++ b/final/test/input.output/iostream.forward/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iosfwd>
+
+#include <iosfwd>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp b/final/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
new file mode 100644
index 0000000..9206d17
--- /dev/null
+++ b/final/test/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream cerr;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::cerr << "Hello World!\n";
+#else
+    assert(std::cerr.tie() == &std::cout);
+    assert(std::cerr.flags() & std::ios_base::unitbuf);
+#endif  // 0
+}
diff --git a/final/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp b/final/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
new file mode 100644
index 0000000..3481598
--- /dev/null
+++ b/final/test/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream cin;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::cout << "Hello World!\n";
+    int i;
+    std::cout << "Enter a number: ";
+    std::cin >> i;
+    std::cout << "The number is : " << i << '\n';
+#else  // 0
+    assert(std::cin.tie() == &std::cout);
+#endif
+}
diff --git a/final/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp b/final/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
new file mode 100644
index 0000000..3812b20
--- /dev/null
+++ b/final/test/input.output/iostream.objects/narrow.stream.objects/clog.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream clog;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::clog << "Hello World!\n";
+#else
+    (void)std::clog;
+#endif
+}
diff --git a/final/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp b/final/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
new file mode 100644
index 0000000..6000ae2
--- /dev/null
+++ b/final/test/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream cout;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::cout << "Hello World!\n";
+    int i;
+    std::cout << "Enter a number: ";
+    std::cin >> i;
+    std::cout << "The number is : " << i << '\n';
+#else  // 0
+    (void)std::cout;
+#endif
+}
diff --git a/final/test/input.output/iostream.objects/version.pass.cpp b/final/test/input.output/iostream.objects/version.pass.cpp
new file mode 100644
index 0000000..09b3611
--- /dev/null
+++ b/final/test/input.output/iostream.objects/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+#include <iostream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp b/final/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
new file mode 100644
index 0000000..19a1dcd
--- /dev/null
+++ b/final/test/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wcerr;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::wcerr << L"Hello World!\n";
+#else
+    assert(std::wcerr.tie() == &std::wcout);
+    assert(std::wcerr.flags() & std::ios_base::unitbuf);
+#endif  // 0
+}
diff --git a/final/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp b/final/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
new file mode 100644
index 0000000..90a5668
--- /dev/null
+++ b/final/test/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wcin;
+
+#include <iostream>
+#include <cassert>
+
+int main()
+{
+#if 0
+    std::wcout << L"Hello World!\n";
+    int i;
+    std::wcout << L"Enter a number: ";
+    std::wcin >> i;
+    std::wcout << L"The number is : " << i << L'\n';
+#else  // 0
+    assert(std::wcin.tie() == &std::wcout);
+#endif
+}
diff --git a/final/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp b/final/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
new file mode 100644
index 0000000..61ff5fb
--- /dev/null
+++ b/final/test/input.output/iostream.objects/wide.stream.objects/wclog.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wclog;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::wclog << L"Hello World!\n";
+#else
+    (void)std::wclog;
+#endif
+}
diff --git a/final/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp b/final/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
new file mode 100644
index 0000000..7a546aa
--- /dev/null
+++ b/final/test/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iostream>
+
+// istream wcout;
+
+#include <iostream>
+
+int main()
+{
+#if 0
+    std::wcout << L"Hello World!\n";
+#else
+    (void)std::wcout;
+#endif
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp
new file mode 100644
index 0000000..1da6d44
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.members/state.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// void state(stateT s);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::fpos<int> f;
+    f.state(3);
+    assert(f.state() == 3);
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp
new file mode 100644
index 0000000..a602e3e
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.operations/addition.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Addition
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(5);
+    std::streamoff o(6);
+    P q = p + o;
+    assert(q == P(11));
+    p += o;
+    assert(p == q);
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp
new file mode 100644
index 0000000..1b939d8
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.operations/ctor_int.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// fpos(int)
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(5);
+    assert(p == P(5));
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp
new file mode 100644
index 0000000..47ce687
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.operations/difference.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Subraction with fpos
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(11);
+    P q(6);
+    std::streamoff o = p - q;
+    assert(o == 5);
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp
new file mode 100644
index 0000000..76f8fa1
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.operations/eq_int.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// == and !=
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(5);
+    P q(6);
+    assert(p == p);
+    assert(p != q);
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp
new file mode 100644
index 0000000..9c6ebd9
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.operations/offset.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// converts to and from streamoff
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(std::streamoff(7));
+    std::streamoff offset(p);
+    assert(offset == 7);
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp
new file mode 100644
index 0000000..eb738b4
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.operations/streamsize.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// streamsize and streamoff interconvert
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::streamoff o(5);
+    std::streamsize sz(o);
+    assert(sz == 5);
+    std::streamoff o2(sz);
+    assert(o == o2);
+}
diff --git a/final/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp b/final/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp
new file mode 100644
index 0000000..f9e6513
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/fpos.operations/subtraction.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class StateT> class fpos
+
+// Subraction with offset
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    typedef std::fpos<std::mbstate_t> P;
+    P p(11);
+    std::streamoff o(6);
+    P q = p - o;
+    assert(q == P(5));
+    p -= o;
+    assert(p == q);
+}
diff --git a/final/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp b/final/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.base/fpos/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp
new file mode 100644
index 0000000..958fcb5
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/flags.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags flags() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.flags() == (test::skipws | test::dec));
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp
new file mode 100644
index 0000000..36b5794
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/flags_fmtflags.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags flags(fmtflags fmtfl);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    test::fmtflags f = t.flags(test::hex | test::right);
+    assert(f == (test::skipws | test::dec));
+    assert(t.flags() == (test::hex | test::right));
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp
new file mode 100644
index 0000000..701e3de
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/precision.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize precision() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.precision() == 6);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp
new file mode 100644
index 0000000..e0d6484
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/precision_streamsize.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize precision(streamsize prec);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.precision() == 6);
+    std::streamsize p = t.precision(10);
+    assert(p == 6);
+    assert(t.precision() == 10);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp
new file mode 100644
index 0000000..d9ec47b
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags setf(fmtflags fmtfl)
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    test::fmtflags f = t.setf(test::hex | test::right);
+    assert(f == (test::skipws | test::dec));
+    assert(t.flags() == (test::skipws | test::dec | test::hex | test::right));
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp
new file mode 100644
index 0000000..b201377
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/setf_fmtflags_mask.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// fmtflags setf(fmtflags fmtfl, fmtflags mask);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    test::fmtflags f = t.setf(test::hex | test::right, test::dec | test::right);
+    assert(f == (test::skipws | test::dec));
+    assert(t.flags() == (test::skipws | test::right));
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp
new file mode 100644
index 0000000..163fc54
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/unsetf_mask.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void unsetf(fmtflags mask);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.flags() == (test::skipws | test::dec));
+    t.unsetf(test::dec | test::right);
+    assert(t.flags() == test::skipws);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp
new file mode 100644
index 0000000..287c89d
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/width.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize width() const;
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.width() == 0);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp
new file mode 100644
index 0000000..6e532de
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/fmtflags.state/width_streamsize.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// streamsize width(streamsize wide);
+
+#include <ios>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    assert(t.width() == 0);
+    std::streamsize w = t.width(4);
+    assert(w == 0);
+    assert(t.width() == 4);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp
new file mode 100644
index 0000000..c0ed315
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void register_callback(event_callback fn, int index);
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int f1_called = 0;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 4);
+        ++f1_called;
+    }
+}
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    b.register_callback(f1, 4);
+    b.register_callback(f1, 4);
+    b.register_callback(f1, 4);
+    std::locale l = b.imbue(std::locale(LOCALE_en_US_UTF_8));
+    assert(f1_called == 3);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp
new file mode 100644
index 0000000..e6f3348
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.base.cons/dtor.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ~ios_base()
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "C");
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == "C");
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!f3_called);
+        assert(stream.getloc().name() == "C");
+        assert(index == 6);
+        f3_called = true;
+    }
+}
+
+int main()
+{
+    {
+        test t;
+        std::ios_base& b = t;
+        b.register_callback(f1, 4);
+        b.register_callback(f2, 5);
+        b.register_callback(f3, 6);
+    }
+    assert(f1_called);
+    assert(f2_called);
+    assert(f3_called);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp
new file mode 100644
index 0000000..8f265bc
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.base.locales/getloc.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// locale getloc() const;
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    const test t;
+    assert(t.getloc().name() == std::string("C"));
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp
new file mode 100644
index 0000000..4e34c08
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// locale imbue(const locale& loc);
+
+#include <ios>
+#include <string>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!f3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 6);
+        f3_called = true;
+    }
+}
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    b.register_callback(f1, 4);
+    b.register_callback(f2, 5);
+    b.register_callback(f3, 6);
+    std::locale l = b.imbue(std::locale(LOCALE_en_US_UTF_8));
+    assert(l.name() == std::string("C"));
+    assert(b.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+    assert(f1_called);
+    assert(f2_called);
+    assert(f3_called);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp
new file mode 100644
index 0000000..1e2ee50
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.base.storage/iword.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// long& iword(int idx);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    for (int i = 0; i < 10000; ++i)
+    {
+        assert(b.iword(i) == 0);
+        b.iword(i) = i;
+        assert(b.iword(i) == i);
+        for (int j = 0; j <= i; ++j)
+            assert(b.iword(j) == j);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp
new file mode 100644
index 0000000..5246ad8
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.base.storage/pword.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// void*& pword(int idx);
+
+#include <ios>
+#include <string>
+#include <cassert>
+#include <cstdint>
+
+class test
+    : public std::ios
+{
+public:
+    test()
+    {
+        init(0);
+    }
+};
+
+int main()
+{
+    test t;
+    std::ios_base& b = t;
+    for (std::intptr_t i = 0; i < 10000; ++i)
+    {
+        assert(b.pword(i) == 0);
+        b.pword(i) = (void*)i;
+        assert(b.pword(i) == (void*)i);
+        for (std::intptr_t j = 0; j <= i; ++j)
+            assert(b.pword(j) == (void*)j);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp
new file mode 100644
index 0000000..eb737b1
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.base.storage/xalloc.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static int xalloc();
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::xalloc() == 0);
+    assert(std::ios_base::xalloc() == 1);
+    assert(std::ios_base::xalloc() == 2);
+    assert(std::ios_base::xalloc() == 3);
+    assert(std::ios_base::xalloc() == 4);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp
new file mode 100644
index 0000000..5dc72b1
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.members.static/sync_with_stdio.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// bool sync_with_stdio(bool sync = true);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert( std::ios_base::sync_with_stdio(false));
+    assert(!std::ios_base::sync_with_stdio(false));
+    assert(!std::ios_base::sync_with_stdio(true));
+    assert( std::ios_base::sync_with_stdio(true));
+    assert( std::ios_base::sync_with_stdio());
+    assert( std::ios_base::sync_with_stdio(false));
+    assert(!std::ios_base::sync_with_stdio());
+    assert( std::ios_base::sync_with_stdio());
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_Init/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp
new file mode 100644
index 0000000..50f5fda
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_char_pointer_error_code.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base::failure
+
+// explicit failure(const char* msg, const error_code& ec = io_errc::stream);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg.c_str(), make_error_code(std::errc::is_a_directory));
+        assert(se.code() == std::make_error_code(std::errc::is_a_directory));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find("Is a directory") != std::string::npos);
+    }
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg.c_str());
+        assert(se.code() == std::make_error_code(std::io_errc::stream));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find(std::iostream_category().message(static_cast<int>
+            (std::io_errc::stream))) != std::string::npos);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp
new file mode 100644
index 0000000..5c9abbe
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base::failure
+
+// explicit failure(const string& msg, const error_code& ec = io_errc::stream);
+
+#include <ios>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory));
+        assert(se.code() == std::make_error_code(std::errc::is_a_directory));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find("Is a directory") != std::string::npos);
+    }
+    {
+        std::string what_arg("io test message");
+        std::ios_base::failure se(what_arg);
+        assert(se.code() == std::make_error_code(std::io_errc::stream));
+        std::string what_message(se.what());
+        assert(what_message.find(what_arg) != std::string::npos);
+        assert(what_message.find(std::iostream_category().message(static_cast<int>
+            (std::io_errc::stream))) != std::string::npos);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp
new file mode 100644
index 0000000..9f37459
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_fmtflags/fmtflags.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const fmtflags boolalpha;
+// static const fmtflags dec;
+// static const fmtflags fixed;
+// static const fmtflags hex;
+// static const fmtflags internal;
+// static const fmtflags left;
+// static const fmtflags oct;
+// static const fmtflags right;
+// static const fmtflags scientific;
+// static const fmtflags showbase;
+// static const fmtflags showpoint;
+// static const fmtflags showpos;
+// static const fmtflags skipws;
+// static const fmtflags unitbuf;
+// static const fmtflags uppercase;
+// static const fmtflags adjustfield = left | right | internal;
+// static const fmtflags basefield   = dec | oct | hex;
+// static const fmtflags floatfield  = scientific | fixed;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::boolalpha);
+    assert(std::ios_base::dec);
+    assert(std::ios_base::fixed);
+    assert(std::ios_base::hex);
+    assert(std::ios_base::internal);
+    assert(std::ios_base::left);
+    assert(std::ios_base::oct);
+    assert(std::ios_base::right);
+    assert(std::ios_base::scientific);
+    assert(std::ios_base::showbase);
+    assert(std::ios_base::showpoint);
+    assert(std::ios_base::showpos);
+    assert(std::ios_base::skipws);
+    assert(std::ios_base::unitbuf);
+    assert(std::ios_base::uppercase);
+
+    assert
+    (
+        ( std::ios_base::boolalpha
+        & std::ios_base::dec
+        & std::ios_base::fixed
+        & std::ios_base::hex
+        & std::ios_base::internal
+        & std::ios_base::left
+        & std::ios_base::oct
+        & std::ios_base::right
+        & std::ios_base::scientific
+        & std::ios_base::showbase
+        & std::ios_base::showpoint
+        & std::ios_base::showpos
+        & std::ios_base::skipws
+        & std::ios_base::unitbuf
+        & std::ios_base::uppercase) == 0
+    );
+
+    assert(std::ios_base::adjustfield == (std::ios_base::left
+                                        | std::ios_base::right
+                                        | std::ios_base::internal));
+    assert(std::ios_base::basefield == (std::ios_base::dec
+                                      | std::ios_base::oct
+                                      | std::ios_base::hex));
+    assert(std::ios_base::floatfield == (std::ios_base::scientific
+                                       | std::ios_base::fixed));
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp
new file mode 100644
index 0000000..55c02f3
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_iostate/iostate.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const iostate badbit;
+// static const iostate eofbit;
+// static const iostate failbit;
+// static const iostate goodbit = 0;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::badbit);
+    assert(std::ios_base::eofbit);
+    assert(std::ios_base::failbit);
+
+    assert
+    (
+        ( std::ios_base::badbit
+        & std::ios_base::eofbit
+        & std::ios_base::failbit) == 0
+    );
+
+    assert(std::ios_base::goodbit == 0);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp
new file mode 100644
index 0000000..238593f
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_openmode/openmode.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const openmode app;
+// static const openmode ate;
+// static const openmode binary;
+// static const openmode in;
+// static const openmode out;
+// static const openmode trunc;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::app);
+    assert(std::ios_base::ate);
+    assert(std::ios_base::binary);
+    assert(std::ios_base::in);
+    assert(std::ios_base::out);
+    assert(std::ios_base::trunc);
+
+    assert
+    (
+        ( std::ios_base::app
+        & std::ios_base::ate
+        & std::ios_base::binary
+        & std::ios_base::in
+        & std::ios_base::out
+        & std::ios_base::trunc) == 0
+    );
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp
new file mode 100644
index 0000000..005fb61
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/ios_seekdir/seekdir.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// static const seekdir beg;
+// static const seekdir cur;
+// static const seekdir end;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    assert(std::ios_base::beg != std::ios_base::cur);
+    assert(std::ios_base::beg != std::ios_base::end);
+    assert(std::ios_base::cur != std::ios_base::end);
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp b/final/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/ios.types/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp b/final/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..760bfcb
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios.base/nothing_to_do.pass.cpp
@@ -0,0 +1,16 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+#include <ios>
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp
new file mode 100644
index 0000000..d86059e
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.cons/ctor_streambuf.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// explicit basic_ios(basic_streambuf<charT,traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+    {
+        std::streambuf* sb = 0;
+        std::basic_ios<char> ios(sb);
+        assert(ios.rdbuf() == sb);
+        assert(ios.tie() == 0);
+        assert(ios.rdstate() == std::ios::badbit);
+        assert(ios.exceptions() == std::ios::goodbit);
+        assert(ios.flags() == (std::ios::skipws | std::ios::dec));
+        assert(ios.width() == 0);
+        assert(ios.precision() == 6);
+        assert(ios.fill() == ' ');
+        assert(ios.getloc() == std::locale());
+    }
+    {
+        std::streambuf* sb = (std::streambuf*)1;
+        std::basic_ios<char> ios(sb);
+        assert(ios.rdbuf() == sb);
+        assert(ios.tie() == 0);
+        assert(ios.rdstate() == std::ios::goodbit);
+        assert(ios.exceptions() == std::ios::goodbit);
+        assert(ios.flags() == (std::ios::skipws | std::ios::dec));
+        assert(ios.width() == 0);
+        assert(ios.precision() == 6);
+        assert(ios.fill() == ' ');
+        assert(ios.getloc() == std::locale());
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
new file mode 100644
index 0000000..80f6e26
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
@@ -0,0 +1,187 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ios& copyfmt(const basic_ios& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert(!g3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::erase_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert(!g3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::copyfmt_event)
+    {
+        assert( f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert( g2_called);
+        assert( g3_called);
+        assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
+        assert(index == 7);
+        g1_called = true;
+    }
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::copyfmt_event)
+    {
+        assert( f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert( g3_called);
+        assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
+        assert(index == 8);
+        g2_called = true;
+    }
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::copyfmt_event)
+    {
+        assert( f1_called);
+        assert( f2_called);
+        assert(!g1_called);
+        assert(!g2_called);
+        assert(!g3_called);
+        assert(stream.getloc().name() == LOCALE_fr_FR_UTF_8);
+        assert(index == 9);
+        g3_called = true;
+    }
+}
+
+int main()
+{
+    testbuf sb1;
+    std::ios ios1(&sb1);
+    ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
+    ios1.precision(1);
+    ios1.width(11);
+    ios1.imbue(std::locale(LOCALE_en_US_UTF_8));
+    ios1.exceptions(std::ios::failbit);
+    ios1.setstate(std::ios::eofbit);
+    ios1.register_callback(f1, 4);
+    ios1.register_callback(f2, 5);
+    ios1.iword(0) = 1;
+    ios1.iword(1) = 2;
+    ios1.iword(2) = 3;
+    char c1, c2, c3;
+    ios1.pword(0) = &c1;
+    ios1.pword(1) = &c2;
+    ios1.pword(2) = &c3;
+    ios1.tie((std::ostream*)1);
+    ios1.fill('1');
+
+    testbuf sb2;
+    std::ios ios2(&sb2);
+    ios2.flags(std::ios::showpoint | std::ios::uppercase);
+    ios2.precision(2);
+    ios2.width(12);
+    ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
+    ios2.exceptions(std::ios::eofbit);
+    ios2.setstate(std::ios::goodbit);
+    ios2.register_callback(g1, 7);
+    ios2.register_callback(g2, 8);
+    ios2.register_callback(g3, 9);
+    ios2.iword(0) = 4;
+    ios2.iword(1) = 5;
+    ios2.iword(2) = 6;
+    ios2.iword(3) = 7;
+    ios2.iword(4) = 8;
+    ios2.iword(5) = 9;
+    char d1, d2;
+    ios2.pword(0) = &d1;
+    ios2.pword(1) = &d2;
+    ios2.tie((std::ostream*)2);
+    ios2.fill('2');
+
+    ios1.copyfmt(ios1);
+    assert(!f1_called);
+
+    try
+    {
+        ios1.copyfmt(ios2);
+        assert(false);
+    }
+    catch (std::ios_base::failure&)
+    {
+    }
+    assert(ios1.rdstate() == std::ios::eofbit);
+    assert(ios1.rdbuf() == &sb1);
+    assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+    assert(ios1.precision() == 2);
+    assert(ios1.width() == 12);
+    assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
+    assert(ios1.exceptions() == std::ios::eofbit);
+    assert(f1_called);
+    assert(f2_called);
+    assert(g1_called);
+    assert(g2_called);
+    assert(g3_called);
+    assert(ios1.iword(0) == 4);
+    assert(ios1.iword(1) == 5);
+    assert(ios1.iword(2) == 6);
+    assert(ios1.iword(3) == 7);
+    assert(ios1.iword(4) == 8);
+    assert(ios1.iword(5) == 9);
+    assert(ios1.pword(0) == &d1);
+    assert(ios1.pword(1) == &d2);
+    assert(ios1.tie() == (std::ostream*)2);
+    assert(ios1.fill() == '2');
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp
new file mode 100644
index 0000000..f5c5aa2
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/fill.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type fill() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::ios ios(0);
+    assert(ios.fill() == ' ');
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
new file mode 100644
index 0000000..10dccca
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type fill(char_type fillch);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(ios.fill() == ' ');
+    char c = ios.fill('*');
+    assert(c == ' ');
+    assert(ios.fill() == '*');
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp
new file mode 100644
index 0000000..6d4ce5f
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// locale imbue(const locale& loc);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+bool f1_called = false;
+bool f2_called = false;
+bool f3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert( f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 4);
+        f1_called = true;
+    }
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert( f3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 5);
+        f2_called = true;
+    }
+}
+
+void f3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(!f1_called);
+        assert(!f2_called);
+        assert(!f3_called);
+        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(index == 6);
+        f3_called = true;
+    }
+}
+
+int main()
+{
+    {
+        std::ios ios(0);
+        ios.register_callback(f1, 4);
+        ios.register_callback(f2, 5);
+        ios.register_callback(f3, 6);
+        std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
+        assert(l.name() == std::string("C"));
+        assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+        assert(f1_called);
+        assert(f2_called);
+        assert(f3_called);
+    }
+    f1_called = false;
+    f2_called = false;
+    f3_called = false;
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        ios.register_callback(f1, 4);
+        ios.register_callback(f2, 5);
+        ios.register_callback(f3, 6);
+        std::locale l = ios.imbue(std::locale(LOCALE_en_US_UTF_8));
+        assert(l.name() == std::string("C"));
+        assert(ios.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+        assert(sb.getloc().name() == std::string(LOCALE_en_US_UTF_8));
+        assert(f1_called);
+        assert(f2_called);
+        assert(f3_called);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
new file mode 100644
index 0000000..eb9262c
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/move.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void move(basic_ios&& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+struct testios
+    : public std::ios
+{
+    testios() {}
+    testios(std::streambuf* p) : std::ios(p) {}
+    void move(std::ios& x) {std::ios::move(x);}
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    f1_called = true;
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    f2_called = true;
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(index == 7);
+        g1_called = true;
+    }
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(index == 8);
+        g2_called = true;
+    }
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    if (ev == std::ios_base::imbue_event)
+    {
+        assert(index == 9);
+        g3_called = true;
+    }
+}
+
+int main()
+{
+    testios ios1;
+    testbuf sb2;
+    std::ios ios2(&sb2);
+    ios2.flags(std::ios::showpoint | std::ios::uppercase);
+    ios2.precision(2);
+    ios2.width(12);
+    ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
+    ios2.exceptions(std::ios::eofbit);
+    ios2.setstate(std::ios::goodbit);
+    ios2.register_callback(g1, 7);
+    ios2.register_callback(g2, 8);
+    ios2.register_callback(g3, 9);
+    ios2.iword(0) = 4;
+    ios2.iword(1) = 5;
+    ios2.iword(2) = 6;
+    ios2.iword(3) = 7;
+    ios2.iword(4) = 8;
+    ios2.iword(5) = 9;
+    char d1, d2;
+    ios2.pword(0) = &d1;
+    ios2.pword(1) = &d2;
+    ios2.tie((std::ostream*)2);
+    ios2.fill('2');
+
+    ios1.move(ios2);
+
+    assert(ios1.rdstate() == std::ios::goodbit);
+    assert(ios1.rdbuf() == 0);
+    assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+    assert(ios1.precision() == 2);
+    assert(ios1.width() == 12);
+    assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
+    assert(ios1.exceptions() == std::ios::eofbit);
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(!g1_called);
+    assert(!g2_called);
+    assert(!g3_called);
+    assert(ios1.iword(0) == 4);
+    assert(ios1.iword(1) == 5);
+    assert(ios1.iword(2) == 6);
+    assert(ios1.iword(3) == 7);
+    assert(ios1.iword(4) == 8);
+    assert(ios1.iword(5) == 9);
+    assert(ios1.pword(0) == &d1);
+    assert(ios1.pword(1) == &d2);
+    assert(ios1.tie() == (std::ostream*)2);
+    assert(ios1.fill() == '2');
+    ios1.imbue(std::locale("C"));
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(g1_called);
+    assert(g2_called);
+    assert(g3_called);
+
+    assert(ios2.rdbuf() == &sb2);
+    assert(ios2.tie() == 0);
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp
new file mode 100644
index 0000000..bf865e6
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/narow.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char narrow(char_type c, char dfault) const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::ios ios(0);
+    assert(ios.narrow('c', '*') == 'c');
+    assert(ios.narrow('\xFE', '*') == '*');
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp
new file mode 100644
index 0000000..7be92e7
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_streambuf<charT,traits>* rdbuf() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::ios ios(0);
+        assert(ios.rdbuf() == 0);
+    }
+    {
+        std::streambuf* sb = (std::streambuf*)1;
+        const std::ios ios(sb);
+        assert(ios.rdbuf() == sb);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp
new file mode 100644
index 0000000..cc0b3f3
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/rdbuf_streambuf.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(ios.rdbuf() == 0);
+    assert(!ios.good());
+    std::streambuf* sb = (std::streambuf*)1;
+    std::streambuf* sb2 = ios.rdbuf(sb);
+    assert(sb2 == 0);
+    assert(ios.rdbuf() == sb);
+    assert(ios.good());
+    sb2 = ios.rdbuf(0);
+    assert(sb2 == (std::streambuf*)1);
+    assert(ios.rdbuf() == 0);
+    assert(ios.bad());
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
new file mode 100644
index 0000000..2d4beee
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void set_rdbuf(basic_streambuf<charT, traits>* sb);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+struct testios
+    : public std::ios
+{
+    testios(std::streambuf* p) : std::ios(p) {}
+    void set_rdbuf(std::streambuf* x) {std::ios::set_rdbuf(x);}
+};
+
+int main()
+{
+    testbuf sb1;
+    testbuf sb2;
+    testios ios(&sb1);
+    try
+    {
+        ios.setstate(std::ios::badbit);
+        ios.exceptions(std::ios::badbit);
+    }
+    catch (...)
+    {
+    }
+    ios.set_rdbuf(&sb2);
+    assert(ios.rdbuf() == &sb2);
+    try
+    {
+        ios.setstate(std::ios::badbit);
+        ios.exceptions(std::ios::badbit);
+    }
+    catch (...)
+    {
+    }
+    ios.set_rdbuf(0);
+    assert(ios.rdbuf() == 0);
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
new file mode 100644
index 0000000..08b8ec4
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/swap.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void move(basic_ios&& rhs);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+struct testbuf
+    : public std::streambuf
+{
+};
+
+struct testios
+    : public std::ios
+{
+    testios(std::streambuf* p) : std::ios(p) {}
+    void swap(std::ios& x) {std::ios::swap(x);}
+};
+
+bool f1_called = false;
+bool f2_called = false;
+
+bool g1_called = false;
+bool g2_called = false;
+bool g3_called = false;
+
+void f1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 4);
+    f1_called = true;
+}
+
+void f2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 5);
+    f2_called = true;
+}
+
+void g1(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 7);
+    g1_called = true;
+}
+
+void g2(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 8);
+    g2_called = true;
+}
+
+void g3(std::ios_base::event ev, std::ios_base& stream, int index)
+{
+    assert(index == 9);
+    g3_called = true;
+}
+
+int main()
+{
+    testbuf sb1;
+    testios ios1(&sb1);
+    ios1.flags(std::ios::boolalpha | std::ios::dec | std::ios::fixed);
+    ios1.precision(1);
+    ios1.width(11);
+    ios1.imbue(std::locale(LOCALE_en_US_UTF_8));
+    ios1.exceptions(std::ios::failbit);
+    ios1.setstate(std::ios::eofbit);
+    ios1.register_callback(f1, 4);
+    ios1.register_callback(f2, 5);
+    ios1.iword(0) = 1;
+    ios1.iword(1) = 2;
+    ios1.iword(2) = 3;
+    char c1, c2, c3;
+    ios1.pword(0) = &c1;
+    ios1.pword(1) = &c2;
+    ios1.pword(2) = &c3;
+    ios1.tie((std::ostream*)1);
+    ios1.fill('1');
+
+    testbuf sb2;
+    testios ios2(&sb2);
+    ios2.flags(std::ios::showpoint | std::ios::uppercase);
+    ios2.precision(2);
+    ios2.width(12);
+    ios2.imbue(std::locale(LOCALE_fr_FR_UTF_8));
+    ios2.exceptions(std::ios::eofbit);
+    ios2.setstate(std::ios::goodbit);
+    ios2.register_callback(g1, 7);
+    ios2.register_callback(g2, 8);
+    ios2.register_callback(g3, 9);
+    ios2.iword(0) = 4;
+    ios2.iword(1) = 5;
+    ios2.iword(2) = 6;
+    ios2.iword(3) = 7;
+    ios2.iword(4) = 8;
+    ios2.iword(5) = 9;
+    char d1, d2;
+    ios2.pword(0) = &d1;
+    ios2.pword(1) = &d2;
+    ios2.tie((std::ostream*)2);
+    ios2.fill('2');
+
+    ios1.swap(ios2);
+
+    assert(ios1.rdstate() == std::ios::goodbit);
+    assert(ios1.rdbuf() == &sb1);
+    assert(ios1.flags() == (std::ios::showpoint | std::ios::uppercase));
+    assert(ios1.precision() == 2);
+    assert(ios1.width() == 12);
+    assert(ios1.getloc().name() == LOCALE_fr_FR_UTF_8);
+    assert(ios1.exceptions() == std::ios::eofbit);
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(!g1_called);
+    assert(!g2_called);
+    assert(!g3_called);
+    assert(ios1.iword(0) == 4);
+    assert(ios1.iword(1) == 5);
+    assert(ios1.iword(2) == 6);
+    assert(ios1.iword(3) == 7);
+    assert(ios1.iword(4) == 8);
+    assert(ios1.iword(5) == 9);
+    assert(ios1.pword(0) == &d1);
+    assert(ios1.pword(1) == &d2);
+    assert(ios1.tie() == (std::ostream*)2);
+    assert(ios1.fill() == '2');
+    ios1.imbue(std::locale("C"));
+    assert(!f1_called);
+    assert(!f2_called);
+    assert(g1_called);
+    assert(g2_called);
+    assert(g3_called);
+
+    assert(ios2.rdstate() == std::ios::eofbit);
+    assert(ios2.rdbuf() == &sb2);
+    assert(ios2.flags() == (std::ios::boolalpha | std::ios::dec | std::ios::fixed));
+    assert(ios2.precision() == 1);
+    assert(ios2.width() == 11);
+    assert(ios2.getloc().name() == LOCALE_en_US_UTF_8);
+    assert(ios2.exceptions() == std::ios::failbit);
+    assert(ios2.iword(0) == 1);
+    assert(ios2.iword(1) == 2);
+    assert(ios2.iword(2) == 3);
+    assert(ios2.pword(0) == &c1);
+    assert(ios2.pword(1) == &c2);
+    assert(ios2.pword(2) == &c3);
+    assert(ios2.tie() == (std::ostream*)1);
+    assert(ios2.fill() == '1');
+    ios2.imbue(std::locale("C"));
+    assert(f1_called);
+    assert(f2_called);
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp
new file mode 100644
index 0000000..71eb238
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/tie.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ostream<charT,traits>* tie() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::basic_ios<char> ios(0);
+    assert(ios.tie() == 0);
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp
new file mode 100644
index 0000000..acccbea
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/tie_ostream.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    std::ostream* os = (std::ostream*)1;
+    std::ostream* r = ios.tie(os);
+    assert(r == 0);
+    assert(ios.tie() == os);
+}
diff --git a/final/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp b/final/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp
new file mode 100644
index 0000000..68fdf68
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/basic.ios.members/widen.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// char_type widen(char c) const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    const std::ios ios(0);
+    assert(ios.widen('c') == 'c');
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp
new file mode 100644
index 0000000..1005df6
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/bad.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool bad() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(ios.bad());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.bad());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(!ios.bad());
+        ios.setstate(std::ios::eofbit);
+        assert(!ios.bad());
+        ios.setstate(std::ios::failbit);
+        assert(!ios.bad());
+        ios.setstate(std::ios::badbit);
+        assert(ios.bad());
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
new file mode 100644
index 0000000..0de889e
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// operator unspecified-bool-type() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(static_cast<bool>(ios) == !ios.fail());
+    ios.setstate(std::ios::failbit);
+    assert(static_cast<bool>(ios) == !ios.fail());
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
new file mode 100644
index 0000000..0c2e8f0
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void clear(iostate state = goodbit);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        ios.clear();
+        assert(ios.rdstate() == std::ios::badbit);
+        try
+        {
+            ios.exceptions(std::ios::badbit);
+        }
+        catch (...)
+        {
+        }
+        try
+        {
+            ios.clear();
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == std::ios::badbit);
+        }
+        try
+        {
+            ios.clear(std::ios::eofbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
+        }
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        ios.clear();
+        assert(ios.rdstate() == std::ios::goodbit);
+        ios.exceptions(std::ios::badbit);
+        ios.clear();
+        assert(ios.rdstate() == std::ios::goodbit);
+        ios.clear(std::ios::eofbit);
+        assert(ios.rdstate() == std::ios::eofbit);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp
new file mode 100644
index 0000000..64d5a30
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/eof.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool eof() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(!ios.eof());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.eof());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(!ios.eof());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.eof());
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp
new file mode 100644
index 0000000..d5158a1
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/exceptions.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate exceptions() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        const std::ios ios(0);
+        assert(ios.exceptions() == std::ios::goodbit);
+    }
+    {
+        testbuf sb;
+        const std::ios ios(&sb);
+        assert(ios.exceptions() == std::ios::goodbit);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
new file mode 100644
index 0000000..a0013ea
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate exceptions() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(ios.exceptions() == std::ios::goodbit);
+        ios.exceptions(std::ios::eofbit);
+        assert(ios.exceptions() == std::ios::eofbit);
+        try
+        {
+            ios.exceptions(std::ios::badbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+        }
+        assert(ios.exceptions() == std::ios::badbit);
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(ios.exceptions() == std::ios::goodbit);
+        ios.exceptions(std::ios::eofbit);
+        assert(ios.exceptions() == std::ios::eofbit);
+        ios.exceptions(std::ios::badbit);
+        assert(ios.exceptions() == std::ios::badbit);
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp
new file mode 100644
index 0000000..fa9f765
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/fail.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool fail() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(ios.fail());
+        ios.setstate(std::ios::eofbit);
+        assert(ios.fail());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(!ios.fail());
+        ios.setstate(std::ios::eofbit);
+        assert(!ios.fail());
+        ios.setstate(std::ios::badbit);
+        assert(ios.fail());
+        ios.setstate(std::ios::failbit);
+        assert(ios.fail());
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp
new file mode 100644
index 0000000..03f8950
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/good.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool good() const;
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        assert(!ios.good());
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        assert(ios.good());
+        ios.setstate(std::ios::eofbit);
+        assert(!ios.good());
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp
new file mode 100644
index 0000000..ef534f6
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/not.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// bool operator!() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(!ios == ios.fail());
+    ios.setstate(std::ios::failbit);
+    assert(!ios == ios.fail());
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp
new file mode 100644
index 0000000..d09e2a6
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/rdstate.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// iostate rdstate() const;
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    std::ios ios(0);
+    assert(ios.rdstate() == std::ios::badbit);
+    ios.setstate(std::ios::failbit);
+    assert(ios.rdstate() == (std::ios::failbit | std::ios::badbit));
+}
diff --git a/final/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp b/final/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
new file mode 100644
index 0000000..b3c66c4
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits> class basic_ios
+
+// void setstate(iostate state);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    {
+        std::ios ios(0);
+        ios.setstate(std::ios::goodbit);
+        assert(ios.rdstate() == std::ios::badbit);
+        try
+        {
+            ios.exceptions(std::ios::badbit);
+        }
+        catch (...)
+        {
+        }
+        try
+        {
+            ios.setstate(std::ios::goodbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == std::ios::badbit);
+        }
+        try
+        {
+            ios.setstate(std::ios::eofbit);
+            assert(false);
+        }
+        catch (std::ios::failure&)
+        {
+            assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
+        }
+    }
+    {
+        testbuf sb;
+        std::ios ios(&sb);
+        ios.setstate(std::ios::goodbit);
+        assert(ios.rdstate() == std::ios::goodbit);
+        ios.setstate(std::ios::eofbit);
+        assert(ios.rdstate() == std::ios::eofbit);
+        ios.setstate(std::ios::failbit);
+        assert(ios.rdstate() == (std::ios::eofbit | std::ios::failbit));
+    }
+}
diff --git a/final/test/input.output/iostreams.base/ios/types.pass.cpp b/final/test/input.output/iostreams.base/ios/types.pass.cpp
new file mode 100644
index 0000000..22e33f6
--- /dev/null
+++ b/final/test/input.output/iostreams.base/ios/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_ios : public ios_base
+// {
+// public:
+//     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 traits traits_type;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::ios_base, std::basic_ios<char> >::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ios<char>::off_type, std::char_traits<char>::off_type>::value), "");
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp
new file mode 100644
index 0000000..461c777
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/internal.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& internal(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::internal(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::internal);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp
new file mode 100644
index 0000000..aa2ca6f
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/left.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& left(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::left(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::left);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp
new file mode 100644
index 0000000..08056e8
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/adjustfield.manip/right.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& right(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::right(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::right);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp
new file mode 100644
index 0000000..cbe03bc
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/dec.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& dec(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::dec(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::dec);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp
new file mode 100644
index 0000000..281a59c
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/hex.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& hex(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::hex(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::hex);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp
new file mode 100644
index 0000000..5ebfea8
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/basefield.manip/oct.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& oct(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::oct(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::oct);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp
new file mode 100644
index 0000000..a93c7b4
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// const error_category& iostream_category();
+
+#include <ios>
+#include <cassert>
+#include <string>
+
+int main()
+{
+    const std::error_category& e_cat1 = std::iostream_category();
+    std::string m1 = e_cat1.name();
+    assert(m1 == "iostream");
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp
new file mode 100644
index 0000000..f764fa6
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_code.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// error_code make_error_code(io_errc e);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec = make_error_code(std::io_errc::stream);
+        assert(ec.value() == static_cast<int>(std::io_errc::stream));
+        assert(ec.category() == std::iostream_category());
+    }
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp
new file mode 100644
index 0000000..30931ba
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/error.reporting/make_error_condition.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// error_condition make_error_condition(io_errc e);
+
+#include <ios>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec1 = std::make_error_condition(std::io_errc::stream);
+        assert(ec1.value() == static_cast<int>(std::io_errc::stream));
+        assert(ec1.category() == std::iostream_category());
+    }
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp
new file mode 100644
index 0000000..f202bc4
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/defaultfloat.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& defaultfloat(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::defaultfloat(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::fixed));
+    assert(!(ios.flags() & std::ios::scientific));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp
new file mode 100644
index 0000000..55bf264
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/fixed.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& fixed(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::fixed(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::fixed);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp
new file mode 100644
index 0000000..2920cca
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/hexfloat.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& hexfloat(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::hexfloat(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::fixed);
+    assert(ios.flags() & std::ios::scientific);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp
new file mode 100644
index 0000000..53cfd81
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/floatfield.manip/scientific.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& scientific(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::scientific(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::scientific);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp
new file mode 100644
index 0000000..ca8cd93
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/boolalpha.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& boolalpha(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::boolalpha(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::boolalpha);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp
new file mode 100644
index 0000000..ebc0aab
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noboolalpha.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noboolalpha(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::boolalpha(ios);
+    std::ios_base& r = std::noboolalpha(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::boolalpha));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp
new file mode 100644
index 0000000..91608f0
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowbase.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowbase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::showbase(ios);
+    std::ios_base& r = std::noshowbase(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::showbase));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp
new file mode 100644
index 0000000..6e26416
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpoint.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowpoint(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::showpoint(ios);
+    std::ios_base& r = std::noshowpoint(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::showpoint));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp
new file mode 100644
index 0000000..5e6911c
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noshowpos.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noshowpos(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::showpos(ios);
+    std::ios_base& r = std::noshowpos(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::showpos));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp
new file mode 100644
index 0000000..e78f5f8
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/noskipws.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& noskipws(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::skipws(ios);
+    std::ios_base& r = std::noskipws(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::skipws));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp
new file mode 100644
index 0000000..5708038
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nounitbuf.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& nounitbuf(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::unitbuf(ios);
+    std::ios_base& r = std::nounitbuf(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::unitbuf));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp
new file mode 100644
index 0000000..76fac60
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/nouppercase.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& nouppercase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::uppercase(ios);
+    std::ios_base& r = std::nouppercase(ios);
+    assert(&r == &ios);
+    assert(!(ios.flags() & std::ios::uppercase));
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp
new file mode 100644
index 0000000..ddf3a85
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showbase.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showbase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::showbase(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::showbase);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp
new file mode 100644
index 0000000..79ae3b6
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpoint.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showpoint(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::showpoint(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::showpoint);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp
new file mode 100644
index 0000000..2265426
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/showpos.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& showpos(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::showpos(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::showpos);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp
new file mode 100644
index 0000000..4ea3e44
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/skipws.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& skipws(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::skipws(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::skipws);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp
new file mode 100644
index 0000000..99a33c7
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/unitbuf.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& unitbuf(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::unitbuf(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::unitbuf);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp
new file mode 100644
index 0000000..1a19e2a
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/fmtflags.manip/uppercase.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// class ios_base
+
+// ios_base& uppercase(ios_base& str);
+
+#include <ios>
+#include <streambuf>
+#include <cassert>
+
+struct testbuf : public std::streambuf {};
+
+int main()
+{
+    testbuf sb;
+    std::ios ios(&sb);
+    std::ios_base& r = std::uppercase(ios);
+    assert(&r == &ios);
+    assert(ios.flags() & std::ios::uppercase);
+}
diff --git a/final/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp b/final/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.base/std.ios.manip/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp b/final/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp
new file mode 100644
index 0000000..0e9f127
--- /dev/null
+++ b/final/test/input.output/iostreams.base/stream.types/streamoff.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// typedef OFF_T streamoff;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert(std::is_integral<std::streamoff>::value, "");
+    static_assert(std::is_signed<std::streamoff>::value, "");
+}
diff --git a/final/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp b/final/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp
new file mode 100644
index 0000000..438c511
--- /dev/null
+++ b/final/test/input.output/iostreams.base/stream.types/streamsize.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+// typedef SZ_T streamsize;
+
+#include <ios>
+#include <type_traits>
+
+int main()
+{
+    static_assert(std::is_integral<std::streamsize>::value, "");
+    static_assert(std::is_signed<std::streamsize>::value, "");
+}
diff --git a/final/test/input.output/iostreams.base/version.pass.cpp b/final/test/input.output/iostreams.base/version.pass.cpp
new file mode 100644
index 0000000..f56846d
--- /dev/null
+++ b/final/test/input.output/iostreams.base/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ios>
+
+#include <ios>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp b/final/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.requirements/iostream.limits.imbue/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp b/final/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.requirements/iostreams.limits.pos/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp b/final/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.requirements/iostreams.threadsafety/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp b/final/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/iostreams.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/nothing_to_do.pass.cpp b/final/test/input.output/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp b/final/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf.reqts/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
new file mode 100644
index 0000000..469c744
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf(const basic_streambuf& rhs);  // protected
+
+#include <streambuf>
+#include <cassert>
+
+std::streambuf get();
+
+int main()
+{
+    std::streambuf sb = get();
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp
new file mode 100644
index 0000000..c1e1839
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf(const basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    test() {}
+
+    test(const test& t)
+        : std::basic_streambuf<CharT>(t)
+    {
+        assert(this->eback() == t.eback());
+        assert(this->gptr()  == t.gptr());
+        assert(this->egptr() == t.egptr());
+        assert(this->pbase() == t.pbase());
+        assert(this->pptr()  == t.pptr());
+        assert(this->epptr() == t.epptr());
+        assert(this->getloc() == t.getloc());
+    }
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        test<char> t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2 = t;
+    }
+    {
+        char g1, g2, g3, p1, p3;
+        test<char> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<char> t2 = t;
+    }
+    {
+        wchar_t g1, g2, g3, p1, p3;
+        test<wchar_t> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<wchar_t> t2 = t;
+    }
+    std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+    {
+        test<char> t;
+        test<char> t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2 = t;
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp
new file mode 100644
index 0000000..7f57f3c
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf();  // is protected
+
+#include <streambuf>
+
+int main()
+{
+    std::basic_streambuf<char> sb;
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp
new file mode 100644
index 0000000..d8ca8ae
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf();
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test()
+    {
+        assert(this->eback() == 0);
+        assert(this->gptr() == 0);
+        assert(this->egptr() == 0);
+        assert(this->pbase() == 0);
+        assert(this->pptr() == 0);
+        assert(this->epptr() == 0);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.getloc().name() == "C");
+    }
+    {
+        test<wchar_t> t;
+        assert(t.getloc().name() == "C");
+    }
+    std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+    {
+        test<char> t;
+        assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+    }
+    {
+        test<wchar_t> t;
+        assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp
new file mode 100644
index 0000000..2c77f25
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekoff.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// pos_type pubseekoff(off_type off, ios_base::seekdir way,
+//                     ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubseekoff(0, std::ios_base::beg) == -1);
+        assert(t.pubseekoff(0, std::ios_base::beg, std::ios_base::app) == -1);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp
new file mode 100644
index 0000000..0b9ddff
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubseekpos.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// pos_type pubseekpos(pos_type sp,
+//                     ios_base::openmode which = ios_base::in | ios_base::out;
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubseekpos(0, std::ios_base::app) == -1);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp
new file mode 100644
index 0000000..8cf6277
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsetbuf.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf* pubsetbuf(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubsetbuf(0, 0) == &t);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp
new file mode 100644
index 0000000..cc16790
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.buffer/pubsync.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int pubsync();
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.pubsync() == 0);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp
new file mode 100644
index 0000000..2c4f22b
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.locales/locales.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// locale pubimbue(const locale& loc);
+// locale getloc() const;
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+
+    void imbue(const std::locale&)
+    {
+        assert(this->getloc().name() == LOCALE_en_US_UTF_8);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.getloc().name() == "C");
+    }
+    std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+    {
+        test<char> t;
+        assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+        assert(t.pubimbue(std::locale(LOCALE_fr_FR_UTF_8)).name() == "en_US.UTF-8");
+        assert(t.getloc().name() == LOCALE_fr_FR_UTF_8);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp
new file mode 100644
index 0000000..2001506
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/in_avail.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize in_avail();
+
+#include <streambuf>
+#include <cassert>
+
+int showmanyc_called = 0;
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+protected:
+    std::streamsize showmanyc()
+    {
+        ++showmanyc_called;
+        return 5;
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        assert(t.in_avail() == 5);
+        assert(showmanyc_called == 1);
+        char in[5];
+        t.setg(in, in+2, in+5);
+        assert(t.in_avail() == 3);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp
new file mode 100644
index 0000000..ac6d0cc
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sbumpc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sbumpc();
+
+#include <streambuf>
+#include <cassert>
+
+int uflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type uflow()
+    {
+        ++uflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(uflow_called == 0);
+        assert(t.sbumpc() == 'a');
+        assert(uflow_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in, in+sizeof(in));
+        assert(t.sbumpc() == 'A');
+        assert(uflow_called == 1);
+        assert(t.sbumpc() == 'B');
+        assert(uflow_called == 1);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp
new file mode 100644
index 0000000..c68930c
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sgetc();
+
+#include <streambuf>
+#include <cassert>
+
+int underflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type underflow()
+    {
+        ++underflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(underflow_called == 0);
+        assert(t.sgetc() == 'a');
+        assert(underflow_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in, in+sizeof(in));
+        assert(t.sgetc() == 'A');
+        assert(underflow_called == 1);
+        assert(t.sgetc() == 'A');
+        assert(underflow_called == 1);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp
new file mode 100644
index 0000000..730cede
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/sgetn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize sgetn(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+int xsgetn_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+
+protected:
+    std::streamsize xsgetn(char_type* s, std::streamsize n)
+    {
+        ++xsgetn_called;
+        return 10;
+    }
+};
+
+int main()
+{
+    test t;
+    assert(xsgetn_called == 0);
+    assert(t.sgetn(0, 0) == 10);
+    assert(xsgetn_called == 1);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp
new file mode 100644
index 0000000..7f44245
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.get/snextc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type snextc();
+
+#include <streambuf>
+#include <cassert>
+
+int uflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type uflow()
+    {
+        ++uflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(uflow_called == 0);
+        assert(t.snextc() == -1);
+        assert(uflow_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in, in+sizeof(in));
+        assert(t.snextc() == 'B');
+        assert(uflow_called == 1);
+        assert(t.snextc() == 'C');
+        assert(uflow_called == 1);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp
new file mode 100644
index 0000000..34a2a2d
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sputbackc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sputbackc(char_type c);
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type pbackfail(int_type c = traits_type::eof())
+    {
+        ++pbackfail_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(pbackfail_called == 0);
+        assert(t.sputbackc('A') == 'a');
+        assert(pbackfail_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in+1, in+sizeof(in));
+        assert(t.sputbackc('A') == 'A');
+        assert(pbackfail_called == 1);
+        assert(t.sputbackc('A') == 'a');
+        assert(pbackfail_called == 2);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp
new file mode 100644
index 0000000..4c68fad
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.pback/sungetc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sungetc();
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+protected:
+    int_type pbackfail(int_type c = traits_type::eof())
+    {
+        ++pbackfail_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(pbackfail_called == 0);
+        assert(t.sungetc() == 'a');
+        assert(pbackfail_called == 1);
+        char in[] = "ABC";
+        t.setg(in, in+1, in+sizeof(in));
+        assert(t.sungetc() == 'A');
+        assert(pbackfail_called == 1);
+        assert(t.sungetc() == 'a');
+        assert(pbackfail_called == 2);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp
new file mode 100644
index 0000000..b04b8b0
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputc.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type sputc(char_type c);
+
+#include <streambuf>
+#include <cassert>
+
+int overflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(char* pbeg, char* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+
+protected:
+    int_type overflow(int_type c = traits_type::eof())
+    {
+        ++overflow_called;
+        return 'a';
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        assert(overflow_called == 0);
+        assert(t.sputc('A') == 'a');
+        assert(overflow_called == 1);
+        char out[3] = {0};
+        t.setp(out, out+sizeof(out));
+        assert(t.sputc('A') == 'A');
+        assert(overflow_called == 1);
+        assert(out[0] == 'A');
+        assert(t.sputc('B') == 'B');
+        assert(overflow_called == 1);
+        assert(out[0] == 'A');
+        assert(out[1] == 'B');
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp
new file mode 100644
index 0000000..e03e8e0
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.members/streambuf.pub.put/sputn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize sputn(const char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+int xsputn_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+
+protected:
+    std::streamsize xsputn(const char_type* s, std::streamsize n)
+    {
+        ++xsputn_called;
+        return 5;
+    }
+};
+
+int main()
+{
+    test t;
+    assert(xsputn_called == 0);
+    assert(t.sputn(0, 0) == 5);
+    assert(xsputn_called == 1);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp
new file mode 100644
index 0000000..8031989
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// basic_streambuf& operator=(const basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    test() {}
+
+    test& operator=(const test& t)
+    {
+        base::operator=(t);
+        assert(this->eback() == t.eback());
+        assert(this->gptr()  == t.gptr());
+        assert(this->egptr() == t.egptr());
+        assert(this->pbase() == t.pbase());
+        assert(this->pptr()  == t.pptr());
+        assert(this->epptr() == t.epptr());
+        assert(this->getloc() == t.getloc());
+        return *this;
+    }
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        test<char> t2;
+        t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        t2 = t;
+    }
+    {
+        char g1, g2, g3, p1, p3;
+        test<char> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<char> t2;
+        t2 = t;
+    }
+    {
+        wchar_t g1, g2, g3, p1, p3;
+        test<wchar_t> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<wchar_t> t2;
+        t2 = t;
+    }
+    std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+    {
+        test<char> t;
+        test<char> t2;
+        t2 = t;
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        t2 = t;
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp
new file mode 100644
index 0000000..7a23206
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void swap(basic_streambuf& rhs);
+
+#include <streambuf>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+    test() {}
+
+    void swap(test& t)
+    {
+        test old_this(*this);
+        test old_that(t);
+        base::swap(t);
+        assert(this->eback() == old_that.eback());
+        assert(this->gptr()  == old_that.gptr());
+        assert(this->egptr() == old_that.egptr());
+        assert(this->pbase() == old_that.pbase());
+        assert(this->pptr()  == old_that.pptr());
+        assert(this->epptr() == old_that.epptr());
+        assert(this->getloc() == old_that.getloc());
+
+        assert(t.eback() == old_this.eback());
+        assert(t.gptr()  == old_this.gptr());
+        assert(t.egptr() == old_this.egptr());
+        assert(t.pbase() == old_this.pbase());
+        assert(t.pptr()  == old_this.pptr());
+        assert(t.epptr() == old_this.epptr());
+        assert(t.getloc() == old_this.getloc());
+        return *this;
+    }
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        test<char> t2;
+        swap(t2, t);
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        swap(t2, t);
+    }
+    {
+        char g1, g2, g3, p1, p3;
+        test<char> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<char> t2;
+        swap(t2, t);
+    }
+    {
+        wchar_t g1, g2, g3, p1, p3;
+        test<wchar_t> t;
+        t.setg(&g1, &g2, &g3);
+        t.setp(&p1, &p3);
+        test<wchar_t> t2;
+        swap(t2, t);
+    }
+    std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+    {
+        test<char> t;
+        test<char> t2;
+        swap(t2, t);
+    }
+    {
+        test<wchar_t> t;
+        test<wchar_t> t2;
+        swap(t2, t);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp
new file mode 100644
index 0000000..ce25a19
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/gbump.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void gbump(int n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+
+    void gbump(int n)
+    {
+        CharT* gbeg = base::eback();
+        CharT* gnext = base::gptr();
+        CharT* gend = base::egptr();
+        base::gbump(n);
+        assert(base::eback() == gbeg);
+        assert(base::gptr() == gnext+n);
+        assert(base::egptr() == gend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABCDE";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+        t.gbump(2);
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABCDE";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+        t.gbump(3);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp
new file mode 100644
index 0000000..68dcf6e
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.get.area/setg.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void setg(char_type* gbeg, char_type* gnext, char_type* gend);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setg(CharT* gbeg, CharT* gnext, CharT* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+        assert(base::eback() == gbeg);
+        assert(base::gptr() == gnext);
+        assert(base::egptr() == gend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABC";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABC";
+        t.setg(in, in+1, in+sizeof(in)/sizeof(in[0]));
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp
new file mode 100644
index 0000000..47ef939
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void pbump(int n);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+
+    void pbump(int n)
+    {
+        CharT* pbeg = base::pbase();
+        CharT* pnext = base::pptr();
+        CharT* pend = base::epptr();
+        base::pbump(n);
+        assert(base::pbase() == pbeg);
+        assert(base::pptr() == pnext+n);
+        assert(base::epptr() == pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABCDE";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+        t.pbump(2);
+        t.pbump(1);
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABCDE";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+        t.pbump(3);
+        t.pbump(1);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp
new file mode 100644
index 0000000..fa4133a
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/setp.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// void setp(char_type* pbeg, char_type* pend);
+
+#include <streambuf>
+#include <cassert>
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    typedef std::basic_streambuf<CharT> base;
+
+    test() {}
+
+    void setp(CharT* pbeg, CharT* pend)
+    {
+        base::setp(pbeg, pend);
+        assert(base::pbase() == pbeg);
+        assert(base::pptr() == pbeg);
+        assert(base::epptr() == pend);
+    }
+};
+
+int main()
+{
+    {
+        test<char> t;
+        char in[] = "ABC";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+    }
+    {
+        test<wchar_t> t;
+        wchar_t in[] = L"ABC";
+        t.setp(in, in+sizeof(in)/sizeof(in[0]));
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.buffer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp
new file mode 100644
index 0000000..acaf1e8
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/showmanyc.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize showmanyc();
+
+#include <streambuf>
+#include <cassert>
+
+int showmanyc_called = 0;
+
+template <class CharT>
+struct test
+    : public std::basic_streambuf<CharT>
+{
+    test() {}
+};
+
+int main()
+{
+    test<char> t;
+    assert(t.in_avail() == 0);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp
new file mode 100644
index 0000000..d25ae9b
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/uflow.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type uflow();
+
+#include <streambuf>
+#include <cassert>
+
+int underflow_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+
+};
+
+int main()
+{
+    test t;
+    assert(t.sgetc() == -1);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp
new file mode 100644
index 0000000..1bdba07
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/underflow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type underflow();
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+};
+
+int main()
+{
+    test t;
+    assert(t.sgetc() == -1);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
new file mode 100644
index 0000000..b1f1542
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.get/xsgetn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize xsgetn(char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setg(char* gbeg, char* gnext, char* gend)
+    {
+        base::setg(gbeg, gnext, gend);
+    }
+};
+
+int main()
+{
+    test t;
+    char input[7] = "123456";
+    t.setg(input, input, input+7);
+    char output[sizeof(input)] = {0};
+    assert(t.sgetn(output, 10) == 7);
+    assert(strcmp(input, output) == 0);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.locales/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp
new file mode 100644
index 0000000..3a10d8a
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.pback/pbackfail.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type pbackfail(int_type c = traits::eof());
+
+#include <streambuf>
+#include <cassert>
+
+int pbackfail_called = 0;
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+};
+
+int main()
+{
+    test t;
+    assert(t.sputbackc('A') == -1);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp
new file mode 100644
index 0000000..dcdd45f
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/overflow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// int_type overflow(int_type c = traits::eof());
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    test() {}
+};
+
+int main()
+{
+    test t;
+    assert(t.sputc('A') == -1);
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
new file mode 100644
index 0000000..93dc154
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/streambuf.virtuals/streambuf.virt.put/xsputn.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf;
+
+// streamsize xsputn(const char_type* s, streamsize n);
+
+#include <streambuf>
+#include <cassert>
+
+struct test
+    : public std::basic_streambuf<char>
+{
+    typedef std::basic_streambuf<char> base;
+
+    test() {}
+
+    void setp(char* pbeg, char* pend)
+    {
+        base::setp(pbeg, pend);
+    }
+};
+
+int main()
+{
+    {
+        test t;
+        char in[] = "123456";
+        assert(t.sputn(in, sizeof(in)) == 0);
+        char out[sizeof(in)] = {0};
+        t.setp(out, out+sizeof(out));
+        assert(t.sputn(in, sizeof(in)) == sizeof(in));
+        assert(strcmp(in, out) == 0);
+    }
+}
diff --git a/final/test/input.output/stream.buffers/streambuf/types.pass.cpp b/final/test/input.output/stream.buffers/streambuf/types.pass.cpp
new file mode 100644
index 0000000..919caee
--- /dev/null
+++ b/final/test/input.output/stream.buffers/streambuf/types.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+// template <class charT, class traits = char_traits<charT> >
+// class basic_streambuf
+// {
+// public:
+//     // types:
+//     typedef charT char_type;
+//     typedef traits traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+
+#include <streambuf>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::streambuf::char_type, char>::value), "");
+    static_assert((std::is_same<std::streambuf::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::streambuf::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::streambuf::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::streambuf::off_type, std::char_traits<char>::off_type>::value), "");
+
+    static_assert((std::is_same<std::wstreambuf::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::wstreambuf::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<std::wstreambuf::int_type, std::char_traits<wchar_t>::int_type>::value), "");
+    static_assert((std::is_same<std::wstreambuf::pos_type, std::char_traits<wchar_t>::pos_type>::value), "");
+    static_assert((std::is_same<std::wstreambuf::off_type, std::char_traits<wchar_t>::off_type>::value), "");
+}
diff --git a/final/test/input.output/stream.buffers/version.pass.cpp b/final/test/input.output/stream.buffers/version.pass.cpp
new file mode 100644
index 0000000..c4b06be
--- /dev/null
+++ b/final/test/input.output/stream.buffers/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <streambuf>
+
+#include <streambuf>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp b/final/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..fc5f2e7
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/istringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void swap(basic_istringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(" 789 321");
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(L" 789 321");
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+}
diff --git a/final/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp b/final/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..6e20640
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/istringstream.assign/move.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream& operator=(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp b/final/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..d72cef1
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/istringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// template <class charT, class traits, class Allocator>
+//   void
+//   swap(basic_istringstream<charT, traits, Allocator>& x,
+//        basic_istringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(" 789 321");
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(L" 789 321");
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss0 >> i;
+        assert(i == 789);
+        ss0 >> i;
+        assert(i == 321);
+    }
+}
diff --git a/final/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp b/final/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..5d44a50
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::istringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::wistringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+    {
+        std::wistringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+}
diff --git a/final/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp b/final/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..adc46ab
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/istringstream.cons/move.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// basic_istringstream(basic_istringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::istringstream ss0(" 123 456");
+        std::istringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss0(L" 123 456");
+        std::wistringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp b/final/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..9779236
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/istringstream.cons/string.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// explicit basic_istringstream(const basic_string<charT,traits,allocator>& str,
+//                              ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::istringstream ss(" 123 456", std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+    {
+        std::wistringstream ss(L" 123 456", std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+    }
+}
diff --git a/final/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp b/final/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp
new file mode 100644
index 0000000..448a6f8
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/istringstream.members/str.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss.str(" 789");
+        ss.clear();
+        assert(ss.good());
+        assert(ss.str() == " 789");
+        ss >> i;
+        assert(i == 789);
+    }
+    {
+        std::wistringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss.str(L" 789");
+        ss.clear();
+        assert(ss.good());
+        assert(ss.str() == L" 789");
+        ss >> i;
+        assert(i == 789);
+    }
+}
diff --git a/final/test/input.output/string.streams/istringstream/types.pass.cpp b/final/test/input.output/string.streams/istringstream/types.pass.cpp
new file mode 100644
index 0000000..349bcae
--- /dev/null
+++ b/final/test/input.output/string.streams/istringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_istringstream
+//     : public basic_istream<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_istream<char>, std::basic_istringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_istringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/final/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp b/final/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..eff4745
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/ostringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == "234 567");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == L"234 567");
+    }
+}
diff --git a/final/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp b/final/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..a6fb8ba
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/ostringstream.assign/move.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// basic_ostringstream& operator=(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp b/final/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..3d7081d
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/ostringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void swap(basic_ostringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == "234 567");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+        ss0 << i << ' ' << 567;;
+        assert(ss0.str() == L"234 567");
+    }
+}
diff --git a/final/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp b/final/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..dde1dc7
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// explicit basic_ostringstream(ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::ostringstream ss(std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::wostringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+    {
+        std::wostringstream ss(std::ios_base::out);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+}
diff --git a/final/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp b/final/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..dc63b59
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/ostringstream.cons/move.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// basic_ostringstream(basic_ostringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::ostringstream ss0(" 123 456");
+        std::ostringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::wostringstream ss0(L" 123 456");
+        std::wostringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp b/final/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..89c91bd
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/ostringstream.cons/string.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// explicit basic_ostringstream(const basic_string<charT,traits,allocator>& str,
+//                              ios_base::openmode which = ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::ostringstream ss(" 123 456", std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == "234 5676");
+    }
+    {
+        std::wostringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+    {
+        std::wostringstream ss(L" 123 456", std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 234;
+        ss << i << ' ' << 567;;
+        assert(ss.str() == L"234 5676");
+    }
+}
diff --git a/final/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp b/final/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
new file mode 100644
index 0000000..ab277a2
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/ostringstream.members/str.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream ss(" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456");
+        int i = 0;
+        ss << i;
+        assert(ss.str() == "0123 456");
+        ss << 456;
+        assert(ss.str() == "0456 456");
+        ss.str(" 789");
+        assert(ss.str() == " 789");
+        ss << "abc";
+        assert(ss.str() == "abc9");
+    }
+    {
+        std::wostringstream ss(L" 123 456");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456");
+        int i = 0;
+        ss << i;
+        assert(ss.str() == L"0123 456");
+        ss << 456;
+        assert(ss.str() == L"0456 456");
+        ss.str(L" 789");
+        assert(ss.str() == L" 789");
+        ss << L"abc";
+        assert(ss.str() == L"abc9");
+    }
+}
diff --git a/final/test/input.output/string.streams/ostringstream/types.pass.cpp b/final/test/input.output/string.streams/ostringstream/types.pass.cpp
new file mode 100644
index 0000000..c9cb763
--- /dev/null
+++ b/final/test/input.output/string.streams/ostringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_ostringstream
+//     : public basic_ostream<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_ostream<char>, std::basic_ostringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_ostringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..eaca724
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.assign/member_swap.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void swap(basic_stringbuf& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        buf.swap(buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
new file mode 100644
index 0000000..716b6af
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.assign/move.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf& operator=(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        buf = move(buf1);
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..dca637d
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// template <class charT, class traits, class Allocator>
+//   void swap(basic_stringbuf<charT, traits, Allocator>& x,
+//             basic_stringbuf<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == "testing");
+        assert(buf1.str() == "");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf;
+        swap(buf, buf1);
+        assert(buf.str() == L"testing");
+        assert(buf1.str() == L"");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
new file mode 100644
index 0000000..28007c8
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf;
+        assert(buf.str() == "");
+    }
+    {
+        std::wstringbuf buf;
+        assert(buf.str() == L"");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
new file mode 100644
index 0000000..14fd0ca
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_stringbuf(basic_stringbuf&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf1("testing");
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::in);
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf1("testing", std::ios_base::out);
+        std::stringbuf buf(move(buf1));
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing");
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::in);
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf1(L"testing", std::ios_base::out);
+        std::wstringbuf buf(move(buf1));
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp
new file mode 100644
index 0000000..eae1b0b
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.cons/string.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// explicit basic_stringbuf(const basic_string<charT,traits,Allocator>& s,
+//                          ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf("testing");
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf("testing", std::ios_base::in);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::stringbuf buf("testing", std::ios_base::out);
+        assert(buf.str() == "testing");
+    }
+    {
+        std::wstringbuf buf(L"testing");
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf(L"testing", std::ios_base::in);
+        assert(buf.str() == L"testing");
+    }
+    {
+        std::wstringbuf buf(L"testing", std::ios_base::out);
+        assert(buf.str() == L"testing");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
new file mode 100644
index 0000000..712e0ed
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.members/str.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// void str(const basic_string<charT,traits,Allocator>& s);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf buf("testing");
+        assert(buf.str() == "testing");
+        buf.str("another test");
+        assert(buf.str() == "another test");
+    }
+    {
+        std::wstringbuf buf(L"testing");
+        assert(buf.str() == L"testing");
+        buf.str(L"another test");
+        assert(buf.str() == L"another test");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
new file mode 100644
index 0000000..3abf942
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type overflow(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+int overflow_called = 0;
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str,
+                     std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+        : base(str, which) {}
+
+    typename base::int_type
+        overflow(typename base::int_type c = base::type_traits::eof())
+        {++overflow_called; return base::overflow(c);}
+
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("abc");
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "1bc");
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == "12c");
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "123");
+        assert(sb.sputc('4') == '4');
+        assert(sb.str() == "1234");
+        assert(sb.sputc('5') == '5');
+        assert(sb.str() == "12345");
+        assert(sb.sputc('6') == '6');
+        assert(sb.str() == "123456");
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == "1234567");
+        assert(sb.sputc('8') == '8');
+        assert(sb.str() == "12345678");
+        assert(sb.sputc('9') == '9');
+        assert(sb.str() == "123456789");
+        assert(sb.sputc('0') == '0');
+        assert(sb.str() == "1234567890");
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "12345678901");
+    }
+    {
+        testbuf<wchar_t> sb(L"abc");
+        assert(sb.sputc(L'1') == L'1');
+        assert(sb.str() == L"1bc");
+        assert(sb.sputc(L'2') == L'2');
+        assert(sb.str() == L"12c");
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"123");
+        assert(sb.sputc(L'4') == L'4');
+        assert(sb.str() == L"1234");
+        assert(sb.sputc(L'5') == L'5');
+        assert(sb.str() == L"12345");
+        assert(sb.sputc(L'6') == L'6');
+        assert(sb.str() == L"123456");
+        assert(sb.sputc(L'7') == L'7');
+        assert(sb.str() == L"1234567");
+        assert(sb.sputc(L'8') == L'8');
+        assert(sb.str() == L"12345678");
+        assert(sb.sputc(L'9') == L'9');
+        assert(sb.str() == L"123456789");
+        assert(sb.sputc(L'0') == L'0');
+        assert(sb.str() == L"1234567890");
+        assert(sb.sputc(L'1') == L'1');
+        assert(sb.str() == L"12345678901");
+    }
+    {
+        testbuf<char> sb("abc", std::ios_base::app | std::ios_base::out);
+        assert(sb.sputc('1') == '1');
+        assert(sb.str() == "abc1");
+        assert(sb.sputc('2') == '2');
+        assert(sb.str() == "abc12");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
new file mode 100644
index 0000000..4af0e63
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type pbackfail(int_type c = traits::eof());
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str,
+                     std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
+        : base(str, which) {}
+
+    typename base::int_type
+        pbackfail(typename base::int_type c = base::type_traits::eof())
+        {return base::pbackfail(c);}
+
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("123", std::ios_base::in);
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == std::char_traits<char>::eof());
+        assert(sb.pbackfail('2') == '2');
+        assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+        assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+        assert(sb.str() == "123");
+    }
+    {
+        testbuf<char> sb("123");
+        assert(sb.sgetc() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.sgetc() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail('3') == '3');
+        assert(sb.pbackfail(std::char_traits<char>::eof()) != std::char_traits<char>::eof());
+        assert(sb.pbackfail(std::char_traits<char>::eof()) == std::char_traits<char>::eof());
+        assert(sb.str() == "133");
+    }
+    {
+        testbuf<wchar_t> sb(L"123", std::ios_base::in);
+        assert(sb.sgetc() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.sgetc() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(L'3') == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'2') == L'2');
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+        assert(sb.str() == L"123");
+    }
+    {
+        testbuf<wchar_t> sb(L"123");
+        assert(sb.sgetc() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.sgetc() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(L'3') == L'3');
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) != std::char_traits<wchar_t>::eof());
+        assert(sb.pbackfail(std::char_traits<wchar_t>::eof()) == std::char_traits<wchar_t>::eof());
+        assert(sb.str() == L"133");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
new file mode 100644
index 0000000..6d20db1
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekoff.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789", std::ios_base::in);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+    }
+    {
+        std::stringbuf sb("0123456789", std::ios_base::out);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('b') == 'b');
+        assert(sb.str() == "012a456b89");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "012a456c89");
+    }
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == '6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.sgetc() == '7');
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "012a456c89");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "0123456c89");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc('7') == '7');
+        assert(sb.str() == "0123456789");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc('c') == 'c');
+        assert(sb.str() == "0123456c89");
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::in);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == L'6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::out);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc(L'b') == L'b');
+        assert(sb.str() == L"012a456b89");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"012a456c89");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::in) == 6);
+        assert(sb.sgetc() == L'6');
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out | std::ios_base::in) == 7);
+        assert(sb.sgetc() == L'7');
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"012a456c89");
+        assert(sb.pubseekoff(3, std::ios_base::beg, std::ios_base::out) == 3);
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"0123456c89");
+        assert(sb.pubseekoff(3, std::ios_base::cur, std::ios_base::out) == 7);
+        assert(sb.sputc(L'7') == L'7');
+        assert(sb.str() == L"0123456789");
+        assert(sb.pubseekoff(-3, std::ios_base::end, std::ios_base::out) == 7);
+        assert(sb.sputc(L'c') == L'c');
+        assert(sb.str() == L"0123456c89");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
new file mode 100644
index 0000000..2b809a8
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/seekpos.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// pos_type seekpos(pos_type sp,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789", std::ios_base::in);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+    }
+    {
+        std::stringbuf sb("0123456789", std::ios_base::out);
+        assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+    }
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == '3');
+        assert(sb.sputc('a') == 'a');
+        assert(sb.str() == "012a456789");
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc('3') == '3');
+        assert(sb.str() == "0123456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::in);
+        assert(sb.pubseekpos(3, std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in | std::ios_base::out) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+    }
+    {
+        std::wstringbuf sb(L"0123456789", std::ios_base::out);
+        assert(sb.pubseekpos(3, std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == -1);
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubseekpos(3, std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.pubseekpos(3, std::ios_base::out | std::ios_base::in) == 3);
+        assert(sb.sgetc() == L'3');
+        assert(sb.sputc(L'a') == L'a');
+        assert(sb.str() == L"012a456789");
+        assert(sb.pubseekpos(3, std::ios_base::out) == 3);
+        assert(sb.sputc(L'3') == L'3');
+        assert(sb.str() == L"0123456789");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp
new file mode 100644
index 0000000..7130f5b
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/setbuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// basic_streambuf<charT,traits>* setbuf(charT* s, streamsize n);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringbuf sb("0123456789");
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == "0123456789");
+    }
+    {
+        std::wstringbuf sb(L"0123456789");
+        assert(sb.pubsetbuf(0, 0) == &sb);
+        assert(sb.str() == L"0123456789");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
new file mode 100644
index 0000000..3641af2
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/stringbuf.virtuals/underflow.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+
+// int_type underflow();
+
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+struct testbuf
+    : public std::basic_stringbuf<CharT>
+{
+    typedef std::basic_stringbuf<CharT> base;
+    explicit testbuf(const std::basic_string<CharT>& str)
+        : base(str) {}
+
+    typename base::int_type underflow() {return base::underflow();}
+    void pbump(int n) {base::pbump(n);}
+};
+
+int main()
+{
+    {
+        testbuf<char> sb("123");
+        sb.pbump(3);
+        assert(sb.underflow() == '1');
+        assert(sb.underflow() == '1');
+        assert(sb.snextc() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.underflow() == '2');
+        assert(sb.snextc() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.underflow() == '3');
+        assert(sb.snextc() == std::char_traits<char>::eof());
+        assert(sb.underflow() == std::char_traits<char>::eof());
+        assert(sb.underflow() == std::char_traits<char>::eof());
+        sb.sputc('4');
+        assert(sb.underflow() == '4');
+        assert(sb.underflow() == '4');
+    }
+    {
+        testbuf<wchar_t> sb(L"123");
+        sb.pbump(3);
+        assert(sb.underflow() == L'1');
+        assert(sb.underflow() == L'1');
+        assert(sb.snextc() == L'2');
+        assert(sb.underflow() == L'2');
+        assert(sb.underflow() == L'2');
+        assert(sb.snextc() == L'3');
+        assert(sb.underflow() == L'3');
+        assert(sb.underflow() == L'3');
+        assert(sb.snextc() == std::char_traits<wchar_t>::eof());
+        assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+        assert(sb.underflow() == std::char_traits<wchar_t>::eof());
+        sb.sputc(L'4');
+        assert(sb.underflow() == L'4');
+        assert(sb.underflow() == L'4');
+    }
+}
diff --git a/final/test/input.output/string.streams/stringbuf/types.pass.cpp b/final/test/input.output/string.streams/stringbuf/types.pass.cpp
new file mode 100644
index 0000000..067a3a2
--- /dev/null
+++ b/final/test/input.output/string.streams/stringbuf/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringbuf
+//     : public basic_streambuf<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_streambuf<char>, std::basic_stringbuf<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_stringbuf<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/final/test/input.output/string.streams/stringstream.cons/default.pass.cpp b/final/test/input.output/string.streams/stringstream.cons/default.pass.cpp
new file mode 100644
index 0000000..b8905ad
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.cons/default.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::stringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == "");
+    }
+    {
+        std::wstringstream ss;
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+    {
+        std::wstringstream ss(std::ios_base::in);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L"");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringstream.cons/move.pass.cpp b/final/test/input.output/string.streams/stringstream.cons/move.pass.cpp
new file mode 100644
index 0000000..4ae3aa6
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.cons/move.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss(std::move(ss0));
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/string.streams/stringstream.cons/move2.pass.cpp b/final/test/input.output/string.streams/stringstream.cons/move2.pass.cpp
new file mode 100644
index 0000000..856cf3c
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.cons/move2.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <vector>
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::vector<std::istringstream> vecis;
+    vecis.push_back(std::istringstream());
+    vecis.back().str("hub started at [00 6b 8b 45 69]");
+    vecis.push_back(std::istringstream());
+    vecis.back().str("hub started at [00 6b 8b 45 69]");
+    for (int n = 0; n < vecis.size(); n++)
+    {
+        assert(vecis[n].str().size() == 31);
+        vecis[n].seekg(0, std::ios_base::beg);
+        assert(vecis[n].str().size() == 31);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/string.streams/stringstream.cons/string.pass.cpp b/final/test/input.output/string.streams/stringstream.cons/string.pass.cpp
new file mode 100644
index 0000000..3776f17
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.cons/string.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// explicit basic_stringstream(const basic_string<charT,traits,Allocator>& str,
+//                             ios_base::openmode which = ios_base::out|ios_base::in);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss(" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+    }
+    {
+        std::wstringstream ss(L" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp b/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
new file mode 100644
index 0000000..95599dd
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/member_swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void swap(basic_stringstream& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == "456 123");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss;
+        ss.swap(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == L"456 123");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp b/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
new file mode 100644
index 0000000..ccaf72d
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/move.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// basic_stringstream& operator=(basic_stringstream&& rhs);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss;
+        ss = std::move(ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp b/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..3ec11cd
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.cons/stringstream.assign/nonmember_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// template <class charT, class traits, class Allocator>
+//   void
+//   swap(basic_stringstream<charT, traits, Allocator>& x,
+//        basic_stringstream<charT, traits, Allocator>& y);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss0(" 123 456 ");
+        std::stringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == "456 123");
+    }
+    {
+        std::wstringstream ss0(L" 123 456 ");
+        std::wstringstream ss;
+        swap(ss, ss0);
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+        ss0 << i << ' ' << 123;
+        assert(ss0.str() == L"456 123");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringstream.members/str.pass.cpp b/final/test/input.output/string.streams/stringstream.members/str.pass.cpp
new file mode 100644
index 0000000..155a262
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream.members/str.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+
+// void str(const basic_string<charT,traits,Allocator>& str);
+
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::stringstream ss(" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == " 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == "456 1236 ");
+        ss.str("5466 89 ");
+        ss >> i;
+        assert(i == 5466);
+        ss >> i;
+        assert(i == 89);
+        ss << i << ' ' << 321;
+        assert(ss.str() == "89 3219 ");
+    }
+    {
+        std::wstringstream ss(L" 123 456 ");
+        assert(ss.rdbuf() != 0);
+        assert(ss.good());
+        assert(ss.str() == L" 123 456 ");
+        int i = 0;
+        ss >> i;
+        assert(i == 123);
+        ss >> i;
+        assert(i == 456);
+        ss << i << ' ' << 123;
+        assert(ss.str() == L"456 1236 ");
+        ss.str(L"5466 89 ");
+        ss >> i;
+        assert(i == 5466);
+        ss >> i;
+        assert(i == 89);
+        ss << i << ' ' << 321;
+        assert(ss.str() == L"89 3219 ");
+    }
+}
diff --git a/final/test/input.output/string.streams/stringstream/types.pass.cpp b/final/test/input.output/string.streams/stringstream/types.pass.cpp
new file mode 100644
index 0000000..a89daa1
--- /dev/null
+++ b/final/test/input.output/string.streams/stringstream/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
+// class basic_stringstream
+//     : public basic_iostream<charT, traits>
+// {
+// public:
+//     typedef charT                          char_type;
+//     typedef traits                         traits_type;
+//     typedef typename traits_type::int_type int_type;
+//     typedef typename traits_type::pos_type pos_type;
+//     typedef typename traits_type::off_type off_type;
+//     typedef Allocator                      allocator_type;
+
+#include <sstream>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::basic_iostream<char>, std::basic_stringstream<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::int_type, std::char_traits<char>::int_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::pos_type, std::char_traits<char>::pos_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::off_type, std::char_traits<char>::off_type>::value), "");
+    static_assert((std::is_same<std::basic_stringstream<char>::allocator_type, std::allocator<char> >::value), "");
+}
diff --git a/final/test/input.output/string.streams/version.pass.cpp b/final/test/input.output/string.streams/version.pass.cpp
new file mode 100644
index 0000000..1038971
--- /dev/null
+++ b/final/test/input.output/string.streams/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <sstream>
+
+#include <sstream>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp b/final/test/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
new file mode 100644
index 0000000..26d5c86
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Category, class T, class Distance = ptrdiff_t,
+//          class Pointer = T*, class Reference = T&>
+// struct iterator
+// {
+//   typedef T         value_type;
+//   typedef Distance  difference_type;
+//   typedef Pointer   pointer;
+//   typedef Reference reference;
+//   typedef Category  iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+template <class T>
+void
+test2()
+{
+    typedef std::iterator<std::forward_iterator_tag, T> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<typename It::pointer, T*>::value), "");
+    static_assert((std::is_same<typename It::reference, T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test3()
+{
+    typedef std::iterator<std::bidirectional_iterator_tag, T, short> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, short>::value), "");
+    static_assert((std::is_same<typename It::pointer, T*>::value), "");
+    static_assert((std::is_same<typename It::reference, T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::bidirectional_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test4()
+{
+    typedef std::iterator<std::random_access_iterator_tag, T, int, const T*> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, int>::value), "");
+    static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+    static_assert((std::is_same<typename It::reference, T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test5()
+{
+    typedef std::iterator<std::input_iterator_tag, T, long, const T*, const T&> It;
+    static_assert((std::is_same<typename It::value_type, T>::value), "");
+    static_assert((std::is_same<typename It::difference_type, long>::value), "");
+    static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+    static_assert((std::is_same<typename It::reference, const T&>::value), "");
+    static_assert((std::is_same<typename It::iterator_category, std::input_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test2<A>();
+    test3<A>();
+    test4<A>();
+    test5<A>();
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.operations/advance.pass.cpp b/final/test/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
new file mode 100644
index 0000000..e395da2
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+//   void advance(Iter& i, Iter::difference_type n);
+//
+// template <BidirectionalIterator Iter>
+//   void advance(Iter& i, Iter::difference_type n);
+//
+// template <RandomAccessIterator Iter>
+//   void advance(Iter& i, Iter::difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::advance(i, n);
+    assert(i == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10));
+    test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+    test(bidirectional_iterator<const char*>(s+5), 5, bidirectional_iterator<const char*>(s+10));
+    test(bidirectional_iterator<const char*>(s+5), -5, bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(random_access_iterator<const char*>(s+5), -5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s+10);
+    test(s+5, -5, s);
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.operations/distance.pass.cpp b/final/test/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
new file mode 100644
index 0000000..7fef635
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+//   Iter::difference_type
+//   distance(Iter first, Iter last);
+//
+// template <RandomAccessIterator Iter>
+//   Iter::difference_type
+//   distance(Iter first, Iter last);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It first, It last, typename std::iterator_traits<It>::difference_type x)
+{
+    assert(std::distance(first, last) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10);
+    test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+10), 10);
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+10), 10);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10);
+    test(s, s+10, 10);
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.operations/next.pass.cpp b/final/test/iterators/iterator.primitives/iterator.operations/next.pass.cpp
new file mode 100644
index 0000000..f584110
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+//   Iter next(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    assert(std::next(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+    assert(std::next(i) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+    test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10));
+    test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10));
+    test(s, 10, s+10);
+
+    test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1));
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1));
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1));
+    test(s, s+1);
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.operations/prev.pass.cpp b/final/test/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
new file mode 100644
index 0000000..0641706
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BidirectionalIterator Iter>
+//   Iter prev(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    assert(std::prev(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+    assert(std::prev(i) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+10), 10, random_access_iterator<const char*>(s));
+    test(s+10, 10, s);
+
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+    test(s+1, s);
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp b/final/test/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
new file mode 100644
index 0000000..f40754f
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<const T*>
+// {
+//   typedef ptrdiff_t                  difference_type;
+//   typedef T                          value_type;
+//   typedef const T*                   pointer;
+//   typedef const T&                   reference;
+//   typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    typedef std::iterator_traits<const A*> It;
+    static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<It::value_type, A>::value), "");
+    static_assert((std::is_same<It::pointer, const A*>::value), "");
+    static_assert((std::is_same<It::reference, const A&>::value), "");
+    static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp b/final/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
new file mode 100644
index 0000000..0da7f84
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class NotAnIterator>
+// struct iterator_traits
+// {
+// };
+
+#include <iterator>
+
+struct not_an_iterator
+{
+};
+
+int main()
+{
+    typedef std::iterator_traits<not_an_iterator> It;
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp b/final/test/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
new file mode 100644
index 0000000..38f7c0b
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Iter>
+// struct iterator_traits
+// {
+//   typedef typename Iter::difference_type difference_type;
+//   typedef typename Iter::value_type value_type;
+//   typedef typename Iter::pointer pointer;
+//   typedef typename Iter::reference reference;
+//   typedef typename Iter::iterator_category iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+struct test_iterator
+{
+    typedef int                       difference_type;
+    typedef A                         value_type;
+    typedef A*                        pointer;
+    typedef A&                        reference;
+    typedef std::forward_iterator_tag iterator_category;
+};
+
+int main()
+{
+    typedef std::iterator_traits<test_iterator> It;
+    static_assert((std::is_same<It::difference_type, int>::value), "");
+    static_assert((std::is_same<It::value_type, A>::value), "");
+    static_assert((std::is_same<It::pointer, A*>::value), "");
+    static_assert((std::is_same<It::iterator_category, std::forward_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp b/final/test/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
new file mode 100644
index 0000000..5a8fe60
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<T*>
+// {
+//   typedef ptrdiff_t                  difference_type;
+//   typedef T                          value_type;
+//   typedef T*                         pointer;
+//   typedef T&                         reference;
+//   typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    typedef std::iterator_traits<A*> It;
+    static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<It::value_type, A>::value), "");
+    static_assert((std::is_same<It::pointer, A*>::value), "");
+    static_assert((std::is_same<It::reference, A&>::value), "");
+    static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.primitives/nothing_to_do.pass.cpp b/final/test/iterators/iterator.primitives/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp b/final/test/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
new file mode 100644
index 0000000..0f368c3
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct bidirectional_iterator_tag : public forward_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::bidirectional_iterator_tag tag;
+    static_assert((std::is_base_of<std::forward_iterator_tag,
+                                   std::bidirectional_iterator_tag>::value), "");
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::bidirectional_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp b/final/test/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
new file mode 100644
index 0000000..0936595
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct forward_iterator_tag: public input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::forward_iterator_tag tag;
+    static_assert((std::is_base_of<std::input_iterator_tag,
+                                   std::forward_iterator_tag>::value), "");
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::forward_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp b/final/test/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
new file mode 100644
index 0000000..afeac3e
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::input_iterator_tag tag;
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::input_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp b/final/test/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
new file mode 100644
index 0000000..7f7f66a
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct output_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::output_iterator_tag tag;
+    static_assert((!std::is_base_of<std::input_iterator_tag,
+                                    std::output_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp b/final/test/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
new file mode 100644
index 0000000..04f830b
--- /dev/null
+++ b/final/test/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    std::random_access_iterator_tag tag;
+    static_assert((std::is_base_of<std::bidirectional_iterator_tag,
+                                   std::random_access_iterator_tag>::value), "");
+    static_assert((!std::is_base_of<std::output_iterator_tag,
+                                    std::random_access_iterator_tag>::value), "");
+}
diff --git a/final/test/iterators/iterator.range/begin-end.pass.cpp b/final/test/iterators/iterator.range/begin-end.pass.cpp
new file mode 100644
index 0000000..abb6433
--- /dev/null
+++ b/final/test/iterators/iterator.range/begin-end.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> auto begin(C& c) -> decltype(c.begin());
+// template <class C> auto begin(const C& c) -> decltype(c.begin());
+// template <class C> auto end(C& c) -> decltype(c.end());
+// template <class C> auto end(const C& c) -> decltype(c.end());
+// template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il);
+// template <class E> reverse_iterator<const E*> rend(initializer_list<E> il);
+
+#include <__config>
+
+#if __cplusplus >= 201103L
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <list>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C & c, typename C::value_type val ) {
+    assert ( std::begin(c)   == c.begin());
+    assert (*std::begin(c)   ==  val );
+    assert ( std::begin(c)   != c.end());
+    assert ( std::end(c)     == c.end());
+#if _LIBCPP_STD_VER > 11
+    assert ( std::cbegin(c)  == c.cbegin());
+    assert ( std::cbegin(c)  != c.cend());
+    assert ( std::cend(c)    == c.cend());
+    assert ( std::rbegin(c)  == c.rbegin());
+    assert ( std::rbegin(c)  != c.rend());
+    assert ( std::rend(c)    == c.rend());
+    assert ( std::crbegin(c) == c.crbegin());
+    assert ( std::crbegin(c) != c.crend());
+    assert ( std::crend(c)   == c.crend());
+#endif
+    }
+
+template<typename T>
+void test_const_container( const std::initializer_list<T> & c, T val ) {
+    assert ( std::begin(c)   == c.begin());
+    assert (*std::begin(c)   ==  val );
+    assert ( std::begin(c)   != c.end());
+    assert ( std::end(c)     == c.end());
+#if _LIBCPP_STD_VER > 11
+//  initializer_list doesn't have cbegin/cend/rbegin/rend
+//  but std::cbegin(),etc work (b/c they're general fn templates)
+//     assert ( std::cbegin(c)  == c.cbegin());
+//     assert ( std::cbegin(c)  != c.cend());
+//     assert ( std::cend(c)    == c.cend());
+//     assert ( std::rbegin(c)  == c.rbegin());
+//     assert ( std::rbegin(c)  != c.rend());
+//     assert ( std::rend(c)    == c.rend());
+//     assert ( std::crbegin(c) == c.crbegin());
+//     assert ( std::crbegin(c) != c.crend());
+//     assert ( std::crend(c)   == c.crend());
+#endif
+    }
+
+template<typename C>
+void test_container( C & c, typename C::value_type val ) {
+    assert ( std::begin(c)   == c.begin());
+    assert (*std::begin(c)   ==  val );
+    assert ( std::begin(c)   != c.end());
+    assert ( std::end(c)     == c.end());
+#if _LIBCPP_STD_VER > 11
+    assert ( std::cbegin(c)  == c.cbegin());
+    assert ( std::cbegin(c)  != c.cend());
+    assert ( std::cend(c)    == c.cend());
+    assert ( std::rbegin(c)  == c.rbegin());
+    assert ( std::rbegin(c)  != c.rend());
+    assert ( std::rend(c)    == c.rend());
+    assert ( std::crbegin(c) == c.crbegin());
+    assert ( std::crbegin(c) != c.crend());
+    assert ( std::crend(c)   == c.crend());
+#endif
+    }
+    
+template<typename T>
+void test_container( std::initializer_list<T> & c, T val ) {
+    assert ( std::begin(c)   == c.begin());
+    assert (*std::begin(c)   ==  val );
+    assert ( std::begin(c)   != c.end());
+    assert ( std::end(c)     == c.end());
+#if _LIBCPP_STD_VER > 11
+//  initializer_list doesn't have cbegin/cend/rbegin/rend
+//     assert ( std::cbegin(c)  == c.cbegin());
+//     assert ( std::cbegin(c)  != c.cend());
+//     assert ( std::cend(c)    == c.cend());
+//     assert ( std::rbegin(c)  == c.rbegin());
+//     assert ( std::rbegin(c)  != c.rend());
+//     assert ( std::rend(c)    == c.rend());
+//     assert ( std::crbegin(c) == c.crbegin());
+//     assert ( std::crbegin(c) != c.crend());
+//     assert ( std::crend(c)   == c.crend());
+#endif
+    }
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] ) {
+    assert ( std::begin(array)  == array );
+    assert (*std::begin(array)  ==  array[0] );
+    assert ( std::begin(array)  != std::end(array));
+    assert ( std::end(array)    == array + Sz);
+#if _LIBCPP_STD_VER > 11
+    assert ( std::cbegin(array) == array );
+    assert (*std::cbegin(array) == array[0] );
+    assert ( std::cbegin(array) != std::cend(array));
+    assert ( std::cend(array)   == array + Sz);
+#endif
+    }
+
+int main(){
+    std::vector<int> v; v.push_back(1);
+    std::list<int> l;   l.push_back(2);
+    std::array<int, 1> a; a[0] = 3;
+    std::initializer_list<int> il = { 4 };
+    
+    test_container ( v, 1 );
+    test_container ( l, 2 );
+    test_container ( a, 3 );
+    test_container ( il, 4 );
+
+    test_const_container ( v, 1 );
+    test_const_container ( l, 2 );
+    test_const_container ( a, 3 );
+    test_const_container ( il, 4 );
+    
+    static constexpr int arrA [] { 1, 2, 3 };
+    test_const_array ( arrA );
+#if _LIBCPP_STD_VER > 11
+    constexpr const int *b = std::cbegin(arrA);
+    constexpr const int *e = std::cend(arrA);
+    static_assert(e - b == 3, "");
+#endif
+}
+
+#else
+int main(){}
+#endif
diff --git a/final/test/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.requirements/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp b/final/test/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterator.synopsis/nothing_to_do.pass.cpp b/final/test/iterators/iterator.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterator.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/iterators.general/nothing_to_do.pass.cpp b/final/test/iterators/iterators.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/iterators.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
new file mode 100644
index 0000000..5dd49a6
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <vector>
+
+int main()
+{
+    std::back_insert_iterator<std::vector<int> > i = std::vector<int>();
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
new file mode 100644
index 0000000..f280adb
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <vector>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..c6ff047
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    std::back_insert_iterator<C> r = i++;
+    r = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..2b9f245
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    std::back_insert_iterator<C>& r = ++i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000..d3d1fbb
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+//   back_insert_iterator<Cont>&
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    const typename C::value_type v = typename C::value_type();
+    std::back_insert_iterator<C> i(c);
+    i = v;
+    assert(c.back() == v);
+}
+
+class Copyable
+{
+    int data_;
+public:
+    Copyable() : data_(0) {}
+    ~Copyable() {data_ = -1;}
+
+    friend bool operator==(const Copyable& x, const Copyable& y)
+        {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    test(std::vector<Copyable>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000..a3c11f7
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+//   back_insert_iterator<Cont>&
+//   operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    i = typename C::value_type();
+    assert(c.back() == typename C::value_type());
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(std::vector<std::unique_ptr<int> >());
+#endif
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000..f50f309
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i(c);
+    std::back_insert_iterator<C>& r = *i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
new file mode 100644
index 0000000..30e4140
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont>
+//   back_insert_iterator<Cont>
+//   back_inserter(Cont& x);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::back_insert_iterator<C> i = std::back_inserter(c);
+    i = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
new file mode 100644
index 0000000..2611c9a
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// Test nested types and data member:
+
+// template <BackInsertionContainer Cont>
+// class back_insert_iterator {
+// protected:
+//   Cont* container;
+// public:
+//   typedef Cont                        container_type;
+//   typedef void                        value_type;
+//   typedef void                        difference_type;
+//   typedef back_insert_iterator<Cont>& reference;
+//   typedef void                        pointer;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+    : private std::back_insert_iterator<C>
+{
+    explicit find_container(C& c) : std::back_insert_iterator<C>(c) {}
+    void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+    typedef std::back_insert_iterator<C> R;
+    C c;
+    find_container<C> q(c);
+    q.test();
+    static_assert((std::is_same<typename R::container_type, C>::value), "");
+    static_assert((std::is_same<typename R::value_type, void>::value), "");
+    static_assert((std::is_same<typename R::difference_type, void>::value), "");
+    static_assert((std::is_same<typename R::reference, R&>::value), "");
+    static_assert((std::is_same<typename R::pointer, void>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<std::vector<int> >();
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
new file mode 100644
index 0000000..96d5d00
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <list>
+
+int main()
+{
+    std::front_insert_iterator<std::list<int> > i = std::list<int>();
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
new file mode 100644
index 0000000..1a148e6
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <list>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+}
+
+int main()
+{
+    test(std::list<int>());
+    test(nasty_list<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..7489227
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    std::front_insert_iterator<C> r = i++;
+    r = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::list<int>());
+    test(nasty_list<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..e6d6c07
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    std::front_insert_iterator<C>& r = ++i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::list<int>());
+    test(nasty_list<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000..cdca9bf
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>&
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    const typename C::value_type v = typename C::value_type();
+    std::front_insert_iterator<C> i(c);
+    i = v;
+    assert(c.front() == v);
+}
+
+class Copyable
+{
+    int data_;
+public:
+    Copyable() : data_(0) {}
+    ~Copyable() {data_ = -1;}
+
+    friend bool operator==(const Copyable& x, const Copyable& y)
+        {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    test(std::list<Copyable>());
+    test(nasty_list<Copyable>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000..bd2bd44
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>&
+//   operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <list>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    i = typename C::value_type();
+    assert(c.front() == typename C::value_type());
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test(std::list<std::unique_ptr<int> >());
+#endif
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000..1ff49dd
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i(c);
+    std::front_insert_iterator<C>& r = *i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::list<int>());
+    test(nasty_list<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
new file mode 100644
index 0000000..c18f84b
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont>
+//   front_insert_iterator<Cont>
+//   front_inserter(Cont& x);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::front_insert_iterator<C> i = std::front_inserter(c);
+    i = 0;
+    assert(c.size() == 1);
+    assert(c.front() == 0);
+}
+
+int main()
+{
+    test(std::list<int>());
+    test(nasty_list<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
new file mode 100644
index 0000000..755133a
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// Test nested types and data member:
+
+// template <class Container>
+// class front_insert_iterator {
+// protected:
+//   Container* container;
+// public:
+//   typedef Container                   container_type;
+//   typedef void                        value_type;
+//   typedef void                        difference_type;
+//   typedef front_insert_iterator<Cont>& reference;
+//   typedef void                        pointer;
+//   typedef output_iterator_tag         iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+    : private std::front_insert_iterator<C>
+{
+    explicit find_container(C& c) : std::front_insert_iterator<C>(c) {}
+    void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+    typedef std::front_insert_iterator<C> R;
+    C c;
+    find_container<C> q(c);
+    q.test();
+    static_assert((std::is_same<typename R::container_type, C>::value), "");
+    static_assert((std::is_same<typename R::value_type, void>::value), "");
+    static_assert((std::is_same<typename R::difference_type, void>::value), "");
+    static_assert((std::is_same<typename R::reference, R&>::value), "");
+    static_assert((std::is_same<typename R::pointer, void>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<std::vector<int> >();
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
new file mode 100644
index 0000000..9f17240
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.begin());
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..7d81a7b
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.end());
+    std::insert_iterator<C> r = i++;
+    r = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..08e6ced
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.end());
+    std::insert_iterator<C>& r = ++i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000..01eb35e
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+//   insert_iterator<Cont>&
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3, const C& c2)
+{
+    std::insert_iterator<C> q(c1, c1.begin() + j);
+    q = x1;
+    q = x2;
+    q = x3;
+    assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3)
+{
+    i = c.insert(i, x1);
+    i = c.insert(++i, x2);
+    c.insert(++i, x3);
+}
+
+int main()
+{
+    {
+    typedef std::vector<int> C;
+    C c1;
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(i);
+    C c2 = c1;
+    insert3at(c2, c2.begin(), 'a', 'b', 'c');
+    test(c1, 0, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
+    test(c1, 1, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
+    test(c1, 2, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
+    test(c1, 3, 'a', 'b', 'c', c2);
+    }
+    {
+    typedef nasty_vector<int> C;
+    C c1;
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(i);
+    C c2 = c1;
+    insert3at(c2, c2.begin(), 'a', 'b', 'c');
+    test(c1, 0, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
+    test(c1, 1, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
+    test(c1, 2, 'a', 'b', 'c', c2);
+    c2 = c1;
+    insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
+    test(c1, 3, 'a', 'b', 'c', c2);
+    }
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000..2033683
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+//   insert_iterator<Cont>&
+//   operator=(const Cont::value_type& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3, const C& c2)
+{
+    std::insert_iterator<C> q(c1, c1.begin() + j);
+    q = std::move(x1);
+    q = std::move(x2);
+    q = std::move(x3);
+    assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+     typename C::value_type x1, typename C::value_type x2,
+     typename C::value_type x3)
+{
+    i = c.insert(i, std::move(x1));
+    i = c.insert(++i, std::move(x2));
+    c.insert(++i, std::move(x3));
+}
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    typedef std::unique_ptr<int, do_nothing> Ptr;
+    typedef std::vector<Ptr> C;
+    C c1;
+    int x[6] = {0};
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    C c2;
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin(), Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 0, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+    c1.clear();
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    c2.clear();
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin()+1, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 1, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+    c1.clear();
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    c2.clear();
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin()+2, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 2, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+    c1.clear();
+    for (int i = 0; i < 3; ++i)
+        c1.push_back(Ptr(x+i));
+    c2.clear();
+    for (int i = 0; i < 3; ++i)
+        c2.push_back(Ptr(x+i));
+    insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+    test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000..1a926b5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i(c, c.end());
+    std::insert_iterator<C>& r = *i;
+    assert(&r == &i);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
new file mode 100644
index 0000000..43f28d0
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InsertionContainer Cont>
+//   insert_iterator<Cont>
+//   inserter(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+    std::insert_iterator<C> i = std::inserter(c, c.end());
+    i = 0;
+    assert(c.size() == 1);
+    assert(c.back() == 0);
+}
+
+int main()
+{
+    test(std::vector<int>());
+    test(nasty_vector<int>());
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
new file mode 100644
index 0000000..cf63df6
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// Test nested types and data members:
+
+// template <InsertionContainer Cont>
+// class insert_iterator {
+// protected:
+//   Cont* container;
+//   Cont::iterator iter;
+// public:
+//   typedef Cont                   container_type;
+//   typedef void                   value_type;
+//   typedef void                   difference_type;
+//   typedef insert_iterator<Cont>& reference;
+//   typedef void                   pointer;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_members
+    : private std::insert_iterator<C>
+{
+    explicit find_members(C& c) : std::insert_iterator<C>(c, c.begin()) {}
+    void test()
+    {
+        this->container = 0;
+        (void)(this->iter == this->iter);
+    }
+};
+
+template <class C>
+void
+test()
+{
+    typedef std::insert_iterator<C> R;
+    C c;
+    find_members<C> q(c);
+    q.test();
+    static_assert((std::is_same<typename R::container_type, C>::value), "");
+    static_assert((std::is_same<typename R::value_type, void>::value), "");
+    static_assert((std::is_same<typename R::difference_type, void>::value), "");
+    static_assert((std::is_same<typename R::reference, R&>::value), "");
+    static_assert((std::is_same<typename R::pointer, void>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<std::vector<int> >();
+}
diff --git a/final/test/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
new file mode 100644
index 0000000..0683498
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter>
+//   move_iterator<Iter>
+//   make_move_iterator(const Iter& i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+    const std::move_iterator<It> r(i);
+    assert(std::make_move_iterator(i) == r);
+}
+
+int main()
+{
+    {
+    char s[] = "1234567890";
+    test(input_iterator<char*>(s+5));
+    test(forward_iterator<char*>(s+5));
+    test(bidirectional_iterator<char*>(s+5));
+    test(random_access_iterator<char*>(s+5));
+    test(s+5);
+    }
+    {
+    int a[] = {1,2,3,4};
+    std::make_move_iterator(a+4);
+    std::make_move_iterator(a); // test for LWG issue 2061
+    }
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
new file mode 100644
index 0000000..d52175c
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasMinus<Iter1, Iter2>
+//   auto
+//   operator-(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y)
+//   -> decltype(x.base() - y.base());
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, typename std::iterator_traits<It>::difference_type x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert(r1 - r2 == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s+5), random_access_iterator<char*>(s), 5);
+    test(s+5, s, 5);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
new file mode 100644
index 0000000..e67ebfc
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter>
+//   move_iterator<Iter>
+//   operator+(Iter::difference_type n, const move_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = n + r;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s+5), 5, random_access_iterator<char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
new file mode 100644
index 0000000..e9a19f4
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+//   move_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r + n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
new file mode 100644
index 0000000..5de1bcc
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+//   move_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = r += n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
new file mode 100644
index 0000000..852f76a
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+//   move_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r - n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
new file mode 100644
index 0000000..f863073
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+//   move_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = r -= n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
new file mode 100644
index 0000000..fb4f0fa
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+//   requires HasEqualTo<Iter1, Iter2>
+//   bool
+//   operator==(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 == r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(input_iterator<char*>(s), input_iterator<char*>(s), true);
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1), false);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s), true);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), false);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), true);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+    test(s, s, true);
+    test(s, s+1, false);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
new file mode 100644
index 0000000..0edd285
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter2, Iter1>
+//   bool
+//   operator>(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 > r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+    test(s, s, false);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
new file mode 100644
index 0000000..cb9cdb9
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter1, Iter2>
+//   bool
+//   operator>=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 >= r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+    test(s, s, true);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
new file mode 100644
index 0000000..e7979dd
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter1, Iter2>
+//   bool
+//   operator<(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 < r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+    test(s, s, false);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
new file mode 100644
index 0000000..97a7bfd
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasLess<Iter2, Iter1>
+//   bool
+//   operator<=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 <= r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+    test(s, s, true);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
new file mode 100644
index 0000000..9e4b9e3
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+//   requires HasEqualTo<Iter1, Iter2>
+//   bool
+//   operator!=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::move_iterator<It> r1(l);
+    const std::move_iterator<It> r2(r);
+    assert((r1 != r2) == x);
+}
+
+int main()
+{
+    char s[] = "1234567890";
+    test(input_iterator<char*>(s), input_iterator<char*>(s), false);
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1), true);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s), false);
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), true);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), false);
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), true);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+    test(s, s, false);
+    test(s, s+1, true);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
new file mode 100644
index 0000000..22d267a
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+//   requires HasConstructor<Iter, const U&>
+//   move_iterator(const move_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+
+    test<base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp
new file mode 100644
index 0000000..8c73a7d
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+//   requires HasConstructor<Iter, const U&>
+//   move_iterator(const move_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1 = r2;
+    assert(r1.base() == u);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+    Derived d;
+
+    test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
+    test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
+    test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+    test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+    test<Base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
new file mode 100644
index 0000000..782cb60
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator();
+
+#include <iterator>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+    std::move_iterator<It> r;
+}
+
+int main()
+{
+    test<input_iterator<char*> >();
+    test<forward_iterator<char*> >();
+    test<bidirectional_iterator<char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
new file mode 100644
index 0000000..188acff
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter );
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+    std::move_iterator<It> r = i;
+}
+
+int main()
+{
+    char s[] = "123";
+    test(s);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
new file mode 100644
index 0000000..4a4a060
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+    std::move_iterator<It> r(i);
+    assert(r.base() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(input_iterator<char*>(s));
+    test(forward_iterator<char*>(s));
+    test(bidirectional_iterator<char*>(s));
+    test(random_access_iterator<char*>(s));
+    test(s);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
new file mode 100644
index 0000000..26fab5b
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r--;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+    test(s+1, s);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
new file mode 100644
index 0000000..700b3b6
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = --r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+    test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+    test(s+1, s);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
new file mode 100644
index 0000000..e7c13b5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It> rr = r++;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+    test(s, s+1);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
new file mode 100644
index 0000000..f27c737
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::move_iterator<It> r(i);
+    std::move_iterator<It>& rr = ++r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+    test(s, s+1);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
new file mode 100644
index 0000000..8d507b8
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+//   unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+     typename std::iterator_traits<It>::value_type x)
+{
+    typedef typename std::iterator_traits<It>::value_type value_type;
+    const std::move_iterator<It> r(i);
+    value_type rr = r[n];
+    assert(rr == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    char s[] = "1234567890";
+    test(random_access_iterator<char*>(s+5), 4, '0');
+    test(s+5, 4, '0');
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    int i[5];
+    typedef std::unique_ptr<int, do_nothing> Ptr;
+    Ptr p[5];
+    for (unsigned j = 0; j < 5; ++j)
+        p[j].reset(i+j);
+    test(p, 3, Ptr(i+3));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
new file mode 100644
index 0000000..b0c00e3
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// pointer operator->() const;
+
+#include <iterator>
+#include <cassert>
+
+template <class It>
+void
+test(It i)
+{
+    std::move_iterator<It> r(i);
+    assert(r.operator->() == i);
+}
+
+int main()
+{
+    char s[] = "123";
+    test(s);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
new file mode 100644
index 0000000..6de708b
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// reference operator*() const;
+
+#include <iterator>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+class A
+{
+    int data_;
+public:
+    A() : data_(1) {}
+    ~A() {data_ = -1;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+    std::move_iterator<It> r(i);
+    assert(*r == x);
+    typename std::iterator_traits<It>::value_type x2 = *r;
+    assert(x2 == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+    void operator()(void*) const {}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    A a;
+    test(&a, A());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    int i;
+    std::unique_ptr<int, do_nothing> p(&i);
+    test(&p, std::unique_ptr<int, do_nothing>(&i));
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
new file mode 100644
index 0000000..089cc29
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+//   requires HasAssign<Iter, const U&>
+//   move_iterator&
+//   operator=(const move_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1;
+    r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+    test<base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
new file mode 100644
index 0000000..449f7e8
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+//   requires HasAssign<Iter, const U&>
+//   move_iterator&
+//   operator=(const move_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::move_iterator<U> r2(u);
+    std::move_iterator<It> r1;
+    std::move_iterator<It>& rr = r1 = r2;
+    assert(r1.base() == u);
+    assert(&rr == &r1);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+    Derived d;
+
+    test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
+    test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
+    test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+    test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+    test<Base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
new file mode 100644
index 0000000..9bdf721
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// Test nested types:
+
+// template <InputIterator Iter>
+// class move_iterator {
+// public:
+//   typedef Iter                  iterator_type;
+//   typedef Iter::difference_type difference_type;
+//   typedef Iterator              pointer;
+//   typedef Iter::value_type      value_type;
+//   typedef value_type&&          reference;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+    typedef std::move_iterator<It> R;
+    typedef std::iterator_traits<It> T;
+    static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+    static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+    static_assert((std::is_same<typename R::pointer, typename T::pointer>::value), "");
+    static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
+#else
+    static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+#endif
+    static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+    test<input_iterator<char*> >();
+    test<forward_iterator<char*> >();
+    test<bidirectional_iterator<char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+}
diff --git a/final/test/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
new file mode 100644
index 0000000..72a767d
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator();
+
+#include <iterator>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+    std::reverse_iterator<It> r;
+}
+
+int main()
+{
+    test<bidirectional_iterator<const char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+    test<const char*>();
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
new file mode 100644
index 0000000..3f42f06
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+    std::reverse_iterator<It> r = i;
+}
+
+int main()
+{
+    const char s[] = "123";
+    test(s);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
new file mode 100644
index 0000000..ea213c0
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+    std::reverse_iterator<It> r(i);
+    assert(r.base() == i);
+}
+
+int main()
+{
+    const char s[] = "123";
+    test(bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s));
+    test(s);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
new file mode 100644
index 0000000..c0a9afe
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+//   requires HasConstructor<Iter, const U&>
+//   reverse_iterator(const reverse_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+
+    test<base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
new file mode 100644
index 0000000..280e7d5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+//   requires HasConstructor<Iter, const U&>
+//   reverse_iterator(const reverse_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1 = r2;
+    assert(r1.base() == u);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+    Derived d;
+
+    test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+    test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+    test<Base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp
new file mode 100644
index 0000000..98b7331
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class Iterator> reverse_iterator<Iterator>
+//     make_reverse_iterator(Iterator i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+
+template <class It>
+void
+test(It i)
+{
+    const std::reverse_iterator<It> r = std::make_reverse_iterator(i);
+    assert(r.base() == i);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    random_access_iterator<const char*>b(s);
+    random_access_iterator<const char*>e(s+10);
+    while ( b != e )
+        test ( b++ );
+}
+#else
+int main () {}
+#endif
diff --git "a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op\041=/test.pass.cpp" "b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op\041=/test.pass.cpp"
new file mode 100644
index 0000000..29da57e
--- /dev/null
+++ "b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op\041=/test.pass.cpp"
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
+//   requires HasEqualTo<Iter1, Iter2>
+//   bool
+//   operator!=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 != r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), false);
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+    test(s, s, false);
+    test(s, s+1, true);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp
new file mode 100644
index 0000000..bd93606
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r++;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+    test(s+1, s);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000..f68a612
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = ++r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+    test(s+1, s);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp
new file mode 100644
index 0000000..39129d6
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+//   reverse_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r + n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp
new file mode 100644
index 0000000..ac97aaf
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+//   reverse_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = r += n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp
new file mode 100644
index 0000000..c3126e8
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r--;
+    assert(r.base() == x);
+    assert(rr.base() == i);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+    test(s+1, s+2);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp
new file mode 100644
index 0000000..f9361cf
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = --r;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "123";
+    test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+    test(s+1, s+2);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp
new file mode 100644
index 0000000..79d4779
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+//   reverse_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = r - n;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp
new file mode 100644
index 0000000..93addf9
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+//   reverse_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It>& rr = r -= n;
+    assert(r.base() == x);
+    assert(&rr == &r);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+    test(s+5, 5, s+10);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
new file mode 100644
index 0000000..7a77598
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reference operator*() const;
+
+// Be sure to respect LWG 198:
+//    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+// LWG 198 was superseded by LWG 2360
+//    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
+
+#include <iterator>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    A() : data_(1) {}
+    ~A() {data_ = -1;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+    std::reverse_iterator<It> r(i);
+    assert(*r == x);
+}
+
+int main()
+{
+    A a;
+    test(&a+1, A());
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
new file mode 100644
index 0000000..18f9780
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+//   requires HasAssign<Iter, const U&>
+//   reverse_iterator&
+//   operator=(const reverse_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1;
+    r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+    derived d;
+    test<base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp
new file mode 100644
index 0000000..92573f9
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+//   requires HasAssign<Iter, const U&>
+//   reverse_iterator&
+//   operator=(const reverse_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+    const std::reverse_iterator<U> r2(u);
+    std::reverse_iterator<It> r1;
+    std::reverse_iterator<It>& rr = r1 = r2;
+    assert(r1.base() == u);
+    assert(&rr == &r1);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+    Derived d;
+
+    test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+    test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+    test<Base*>(&d);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
new file mode 100644
index 0000000..3da4b95
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
+//   requires HasEqualTo<Iter1, Iter2>
+//   bool
+//   operator==(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 == r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), true);
+    test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+    test(s, s, true);
+    test(s, s+1, false);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
new file mode 100644
index 0000000..437bb6f
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasMinus<Iter2, Iter1>
+//   auto operator-(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y)
+//   -> decltype(y.base() - x.base());
+
+#include <iterator>
+#include <cstddef>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It1, class It2>
+void
+test(It1 l, It2 r, std::ptrdiff_t x)
+{
+    const std::reverse_iterator<It1> r1(l);
+    const std::reverse_iterator<It2> r2(r);
+    assert((r1 - r2) == x);
+}
+
+int main()
+{
+    char s[3] = {0};
+    test(random_access_iterator<const char*>(s), random_access_iterator<char*>(s), 0);
+    test(random_access_iterator<char*>(s), random_access_iterator<const char*>(s+1), 1);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<char*>(s), -1);
+    test(s, s, 0);
+    test(s, s+1, 1);
+    test(s+1, s, -1);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
new file mode 100644
index 0000000..afbb334
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasGreater<Iter1, Iter2>
+//   bool
+//   operator>(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 > r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+    test(s, s, false);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
new file mode 100644
index 0000000..c6e79af
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasGreater<Iter1, Iter2>
+//   bool
+//   operator>=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 >= r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+    test(s, s, true);
+    test(s, s+1, true);
+    test(s+1, s, false);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
new file mode 100644
index 0000000..16f4a07
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+//   unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+     typename std::iterator_traits<It>::value_type x)
+{
+    typedef typename std::iterator_traits<It>::value_type value_type;
+    const std::reverse_iterator<It> r(i);
+    value_type rr = r[n];
+    assert(rr == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 4, '1');
+    test(s+5, 4, '1');
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
new file mode 100644
index 0000000..2b389b8
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasGreater<Iter1, Iter2>
+//   bool
+//   operator<(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 < r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+    test(s, s, false);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
new file mode 100644
index 0000000..6c4f05c
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+//   requires HasGreater<Iter1, Iter2>
+//   bool
+//   operator<=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+    const std::reverse_iterator<It> r1(l);
+    const std::reverse_iterator<It> r2(r);
+    assert((r1 <= r2) == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+    test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+    test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+    test(s, s, true);
+    test(s, s+1, false);
+    test(s+1, s, true);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp
new file mode 100644
index 0000000..efbdf14
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// pointer operator->() const;
+
+// Be sure to respect LWG 198:
+//    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+// LWG 198 was superseded by LWG 2360
+//    http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
+
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    A() : data_(1) {}
+    ~A() {data_ = -1;}
+
+    int get() const {return data_;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+    std::reverse_iterator<It> r(i);
+    assert(r->get() == x.get());
+}
+
+class B
+{
+    int data_;
+public:
+    B(int d=1) : data_(d) {}
+    ~B() {data_ = -1;}
+
+    int get() const {return data_;}
+
+    friend bool operator==(const B& x, const B& y)
+        {return x.data_ == y.data_;}
+    const B *operator&() const { return nullptr; }
+    B       *operator&()       { return nullptr; }
+};
+
+int main()
+{
+    A a;
+    test(&a+1, A());
+    
+    {
+    std::list<B> l;
+    l.push_back(B(0));
+    l.push_back(B(1));
+    l.push_back(B(2));
+    
+    {
+    std::list<B>::const_iterator i = l.begin();
+    assert ( i->get() == 0 );  ++i;
+    assert ( i->get() == 1 );  ++i;
+    assert ( i->get() == 2 );  ++i;
+    assert ( i == l.end ());
+    }
+    
+    {
+    std::list<B>::const_reverse_iterator ri = l.rbegin();
+    assert ( ri->get() == 2 );  ++ri;
+    assert ( ri->get() == 1 );  ++ri;
+    assert ( ri->get() == 0 );  ++ri;
+    assert ( ri == l.rend ());
+    }
+    }
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp
new file mode 100644
index 0000000..74747cb
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iterator>
+//   reverse_iterator<Iter>
+//   operator+(Iter::difference_type n, const reverse_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+    const std::reverse_iterator<It> r(i);
+    std::reverse_iterator<It> rr = n + r;
+    assert(rr.base() == x);
+}
+
+int main()
+{
+    const char* s = "1234567890";
+    test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+    test(s+5, 5, s);
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
new file mode 100644
index 0000000..292a777
--- /dev/null
+++ b/final/test/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// Test nested types and data member:
+
+// template <BidirectionalIterator Iter>
+// class reverse_iterator {
+// protected:
+//   Iter current;
+// public:
+//   iterator<typename iterator_traits<Iterator>::iterator_category,
+//   typename iterator_traits<Iterator>::value_type,
+//   typename iterator_traits<Iterator>::difference_type,
+//   typename iterator_traits<Iterator>::pointer,
+//   typename iterator_traits<Iterator>::reference> {
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "test_iterators.h"
+
+template <class It>
+struct find_current
+    : private std::reverse_iterator<It>
+{
+    void test() {++(this->current);}
+};
+
+template <class It>
+void
+test()
+{
+    typedef std::reverse_iterator<It> R;
+    typedef std::iterator_traits<It> T;
+    find_current<It> q;
+    q.test();
+    static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+    static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+    static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+    static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+    static_assert((std::is_same<typename R::pointer, typename std::iterator_traits<It>::pointer>::value), "");
+    static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+    test<bidirectional_iterator<char*> >();
+    test<random_access_iterator<char*> >();
+    test<char*>();
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
new file mode 100644
index 0000000..0d70c7f
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(const istream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istream_iterator<int> io;
+        std::istream_iterator<int> i = io;
+        assert(i == std::istream_iterator<int>());
+    }
+    {
+        std::istringstream inf(" 1 23");
+        std::istream_iterator<int> io(inf);
+        std::istream_iterator<int> i = io;
+        assert(i != std::istream_iterator<int>());
+        int j = 0;
+        j = *i;
+        assert(j == 1);
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
new file mode 100644
index 0000000..f6c3dba
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator();
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    std::istream_iterator<int> i;
+    assert(i == std::istream_iterator<int>());
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
new file mode 100644
index 0000000..12a6f90
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(istream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    assert(i != std::istream_iterator<int>());
+    assert(inf.peek() == ' ');
+    assert(inf.good());
+    int j = 0;
+    inf >> j;
+    assert(j == 23);
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
new file mode 100644
index 0000000..5c4ddca
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T* operator->() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+struct A
+{
+    double d_;
+    int i_;
+};
+
+std::istream& operator>>(std::istream& is, A& a)
+{
+    return is >> a.d_ >> a.i_;
+}
+
+int main()
+{
+    std::istringstream inf("1.5  23 ");
+    std::istream_iterator<A> i(inf);
+    assert(i->d_ == 1.5);
+    assert(i->i_ == 23);
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 0000000..e6f86d4
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    int j = 0;
+    j = *i;
+    assert(j == 1);
+    j = *i;
+    assert(j == 1);
+    ++i;
+    j = *i;
+    assert(j == 23);
+    j = *i;
+    assert(j == 23);
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
new file mode 100644
index 0000000..0bee916
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// template <class T, class charT, class traits, class Distance>
+//   bool operator==(const istream_iterator<T,charT,traits,Distance> &x,
+//                   const istream_iterator<T,charT,traits,Distance> &y);
+//
+// template <class T, class charT, class traits, class Distance>
+//   bool operator!=(const istream_iterator<T,charT,traits,Distance> &x,
+//                   const istream_iterator<T,charT,traits,Distance> &y);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf1(" 1 23");
+    std::istringstream inf2(" 1 23");
+    std::istream_iterator<int> i1(inf1);
+    std::istream_iterator<int> i2(inf1);
+    std::istream_iterator<int> i3(inf2);
+    std::istream_iterator<int> i4;
+    std::istream_iterator<int> i5;
+    assert(i1 == i1);
+    assert(i1 == i2);
+    assert(i1 != i3);
+    assert(i1 != i4);
+    assert(i1 != i5);
+
+    assert(i2 == i2);
+    assert(i2 != i3);
+    assert(i2 != i4);
+    assert(i2 != i5);
+
+    assert(i3 == i3);
+    assert(i3 != i4);
+    assert(i3 != i5);
+
+    assert(i4 == i4);
+    assert(i4 == i5);
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp
new file mode 100644
index 0000000..f5c49e3
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    std::istream_iterator<int> icopy = i++;
+    assert(icopy == i);
+    int j = 0;
+    j = *i;
+    assert(j == 23);
+    j = 0;
+    j = *icopy;
+    assert(j == 1);
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
new file mode 100644
index 0000000..87173f7
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator& operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream inf(" 1 23");
+    std::istream_iterator<int> i(inf);
+    std::istream_iterator<int>& iref = ++i;
+    assert(&iref == &i);
+    int j = 0;
+    j = *i;
+    assert(j == 23);
+}
diff --git a/final/test/iterators/stream.iterators/istream.iterator/types.pass.cpp b/final/test/iterators/stream.iterators/istream.iterator/types.pass.cpp
new file mode 100644
index 0000000..be55c97
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istream.iterator/types.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+//           class Distance = ptrdiff_t>
+// class istream_iterator
+//     : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
+// {
+// public:
+//     typedef charT char_type;
+//     typedef traits traits_type;
+//     typedef basic_istream<charT,traits> istream_type;
+//     ...
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    typedef std::istream_iterator<double> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
+        const double*, const double&> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+    typedef std::istream_iterator<unsigned, wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
+        const unsigned*, const unsigned&> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
new file mode 100644
index 0000000..d1eabba
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator() throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istreambuf_iterator<char> i;
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istreambuf_iterator<wchar_t> i;
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
new file mode 100644
index 0000000..69e9826
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_istream<charT,traits>& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf;
+        std::istreambuf_iterator<char> i(inf);
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istringstream inf("a");
+        std::istreambuf_iterator<char> i(inf);
+        assert(i != std::istreambuf_iterator<char>());
+    }
+    {
+        std::wistringstream inf;
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+    {
+        std::wistringstream inf(L"a");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(i != std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp
new file mode 100644
index 0000000..f5a5fa0
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(const proxy& p) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> j(inf);
+        std::istreambuf_iterator<char> i = j++;
+        assert(i != std::istreambuf_iterator<char>());
+        assert(*i == 'b');
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> j(inf);
+        std::istreambuf_iterator<wchar_t> i = j++;
+        assert(i != std::istreambuf_iterator<wchar_t>());
+        assert(*i == L'b');
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..020b4f2
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_streambuf<charT,traits>* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istreambuf_iterator<char> i(nullptr);
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istringstream inf;
+        std::istreambuf_iterator<char> i(inf.rdbuf());
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::istringstream inf("a");
+        std::istreambuf_iterator<char> i(inf.rdbuf());
+        assert(i != std::istreambuf_iterator<char>());
+    }
+    {
+        std::istreambuf_iterator<wchar_t> i(nullptr);
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+    {
+        std::wistringstream inf;
+        std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+    {
+        std::wistringstream inf(L"a");
+        std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+        assert(i != std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp
new file mode 100644
index 0000000..2005d30
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// bool equal(istreambuf_iterator<charT,traits>& b) const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf1("abc");
+        std::istringstream inf2("def");
+        std::istreambuf_iterator<char> i1(inf1);
+        std::istreambuf_iterator<char> i2(inf2);
+        std::istreambuf_iterator<char> i3;
+        std::istreambuf_iterator<char> i4;
+
+        assert( i1.equal(i1));
+        assert( i1.equal(i2));
+        assert(!i1.equal(i3));
+        assert(!i1.equal(i4));
+
+        assert( i2.equal(i1));
+        assert( i2.equal(i2));
+        assert(!i2.equal(i3));
+        assert(!i2.equal(i4));
+
+        assert(!i3.equal(i1));
+        assert(!i3.equal(i2));
+        assert( i3.equal(i3));
+        assert( i3.equal(i4));
+
+        assert(!i4.equal(i1));
+        assert(!i4.equal(i2));
+        assert( i4.equal(i3));
+        assert( i4.equal(i4));
+    }
+    {
+        std::wistringstream inf1(L"abc");
+        std::wistringstream inf2(L"def");
+        std::istreambuf_iterator<wchar_t> i1(inf1);
+        std::istreambuf_iterator<wchar_t> i2(inf2);
+        std::istreambuf_iterator<wchar_t> i3;
+        std::istreambuf_iterator<wchar_t> i4;
+
+        assert( i1.equal(i1));
+        assert( i1.equal(i2));
+        assert(!i1.equal(i3));
+        assert(!i1.equal(i4));
+
+        assert( i2.equal(i1));
+        assert( i2.equal(i2));
+        assert(!i2.equal(i3));
+        assert(!i2.equal(i4));
+
+        assert(!i3.equal(i1));
+        assert(!i3.equal(i2));
+        assert( i3.equal(i3));
+        assert( i3.equal(i4));
+
+        assert(!i4.equal(i1));
+        assert(!i4.equal(i2));
+        assert( i4.equal(i3));
+        assert( i4.equal(i4));
+    }
+}
diff --git "a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op\041=/not_equal.pass.cpp" "b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op\041=/not_equal.pass.cpp"
new file mode 100644
index 0000000..5e85364
--- /dev/null
+++ "b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op\041=/not_equal.pass.cpp"
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+//   bool operator!=(const istreambuf_iterator<charT,traits>& a,
+//                   const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf1("abc");
+        std::istringstream inf2("def");
+        std::istreambuf_iterator<char> i1(inf1);
+        std::istreambuf_iterator<char> i2(inf2);
+        std::istreambuf_iterator<char> i3;
+        std::istreambuf_iterator<char> i4;
+
+        assert(!(i1 != i1));
+        assert(!(i1 != i2));
+        assert( (i1 != i3));
+        assert( (i1 != i4));
+
+        assert(!(i2 != i1));
+        assert(!(i2 != i2));
+        assert( (i2 != i3));
+        assert( (i2 != i4));
+
+        assert( (i3 != i1));
+        assert( (i3 != i2));
+        assert(!(i3 != i3));
+        assert(!(i3 != i4));
+
+        assert( (i4 != i1));
+        assert( (i4 != i2));
+        assert(!(i4 != i3));
+        assert(!(i4 != i4));
+    }
+    {
+        std::wistringstream inf1(L"abc");
+        std::wistringstream inf2(L"def");
+        std::istreambuf_iterator<wchar_t> i1(inf1);
+        std::istreambuf_iterator<wchar_t> i2(inf2);
+        std::istreambuf_iterator<wchar_t> i3;
+        std::istreambuf_iterator<wchar_t> i4;
+
+        assert(!(i1 != i1));
+        assert(!(i1 != i2));
+        assert( (i1 != i3));
+        assert( (i1 != i4));
+
+        assert(!(i2 != i1));
+        assert(!(i2 != i2));
+        assert( (i2 != i3));
+        assert( (i2 != i4));
+
+        assert( (i3 != i1));
+        assert( (i3 != i2));
+        assert(!(i3 != i3));
+        assert(!(i3 != i4));
+
+        assert( (i4 != i1));
+        assert( (i4 != i2));
+        assert(!(i4 != i3));
+        assert(!(i4 != i4));
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp
new file mode 100644
index 0000000..19fb02f
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// charT operator*() const
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i == 'a');
+        ++i;
+        assert(*i == 'b');
+        ++i;
+        assert(*i == 'c');
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i == L'a');
+        ++i;
+        assert(*i == L'b');
+        ++i;
+        assert(*i == L'c');
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp
new file mode 100644
index 0000000..9195769
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+//   bool operator==(const istreambuf_iterator<charT,traits>& a,
+//                   const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf1("abc");
+        std::istringstream inf2("def");
+        std::istreambuf_iterator<char> i1(inf1);
+        std::istreambuf_iterator<char> i2(inf2);
+        std::istreambuf_iterator<char> i3;
+        std::istreambuf_iterator<char> i4;
+
+        assert( (i1 == i1));
+        assert( (i1 == i2));
+        assert(!(i1 == i3));
+        assert(!(i1 == i4));
+
+        assert( (i2 == i1));
+        assert( (i2 == i2));
+        assert(!(i2 == i3));
+        assert(!(i2 == i4));
+
+        assert(!(i3 == i1));
+        assert(!(i3 == i2));
+        assert( (i3 == i3));
+        assert( (i3 == i4));
+
+        assert(!(i4 == i1));
+        assert(!(i4 == i2));
+        assert( (i4 == i3));
+        assert( (i4 == i4));
+    }
+    {
+        std::wistringstream inf1(L"abc");
+        std::wistringstream inf2(L"def");
+        std::istreambuf_iterator<wchar_t> i1(inf1);
+        std::istreambuf_iterator<wchar_t> i2(inf2);
+        std::istreambuf_iterator<wchar_t> i3;
+        std::istreambuf_iterator<wchar_t> i4;
+
+        assert( (i1 == i1));
+        assert( (i1 == i2));
+        assert(!(i1 == i3));
+        assert(!(i1 == i4));
+
+        assert( (i2 == i1));
+        assert( (i2 == i2));
+        assert(!(i2 == i3));
+        assert(!(i2 == i4));
+
+        assert(!(i3 == i1));
+        assert(!(i3 == i2));
+        assert( (i3 == i3));
+        assert( (i3 == i4));
+
+        assert(!(i4 == i1));
+        assert(!(i4 == i2));
+        assert( (i4 == i3));
+        assert( (i4 == i4));
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp
new file mode 100644
index 0000000..e3bf5e2
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// pointer operator->() const;
+
+#include <iostream>
+#include <sstream>
+#include <streambuf>
+
+typedef char C;
+int main ()
+{
+   std::istringstream s("filename");
+   std::istreambuf_iterator<char> i(s);
+
+   (*i).~C();  // This is well-formed...
+   i->~C();  // ... so this should be supported!
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp
new file mode 100644
index 0000000..2e4f52c
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// proxy istreambuf_iterator<charT,traits>::operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i++ == 'a');
+        assert(*i++ == 'b');
+        assert(*i++ == 'c');
+        assert(i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i++ == L'a');
+        assert(*i++ == L'b');
+        assert(*i++ == L'c');
+        assert(i == std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp
new file mode 100644
index 0000000..cb7960a
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator<charT,traits>&
+//   istreambuf_iterator<charT,traits>::operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i == 'a');
+        assert(*++i == 'b');
+        assert(*++i == 'c');
+        assert(++i == std::istreambuf_iterator<char>());
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i == L'a');
+        assert(*++i == L'b');
+        assert(*++i == L'c');
+        assert(++i == std::istreambuf_iterator<wchar_t>());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp
new file mode 100644
index 0000000..acaf2f5
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+//     : public iterator<input_iterator_tag, charT,
+//                       typename traits::off_type, charT*,
+//                       charT>
+// {
+// public:
+//     ...
+//     proxy operator++(int);
+
+// class proxy
+// {
+// public:
+//     charT operator*();
+// };
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream inf("abc");
+        std::istreambuf_iterator<char> i(inf);
+        assert(*i++ == 'a');
+    }
+    {
+        std::wistringstream inf(L"abc");
+        std::istreambuf_iterator<wchar_t> i(inf);
+        assert(*i++ == L'a');
+    }
+}
diff --git a/final/test/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp b/final/test/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
new file mode 100644
index 0000000..75894a8
--- /dev/null
+++ b/final/test/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+//     : public iterator<input_iterator_tag, charT,
+//                       typename traits::off_type, unspecified,
+//                       charT>
+// {
+// public:
+//     typedef charT                         char_type;
+//     typedef traits                        traits_type;
+//     typedef typename traits::int_type     int_type;
+//     typedef basic_streambuf<charT,traits> streambuf_type;
+//     typedef basic_istream<charT,traits>   istream_type;
+//     ...
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    typedef std::istreambuf_iterator<char> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type,
+        char*, char> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
+    static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+    static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+
+    typedef std::istreambuf_iterator<wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type,
+        wchar_t*, wchar_t> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
+    static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+    static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+}
diff --git a/final/test/iterators/stream.iterators/iterator.range/begin_array.pass.cpp b/final/test/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
new file mode 100644
index 0000000..42c8c3d
--- /dev/null
+++ b/final/test/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* begin(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    int* i = std::begin(ia);
+    assert(*i == 1);
+    *i = 2;
+    assert(ia[0] == 2);
+}
diff --git a/final/test/iterators/stream.iterators/iterator.range/begin_const.pass.cpp b/final/test/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
new file mode 100644
index 0000000..7dca8b0
--- /dev/null
+++ b/final/test/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(const C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::const_iterator i = begin(v);
+    assert(*i == 1);
+}
diff --git a/final/test/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp b/final/test/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
new file mode 100644
index 0000000..de4c8b0
--- /dev/null
+++ b/final/test/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::iterator i = begin(v);
+    assert(*i == 1);
+    *i = 2;
+    assert(*i == 2);
+}
diff --git a/final/test/iterators/stream.iterators/iterator.range/end_array.pass.cpp b/final/test/iterators/stream.iterators/iterator.range/end_array.pass.cpp
new file mode 100644
index 0000000..628e5e9
--- /dev/null
+++ b/final/test/iterators/stream.iterators/iterator.range/end_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* end(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    int* i = std::begin(ia);
+    int* e = std::end(ia);
+    assert(e == ia + 3);
+    assert(e - i == 3);
+}
diff --git a/final/test/iterators/stream.iterators/iterator.range/end_const.pass.cpp b/final/test/iterators/stream.iterators/iterator.range/end_const.pass.cpp
new file mode 100644
index 0000000..7fa2617
--- /dev/null
+++ b/final/test/iterators/stream.iterators/iterator.range/end_const.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(const C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::const_iterator i = end(v);
+    assert(i == v.cend());
+}
diff --git a/final/test/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp b/final/test/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
new file mode 100644
index 0000000..8c75433
--- /dev/null
+++ b/final/test/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    int ia[] = {1, 2, 3};
+    std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+    std::vector<int>::iterator i = end(v);
+    assert(i == v.end());
+}
diff --git a/final/test/iterators/stream.iterators/nothing_to_do.pass.cpp b/final/test/iterators/stream.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/iterators/stream.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp
new file mode 100644
index 0000000..8862458
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(const ostream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream outf;
+    std::ostream_iterator<int> i(outf);
+    std::ostream_iterator<int> j = i;
+    assert(outf.good());
+}
diff --git a/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
new file mode 100644
index 0000000..321cfbd
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream outf;
+    std::ostream_iterator<int> i(outf);
+    assert(outf.good());
+}
diff --git a/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp
new file mode 100644
index 0000000..8e5c771
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s, const charT* delimiter);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostream_iterator<int> i(outf, ", ");
+        assert(outf.good());
+    }
+    {
+        std::wostringstream outf;
+        std::ostream_iterator<double, wchar_t> i(outf, L", ");
+        assert(outf.good());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
new file mode 100644
index 0000000..02ef571
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator=(const T& value);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostream_iterator<int> i(outf);
+        i = 2.4;
+        assert(outf.str() == "2");
+    }
+    {
+        std::ostringstream outf;
+        std::ostream_iterator<int> i(outf, ", ");
+        i = 2.4;
+        assert(outf.str() == "2, ");
+    }
+    {
+        std::wostringstream outf;
+        std::ostream_iterator<int, wchar_t> i(outf);
+        i = 2.4;
+        assert(outf.str() == L"2");
+    }
+    {
+        std::wostringstream outf;
+        std::ostream_iterator<int, wchar_t> i(outf, L", ");
+        i = 2.4;
+        assert(outf.str() == L"2, ");
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 0000000..3221075
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream os;
+    std::ostream_iterator<int> i(os);
+    std::ostream_iterator<int>& iref = *i;
+    assert(&iref == &i);
+}
diff --git a/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
new file mode 100644
index 0000000..00b63e8
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator++();
+// ostream_iterator& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream os;
+    std::ostream_iterator<int> i(os);
+    std::ostream_iterator<int>& iref1 = ++i;
+    assert(&iref1 == &i);
+    std::ostream_iterator<int>& iref2 = i++;
+    assert(&iref2 == &i);
+}
diff --git a/final/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp b/final/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp
new file mode 100644
index 0000000..460da64
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+//           class Distance = ptrdiff_t>
+// class ostream_iterator
+//     : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+//     typedef charT char_type;
+//     typedef traits traits_type;
+//     typedef basic_istream<charT,traits> istream_type;
+//     ...
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    typedef std::ostream_iterator<double> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+    typedef std::ostream_iterator<unsigned, wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp
new file mode 100644
index 0000000..c46cf48
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(ostream_type& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        assert(!i.failed());
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        assert(!i.failed());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp
new file mode 100644
index 0000000..1576b7d
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(streambuf_type* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf.rdbuf());
+        assert(!i.failed());
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf.rdbuf());
+        assert(!i.failed());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
new file mode 100644
index 0000000..91d7b69
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>&
+//   operator=(charT c);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        i = 'a';
+        assert(outf.str() == "a");
+        i = 'b';
+        assert(outf.str() == "ab");
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        i = L'a';
+        assert(outf.str() == L"a");
+        i = L'b';
+        assert(outf.str() == L"ab");
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
new file mode 100644
index 0000000..d086164
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator*();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        std::ostreambuf_iterator<char>& iref = *i;
+        assert(&iref == &i);
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        std::ostreambuf_iterator<wchar_t>& iref = *i;
+        assert(&iref == &i);
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
new file mode 100644
index 0000000..9d93bad
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// bool failed() const throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostreambuf_iterator<char> i(nullptr);
+        assert(i.failed());
+    }
+    {
+        std::ostreambuf_iterator<wchar_t> i(nullptr);
+        assert(i.failed());
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
new file mode 100644
index 0000000..7461ce1
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator++();
+// ostreambuf_iterator<charT,traits>& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ostringstream outf;
+        std::ostreambuf_iterator<char> i(outf);
+        std::ostreambuf_iterator<char>& iref = ++i;
+        assert(&iref == &i);
+        std::ostreambuf_iterator<char>& iref2 = i++;
+        assert(&iref2 == &i);
+    }
+    {
+        std::wostringstream outf;
+        std::ostreambuf_iterator<wchar_t> i(outf);
+        std::ostreambuf_iterator<wchar_t>& iref = ++i;
+        assert(&iref == &i);
+        std::ostreambuf_iterator<wchar_t>& iref2 = i++;
+        assert(&iref2 == &i);
+    }
+}
diff --git a/final/test/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp b/final/test/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
new file mode 100644
index 0000000..a699b24
--- /dev/null
+++ b/final/test/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class charT, class traits = char_traits<charT> >
+// class ostreambuf_iterator
+//   : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+//   typedef charT                          char_type;
+//   typedef traits                         traits_type;
+//   typedef basic_streambuf<charT, traits> streambuf_type;
+//   typedef basic_ostream<charT, traits>   ostream_type;
+//   ...
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    typedef std::ostreambuf_iterator<char> I1;
+    static_assert((std::is_convertible<I1,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I1::char_type, char>::value), "");
+    static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+    static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+    static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+
+    typedef std::ostreambuf_iterator<wchar_t> I2;
+    static_assert((std::is_convertible<I2,
+        std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+    static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+    static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+    static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/final/test/iterators/version.pass.cpp b/final/test/iterators/version.pass.cpp
new file mode 100644
index 0000000..dd09785
--- /dev/null
+++ b/final/test/iterators/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+#include <iterator>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/cstdint/cstdint.syn/cstdint.pass.cpp b/final/test/language.support/cstdint/cstdint.syn/cstdint.pass.cpp
new file mode 100644
index 0000000..9c3354d
--- /dev/null
+++ b/final/test/language.support/cstdint/cstdint.syn/cstdint.pass.cpp
@@ -0,0 +1,290 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdint>
+
+#include <cstdint>
+#include <csignal>
+#include <cwctype>
+#include <climits>
+#include <type_traits>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    // typedef std::int8_t
+    static_assert(sizeof(std::int8_t)*CHAR_BIT == 8,
+                 "sizeof(std::int8_t)*CHAR_BIT == 8");
+    static_assert(std::is_signed<std::int8_t>::value,
+                 "std::is_signed<std::int8_t>::value");
+    // typedef std::int16_t
+    static_assert(sizeof(std::int16_t)*CHAR_BIT == 16,
+                 "sizeof(std::int16_t)*CHAR_BIT == 16");
+    static_assert(std::is_signed<std::int16_t>::value,
+                 "std::is_signed<std::int16_t>::value");
+    // typedef std::int32_t
+    static_assert(sizeof(std::int32_t)*CHAR_BIT == 32,
+                 "sizeof(std::int32_t)*CHAR_BIT == 32");
+    static_assert(std::is_signed<std::int32_t>::value,
+                 "std::is_signed<std::int32_t>::value");
+    // typedef std::int64_t
+    static_assert(sizeof(std::int64_t)*CHAR_BIT == 64,
+                 "sizeof(std::int64_t)*CHAR_BIT == 64");
+    static_assert(std::is_signed<std::int64_t>::value,
+                 "std::is_signed<std::int64_t>::value");
+
+    // typedef std::uint8_t
+    static_assert(sizeof(std::uint8_t)*CHAR_BIT == 8,
+                 "sizeof(std::uint8_t)*CHAR_BIT == 8");
+    static_assert(std::is_unsigned<std::uint8_t>::value,
+                 "std::is_unsigned<std::uint8_t>::value");
+    // typedef std::uint16_t
+    static_assert(sizeof(std::uint16_t)*CHAR_BIT == 16,
+                 "sizeof(std::uint16_t)*CHAR_BIT == 16");
+    static_assert(std::is_unsigned<std::uint16_t>::value,
+                 "std::is_unsigned<std::uint16_t>::value");
+    // typedef std::uint32_t
+    static_assert(sizeof(std::uint32_t)*CHAR_BIT == 32,
+                 "sizeof(std::uint32_t)*CHAR_BIT == 32");
+    static_assert(std::is_unsigned<std::uint32_t>::value,
+                 "std::is_unsigned<std::uint32_t>::value");
+    // typedef std::uint64_t
+    static_assert(sizeof(std::uint64_t)*CHAR_BIT == 64,
+                 "sizeof(std::uint64_t)*CHAR_BIT == 64");
+    static_assert(std::is_unsigned<std::uint64_t>::value,
+                 "std::is_unsigned<std::uint64_t>::value");
+
+    // typedef std::int_least8_t
+    static_assert(sizeof(std::int_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::int_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<std::int_least8_t>::value,
+                 "std::is_signed<std::int_least8_t>::value");
+    // typedef std::int_least16_t
+    static_assert(sizeof(std::int_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::int_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<std::int_least16_t>::value,
+                 "std::is_signed<std::int_least16_t>::value");
+    // typedef std::int_least32_t
+    static_assert(sizeof(std::int_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::int_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<std::int_least32_t>::value,
+                 "std::is_signed<std::int_least32_t>::value");
+    // typedef std::int_least64_t
+    static_assert(sizeof(std::int_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::int_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<std::int_least64_t>::value,
+                 "std::is_signed<std::int_least64_t>::value");
+
+    // typedef std::uint_least8_t
+    static_assert(sizeof(std::uint_least8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::uint_least8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<std::uint_least8_t>::value,
+                 "std::is_unsigned<std::uint_least8_t>::value");
+    // typedef std::uint_least16_t
+    static_assert(sizeof(std::uint_least16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::uint_least16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<std::uint_least16_t>::value,
+                 "std::is_unsigned<std::uint_least16_t>::value");
+    // typedef std::uint_least32_t
+    static_assert(sizeof(std::uint_least32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::uint_least32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<std::uint_least32_t>::value,
+                 "std::is_unsigned<std::uint_least32_t>::value");
+    // typedef std::uint_least64_t
+    static_assert(sizeof(std::uint_least64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::uint_least64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<std::uint_least64_t>::value,
+                 "std::is_unsigned<std::uint_least64_t>::value");
+
+    // typedef std::int_fast8_t
+    static_assert(sizeof(std::int_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::int_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_signed<std::int_fast8_t>::value,
+                 "std::is_signed<std::int_fast8_t>::value");
+    // typedef std::int_fast16_t
+    static_assert(sizeof(std::int_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::int_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_signed<std::int_fast16_t>::value,
+                 "std::is_signed<std::int_fast16_t>::value");
+    // typedef std::int_fast32_t
+    static_assert(sizeof(std::int_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::int_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_signed<std::int_fast32_t>::value,
+                 "std::is_signed<std::int_fast32_t>::value");
+    // typedef std::int_fast64_t
+    static_assert(sizeof(std::int_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::int_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_signed<std::int_fast64_t>::value,
+                 "std::is_signed<std::int_fast64_t>::value");
+
+    // typedef std::uint_fast8_t
+    static_assert(sizeof(std::uint_fast8_t)*CHAR_BIT >= 8,
+                 "sizeof(std::uint_fast8_t)*CHAR_BIT >= 8");
+    static_assert(std::is_unsigned<std::uint_fast8_t>::value,
+                 "std::is_unsigned<std::uint_fast8_t>::value");
+    // typedef std::uint_fast16_t
+    static_assert(sizeof(std::uint_fast16_t)*CHAR_BIT >= 16,
+                 "sizeof(std::uint_fast16_t)*CHAR_BIT >= 16");
+    static_assert(std::is_unsigned<std::uint_fast16_t>::value,
+                 "std::is_unsigned<std::uint_fast16_t>::value");
+    // typedef std::uint_fast32_t
+    static_assert(sizeof(std::uint_fast32_t)*CHAR_BIT >= 32,
+                 "sizeof(std::uint_fast32_t)*CHAR_BIT >= 32");
+    static_assert(std::is_unsigned<std::uint_fast32_t>::value,
+                 "std::is_unsigned<std::uint_fast32_t>::value");
+    // typedef std::uint_fast64_t
+    static_assert(sizeof(std::uint_fast64_t)*CHAR_BIT >= 64,
+                 "sizeof(std::uint_fast64_t)*CHAR_BIT >= 64");
+    static_assert(std::is_unsigned<std::uint_fast64_t>::value,
+                 "std::is_unsigned<std::uint_fast64_t>::value");
+
+    // typedef std::intptr_t
+    static_assert(sizeof(std::intptr_t) >= sizeof(void*),
+                 "sizeof(std::intptr_t) >= sizeof(void*)");
+    static_assert(std::is_signed<std::intptr_t>::value,
+                 "std::is_signed<std::intptr_t>::value");
+    // typedef std::uintptr_t
+    static_assert(sizeof(std::uintptr_t) >= sizeof(void*),
+                 "sizeof(std::uintptr_t) >= sizeof(void*)");
+    static_assert(std::is_unsigned<std::uintptr_t>::value,
+                 "std::is_unsigned<std::uintptr_t>::value");
+
+    // typedef std::intmax_t
+    static_assert(sizeof(std::intmax_t) >= sizeof(long long),
+                 "sizeof(std::intmax_t) >= sizeof(long long)");
+    static_assert(std::is_signed<std::intmax_t>::value,
+                 "std::is_signed<std::intmax_t>::value");
+    // typedef std::uintmax_t
+    static_assert(sizeof(std::uintmax_t) >= sizeof(unsigned long long),
+                 "sizeof(std::uintmax_t) >= sizeof(unsigned long long)");
+    static_assert(std::is_unsigned<std::uintmax_t>::value,
+                 "std::is_unsigned<std::uintmax_t>::value");
+
+    // INTN_MIN
+    static_assert(INT8_MIN == -128, "INT8_MIN == -128");
+    static_assert(INT16_MIN == -32768, "INT16_MIN == -32768");
+    static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648");
+    static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL");
+
+    // INTN_MAX
+    static_assert(INT8_MAX == 127, "INT8_MAX == 127");
+    static_assert(INT16_MAX == 32767, "INT16_MAX == 32767");
+    static_assert(INT32_MAX == 2147483647, "INT32_MAX == 2147483647");
+    static_assert(INT64_MAX == 9223372036854775807LL, "INT64_MAX == 9223372036854775807LL");
+
+    // UINTN_MAX
+    static_assert(UINT8_MAX == 255, "UINT8_MAX == 255");
+    static_assert(UINT16_MAX == 65535, "UINT16_MAX == 65535");
+    static_assert(UINT32_MAX == 4294967295U, "UINT32_MAX == 4294967295");
+    static_assert(UINT64_MAX == 18446744073709551615ULL, "UINT64_MAX == 18446744073709551615ULL");
+
+    // INT_FASTN_MIN
+    static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128");
+    static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768");
+    static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648");
+    static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL");
+
+    // INT_FASTN_MAX
+    static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127");
+    static_assert(INT_FAST16_MAX >= 32767, "INT_FAST16_MAX >= 32767");
+    static_assert(INT_FAST32_MAX >= 2147483647, "INT_FAST32_MAX >= 2147483647");
+    static_assert(INT_FAST64_MAX >= 9223372036854775807LL, "INT_FAST64_MAX >= 9223372036854775807LL");
+
+    // UINT_FASTN_MAX
+    static_assert(UINT_FAST8_MAX >= 255, "UINT_FAST8_MAX >= 255");
+    static_assert(UINT_FAST16_MAX >= 65535, "UINT_FAST16_MAX >= 65535");
+    static_assert(UINT_FAST32_MAX >= 4294967295U, "UINT_FAST32_MAX >= 4294967295");
+    static_assert(UINT_FAST64_MAX >= 18446744073709551615ULL, "UINT_FAST64_MAX >= 18446744073709551615ULL");
+
+    // INTPTR_MIN
+    assert(INTPTR_MIN == std::numeric_limits<std::intptr_t>::min());
+
+    // INTPTR_MAX
+    assert(INTPTR_MAX == std::numeric_limits<std::intptr_t>::max());
+
+    // UINTPTR_MAX
+    assert(UINTPTR_MAX == std::numeric_limits<std::uintptr_t>::max());
+
+    // INTMAX_MIN
+    assert(INTMAX_MIN == std::numeric_limits<std::intmax_t>::min());
+
+    // INTMAX_MAX
+    assert(INTMAX_MAX == std::numeric_limits<std::intmax_t>::max());
+
+    // UINTMAX_MAX
+    assert(UINTMAX_MAX == std::numeric_limits<std::uintmax_t>::max());
+
+    // PTRDIFF_MIN
+    assert(PTRDIFF_MIN == std::numeric_limits<std::ptrdiff_t>::min());
+
+    // PTRDIFF_MAX
+    assert(PTRDIFF_MAX == std::numeric_limits<std::ptrdiff_t>::max());
+
+    // SIG_ATOMIC_MIN
+    assert(SIG_ATOMIC_MIN == std::numeric_limits<std::sig_atomic_t>::min());
+
+    // SIG_ATOMIC_MAX
+    assert(SIG_ATOMIC_MAX == std::numeric_limits<std::sig_atomic_t>::max());
+
+    // SIZE_MAX
+    assert(SIZE_MAX == std::numeric_limits<std::size_t>::max());
+
+    // WCHAR_MIN
+    assert(WCHAR_MIN == std::numeric_limits<wchar_t>::min());
+
+    // WCHAR_MAX
+    assert(WCHAR_MAX == std::numeric_limits<wchar_t>::max());
+
+    // WINT_MIN
+    assert(WINT_MIN == std::numeric_limits<std::wint_t>::min());
+
+    // WINT_MAX
+    assert(WINT_MAX == std::numeric_limits<std::wint_t>::max());
+
+#ifndef INT8_C
+#error INT8_C not defined
+#endif
+
+#ifndef INT16_C
+#error INT16_C not defined
+#endif
+
+#ifndef INT32_C
+#error INT32_C not defined
+#endif
+
+#ifndef INT64_C
+#error INT64_C not defined
+#endif
+
+#ifndef UINT8_C
+#error UINT8_C not defined
+#endif
+
+#ifndef UINT16_C
+#error UINT16_C not defined
+#endif
+
+#ifndef UINT32_C
+#error UINT32_C not defined
+#endif
+
+#ifndef UINT64_C
+#error UINT64_C not defined
+#endif
+
+#ifndef INTMAX_C
+#error INTMAX_C not defined
+#endif
+
+#ifndef UINTMAX_C
+#error UINTMAX_C not defined
+#endif
+}
diff --git a/final/test/language.support/cstdint/version.pass.cpp b/final/test/language.support/cstdint/version.pass.cpp
new file mode 100644
index 0000000..4c9a43a
--- /dev/null
+++ b/final/test/language.support/cstdint/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdint>
+
+#include <cstdint>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/nothing_to_do.pass.cpp b/final/test/language.support/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp b/final/test/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
new file mode 100644
index 0000000..cf8d4af
--- /dev/null
+++ b/final/test/language.support/support.dynamic/alloc.errors/bad.alloc/bad_alloc.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_alloc
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_alloc>::value),
+                 "std::is_base_of<std::exception, std::bad_alloc>::value");
+    static_assert(std::is_polymorphic<std::bad_alloc>::value,
+                 "std::is_polymorphic<std::bad_alloc>::value");
+    std::bad_alloc b;
+    std::bad_alloc b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/final/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp b/final/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp
new file mode 100644
index 0000000..7de5033
--- /dev/null
+++ b/final/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_length.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_array_length
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if __LIBCPP_STD_VER > 11
+    static_assert((std::is_base_of<std::bad_alloc, std::bad_array_length>::value),
+                  "std::is_base_of<std::bad_alloc, std::bad_array_length>::value");
+    static_assert(std::is_polymorphic<std::bad_array_length>::value,
+                 "std::is_polymorphic<std::bad_array_length>::value");
+    std::bad_array_length b;
+    std::bad_array_length b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+#endif
+}
diff --git a/final/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp b/final/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
new file mode 100644
index 0000000..50521c0
--- /dev/null
+++ b/final/test/language.support/support.dynamic/alloc.errors/new.badlength/bad_array_new_length.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_array_new_length
+
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value),
+                  "std::is_base_of<std::bad_alloc, std::bad_array_new_length>::value");
+    static_assert(std::is_polymorphic<std::bad_array_new_length>::value,
+                 "std::is_polymorphic<std::bad_array_new_length>::value");
+    std::bad_array_new_length b;
+    std::bad_array_new_length b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/final/test/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp b/final/test/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp
new file mode 100644
index 0000000..6b799a3
--- /dev/null
+++ b/final/test/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test new_handler
+
+#include <new>
+
+void f() {}
+
+int main()
+{
+    std::new_handler p = f;
+}
diff --git a/final/test/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp b/final/test/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/support.dynamic/alloc.errors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp b/final/test/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp
new file mode 100644
index 0000000..55a3eda
--- /dev/null
+++ b/final/test/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test get_new_handler
+
+#include <new>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+    assert(std::get_new_handler() == 0);
+    std::set_new_handler(f1);
+    assert(std::get_new_handler() == f1);
+    std::set_new_handler(f2);
+    assert(std::get_new_handler() == f2);
+}
diff --git a/final/test/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp b/final/test/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp
new file mode 100644
index 0000000..349bf44
--- /dev/null
+++ b/final/test/language.support/support.dynamic/alloc.errors/set.new.handler/set_new_handler.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_new_handler
+
+#include <new>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+    assert(std::set_new_handler(f1) == 0);
+    assert(std::set_new_handler(f2) == f1);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
new file mode 100644
index 0000000..63f847f
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new[]
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void*volatile vp = operator new[] (std::numeric_limits<std::size_t>::max());
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(new_handler_called == 1);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    delete [] ap;
+    assert(A_constructed == 0);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
new file mode 100644
index 0000000..60bc7c4
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new [] (nothrow)
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void*volatile vp = operator new [] (std::numeric_limits<std::size_t>::max(), std::nothrow);
+        assert(new_handler_called == 1);
+        assert(vp == 0);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new(std::nothrow) A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    delete [] ap;
+    assert(A_constructed == 0);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
new file mode 100644
index 0000000..9bf6e8a
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new [] nothrow by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+volatile int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    A* ap = new (std::nothrow) A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    assert(new_called);
+    delete [] ap;
+    assert(A_constructed == 0);
+    assert(!new_called);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
new file mode 100644
index 0000000..959bc45
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new[] replacement by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+volatile int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    A* ap = new A[3];
+    assert(ap);
+    assert(A_constructed == 3);
+    assert(new_called == 1);
+    delete [] ap;
+    assert(A_constructed == 0);
+    assert(new_called == 0);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.dataraces/not_testable.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp
new file mode 100644
index 0000000..ad306e0
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.placement/new.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test placement new
+
+#include <new>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    char buf[sizeof(A)];
+
+    A* ap = new(buf) A;
+    assert((char*)ap == buf);
+    assert(A_constructed == 1);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
new file mode 100644
index 0000000..1ab52ae
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.placement/new_array.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test placement new array
+
+#include <new>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+    A() {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    char buf[3*sizeof(A)];
+
+    A* ap = new(buf) A[3];
+    assert((char*)ap == buf);
+    assert(A_constructed == 3);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
new file mode 100644
index 0000000..4d219e3
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void* vp = operator new (std::numeric_limits<std::size_t>::max());
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(new_handler_called == 1);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new A;
+    assert(ap);
+    assert(A_constructed);
+    delete ap;
+    assert(!A_constructed);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
new file mode 100644
index 0000000..c54d14e
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new (nothrow)
+
+#include <new>
+#include <cstddef>
+#include <cassert>
+#include <limits>
+
+int new_handler_called = 0;
+
+void new_handler()
+{
+    ++new_handler_called;
+    std::set_new_handler(0);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    std::set_new_handler(new_handler);
+    try
+    {
+        void* vp = operator new (std::numeric_limits<std::size_t>::max(), std::nothrow);
+        assert(new_handler_called == 1);
+        assert(vp == 0);
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    A* ap = new(std::nothrow) A;
+    assert(ap);
+    assert(A_constructed);
+    delete ap;
+    assert(!A_constructed);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
new file mode 100644
index 0000000..ed3c035
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new nothrow by replacing only operator new
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    A* ap = new (std::nothrow) A;
+    assert(ap);
+    assert(A_constructed);
+    assert(new_called);
+    delete ap;
+    assert(!A_constructed);
+    assert(!new_called);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
new file mode 100644
index 0000000..7646097
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/new.delete.single/new_replace.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test operator new replacement
+
+#include <new>
+#include <cstddef>
+#include <cstdlib>
+#include <cassert>
+#include <limits>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+bool A_constructed = false;
+
+struct A
+{
+    A() {A_constructed = true;}
+    ~A() {A_constructed = false;}
+};
+
+int main()
+{
+    A* ap = new A;
+    assert(ap);
+    assert(A_constructed);
+    assert(new_called);
+    delete ap;
+    assert(!A_constructed);
+    assert(!new_called);
+}
diff --git a/final/test/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp b/final/test/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/support.dynamic/new.delete/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.dynamic/version.pass.cpp b/final/test/language.support/support.dynamic/version.pass.cpp
new file mode 100644
index 0000000..ba1ff51
--- /dev/null
+++ b/final/test/language.support/support.dynamic/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <new>
+
+#include <new>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.exception/bad.exception/bad_exception.pass.cpp b/final/test/language.support/support.exception/bad.exception/bad_exception.pass.cpp
new file mode 100644
index 0000000..3baddaa
--- /dev/null
+++ b/final/test/language.support/support.exception/bad.exception/bad_exception.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_exception>::value),
+                 "std::is_base_of<std::exception, std::bad_exception>::value");
+    static_assert(std::is_polymorphic<std::bad_exception>::value,
+                 "std::is_polymorphic<std::bad_exception>::value");
+    std::bad_exception b;
+    std::bad_exception b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/final/test/language.support/support.exception/except.nested/assign.pass.cpp b/final/test/language.support/support.exception/except.nested/assign.pass.cpp
new file mode 100644
index 0000000..cbe303c
--- /dev/null
+++ b/final/test/language.support/support.exception/except.nested/assign.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception& operator=(const nested_exception&) throw() = default;
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    explicit A(int data) : data_(data) {}
+
+    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    {
+        std::nested_exception e0;
+        std::nested_exception e;
+        e = e0;
+        assert(e.nested_ptr() == nullptr);
+    }
+    {
+        try
+        {
+            throw A(2);
+            assert(false);
+        }
+        catch (const A&)
+        {
+            std::nested_exception e0;
+            std::nested_exception e;
+            e = e0;
+            assert(e.nested_ptr() != nullptr);
+            try
+            {
+                rethrow_exception(e.nested_ptr());
+                assert(false);
+            }
+            catch (const A& a)
+            {
+                assert(a == A(2));
+            }
+        }
+    }
+}
diff --git a/final/test/language.support/support.exception/except.nested/ctor_copy.pass.cpp b/final/test/language.support/support.exception/except.nested/ctor_copy.pass.cpp
new file mode 100644
index 0000000..bfa1370
--- /dev/null
+++ b/final/test/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception(const nested_exception&) throw() = default;
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    explicit A(int data) : data_(data) {}
+
+    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    {
+        std::nested_exception e0;
+        std::nested_exception e = e0;
+        assert(e.nested_ptr() == nullptr);
+    }
+    {
+        try
+        {
+            throw A(2);
+            assert(false);
+        }
+        catch (const A&)
+        {
+            std::nested_exception e0;
+            std::nested_exception e = e0;
+            assert(e.nested_ptr() != nullptr);
+            try
+            {
+                rethrow_exception(e.nested_ptr());
+                assert(false);
+            }
+            catch (const A& a)
+            {
+                assert(a == A(2));
+            }
+        }
+    }
+}
diff --git a/final/test/language.support/support.exception/except.nested/ctor_default.pass.cpp b/final/test/language.support/support.exception/except.nested/ctor_default.pass.cpp
new file mode 100644
index 0000000..1422f77
--- /dev/null
+++ b/final/test/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// nested_exception() throw();
+
+#include <exception>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    explicit A(int data) : data_(data) {}
+
+    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    {
+        std::nested_exception e;
+        assert(e.nested_ptr() == nullptr);
+    }
+    {
+        try
+        {
+            throw A(2);
+            assert(false);
+        }
+        catch (const A&)
+        {
+            std::nested_exception e;
+            assert(e.nested_ptr() != nullptr);
+            try
+            {
+                rethrow_exception(e.nested_ptr());
+                assert(false);
+            }
+            catch (const A& a)
+            {
+                assert(a == A(2));
+            }
+        }
+    }
+}
diff --git a/final/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/final/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
new file mode 100644
index 0000000..567ed57
--- /dev/null
+++ b/final/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// template <class E> void rethrow_if_nested(const E& e);
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    explicit A(int data) : data_(data) {}
+    virtual ~A() _NOEXCEPT {}
+
+    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+class B
+    : public std::nested_exception,
+      public A
+{
+public:
+    explicit B(int data) : A(data) {}
+    B(const B& b) : A(b) {}
+};
+
+int main()
+{
+    {
+        try
+        {
+            A a(3);
+            std::rethrow_if_nested(a);
+            assert(true);
+        }
+        catch (...)
+        {
+            assert(false);
+        }
+    }
+    {
+        try
+        {
+            throw B(5);
+        }
+        catch (const B& b)
+        {
+            try
+            {
+                throw b;
+            }
+            catch (const A& a)
+            {
+                try
+                {
+                    std::rethrow_if_nested(a);
+                    assert(false);
+                }
+                catch (const B& b)
+                {
+                    assert(b == B(5));
+                }
+            }
+        }
+    }
+    {
+        try
+        {
+            std::rethrow_if_nested(1);
+            assert(true);
+        }
+        catch (...)
+        {
+            assert(false);
+        }
+    }
+}
diff --git a/final/test/language.support/support.exception/except.nested/rethrow_nested.pass.cpp b/final/test/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
new file mode 100644
index 0000000..b072690
--- /dev/null
+++ b/final/test/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// void rethrow_nested [[noreturn]] () const;
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    explicit A(int data) : data_(data) {}
+
+    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+void go_quietly()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    {
+        try
+        {
+            throw A(2);
+            assert(false);
+        }
+        catch (const A&)
+        {
+            const std::nested_exception e;
+            assert(e.nested_ptr() != nullptr);
+            try
+            {
+                e.rethrow_nested();
+                assert(false);
+            }
+            catch (const A& a)
+            {
+                assert(a == A(2));
+            }
+        }
+    }
+    {
+        try
+        {
+            std::set_terminate(go_quietly);
+            const std::nested_exception e;
+            e.rethrow_nested();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(false);
+        }
+    }
+}
diff --git a/final/test/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/final/test/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
new file mode 100644
index 0000000..887264a
--- /dev/null
+++ b/final/test/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// class nested_exception;
+
+// template<class T> void throw_with_nested [[noreturn]] (T&& t);
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    explicit A(int data) : data_(data) {}
+
+    friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
+};
+
+class B
+    : public std::nested_exception
+{
+    int data_;
+public:
+    explicit B(int data) : data_(data) {}
+
+    friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
+};
+
+int main()
+{
+    {
+        try
+        {
+            A a(3);
+            std::throw_with_nested(a);
+            assert(false);
+        }
+        catch (const A& a)
+        {
+            assert(a == A(3));
+        }
+    }
+    {
+        try
+        {
+            A a(4);
+            std::throw_with_nested(a);
+            assert(false);
+        }
+        catch (const std::nested_exception& e)
+        {
+            assert(e.nested_ptr() == nullptr);
+        }
+    }
+    {
+        try
+        {
+            B b(5);
+            std::throw_with_nested(b);
+            assert(false);
+        }
+        catch (const B& b)
+        {
+            assert(b == B(5));
+        }
+    }
+    {
+        try
+        {
+            B b(6);
+            std::throw_with_nested(b);
+            assert(false);
+        }
+        catch (const std::nested_exception& e)
+        {
+            assert(e.nested_ptr() == nullptr);
+            const B& b = dynamic_cast<const B&>(e);
+            assert(b == B(6));
+        }
+    }
+    {
+        try
+        {
+            int i = 7;
+            std::throw_with_nested(i);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 7);
+        }
+    }
+}
diff --git a/final/test/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp b/final/test/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/support.exception/exception.terminate/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp b/final/test/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp
new file mode 100644
index 0000000..82ae4aa
--- /dev/null
+++ b/final/test/language.support/support.exception/exception.terminate/set.terminate/get_terminate.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test get_terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+    std::set_terminate(f1);
+    assert(std::get_terminate() == f1);
+    std::set_terminate(f2);
+    assert(std::get_terminate() == f2);
+}
diff --git a/final/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp b/final/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
new file mode 100644
index 0000000..c4bff60
--- /dev/null
+++ b/final/test/language.support/support.exception/exception.terminate/set.terminate/set_terminate.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+    std::set_terminate(f1);
+    assert(std::set_terminate(f2) == f1);
+}
diff --git a/final/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/final/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
new file mode 100644
index 0000000..232ce0a
--- /dev/null
+++ b/final/test/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test terminate_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+    std::terminate_handler p = f;
+}
diff --git a/final/test/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp b/final/test/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp
new file mode 100644
index 0000000..3199d9b
--- /dev/null
+++ b/final/test/language.support/support.exception/exception.terminate/terminate/terminate.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test terminate
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::set_terminate(f1);
+    std::terminate();
+    assert(false);
+}
diff --git a/final/test/language.support/support.exception/exception/exception.pass.cpp b/final/test/language.support/support.exception/exception/exception.pass.cpp
new file mode 100644
index 0000000..ad53b6e
--- /dev/null
+++ b/final/test/language.support/support.exception/exception/exception.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert(std::is_polymorphic<std::exception>::value,
+                 "std::is_polymorphic<std::exception>::value");
+    std::exception b;
+    std::exception b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/final/test/language.support/support.exception/propagation/current_exception.pass.cpp b/final/test/language.support/support.exception/propagation/current_exception.pass.cpp
new file mode 100644
index 0000000..9ff0d6e
--- /dev/null
+++ b/final/test/language.support/support.exception/propagation/current_exception.pass.cpp
@@ -0,0 +1,269 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// exception_ptr current_exception();
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    static int constructed;
+
+    A() {++constructed;}
+    ~A() {--constructed;}
+    A(const A&)  {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+    {
+        std::exception_ptr p = std::current_exception();
+        assert(p == nullptr);
+    }
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p2;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p2 = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p == p2);
+        }
+        assert(A::constructed == 1);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p2;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (A& a)
+        {
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p2 = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p == p2);
+        }
+        assert(A::constructed == 1);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p2;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (A a)
+        {
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 2);
+            assert(p != nullptr);
+            p2 = std::current_exception();
+            assert(A::constructed == 2);
+            assert(p == p2);
+        }
+        assert(A::constructed == 1);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                std::exception_ptr p = std::current_exception();
+                assert(A::constructed == 1);
+                assert(p != nullptr);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                std::exception_ptr p = std::current_exception();
+                assert(A::constructed == 1);
+                assert(p != nullptr);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            std::exception_ptr p = std::current_exception();
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+        }
+        assert(A::constructed == 0);
+    }
+    assert(A::constructed == 0);
+    {
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        std::exception_ptr p = std::current_exception();
+        assert(A::constructed == 0);
+        assert(p == nullptr);
+    }
+    assert(A::constructed == 0);
+    {
+        std::exception_ptr p;
+        try
+        {
+            assert(A::constructed == 0);
+            throw A();
+            assert(false);
+        }
+        catch (...)
+        {
+            assert(A::constructed == 1);
+            try
+            {
+                assert(A::constructed == 1);
+                throw;
+                assert(false);
+            }
+            catch (...)
+            {
+                p = std::current_exception();
+                assert(A::constructed == 1);
+            }
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 1);
+        assert(p != nullptr);
+    }
+    assert(A::constructed == 0);
+}
diff --git a/final/test/language.support/support.exception/propagation/exception_ptr.pass.cpp b/final/test/language.support/support.exception/propagation/exception_ptr.pass.cpp
new file mode 100644
index 0000000..3aa8dcf
--- /dev/null
+++ b/final/test/language.support/support.exception/propagation/exception_ptr.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// typedef unspecified exception_ptr;
+
+// exception_ptr shall satisfy the requirements of NullablePointer.
+
+#include <exception>
+#include <cassert>
+
+int main()
+{
+    std::exception_ptr p;
+    assert(p == nullptr);
+    std::exception_ptr p2 = p;
+    assert(nullptr == p);
+    assert(!p);
+    assert(p2 == p);
+    p2 = p;
+    assert(p2 == p);
+    assert(p2 == nullptr);
+    std::exception_ptr p3 = nullptr;
+    assert(p3 == nullptr);
+    p3 = nullptr;
+    assert(p3 == nullptr);
+}
diff --git a/final/test/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/final/test/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
new file mode 100644
index 0000000..89c9f85
--- /dev/null
+++ b/final/test/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// template<class E> exception_ptr make_exception_ptr(E e);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    static int constructed;
+    int data_;
+
+    A(int data = 0) : data_(data) {++constructed;}
+    ~A() {--constructed;}
+    A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+    {
+        std::exception_ptr p = std::make_exception_ptr(A(5));
+        try
+        {
+            std::rethrow_exception(p);
+            assert(false);
+        }
+        catch (const A& a)
+        {
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p = nullptr;
+            assert(p == nullptr);
+            assert(a.data_ == 5);
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+}
diff --git a/final/test/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/final/test/language.support/support.exception/propagation/rethrow_exception.pass.cpp
new file mode 100644
index 0000000..e47a598
--- /dev/null
+++ b/final/test/language.support/support.exception/propagation/rethrow_exception.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+// void rethrow_exception [[noreturn]] (exception_ptr p);
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    static int constructed;
+    int data_;
+
+    A(int data = 0) : data_(data) {++constructed;}
+    ~A() {--constructed;}
+    A(const A& a) : data_(a.data_) {++constructed;}
+};
+
+int A::constructed = 0;
+
+int main()
+{
+    {
+        std::exception_ptr p;
+        try
+        {
+            throw A(3);
+        }
+        catch (...)
+        {
+            p = std::current_exception();
+        }
+        try
+        {
+            std::rethrow_exception(p);
+            assert(false);
+        }
+        catch (const A& a)
+        {
+            assert(A::constructed == 1);
+            assert(p != nullptr);
+            p = nullptr;
+            assert(p == nullptr);
+            assert(a.data_ == 3);
+            assert(A::constructed == 1);
+        }
+        assert(A::constructed == 0);
+    }
+}
diff --git a/final/test/language.support/support.exception/uncaught/uncaught_exception.pass.cpp b/final/test/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
new file mode 100644
index 0000000..22d8d8e
--- /dev/null
+++ b/final/test/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test uncaught_exception
+
+#include <exception>
+#include <cassert>
+
+struct A
+{
+    ~A()
+    {
+        assert(std::uncaught_exception());
+    }
+};
+
+struct B
+{
+    B()
+    {
+        // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
+        assert(!std::uncaught_exception());
+    }
+};
+
+int main()
+{
+    try
+    {
+        A a;
+        assert(!std::uncaught_exception());
+        throw B();
+    }
+    catch (...)
+    {
+        assert(!std::uncaught_exception());
+    }
+    assert(!std::uncaught_exception());
+}
diff --git a/final/test/language.support/support.exception/version.pass.cpp b/final/test/language.support/support.exception/version.pass.cpp
new file mode 100644
index 0000000..acdedbb
--- /dev/null
+++ b/final/test/language.support/support.exception/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <exception>
+
+#include <exception>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.general/nothing_to_do.pass.cpp b/final/test/language.support/support.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/support.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.initlist/support.initlist.access/access.pass.cpp b/final/test/language.support/support.initlist/support.initlist.access/access.pass.cpp
new file mode 100644
index 0000000..2f07206
--- /dev/null
+++ b/final/test/language.support/support.initlist/support.initlist.access/access.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// const E* begin() const;
+// const E* end() const;
+// size_t size() const;
+
+#include <initializer_list>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+struct A
+{
+    A(std::initializer_list<int> il)
+    {
+        const int* b = il.begin();
+        const int* e = il.end();
+        assert(il.size() == 3);
+        assert(e - b == il.size());
+        assert(*b++ == 3);
+        assert(*b++ == 2);
+        assert(*b++ == 1);
+    }
+};
+
+#if _LIBCPP_STD_VER > 11
+struct B
+{
+    constexpr B(std::initializer_list<int> il)
+    {
+        const int* b = il.begin();
+        const int* e = il.end();
+        assert(il.size() == 3);
+        assert(e - b == il.size());
+        assert(*b++ == 3);
+        assert(*b++ == 2);
+        assert(*b++ == 1);
+    }
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    A test1 = {3, 2, 1};
+#endif
+#if _LIBCPP_STD_VER > 11
+    constexpr B test2 = {3, 2, 1};
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp b/final/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp
new file mode 100644
index 0000000..7822a62
--- /dev/null
+++ b/final/test/language.support/support.initlist/support.initlist.cons/default.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E> class initializer_list;
+
+// initializer_list();
+
+#include <initializer_list>
+#include <cassert>
+
+struct A {};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    std::initializer_list<A> il;
+    assert(il.size() == 0);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if _LIBCPP_STD_VER > 11
+    constexpr std::initializer_list<A> il2;
+    static_assert(il2.size() == 0, "");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp b/final/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
new file mode 100644
index 0000000..5fcd28f
--- /dev/null
+++ b/final/test/language.support/support.initlist/support.initlist.range/begin_end.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+// template<class E> const E* begin(initializer_list<E> il);
+
+#include <initializer_list>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+struct A
+{
+    A(std::initializer_list<int> il)
+    {
+        const int* b = begin(il);
+        const int* e = end(il);
+        assert(il.size() == 3);
+        assert(e - b == il.size());
+        assert(*b++ == 3);
+        assert(*b++ == 2);
+        assert(*b++ == 1);
+    }
+};
+
+#if _LIBCPP_STD_VER > 11
+struct B
+{
+    constexpr B(std::initializer_list<int> il)
+    {
+        const int* b = begin(il);
+        const int* e = end(il);
+        assert(il.size() == 3);
+        assert(e - b == il.size());
+        assert(*b++ == 3);
+        assert(*b++ == 2);
+        assert(*b++ == 1);
+    }
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    A test1 = {3, 2, 1};
+#endif
+#if _LIBCPP_STD_VER > 11
+    constexpr B test2 = {3, 2, 1};
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/language.support/support.initlist/types.pass.cpp b/final/test/language.support/support.initlist/types.pass.cpp
new file mode 100644
index 0000000..8358300
--- /dev/null
+++ b/final/test/language.support/support.initlist/types.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class E>
+// class initializer_list
+// {
+// public:
+//     typedef E        value_type;
+//     typedef const E& reference;
+//     typedef const E& const_reference;
+//     typedef size_t   size_type;
+//
+//     typedef const E* iterator;
+//     typedef const E* const_iterator;
+
+#include <initializer_list>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    static_assert((std::is_same<std::initializer_list<A>::value_type, A>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::reference, const A&>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::const_reference, const A&>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::iterator, const A*>::value), "");
+    static_assert((std::is_same<std::initializer_list<A>::const_iterator, const A*>::value), "");
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/language.support/support.initlist/version.pass.cpp b/final/test/language.support/support.initlist/version.pass.cpp
new file mode 100644
index 0000000..f3f08cd
--- /dev/null
+++ b/final/test/language.support/support.initlist/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <initializer_list>
+
+#include <initializer_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.limits/c.limits/cfloat.pass.cpp b/final/test/language.support/support.limits/c.limits/cfloat.pass.cpp
new file mode 100644
index 0000000..5f63af6
--- /dev/null
+++ b/final/test/language.support/support.limits/c.limits/cfloat.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test cfloat
+
+#include <cfloat>
+
+#ifndef FLT_ROUNDS
+#error FLT_ROUNDS not defined
+#endif
+
+#ifndef FLT_EVAL_METHOD
+#error FLT_EVAL_METHOD not defined
+#endif
+
+#ifndef FLT_RADIX
+#error FLT_RADIX not defined
+#endif
+
+#ifndef FLT_MANT_DIG
+#error FLT_MANT_DIG not defined
+#endif
+
+#ifndef DBL_MANT_DIG
+#error DBL_MANT_DIG not defined
+#endif
+
+#ifndef LDBL_MANT_DIG
+#error LDBL_MANT_DIG not defined
+#endif
+
+#ifndef DECIMAL_DIG
+#error DECIMAL_DIG not defined
+#endif
+
+#ifndef FLT_DIG
+#error FLT_DIG not defined
+#endif
+
+#ifndef DBL_DIG
+#error DBL_DIG not defined
+#endif
+
+#ifndef LDBL_DIG
+#error LDBL_DIG not defined
+#endif
+
+#ifndef FLT_MIN_EXP
+#error FLT_MIN_EXP not defined
+#endif
+
+#ifndef DBL_MIN_EXP
+#error DBL_MIN_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_EXP
+#error LDBL_MIN_EXP not defined
+#endif
+
+#ifndef FLT_MIN_10_EXP
+#error FLT_MIN_10_EXP not defined
+#endif
+
+#ifndef DBL_MIN_10_EXP
+#error DBL_MIN_10_EXP not defined
+#endif
+
+#ifndef LDBL_MIN_10_EXP
+#error LDBL_MIN_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX_EXP
+#error FLT_MAX_EXP not defined
+#endif
+
+#ifndef DBL_MAX_EXP
+#error DBL_MAX_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_EXP
+#error LDBL_MAX_EXP not defined
+#endif
+
+#ifndef FLT_MAX_10_EXP
+#error FLT_MAX_10_EXP not defined
+#endif
+
+#ifndef DBL_MAX_10_EXP
+#error DBL_MAX_10_EXP not defined
+#endif
+
+#ifndef LDBL_MAX_10_EXP
+#error LDBL_MAX_10_EXP not defined
+#endif
+
+#ifndef FLT_MAX
+#error FLT_MAX not defined
+#endif
+
+#ifndef DBL_MAX
+#error DBL_MAX not defined
+#endif
+
+#ifndef LDBL_MAX
+#error LDBL_MAX not defined
+#endif
+
+#ifndef FLT_EPSILON
+#error FLT_EPSILON not defined
+#endif
+
+#ifndef DBL_EPSILON
+#error DBL_EPSILON not defined
+#endif
+
+#ifndef LDBL_EPSILON
+#error LDBL_EPSILON not defined
+#endif
+
+#ifndef FLT_MIN
+#error FLT_MIN not defined
+#endif
+
+#ifndef DBL_MIN
+#error DBL_MIN not defined
+#endif
+
+#ifndef LDBL_MIN
+#error LDBL_MIN not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.limits/c.limits/climits.pass.cpp b/final/test/language.support/support.limits/c.limits/climits.pass.cpp
new file mode 100644
index 0000000..5e31b49
--- /dev/null
+++ b/final/test/language.support/support.limits/c.limits/climits.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+ // test climits
+
+#include <climits>
+
+#ifndef CHAR_BIT
+#error CHAR_BIT not defined
+#endif
+
+#ifndef SCHAR_MIN
+#error SCHAR_MIN not defined
+#endif
+
+#ifndef SCHAR_MAX
+#error SCHAR_MAX not defined
+#endif
+
+#ifndef UCHAR_MAX
+#error UCHAR_MAX not defined
+#endif
+
+#ifndef CHAR_MIN
+#error CHAR_MIN not defined
+#endif
+
+#ifndef CHAR_MAX
+#error CHAR_MAX not defined
+#endif
+
+#ifndef MB_LEN_MAX
+#error MB_LEN_MAX not defined
+#endif
+
+#ifndef SHRT_MIN
+#error SHRT_MIN not defined
+#endif
+
+#ifndef SHRT_MAX
+#error SHRT_MAX not defined
+#endif
+
+#ifndef USHRT_MAX
+#error USHRT_MAX not defined
+#endif
+
+#ifndef INT_MIN
+#error INT_MIN not defined
+#endif
+
+#ifndef INT_MAX
+#error INT_MAX not defined
+#endif
+
+#ifndef UINT_MAX
+#error UINT_MAX not defined
+#endif
+
+#ifndef LONG_MIN
+#error LONG_MIN not defined
+#endif
+
+#ifndef LONG_MAX
+#error LONG_MAX not defined
+#endif
+
+#ifndef ULONG_MAX
+#error ULONG_MAX not defined
+#endif
+
+#ifndef LLONG_MIN
+#error LLONG_MIN not defined
+#endif
+
+#ifndef LLONG_MAX
+#error LLONG_MAX not defined
+#endif
+
+#ifndef ULLONG_MAX
+#error ULLONG_MAX not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.limits/c.limits/version_cfloat.pass.cpp b/final/test/language.support/support.limits/c.limits/version_cfloat.pass.cpp
new file mode 100644
index 0000000..19b4631
--- /dev/null
+++ b/final/test/language.support/support.limits/c.limits/version_cfloat.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfloat>
+
+#include <cfloat>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.limits/c.limits/version_climits.pass.cpp b/final/test/language.support/support.limits/c.limits/version_climits.pass.cpp
new file mode 100644
index 0000000..3fe07a5
--- /dev/null
+++ b/final/test/language.support/support.limits/c.limits/version_climits.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <climits>
+
+#include <climits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.limits/limits/denorm.style/check_values.pass.cpp b/final/test/language.support/support.limits/limits/denorm.style/check_values.pass.cpp
new file mode 100644
index 0000000..c6731fc
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/denorm.style/check_values.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// float_round_style
+
+#include <limits>
+
+typedef char one;
+struct two {one _[2];};
+
+one test(std::float_round_style);
+two test(int);
+
+int main()
+{
+    static_assert(std::round_indeterminate == -1,
+                 "std::round_indeterminate == -1");
+    static_assert(std::round_toward_zero == 0,
+                 "std::round_toward_zero == 0");
+    static_assert(std::round_to_nearest == 1,
+                 "std::round_to_nearest == 1");
+    static_assert(std::round_toward_infinity == 2,
+                 "std::round_toward_infinity == 2");
+    static_assert(std::round_toward_neg_infinity == 3,
+                 "std::round_toward_neg_infinity == 3");
+    static_assert(sizeof(test(std::round_to_nearest)) == 1,
+                 "sizeof(test(std::round_to_nearest)) == 1");
+    static_assert(sizeof(test(1)) == 2,
+                 "sizeof(test(1)) == 2");
+}
diff --git a/final/test/language.support/support.limits/limits/is_specialized.pass.cpp b/final/test/language.support/support.limits/limits/is_specialized.pass.cpp
new file mode 100644
index 0000000..ff5c1a2
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/is_specialized.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// Specializations shall be provided for each arithmetic type, both floating
+// point and integer, including bool. The member is_specialized shall be
+// true for all such specializations of numeric_limits.
+
+// Non-arithmetic standard types, such as complex<T> (26.3.2), shall not
+// have specializations.
+
+// From [numeric.limits]:
+
+// The value of each member of a specialization of numeric_limits on a cv
+// -qualified type cv T shall be equal to the value of the corresponding
+// member of the specialization on the unqualified type T.
+
+// More convenient to test it here.
+
+#include <limits>
+#include <complex>
+
+template <class T>
+void test()
+{
+    static_assert(std::numeric_limits<T>::is_specialized,
+                 "std::numeric_limits<T>::is_specialized");
+    static_assert(std::numeric_limits<const T>::is_specialized,
+                 "std::numeric_limits<const T>::is_specialized");
+    static_assert(std::numeric_limits<volatile T>::is_specialized,
+                 "std::numeric_limits<volatile T>::is_specialized");
+    static_assert(std::numeric_limits<const volatile T>::is_specialized,
+                 "std::numeric_limits<const volatile T>::is_specialized");
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<signed char>();
+    test<unsigned char>();
+    test<signed short>();
+    test<unsigned short>();
+    test<signed int>();
+    test<unsigned int>();
+    test<signed long>();
+    test<unsigned long>();
+    test<signed long long>();
+    test<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>();
+    test<__uint128_t>();
+#endif
+    test<float>();
+    test<double>();
+    test<long double>();
+    static_assert(!std::numeric_limits<std::complex<double> >::is_specialized,
+                 "!std::numeric_limits<std::complex<double> >::is_specialized");
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
new file mode 100644
index 0000000..bbead15
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <limits>
+
+/*
+<limits>:
+    numeric_limits
+        is_specialized
+        digits
+        digits10
+        max_digits10
+        is_signed
+        is_integer
+        is_exact
+        radix
+        min_exponent
+        min_exponent10
+        max_exponent
+        max_exponent10
+        has_infinity
+        has_quiet_NaN
+        has_signaling_NaN
+        has_denorm
+        has_denorm_loss
+        is_iec559
+        is_bounded
+        is_modulo
+        traps
+        tinyness_before
+        round_style
+*/
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+#define TEST_NUMERIC_LIMITS(type) \
+  test(std::numeric_limits<type>::is_specialized); \
+  test(std::numeric_limits<type>::digits); \
+  test(std::numeric_limits<type>::digits10); \
+  test(std::numeric_limits<type>::max_digits10); \
+  test(std::numeric_limits<type>::is_signed); \
+  test(std::numeric_limits<type>::is_integer); \
+  test(std::numeric_limits<type>::is_exact); \
+  test(std::numeric_limits<type>::radix); \
+  test(std::numeric_limits<type>::min_exponent); \
+  test(std::numeric_limits<type>::min_exponent10); \
+  test(std::numeric_limits<type>::max_exponent); \
+  test(std::numeric_limits<type>::max_exponent10); \
+  test(std::numeric_limits<type>::has_infinity); \
+  test(std::numeric_limits<type>::has_quiet_NaN); \
+  test(std::numeric_limits<type>::has_signaling_NaN); \
+  test(std::numeric_limits<type>::has_denorm); \
+  test(std::numeric_limits<type>::has_denorm_loss); \
+  test(std::numeric_limits<type>::is_iec559); \
+  test(std::numeric_limits<type>::is_bounded); \
+  test(std::numeric_limits<type>::is_modulo); \
+  test(std::numeric_limits<type>::traps); \
+  test(std::numeric_limits<type>::tinyness_before); \
+  test(std::numeric_limits<type>::round_style);
+
+struct other {};
+
+int main()
+{
+    // bool
+    TEST_NUMERIC_LIMITS(bool)
+    TEST_NUMERIC_LIMITS(const bool)
+    TEST_NUMERIC_LIMITS(volatile bool)
+    TEST_NUMERIC_LIMITS(const volatile bool)
+
+    // char
+    TEST_NUMERIC_LIMITS(char)
+    TEST_NUMERIC_LIMITS(const char)
+    TEST_NUMERIC_LIMITS(volatile char)
+    TEST_NUMERIC_LIMITS(const volatile char)
+
+    // signed char
+    TEST_NUMERIC_LIMITS(signed char)
+    TEST_NUMERIC_LIMITS(const signed char)
+    TEST_NUMERIC_LIMITS(volatile signed char)
+    TEST_NUMERIC_LIMITS(const volatile signed char)
+
+    // unsigned char
+    TEST_NUMERIC_LIMITS(unsigned char)
+    TEST_NUMERIC_LIMITS(const unsigned char)
+    TEST_NUMERIC_LIMITS(volatile unsigned char)
+    TEST_NUMERIC_LIMITS(const volatile unsigned char)
+
+    // wchar_t
+    TEST_NUMERIC_LIMITS(wchar_t)
+    TEST_NUMERIC_LIMITS(const wchar_t)
+    TEST_NUMERIC_LIMITS(volatile wchar_t)
+    TEST_NUMERIC_LIMITS(const volatile wchar_t)
+
+    // char16_t
+    TEST_NUMERIC_LIMITS(char16_t)
+    TEST_NUMERIC_LIMITS(const char16_t)
+    TEST_NUMERIC_LIMITS(volatile char16_t)
+    TEST_NUMERIC_LIMITS(const volatile char16_t)
+
+    // char32_t
+    TEST_NUMERIC_LIMITS(char32_t)
+    TEST_NUMERIC_LIMITS(const char32_t)
+    TEST_NUMERIC_LIMITS(volatile char32_t)
+    TEST_NUMERIC_LIMITS(const volatile char32_t)
+
+    // short
+    TEST_NUMERIC_LIMITS(short)
+    TEST_NUMERIC_LIMITS(const short)
+    TEST_NUMERIC_LIMITS(volatile short)
+    TEST_NUMERIC_LIMITS(const volatile short)
+
+    // int
+    TEST_NUMERIC_LIMITS(int)
+    TEST_NUMERIC_LIMITS(const int)
+    TEST_NUMERIC_LIMITS(volatile int)
+    TEST_NUMERIC_LIMITS(const volatile int)
+
+    // long
+    TEST_NUMERIC_LIMITS(long)
+    TEST_NUMERIC_LIMITS(const long)
+    TEST_NUMERIC_LIMITS(volatile long)
+    TEST_NUMERIC_LIMITS(const volatile long)
+
+#ifndef _LIBCPP_HAS_NO_INT128
+    TEST_NUMERIC_LIMITS(__int128_t)
+    TEST_NUMERIC_LIMITS(const __int128_t)
+    TEST_NUMERIC_LIMITS(volatile __int128_t)
+    TEST_NUMERIC_LIMITS(const volatile __int128_t)
+#endif
+
+    // long long
+    TEST_NUMERIC_LIMITS(long long)
+    TEST_NUMERIC_LIMITS(const long long)
+    TEST_NUMERIC_LIMITS(volatile long long)
+    TEST_NUMERIC_LIMITS(const volatile long long)
+
+    // unsigned short
+    TEST_NUMERIC_LIMITS(unsigned short)
+    TEST_NUMERIC_LIMITS(const unsigned short)
+    TEST_NUMERIC_LIMITS(volatile unsigned short)
+    TEST_NUMERIC_LIMITS(const volatile unsigned short)
+
+    // unsigned int
+    TEST_NUMERIC_LIMITS(unsigned int)
+    TEST_NUMERIC_LIMITS(const unsigned int)
+    TEST_NUMERIC_LIMITS(volatile unsigned int)
+    TEST_NUMERIC_LIMITS(const volatile unsigned int)
+
+    // unsigned long
+    TEST_NUMERIC_LIMITS(unsigned long)
+    TEST_NUMERIC_LIMITS(const unsigned long)
+    TEST_NUMERIC_LIMITS(volatile unsigned long)
+    TEST_NUMERIC_LIMITS(const volatile unsigned long)
+
+    // unsigned long long
+    TEST_NUMERIC_LIMITS(unsigned long long)
+    TEST_NUMERIC_LIMITS(const unsigned long long)
+    TEST_NUMERIC_LIMITS(volatile unsigned long long)
+    TEST_NUMERIC_LIMITS(const volatile unsigned long long)
+
+#ifndef _LIBCPP_HAS_NO_INT128
+    TEST_NUMERIC_LIMITS(__uint128_t)
+    TEST_NUMERIC_LIMITS(const __uint128_t)
+    TEST_NUMERIC_LIMITS(volatile __uint128_t)
+    TEST_NUMERIC_LIMITS(const volatile __uint128_t)
+#endif
+
+    // float
+    TEST_NUMERIC_LIMITS(float)
+    TEST_NUMERIC_LIMITS(const float)
+    TEST_NUMERIC_LIMITS(volatile float)
+    TEST_NUMERIC_LIMITS(const volatile float)
+    
+    // double
+    TEST_NUMERIC_LIMITS(double)
+    TEST_NUMERIC_LIMITS(const double)
+    TEST_NUMERIC_LIMITS(volatile double)
+    TEST_NUMERIC_LIMITS(const volatile double)
+    
+    // long double
+    TEST_NUMERIC_LIMITS(long double)
+    TEST_NUMERIC_LIMITS(const long double)
+    TEST_NUMERIC_LIMITS(volatile long double)
+    TEST_NUMERIC_LIMITS(const volatile long double)
+
+    // other
+    TEST_NUMERIC_LIMITS(other)
+    TEST_NUMERIC_LIMITS(const other)
+    TEST_NUMERIC_LIMITS(volatile other)
+    TEST_NUMERIC_LIMITS(const volatile other)
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp
new file mode 100644
index 0000000..a452d4e
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/denorm_min.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// denorm_min()
+
+#include <limits>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::denorm_min() == expected);
+    assert(std::numeric_limits<const T>::denorm_min() == expected);
+    assert(std::numeric_limits<volatile T>::denorm_min() == expected);
+    assert(std::numeric_limits<const volatile T>::denorm_min() == expected);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>(0);
+    test<__uint128_t>(0);
+#endif
+    test<float>(__FLT_DENORM_MIN__);
+    test<double>(__DBL_DENORM_MIN__);
+    test<long double>(__LDBL_DENORM_MIN__);
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp
new file mode 100644
index 0000000..2dfea08
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/digits.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// digits
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::digits == expected, "digits test 1");
+    static_assert(std::numeric_limits<const T>::digits == expected, "digits test 2");
+    static_assert(std::numeric_limits<volatile T>::digits == expected, "digits test 3");
+    static_assert(std::numeric_limits<const volatile T>::digits == expected, "digits test 4");
+}
+
+int main()
+{
+    test<bool, 1>();
+    test<char, std::numeric_limits<char>::is_signed ? 7 : 8>();
+    test<signed char, 7>();
+    test<unsigned char, 8>();
+    test<wchar_t, std::numeric_limits<wchar_t>::is_signed ? sizeof(wchar_t)*8-1 : sizeof(wchar_t)*8>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 16>();
+    test<char32_t, 32>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 15>();
+    test<unsigned short, 16>();
+    test<int, 31>();
+    test<unsigned int, 32>();
+    test<long, sizeof(long) == 4 ? 31 : 63>();
+    test<unsigned long, sizeof(long) == 4 ? 32 : 64>();
+    test<long long, 63>();
+    test<unsigned long long, 64>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 127>();
+    test<__uint128_t, 128>();
+#endif
+    test<float, FLT_MANT_DIG>();
+    test<double, DBL_MANT_DIG>();
+    test<long double, LDBL_MANT_DIG>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp
new file mode 100644
index 0000000..2c5302c
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/digits10.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// digits10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::digits10 == expected, "digits10 test 1");
+    static_assert(std::numeric_limits<T>::is_bounded, "digits10 test 5");
+    static_assert(std::numeric_limits<const T>::digits10 == expected, "digits10 test 2");
+    static_assert(std::numeric_limits<const T>::is_bounded, "digits10 test 6");
+    static_assert(std::numeric_limits<volatile T>::digits10 == expected, "digits10 test 3");
+    static_assert(std::numeric_limits<volatile T>::is_bounded, "digits10 test 7");
+    static_assert(std::numeric_limits<const volatile T>::digits10 == expected, "digits10 test 4");
+    static_assert(std::numeric_limits<const volatile T>::is_bounded, "digits10 test 8");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 2>();
+    test<signed char, 2>();
+    test<unsigned char, 2>();
+    test<wchar_t, 5*sizeof(wchar_t)/2-1>();  // 4 -> 9 and 2 -> 4
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 4>();
+    test<char32_t, 9>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 4>();
+    test<unsigned short, 4>();
+    test<int, 9>();
+    test<unsigned int, 9>();
+    test<long, sizeof(long) == 4 ? 9 : 18>();
+    test<unsigned long, sizeof(long) == 4 ? 9 : 19>();
+    test<long long, 18>();
+    test<unsigned long long, 19>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 38>();
+    test<__uint128_t, 38>();
+#endif
+    test<float, FLT_DIG>();
+    test<double, DBL_DIG>();
+    test<long double, LDBL_DIG>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp
new file mode 100644
index 0000000..0cce484
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/epsilon.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// epsilon()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::epsilon() == expected);
+    assert(std::numeric_limits<const T>::epsilon() == expected);
+    assert(std::numeric_limits<volatile T>::epsilon() == expected);
+    assert(std::numeric_limits<const volatile T>::epsilon() == expected);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>(0);
+    test<__uint128_t>(0);
+#endif
+    test<float>(FLT_EPSILON);
+    test<double>(DBL_EPSILON);
+    test<long double>(LDBL_EPSILON);
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp
new file mode 100644
index 0000000..e618020
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/has_denorm.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_denorm
+
+#include <limits>
+
+template <class T, std::float_denorm_style expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_denorm == expected, "has_denorm test 1");
+    static_assert(std::numeric_limits<const T>::has_denorm == expected, "has_denorm test 2");
+    static_assert(std::numeric_limits<volatile T>::has_denorm == expected, "has_denorm test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_denorm == expected, "has_denorm test 4");
+}
+
+int main()
+{
+    test<bool, std::denorm_absent>();
+    test<char, std::denorm_absent>();
+    test<signed char, std::denorm_absent>();
+    test<unsigned char, std::denorm_absent>();
+    test<wchar_t, std::denorm_absent>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, std::denorm_absent>();
+    test<char32_t, std::denorm_absent>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, std::denorm_absent>();
+    test<unsigned short, std::denorm_absent>();
+    test<int, std::denorm_absent>();
+    test<unsigned int, std::denorm_absent>();
+    test<long, std::denorm_absent>();
+    test<unsigned long, std::denorm_absent>();
+    test<long long, std::denorm_absent>();
+    test<unsigned long long, std::denorm_absent>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, std::denorm_absent>();
+    test<__uint128_t, std::denorm_absent>();
+#endif
+    test<float, std::denorm_present>();
+    test<double, std::denorm_present>();
+    test<long double, std::denorm_present>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp
new file mode 100644
index 0000000..660ecf5
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/has_denorm_loss.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_denorm_loss
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_denorm_loss == expected, "has_denorm_loss test 1");
+    static_assert(std::numeric_limits<const T>::has_denorm_loss == expected, "has_denorm_loss test 2");
+    static_assert(std::numeric_limits<volatile T>::has_denorm_loss == expected, "has_denorm_loss test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_denorm_loss == expected, "has_denorm_loss test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, false>();
+    test<__uint128_t, false>();
+#endif
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp
new file mode 100644
index 0000000..f8ca205
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/has_infinity.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_infinity
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_infinity == expected, "has_infinity test 1");
+    static_assert(std::numeric_limits<const T>::has_infinity == expected, "has_infinity test 2");
+    static_assert(std::numeric_limits<volatile T>::has_infinity == expected, "has_infinity test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_infinity == expected, "has_infinity test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, false>();
+    test<__uint128_t, false>();
+#endif
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp
new file mode 100644
index 0000000..7592171
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/has_quiet_NaN.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_quiet_NaN
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_quiet_NaN == expected, "has_quiet_NaN test 1");
+    static_assert(std::numeric_limits<const T>::has_quiet_NaN == expected, "has_quiet_NaN test 2");
+    static_assert(std::numeric_limits<volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_quiet_NaN == expected, "has_quiet_NaN test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, false>();
+    test<__uint128_t, false>();
+#endif
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp
new file mode 100644
index 0000000..d68cd5d
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/has_signaling_NaN.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// has_signaling_NaN
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::has_signaling_NaN == expected, "has_signaling_NaN test 1");
+    static_assert(std::numeric_limits<const T>::has_signaling_NaN == expected, "has_signaling_NaN test 2");
+    static_assert(std::numeric_limits<volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 3");
+    static_assert(std::numeric_limits<const volatile T>::has_signaling_NaN == expected, "has_signaling_NaN test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, false>();
+    test<__uint128_t, false>();
+#endif
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
new file mode 100644
index 0000000..a2ccca3
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// infinity()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::infinity() == expected);
+    assert(std::numeric_limits<const T>::infinity() == expected);
+    assert(std::numeric_limits<volatile T>::infinity() == expected);
+    assert(std::numeric_limits<const volatile T>::infinity() == expected);
+}
+
+extern float zero;
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>(0);
+    test<__uint128_t>(0);
+#endif
+    test<float>(1./zero);
+    test<double>(1./zero);
+    test<long double>(1./zero);
+}
+
+float zero = 0;
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp
new file mode 100644
index 0000000..fa714d5
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/is_bounded.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_bounded
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_bounded == expected, "is_bounded test 1");
+    static_assert(std::numeric_limits<const T>::is_bounded == expected, "is_bounded test 2");
+    static_assert(std::numeric_limits<volatile T>::is_bounded == expected, "is_bounded test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_bounded == expected, "is_bounded test 4");
+}
+
+int main()
+{
+    test<bool, true>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, true>();
+    test<__uint128_t, true>();
+#endif
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp
new file mode 100644
index 0000000..b96a0e7
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/is_exact.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_exact
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_exact == expected, "is_exact test 1");
+    static_assert(std::numeric_limits<const T>::is_exact == expected, "is_exact test 2");
+    static_assert(std::numeric_limits<volatile T>::is_exact == expected, "is_exact test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_exact == expected, "is_exact test 4");
+}
+
+int main()
+{
+    test<bool, true>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, true>();
+    test<__uint128_t, true>();
+#endif
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp
new file mode 100644
index 0000000..4408714
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/is_iec559.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_iec559
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_iec559 == expected, "is_iec559 test 1");
+    static_assert(std::numeric_limits<const T>::is_iec559 == expected, "is_iec559 test 2");
+    static_assert(std::numeric_limits<volatile T>::is_iec559 == expected, "is_iec559 test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_iec559 == expected, "is_iec559 test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, false>();
+    test<__uint128_t, false>();
+#endif
+    test<float, true>();
+    test<double, true>();
+#if (defined(__ppc__) || defined(__ppc64__))
+    test<long double, false>();
+#else
+    test<long double, true>();
+#endif
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp
new file mode 100644
index 0000000..79bc586
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/is_integer.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_integer
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_integer == expected, "is_integer test 1");
+    static_assert(std::numeric_limits<const T>::is_integer == expected, "is_integer test 2");
+    static_assert(std::numeric_limits<volatile T>::is_integer == expected, "is_integer test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_integer == expected, "is_integer test 4");
+}
+
+int main()
+{
+    test<bool, true>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, true>();
+    test<__uint128_t, true>();
+#endif
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp
new file mode 100644
index 0000000..fadc015
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/is_modulo.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_modulo
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_modulo == expected, "is_modulo test 1");
+    static_assert(std::numeric_limits<const T>::is_modulo == expected, "is_modulo test 2");
+    static_assert(std::numeric_limits<volatile T>::is_modulo == expected, "is_modulo test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_modulo == expected, "is_modulo test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, true>();
+    test<signed char, true>();
+    test<unsigned char, true>();
+    test<wchar_t, true>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, true>();
+    test<char32_t, true>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, true>();
+    test<unsigned short, true>();
+    test<int, true>();
+    test<unsigned int, true>();
+    test<long, true>();
+    test<unsigned long, true>();
+    test<long long, true>();
+    test<unsigned long long, true>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, true>();
+    test<__uint128_t, true>();
+#endif
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp
new file mode 100644
index 0000000..28570fd
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/is_signed.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// is_signed
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::is_signed == expected, "is_signed test 1");
+    static_assert(std::numeric_limits<const T>::is_signed == expected, "is_signed test 2");
+    static_assert(std::numeric_limits<volatile T>::is_signed == expected, "is_signed test 3");
+    static_assert(std::numeric_limits<const volatile T>::is_signed == expected, "is_signed test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, char(-1) < char(0)>();
+    test<signed char, true>();
+    test<unsigned char, false>();
+    test<wchar_t, wchar_t(-1) < wchar_t(0)>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, true>();
+    test<unsigned short, false>();
+    test<int, true>();
+    test<unsigned int, false>();
+    test<long, true>();
+    test<unsigned long, false>();
+    test<long long, true>();
+    test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, true>();
+    test<__uint128_t, false>();
+#endif
+    test<float, true>();
+    test<double, true>();
+    test<long double, true>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp
new file mode 100644
index 0000000..21090aa
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/lowest.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// lowest()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::lowest() == expected);
+    assert(std::numeric_limits<T>::is_bounded);
+    assert(std::numeric_limits<const T>::lowest() == expected);
+    assert(std::numeric_limits<const T>::is_bounded);
+    assert(std::numeric_limits<volatile T>::lowest() == expected);
+    assert(std::numeric_limits<volatile T>::is_bounded);
+    assert(std::numeric_limits<const volatile T>::lowest() == expected);
+    assert(std::numeric_limits<const volatile T>::is_bounded);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(CHAR_MIN);
+    test<signed char>(SCHAR_MIN);
+    test<unsigned char>(0);
+    test<wchar_t>(WCHAR_MIN);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>(SHRT_MIN);
+    test<unsigned short>(0);
+    test<int>(INT_MIN);
+    test<unsigned int>(0);
+    test<long>(LONG_MIN);
+    test<unsigned long>(0);
+    test<long long>(LLONG_MIN);
+    test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1);
+    test<__uint128_t>(0);
+#endif
+    test<float>(-FLT_MAX);
+    test<double>(-DBL_MAX);
+    test<long double>(-LDBL_MAX);
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp
new file mode 100644
index 0000000..7517aaa
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/max.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::max() == expected);
+    assert(std::numeric_limits<T>::is_bounded);
+    assert(std::numeric_limits<const T>::max() == expected);
+    assert(std::numeric_limits<const T>::is_bounded);
+    assert(std::numeric_limits<volatile T>::max() == expected);
+    assert(std::numeric_limits<volatile T>::is_bounded);
+    assert(std::numeric_limits<const volatile T>::max() == expected);
+    assert(std::numeric_limits<const volatile T>::is_bounded);
+}
+
+int main()
+{
+    test<bool>(true);
+    test<char>(CHAR_MAX);
+    test<signed char>(SCHAR_MAX);
+    test<unsigned char>(UCHAR_MAX);
+    test<wchar_t>(WCHAR_MAX);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(USHRT_MAX);
+    test<char32_t>(UINT_MAX);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>(SHRT_MAX);
+    test<unsigned short>(USHRT_MAX);
+    test<int>(INT_MAX);
+    test<unsigned int>(UINT_MAX);
+    test<long>(LONG_MAX);
+    test<unsigned long>(ULONG_MAX);
+    test<long long>(LLONG_MAX);
+    test<unsigned long long>(ULLONG_MAX);
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>(__int128_t(__uint128_t(-1)/2));
+    test<__uint128_t>(__uint128_t(-1));
+#endif
+    test<float>(FLT_MAX);
+    test<double>(DBL_MAX);
+    test<long double>(LDBL_MAX);
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp
new file mode 100644
index 0000000..de771eb
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/max_digits10.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_digits10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::max_digits10 == expected, "max_digits10 test 1");
+    static_assert(std::numeric_limits<const T>::max_digits10 == expected, "max_digits10 test 2");
+    static_assert(std::numeric_limits<volatile T>::max_digits10 == expected, "max_digits10 test 3");
+    static_assert(std::numeric_limits<const volatile T>::max_digits10 == expected, "max_digits10 test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 0>();
+    test<__uint128_t, 0>();
+#endif
+    test<float, 2+(FLT_MANT_DIG * 30103)/100000>();
+    test<double, 2+(DBL_MANT_DIG * 30103)/100000>();
+    test<long double, 2+(LDBL_MANT_DIG * 30103)/100000>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp
new file mode 100644
index 0000000..6b61f7b
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/max_exponent.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_exponent
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::max_exponent == expected, "max_exponent test 1");
+    static_assert(std::numeric_limits<const T>::max_exponent == expected, "max_exponent test 2");
+    static_assert(std::numeric_limits<volatile T>::max_exponent == expected, "max_exponent test 3");
+    static_assert(std::numeric_limits<const volatile T>::max_exponent == expected, "max_exponent test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 0>();
+    test<__uint128_t, 0>();
+#endif
+    test<float, FLT_MAX_EXP>();
+    test<double, DBL_MAX_EXP>();
+    test<long double, LDBL_MAX_EXP>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp
new file mode 100644
index 0000000..927585e
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/max_exponent10.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// max_exponent10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::max_exponent10 == expected, "max_exponent10 test 1");
+    static_assert(std::numeric_limits<const T>::max_exponent10 == expected, "max_exponent10 test 2");
+    static_assert(std::numeric_limits<volatile T>::max_exponent10 == expected, "max_exponent10 test 3");
+    static_assert(std::numeric_limits<const volatile T>::max_exponent10 == expected, "max_exponent10 test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 0>();
+    test<__uint128_t, 0>();
+#endif
+    test<float, FLT_MAX_10_EXP>();
+    test<double, DBL_MAX_10_EXP>();
+    test<long double, LDBL_MAX_10_EXP>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp
new file mode 100644
index 0000000..e72fbba
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/min.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min()
+
+#include <limits>
+#include <climits>
+#include <cwchar>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::min() == expected);
+    assert(std::numeric_limits<T>::is_bounded || !std::numeric_limits<T>::is_signed);
+    assert(std::numeric_limits<const T>::min() == expected);
+    assert(std::numeric_limits<const T>::is_bounded || !std::numeric_limits<const T>::is_signed);
+    assert(std::numeric_limits<volatile T>::min() == expected);
+    assert(std::numeric_limits<volatile T>::is_bounded || !std::numeric_limits<volatile T>::is_signed);
+    assert(std::numeric_limits<const volatile T>::min() == expected);
+    assert(std::numeric_limits<const volatile T>::is_bounded || !std::numeric_limits<const volatile T>::is_signed);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(CHAR_MIN);
+    test<signed char>(SCHAR_MIN);
+    test<unsigned char>(0);
+    test<wchar_t>(WCHAR_MIN);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>(SHRT_MIN);
+    test<unsigned short>(0);
+    test<int>(INT_MIN);
+    test<unsigned int>(0);
+    test<long>(LONG_MIN);
+    test<unsigned long>(0);
+    test<long long>(LLONG_MIN);
+    test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>(-__int128_t(__uint128_t(-1)/2) - 1);
+    test<__uint128_t>(0);
+#endif
+    test<float>(FLT_MIN);
+    test<double>(DBL_MIN);
+    test<long double>(LDBL_MIN);
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp
new file mode 100644
index 0000000..245e844
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/min_exponent.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min_exponent
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::min_exponent == expected, "min_exponent test 1");
+    static_assert(std::numeric_limits<const T>::min_exponent == expected, "min_exponent test 2");
+    static_assert(std::numeric_limits<volatile T>::min_exponent == expected, "min_exponent test 3");
+    static_assert(std::numeric_limits<const volatile T>::min_exponent == expected, "min_exponent test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 0>();
+    test<__uint128_t, 0>();
+#endif
+    test<float, FLT_MIN_EXP>();
+    test<double, DBL_MIN_EXP>();
+    test<long double, LDBL_MIN_EXP>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp
new file mode 100644
index 0000000..b54d46f
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/min_exponent10.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// min_exponent10
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::min_exponent10 == expected, "min_exponent10 test 1");
+    static_assert(std::numeric_limits<const T>::min_exponent10 == expected, "min_exponent10 test 2");
+    static_assert(std::numeric_limits<volatile T>::min_exponent10 == expected, "min_exponent10 test 3");
+    static_assert(std::numeric_limits<const volatile T>::min_exponent10 == expected, "min_exponent10 test 4");
+}
+
+int main()
+{
+    test<bool, 0>();
+    test<char, 0>();
+    test<signed char, 0>();
+    test<unsigned char, 0>();
+    test<wchar_t, 0>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 0>();
+    test<char32_t, 0>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 0>();
+    test<unsigned short, 0>();
+    test<int, 0>();
+    test<unsigned int, 0>();
+    test<long, 0>();
+    test<unsigned long, 0>();
+    test<long long, 0>();
+    test<unsigned long long, 0>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 0>();
+    test<__uint128_t, 0>();
+#endif
+    test<float, FLT_MIN_10_EXP>();
+    test<double, DBL_MIN_10_EXP>();
+    test<long double, LDBL_MIN_10_EXP>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp
new file mode 100644
index 0000000..97166f0
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/quiet_NaN.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// quiet_NaN()
+
+#include <limits>
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test_imp(std::true_type)
+{
+    assert(std::isnan(std::numeric_limits<T>::quiet_NaN()));
+    assert(std::isnan(std::numeric_limits<const T>::quiet_NaN()));
+    assert(std::isnan(std::numeric_limits<volatile T>::quiet_NaN()));
+    assert(std::isnan(std::numeric_limits<const volatile T>::quiet_NaN()));
+}
+
+template <class T>
+void
+test_imp(std::false_type)
+{
+    assert(std::numeric_limits<T>::quiet_NaN() == T());
+    assert(std::numeric_limits<const T>::quiet_NaN() == T());
+    assert(std::numeric_limits<volatile T>::quiet_NaN() == T());
+    assert(std::numeric_limits<const volatile T>::quiet_NaN() == T());
+}
+
+template <class T>
+inline
+void
+test()
+{
+    test_imp<T>(std::is_floating_point<T>());
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>();
+    test<__uint128_t>();
+#endif
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp
new file mode 100644
index 0000000..98a2a53
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/radix.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// radix
+
+#include <limits>
+#include <cfloat>
+
+template <class T, int expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::radix == expected, "radix test 1");
+    static_assert(std::numeric_limits<const T>::radix == expected, "radix test 2");
+    static_assert(std::numeric_limits<volatile T>::radix == expected, "radix test 3");
+    static_assert(std::numeric_limits<const volatile T>::radix == expected, "radix test 4");
+}
+
+int main()
+{
+    test<bool, 2>();
+    test<char, 2>();
+    test<signed char, 2>();
+    test<unsigned char, 2>();
+    test<wchar_t, 2>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, 2>();
+    test<char32_t, 2>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, 2>();
+    test<unsigned short, 2>();
+    test<int, 2>();
+    test<unsigned int, 2>();
+    test<long, 2>();
+    test<unsigned long, 2>();
+    test<long long, 2>();
+    test<unsigned long long, 2>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, 2>();
+    test<__uint128_t, 2>();
+#endif
+    test<float, FLT_RADIX>();
+    test<double, FLT_RADIX>();
+    test<long double, FLT_RADIX>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp
new file mode 100644
index 0000000..5da5c95
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/round_error.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// round_error()
+
+#include <limits>
+#include <cfloat>
+#include <cassert>
+
+template <class T>
+void
+test(T expected)
+{
+    assert(std::numeric_limits<T>::round_error() == expected);
+    assert(std::numeric_limits<const T>::round_error() == expected);
+    assert(std::numeric_limits<volatile T>::round_error() == expected);
+    assert(std::numeric_limits<const volatile T>::round_error() == expected);
+}
+
+int main()
+{
+    test<bool>(false);
+    test<char>(0);
+    test<signed char>(0);
+    test<unsigned char>(0);
+    test<wchar_t>(0);
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>(0);
+    test<char32_t>(0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>(0);
+    test<unsigned short>(0);
+    test<int>(0);
+    test<unsigned int>(0);
+    test<long>(0);
+    test<unsigned long>(0);
+    test<long long>(0);
+    test<unsigned long long>(0);
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>(0);
+    test<__uint128_t>(0);
+#endif
+    test<float>(0.5);
+    test<double>(0.5);
+    test<long double>(0.5);
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp
new file mode 100644
index 0000000..645f6f7
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/round_style.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// round_style
+
+#include <limits>
+
+template <class T, std::float_round_style expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::round_style == expected, "round_style test 1");
+    static_assert(std::numeric_limits<const T>::round_style == expected, "round_style test 2");
+    static_assert(std::numeric_limits<volatile T>::round_style == expected, "round_style test 3");
+    static_assert(std::numeric_limits<const volatile T>::round_style == expected, "round_style test 4");
+}
+
+int main()
+{
+    test<bool, std::round_toward_zero>();
+    test<char, std::round_toward_zero>();
+    test<signed char, std::round_toward_zero>();
+    test<unsigned char, std::round_toward_zero>();
+    test<wchar_t, std::round_toward_zero>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, std::round_toward_zero>();
+    test<char32_t, std::round_toward_zero>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, std::round_toward_zero>();
+    test<unsigned short, std::round_toward_zero>();
+    test<int, std::round_toward_zero>();
+    test<unsigned int, std::round_toward_zero>();
+    test<long, std::round_toward_zero>();
+    test<unsigned long, std::round_toward_zero>();
+    test<long long, std::round_toward_zero>();
+    test<unsigned long long, std::round_toward_zero>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, std::round_toward_zero>();
+    test<__uint128_t, std::round_toward_zero>();
+#endif
+    test<float, std::round_to_nearest>();
+    test<double, std::round_to_nearest>();
+    test<long double, std::round_to_nearest>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp
new file mode 100644
index 0000000..d9df999
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/signaling_NaN.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// signaling_NaN()
+
+#include <limits>
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void
+test_imp(std::true_type)
+{
+    assert(std::isnan(std::numeric_limits<T>::signaling_NaN()));
+    assert(std::isnan(std::numeric_limits<const T>::signaling_NaN()));
+    assert(std::isnan(std::numeric_limits<volatile T>::signaling_NaN()));
+    assert(std::isnan(std::numeric_limits<const volatile T>::signaling_NaN()));
+}
+
+template <class T>
+void
+test_imp(std::false_type)
+{
+    assert(std::numeric_limits<T>::signaling_NaN() == T());
+    assert(std::numeric_limits<const T>::signaling_NaN() == T());
+    assert(std::numeric_limits<volatile T>::signaling_NaN() == T());
+    assert(std::numeric_limits<const volatile T>::signaling_NaN() == T());
+}
+
+template <class T>
+inline
+void
+test()
+{
+    test_imp<T>(std::is_floating_point<T>());
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<wchar_t>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t>();
+    test<char32_t>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t>();
+    test<__uint128_t>();
+#endif
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp
new file mode 100644
index 0000000..9e2a843
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// tinyness_before
+
+#include <limits>
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::tinyness_before == expected, "tinyness_before test 1");
+    static_assert(std::numeric_limits<const T>::tinyness_before == expected, "tinyness_before test 2");
+    static_assert(std::numeric_limits<volatile T>::tinyness_before == expected, "tinyness_before test 3");
+    static_assert(std::numeric_limits<const volatile T>::tinyness_before == expected, "tinyness_before test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, false>();
+    test<signed char, false>();
+    test<unsigned char, false>();
+    test<wchar_t, false>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, false>();
+    test<char32_t, false>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, false>();
+    test<unsigned short, false>();
+    test<int, false>();
+    test<unsigned int, false>();
+    test<long, false>();
+    test<unsigned long, false>();
+    test<long long, false>();
+    test<unsigned long long, false>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, false>();
+    test<__uint128_t, false>();
+#endif
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
new file mode 100644
index 0000000..0345363
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// traps
+
+#include <limits>
+
+#if (defined(__i386__) || defined(__x86_64__))
+static const bool integral_types_trap = true;
+#else
+static const bool integral_types_trap = false;
+#endif
+
+template <class T, bool expected>
+void
+test()
+{
+    static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
+    static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
+    static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
+    static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
+}
+
+int main()
+{
+    test<bool, false>();
+    test<char, integral_types_trap>();
+    test<signed char, integral_types_trap>();
+    test<unsigned char, integral_types_trap>();
+    test<wchar_t, integral_types_trap>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<char16_t, integral_types_trap>();
+    test<char32_t, integral_types_trap>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<short, integral_types_trap>();
+    test<unsigned short, integral_types_trap>();
+    test<int, integral_types_trap>();
+    test<unsigned int, integral_types_trap>();
+    test<long, integral_types_trap>();
+    test<unsigned long, integral_types_trap>();
+    test<long long, integral_types_trap>();
+    test<unsigned long long, integral_types_trap>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test<__int128_t, integral_types_trap>();
+    test<__uint128_t, integral_types_trap>();
+#endif
+    test<float, false>();
+    test<double, false>();
+    test<long double, false>();
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.limits/default.pass.cpp b/final/test/language.support/support.limits/limits/numeric.limits/default.pass.cpp
new file mode 100644
index 0000000..6cf5681
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.limits/default.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// The default numeric_limits<T> template shall have all members, but with
+// 0 or false values.
+
+#include <limits>
+#include <cassert>
+
+struct A
+{
+    A(int i = 0) : data_(i) {}
+    int data_;
+};
+
+bool operator == (const A& x, const A& y) {return x.data_ == y.data_;}
+
+int main()
+{
+    static_assert(std::numeric_limits<A>::is_specialized == false,
+                 "std::numeric_limits<A>::is_specialized == false");
+    assert(std::numeric_limits<A>::min() == A());
+    assert(std::numeric_limits<A>::max() == A());
+    assert(std::numeric_limits<A>::lowest() == A());
+    static_assert(std::numeric_limits<A>::digits == 0,
+                 "std::numeric_limits<A>::digits == 0");
+    static_assert(std::numeric_limits<A>::digits10 == 0,
+                 "std::numeric_limits<A>::digits10 == 0");
+    static_assert(std::numeric_limits<A>::max_digits10 == 0,
+                 "std::numeric_limits<A>::max_digits10 == 0");
+    static_assert(std::numeric_limits<A>::is_signed == false,
+                 "std::numeric_limits<A>::is_signed == false");
+    static_assert(std::numeric_limits<A>::is_integer == false,
+                 "std::numeric_limits<A>::is_integer == false");
+    static_assert(std::numeric_limits<A>::is_exact == false,
+                 "std::numeric_limits<A>::is_exact == false");
+    static_assert(std::numeric_limits<A>::radix == 0,
+                 "std::numeric_limits<A>::radix == 0");
+    assert(std::numeric_limits<A>::epsilon() == A());
+    assert(std::numeric_limits<A>::round_error() == A());
+    static_assert(std::numeric_limits<A>::min_exponent == 0,
+                 "std::numeric_limits<A>::min_exponent == 0");
+    static_assert(std::numeric_limits<A>::min_exponent10 == 0,
+                 "std::numeric_limits<A>::min_exponent10 == 0");
+    static_assert(std::numeric_limits<A>::max_exponent == 0,
+                 "std::numeric_limits<A>::max_exponent == 0");
+    static_assert(std::numeric_limits<A>::max_exponent10 == 0,
+                 "std::numeric_limits<A>::max_exponent10 == 0");
+    static_assert(std::numeric_limits<A>::has_infinity == false,
+                 "std::numeric_limits<A>::has_infinity == false");
+    static_assert(std::numeric_limits<A>::has_quiet_NaN == false,
+                 "std::numeric_limits<A>::has_quiet_NaN == false");
+    static_assert(std::numeric_limits<A>::has_signaling_NaN == false,
+                 "std::numeric_limits<A>::has_signaling_NaN == false");
+    static_assert(std::numeric_limits<A>::has_denorm == std::denorm_absent,
+                 "std::numeric_limits<A>::has_denorm == std::denorm_absent");
+    static_assert(std::numeric_limits<A>::has_denorm_loss == false,
+                 "std::numeric_limits<A>::has_denorm_loss == false");
+    assert(std::numeric_limits<A>::infinity() == A());
+    assert(std::numeric_limits<A>::quiet_NaN() == A());
+    assert(std::numeric_limits<A>::signaling_NaN() == A());
+    assert(std::numeric_limits<A>::denorm_min() == A());
+    static_assert(std::numeric_limits<A>::is_iec559 == false,
+                 "std::numeric_limits<A>::is_iec559 == false");
+    static_assert(std::numeric_limits<A>::is_bounded == false,
+                 "std::numeric_limits<A>::is_bounded == false");
+    static_assert(std::numeric_limits<A>::is_modulo == false,
+                 "std::numeric_limits<A>::is_modulo == false");
+    static_assert(std::numeric_limits<A>::traps == false,
+                 "std::numeric_limits<A>::traps == false");
+    static_assert(std::numeric_limits<A>::tinyness_before == false,
+                 "std::numeric_limits<A>::tinyness_before == false");
+    static_assert(std::numeric_limits<A>::round_style == std::round_toward_zero,
+                 "std::numeric_limits<A>::round_style == std::round_toward_zero");
+}
diff --git a/final/test/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp b/final/test/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/numeric.special/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.limits/limits/round.style/check_values.pass.cpp b/final/test/language.support/support.limits/limits/round.style/check_values.pass.cpp
new file mode 100644
index 0000000..d6c70c4
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/round.style/check_values.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test numeric_limits
+
+// float_denorm_style
+
+#include <limits>
+
+typedef char one;
+struct two {one _[2];};
+
+one test(std::float_denorm_style);
+two test(int);
+
+int main()
+{
+    static_assert(std::denorm_indeterminate == -1,
+                 "std::denorm_indeterminate == -1");
+    static_assert(std::denorm_absent == 0,
+                 "std::denorm_absent == 0");
+    static_assert(std::denorm_present == 1,
+                 "std::denorm_present == 1");
+    static_assert(sizeof(test(std::denorm_present)) == 1,
+                 "sizeof(test(std::denorm_present)) == 1");
+    static_assert(sizeof(test(1)) == 2,
+                 "sizeof(test(1)) == 2");
+}
diff --git a/final/test/language.support/support.limits/limits/version.pass.cpp b/final/test/language.support/support.limits/limits/version.pass.cpp
new file mode 100644
index 0000000..0cb3f6f
--- /dev/null
+++ b/final/test/language.support/support.limits/limits/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <limits>
+
+#include <limits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.limits/nothing_to_do.pass.cpp b/final/test/language.support/support.limits/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/language.support/support.limits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp b/final/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
new file mode 100644
index 0000000..448ffba
--- /dev/null
+++ b/final/test/language.support/support.rtti/bad.cast/bad_cast.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_cast
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_cast>::value),
+                 "std::is_base_of<std::exception, std::bad_cast>::value");
+    static_assert(std::is_polymorphic<std::bad_cast>::value,
+                 "std::is_polymorphic<std::bad_cast>::value");
+    std::bad_cast b;
+    std::bad_cast b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/final/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp b/final/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
new file mode 100644
index 0000000..190aebe
--- /dev/null
+++ b/final/test/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_typeid
+
+#include <typeinfo>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_typeid>::value),
+                 "std::is_base_of<std::exception, std::bad_typeid>::value");
+    static_assert(std::is_polymorphic<std::bad_typeid>::value,
+                 "std::is_polymorphic<std::bad_typeid>::value");
+    std::bad_typeid b;
+    std::bad_typeid b2 = b;
+    b2 = b;
+    const char* w = b2.what();
+    assert(w);
+}
diff --git a/final/test/language.support/support.rtti/type.info/type_info.pass.cpp b/final/test/language.support/support.rtti/type.info/type_info.pass.cpp
new file mode 100644
index 0000000..2616865
--- /dev/null
+++ b/final/test/language.support/support.rtti/type.info/type_info.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& t1 = typeid(int);
+    const std::type_info& t2 = typeid(int);
+    assert(t1 == t2);
+    const std::type_info& t3 = typeid(short);
+    assert(t1 != t3);
+    assert(!t1.before(t2));
+    assert(strcmp(t1.name(), t2.name()) == 0);
+    assert(strcmp(t1.name(), t3.name()) != 0);
+}
diff --git a/final/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp b/final/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp
new file mode 100644
index 0000000..c91a21f
--- /dev/null
+++ b/final/test/language.support/support.rtti/type.info/type_info_hash.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// test type_info
+
+#include <typeinfo>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& t1 = typeid(int);
+    const std::type_info& t2 = typeid(int);
+    const std::type_info& t3 = typeid(short);
+    assert(t1.hash_code() == t2.hash_code());
+    assert(t1.hash_code() != t3.hash_code());
+}
diff --git a/final/test/language.support/support.rtti/version.pass.cpp b/final/test/language.support/support.rtti/version.pass.cpp
new file mode 100644
index 0000000..0a9ece3
--- /dev/null
+++ b/final/test/language.support/support.rtti/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeinfo>
+
+#include <typeinfo>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.runtime/csetjmp.pass.cpp b/final/test/language.support/support.runtime/csetjmp.pass.cpp
new file mode 100644
index 0000000..a54f67b
--- /dev/null
+++ b/final/test/language.support/support.runtime/csetjmp.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <csetjmp>
+
+#include <csetjmp>
+#include <type_traits>
+
+#ifndef setjmp
+#error setjmp not defined
+#endif
+
+int main()
+{
+    std::jmp_buf jb;
+    static_assert((std::is_same<__typeof__(std::longjmp(jb, 0)), void>::value),
+                  "std::is_same<__typeof__(std::longjmp(jb, 0)), void>::value");
+}
diff --git a/final/test/language.support/support.runtime/csignal.pass.cpp b/final/test/language.support/support.runtime/csignal.pass.cpp
new file mode 100644
index 0000000..717347d
--- /dev/null
+++ b/final/test/language.support/support.runtime/csignal.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <csignal>
+
+#include <csignal>
+#include <type_traits>
+
+#ifndef SIG_DFL
+#error SIG_DFL not defined
+#endif
+
+#ifndef SIG_ERR
+#error SIG_ERR not defined
+#endif
+
+#ifndef SIG_IGN
+#error SIG_IGN not defined
+#endif
+
+#ifndef SIGABRT
+#error SIGABRT not defined
+#endif
+
+#ifndef SIGFPE
+#error SIGFPE not defined
+#endif
+
+#ifndef SIGILL
+#error SIGILL not defined
+#endif
+
+#ifndef SIGINT
+#error SIGINT not defined
+#endif
+
+#ifndef SIGSEGV
+#error SIGSEGV not defined
+#endif
+
+#ifndef SIGTERM
+#error SIGTERM not defined
+#endif
+
+int main()
+{
+    std::sig_atomic_t sig;
+    typedef void (*func)(int);
+    static_assert((std::is_same<decltype(std::signal(0, (func)0)), func>::value), "");
+    static_assert((std::is_same<decltype(std::raise(0)), int>::value), "");
+}
diff --git a/final/test/language.support/support.runtime/cstdarg.pass.cpp b/final/test/language.support/support.runtime/cstdarg.pass.cpp
new file mode 100644
index 0000000..00baf80
--- /dev/null
+++ b/final/test/language.support/support.runtime/cstdarg.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdarg>
+
+#include <cstdarg>
+
+#ifndef va_arg
+#error va_arg not defined
+#endif
+
+#ifndef va_copy
+#error va_copy not defined
+#endif
+
+#ifndef va_end
+#error va_end not defined
+#endif
+
+#ifndef va_start
+#error va_start not defined
+#endif
+
+int main()
+{
+    std::va_list va;
+}
diff --git a/final/test/language.support/support.runtime/cstdbool.pass.cpp b/final/test/language.support/support.runtime/cstdbool.pass.cpp
new file mode 100644
index 0000000..f52c155
--- /dev/null
+++ b/final/test/language.support/support.runtime/cstdbool.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdbool>
+
+#include <cstdbool>
+
+#ifndef __bool_true_false_are_defined
+#error __bool_true_false_are_defined not defined
+#endif
+
+#ifdef bool
+#error bool should not be defined
+#endif
+
+#ifdef true
+#error true should not be defined
+#endif
+
+#ifdef false
+#error false should not be defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.runtime/cstdlib.pass.cpp b/final/test/language.support/support.runtime/cstdlib.pass.cpp
new file mode 100644
index 0000000..e14e70e
--- /dev/null
+++ b/final/test/language.support/support.runtime/cstdlib.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdlib>
+
+#include <cstdlib>
+#include <type_traits>
+
+#ifndef EXIT_FAILURE
+#error EXIT_FAILURE not defined
+#endif
+
+#ifndef EXIT_SUCCESS
+#error EXIT_SUCCESS not defined
+#endif
+
+#ifndef MB_CUR_MAX
+#error MB_CUR_MAX not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef RAND_MAX
+#error RAND_MAX not defined
+#endif
+
+int main()
+{
+    std::size_t s = 0;
+    std::div_t d;
+    std::ldiv_t ld;
+    std::lldiv_t lld;
+    char** endptr = 0;
+    static_assert((std::is_same<decltype(std::atof("")), double>::value), "");
+    static_assert((std::is_same<decltype(std::atoi("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::atol("")), long>::value), "");
+    static_assert((std::is_same<decltype(std::atoll("")), long long>::value), "");
+    static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strtod("", endptr)), double>::value), "");
+    static_assert((std::is_same<decltype(std::strtof("", endptr)), float>::value), "");
+    static_assert((std::is_same<decltype(std::strtold("", endptr)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::strtol("", endptr,0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::strtoll("", endptr,0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::strtoul("", endptr,0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(std::strtoull("", endptr,0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(std::rand()), int>::value), "");
+    static_assert((std::is_same<decltype(std::srand(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::calloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::free(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::malloc(0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::realloc(0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::abort()), void>::value), "");
+    static_assert((std::is_same<decltype(std::atexit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::_Exit(0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::getenv("")), char*>::value), "");
+    static_assert((std::is_same<decltype(std::system("")), int>::value), "");
+    static_assert((std::is_same<decltype(std::bsearch(0,0,0,0,0)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::qsort(0,0,0,0)), void>::value), "");
+    static_assert((std::is_same<decltype(std::abs(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::abs((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::abs((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::labs((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::llabs((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::div(0,0)), std::div_t>::value), "");
+    static_assert((std::is_same<decltype(std::div(0L,0L)), std::ldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::div(0LL,0LL)), std::lldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::ldiv(0L,0L)), std::ldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::lldiv(0LL,0LL)), std::lldiv_t>::value), "");
+    static_assert((std::is_same<decltype(std::mblen("",0)), int>::value), "");
+    wchar_t* pw = 0;
+    const wchar_t* pwc = 0;
+    char* pc = 0;
+    static_assert((std::is_same<decltype(std::mbtowc(pw,"",0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wctomb(pc,L' ')), int>::value), "");
+    static_assert((std::is_same<decltype(std::mbstowcs(pw,"",0)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstombs(pc,pwc,0)), std::size_t>::value), "");
+}
diff --git a/final/test/language.support/support.runtime/ctime.pass.cpp b/final/test/language.support/support.runtime/ctime.pass.cpp
new file mode 100644
index 0000000..495d6eb
--- /dev/null
+++ b/final/test/language.support/support.runtime/ctime.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test <ctime>
+
+#include <ctime>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+    std::clock_t c = 0;
+    std::size_t s = 0;
+    std::time_t t = 0;
+    std::tm tm = {0};
+    static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
+    static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
+    static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
+    static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
+    char* c1 = 0;
+    const char* c2 = 0;
+    static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), "");
+}
diff --git a/final/test/language.support/support.runtime/version_csetjmp.pass.cpp b/final/test/language.support/support.runtime/version_csetjmp.pass.cpp
new file mode 100644
index 0000000..7e37716
--- /dev/null
+++ b/final/test/language.support/support.runtime/version_csetjmp.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <csetjmp>
+
+#include <csetjmp>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.runtime/version_csignal.pass.cpp b/final/test/language.support/support.runtime/version_csignal.pass.cpp
new file mode 100644
index 0000000..be1045f
--- /dev/null
+++ b/final/test/language.support/support.runtime/version_csignal.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <csignal>
+
+#include <csignal>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.runtime/version_cstdarg.pass.cpp b/final/test/language.support/support.runtime/version_cstdarg.pass.cpp
new file mode 100644
index 0000000..f3ca938
--- /dev/null
+++ b/final/test/language.support/support.runtime/version_cstdarg.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdarg>
+
+#include <cstdarg>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.runtime/version_cstdbool.pass.cpp b/final/test/language.support/support.runtime/version_cstdbool.pass.cpp
new file mode 100644
index 0000000..0415227
--- /dev/null
+++ b/final/test/language.support/support.runtime/version_cstdbool.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdbool>
+
+#include <cstdbool>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.runtime/version_cstdlib.pass.cpp b/final/test/language.support/support.runtime/version_cstdlib.pass.cpp
new file mode 100644
index 0000000..db41952
--- /dev/null
+++ b/final/test/language.support/support.runtime/version_cstdlib.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdlib>
+
+#include <cstdlib>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.runtime/version_ctime.pass.cpp b/final/test/language.support/support.runtime/version_ctime.pass.cpp
new file mode 100644
index 0000000..ce0bf2c
--- /dev/null
+++ b/final/test/language.support/support.runtime/version_ctime.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctime>
+
+#include <ctime>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.start.term/quick_exit.pass.cpp b/final/test/language.support/support.start.term/quick_exit.pass.cpp
new file mode 100644
index 0000000..1945a1b
--- /dev/null
+++ b/final/test/language.support/support.start.term/quick_exit.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// test quick_exit and at_quick_exit
+
+#include <cstdlib>
+#include <type_traits>
+
+void f() {}
+
+int main()
+{
+    std::at_quick_exit(f);
+    quick_exit(0);
+}
diff --git a/final/test/language.support/support.types/max_align_t.pass.cpp b/final/test/language.support/support.types/max_align_t.pass.cpp
new file mode 100644
index 0000000..08a6c28
--- /dev/null
+++ b/final/test/language.support/support.types/max_align_t.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <cstddef>
+#include <type_traits>
+
+// max_align_t is a POD type whose alignment requirement is at least as
+//   great as that of every scalar type
+
+#include <stdio.h>
+
+int main()
+{
+    static_assert(std::is_pod<std::max_align_t>::value,
+                  "std::is_pod<std::max_align_t>::value");
+    static_assert((std::alignment_of<std::max_align_t>::value >=
+                  std::alignment_of<long long>::value),
+                  "std::alignment_of<std::max_align_t>::value >= "
+                  "std::alignment_of<long long>::value");
+    static_assert(std::alignment_of<std::max_align_t>::value >=
+                  std::alignment_of<long double>::value,
+                  "std::alignment_of<std::max_align_t>::value >= "
+                  "std::alignment_of<long double>::value");
+    static_assert(std::alignment_of<std::max_align_t>::value >=
+                  std::alignment_of<void*>::value,
+                  "std::alignment_of<std::max_align_t>::value >= "
+                  "std::alignment_of<void*>::value");
+}
diff --git a/final/test/language.support/support.types/null.pass.cpp b/final/test/language.support/support.types/null.pass.cpp
new file mode 100644
index 0000000..7e31a85
--- /dev/null
+++ b/final/test/language.support/support.types/null.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <cstddef>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/language.support/support.types/nullptr_t.pass.cpp b/final/test/language.support/support.types/nullptr_t.pass.cpp
new file mode 100644
index 0000000..6c15fef
--- /dev/null
+++ b/final/test/language.support/support.types/nullptr_t.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <cstddef>
+#include <type_traits>
+#include <cassert>
+
+// typedef decltype(nullptr) nullptr_t;
+
+struct A
+{
+    A(std::nullptr_t) {}
+};
+
+int main()
+{
+    static_assert(sizeof(std::nullptr_t) == sizeof(void*),
+                  "sizeof(std::nullptr_t) == sizeof(void*)");
+    A* p = 0;
+    assert(p == nullptr);
+    void (A::*pmf)() = 0;
+#ifdef __clang__
+    // GCC 4.2 can't handle this
+    assert(pmf == nullptr);
+#endif
+    int A::*pmd = 0;
+    assert(pmd == nullptr);
+    A a1(nullptr);
+    A a2(0);
+    bool b = nullptr;
+    assert(!b);
+    assert(nullptr == nullptr);
+    assert(nullptr <= nullptr);
+    assert(nullptr >= nullptr);
+    assert(!(nullptr != nullptr));
+    assert(!(nullptr < nullptr));
+    assert(!(nullptr > nullptr));
+    A* a = nullptr;
+    assert(a == nullptr);
+    assert(a <= nullptr);
+    assert(a >= nullptr);
+    assert(!(a != nullptr));
+    assert(!(a < nullptr));
+    assert(!(a > nullptr));
+    assert(nullptr == a);
+    assert(nullptr <= a);
+    assert(nullptr >= a);
+    assert(!(nullptr != a));
+    assert(!(nullptr < a));
+    assert(!(nullptr > a));
+    std::ptrdiff_t i = reinterpret_cast<std::ptrdiff_t>(nullptr);
+    assert(i == 0);
+}
diff --git a/final/test/language.support/support.types/offsetof.pass.cpp b/final/test/language.support/support.types/offsetof.pass.cpp
new file mode 100644
index 0000000..e36ac22
--- /dev/null
+++ b/final/test/language.support/support.types/offsetof.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <cstddef>
+
+#ifndef offsetof
+#error offsetof not defined
+#endif
+
+struct A
+{
+    int x;
+};
+
+int main()
+{
+#if (__has_feature(cxx_noexcept))
+    static_assert(noexcept(offsetof(A, x)), "");
+#endif
+}
diff --git a/final/test/language.support/support.types/ptrdiff_t.pass.cpp b/final/test/language.support/support.types/ptrdiff_t.pass.cpp
new file mode 100644
index 0000000..702ec72
--- /dev/null
+++ b/final/test/language.support/support.types/ptrdiff_t.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <cstddef>
+#include <type_traits>
+
+// ptrdiff_t should:
+
+//  1. be in namespace std.
+//  2. be the same sizeof as void*.
+//  3. be a signed integral.
+
+int main()
+{
+    static_assert(sizeof(std::ptrdiff_t) == sizeof(void*),
+                  "sizeof(std::ptrdiff_t) == sizeof(void*)");
+    static_assert(std::is_signed<std::ptrdiff_t>::value,
+                  "std::is_signed<std::ptrdiff_t>::value");
+    static_assert(std::is_integral<std::ptrdiff_t>::value,
+                  "std::is_integral<std::ptrdiff_t>::value");
+}
diff --git a/final/test/language.support/support.types/size_t.pass.cpp b/final/test/language.support/support.types/size_t.pass.cpp
new file mode 100644
index 0000000..bb3b080
--- /dev/null
+++ b/final/test/language.support/support.types/size_t.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <cstddef>
+#include <type_traits>
+
+// size_t should:
+
+//  1. be in namespace std.
+//  2. be the same sizeof as void*.
+//  3. be an unsigned integral.
+
+int main()
+{
+    static_assert(sizeof(std::size_t) == sizeof(void*),
+                  "sizeof(std::size_t) == sizeof(void*)");
+    static_assert(std::is_unsigned<std::size_t>::value,
+                  "std::is_unsigned<std::size_t>::value");
+    static_assert(std::is_integral<std::size_t>::value,
+                  "std::is_integral<std::size_t>::value");
+}
diff --git a/final/test/language.support/support.types/version.pass.cpp b/final/test/language.support/support.types/version.pass.cpp
new file mode 100644
index 0000000..2ab7c18
--- /dev/null
+++ b/final/test/language.support/support.types/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstddef>
+
+#include <cstddef>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/lit.cfg b/final/test/lit.cfg
new file mode 100644
index 0000000..5e64e54
--- /dev/null
+++ b/final/test/lit.cfg
@@ -0,0 +1,306 @@
+# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80:
+
+# Configuration file for the 'lit' test runner.
+
+import errno
+import os
+import platform
+import re
+import shlex
+import signal
+import subprocess
+import sys
+import tempfile
+import time
+
+import lit.Test
+import lit.formats
+import lit.util
+
+class LibcxxTestFormat(lit.formats.FileBasedTest):
+    """
+    Custom test format handler for use with the test format use by libc++.
+
+    Tests fall into two categories:
+      FOO.pass.cpp - Executable test which should compile, run, and exit with
+                     code 0.
+      FOO.fail.cpp - Negative test case which is expected to fail compilation.
+    """
+
+    def __init__(self, cxx_under_test, cpp_flags, ld_flags, exec_env):
+        self.cxx_under_test = cxx_under_test
+        self.cpp_flags = list(cpp_flags)
+        self.ld_flags = list(ld_flags)
+        self.exec_env = dict(exec_env)
+
+    def execute_command(self, command, in_dir=None):
+        kwargs = {
+            'stdin' :subprocess.PIPE,
+            'stdout':subprocess.PIPE,
+            'stderr':subprocess.PIPE,
+        }
+        if in_dir:
+            kwargs['cwd'] = in_dir
+        p = subprocess.Popen(command, **kwargs)
+        out,err = p.communicate()
+        exitCode = p.wait()
+
+        # Detect Ctrl-C in subprocess.
+        if exitCode == -signal.SIGINT:
+            raise KeyboardInterrupt
+
+        return out, err, exitCode
+
+    def execute(self, test, lit_config):
+        while True:
+            try:
+                return self._execute(test, lit_config)
+            except OSError, oe:
+                if oe.errno != errno.ETXTBSY:
+                    raise
+                time.sleep(0.1)
+
+    def _execute(self, test, lit_config):
+        # Extract test metadata from the test file.
+        requires = []
+        with open(test.getSourcePath()) as f:
+            for ln in f:
+                if 'XFAIL:' in ln:
+                    items = ln[ln.index('XFAIL:') + 6:].split(',')
+                    test.xfails.extend([s.strip() for s in items])
+                elif 'REQUIRES:' in ln:
+                    items = ln[ln.index('REQUIRES:') + 9:].split(',')
+                    requires.extend([s.strip() for s in items])
+                elif not ln.startswith("//") and ln.strip():
+                    # Stop at the first non-empty line that is not a C++
+                    # comment.
+                    break
+
+        # Check that we have the required features.
+        #
+        # FIXME: For now, this is cribbed from lit.TestRunner, to avoid
+        # introducing a dependency there. What we more ideally would like to do
+        # is lift the "requires" handling to be a core lit framework feature.
+        missing_required_features = [f for f in requires
+                                     if f not in test.config.available_features]
+        if missing_required_features:
+            return (lit.Test.UNSUPPORTED,
+                    "Test requires the following features: %s" % (
+                      ', '.join(missing_required_features),))
+
+        # Evaluate the test.
+        return self._evaluate_test(test, lit_config)
+
+    def _evaluate_test(self, test, lit_config):
+        name = test.path_in_suite[-1]
+        source_path = test.getSourcePath()
+        source_dir = os.path.dirname(source_path)
+
+        # Check what kind of test this is.
+        assert name.endswith('.pass.cpp') or name.endswith('.fail.cpp')
+        expected_compile_fail = name.endswith('.fail.cpp')
+
+        # If this is a compile (failure) test, build it and check for failure.
+        if expected_compile_fail:
+            cmd = [self.cxx_under_test, '-c',
+                   '-o', '/dev/null', source_path] + self.cpp_flags
+            out, err, exitCode = self.execute_command(cmd)
+            if exitCode == 1:
+                return lit.Test.PASS, ""
+            else:
+                report = """Command: %s\n""" % ' '.join(["'%s'" % a
+                                                         for a in cmd])
+                report += """Exit Code: %d\n""" % exitCode
+                if out:
+                    report += """Standard Output:\n--\n%s--""" % out
+                if err:
+                    report += """Standard Error:\n--\n%s--""" % err
+                report += "\n\nExpected compilation to fail!"
+                return lit.Test.FAIL, report
+        else:
+            exec_file = tempfile.NamedTemporaryFile(suffix="exe", delete=False)
+            exec_path = exec_file.name
+            exec_file.close()
+
+            try:
+                compile_cmd = [self.cxx_under_test, '-o', exec_path,
+                       source_path] + self.cpp_flags + self.ld_flags
+                cmd = compile_cmd
+                out, err, exitCode = self.execute_command(cmd)
+                if exitCode != 0:
+                    report = """Command: %s\n""" % ' '.join(["'%s'" % a
+                                                             for a in cmd])
+                    report += """Exit Code: %d\n""" % exitCode
+                    if out:
+                        report += """Standard Output:\n--\n%s--""" % out
+                    if err:
+                        report += """Standard Error:\n--\n%s--""" % err
+                    report += "\n\nCompilation failed unexpectedly!"
+                    return lit.Test.FAIL, report
+
+                cmd = []
+                if self.exec_env:
+                    cmd.append('env')
+                    cmd.extend('%s=%s' % (name, value)
+                               for name,value in self.exec_env.items())
+                cmd.append(exec_path)
+                if lit_config.useValgrind:
+                    cmd = lit_config.valgrindArgs + cmd
+                out, err, exitCode = self.execute_command(cmd, source_dir)
+                if exitCode != 0:
+                    report = """Compiled With: %s\n""" % \
+                        ' '.join(["'%s'" % a for a in compile_cmd])
+                    report += """Command: %s\n""" % \
+                        ' '.join(["'%s'" % a for a in cmd])
+                    report += """Exit Code: %d\n""" % exitCode
+                    if out:
+                        report += """Standard Output:\n--\n%s--""" % out
+                    if err:
+                        report += """Standard Error:\n--\n%s--""" % err
+                    report += "\n\nCompiled test failed unexpectedly!"
+                    return lit.Test.FAIL, report
+            finally:
+                try:
+                    os.remove(exec_path)
+                except:
+                    pass
+        return lit.Test.PASS, ""
+
+# name: The name of this test suite.
+config.name = 'libc++'
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = ['.cpp']
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# Gather various compiler parameters.
+cxx_under_test = lit_config.params.get('cxx_under_test', None)
+if cxx_under_test is None:
+    cxx_under_test = getattr(config, 'cxx_under_test', None)
+
+    # If no specific cxx_under_test was given, attempt to infer it as clang++.
+    if cxx_under_test is None:
+        clangxx = lit.util.which('clang++', config.environment['PATH'])
+        if clangxx is not None:
+            cxx_under_test = clangxx
+    lit_config.note("inferred cxx_under_test as: %r" % (cxx_under_test,))
+if cxx_under_test is None:
+    lit_config.fatal('must specify user parameter cxx_under_test '
+                     '(e.g., --param=cxx_under_test=clang++)')
+
+libcxx_src_root = lit_config.params.get('libcxx_src_root', None)
+if libcxx_src_root is None:
+    libcxx_src_root = getattr(config, 'libcxx_src_root', None)
+    if libcxx_src_root is None:
+        libcxx_src_root = os.path.dirname(config.test_source_root)
+
+libcxx_obj_root = lit_config.params.get('libcxx_obj_root', None)
+if libcxx_obj_root is None:
+    libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
+    if libcxx_obj_root is None:
+        libcxx_obj_root = libcxx_src_root
+
+cxx_has_stdcxx0x_flag_str = lit_config.params.get('cxx_has_stdcxx0x_flag', None)
+if cxx_has_stdcxx0x_flag_str is not None:
+    if cxx_has_stdcxx0x_flag_str.lower() in ('1', 'true'):
+        cxx_has_stdcxx0x_flag = True
+    elif cxx_has_stdcxx0x_flag_str.lower() in ('', '0', 'false'):
+        cxx_has_stdcxx0x_flag = False
+    else:
+        lit_config.fatal(
+            'user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1')
+else:
+    cxx_has_stdcxx0x_flag = getattr(config, 'cxx_has_stdcxx0x_flag', True)
+
+# This test suite supports testing against either the system library or the
+# locally built one; the former mode is useful for testing ABI compatibility
+# between the current headers and a shipping dynamic library.
+use_system_lib_str = lit_config.params.get('use_system_lib', None)
+if use_system_lib_str is not None:
+    if use_system_lib_str.lower() in ('1', 'true'):
+        use_system_lib = True
+    elif use_system_lib_str.lower() in ('', '0', 'false'):
+        use_system_lib = False
+    else:
+        lit_config.fatal('user parameter use_system_lib should be 0 or 1')
+else:
+    # Default to testing against the locally built libc++ library.
+    use_system_lib = False
+    lit_config.note("inferred use_system_lib as: %r" % (use_system_lib,))
+
+link_flags = []
+link_flags_str = lit_config.params.get('link_flags', None)
+if link_flags_str is None:
+    link_flags_str = getattr(config, 'link_flags', None)
+    if link_flags_str is None:
+      cxx_abi = getattr(config, 'cxx_abi', 'libcxxabi')
+      if cxx_abi == 'libstdc++':
+        link_flags += ['-lstdc++']
+      elif cxx_abi == 'libsupc++':
+        link_flags += ['-lsupc++']
+      elif cxx_abi == 'libcxxabi':
+        link_flags += ['-lc++abi']
+      elif cxx_abi == 'none':
+        pass
+      else:
+        lit_config.fatal('C++ ABI setting %s unsupported for tests' % cxx_abi)
+
+      if sys.platform == 'darwin':
+        link_flags += ['-lSystem']
+      elif sys.platform == 'linux2':
+        link_flags += [ '-lgcc_eh', '-lc', '-lm', '-lpthread',
+              '-lrt', '-lgcc_s']
+      else:
+        lit_config.fatal("unrecognized system")
+
+      lit_config.note("inferred link_flags as: %r" % (link_flags,))
+if not link_flags_str is None:
+    link_flags += shlex.split(link_flags_str)
+
+# Configure extra compiler flags.
+include_paths = ['-I' + libcxx_src_root + '/include',
+    '-I' + libcxx_src_root + '/test/support']
+library_paths = ['-L' + libcxx_obj_root + '/lib']
+compile_flags = []
+if cxx_has_stdcxx0x_flag:
+    compile_flags += ['-std=c++0x']
+
+# Configure extra linker parameters.
+exec_env = {}
+if sys.platform == 'darwin':
+    if not use_system_lib:
+        exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxx_obj_root, 'lib')
+elif sys.platform == 'linux2':
+    if not use_system_lib:
+        link_flags += ['-Wl,-R', libcxx_obj_root + '/lib']
+    compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS',
+        '-D__STDC_CONSTANT_MACROS']
+else:
+    lit_config.fatal("unrecognized system")
+
+config.test_format = LibcxxTestFormat(
+    cxx_under_test,
+    cpp_flags = ['-nostdinc++'] + compile_flags + include_paths,
+    ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + link_flags,
+    exec_env = exec_env)
+
+# Get or infer the target triple.
+config.target_triple = lit_config.params.get('target_triple', None)
+# If no target triple was given, try to infer it from the compiler under test.
+if config.target_triple is None:
+    config.target_triple = lit.util.capture(
+        [cxx_under_test, '-dumpmachine']).strip()
+    lit_config.note("inferred target_triple as: %r" % (config.target_triple,))
+
+# Write an "available feature" that combines the triple when use_system_lib is
+# enabled. This is so that we can easily write XFAIL markers for tests that are
+# known to fail with versions of libc++ as were shipped with a particular
+# triple.
+if use_system_lib:
+    # Drop sub-major version components from the triple, because the current
+    # XFAIL handling expects exact matches for feature checks.
+    sanitized_triple = re.sub(r"([^-]+)-([^-]+)-([^-.]+).*", r"\1-\2-\3",
+                              config.target_triple)
+    config.available_features.add('with_system_lib=%s' % (sanitized_triple,))
diff --git a/final/test/lit.site.cfg.in b/final/test/lit.site.cfg.in
new file mode 100644
index 0000000..5343eda
--- /dev/null
+++ b/final/test/lit.site.cfg.in
@@ -0,0 +1,11 @@
+@AUTO_GEN_COMMENT@
+config.cxx_under_test        = "@LIBCXX_COMPILER@"
+config.cxx_has_stdcxx0x_flag = @LIBCXX_HAS_STDCXX0X_FLAG@
+config.libcxx_src_root       = "@LIBCXX_SOURCE_DIR@"
+config.libcxx_obj_root       = "@LIBCXX_BINARY_DIR@"
+config.python_executable     = "@PYTHON_EXECUTABLE@"
+config.enable_shared         = @LIBCXX_ENABLE_SHARED@
+config.cxx_abi               = "@LIBCXX_CXX_ABI@"
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
diff --git a/final/test/localization/c.locales/clocale.pass.cpp b/final/test/localization/c.locales/clocale.pass.cpp
new file mode 100644
index 0000000..8774865
--- /dev/null
+++ b/final/test/localization/c.locales/clocale.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <clocale>
+
+#include <clocale>
+#include <type_traits>
+
+#ifndef LC_ALL
+#error LC_ALL not defined
+#endif
+
+#ifndef LC_COLLATE
+#error LC_COLLATE not defined
+#endif
+
+#ifndef LC_CTYPE
+#error LC_CTYPE not defined
+#endif
+
+#ifndef LC_MONETARY
+#error LC_MONETARY not defined
+#endif
+
+#ifndef LC_NUMERIC
+#error LC_NUMERIC not defined
+#endif
+
+#ifndef LC_TIME
+#error LC_TIME not defined
+#endif
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    std::lconv lc;
+    static_assert((std::is_same<__typeof__(std::setlocale(0, "")), char*>::value), "");
+    static_assert((std::is_same<__typeof__(std::localeconv()), std::lconv*>::value), "");
+}
diff --git a/final/test/localization/c.locales/version.pass.cpp b/final/test/localization/c.locales/version.pass.cpp
new file mode 100644
index 0000000..0fce59e
--- /dev/null
+++ b/final/test/localization/c.locales/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <clocale>
+
+#include <clocale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/__scan_keyword.pass.cpp b/final/test/localization/locale.categories/__scan_keyword.pass.cpp
new file mode 100644
index 0000000..b33aab9
--- /dev/null
+++ b/final/test/localization/locale.categories/__scan_keyword.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// Not a portable test
+
+// __scan_keyword
+// Scans [__b, __e) until a match is found in the basic_strings range
+//  [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
+//  __b will be incremented (visibly), consuming CharT until a match is found
+//  or proved to not exist.  A keyword may be "", in which will match anything.
+//  If one keyword is a prefix of another, and the next CharT in the input
+//  might match another keyword, the algorithm will attempt to find the longest
+//  matching keyword.  If the longer matching keyword ends up not matching, then
+//  no keyword match is found.  If no keyword match is found, __ke is returned.
+//  Else an iterator pointing to the matching keyword is found.  If more than
+//  one keyword matches, an iterator to the first matching keyword is returned.
+//  If on exit __b == __e, eofbit is set in __err.  If __case_sensitive is false,
+//  __ct is used to force to lower case before comparing characters.
+//  Examples:
+//  Keywords:  "a", "abb"
+//  If the input is "a", the first keyword matches and eofbit is set.
+//  If the input is "abc", no match is found and "ab" are consumed.
+//
+// template <class _InputIterator, class _ForwardIterator, class _Ctype>
+// _ForwardIterator
+// __scan_keyword(_InputIterator& __b, _InputIterator __e,
+//                _ForwardIterator __kb, _ForwardIterator __ke,
+//                const _Ctype& __ct, ios_base::iostate& __err,
+//                bool __case_sensitive = true);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic());
+    std::ios_base::iostate err = std::ios_base::goodbit;
+    {
+        const char input[] = "a";
+        const char* in = input;
+        std::string keys[] = {"a", "abb"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 0);
+        assert(in == input+1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char input[] = "abc";
+        const char* in = input;
+        std::string keys[] = {"a", "abb"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 2);
+        assert(in == input+2);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char input[] = "abb";
+        const char* in = input;
+        std::string keys[] = {"a", "abb"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 1);
+        assert(in == input+3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char input[] = "Tue ";
+        const char* in = input;
+        std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 2);
+        assert(in == input+3);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char input[] = "tue ";
+        const char* in = input;
+        std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err);
+        assert(k - keys == 4);
+        assert(in == input+0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char input[] = "tue ";
+        const char* in = input;
+        std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+        err = std::ios_base::goodbit;
+        std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
+                                             keys, keys+sizeof(keys)/sizeof(keys[0]),
+                                             ct, err, false);
+        assert(k - keys == 2);
+        assert(in == input+3);
+        assert(err == std::ios_base::goodbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
new file mode 100644
index 0000000..d644125
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// int compare(const charT* low1, const charT* high1,
+//             const charT* low2, const charT* high2) const;
+
+//  I'm currently unable to confirm that collation based on named locales
+//     has any difference from "C" collation.  But I do believe I'm picking
+//     up the OS's collation files.
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+        {
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+    }
+    {
+        std::locale l("");
+        {
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+        {
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+        {
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(f.compare(s2.data(), s2.data() + s2.size(),
+                             s3.data(), s3.data() + s3.size()) == 1);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp
new file mode 100644
index 0000000..f8641cb
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// long hash(const charT* low, const charT* high) const;
+
+//   This test is not portable
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    std::locale l(LOCALE_en_US_UTF_8);
+    {
+        std::string x1("1234");
+        std::string x2("12345");
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+    {
+        std::wstring x1(L"1234");
+        std::wstring x2(L"12345");
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp
new file mode 100644
index 0000000..20a7d48
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate_byname
+
+// string_type transform(const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    // Ensure that the default locale is not C.  If it is, the second tests will fail.
+    putenv(const_cast<char*>("LANG=" LOCALE_en_US_UTF_8));
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            std::string x("1234");
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+        {
+            std::wstring x(L"1234");
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+    }
+    {
+        std::locale l("");
+        {
+            std::string x("1234");
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+        {
+            std::wstring x(L"1234");
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) != x);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            std::string x("1234");
+            const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) == x);
+        }
+        {
+            std::wstring x(L"1234");
+            const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+            assert(f.transform(x.data(), x.data() + x.size()) == x);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp
new file mode 100644
index 0000000..04974b2
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT>
+// class collate_byname
+//     : public collate<charT>
+// {
+// public:
+//     typedef basic_string<charT> string_type;
+//     explicit collate_byname(const char*, size_t refs = 0);
+//     explicit collate_byname(const string&, size_t refs = 0);
+// protected:
+//     ~collate_byname();
+// };
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    std::locale l(LOCALE_en_US_UTF_8);
+    {
+        assert(std::has_facet<std::collate_byname<char> >(l));
+        assert(&std::use_facet<std::collate<char> >(l)
+            == &std::use_facet<std::collate_byname<char> >(l));
+    }
+    {
+        assert(std::has_facet<std::collate_byname<wchar_t> >(l));
+        assert(&std::use_facet<std::collate<wchar_t> >(l)
+            == &std::use_facet<std::collate_byname<wchar_t> >(l));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp
new file mode 100644
index 0000000..8f7e2b5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate/ctor.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// explicit collate(size_t refs = 0);
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+template <class C>
+class my_facet
+    : public std::collate<C>
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : std::collate<C>(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet<char>);
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        my_facet<char> f(1);
+        assert(my_facet<char>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<char>::count == 1);
+        }
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+    {
+        my_facet<wchar_t> f(1);
+        assert(my_facet<wchar_t>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<wchar_t>::count == 1);
+        }
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp
new file mode 100644
index 0000000..d2cf3a9
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/compare.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// int compare(const charT* low1, const charT* high1,
+//             const charT* low2, const charT* high2) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        const char ia[] = "1234";
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        const char ib[] = "123";
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
+        assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
+        assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
+        assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
+        assert(f.compare(ia, ia+3, ib, ib+3) == 0);
+    }
+    {
+        const wchar_t ia[] = L"1234";
+        const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+        const wchar_t ib[] = L"123";
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
+        assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
+        assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
+        assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
+        assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
+        assert(f.compare(ia, ia+3, ib, ib+3) == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp
new file mode 100644
index 0000000..d8a9650
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/hash.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// long hash(const charT* low, const charT* high) const;
+
+//   This test is not portable
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        std::string x1("1234");
+        std::string x2("12345");
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+    {
+        std::wstring x1(L"1234");
+        std::wstring x2(L"12345");
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.hash(x1.data(), x1.data() + x1.size())
+            != f.hash(x2.data(), x2.data() + x2.size()));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp
new file mode 100644
index 0000000..e78a3c7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.members/transform.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class collate;
+
+// string_type transform(const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        std::string x("1234");
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        assert(f.transform(x.data(), x.data() + x.size()) == x);
+    }
+    {
+        std::wstring x(L"1234");
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        assert(f.transform(x.data(), x.data() + x.size()) == x);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate/locale.collate.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.collate/locale.collate/types.pass.cpp b/final/test/localization/locale.categories/category.collate/locale.collate/types.pass.cpp
new file mode 100644
index 0000000..13945f8
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/locale.collate/types.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT>
+// class collate
+//     : public locale::facet {
+// public:
+//     typedef charT char_type;
+//     typedef basic_string<charT>string_type;
+//
+//     static locale::id id;
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::collate<char> >(l));
+        const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
+        {
+            (void)std::collate<char>::id;
+        }
+        static_assert((std::is_same<std::collate<char>::char_type, char>::value), "");
+        static_assert((std::is_same<std::collate<char>::string_type, std::string>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::collate<char> >::value), "");
+    }
+    {
+        assert(std::has_facet<std::collate<wchar_t> >(l));
+        const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
+        {
+            (void)std::collate<wchar_t>::id;
+        }
+        static_assert((std::is_same<std::collate<wchar_t>::char_type, wchar_t>::value), "");
+        static_assert((std::is_same<std::collate<wchar_t>::string_type, std::wstring>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::collate<wchar_t> >::value), "");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.collate/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/category.collate/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.collate/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.ctype/ctype_base.pass.cpp b/final/test/localization/locale.categories/category.ctype/ctype_base.pass.cpp
new file mode 100644
index 0000000..d78df20
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/ctype_base.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// class ctype_base
+// {
+// public:
+//     typedef T mask;
+//
+//     // numeric values are for exposition only.
+//     static const mask space = 1 << 0;
+//     static const mask print = 1 << 1;
+//     static const mask cntrl = 1 << 2;
+//     static const mask upper = 1 << 3;
+//     static const mask lower = 1 << 4;
+//     static const mask alpha = 1 << 5;
+//     static const mask digit = 1 << 6;
+//     static const mask punct = 1 << 7;
+//     static const mask xdigit = 1 << 8;
+//     static const mask alnum = alpha | digit;
+//     static const mask graph = alnum | punct;
+// };
+
+#include <locale>
+#include <cassert>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+    assert(std::ctype_base::space);
+    assert(std::ctype_base::print);
+    assert(std::ctype_base::cntrl);
+    assert(std::ctype_base::upper);
+    assert(std::ctype_base::lower);
+    assert(std::ctype_base::alpha);
+    assert(std::ctype_base::digit);
+    assert(std::ctype_base::punct);
+    assert(std::ctype_base::xdigit);
+    assert(
+      ( std::ctype_base::space
+      & std::ctype_base::print
+      & std::ctype_base::cntrl
+      & std::ctype_base::upper
+      & std::ctype_base::lower
+      & std::ctype_base::alpha
+      & std::ctype_base::digit
+      & std::ctype_base::punct
+      & std::ctype_base::xdigit) == 0);
+    assert(std::ctype_base::alnum == (std::ctype_base::alpha | std::ctype_base::digit));
+    assert(std::ctype_base::graph == (std::ctype_base::alnum | std::ctype_base::punct));
+
+    test(std::ctype_base::space);
+    test(std::ctype_base::print);
+    test(std::ctype_base::cntrl);
+    test(std::ctype_base::upper);
+    test(std::ctype_base::lower);
+    test(std::ctype_base::alpha);
+    test(std::ctype_base::digit);
+    test(std::ctype_base::punct);
+    test(std::ctype_base::xdigit);
+    test(std::ctype_base::blank);
+    test(std::ctype_base::alnum);
+    test(std::ctype_base::graph);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
new file mode 100644
index 0000000..6d9e1cd
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.dtor/dtor.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// ~ctype();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+unsigned delete_called = 0;
+
+void* operator new[](size_t sz) throw(std::bad_alloc)
+{
+    return operator new(sz);
+}
+
+void operator delete[](void* p) throw()
+{
+    operator delete(p);
+    ++delete_called;
+}
+
+int main()
+{
+    {
+        delete_called = 0;
+        std::locale l(std::locale::classic(), new std::ctype<char>);
+        assert(delete_called == 0);
+    }
+    assert(delete_called == 0);
+    {
+        std::ctype<char>::mask table[256];
+        delete_called = 0;
+        std::locale l(std::locale::classic(), new std::ctype<char>(table));
+        assert(delete_called == 0);
+    }
+    assert(delete_called == 0);
+    {
+        delete_called = 0;
+        std::locale l(std::locale::classic(),
+            new std::ctype<char>(new std::ctype<char>::mask[256], true));
+        assert(delete_called == 0);
+    }
+    assert(delete_called == 1);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp
new file mode 100644
index 0000000..a1e15ba
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/ctor.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// explicit ctype(const mask* tbl = 0, bool del = false, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+class my_facet
+    : public std::ctype<char>
+{
+public:
+    static int count;
+
+    explicit my_facet(const mask* tbl = 0, bool del = false, std::size_t refs = 0)
+        : std::ctype<char>(tbl, del, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(0, false, 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp
new file mode 100644
index 0000000..945de76
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// bool is(mask m, char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.is(F::space, ' '));
+        assert(!f.is(F::space, 'A'));
+
+        assert(f.is(F::print, ' '));
+        assert(!f.is(F::print, '\x07'));
+
+        assert(f.is(F::cntrl, '\x07'));
+        assert(!f.is(F::cntrl, ' '));
+
+        assert(f.is(F::upper, 'A'));
+        assert(!f.is(F::upper, 'a'));
+
+        assert(f.is(F::lower, 'a'));
+        assert(!f.is(F::lower, 'A'));
+
+        assert(f.is(F::alpha, 'a'));
+        assert(!f.is(F::alpha, '1'));
+
+        assert(f.is(F::digit, '1'));
+        assert(!f.is(F::digit, 'a'));
+
+        assert(f.is(F::punct, '.'));
+        assert(!f.is(F::punct, 'a'));
+
+        assert(f.is(F::xdigit, 'a'));
+        assert(!f.is(F::xdigit, 'g'));
+
+        assert(f.is(F::alnum, 'a'));
+        assert(!f.is(F::alnum, '.'));
+
+        assert(f.is(F::graph, '.'));
+        assert(!f.is(F::graph,  '\x07'));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp
new file mode 100644
index 0000000..74a4906
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/is_many.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* is(const char* low, const char* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        const std::string in(" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        const char* h = f.is(in.data(), in.data() + in.size(), m.data());
+        assert(h == in.data() + in.size());
+
+        // ' '
+        assert( (m[0] & F::space));
+        assert( (m[0] & F::print));
+        assert(!(m[0] & F::cntrl));
+        assert(!(m[0] & F::upper));
+        assert(!(m[0] & F::lower));
+        assert(!(m[0] & F::alpha));
+        assert(!(m[0] & F::digit));
+        assert(!(m[0] & F::punct));
+        assert(!(m[0] & F::xdigit));
+        assert( (m[0] & F::blank));
+        assert(!(m[0] & F::alnum));
+        assert(!(m[0] & F::graph));
+
+        // 'A'
+        assert(!(m[1] & F::space));
+        assert( (m[1] & F::print));
+        assert(!(m[1] & F::cntrl));
+        assert( (m[1] & F::upper));
+        assert(!(m[1] & F::lower));
+        assert( (m[1] & F::alpha));
+        assert(!(m[1] & F::digit));
+        assert(!(m[1] & F::punct));
+        assert( (m[1] & F::xdigit));
+        assert(!(m[1] & F::blank));
+        assert( (m[1] & F::alnum));
+        assert( (m[1] & F::graph));
+
+        // '\x07'
+        assert(!(m[2] & F::space));
+        assert(!(m[2] & F::print));
+        assert( (m[2] & F::cntrl));
+        assert(!(m[2] & F::upper));
+        assert(!(m[2] & F::lower));
+        assert(!(m[2] & F::alpha));
+        assert(!(m[2] & F::digit));
+        assert(!(m[2] & F::punct));
+        assert(!(m[2] & F::xdigit));
+        assert(!(m[2] & F::blank));
+        assert(!(m[2] & F::alnum));
+        assert(!(m[2] & F::graph));
+
+        // '.'
+        assert(!(m[3] & F::space));
+        assert( (m[3] & F::print));
+        assert(!(m[3] & F::cntrl));
+        assert(!(m[3] & F::upper));
+        assert(!(m[3] & F::lower));
+        assert(!(m[3] & F::alpha));
+        assert(!(m[3] & F::digit));
+        assert( (m[3] & F::punct));
+        assert(!(m[3] & F::xdigit));
+        assert(!(m[3] & F::blank));
+        assert(!(m[3] & F::alnum));
+        assert( (m[3] & F::graph));
+
+        // 'a'
+        assert(!(m[4] & F::space));
+        assert( (m[4] & F::print));
+        assert(!(m[4] & F::cntrl));
+        assert(!(m[4] & F::upper));
+        assert( (m[4] & F::lower));
+        assert( (m[4] & F::alpha));
+        assert(!(m[4] & F::digit));
+        assert(!(m[4] & F::punct));
+        assert( (m[4] & F::xdigit));
+        assert(!(m[4] & F::blank));
+        assert( (m[4] & F::alnum));
+        assert( (m[4] & F::graph));
+
+        // '1'
+        assert(!(m[5] & F::space));
+        assert( (m[5] & F::print));
+        assert(!(m[5] & F::cntrl));
+        assert(!(m[5] & F::upper));
+        assert(!(m[5] & F::lower));
+        assert(!(m[5] & F::alpha));
+        assert( (m[5] & F::digit));
+        assert(!(m[5] & F::punct));
+        assert( (m[5] & F::xdigit));
+        assert(!(m[5] & F::blank));
+        assert( (m[5] & F::alnum));
+        assert( (m[5] & F::graph));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp
new file mode 100644
index 0000000..dedf6a7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char narrow(char c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.narrow(' ', '*') == ' ');
+        assert(f.narrow('A', '*') == 'A');
+        assert(f.narrow('\x07', '*') == '\x07');
+        assert(f.narrow('.', '*') == '.');
+        assert(f.narrow('a', '*') == 'a');
+        assert(f.narrow('1', '*') == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp
new file mode 100644
index 0000000..4c5478a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/narrow_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* narrow(const char* low, const char*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+        std::vector<char> v(in.size());
+
+        assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+        assert(v[0] == ' ');
+        assert(v[1] == 'A');
+        assert(v[2] == '\x07');
+        assert(v[3] == '.');
+        assert(v[4] == 'a');
+        assert(v[5] == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
new file mode 100644
index 0000000..9777c98
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_is.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* scan_is(mask m, const char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        const std::string in(" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
+        assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
+        assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
+        assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
new file mode 100644
index 0000000..b17662d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/scan_not.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* scan_not(mask m, const char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        const std::string in(" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp
new file mode 100644
index 0000000..f28f4f9
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/table.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// const mask* table() const throw();
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    typedef std::ctype<char> F;
+    {
+        std::locale l(std::locale::classic(), new std::ctype<char>);
+        const F& f = std::use_facet<F>(l);
+        assert(f.table() == f.classic_table());
+    }
+    {
+        std::ctype<char>::mask table[256];
+        std::locale l(std::locale::classic(), new std::ctype<char>(table));
+        const F& f = std::use_facet<F>(l);
+        assert(f.table() == table);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp
new file mode 100644
index 0000000..1dfc95f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char tolower(char) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.tolower(' ') == ' ');
+        assert(f.tolower('A') == 'a');
+        assert(f.tolower('\x07') == '\x07');
+        assert(f.tolower('.') == '.');
+        assert(f.tolower('a') == 'a');
+        assert(f.tolower('1') == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp
new file mode 100644
index 0000000..22b2737
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/tolower_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* tolower(char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+
+        assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == ' ');
+        assert(in[1] == 'a');
+        assert(in[2] == '\x07');
+        assert(in[3] == '.');
+        assert(in[4] == 'a');
+        assert(in[5] == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp
new file mode 100644
index 0000000..2a714b1
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char toupper(char) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.toupper(' ') == ' ');
+        assert(f.toupper('A') == 'A');
+        assert(f.toupper('\x07') == '\x07');
+        assert(f.toupper('.') == '.');
+        assert(f.toupper('a') == 'A');
+        assert(f.toupper('1') == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp
new file mode 100644
index 0000000..8a842c8
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/toupper_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* toupper(char* low, const char* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+
+        assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == ' ');
+        assert(in[1] == 'A');
+        assert(in[2] == '\x07');
+        assert(in[3] == '.');
+        assert(in[4] == 'A');
+        assert(in[5] == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp
new file mode 100644
index 0000000..5a65a56
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// char widen(char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.widen(' ') == ' ');
+        assert(f.widen('A') == 'A');
+        assert(f.widen('\x07') == '\x07');
+        assert(f.widen('.') == '.');
+        assert(f.widen('a') == 'a');
+        assert(f.widen('1') == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp
new file mode 100644
index 0000000..c86cc55
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.members/widen_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>;
+
+// const char* widen(const char* low, const char* high, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<char> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+        std::vector<char> v(in.size());
+
+        assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+        assert(v[0] == ' ');
+        assert(v[1] == 'A');
+        assert(v[2] == '\x07');
+        assert(v[3] == '.');
+        assert(v[4] == 'a');
+        assert(v[5] == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp
new file mode 100644
index 0000000..bdb7696
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class ctype<char>
+
+// static const mask* classic_table() throw();
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    typedef std::ctype<char> F;
+    assert(F::classic_table() != 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp
new file mode 100644
index 0000000..f58ec30
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/facet.ctype.special/types.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class ctype<char>
+//     : public locale::facet,
+//       public ctype_base
+// {
+// public:
+//     typedef char char_type;
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::ctype<char> >(l));
+        const std::ctype<char>& f = std::use_facet<std::ctype<char> >(l);
+        {
+            (void)std::ctype<char>::id;
+        }
+        static_assert((std::is_same<std::ctype<char>::char_type, char>::value), "");
+        static_assert((std::is_base_of<std::ctype_base, std::ctype<char> >::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::ctype<char> >::value), "");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
new file mode 100644
index 0000000..3495778
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet("en_US"));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f("en_US", 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string("en_US"), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp
new file mode 100644
index 0000000..0559896
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char16_t.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char16_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char16_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet("en_US"));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f("en_US", 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string("en_US"), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp
new file mode 100644
index 0000000..8eda52d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_char32_t.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<char32_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt_byname<char32_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet("en_US"));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f("en_US", 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string("en_US"), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp
new file mode 100644
index 0000000..bc55f00
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt_byname<wchar_t, char, mbstate_t>
+
+// explicit codecvt_byname(const char* nm, size_t refs = 0);
+// explicit codecvt_byname(const string& nm, size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(const char* nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet(LOCALE_en_US_UTF_8));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(LOCALE_en_US_UTF_8, 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet(std::string(LOCALE_en_US_UTF_8)));
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(std::string(LOCALE_en_US_UTF_8), 1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp
new file mode 100644
index 0000000..a2973b7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/codecvt_base.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class codecvt_base
+// {
+// public:
+//     enum result {ok, partial, error, noconv};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    assert(std::codecvt_base::ok == 0);
+    assert(std::codecvt_base::partial == 1);
+    assert(std::codecvt_base::error == 2);
+    assert(std::codecvt_base::noconv == 3);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp
new file mode 100644
index 0000000..121a815
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp
new file mode 100644
index 0000000..5a6cdee
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char16_t.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+//#endif
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+//#endif
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp
new file mode 100644
index 0000000..fae0d7b
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_char32_t.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+//#endif
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+//#endif
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp
new file mode 100644
index 0000000..4cd84f2
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/ctor_wchar_t.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// explicit codecvt(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp
new file mode 100644
index 0000000..4a0f94f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(!f.always_noconv());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp
new file mode 100644
index 0000000..d2a6ae3
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
new file mode 100644
index 0000000..331f4ba
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result in(stateT& state,
+//           const externT* from, const externT* from_end, const externT*& from_next,
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const char from[] = "some text";
+    F::intern_type to[9];
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char* from_next = 0;
+    F::intern_type* to_next = 0;
+    assert(f.in(mbs, from, from + 9, from_next,
+                     to, to + 9, to_next) == F::ok);
+    assert(from_next - from == 9);
+    assert(to_next - to == 9);
+    for (unsigned i = 0; i < 9; ++i)
+        assert(to[i] == from[i]);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp
new file mode 100644
index 0000000..34ab217
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char from[] = "some text";
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 8) == 8);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp
new file mode 100644
index 0000000..8abe10b
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 4);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp
new file mode 100644
index 0000000..0f65f13
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result out(stateT& state,
+//            const internT* from, const internT* from_end, const internT*& from_next,
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    {
+        F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
+        char to[9] = {0};
+        std::mbstate_t mbs = {0};
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from, from + 9, from_next,
+                                 to, to + 9, to_next);
+        assert(r == F::ok);
+        assert(from_next - from == 9);
+        assert(to_next - to == 9);
+        for (unsigned i = 0; i < 9; ++i)
+            assert(to[i] == from[i]);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp
new file mode 100644
index 0000000..c213030
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char16_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<char> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    char* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(to_next == to.data());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp
new file mode 100644
index 0000000..2270a30
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(!f.always_noconv());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp
new file mode 100644
index 0000000..175470a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp
new file mode 100644
index 0000000..8fb28f0
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result in(stateT& state,
+//           const externT* from, const externT* from_end, const externT*& from_next,
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const char from[] = "some text";
+    F::intern_type to[9];
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char* from_next = 0;
+    F::intern_type* to_next = 0;
+    assert(f.in(mbs, from, from + 9, from_next,
+                     to, to + 9, to_next) == F::ok);
+    assert(from_next - from == 9);
+    assert(to_next - to == 9);
+    for (unsigned i = 0; i < 9; ++i)
+        assert(to[i] == from[i]);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp
new file mode 100644
index 0000000..d8555d1
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char from[] = "some text";
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 8) == 8);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp
new file mode 100644
index 0000000..62b4919
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 4);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp
new file mode 100644
index 0000000..a1d11f7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result out(stateT& state,
+//            const internT* from, const internT* from_end, const internT*& from_next,
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    {
+        F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
+        char to[9] = {0};
+        std::mbstate_t mbs = {0};
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from, from + 9, from_next,
+                                 to, to + 9, to_next);
+        assert(r == F::ok);
+        assert(from_next - from == 9);
+        assert(to_next - to == 9);
+        for (unsigned i = 0; i < 9; ++i)
+            assert(to[i] == from[i]);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp
new file mode 100644
index 0000000..1bd45e0
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<char> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    char* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(to_next == to.data());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp
new file mode 100644
index 0000000..7164049
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.always_noconv());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp
new file mode 100644
index 0000000..79bc2bf
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 1);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp
new file mode 100644
index 0000000..4d2f6f2
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result in(stateT& state,
+//           const externT* from, const externT* from_end, const externT*& from_next,
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const std::basic_string<F::intern_type> from("some text");
+    std::vector<char> to(from.size());
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char* from_next = 0;
+    char* to_next = 0;
+    assert(f.in(mbs, from.data(), from.data() + from.size(), from_next,
+                     to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(from_next == from.data());
+    assert(to_next == to.data());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp
new file mode 100644
index 0000000..df33b18
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char from[10]= {0};
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 11) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp
new file mode 100644
index 0000000..626c652
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 1);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp
new file mode 100644
index 0000000..de7f024
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result out(stateT& state,
+//            const internT* from, const internT* from_end, const internT*& from_next,
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const std::basic_string<F::intern_type> from("some text");
+    std::vector<char> to(from.size());
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char* from_next = 0;
+    char* to_next = 0;
+    assert(f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                      to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(from_next == from.data());
+    assert(to_next == to.data());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp
new file mode 100644
index 0000000..830bc43
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<char, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<char> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    char* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
+    assert(to_next == to.data());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp
new file mode 100644
index 0000000..2505582
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<char32_t, char, mbstate_t>
+// template <> class codecvt<char16_t, char, mbstate_t>
+// template <> class codecvt<char32_t, char16_t, mbstate_t>  // extension
+
+// sanity check
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    typedef std::codecvt<char32_t, char, std::mbstate_t> F32_8;
+    typedef std::codecvt<char16_t, char, std::mbstate_t> F16_8;
+    typedef std::codecvt_utf16<char32_t> F32_16;
+    std::locale l = std::locale(std::locale::classic(), new F32_16);
+    const F32_8& f32_8 = std::use_facet<F32_8>(std::locale::classic());
+    const F32_16& f32_16 = std::use_facet<F32_16>(l);
+    const F16_8& f16_8 = std::use_facet<F16_8>(std::locale::classic());
+    std::mbstate_t mbs = {0};
+    F32_8::intern_type* c32p;
+    F16_8::intern_type* c16p;
+    F32_8::extern_type* c8p;
+    const F32_8::intern_type* c_c32p;
+    const F16_8::intern_type* c_c16p;
+    const F32_8::extern_type* c_c8p;
+    F32_8::intern_type c32;
+    F16_8::intern_type c16[2];
+    char c16c[4];
+    char* c16cp;
+    F32_8::extern_type c8[4];
+    for (F32_8::intern_type c32x = 0; c32x < 0x110003; ++c32x)
+    {
+        if ((0xD800 <= c32x && c32x < 0xE000) || c32x >= 0x110000)
+        {
+            assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16c+0, c16c+4, c16cp) == F32_8::error);
+            assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::error);
+        }
+        else
+        {
+            assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16c, c16c+4, c16cp) == F32_8::ok);
+            assert(c_c32p-&c32x == 1);
+            if (c32x < 0x10000)
+                assert(c16cp-c16c == 2);
+            else
+                assert(c16cp-c16c == 4);
+            for (int i = 0; i < (c16cp - c16c) / 2; ++i)
+                c16[i] = (unsigned char)c16c[2*i] << 8 | (unsigned char)c16c[2*i+1];
+            c_c16p = c16 + (c16cp - c16c) / 2;
+            assert(f16_8.out(mbs, c16, c_c16p, c_c16p, c8, c8+4, c8p) == F32_8::ok);
+            if (c32x < 0x10000)
+                assert(c_c16p-c16 == 1);
+            else
+                assert(c_c16p-c16 == 2);
+            if (c32x < 0x80)
+                assert(c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c8p-c8 == 3);
+            else
+                assert(c8p-c8 == 4);
+            c_c8p = c8p;
+            assert(f32_8.in(mbs, c8, c_c8p, c_c8p, &c32, &c32+1, c32p) == F32_8::ok);
+            if (c32x < 0x80)
+                assert(c_c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c_c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c_c8p-c8 == 3);
+            else
+                assert(c_c8p-c8 == 4);
+            assert(c32p-&c32 == 1);
+            assert(c32 == c32x);
+            assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::ok);
+            assert(c_c32p-&c32x == 1);
+            if (c32x < 0x80)
+                assert(c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c8p-c8 == 3);
+            else
+                assert(c8p-c8 == 4);
+            c_c8p = c8p;
+            assert(f16_8.in(mbs, c8, c_c8p, c_c8p, c16, c16+2, c16p) == F32_8::ok);
+            if (c32x < 0x80)
+                assert(c_c8p-c8 == 1);
+            else if (c32x < 0x800)
+                assert(c_c8p-c8 == 2);
+            else if (c32x < 0x10000)
+                assert(c_c8p-c8 == 3);
+            else
+                assert(c_c8p-c8 == 4);
+            if (c32x < 0x10000)
+                assert(c16p-c16 == 1);
+            else
+                assert(c16p-c16 == 2);
+            for (int i = 0; i < c16p-c16; ++i)
+            {
+                c16c[2*i] = static_cast<char>(c16[i] >> 8);
+                c16c[2*i+1] = static_cast<char>(c16[i]);
+            }
+            const char* c_c16cp = c16c + (c16p-c16)*2;
+            assert(f32_16.in(mbs, c16c, c_c16cp, c_c16cp, &c32, &c32+1, c32p) == F32_8::ok);
+            if (c32x < 0x10000)
+                assert(c_c16cp-c16c == 2);
+            else
+                assert(c_c16cp-c16c == 4);
+            assert(c32p-&c32 == 1);
+            assert(c32 == c32x);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp
new file mode 100644
index 0000000..258998f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_always_noconv.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// bool always_noconv() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(!f.always_noconv());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp
new file mode 100644
index 0000000..b7604f3
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_encoding.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int encoding() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.encoding() == 1);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp
new file mode 100644
index 0000000..e98097b
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result in(stateT& state,
+//           const externT* from, const externT* from_end, const externT*& from_next,
+//           internT* to, internT* to_end, internT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const std::basic_string<F::extern_type> from("some text");
+    const std::basic_string<F::intern_type> expected(from.begin(), from.end());
+    std::basic_string<F::intern_type> to(from.size(), F::intern_type());
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const F::extern_type* from_next = 0;
+    F::intern_type* to_next = 0;
+    F::result r = f.in(mbs, from.data(), from.data() + from.size(), from_next,
+                            &to[0], &to[0] + to.size(), to_next);
+    assert(r == F::ok);
+    assert(from_next - from.data() == from.size());
+    assert(to_next - to.data() == expected.size());
+    assert(to_next - to.data() == expected.size());
+    assert(to == expected);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp
new file mode 100644
index 0000000..f97f2b4
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    const char* from = "123467890";
+    assert(f.length(mbs, from, from+10, 0) == 0);
+    assert(f.length(mbs, from, from+10, 9) == 9);
+    assert(f.length(mbs, from, from+10, 10) == 10);
+    assert(f.length(mbs, from, from+10, 11) == 10);
+    assert(f.length(mbs, from, from+10, 100) == 10);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp
new file mode 100644
index 0000000..38ce514
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_max_length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// int max_length() const throw();
+
+#include <locale>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    assert(f.max_length() == 1);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp
new file mode 100644
index 0000000..dce2d38
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result out(stateT& state,
+//            const internT* from, const internT* from_end, const internT*& from_next,
+//            externT* to, externT* to_end, externT*& to_next) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    const F& f = std::use_facet<F>(l);
+    {
+        const std::basic_string<F::intern_type> from(L"some text");
+        std::vector<char> to(from.size()+1);
+        std::mbstate_t mbs = {0};
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                                 to.data(), to.data() + to.size(), to_next);
+        assert(r == F::ok);
+        assert(from_next - from.data() == from.size());
+        assert(to_next - to.data() == from.size());
+        assert(to.data() == std::string("some text"));
+    }
+    {
+        std::basic_string<F::intern_type> from(L"some text");
+        from[4] = '\0';
+        std::vector<char> to(from.size()+1);
+        std::mbstate_t mbs = {0};
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                                 to.data(), to.data() + to.size(), to_next);
+        assert(r == F::ok);
+        assert(from_next - from.data() == from.size());
+        assert(to_next - to.data() == from.size());
+        assert(memcmp(to.data(), "some\0text", from.size()) == 0);
+    }
+    {
+        std::basic_string<F::intern_type> from(L"some text");
+        std::vector<char> to(from.size()-1);
+        std::mbstate_t mbs = {0};
+        const F::intern_type* from_next = 0;
+        char* to_next = 0;
+        F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
+                                 to.data(), to.data() + to.size()-1, to_next);
+        assert(r == F::partial);
+        assert(from_next - from.data() == to.size()-1);
+        assert(to_next - to.data() == to.size()-1);
+        assert(to.data() == std::string("some te"));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp
new file mode 100644
index 0000000..4d8895c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <> class codecvt<wchar_t, char, mbstate_t>
+
+// result unshift(stateT& state,
+//                externT* to, externT* to_end, externT*& to_next) const;
+
+// This is pretty much just an "are you breathing" test
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    std::vector<F::extern_type> to(3);
+    const F& f = std::use_facet<F>(l);
+    std::mbstate_t mbs = {0};
+    F::extern_type* to_next = 0;
+    assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::ok);
+    assert(to_next == to.data());
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp
new file mode 100644
index 0000000..5e2c44f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public:
+//     typedef char      intern_type;
+//     typedef char      extern_type;
+//     typedef mbstate_t state_type;
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::codecvt<char, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, char>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp
new file mode 100644
index 0000000..9d512bd
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char16_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char16_t, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public:
+//     typedef char16_t  intern_type;
+//     typedef char      extern_type;
+//     typedef mbstate_t state_type;
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    typedef std::codecvt<char16_t, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, char16_t>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+//#endif
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp
new file mode 100644
index 0000000..25f2b3d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_char32_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<char32_t, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public:
+//     typedef char32_t  intern_type;
+//     typedef char      extern_type;
+//     typedef mbstate_t state_type;
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    typedef std::codecvt<char32_t, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, char32_t>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+//#endif
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp
new file mode 100644
index 0000000..8b6868e
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.codecvt/types_wchar_t.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <>
+// class codecvt<wchar_t, char, mbstate_t>
+//     : public locale::facet,
+//       public codecvt_base
+// {
+// public:
+//     typedef wchar_t   intern_type;
+//     typedef char      extern_type;
+//     typedef mbstate_t state_type;
+//     ...
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
+    static_assert((std::is_base_of<std::locale::facet, F>::value), "");
+    static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
+    static_assert((std::is_same<F::intern_type, wchar_t>::value), "");
+    static_assert((std::is_same<F::extern_type, char>::value), "");
+    static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
+    std::locale l = std::locale::classic();
+    assert(std::has_facet<F>(l));
+    const F& f = std::use_facet<F>(l);
+    (void)F::id;
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp
new file mode 100644
index 0000000..0ade80a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_1.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// bool is(mask m, charT c) const;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.is(F::space, L' '));
+            assert(!f.is(F::space, L'A'));
+
+            assert(f.is(F::print, L' '));
+            assert(!f.is(F::print, L'\x07'));
+
+            assert(f.is(F::cntrl, L'\x07'));
+            assert(!f.is(F::cntrl, L' '));
+
+            assert(f.is(F::upper, L'A'));
+            assert(!f.is(F::upper, L'a'));
+
+            assert(f.is(F::lower, L'a'));
+            assert(!f.is(F::lower, L'A'));
+
+            assert(f.is(F::alpha, L'a'));
+            assert(!f.is(F::alpha, L'1'));
+
+            assert(f.is(F::digit, L'1'));
+            assert(!f.is(F::digit, L'a'));
+
+            assert(f.is(F::punct, L'.'));
+            assert(!f.is(F::punct, L'a'));
+
+            assert(f.is(F::xdigit, L'a'));
+            assert(!f.is(F::xdigit, L'g'));
+
+            assert(f.is(F::alnum, L'a'));
+            assert(!f.is(F::alnum, L'.'));
+
+            assert(f.is(F::graph, L'.'));
+            assert(!f.is(F::graph,  L'\x07'));
+
+            assert(f.is(F::alpha, L'\x00DA'));
+            assert(f.is(F::upper, L'\x00DA'));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.is(F::space, L' '));
+            assert(!f.is(F::space, L'A'));
+
+            assert(f.is(F::print, L' '));
+            assert(!f.is(F::print, L'\x07'));
+
+            assert(f.is(F::cntrl, L'\x07'));
+            assert(!f.is(F::cntrl, L' '));
+
+            assert(f.is(F::upper, L'A'));
+            assert(!f.is(F::upper, L'a'));
+
+            assert(f.is(F::lower, L'a'));
+            assert(!f.is(F::lower, L'A'));
+
+            assert(f.is(F::alpha, L'a'));
+            assert(!f.is(F::alpha, L'1'));
+
+            assert(f.is(F::digit, L'1'));
+            assert(!f.is(F::digit, L'a'));
+
+            assert(f.is(F::punct, L'.'));
+            assert(!f.is(F::punct, L'a'));
+
+            assert(f.is(F::xdigit, L'a'));
+            assert(!f.is(F::xdigit, L'g'));
+
+            assert(f.is(F::alnum, L'a'));
+            assert(!f.is(F::alnum, L'.'));
+
+            assert(f.is(F::graph, L'.'));
+            assert(!f.is(F::graph,  L'\x07'));
+
+            assert(!f.is(F::alpha, L'\x00DA'));
+            assert(!f.is(F::upper, L'\x00DA'));
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp
new file mode 100644
index 0000000..39f6071
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/is_many.pass.cpp
@@ -0,0 +1,245 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+            assert(h == in.data() + in.size());
+
+            // L'\x00DA'
+            assert(!(m[0] & F::space));
+            assert( (m[0] & F::print));
+            assert(!(m[0] & F::cntrl));
+            assert( (m[0] & F::upper));
+            assert(!(m[0] & F::lower));
+            assert( (m[0] & F::alpha));
+            assert(!(m[0] & F::digit));
+            assert(!(m[0] & F::punct));
+            assert(!(m[0] & F::xdigit));
+            assert(!(m[0] & F::blank));
+            assert( (m[0] & F::alnum));
+            assert( (m[0] & F::graph));
+
+            // L' '
+            assert( (m[1] & F::space));
+            assert( (m[1] & F::print));
+            assert(!(m[1] & F::cntrl));
+            assert(!(m[1] & F::upper));
+            assert(!(m[1] & F::lower));
+            assert(!(m[1] & F::alpha));
+            assert(!(m[1] & F::digit));
+            assert(!(m[1] & F::punct));
+            assert(!(m[1] & F::xdigit));
+            assert( (m[1] & F::blank));
+            assert(!(m[1] & F::alnum));
+            assert(!(m[1] & F::graph));
+
+            // L'A'
+            assert(!(m[2] & F::space));
+            assert( (m[2] & F::print));
+            assert(!(m[2] & F::cntrl));
+            assert( (m[2] & F::upper));
+            assert(!(m[2] & F::lower));
+            assert( (m[2] & F::alpha));
+            assert(!(m[2] & F::digit));
+            assert(!(m[2] & F::punct));
+            assert( (m[2] & F::xdigit));
+            assert(!(m[2] & F::blank));
+            assert( (m[2] & F::alnum));
+            assert( (m[2] & F::graph));
+
+            // L'\x07'
+            assert(!(m[3] & F::space));
+            assert(!(m[3] & F::print));
+            assert( (m[3] & F::cntrl));
+            assert(!(m[3] & F::upper));
+            assert(!(m[3] & F::lower));
+            assert(!(m[3] & F::alpha));
+            assert(!(m[3] & F::digit));
+            assert(!(m[3] & F::punct));
+            assert(!(m[3] & F::xdigit));
+            assert(!(m[3] & F::blank));
+            assert(!(m[3] & F::alnum));
+            assert(!(m[3] & F::graph));
+
+            // L'.'
+            assert(!(m[4] & F::space));
+            assert( (m[4] & F::print));
+            assert(!(m[4] & F::cntrl));
+            assert(!(m[4] & F::upper));
+            assert(!(m[4] & F::lower));
+            assert(!(m[4] & F::alpha));
+            assert(!(m[4] & F::digit));
+            assert( (m[4] & F::punct));
+            assert(!(m[4] & F::xdigit));
+            assert(!(m[4] & F::blank));
+            assert(!(m[4] & F::alnum));
+            assert( (m[4] & F::graph));
+
+            // L'a'
+            assert(!(m[5] & F::space));
+            assert( (m[5] & F::print));
+            assert(!(m[5] & F::cntrl));
+            assert(!(m[5] & F::upper));
+            assert( (m[5] & F::lower));
+            assert( (m[5] & F::alpha));
+            assert(!(m[5] & F::digit));
+            assert(!(m[5] & F::punct));
+            assert( (m[5] & F::xdigit));
+            assert(!(m[5] & F::blank));
+            assert( (m[5] & F::alnum));
+            assert( (m[5] & F::graph));
+
+            // L'1'
+            assert(!(m[6] & F::space));
+            assert( (m[6] & F::print));
+            assert(!(m[6] & F::cntrl));
+            assert(!(m[6] & F::upper));
+            assert(!(m[6] & F::lower));
+            assert(!(m[6] & F::alpha));
+            assert( (m[6] & F::digit));
+            assert(!(m[6] & F::punct));
+            assert( (m[6] & F::xdigit));
+            assert(!(m[6] & F::blank));
+            assert( (m[6] & F::alnum));
+            assert( (m[6] & F::graph));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+            assert(h == in.data() + in.size());
+
+            // L'\x00DA'
+            assert(!(m[0] & F::space));
+            assert(!(m[0] & F::print));
+            assert(!(m[0] & F::cntrl));
+            assert(!(m[0] & F::upper));
+            assert(!(m[0] & F::lower));
+            assert(!(m[0] & F::alpha));
+            assert(!(m[0] & F::digit));
+            assert(!(m[0] & F::punct));
+            assert(!(m[0] & F::xdigit));
+            assert(!(m[0] & F::blank));
+            assert(!(m[0] & F::alnum));
+            assert(!(m[0] & F::graph));
+
+            // L' '
+            assert( (m[1] & F::space));
+            assert( (m[1] & F::print));
+            assert(!(m[1] & F::cntrl));
+            assert(!(m[1] & F::upper));
+            assert(!(m[1] & F::lower));
+            assert(!(m[1] & F::alpha));
+            assert(!(m[1] & F::digit));
+            assert(!(m[1] & F::punct));
+            assert(!(m[1] & F::xdigit));
+            assert( (m[1] & F::blank));
+            assert(!(m[1] & F::alnum));
+            assert(!(m[1] & F::graph));
+
+            // L'A'
+            assert(!(m[2] & F::space));
+            assert( (m[2] & F::print));
+            assert(!(m[2] & F::cntrl));
+            assert( (m[2] & F::upper));
+            assert(!(m[2] & F::lower));
+            assert( (m[2] & F::alpha));
+            assert(!(m[2] & F::digit));
+            assert(!(m[2] & F::punct));
+            assert( (m[2] & F::xdigit));
+            assert(!(m[2] & F::blank));
+            assert( (m[2] & F::alnum));
+            assert( (m[2] & F::graph));
+
+            // L'\x07'
+            assert(!(m[3] & F::space));
+            assert(!(m[3] & F::print));
+            assert( (m[3] & F::cntrl));
+            assert(!(m[3] & F::upper));
+            assert(!(m[3] & F::lower));
+            assert(!(m[3] & F::alpha));
+            assert(!(m[3] & F::digit));
+            assert(!(m[3] & F::punct));
+            assert(!(m[3] & F::xdigit));
+            assert(!(m[3] & F::blank));
+            assert(!(m[3] & F::alnum));
+            assert(!(m[3] & F::graph));
+
+            // L'.'
+            assert(!(m[4] & F::space));
+            assert( (m[4] & F::print));
+            assert(!(m[4] & F::cntrl));
+            assert(!(m[4] & F::upper));
+            assert(!(m[4] & F::lower));
+            assert(!(m[4] & F::alpha));
+            assert(!(m[4] & F::digit));
+            assert( (m[4] & F::punct));
+            assert(!(m[4] & F::xdigit));
+            assert(!(m[4] & F::blank));
+            assert(!(m[4] & F::alnum));
+            assert( (m[4] & F::graph));
+
+            // L'a'
+            assert(!(m[5] & F::space));
+            assert( (m[5] & F::print));
+            assert(!(m[5] & F::cntrl));
+            assert(!(m[5] & F::upper));
+            assert( (m[5] & F::lower));
+            assert( (m[5] & F::alpha));
+            assert(!(m[5] & F::digit));
+            assert(!(m[5] & F::punct));
+            assert( (m[5] & F::xdigit));
+            assert(!(m[5] & F::blank));
+            assert( (m[5] & F::alnum));
+            assert( (m[5] & F::graph));
+
+            // L'1'
+            assert(!(m[6] & F::space));
+            assert( (m[6] & F::print));
+            assert(!(m[6] & F::cntrl));
+            assert(!(m[6] & F::upper));
+            assert(!(m[6] & F::lower));
+            assert(!(m[6] & F::alpha));
+            assert( (m[6] & F::digit));
+            assert(!(m[6] & F::punct));
+            assert( (m[6] & F::xdigit));
+            assert(!(m[6] & F::blank));
+            assert( (m[6] & F::alnum));
+            assert( (m[6] & F::graph));
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp
new file mode 100644
index 0000000..04d061b
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_1.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// char narrow(charT c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(std::string(LOCALE_fr_CA_ISO8859_1));
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.narrow(L' ', '*') == ' ');
+            assert(f.narrow(L'A', '*') == 'A');
+            assert(f.narrow(L'\x07', '*') == '\x07');
+            assert(f.narrow(L'.', '*') == '.');
+            assert(f.narrow(L'a', '*') == 'a');
+            assert(f.narrow(L'1', '*') == '1');
+            assert(f.narrow(L'\xDA', '*') == '\xDA');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.narrow(L' ', '*') == ' ');
+            assert(f.narrow(L'A', '*') == 'A');
+            assert(f.narrow(L'\x07', '*') == '\x07');
+            assert(f.narrow(L'.', '*') == '.');
+            assert(f.narrow(L'a', '*') == 'a');
+            assert(f.narrow(L'1', '*') == '1');
+            assert(f.narrow(L'\xDA', '*') == '*');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp
new file mode 100644
index 0000000..7165dc9
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/narrow_many.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_fr_CA_ISO8859_1);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L" A\x07.a1\xDA");
+            std::vector<char> v(in.size());
+
+            assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+            assert(v[0] == ' ');
+            assert(v[1] == 'A');
+            assert(v[2] == '\x07');
+            assert(v[3] == '.');
+            assert(v[4] == 'a');
+            assert(v[5] == '1');
+            assert(v[6] == '\xDA');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L" A\x07.a1\xDA");
+            std::vector<char> v(in.size());
+
+            assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+            assert(v[0] == ' ');
+            assert(v[1] == 'A');
+            assert(v[2] == '\x07');
+            assert(v[3] == '.');
+            assert(v[4] == 'a');
+            assert(v[5] == '1');
+            assert(v[6] == '*');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
new file mode 100644
index 0000000..ab08794
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_is.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* scan_is(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
+            assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
+            assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
+            assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
+            assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
+            assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
+            assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
+            assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
+            assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 2);
+            assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 2);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
new file mode 100644
index 0000000..126fc5a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/scan_not.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* scan_not(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 3);
+            assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+            assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            const std::wstring in(L"\x00DA A\x07.a1");
+            std::vector<F::mask> m(in.size());
+            assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+            assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
new file mode 100644
index 0000000..8f84195
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT tolower(charT) const;
+
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.tolower(' ') == ' ');
+            assert(f.tolower('A') == 'a');
+            assert(f.tolower('\x07') == '\x07');
+            assert(f.tolower('.') == '.');
+            assert(f.tolower('a') == 'a');
+            assert(f.tolower('1') == '1');
+            assert(f.tolower('\xDA') == '\xFA');
+            assert(f.tolower('\xFA') == '\xFA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.tolower(' ') == ' ');
+            assert(f.tolower('A') == 'a');
+            assert(f.tolower('\x07') == '\x07');
+            assert(f.tolower('.') == '.');
+            assert(f.tolower('a') == 'a');
+            assert(f.tolower('1') == '1');
+            assert(f.tolower('\xDA') == '\xDA');
+            assert(f.tolower('\xFA') == '\xFA');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.tolower(L' ') == L' ');
+            assert(f.tolower(L'A') == L'a');
+            assert(f.tolower(L'\x07') == L'\x07');
+            assert(f.tolower(L'.') == L'.');
+            assert(f.tolower(L'a') == L'a');
+            assert(f.tolower(L'1') == L'1');
+            assert(f.tolower(L'\xDA') == L'\xFA');
+            assert(f.tolower(L'\xFA') == L'\xFA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.tolower(L' ') == L' ');
+            assert(f.tolower(L'A') == L'a');
+            assert(f.tolower(L'\x07') == L'\x07');
+            assert(f.tolower(L'.') == L'.');
+            assert(f.tolower(L'a') == L'a');
+            assert(f.tolower(L'1') == L'1');
+            assert(f.tolower(L'\xDA') == L'\xDA');
+            assert(f.tolower(L'\xFA') == L'\xFA');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
new file mode 100644
index 0000000..1f48076
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* tolower(charT* low, const charT* high) const;
+
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xDA A\x07.a1");
+
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xFA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'a');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'a');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xDA A\x07.a1");
+
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xDA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'a');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'a');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xDA A\x07.a1");
+
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xFA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'a');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'a');
+            assert(in[6] == L'1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xDA A\x07.a1");
+
+            assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xDA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'a');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'a');
+            assert(in[6] == L'1');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
new file mode 100644
index 0000000..d215791
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT toupper(charT) const;
+
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.toupper(' ') == ' ');
+            assert(f.toupper('A') == 'A');
+            assert(f.toupper('\x07') == '\x07');
+            assert(f.toupper('.') == '.');
+            assert(f.toupper('a') == 'A');
+            assert(f.toupper('1') == '1');
+            assert(f.toupper('\xDA') == '\xDA');
+            assert(f.toupper('\xFA') == '\xDA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.toupper(' ') == ' ');
+            assert(f.toupper('A') == 'A');
+            assert(f.toupper('\x07') == '\x07');
+            assert(f.toupper('.') == '.');
+            assert(f.toupper('a') == 'A');
+            assert(f.toupper('1') == '1');
+            assert(f.toupper('\xDA') == '\xDA');
+            assert(f.toupper('\xFA') == '\xFA');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.toupper(L' ') == L' ');
+            assert(f.toupper(L'A') == L'A');
+            assert(f.toupper(L'\x07') == L'\x07');
+            assert(f.toupper(L'.') == L'.');
+            assert(f.toupper(L'a') == L'A');
+            assert(f.toupper(L'1') == L'1');
+            assert(f.toupper(L'\xDA') == L'\xDA');
+            assert(f.toupper(L'\xFA') == L'\xDA');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.toupper(L' ') == L' ');
+            assert(f.toupper(L'A') == L'A');
+            assert(f.toupper(L'\x07') == L'\x07');
+            assert(f.toupper(L'.') == L'.');
+            assert(f.toupper(L'a') == L'A');
+            assert(f.toupper(L'1') == L'1');
+            assert(f.toupper(L'\xDA') == L'\xDA');
+            assert(f.toupper(L'\xFA') == L'\xFA');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
new file mode 100644
index 0000000..c3c32e7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const charT* toupper(charT* low, const charT* high) const;
+
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xFA A\x07.a1");
+
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xDA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'A');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'A');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<char> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in("\xFA A\x07.a1");
+
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == '\xFA');
+            assert(in[1] == ' ');
+            assert(in[2] == 'A');
+            assert(in[3] == '\x07');
+            assert(in[4] == '.');
+            assert(in[5] == 'A');
+            assert(in[6] == '1');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xFA A\x07.a1");
+
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xDA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'A');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'A');
+            assert(in[6] == L'1');
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::wstring in(L"\xFA A\x07.a1");
+
+            assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+            assert(in[0] == L'\xFA');
+            assert(in[1] == L' ');
+            assert(in[2] == L'A');
+            assert(in[3] == L'\x07');
+            assert(in[4] == L'.');
+            assert(in[5] == L'A');
+            assert(in[6] == L'1');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp
new file mode 100644
index 0000000..03e8dfc
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT>
+// class ctype_byname
+//     : public ctype<CharT>
+// {
+// public:
+//     explicit ctype_byname(const char*, size_t = 0);
+//     explicit ctype_byname(const string&, size_t = 0);
+//
+// protected:
+//     ~ctype_byname();
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            assert(std::has_facet<std::ctype_byname<char> >(l));
+            assert(&std::use_facet<std::ctype<char> >(l)
+                == &std::use_facet<std::ctype_byname<char> >(l));
+        }
+        {
+            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+            assert(&std::use_facet<std::ctype<wchar_t> >(l)
+                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+        }
+    }
+    {
+        std::locale l("");
+        {
+            assert(std::has_facet<std::ctype_byname<char> >(l));
+            assert(&std::use_facet<std::ctype<char> >(l)
+                == &std::use_facet<std::ctype_byname<char> >(l));
+        }
+        {
+            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+            assert(&std::use_facet<std::ctype<wchar_t> >(l)
+                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            assert(std::has_facet<std::ctype_byname<char> >(l));
+            assert(&std::use_facet<std::ctype<char> >(l)
+                == &std::use_facet<std::ctype_byname<char> >(l));
+        }
+        {
+            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
+            assert(&std::use_facet<std::ctype<wchar_t> >(l)
+                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
new file mode 100644
index 0000000..ed56dd3
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// charT widen(char c) const;
+
+// I doubt this test is portable
+
+#include <locale>
+#include <cassert>
+#include <limits.h>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.widen(' ') == L' ');
+            assert(f.widen('A') == L'A');
+            assert(f.widen('\x07') == L'\x07');
+            assert(f.widen('.') == L'.');
+            assert(f.widen('a') == L'a');
+            assert(f.widen('1') == L'1');
+            assert(f.widen(char(-5)) == wchar_t(-1));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+
+            assert(f.widen(' ') == L' ');
+            assert(f.widen('A') == L'A');
+            assert(f.widen('\x07') == L'\x07');
+            assert(f.widen('.') == L'.');
+            assert(f.widen('a') == L'a');
+            assert(f.widen('1') == L'1');
+            assert(f.widen(char(-5)) == wchar_t(251));
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
new file mode 100644
index 0000000..c522762
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype_byname;
+
+// const char* widen(const char* low, const char* high, charT* to) const;
+
+// I doubt this test is portable
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in(" A\x07.a1\x85");
+            std::vector<wchar_t> v(in.size());
+
+            assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+            assert(v[0] == L' ');
+            assert(v[1] == L'A');
+            assert(v[2] == L'\x07');
+            assert(v[3] == L'.');
+            assert(v[4] == L'a');
+            assert(v[5] == L'1');
+            assert(v[6] == wchar_t(-1));
+        }
+    }
+    {
+        std::locale l("C");
+        {
+            typedef std::ctype<wchar_t> F;
+            const F& f = std::use_facet<F>(l);
+            std::string in(" A\x07.a1\x85");
+            std::vector<wchar_t> v(in.size());
+
+            assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+            assert(v[0] == L' ');
+            assert(v[1] == L'A');
+            assert(v[2] == L'\x07');
+            assert(v[3] == L'.');
+            assert(v[4] == L'a');
+            assert(v[5] == L'1');
+            assert(v[6] == wchar_t(133));
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp
new file mode 100644
index 0000000..7eb3cc8
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/ctor.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// explicit ctype(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+template <class C>
+class my_facet
+    : public std::ctype<C>
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : std::ctype<C>(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+    {
+        my_facet<wchar_t> f(1);
+        assert(my_facet<wchar_t>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<wchar_t>::count == 1);
+        }
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp
new file mode 100644
index 0000000..fa82da9
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_1.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// bool is(mask m, charT c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.is(F::space, L' '));
+        assert(!f.is(F::space, L'A'));
+
+        assert(f.is(F::print, L' '));
+        assert(!f.is(F::print, L'\x07'));
+
+        assert(f.is(F::cntrl, L'\x07'));
+        assert(!f.is(F::cntrl, L' '));
+
+        assert(f.is(F::upper, L'A'));
+        assert(!f.is(F::upper, L'a'));
+
+        assert(f.is(F::lower, L'a'));
+        assert(!f.is(F::lower, L'A'));
+
+        assert(f.is(F::alpha, L'a'));
+        assert(!f.is(F::alpha, L'1'));
+
+        assert(f.is(F::digit, L'1'));
+        assert(!f.is(F::digit, L'a'));
+
+        assert(f.is(F::punct, L'.'));
+        assert(!f.is(F::punct, L'a'));
+
+        assert(f.is(F::xdigit, L'a'));
+        assert(!f.is(F::xdigit, L'g'));
+
+        assert(f.is(F::alnum, L'a'));
+        assert(!f.is(F::alnum, L'.'));
+
+        assert(f.is(F::graph, L'.'));
+        assert(!f.is(F::graph,  L'\x07'));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp
new file mode 100644
index 0000000..7084245
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/is_many.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        const std::wstring in(L" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
+        assert(h == in.data() + in.size());
+
+        // L' '
+        assert( (m[0] & F::space));
+        assert( (m[0] & F::print));
+        assert(!(m[0] & F::cntrl));
+        assert(!(m[0] & F::upper));
+        assert(!(m[0] & F::lower));
+        assert(!(m[0] & F::alpha));
+        assert(!(m[0] & F::digit));
+        assert(!(m[0] & F::punct));
+        assert(!(m[0] & F::xdigit));
+        assert( (m[0] & F::blank));
+        assert(!(m[0] & F::alnum));
+        assert(!(m[0] & F::graph));
+
+        // L'A'
+        assert(!(m[1] & F::space));
+        assert( (m[1] & F::print));
+        assert(!(m[1] & F::cntrl));
+        assert( (m[1] & F::upper));
+        assert(!(m[1] & F::lower));
+        assert( (m[1] & F::alpha));
+        assert(!(m[1] & F::digit));
+        assert(!(m[1] & F::punct));
+        assert( (m[1] & F::xdigit));
+        assert(!(m[1] & F::blank));
+        assert( (m[1] & F::alnum));
+        assert( (m[1] & F::graph));
+
+        // L'\x07'
+        assert(!(m[2] & F::space));
+        assert(!(m[2] & F::print));
+        assert( (m[2] & F::cntrl));
+        assert(!(m[2] & F::upper));
+        assert(!(m[2] & F::lower));
+        assert(!(m[2] & F::alpha));
+        assert(!(m[2] & F::digit));
+        assert(!(m[2] & F::punct));
+        assert(!(m[2] & F::xdigit));
+        assert(!(m[2] & F::blank));
+        assert(!(m[2] & F::alnum));
+        assert(!(m[2] & F::graph));
+
+        // L'.'
+        assert(!(m[3] & F::space));
+        assert( (m[3] & F::print));
+        assert(!(m[3] & F::cntrl));
+        assert(!(m[3] & F::upper));
+        assert(!(m[3] & F::lower));
+        assert(!(m[3] & F::alpha));
+        assert(!(m[3] & F::digit));
+        assert( (m[3] & F::punct));
+        assert(!(m[3] & F::xdigit));
+        assert(!(m[3] & F::blank));
+        assert(!(m[3] & F::alnum));
+        assert( (m[3] & F::graph));
+
+        // L'a'
+        assert(!(m[4] & F::space));
+        assert( (m[4] & F::print));
+        assert(!(m[4] & F::cntrl));
+        assert(!(m[4] & F::upper));
+        assert( (m[4] & F::lower));
+        assert( (m[4] & F::alpha));
+        assert(!(m[4] & F::digit));
+        assert(!(m[4] & F::punct));
+        assert( (m[4] & F::xdigit));
+        assert(!(m[4] & F::blank));
+        assert( (m[4] & F::alnum));
+        assert( (m[4] & F::graph));
+
+        // L'1'
+        assert(!(m[5] & F::space));
+        assert( (m[5] & F::print));
+        assert(!(m[5] & F::cntrl));
+        assert(!(m[5] & F::upper));
+        assert(!(m[5] & F::lower));
+        assert(!(m[5] & F::alpha));
+        assert( (m[5] & F::digit));
+        assert(!(m[5] & F::punct));
+        assert( (m[5] & F::xdigit));
+        assert(!(m[5] & F::blank));
+        assert( (m[5] & F::alnum));
+        assert( (m[5] & F::graph));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp
new file mode 100644
index 0000000..ad8fb21
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// char narrow(charT c, char dfault) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.narrow(L' ', '*') == ' ');
+        assert(f.narrow(L'A', '*') == 'A');
+        assert(f.narrow(L'\x07', '*') == '\x07');
+        assert(f.narrow(L'.', '*') == '.');
+        assert(f.narrow(L'a', '*') == 'a');
+        assert(f.narrow(L'1', '*') == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp
new file mode 100644
index 0000000..fcc6cfc
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/narrow_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::wstring in(L" A\x07.a1");
+        std::vector<char> v(in.size());
+
+        assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
+        assert(v[0] == ' ');
+        assert(v[1] == 'A');
+        assert(v[2] == '\x07');
+        assert(v[3] == '.');
+        assert(v[4] == 'a');
+        assert(v[5] == '1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
new file mode 100644
index 0000000..535c830
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_is.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* scan_is(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        const std::wstring in(L" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
+        assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
+        assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
+        assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
new file mode 100644
index 0000000..da21642
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/scan_not.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* scan_not(mask m, const charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+#include <stdio.h>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        const std::wstring in(L" A\x07.a1");
+        std::vector<F::mask> m(in.size());
+        assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
+        assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
+        assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
+        assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp
new file mode 100644
index 0000000..6e75ba4
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT tolower(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.tolower(L' ') == L' ');
+        assert(f.tolower(L'A') == L'a');
+        assert(f.tolower(L'\x07') == L'\x07');
+        assert(f.tolower(L'.') == L'.');
+        assert(f.tolower(L'a') == L'a');
+        assert(f.tolower(L'1') == L'1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp
new file mode 100644
index 0000000..68daf8d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/tolower_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* tolower(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::wstring in(L" A\x07.a1");
+
+        assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == L' ');
+        assert(in[1] == L'a');
+        assert(in[2] == L'\x07');
+        assert(in[3] == L'.');
+        assert(in[4] == L'a');
+        assert(in[5] == L'1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp
new file mode 100644
index 0000000..2a5acd1
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT toupper(charT) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.toupper(L' ') == L' ');
+        assert(f.toupper(L'A') == L'A');
+        assert(f.toupper(L'\x07') == L'\x07');
+        assert(f.toupper(L'.') == L'.');
+        assert(f.toupper(L'a') == L'A');
+        assert(f.toupper(L'1') == L'1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp
new file mode 100644
index 0000000..f0a7ee3
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/toupper_many.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const charT* toupper(charT* low, const charT* high) const;
+
+#include <locale>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::wstring in(L" A\x07.a1");
+
+        assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
+        assert(in[0] == L' ');
+        assert(in[1] == L'A');
+        assert(in[2] == L'\x07');
+        assert(in[3] == L'.');
+        assert(in[4] == L'A');
+        assert(in[5] == L'1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp
new file mode 100644
index 0000000..2a8733c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_1.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// charT widen(char c) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+
+        assert(f.widen(' ') == L' ');
+        assert(f.widen('A') == L'A');
+        assert(f.widen('\x07') == L'\x07');
+        assert(f.widen('.') == L'.');
+        assert(f.widen('a') == L'a');
+        assert(f.widen('1') == L'1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp
new file mode 100644
index 0000000..1c65601
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.members/widen_many.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class ctype;
+
+// const char* widen(const char* low, const char* high, charT* to) const;
+
+#include <locale>
+#include <string>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef std::ctype<wchar_t> F;
+        const F& f = std::use_facet<F>(l);
+        std::string in(" A\x07.a1");
+        std::vector<wchar_t> v(in.size());
+
+        assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
+        assert(v[0] == L' ');
+        assert(v[1] == L'A');
+        assert(v[2] == L'\x07');
+        assert(v[3] == L'.');
+        assert(v[4] == L'a');
+        assert(v[5] == L'1');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/locale.ctype.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp b/final/test/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp
new file mode 100644
index 0000000..7ad36af
--- /dev/null
+++ b/final/test/localization/locale.categories/category.ctype/locale.ctype/types.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT>
+// class ctype
+//     : public locale::facet,
+//       public ctype_base
+// {
+// public:
+//     typedef CharT char_type;
+// };
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::ctype<wchar_t> >(l));
+        const std::ctype<wchar_t>& f = std::use_facet<std::ctype<wchar_t> >(l);
+        {
+            (void)std::ctype<wchar_t>::id;
+        }
+        static_assert((std::is_same<std::ctype<wchar_t>::char_type, wchar_t>::value), "");
+        static_assert((std::is_base_of<std::ctype_base, std::ctype<wchar_t> >::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::ctype<wchar_t> >::value), "");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.messages/locale.messages.byname/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp b/final/test/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp
new file mode 100644
index 0000000..e82878a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.messages/locale.messages/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages<charT>
+
+// explicit messages(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::messages<char> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp b/final/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp
new file mode 100644
index 0000000..6bed538
--- /dev/null
+++ b/final/test/localization/locale.categories/category.messages/locale.messages/locale.messages.members/not_testable.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages<charT>
+
+// catalog open(const basic_string<char>& name, const locale&) const;
+
+#include <locale>
+#include <cassert>
+
+// As far as I can tell, the messages facet is untestable.  I have a best
+// effort implementation in the hopes that in the future I will learn how
+// to test it.
+
+template <class CharT>
+class F
+    : public std::messages<CharT>
+{
+public:
+    explicit F(std::size_t refs = 0)
+        : std::messages<CharT>(refs) {}
+};
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.messages/locale.messages/locale.messages.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp b/final/test/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp
new file mode 100644
index 0000000..cf9b4c8
--- /dev/null
+++ b/final/test/localization/locale.categories/category.messages/locale.messages/messages_base.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class messages_base
+// {
+// public:
+//     typedef unspecified catalog;
+// };
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    std::messages_base mb;
+}
diff --git a/final/test/localization/locale.categories/category.messages/locale.messages/types.pass.cpp b/final/test/localization/locale.categories/category.messages/locale.messages/types.pass.cpp
new file mode 100644
index 0000000..60e47b5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.messages/locale.messages/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class _CharT>
+// class messages
+//     : public locale::facet,
+//       public messages_base
+// {
+// public:
+//     typedef _CharT               char_type;
+//     typedef basic_string<_CharT> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::messages<char> >::value), "");
+    static_assert((std::is_base_of<std::messages_base, std::messages<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::messages<wchar_t> >::value), "");
+    static_assert((std::is_base_of<std::messages_base, std::messages<wchar_t> >::value), "");
+    static_assert((std::is_same<std::messages<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::messages<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::messages<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::messages<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/final/test/localization/locale.categories/category.messages/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/category.messages/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.messages/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp
new file mode 100644
index 0000000..9052826
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// explicit money_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::money_get<char, const char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
new file mode 100644
index 0000000..edd9015
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_en_US.pass.cpp
@@ -0,0 +1,721 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_en_US_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
new file mode 100644
index 0000000..489068c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -0,0 +1,724 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_fr_FR_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0,00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0,01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1 234 567,89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567,89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 \u20ac";  // €
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 \u20ac";  // €
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 \u20ac";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 \u20ac";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 EUR -";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 EUR -";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        noshowbase(ios);
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0,00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0,01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1 234 567,89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567,89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 EUR";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 EUR";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 EUR";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 EUR";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 EUR";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 EUR";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 EUR";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 Eu-";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "1 234 567,89 Eu-";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0,01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1 234 567,89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567,89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 \u20ac";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 \u20ac";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 \u20ac";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 EUR -";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 EUR -";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0,01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1 234 567,89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567,89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 EUR";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 EUR";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 EUR";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 EUR";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 EUR";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 EUR";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 EUR";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 Eu-";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"1 234 567,89 Eu-";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
new file mode 100644
index 0000000..737299a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_ru_RU.pass.cpp
@@ -0,0 +1,727 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_ru_RU_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0,00 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0,01 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 RUB ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 RUB ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0,00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0,01 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1 234 567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567,89 ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 RUB ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "0,00 RUB ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 RUB ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "-0,01 RUB ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 RUB ";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "1 234 567,89 RUB ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 RUB ";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0,01 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 RUB ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 RUB ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0,00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0,01 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1 234 567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567,89 ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 RUB ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 5);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"0,00 RUB ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 RUB ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 6);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-0,01 RUB ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 RUB ";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 13);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"1 234 567,89 RUB ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 RUB ";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-1 234 567,89 \x440\x443\x431"".";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 14);
+            assert(err == std::ios_base::goodbit);
+            assert(ex == -123456789);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
new file mode 100644
index 0000000..cc5d825
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp
@@ -0,0 +1,721 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_zh_CN_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "\xEF\xBF\xA5""0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "\xEF\xBF\xA5""0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "\xEF\xBF\xA5""-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "\xEF\xBF\xA5""-0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "\xEF\xBF\xA5""1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "\xEF\xBF\xA5""1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "CNY -1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::string v = "CNY 0.00";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::string v = "CNY 0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "CNY -0.01";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::string v = "CNY -0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "CNY 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::string v = "CNY 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "\xEF\xBF\xA5""-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"\xFFE5""0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"\xFFE5""0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"\xFFE5""-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"\xFFE5""-0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"\xFFE5""1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"\xFFE5""1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"\xFFE5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"CNY -1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+        }
+        {   // zero, showbase
+            std::wstring v = L"CNY 0.00";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+        }
+        {   // zero, showbase
+            std::wstring v = L"CNY 0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 0);
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"CNY -0.01";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"CNY -0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -1);
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"CNY 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+        }
+        {   // positive, showbase
+            std::wstring v = L"CNY 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == 123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"CNY -1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == -123456789);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"\xFFE5""-1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"\xFFE5""-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            long double ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 0);
+            assert(err == std::ios_base::failbit);
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
new file mode 100644
index 0000000..29c5266
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_string_en_US.pass.cpp
@@ -0,0 +1,729 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_get<charT, InputIterator>
+
+// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
+//               ios_base::iostate& err, string_type& v) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_get<char, input_iterator<const char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_get<wchar_t, input_iterator<const wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_en_US_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+    {
+        const my_facet f(1);
+        // char, national
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // zero, showbase
+            std::string v = "$0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // negative one, showbase
+            std::string v = "-$0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // positive, showbase
+            std::string v = "$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+        }
+    }
+    {
+        const my_facet f(1);
+        // char, international
+        {   // zero
+            std::string v = "0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // negative one
+            std::string v = "-0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // positive
+            std::string v = "1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // negative
+            std::string v = "-1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // negative
+            std::string v = "-1234567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+        }
+        {   // zero, showbase
+            std::string v = "USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+        }
+        {   // negative one, showbase
+            std::string v = "-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+        }
+        {   // positive, showbase
+            std::string v = "USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == "-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::string v = "-$1,234,567.89";
+            typedef input_iterator<const char*> I;
+            std::string ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == "");
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, national
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // zero, showbase
+            std::wstring v = L"$0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-$0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // positive, showbase
+            std::wstring v = L"$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                false, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+        }
+    }
+    {
+        const my_facetw f(1);
+        // wchar_t, international
+        {   // zero
+            std::wstring v = L"0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // negative one
+            std::wstring v = L"-0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // positive
+            std::wstring v = L"1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // negative
+            std::wstring v = L"-1234567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+        }
+        {   // zero, showbase
+            std::wstring v = L"USD 0.00";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"0");
+            noshowbase(ios);
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+        }
+        {   // negative one, showbase
+            std::wstring v = L"-USD 0.01";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-1");
+            noshowbase(ios);
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+        }
+        {   // positive, showbase
+            std::wstring v = L"USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-USD 1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + v.size());
+            assert(err == std::ios_base::eofbit);
+            assert(ex == L"-123456789");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            showbase(ios);
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+            noshowbase(ios);
+        }
+        {   // negative, showbase
+            std::wstring v = L"-$1,234,567.89";
+            typedef input_iterator<const wchar_t*> I;
+            std::wstring ex;
+            std::ios_base::iostate err = std::ios_base::goodbit;
+            I iter = f.get(I(v.data()), I(v.data() + v.size()),
+                                                true, ios, err, ex);
+            assert(iter.base() == v.data() + 1);
+            assert(err == std::ios_base::failbit);
+            assert(ex == L"");
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp
new file mode 100644
index 0000000..2e4fb32
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.get/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class InputIterator = istreambuf_iterator<CharT> >
+// class money_get
+//     : public locale::facet
+// {
+// public:
+//     typedef CharT                   char_type;
+//     typedef InputIterator           iter_type;
+//     typedef basic_string<char_type> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::money_get<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::money_get<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_get<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::money_get<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::money_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::money_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_get<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::money_get<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp
new file mode 100644
index 0000000..d0a0007
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// explicit money_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::money_put<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp
new file mode 100644
index 0000000..8614807
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_en_US.pass.cpp
@@ -0,0 +1,492 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_en_US_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+{
+
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
new file mode 100644
index 0000000..73b8f01
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
@@ -0,0 +1,493 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_fr_FR_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 \u20ac");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 \u20ac");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 \u20ac");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \u20ac");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \u20ac   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89    \u20ac");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   -1 234 567,89 \u20ac");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 EUR");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 EUR");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 EUR");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 EUR");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 EUR   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89    EUR");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   -1 234 567,89 EUR");
+        assert(ios.width() == 0);
+    }
+}
+{
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 \u20ac");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 \u20ac");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 \u20ac");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 \u20ac");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 \u20ac     ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89      \u20ac");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"     -1 234 567,89 \u20ac");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 EUR");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 EUR");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 EUR");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 EUR");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 EUR   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89    EUR");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"   -1 234 567,89 EUR");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
new file mode 100644
index 0000000..705ed54
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_ru_RU.pass.cpp
@@ -0,0 +1,493 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_ru_RU_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 \xD1\x80\xD1\x83\xD0\xB1"".");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0,00 RUB ");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0,01 RUB ");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1 234 567,89 RUB ");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 RUB ");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89 RUB   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1 234 567,89   RUB ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "  -1 234 567,89 RUB ");
+        assert(ios.width() == 0);
+    }
+}
+{
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 \x440\x443\x431"".");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 \x440\x443\x431"".");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 \x440\x443\x431"".");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 \x440\x443\x431"".");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 \x440\x443\x431"".  ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89   \x440\x443\x431"".");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"  -1 234 567,89 \x440\x443\x431"".");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 ");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 ");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 ");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 ");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0,00 RUB ");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0,01 RUB ");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1 234 567,89 RUB ");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 RUB ");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89 RUB   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1 234 567,89   RUB ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"  -1 234 567,89 RUB ");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
new file mode 100644
index 0000000..8dc68c1
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp
@@ -0,0 +1,491 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               long double units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_zh_CN_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-1,234,567.89    ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "\xEF\xBF\xA5""-    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "    \xEF\xBF\xA5""-1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "CNY -   1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   CNY -1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+{
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"\xFFE5""-      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"      \xFFE5""-1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        long double v = 0;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        long double v = -1;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        long double v = 123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        long double v = -123456789;
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        long double v = 0;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY 0.00");
+    }
+    {   // negative one, showbase
+        long double v = -1;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -0.01");
+    }
+    {   // positive, showbase
+        long double v = 123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY 1,234,567.89");
+    }
+    {   // negative, showbase
+        long double v = -123456789;
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -1,234,567.89");
+    }
+    {   // negative, showbase, left
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"CNY -   1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        long double v = -123456789;
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"   CNY -1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp
new file mode 100644
index 0000000..13c6ef7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_string_en_US.pass.cpp
@@ -0,0 +1,492 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
+//               const string_type& units) const;
+
+#include <locale>
+#include <ios>
+#include <streambuf>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::money_put<char, output_iterator<char*> > Fn;
+
+class my_facet
+    : public Fn
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : Fn(refs) {}
+};
+
+typedef std::money_put<wchar_t, output_iterator<wchar_t*> > Fw;
+
+class my_facetw
+    : public Fw
+{
+public:
+    explicit my_facetw(std::size_t refs = 0)
+        : Fw(refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::string loc_name(LOCALE_en_US_UTF_8);
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<char, true>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, false>(loc_name)));
+    ios.imbue(std::locale(ios.getloc(),
+                          new std::moneypunct_byname<wchar_t, true>(loc_name)));
+{
+    const my_facet f(1);
+    // char, national
+    {   // zero
+        std::string v = "0";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        std::string v = "-1";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        std::string v = "123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        std::string v = "-123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::string v = "0";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$0.00");
+    }
+    {   // negative one, showbase
+        std::string v = "-1";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$0.01");
+    }
+    {   // positive, showbase
+        std::string v = "123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "$1,234,567.89");
+    }
+    {   // negative, showbase
+        std::string v = "-123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            false, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // char, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        std::string v = "0";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0.00");
+    }
+    {   // negative one
+        std::string v = "-1";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-0.01");
+    }
+    {   // positive
+        std::string v = "123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1,234,567.89");
+    }
+    {   // negative
+        std::string v = "-123456789";
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::string v = "0";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 0.00");
+    }
+    {   // negative one, showbase
+        std::string v = "-1";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 0.01");
+    }
+    {   // positive, showbase
+        std::string v = "123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        std::string v = "-123456789";
+        showbase(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::string v = "-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        char str[100];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str),
+                                            true, ios, ' ', v);
+        std::string ex(str, iter.base());
+        assert(ex == "   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+{
+
+    const my_facetw f(1);
+    // wchar_t, national
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        std::wstring v = L"0";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        std::wstring v = L"-1";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        std::wstring v = L"123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        std::wstring v = L"-123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::wstring v = L"0";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$0.00");
+    }
+    {   // negative one, showbase
+        std::wstring v = L"-1";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$0.01");
+    }
+    {   // positive, showbase
+        std::wstring v = L"123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"$1,234,567.89");
+    }
+    {   // negative, showbase
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$1,234,567.89      ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-$      1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            false, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"      -$1,234,567.89");
+        assert(ios.width() == 0);
+    }
+
+    // wchar_t, international
+    noshowbase(ios);
+    ios.unsetf(std::ios_base::adjustfield);
+    {   // zero
+        std::wstring v = L"0";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"0.00");
+    }
+    {   // negative one
+        std::wstring v = L"-1";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-0.01");
+    }
+    {   // positive
+        std::wstring v = L"123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"1,234,567.89");
+    }
+    {   // negative
+        std::wstring v = L"-123456789";
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-1,234,567.89");
+    }
+    {   // zero, showbase
+        std::wstring v = L"0";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 0.00");
+    }
+    {   // negative one, showbase
+        std::wstring v = L"-1";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 0.01");
+    }
+    {   // positive, showbase
+        std::wstring v = L"123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"USD 1,234,567.89");
+    }
+    {   // negative, showbase
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, '*', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89");
+    }
+    {   // negative, showbase, left
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        left(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD 1,234,567.89   ");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, internal
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        internal(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"-USD    1,234,567.89");
+        assert(ios.width() == 0);
+    }
+    {   // negative, showbase, right
+        std::wstring v = L"-123456789";
+        showbase(ios);
+        ios.width(20);
+        right(ios);
+        wchar_t str[100];
+        output_iterator<wchar_t*> iter = f.put(output_iterator<wchar_t*>(str),
+                                            true, ios, ' ', v);
+        std::wstring ex(str, iter.base());
+        assert(ex == L"   -USD 1,234,567.89");
+        assert(ios.width() == 0);
+    }
+}
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp
new file mode 100644
index 0000000..44ff107
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.money.put/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
+// class money_put
+//     : public locale::facet
+// {
+// public:
+//     typedef CharT                   char_type;
+//     typedef OutputIterator          iter_type;
+//     typedef basic_string<char_type> string_type;
+
+#include <locale>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::money_put<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::money_put<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_put<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::money_put<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::money_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::money_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+    static_assert((std::is_same<std::money_put<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::money_put<wchar_t>::string_type, std::wstring>::value), "");
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
new file mode 100644
index 0000000..a197a18
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type curr_symbol() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.curr_symbol() == "$");
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.curr_symbol() == "USD ");
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.curr_symbol() == L"$");
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.curr_symbol() == L"USD ");
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.curr_symbol() == " \u20ac");
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.curr_symbol() == " EUR");
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.curr_symbol() == L" \u20ac");
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.curr_symbol() == L" EUR");
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.curr_symbol() == " RUB");
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.curr_symbol() == L" \x440\x443\x431");
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.curr_symbol() == L" RUB");
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.curr_symbol() == "\xEF\xBF\xA5");
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.curr_symbol() == "CNY ");
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.curr_symbol() == L"\xFFE5");
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.curr_symbol() == L"CNY ");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
new file mode 100644
index 0000000..b0fa38f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// charT decimal_point() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.decimal_point() == L'.');
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.decimal_point() == L'.');
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.decimal_point() == L',');
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.decimal_point() == L',');
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.decimal_point() == ',');
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.decimal_point() == L',');
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.decimal_point() == L',');
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.decimal_point() == '.');
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.decimal_point() == L'.');
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.decimal_point() == L'.');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp
new file mode 100644
index 0000000..6bfb097
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/frac_digits.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// int frac_digits() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.frac_digits() == 0);
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.frac_digits() == 2);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp
new file mode 100644
index 0000000..5c0bd3d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/grouping.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string grouping() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    // Monetary grouping strings may be terminated with 0 or CHAR_MAX, defining
+    // how the grouping is repeated.
+    std::string s = std::string(1, CHAR_MAX);
+    {
+        Fnf f("C", 1);
+        assert(f.grouping() == s || f.grouping() == "");
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.grouping() == s || f.grouping() == "");
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.grouping() == s || f.grouping() == "");
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.grouping() == s || f.grouping() == "");
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.grouping() == "\3\3");
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.grouping() == "\3");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp
new file mode 100644
index 0000000..e670354
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/neg_format.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// pattern neg_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("C", 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp
new file mode 100644
index 0000000..97fcdaa
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/negative_sign.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type negative_sign() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.negative_sign() == std::string());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.negative_sign() == std::string());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.negative_sign() == std::wstring());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.negative_sign() == std::wstring());
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.negative_sign() == L"-");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp
new file mode 100644
index 0000000..3027737
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/pos_format.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// pattern pos_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f("C", 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::value);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::symbol);
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::sign);
+        assert(p.field[1] == std::money_base::symbol);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp
new file mode 100644
index 0000000..3196d48
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/positive_sign.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// string_type positive_sign() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.positive_sign() == std::wstring());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.positive_sign() == std::wstring());
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.positive_sign() == "");
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.positive_sign() == L"");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
new file mode 100644
index 0000000..b681874
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct_byname<charT, International>
+
+// charT thousands_sep() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+class Fnf
+    : public std::moneypunct_byname<char, false>
+{
+public:
+    explicit Fnf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, false>(nm, refs) {}
+};
+
+class Fnt
+    : public std::moneypunct_byname<char, true>
+{
+public:
+    explicit Fnt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<char, true>(nm, refs) {}
+};
+
+class Fwf
+    : public std::moneypunct_byname<wchar_t, false>
+{
+public:
+    explicit Fwf(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, false>(nm, refs) {}
+};
+
+class Fwt
+    : public std::moneypunct_byname<wchar_t, true>
+{
+public:
+    explicit Fwt(const std::string& nm, std::size_t refs = 0)
+        : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f("C", 1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+
+    {
+        Fnf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fnt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fwf f(LOCALE_en_US_UTF_8, 1);
+        assert(f.thousands_sep() == L',');
+    }
+    {
+        Fwt f(LOCALE_en_US_UTF_8, 1);
+        assert(f.thousands_sep() == L',');
+    }
+
+    {
+        Fnf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fnt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fwf f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.thousands_sep() == L' ');
+    }
+    {
+        Fwt f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.thousands_sep() == L' ');
+    }
+
+    {
+        Fnf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fnt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.thousands_sep() == ' ');
+    }
+    {
+        Fwf f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.thousands_sep() == L' ');
+    }
+    {
+        Fwt f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.thousands_sep() == L' ');
+    }
+
+    {
+        Fnf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fnt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.thousands_sep() == ',');
+    }
+    {
+        Fwf f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.thousands_sep() == L',');
+    }
+    {
+        Fwt f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.thousands_sep() == L',');
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp
new file mode 100644
index 0000000..798dbd0
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// explicit moneypunct(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp
new file mode 100644
index 0000000..8dc4726
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/curr_symbol.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type curr_symbol() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fnt f(1);
+        assert(f.curr_symbol() == std::string());
+    }
+    {
+        Fwf f(1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+    {
+        Fwt f(1);
+        assert(f.curr_symbol() == std::wstring());
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp
new file mode 100644
index 0000000..66262dc
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/decimal_point.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// charT decimal_point() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f(1);
+        assert(f.decimal_point() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f(1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f(1);
+        assert(f.decimal_point() == std::numeric_limits<wchar_t>::max());
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp
new file mode 100644
index 0000000..0622342
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/frac_digits.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// int frac_digits() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fnt f(1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwf f(1);
+        assert(f.frac_digits() == 0);
+    }
+    {
+        Fwt f(1);
+        assert(f.frac_digits() == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp
new file mode 100644
index 0000000..fc857d6
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/grouping.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string grouping() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.grouping() == std::string());
+    }
+    {
+        Fnt f(1);
+        assert(f.grouping() == std::string());
+    }
+    {
+        Fwf f(1);
+        assert(f.grouping() == std::string());
+    }
+    {
+        Fwt f(1);
+        assert(f.grouping() == std::string());
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp
new file mode 100644
index 0000000..d1df09c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/neg_format.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// pattern neg_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(1);
+        std::money_base::pattern p = f.neg_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp
new file mode 100644
index 0000000..df350d3
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/negative_sign.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type negative_sign() const;
+
+// The C++ and C standards are silent.
+//   On this one, commen sense is the guideline.
+//   If customers complain, I'll endeavor to minimize customer complaints
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fnt f(1);
+        assert(f.negative_sign() == "-");
+    }
+    {
+        Fwf f(1);
+        assert(f.negative_sign() == L"-");
+    }
+    {
+        Fwt f(1);
+        assert(f.negative_sign() == L"-");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp
new file mode 100644
index 0000000..6e28154
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/pos_format.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// pattern pos_format() const;
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fnt f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwf f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+    {
+        Fwt f(1);
+        std::money_base::pattern p = f.pos_format();
+        assert(p.field[0] == std::money_base::symbol);
+        assert(p.field[1] == std::money_base::sign);
+        assert(p.field[2] == std::money_base::none);
+        assert(p.field[3] == std::money_base::value);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp
new file mode 100644
index 0000000..5ec8d9a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/positive_sign.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// string_type positive_sign() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fnt f(1);
+        assert(f.positive_sign() == std::string());
+    }
+    {
+        Fwf f(1);
+        assert(f.positive_sign() == std::wstring());
+    }
+    {
+        Fwt f(1);
+        assert(f.positive_sign() == std::wstring());
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp
new file mode 100644
index 0000000..27db562
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.members/thousands_sep.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class moneypunct<charT, International>
+
+// charT thousands_sep() const;
+
+// The C++ and C standards are silent.
+//   POSIX standard is being followed (as a guideline).
+
+#include <locale>
+#include <limits>
+#include <cassert>
+
+typedef std::moneypunct<char> F;
+
+class Fnf
+    : public std::moneypunct<char, false>
+{
+public:
+    explicit Fnf(std::size_t refs = 0)
+        : std::moneypunct<char, false>(refs) {}
+};
+
+class Fnt
+    : public std::moneypunct<char, true>
+{
+public:
+    explicit Fnt(std::size_t refs = 0)
+        : std::moneypunct<char, true>(refs) {}
+};
+
+class Fwf
+    : public std::moneypunct<wchar_t, false>
+{
+public:
+    explicit Fwf(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, false>(refs) {}
+};
+
+class Fwt
+    : public std::moneypunct<wchar_t, true>
+{
+public:
+    explicit Fwt(std::size_t refs = 0)
+        : std::moneypunct<wchar_t, true>(refs) {}
+};
+
+int main()
+{
+    {
+        Fnf f(1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fnt f(1);
+        assert(f.thousands_sep() == std::numeric_limits<char>::max());
+    }
+    {
+        Fwf f(1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+    {
+        Fwt f(1);
+        assert(f.thousands_sep() == std::numeric_limits<wchar_t>::max());
+    }
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/locale.moneypunct.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp
new file mode 100644
index 0000000..beabe0c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class money_base
+// {
+// public:
+//     enum part {none, space, symbol, sign, value};
+//     struct pattern {char field[4];};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::money_base mb;
+    assert(mb.none == 0);
+    assert(mb.space == 1);
+    assert(mb.symbol == 2);
+    assert(mb.sign == 3);
+    assert(mb.value == 4);
+    assert(sizeof(std::money_base::pattern) == 4);
+    std::money_base::pattern p;
+    p.field[0] = std::money_base::none;
+}
diff --git a/final/test/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp
new file mode 100644
index 0000000..a76cea5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// template <class _CharT, bool _International = false>
+// class moneypunct
+//     : public locale::facet,
+//       public money_base
+// {
+// public:
+//     typedef _CharT                  char_type;
+//     typedef basic_string<char_type> string_type;
+//     static const bool intl = International;
+
+#include <locale>
+#include <type_traits>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::moneypunct<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::moneypunct<wchar_t> >::value), "");
+    static_assert((std::is_base_of<std::money_base, std::moneypunct<char> >::value), "");
+    static_assert((std::is_base_of<std::money_base, std::moneypunct<wchar_t> >::value), "");
+    static_assert((std::is_same<std::moneypunct<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::moneypunct<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::moneypunct<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::moneypunct<wchar_t>::string_type, std::wstring>::value), "");
+
+    test(std::moneypunct<char, false>::intl);
+    test(std::moneypunct<char, true>::intl);
+    test(std::moneypunct<wchar_t, false>::intl);
+    test(std::moneypunct<wchar_t, true>::intl);
+}
diff --git a/final/test/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.monetary/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp
new file mode 100644
index 0000000..f801e6c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// explicit num_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::num_put<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp
new file mode 100644
index 0000000..4f6f0b4
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_bool.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, bool v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual string_type do_truename() const {return "yes";}
+    virtual string_type do_falsename() const {return "no";}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        {
+            bool v = false;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "0");
+        }
+        {
+            bool v = true;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "1");
+        }
+    }
+    {
+        std::ios ios(0);
+        boolalpha(ios);
+        {
+            bool v = false;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "false");
+        }
+        {
+            bool v = true;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "true");
+        }
+    }
+    {
+        std::ios ios(0);
+        boolalpha(ios);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        {
+            bool v = false;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "no");
+        }
+        {
+            bool v = true;
+            char str[50];
+            output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+            std::string ex(str, iter.base());
+            assert(ex == "yes");
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
new file mode 100644
index 0000000..a54b373
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp
@@ -0,0 +1,17887 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_decimal_point() const {return ';';}
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+void test1()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = +0.;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test2()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test3()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = +0.;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test4()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test5()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = -0.;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test6()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test7()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = -0.;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test8()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        double v = 1234567890.125;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1.26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x1;26580b488p+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x********1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1.26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1.26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x1;26580b488p+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0x1;26580b488p+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1.26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X1;26580B488P+30********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X********1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1.26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1.26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X1;26580B488P+30*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0X1;26580B488P+30");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp
new file mode 100644
index 0000000..4085f08
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long.pass.cpp
@@ -0,0 +1,371 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        long v = 0;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        long v = 1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        long v = -1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1");
+    }
+    {
+        std::ios ios(0);
+        long v = -1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1000");
+    }
+    {
+        std::ios ios(0);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***+1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+***1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***-1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-***1_00_0");
+        assert(ios.width() == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
new file mode 100644
index 0000000..2010dca
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp
@@ -0,0 +1,26245 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_decimal_point() const {return ';';}
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+void test1()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = +0.;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test2()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;00000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0.000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******-0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******0;000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;00000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test3()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457e+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457e+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;23457E+09**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1.23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;23457E+09*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1;23457E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1234567890.125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******1_234_567_89_0;125");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;12500000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test4()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -INFINITY;
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-inf*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-inf");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************inf");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-INF*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-INF");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************INF");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test5()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = std::nan("");
+        std::ios ios(0);
+        // %g
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "nan**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************nan");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "NAN**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************NAN");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {}
+            ios.precision(6);
+            {}
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test6()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = +0.;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0************************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************+0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************+0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************+0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;0000000000000000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******+0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test7()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0***********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********************-0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-***********************0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;**********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********************-0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-**********************0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0.0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0.0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0*********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********************-0;0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*********************0;0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0.000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****************-0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-****************0;000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0.0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0000000000000000******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******-0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******0;0000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000000000000000000000000000000000000000000000000000000000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test8()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        fixed(ios);
+        // %f
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890***************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0***********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890**************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**************+1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**************1234567890");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0**********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "**********+1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+**********1_234_567_89_0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************+1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*************1234567890.");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********+1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*********1_234_567_89_0;");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.1*************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;1*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.1************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************+1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+************1234567890.1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;1********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********1_234_567_89_0;1");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1234567890.125000********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1_234_567_89_0;125000****");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "****1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1234567890.125000*******");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******+1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******1234567890.125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1_234_567_89_0;125000***");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "***+1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+***1_234_567_89_0;125000");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {}
+            ios.precision(60);
+            {}
+        }
+    }
+}
+
+void test9()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0e+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;e+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0E+00*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************-0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*******************0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0.E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;E+00******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0;E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0e+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0.0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;0E+00*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0;0E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000e+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000e+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0.000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0.000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0;000000E+00************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "************-0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-************0;000000E+00");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test10()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        scientific(ios);
+        // %e
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1e+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1e+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1E+09********************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1E+09*******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*******************+1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*******************1E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1.E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************+1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+******************1;E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2e+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2e+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;2E+09******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1.2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;2E+09*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************+1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+*****************1;2E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000e+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1.234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+1;234567890125000000000000000000000000000000000000000000000000E+09");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+void test11()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -0.;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0p+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0x0p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0.p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0.p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0x0;p+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0x0;p+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0P+0******************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "******************-0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-******************0X0P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0.P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0.P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-0X0;P+0*****************");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*****************-0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "-*****************0X0;P+0");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+            }
+        }
+    }
+}
+
+void test12()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+#ifdef __APPLE__
+// This test is failing on FreeBSD, possibly due to different representations
+// of the floating point numbers.  
+    const my_facet f(1);
+    {
+        long double v = 1234567890.125;
+        std::ios ios(0);
+        hexfloat(ios);
+        // %a
+        {
+            ios.precision(0);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                                ios.width(0);
+                            ios.imbue(lc);
+                            {
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(1);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            ios.precision(6);
+            {
+            }
+            ios.precision(16);
+            {
+            }
+            ios.precision(60);
+            {
+                nouppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9.32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x9;32c05a44p+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0x*********9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9.32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9.32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0x9;32c05a44p+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0x9;32c05a44p+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+                uppercase(ios);
+                {
+                    noshowpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9.32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X9;32C05A44P+27*********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "*********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "0X*********9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                    showpos(ios);
+                    {
+                        noshowpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                        showpoint(ios);
+                        {
+                            ios.imbue(lc);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9.32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9.32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                            ios.imbue(lg);
+                            {
+                                ios.width(0);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                left(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+0X9;32C05A44P+27********");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                right(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "********+0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                                ios.width(25);
+                                internal(ios);
+                                {
+                                    iter = f.put(output_iterator<char*>(str), ios, '*', v);
+                                    std::string ex(str, iter.base());
+                                    assert(ex == "+********0X9;32C05A44P+27");
+                                    assert(ios.width() == 0);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+#endif
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+    test9();
+    test10();
+    test11();
+    test12();
+    char str[200];
+    output_iterator<char*> iter;
+    std::locale lc = std::locale::classic();
+    std::locale lg(lc, new my_numpunct);
+    const my_facet f(1);
+    {
+        long double v = -INFINITY;
+    }
+    {
+        long double v = std::nan("");
+    }
+
+    {
+        long double v = +0.;
+    }
+    {
+        long double v = -INFINITY;
+    }
+    {
+        long double v = std::nan("");
+    }
+    {
+        long double v = -INFINITY;
+    }
+    {
+        long double v = std::nan("");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp
new file mode 100644
index 0000000..55f7d0f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_long.pass.cpp
@@ -0,0 +1,344 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, long long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        long long v = 0;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        long long v = 1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        long long v = -1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1");
+    }
+    {
+        std::ios ios(0);
+        long long v = -1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1000");
+    }
+    {
+        std::ios ios(0);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***+1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        long long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "+***1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "***-1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-1_00_0***");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        long long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "-***1_00_0");
+        assert(ios.width() == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
new file mode 100644
index 0000000..8edcfc4
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_pointer.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, void* v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        void* v = 0;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x0" || ex == "(nil)");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp
new file mode 100644
index 0000000..f7a577f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long.pass.cpp
@@ -0,0 +1,374 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        unsigned long v = 0;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = 1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = -1;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4294967295" : "18446744073709551615"));
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = -1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4294966296" : "18446744073709550616"));
+    }
+    {
+        std::ios ios(0);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long v = 1000;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long v = 0123467;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long v = 2147483647;
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1_00_0****");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+                                                 : "18_446_744_073_709_550_61_6"));
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+                                                 : "18_446_744_073_709_550_61_6"));
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        std::ios_base::iostate err = ios.goodbit;
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long) == 4 ? "4_294_966_29_6"
+                                                 : "18_446_744_073_709_550_61_6"));
+        assert(ios.width() == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..debbd5e
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_unsigned_long_long.pass.cpp
@@ -0,0 +1,344 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& iob, char_type fill, unsigned long long v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    {
+        std::ios ios(0);
+        unsigned long long v = 0;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0");
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = 1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1");
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = -1;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == (sizeof(unsigned long long) == 4 ? "4294967295" : "18446744073709551615"));
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = -1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18446744073709550616");
+    }
+    {
+        std::ios ios(0);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        showpos(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1000");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1750");
+    }
+    {
+        std::ios ios(0);
+        oct(ios);
+        showbase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "01750");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x3e8");
+    }
+    {
+        std::ios ios(0);
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        uppercase(ios);
+        unsigned long long v = 1000;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0X3E_8");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0_123_46_7*****");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        oct(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long long v = 0123467;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "*****0_123_46_7");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        right(ios);
+        ios.width(15);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "**0x7f_fff_ff_f");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        left(ios);
+        ios.width(15);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x7f_fff_ff_f**");
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        hex(ios);
+        showbase(ios);
+        internal(ios);
+        ios.width(15);
+        unsigned long long v = 2147483647;
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "0x**7f_fff_ff_f");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long long v = 1000;
+        right(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long long v = 1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "1_00_0****");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        showpos(ios);
+        unsigned long long v = 1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "****1_00_0");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long long v = -1000;
+        right(ios);
+        showpos(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18_446_744_073_709_550_61_6");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long long v = -1000;
+        left(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18_446_744_073_709_550_61_6");
+        assert(ios.width() == 0);
+    }
+    {
+        std::ios ios(0);
+        ios.imbue(std::locale(std::locale::classic(), new my_numpunct));
+        unsigned long long v = -1000;
+        internal(ios);
+        ios.width(10);
+        char str[50];
+        output_iterator<char*> iter = f.put(output_iterator<char*>(str), ios, '*', v);
+        std::string ex(str, iter.base());
+        assert(ex == "18_446_744_073_709_550_61_6");
+        assert(ios.width() == 0);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp
new file mode 100644
index 0000000..f6f1e5c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.nm.put/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
+// class num_put
+//     : public locale::facet
+// {
+// public:
+//     typedef charT          char_type;
+//     typedef OutputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::num_put<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::num_put<wchar_t> >::value), "");
+    static_assert((std::is_same<std::num_put<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::num_put<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::num_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::num_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp
new file mode 100644
index 0000000..71af9cd
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// explicit num_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::num_get<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp
new file mode 100644
index 0000000..f2cc2e7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_bool.pass.cpp
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, bool& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class p1
+    : public std::numpunct<char>
+{
+public:
+    p1() : std::numpunct<char>() {}
+
+protected:
+    virtual string_type do_truename() const {return "a";}
+    virtual string_type do_falsename() const {return "abb";}
+};
+
+class p2
+    : public std::numpunct<char>
+{
+public:
+    p2() : std::numpunct<char>() {}
+
+protected:
+    virtual string_type do_truename() const {return "a";}
+    virtual string_type do_falsename() const {return "ab";}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "12";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "*12";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+0);
+        assert(err == ios.failbit);
+        assert(b == false);
+    }
+    boolalpha(ios);
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+0);
+        assert(err == ios.failbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "true";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "false";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, b);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(b == false);
+    }
+    ios.imbue(std::locale(ios.getloc(), new p1));
+    {
+        const char str[] = "a";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+1),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.eofbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "abc";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+3),
+                  ios, err, b);
+        assert(iter.base() == str+2);
+        assert(err == ios.failbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "acc";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+3),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+    ios.imbue(std::locale(ios.getloc(), new p2));
+    {
+        const char str[] = "a";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+1),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.eofbit);
+        assert(b == true);
+    }
+    {
+        const char str[] = "ab";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+2),
+                  ios, err, b);
+        assert(iter.base() == str+2);
+        assert(err == ios.eofbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "abc";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+3),
+                  ios, err, b);
+        assert(iter.base() == str+2);
+        assert(err == ios.goodbit);
+        assert(b == false);
+    }
+    {
+        const char str[] = "ac";
+        std::ios_base::iostate err = ios.goodbit;
+        bool b;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+2),
+                  ios, err, b);
+        assert(iter.base() == str+1);
+        assert(err == ios.goodbit);
+        assert(b == true);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
new file mode 100644
index 0000000..e6ebb9d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp
@@ -0,0 +1,256 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, double& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+#include "hexfloat.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_decimal_point() const {return ';';}
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    double v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123.5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123.5);
+    }
+    {
+        const char str[] = "125e-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 125e-1);
+    }
+    {
+        const char str[] = "0x125p-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == hexfloat<double>(0x125, 0, -1));
+    }
+    {
+        const char str[] = "inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "-inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "-INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "nan";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        const char str[] = "NAN";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        v = -1;
+        const char str[] = "123_456_78_9;125";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        v = -1;
+        const char str[] = "2-";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+1);
+        assert(err == ios.goodbit);
+        assert(v == 2);
+    }
+    ios.imbue(std::locale(std::locale(), new my_numpunct));
+    {
+        v = -1;
+        const char str[] = "123_456_78_9;125";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123456789.125);
+    }
+    {
+        v = -1;
+        const char str[] = "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+    }
+    {
+        v = -1;
+        const char str[] = "3;14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651e+10";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::abs(v - 3.14159265358979e+10)/3.14159265358979e+10 < 1.e-8);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp
new file mode 100644
index 0000000..9138894
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, float& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+#include "hexfloat.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    float v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123.5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123.5);
+    }
+    {
+        const char str[] = "125e-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 125e-1);
+    }
+    {
+        const char str[] = "0x125p-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == hexfloat<float>(0x125, 0, -1));
+    }
+    {
+        const char str[] = "inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "-inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "-INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "nan";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        const char str[] = "NAN";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
new file mode 100644
index 0000000..d900c37
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
@@ -0,0 +1,519 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    long v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+4);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123";
+        oct(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 83);
+    }
+    {
+        const char str[] = "123";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+3);
+        assert(err == ios.goodbit);
+        assert(v == 291);
+    }
+    {
+        const char str[] = "0x123";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 291);
+    }
+    {
+        const char str[] = "123";
+        ios.setf(0, ios.basefield);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "0x123";
+        ios.setf(0, ios.basefield);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 291);
+    }
+    {
+        const char str[] = "0123";
+        ios.setf(0, ios.basefield);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 83);
+    }
+    {
+        const char str[] = "2-";
+        ios.setf(0, ios.basefield);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+1);
+        assert(err == ios.goodbit);
+        assert(v == 2);
+    }
+    dec(ios);
+    ios.imbue(std::locale(std::locale(), new my_numpunct));
+    {
+        v = -1;
+        const char str[] = "123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 123);
+    }
+    {
+        v = -1;
+        const char str[] = "+1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+_1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "_+1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+1__";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+_1_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "_+1_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+__1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "_+_1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "__+1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_2";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+_12";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+1__2";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 12);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_3";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_23";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 123);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_23_4";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234);
+    }
+    {
+        v = -1;
+        const char str[] = "+123_4";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1234);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_34";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1234);
+    }
+    {
+        v = -1;
+        const char str[] = "+12_34_5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 12345);
+    }
+    {
+        v = -1;
+        const char str[] = "+123_45_6";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123456);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_23_45_6";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 123456);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_234_56_7";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234567);
+    }
+    {
+        v = -1;
+        const char str[] = "+1_234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "-1_234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "1_234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "1234_567_89_0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == 1234567890);
+    }
+    {
+        v = -1;
+        const char str[] = "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_"
+                           "1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_1_2_3_4_5_6_7_8_9_0_";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == std::numeric_limits<long>::max());
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp
new file mode 100644
index 0000000..8e89ebc
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, long double& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include <cmath>
+#include "test_iterators.h"
+#include "hexfloat.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    long double v = -1;
+    {
+        const char str[] = "123";
+        assert((ios.flags() & ios.basefield) == ios.dec);
+        assert(ios.getloc().name() == "C");
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123);
+    }
+    {
+        const char str[] = "-123";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -123);
+    }
+    {
+        const char str[] = "123.5";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 123.5);
+    }
+    {
+        const char str[] = "125e-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 125e-1);
+    }
+    {
+        const char str[] = "0x125p-1";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == hexfloat<long double>(0x125, 0, -1));
+    }
+    {
+        const char str[] = "inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "-inf";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "-INF";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -INFINITY);
+    }
+    {
+        const char str[] = "nan";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        const char str[] = "NAN";
+        hex(ios);
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(std::isnan(v));
+    }
+    {
+        const char str[] = "1.189731495357231765021264e+49321";
+        std::ios_base::iostate err = ios.goodbit;
+        v = 0;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "1.189731495357231765021264e+49329";
+        std::ios_base::iostate err = ios.goodbit;
+        v = 0;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "11.189731495357231765021264e+4932";
+        std::ios_base::iostate err = ios.goodbit;
+        v = 0;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "91.189731495357231765021264e+4932";
+        std::ios_base::iostate err = ios.goodbit;
+        v = 0;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.failbit);
+        assert(v == INFINITY);
+    }
+    {
+        const char str[] = "304888344611713860501504000000";
+        std::ios_base::iostate err = ios.goodbit;
+        v = 0;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err != ios.failbit);
+        assert(v == 304888344611713860501504000000.0L);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp
new file mode 100644
index 0000000..fe00876
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_long.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, long long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    long long v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    {
+        const char str[] = "-1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == -1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0x7FFFFFFFFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0x7FFFFFFFFFFFFFFFLL);
+    }
+    {
+        const char str[] = "-0x8000000000000000";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0x8000000000000000LL);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp
new file mode 100644
index 0000000..c290722
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_pointer.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, void*& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    {
+        const char str[] = "0x0";
+        std::ios_base::iostate err = ios.goodbit;
+        void* p;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, p);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(p == 0);
+    }
+    {
+        const char str[] = "0x73";
+        std::ios_base::iostate err = ios.goodbit;
+        void* p;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, p);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(p == (void*)0x73);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp
new file mode 100644
index 0000000..2d10569
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_int.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned int& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned int v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFFFFFF);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp
new file mode 100644
index 0000000..50f0ff5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned long v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFFFFFF);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp
new file mode 100644
index 0000000..31fbb2a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_long_long.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned long long& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned long long v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFFFFFFFFFFFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFFFFFFFFFFFFFFULL);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp
new file mode 100644
index 0000000..822b83e
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_unsigned_short.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class num_get<charT, InputIterator>
+
+// iter_type get(iter_type in, iter_type end, ios_base&,
+//               ios_base::iostate& err, unsigned short& v) const;
+
+#include <locale>
+#include <ios>
+#include <cassert>
+#include <streambuf>
+#include "test_iterators.h"
+
+typedef std::num_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+class my_numpunct
+    : public std::numpunct<char>
+{
+public:
+    my_numpunct() : std::numpunct<char>() {}
+
+protected:
+    virtual char_type do_thousands_sep() const {return '_';}
+    virtual std::string do_grouping() const {return std::string("\1\2\3");}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    unsigned short v = -1;
+    {
+        const char str[] = "0";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0);
+    }
+    {
+        const char str[] = "1";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 1);
+    }
+    hex(ios);
+    {
+        const char str[] = "0xFFFF";
+        std::ios_base::iostate err = ios.goodbit;
+        input_iterator<const char*> iter =
+            f.get(input_iterator<const char*>(str),
+                  input_iterator<const char*>(str+sizeof(str)),
+                  ios, err, v);
+        assert(iter.base() == str+sizeof(str)-1);
+        assert(err == ios.goodbit);
+        assert(v == 0xFFFF);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp
new file mode 100644
index 0000000..e474eca
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <limits>
+#include <sstream>
+#include <iostream>
+#include <cassert>
+#include <iostream>
+
+using namespace std;
+
+template<typename T>
+void check_limits()
+{
+    T minv = numeric_limits<T>::min();
+    T maxv = numeric_limits<T>::max();
+
+    ostringstream miniss, maxiss;
+    assert(miniss << minv);
+    assert(maxiss << maxv);
+    std::string mins = miniss.str();
+    std::string maxs = maxiss.str(); 
+
+    istringstream maxoss(maxs), minoss(mins);
+
+    T new_minv, new_maxv;
+    assert(maxoss >> new_maxv);
+    assert(minoss >> new_minv);
+ 
+    assert(new_minv == minv);
+    assert(new_maxv == maxv);
+
+    if(mins == "0")
+        mins = "-1";
+    else
+        mins[mins.size() - 1]++;
+    
+    maxs[maxs.size() - 1]++;
+
+    istringstream maxoss2(maxs), minoss2(mins);
+    
+    assert(! (maxoss2 >> new_maxv));
+    assert(! (minoss2 >> new_minv));
+}
+
+int main(void)
+{
+    check_limits<short>();
+    check_limits<unsigned short>();
+    check_limits<int>();
+    check_limits<unsigned int>();
+    check_limits<long>();
+    check_limits<unsigned long>();
+    check_limits<long long>();
+    check_limits<unsigned long long>();
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp b/final/test/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp
new file mode 100644
index 0000000..b87b4b9
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/locale.num.get/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class InputIterator = istreambuf_iterator<charT> >
+// class num_get
+//     : public locale::facet
+// {
+// public:
+//     typedef charT char_type;
+//     typedef InputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::num_get<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::num_get<wchar_t> >::value), "");
+    static_assert((std::is_same<std::num_get<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::num_get<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::num_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::num_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/final/test/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.numeric/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp
new file mode 100644
index 0000000..f9b8ef2
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/date_order.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::time_get_byname<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        assert(f.date_order() == std::time_base::mdy);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.date_order() == std::time_base::ymd);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp
new file mode 100644
index 0000000..f9fc39f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/date_order_wide.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::time_get_byname<wchar_t, input_iterator<const wchar_t*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        assert(f.date_order() == std::time_base::mdy);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        assert(f.date_order() == std::time_base::dmy);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        assert(f.date_order() == std::time_base::ymd);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
new file mode 100644
index 0000000..a5935bf
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_date.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const char in[] = "06/10/2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const char in[] = "10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const char in[] = "10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const char in[] = "2009/06/10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
new file mode 100644
index 0000000..4c569ca
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_date_wide.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const wchar_t in[] = L"06/10/2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const wchar_t in[] = L"10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const wchar_t in[] = L"10.06.2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const wchar_t in[] = L"2009/06/10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
new file mode 100644
index 0000000..b9c64d7
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const char in[] = "juin";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const char in[] = "\xE5\x85\xAD\xE6\x9C\x88";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
new file mode 100644
index 0000000..17ddace
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+typedef std::time_put_byname<wchar_t, wchar_t*> F2;
+class my_facet2
+    : public F2
+{
+public:
+    explicit my_facet2(const std::string& nm, std::size_t refs = 0)
+        : F2(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const wchar_t in[] = L"June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const wchar_t in[] = L"juin";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const wchar_t in[] = L"\x438\x44E\x43D\x44F";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const wchar_t in[] = L"\x516D\x6708";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
new file mode 100644
index 0000000..473bc27
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f,
+//               ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const char in[] = "Sat Dec 31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const char in[] = "23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const char in[] = "Sam 31 d""\xC3\xA9""c 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const char in[] = "23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const char in[] = "\xD1\x81\xD1\x83\xD0\xB1\xD0\xB1"
+                          "\xD0\xBE\xD1\x82\xD0\xB0"
+                          ", 31 "
+                          "\xD0\xB4\xD0\xB5\xD0\xBA\xD0\xB0"
+                          "\xD0\xB1\xD1\x80\xD1\x8F"
+                          " 2061 "
+                          "\xD0\xB3"
+                          ". 23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const char in[] = "23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const char in[] = "\xE5\x85\xAD"
+                          " 12/31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const char in[] = "23""\xE6\x97\xB6""55""\xE5\x88\x86""59""\xE7\xA7\x92";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
new file mode 100644
index 0000000..973d374
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f,
+//               ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const wchar_t in[] = L"Sat Dec 31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const wchar_t in[] = L"23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const wchar_t in[] = L"Sam 31 d""\xE9""c 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const wchar_t in[] = L"23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+#ifdef __APPLE__
+    {
+        const my_facet f("ru_RU", 1);
+        const wchar_t in[] = L"\x441\x443\x431\x431\x43E\x442\x430"
+                          ", 31 "
+                          "\x434\x435\x43A\x430\x431\x440\x44F"
+                          " 2061 "
+                          "\x433"
+                          ". 23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+#endif
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const wchar_t in[] = L"23:55:59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+#ifdef __APPLE__
+    {
+        const my_facet f("zh_CN", 1);
+        const wchar_t in[] = L"\x516D"
+                          " 12/31 23:55:59 2061";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(t.tm_mday == 31);
+        assert(t.tm_mon == 11);
+        assert(t.tm_year == 161);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+#endif
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const wchar_t in[] = L"23""\x65F6""55""\x5206""59""\x79D2";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_sec == 59);
+        assert(t.tm_min == 55);
+        assert(t.tm_hour == 23);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp
new file mode 100644
index 0000000..094a52c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_time.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const char in[] = "13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp
new file mode 100644
index 0000000..451e87f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_time_wide.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const wchar_t in[] = L"13:14:15";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 13);
+        assert(t.tm_min == 14);
+        assert(t.tm_sec == 15);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp
new file mode 100644
index 0000000..39a6fe9
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const char in[] = "Monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const char in[] = "Lundi";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const char in[] = "\xD0\xBF\xD0\xBE\xD0\xBD\xD0\xB5"
+                          "\xD0\xB4\xD0\xB5\xD0\xBB\xD1\x8C"
+                          "\xD0\xBD\xD0\xB8\xD0\xBA";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const char in[] = "\xE6\x98\x9F\xE6\x9C\x9F\xE4\xB8\x80";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
new file mode 100644
index 0000000..951aee5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const wchar_t in[] = L"Monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const wchar_t in[] = L"Lundi";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const wchar_t in[] = L"\x661F\x671F\x4E00";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp
new file mode 100644
index 0000000..b558f43
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_year.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str,
+//                    ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get_byname<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const char in[] = "2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp
new file mode 100644
index 0000000..088849d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get.byname/get_year_wide.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str,
+//                    ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+        const wchar_t in[] = L"2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp
new file mode 100644
index 0000000..c6c4359
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// explicit time_get(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::time_get<char, const char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp
new file mode 100644
index 0000000..264494b
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/date_order.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// dateorder date_order() const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef std::time_get<char, input_iterator<const char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    assert(f.date_order() == std::time_base::mdy);
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp
new file mode 100644
index 0000000..6b8bd73
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "5/5/5";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 5);
+        assert(t.tm_year == 105);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp
new file mode 100644
index 0000000..4c663a3
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_date_wide.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_date(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"5/5/5";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 5);
+        assert(t.tm_year == 105);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp
new file mode 100644
index 0000000..39a10b4
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_many.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err, tm *t,
+//     const char_type *fmt, const char_type *fmtend) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "2009 May 9, 10:27pm";
+        const char fmt[] = "%Y %b %d, %I:%M%p";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, fmt, fmt+sizeof(fmt)-1);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 109);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 9);
+        assert(t.tm_hour == 22);
+        assert(t.tm_min == 27);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "10:27PM May 9, 2009";
+        const char fmt[] = "%I:%M%p %b %d, %Y";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, fmt, fmt+sizeof(fmt)-1);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 109);
+        assert(t.tm_mon == 4);
+        assert(t.tm_mday == 9);
+        assert(t.tm_hour == 22);
+        assert(t.tm_min == 27);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp
new file mode 100644
index 0000000..19e378c
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname.pass.cpp
@@ -0,0 +1,265 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "Jan";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Feb";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Mar";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Apr";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Jun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Jul";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Aug";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Sep";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Oct";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Nov";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Dec";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "January";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "February";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "March";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "April";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "July";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "August";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "September";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "October";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "November";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "December";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Decemper";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp
new file mode 100644
index 0000000..1761a6d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_monthname_wide.pass.cpp
@@ -0,0 +1,265 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_monthname(iter_type s, iter_type end, ios_base& str,
+//               ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"Jan";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Feb";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Mar";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Apr";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Jun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Jul";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Aug";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Sep";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Oct";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Nov";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Dec";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"January";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"February";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"March";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"April";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"May";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_mon == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"July";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"August";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_mon == 7);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"September";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_mon == 8);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"October";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_mon == 9);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"November";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"December";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Decemper";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+        assert(t.tm_mon == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp
new file mode 100644
index 0000000..05182c2
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_one.pass.cpp
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type get(iter_type s, iter_type end, ios_base& f,
+//               ios_base::iostate& err, tm *t, char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'a');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "wednesdaY";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'A');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'b');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Jul";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'B');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Thu Jun  6 09:49:10 2009";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'c');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 4);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 6);
+        assert(t.tm_hour == 9);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "11";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'd');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mday == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "2/1/1";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'D');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 1);
+        assert(t.tm_mday == 1);
+        assert(t.tm_year == 101);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "11";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'e');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mday == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "June";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'h');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "19";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'H');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 19);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "12";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'm');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 11);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "59";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'M');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_min == 59);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "\t\n ";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'n');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "09:49:10 PM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 21);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "09:49:10 AM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 9);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "12:49:10 AM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "12:49:10 PM";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'r');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 12);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "09:49";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'R');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 9);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'S');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 60);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "\t\n ";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 't');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "21:49:10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'T');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 21);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "3";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'w');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "06/06/09";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'x');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_mon == 5);
+        assert(t.tm_mday == 6);
+        assert(t.tm_year == 109);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "21:49:10";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'X');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 21);
+        assert(t.tm_min == 49);
+        assert(t.tm_sec == 10);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "68";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'y');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 168);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "68";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, 'Y');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == -1832);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "%";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get(I(in), I(in+sizeof(in)-1), ios, err, &t, '%');
+        assert(i.base() == in+sizeof(in)-1);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp
new file mode 100644
index 0000000..b8b05f6
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "0:0:0";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "23:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_hour == 23);
+        assert(t.tm_min == 59);
+        assert(t.tm_sec == 60);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "24:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+2);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char in[] = "23:60:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+5);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const char in[] = "23:59:61";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const char in[] = "2:43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_hour == 2);
+        assert(t.tm_min == 43);
+        assert(t.tm_sec == 22);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char in[] = "2.43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+1);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp
new file mode 100644
index 0000000..679d058
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_time_wide.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_time(iter_type s, iter_type end, ios_base& str,
+//          ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"0:0:0";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"23:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+        assert(t.tm_hour == 23);
+        assert(t.tm_min == 59);
+        assert(t.tm_sec == 60);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"24:59:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+2);
+        assert(t.tm_hour == 0);
+        assert(t.tm_min == 0);
+        assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const wchar_t in[] = L"23:60:60";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+5);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+    {
+        const wchar_t in[] = L"23:59:61";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const wchar_t in[] = L"2:43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_hour == 2);
+        assert(t.tm_min == 43);
+        assert(t.tm_sec == 22);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const wchar_t in[] = L"2.43:221";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_time(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+1);
+//         assert(t.tm_hour == 0);
+//         assert(t.tm_min == 0);
+//         assert(t.tm_sec == 0);
+        assert(err == std::ios_base::failbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp
new file mode 100644
index 0000000..918a902
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday.pass.cpp
@@ -0,0 +1,220 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "Sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Suny";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char in[] = "Sund";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const char in[] = "sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "sunday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Mony";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const char in[] = "Mond";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const char in[] = "mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Tue";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Tuesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Wed";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Wednesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Thu";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Thursday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Fri";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Friday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Sat";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "Saturday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp
new file mode 100644
index 0000000..5212eb1
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_weekday_wide.pass.cpp
@@ -0,0 +1,220 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+//             ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get<wchar_t, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const wchar_t in[] = L"Sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Suny";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const wchar_t in[] = L"Sund";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const wchar_t in[] = L"sun";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"sunday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Mony";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::goodbit);
+    }
+    {
+        const wchar_t in[] = L"Mond";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+4);
+        assert(t.tm_wday == 0);
+        assert(err == (std::ios_base::failbit | std::ios_base::eofbit));
+    }
+    {
+        const wchar_t in[] = L"mon";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"monday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 1);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Tue";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Tuesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+7);
+        assert(t.tm_wday == 2);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Wed";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Wednesday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+9);
+        assert(t.tm_wday == 3);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Thu";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Thursday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 4);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Fri";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Friday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+6);
+        assert(t.tm_wday == 5);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Sat";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+3);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const wchar_t in[] = L"Saturday";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+        assert(i.base() == in+8);
+        assert(t.tm_wday == 6);
+        assert(err == std::ios_base::eofbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp
new file mode 100644
index 0000000..6e5e04d
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.members/get_year.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_get<charT, InputIterator>
+
+// iter_type get_year(iter_type s, iter_type end, ios_base& str,
+//                    ios_base::iostate& err, tm* t) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef input_iterator<const char*> I;
+
+typedef std::time_get<char, I> F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    std::ios ios(0);
+    std::ios_base::iostate err;
+    std::tm t;
+    {
+        const char in[] = "0";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 100);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "00";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 100);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "1";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 101);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "68";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 168);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "69";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 69);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "99";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 99);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "100";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == -1800);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "1900";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 0);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "1968";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 68);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "2000";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-1);
+        assert(t.tm_year == 100);
+        assert(err == std::ios_base::eofbit);
+    }
+    {
+        const char in[] = "2999c";
+        err = std::ios_base::goodbit;
+        t = std::tm();
+        I i = f.get_year(I(in), I(in+sizeof(in)-1), ios, err, &t);
+        assert(i.base() == in+sizeof(in)-2);
+        assert(t.tm_year == 1099);
+        assert(err == std::ios_base::goodbit);
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/locale.time.get.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp
new file mode 100644
index 0000000..28bc3aa
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/time_base.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_base
+// {
+// public:
+//     enum dateorder {no_order, dmy, mdy, ymd, ydm};
+// };
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::time_base::dateorder d = std::time_base::no_order;
+    assert(std::time_base::no_order == 0);
+    assert(std::time_base::dmy == 1);
+    assert(std::time_base::mdy == 2);
+    assert(std::time_base::ymd == 3);
+    assert(std::time_base::ydm == 4);
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.get/types.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.get/types.pass.cpp
new file mode 100644
index 0000000..f434ea5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.get/types.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_base
+// {
+// public:
+//     enum dateorder {no_order, dmy, mdy, ymd, ydm};
+// };
+//
+// template <class charT, class InputIterator = istreambuf_iterator<charT> >
+// class time_get
+//     : public locale::facet,
+//       public time_base
+// {
+// public:
+//     typedef charT         char_type;
+//     typedef InputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::time_get<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::time_get<wchar_t> >::value), "");
+    static_assert((std::is_base_of<std::time_base, std::time_get<char> >::value), "");
+    static_assert((std::is_base_of<std::time_base, std::time_get<wchar_t> >::value), "");
+    static_assert((std::is_same<std::time_get<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::time_get<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::time_get<char>::iter_type, std::istreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::time_get<wchar_t>::iter_type, std::istreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
new file mode 100644
index 0000000..b6a4ed3
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.put.byname/put1.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class CharT, class OutputIterator = ostreambuf_iterator<CharT> >
+// class time_put_byname
+//     : public time_put<CharT, OutputIterator>
+// {
+// public:
+//     explicit time_put_byname(const char* nm, size_t refs = 0);
+//     explicit time_put_byname(const string& nm, size_t refs = 0);
+//
+// protected:
+//     ~time_put_byname();
+// };
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef std::time_put_byname<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(const std::string& nm, std::size_t refs = 0)
+        : F(nm, refs) {}
+};
+
+int main()
+{
+    char str[200];
+    output_iterator<char*> iter;
+    tm t;
+    t.tm_sec = 6;
+    t.tm_min = 3;
+    t.tm_hour = 13;
+    t.tm_mday = 2;
+    t.tm_mon = 4;
+    t.tm_year = 109;
+    t.tm_wday = 6;
+    t.tm_yday = -1;
+    t.tm_isdst = 1;
+    std::ios ios(0);
+    {
+        const my_facet f(LOCALE_en_US_UTF_8, 1);
+        std::string pat("Today is %A which is abbreviated %a.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert(ex == "Today is Saturday which is abbreviated Sat.");
+    }
+    {
+        const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+        std::string pat("Today is %A which is abbreviated %a.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert((ex == "Today is Samedi which is abbreviated Sam.")||
+               (ex == "Today is samedi which is abbreviated sam." ));
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp
new file mode 100644
index 0000000..c22980a
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// explicit time_put(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+typedef std::time_put<char, char*> F;
+
+class my_facet
+    : public F
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet);
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+    {
+        my_facet f(1);
+        assert(my_facet::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet::count == 1);
+        }
+        assert(my_facet::count == 1);
+    }
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp
new file mode 100644
index 0000000..93d5952
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put1.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
+//               const charT* pattern, const charT* pat_end) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef std::time_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    char str[200];
+    output_iterator<char*> iter;
+    tm t;
+    t.tm_sec = 6;
+    t.tm_min = 3;
+    t.tm_hour = 13;
+    t.tm_mday = 2;
+    t.tm_mon = 4;
+    t.tm_year = 109;
+    t.tm_wday = 6;
+    t.tm_yday = -1;
+    t.tm_isdst = 1;
+    std::ios ios(0);
+    {
+        std::string pat("Today is %A which is abbreviated %a.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert(ex == "Today is Saturday which is abbreviated Sat.");
+    }
+    {
+        std::string pat("The number of the month is %Om.");
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t,
+                     pat.data(), pat.data() + pat.size());
+        std::string ex(str, iter.base());
+        assert(ex == "The number of the month is 05.");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
new file mode 100644
index 0000000..577655f
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.members/put2.pass.cpp
@@ -0,0 +1,367 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class time_put<charT, OutputIterator>
+
+// iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
+//               char format, char modifier = 0) const;
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+typedef std::time_put<char, output_iterator<char*> > F;
+
+class my_facet
+    : public F
+{
+public:
+    explicit my_facet(std::size_t refs = 0)
+        : F(refs) {}
+};
+
+int main()
+{
+    const my_facet f(1);
+    char str[200];
+    output_iterator<char*> iter;
+    tm t = {0};
+    t.tm_sec = 6;
+    t.tm_min = 3;
+    t.tm_hour = 13;
+    t.tm_mday = 2;
+    t.tm_mon = 4;
+    t.tm_year = 109;
+    t.tm_wday = 6;
+    t.tm_yday = -1;
+    t.tm_isdst = 1;
+    std::ios ios(0);
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'A');
+        std::string ex(str, iter.base());
+        assert(ex == "Saturday");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'a');
+        std::string ex(str, iter.base());
+        assert(ex == "Sat");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'B');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'b');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'C');
+        std::string ex(str, iter.base());
+        assert(ex == "20");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'c');
+        std::string ex(str, iter.base());
+        assert(ex == "Sat May  2 13:03:06 2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'D');
+        std::string ex(str, iter.base());
+        assert(ex == "05/02/09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'd');
+        std::string ex(str, iter.base());
+        assert(ex == "02");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'c', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "Sat May  2 13:03:06 2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'C', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "20");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'x', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "05/02/09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'X', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03:06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Y', 'E');
+        std::string ex(str, iter.base());
+        assert(ex == "2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'd', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "02");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'e', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == " 2");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'H', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "13");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'I', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "01");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'm', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "05");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'M', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "03");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'S', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'u', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "52");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'B', 'O');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'e');
+        std::string ex(str, iter.base());
+        assert(ex == " 2");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'F');
+        std::string ex(str, iter.base());
+        assert(ex == "2009-05-02");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'G');
+        std::string ex(str, iter.base());
+        assert(ex == "2008");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'g');
+        std::string ex(str, iter.base());
+        assert(ex == "08");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'H');
+        std::string ex(str, iter.base());
+        assert(ex == "13");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'h');
+        std::string ex(str, iter.base());
+        assert(ex == "May");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'I');
+        std::string ex(str, iter.base());
+        assert(ex == "01");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'j');
+        std::string ex(str, iter.base());
+        assert(ex == "000");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'k');
+        std::string ex(str, iter.base());
+        assert(ex == "13");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'l');
+        std::string ex(str, iter.base());
+        assert(ex == " 1");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'M');
+        std::string ex(str, iter.base());
+        assert(ex == "03");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'm');
+        std::string ex(str, iter.base());
+        assert(ex == "05");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'n');
+        std::string ex(str, iter.base());
+        assert(ex == "\n");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'p');
+        std::string ex(str, iter.base());
+        assert(ex == "PM");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'R');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'r');
+        std::string ex(str, iter.base());
+        assert(ex == "01:03:06 PM");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'S');
+        std::string ex(str, iter.base());
+        assert(ex == "06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 's');
+        std::string ex(str, iter.base());
+//        assert(ex == "1241283786");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'T');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03:06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 't');
+        std::string ex(str, iter.base());
+        assert(ex == "\t");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'U');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'u');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'V');
+        std::string ex(str, iter.base());
+        assert(ex == "52");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'v');
+        std::string ex(str, iter.base());
+        assert(ex == " 2-May-2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'W');
+        std::string ex(str, iter.base());
+        assert(ex == "00");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'w');
+        std::string ex(str, iter.base());
+        assert(ex == "6");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'X');
+        std::string ex(str, iter.base());
+        assert(ex == "13:03:06");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'x');
+        std::string ex(str, iter.base());
+        assert(ex == "05/02/09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Y');
+        std::string ex(str, iter.base());
+        assert(ex == "2009");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'y');
+        std::string ex(str, iter.base());
+        assert(ex == "09");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'Z');
+        std::string ex(str, iter.base());
+//        assert(ex == "EDT");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'z');
+        std::string ex(str, iter.base());
+//        assert(ex == "-0400");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, '+');
+        std::string ex(str, iter.base());
+//        assert(ex == "Sat May  2 13:03:06 EDT 2009");  depends on time zone
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, '%');
+        std::string ex(str, iter.base());
+        assert(ex == "%");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, '%', 'J');
+        std::string ex(str, iter.base());
+        assert(ex == "J%");
+    }
+    {
+        iter = f.put(output_iterator<char*>(str), ios, '*', &t, 'J');
+        std::string ex(str, iter.base());
+        assert(ex == "J");
+    }
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.put/locale.time.put.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/category.time/locale.time.put/types.pass.cpp b/final/test/localization/locale.categories/category.time/locale.time.put/types.pass.cpp
new file mode 100644
index 0000000..db9d3fb
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/locale.time.put/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class OutputIterator = ostreambuf_iterator<charT> >
+// class time_put
+//     : public locale::facet
+// {
+// public:
+//     typedef charT          char_type;
+//     typedef OutputIterator iter_type;
+
+#include <locale>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::locale::facet, std::time_put<char> >::value), "");
+    static_assert((std::is_base_of<std::locale::facet, std::time_put<wchar_t> >::value), "");
+    static_assert((std::is_same<std::time_put<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::time_put<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::time_put<char>::iter_type, std::ostreambuf_iterator<char> >::value), "");
+    static_assert((std::is_same<std::time_put<wchar_t>::iter_type, std::ostreambuf_iterator<wchar_t> >::value), "");
+}
diff --git a/final/test/localization/locale.categories/category.time/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/category.time/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/category.time/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp
new file mode 100644
index 0000000..7becb8c
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/decimal_point.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// char_type decimal_point() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l("C");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == '.');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == L'.');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == '.');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == L'.');
+        }
+    }
+    {
+        std::locale l(LOCALE_fr_FR_UTF_8);
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.decimal_point() == L',');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
new file mode 100644
index 0000000..78bd944
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// string grouping() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l("C");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "");
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "");
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\3\3");
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\3\3");
+        }
+    }
+    {
+        std::locale l(LOCALE_fr_FR_UTF_8);
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\x7F");
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.grouping() == "\x7F");
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
new file mode 100644
index 0000000..9fdca1d
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct_byname;
+
+// char_type thousands_sep() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale l("C");
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == L',');
+        }
+    }
+    {
+        std::locale l(LOCALE_en_US_UTF_8);
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == L',');
+        }
+    }
+    {
+        std::locale l(LOCALE_fr_FR_UTF_8);
+        {
+            typedef char C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == ',');
+        }
+        {
+            typedef wchar_t C;
+            const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+            assert(np.thousands_sep() == L',');
+        }
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp
new file mode 100644
index 0000000..6ac4596
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/ctor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// explicit numpunct(size_t refs = 0);
+
+#include <locale>
+#include <cassert>
+
+template <class C>
+class my_facet
+    : public std::numpunct<C>
+{
+public:
+    static int count;
+
+    explicit my_facet(std::size_t refs = 0)
+        : std::numpunct<C>(refs) {++count;}
+
+    ~my_facet() {--count;}
+};
+
+template <class C> int my_facet<C>::count = 0;
+
+int main()
+{
+    {
+        std::locale l(std::locale::classic(), new my_facet<char>);
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        my_facet<char> f(1);
+        assert(my_facet<char>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<char>::count == 1);
+        }
+        assert(my_facet<char>::count == 1);
+    }
+    assert(my_facet<char>::count == 0);
+    {
+        std::locale l(std::locale::classic(), new my_facet<wchar_t>);
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+    {
+        my_facet<wchar_t> f(1);
+        assert(my_facet<wchar_t>::count == 1);
+        {
+            std::locale l(std::locale::classic(), &f);
+            assert(my_facet<wchar_t>::count == 1);
+        }
+        assert(my_facet<wchar_t>::count == 1);
+    }
+    assert(my_facet<wchar_t>::count == 0);
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp
new file mode 100644
index 0000000..c89e3f4
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/decimal_point.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// char_type decimal_point() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.decimal_point() == '.');
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.decimal_point() == L'.');
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp
new file mode 100644
index 0000000..b480055
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/falsename.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string_type falsename() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.falsename() == std::string("false"));
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.falsename() == std::wstring(L"false"));
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp
new file mode 100644
index 0000000..f2935ba
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/grouping.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string grouping() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.grouping() == std::string());
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.grouping() == std::string());
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp
new file mode 100644
index 0000000..19932d6
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/thousands_sep.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// char_type thousands_sep() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.thousands_sep() == ',');
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.thousands_sep() == L',');
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp
new file mode 100644
index 0000000..aa426d0
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.members/truename.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> class numpunct;
+
+// string_type truename() const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        typedef char C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.truename() == std::string("true"));
+    }
+    {
+        typedef wchar_t C;
+        const std::numpunct<C>& np = std::use_facet<std::numpunct<C> >(l);
+        assert(np.truename() == std::wstring(L"true"));
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/facet.numpunct.virtuals/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp
new file mode 100644
index 0000000..bbdf325
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/locale.numpunct/types.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT>
+// class numpunct
+//     : public locale::facet
+// {
+// public:
+//     typedef charT char_type;
+//     typedef basic_string<charT> string_type;
+//     static locale::id id;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    std::locale l = std::locale::classic();
+    {
+        assert(std::has_facet<std::numpunct<char> >(l));
+        const std::numpunct<char>& f = std::use_facet<std::numpunct<char> >(l);
+        {
+            (void)std::numpunct<char>::id;
+        }
+        static_assert((std::is_same<std::numpunct<char>::char_type, char>::value), "");
+        static_assert((std::is_same<std::numpunct<char>::string_type, std::string>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::numpunct<char> >::value), "");
+    }
+    {
+        assert(std::has_facet<std::numpunct<wchar_t> >(l));
+        const std::numpunct<wchar_t>& f = std::use_facet<std::numpunct<wchar_t> >(l);
+        {
+            (void)std::numpunct<wchar_t>::id;
+        }
+        static_assert((std::is_same<std::numpunct<wchar_t>::char_type, wchar_t>::value), "");
+        static_assert((std::is_same<std::numpunct<wchar_t>::string_type, std::wstring>::value), "");
+        static_assert((std::is_base_of<std::locale::facet, std::numpunct<wchar_t> >::value), "");
+    }
+}
diff --git a/final/test/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/facet.numpunct/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp b/final/test/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.categories/facets.examples/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_mode.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_mode.pass.cpp
new file mode 100644
index 0000000..ac35fb8
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_mode.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// enum codecvt_mode
+// {
+//     consume_header = 4,
+//     generate_header = 2,
+//     little_endian = 1
+// };
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    assert(std::consume_header == 4);
+    assert(std::generate_header == 2);
+    assert(std::little_endian == 1);
+    std::codecvt_mode e = std::consume_header;
+    assert(e == 4);
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16.pass.cpp
new file mode 100644
index 0000000..0569e4d
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// Not a portable test
+
+#include <codecvt>
+#include <cstdlib>
+#include <cassert>
+
+int outstanding_news = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++outstanding_news;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    if (p)
+    {
+        --outstanding_news;
+        std::free(p);
+    }
+}
+
+int main()
+{
+    assert(outstanding_news == 0);
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        assert(outstanding_news == 0);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        std::locale loc(std::locale::classic(), new C);
+        assert(outstanding_news != 0);
+    }
+    assert(outstanding_news == 0);
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
new file mode 100644
index 0000000..0b7d4cb
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// bool always_noconv() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
new file mode 100644
index 0000000..2d12d98
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int encoding() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
new file mode 100644
index 0000000..4d710c1
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
@@ -0,0 +1,739 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+//     in(stateT& state,
+//        const externT* from, const externT* from_end, const externT*& from_next,
+//        internT* to, internT* to_end, internT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        wchar_t w = 0;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(w == 0x40003);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x1000> C;
+        C c;
+        wchar_t w = 0;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+        C c;
+        wchar_t w = 0;
+        char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(w == 0x40003);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian> C;
+        C c;
+        wchar_t w = 0;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(w == 0x40003);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C;
+        C c;
+        wchar_t w = 0;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode(
+                                                         std::consume_header |
+                                                         std::little_endian)> C;
+        C c;
+        wchar_t w = 0;
+        char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(w == 0x40003);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t> C;
+        C c;
+        char32_t w = 0;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(w == 0x40003);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x1000> C;
+        C c;
+        char32_t w = 0;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char32_t w = 0;
+        char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(w == 0x40003);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
+        C c;
+        char32_t w = 0;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(w == 0x40003);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
+        C c;
+        char32_t w = 0;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x10ffff, std::codecvt_mode(
+                                                         std::consume_header |
+                                                         std::little_endian)> C;
+        C c;
+        char32_t w = 0;
+        char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(w == 0x40003);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+
+    {
+        typedef std::codecvt_utf16<char16_t> C;
+        C c;
+        char16_t w = 0;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x1000> C;
+        C c;
+        char16_t w = 0;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char16_t w = 0;
+        char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n+2);
+        assert(w == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x10ffff, std::little_endian> C;
+        C c;
+        char16_t w = 0;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x1000, std::little_endian> C;
+        C c;
+        char16_t w = 0;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x10ffff, std::codecvt_mode(
+                                                         std::consume_header |
+                                                         std::little_endian)> C;
+        C c;
+        char16_t w = 0;
+        char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n+2);
+        assert(w == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x1005);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x56);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
new file mode 100644
index 0000000..463a9fb
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
@@ -0,0 +1,449 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int length(stateT& state, const externT* from, const externT* from_end,
+//            size_t max) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 4);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 0);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+6, 2);
+        assert(r == 6);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::little_endian> C;
+        C c;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 4);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C;
+        C c;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 0);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode(
+                                                         std::consume_header |
+                                                         std::little_endian)> C;
+        C c;
+        char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+6, 2);
+        assert(r == 6);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t> C;
+        C c;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 4);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 0);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+6, 2);
+        assert(r == 6);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x10ffff, std::little_endian> C;
+        C c;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 4);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x1000, std::little_endian> C;
+        C c;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 0);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0x10ffff, std::codecvt_mode(
+                                                         std::consume_header |
+                                                         std::little_endian)> C;
+        C c;
+        char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+6, 2);
+        assert(r == 6);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+
+    {
+        typedef std::codecvt_utf16<char16_t> C;
+        C c;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 0);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char n[6] = {char(0xFE), char(0xFF), char(0xD8), char(0xC0), char(0xDC), char(0x03)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+6, 2);
+        assert(r == 2);
+
+        n[0] = char(0x10);
+        n[1] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x04);
+        n[1] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x00);
+        n[1] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x10ffff, std::little_endian> C;
+        C c;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x1000, std::little_endian> C;
+        C c;
+        char n[4] = {char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 0);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0x10ffff, std::codecvt_mode(
+                                                         std::consume_header |
+                                                         std::little_endian)> C;
+        C c;
+        char n[6] = {char(0xFF), char(0xFE), char(0xC0), char(0xD8), char(0x03), char(0xDC)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+6, 2);
+        assert(r == 2);
+
+        n[1] = char(0x10);
+        n[0] = char(0x05);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x04);
+        n[0] = char(0x53);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[1] = char(0x00);
+        n[0] = char(0x56);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
new file mode 100644
index 0000000..29bb58d
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int max_length() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 6);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 2);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 6);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
new file mode 100644
index 0000000..2eb6978
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
@@ -0,0 +1,331 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+// out(stateT& state,
+//     const internT* from, const internT* from_end, const internT*& from_next,
+//     externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xD8));
+        assert(n[1] == char(0xC0));
+        assert(n[2] == char(0xDC));
+        assert(n[3] == char(0x03));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0x10));
+        assert(n[1] == char(0x05));
+        assert(n[2] == char(0xDC));
+        assert(n[3] == char(0x03));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0x04));
+        assert(n[1] == char(0x53));
+        assert(n[2] == char(0xDC));
+        assert(n[3] == char(0x03));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0x00));
+        assert(n[1] == char(0x56));
+        assert(n[2] == char(0xDC));
+        assert(n[3] == char(0x03));
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x1000> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[0] == char(0));
+        assert(n[1] == char(0));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[0] == char(0));
+        assert(n[1] == char(0));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0x04));
+        assert(n[1] == char(0x53));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0x00));
+        assert(n[1] == char(0x56));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::generate_header> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[6] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(n[0] == char(0xFE));
+        assert(n[1] == char(0xFF));
+        assert(n[2] == char(0xD8));
+        assert(n[3] == char(0xC0));
+        assert(n[4] == char(0xDC));
+        assert(n[5] == char(0x03));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xFE));
+        assert(n[1] == char(0xFF));
+        assert(n[2] == char(0x10));
+        assert(n[3] == char(0x05));
+        assert(n[4] == char(0xDC));
+        assert(n[5] == char(0x03));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xFE));
+        assert(n[1] == char(0xFF));
+        assert(n[2] == char(0x04));
+        assert(n[3] == char(0x53));
+        assert(n[4] == char(0xDC));
+        assert(n[5] == char(0x03));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xFE));
+        assert(n[1] == char(0xFF));
+        assert(n[2] == char(0x00));
+        assert(n[3] == char(0x56));
+        assert(n[4] == char(0xDC));
+        assert(n[5] == char(0x03));
+    }
+
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10FFFF, std::little_endian> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[1] == char(0xD8));
+        assert(n[0] == char(0xC0));
+        assert(n[3] == char(0xDC));
+        assert(n[2] == char(0x03));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[1] == char(0x10));
+        assert(n[0] == char(0x05));
+        assert(n[3] == char(0xDC));
+        assert(n[2] == char(0x03));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[1] == char(0x04));
+        assert(n[0] == char(0x53));
+        assert(n[3] == char(0xDC));
+        assert(n[2] == char(0x03));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[1] == char(0x00));
+        assert(n[0] == char(0x56));
+        assert(n[3] == char(0xDC));
+        assert(n[2] == char(0x03));
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x1000, std::little_endian> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[1] == char(0));
+        assert(n[0] == char(0));
+        assert(n[3] == char(0));
+        assert(n[2] == char(0));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[1] == char(0));
+        assert(n[0] == char(0));
+        assert(n[3] == char(0));
+        assert(n[2] == char(0));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[1] == char(0x04));
+        assert(n[0] == char(0x53));
+        assert(n[3] == char(0));
+        assert(n[2] == char(0));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[1] == char(0x00));
+        assert(n[0] == char(0x56));
+        assert(n[3] == char(0));
+        assert(n[2] == char(0));
+    }
+    {
+        typedef std::codecvt_utf16<wchar_t, 0x10ffff, std::codecvt_mode(
+                                                         std::generate_header |
+                                                         std::little_endian)> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[6] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(n[1] == char(0xFE));
+        assert(n[0] == char(0xFF));
+        assert(n[3] == char(0xD8));
+        assert(n[2] == char(0xC0));
+        assert(n[5] == char(0xDC));
+        assert(n[4] == char(0x03));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[1] == char(0xFE));
+        assert(n[0] == char(0xFF));
+        assert(n[3] == char(0x10));
+        assert(n[2] == char(0x05));
+        assert(n[5] == char(0xDC));
+        assert(n[4] == char(0x03));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[1] == char(0xFE));
+        assert(n[0] == char(0xFF));
+        assert(n[3] == char(0x04));
+        assert(n[2] == char(0x53));
+        assert(n[5] == char(0xDC));
+        assert(n[4] == char(0x03));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+6, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[1] == char(0xFE));
+        assert(n[0] == char(0xFF));
+        assert(n[3] == char(0x00));
+        assert(n[2] == char(0x56));
+        assert(n[5] == char(0xDC));
+        assert(n[4] == char(0x03));
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
new file mode 100644
index 0000000..463d2f9
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+//     unshift(stateT& state,
+//             externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf16<wchar_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+    {
+        typedef std::codecvt_utf16<char16_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+    {
+        typedef std::codecvt_utf16<char32_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8.pass.cpp
new file mode 100644
index 0000000..4232f59
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// Not a portable test
+
+#include <codecvt>
+#include <cstdlib>
+#include <cassert>
+
+int outstanding_news = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++outstanding_news;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    if (p)
+    {
+        --outstanding_news;
+        std::free(p);
+    }
+}
+
+int main()
+{
+    assert(outstanding_news == 0);
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        assert(outstanding_news == 0);
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        std::locale loc(std::locale::classic(), new C);
+        assert(outstanding_news != 0);
+    }
+    assert(outstanding_news == 0);
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
new file mode 100644
index 0000000..963c269
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// bool always_noconv() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
new file mode 100644
index 0000000..b17752c
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int encoding() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
new file mode 100644
index 0000000..382ea12
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
@@ -0,0 +1,360 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+//     in(stateT& state,
+//        const externT* from, const externT* from_end, const externT*& from_next,
+//        internT* to, internT* to_end, internT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        wchar_t w = 0;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(w == 0x40003);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(w == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t, 0x1000> C;
+        C c;
+        wchar_t w = 0;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        wchar_t w = 0;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+7, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+7);
+        assert(w == 0x40003);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(w == 0x1005);
+
+        n[0] = char(0xEF);
+        n[1] = char(0xBB);
+        n[2] = char(0xBF);
+        n[3] = char(0xD1);
+        n[4] = char(0x93);
+        r = c.in(m, n, n+5, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+5);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t> C;
+        C c;
+        char32_t w = 0;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(w == 0x40003);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(w == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t, 0x1000> C;
+        C c;
+        char32_t w = 0;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        char32_t w = 0;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+7, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+7);
+        assert(w == 0x40003);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(w == 0x1005);
+
+        n[0] = char(0xEF);
+        n[1] = char(0xBB);
+        n[2] = char(0xBF);
+        n[3] = char(0xD1);
+        n[4] = char(0x93);
+        r = c.in(m, n, n+5, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+5);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t> C;
+        C c;
+        char16_t w = 0;
+        char n[3] = {char(0xE1), char(0x80), char(0x85)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(w == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t, 0x1000> C;
+        C c;
+        char16_t w = 0;
+        char n[3] = {char(0xE1), char(0x80), char(0x85)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+3, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(w == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        char16_t w = 0;
+        char n[6] = {char(0xEF), char(0xBB), char(0xBF), char(0xE1), char(0x80), char(0x85)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+6, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(w == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(w == 0x453);
+
+        w = 0x56;
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, &w, &w+1, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(w == 0x56);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
new file mode 100644
index 0000000..7239b4c
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
@@ -0,0 +1,244 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int length(stateT& state, const externT* from, const externT* from_end,
+//            size_t max) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 1);
+        assert(r == 4);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 3);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 1);
+        assert(r == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 3);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+7, 1);
+        assert(r == 7);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xEF);
+        n[1] = char(0xBB);
+        n[2] = char(0xBF);
+        n[3] = char(0xD1);
+        n[4] = char(0x93);
+        r = c.length(m, n, n+5, 3);
+        assert(r == 5);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 1);
+        assert(r == 4);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 3);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 1);
+        assert(r == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 3);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+7, 1);
+        assert(r == 7);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xEF);
+        n[1] = char(0xBB);
+        n[2] = char(0xBF);
+        n[3] = char(0xD1);
+        n[4] = char(0x93);
+        r = c.length(m, n, n+5, 3);
+        assert(r == 5);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 1);
+        assert(r == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 3);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 1);
+        assert(r == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 3);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+7, 1);
+        assert(r == 3);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xEF);
+        n[1] = char(0xBB);
+        n[2] = char(0xBF);
+        n[3] = char(0xD1);
+        n[4] = char(0x93);
+        r = c.length(m, n, n+5, 3);
+        assert(r == 5);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 3);
+        assert(r == 1);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
new file mode 100644
index 0000000..70e23f8
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int max_length() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 7);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 3);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 6);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 7);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
new file mode 100644
index 0000000..02cf7cf
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
@@ -0,0 +1,456 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+// out(stateT& state,
+//     const internT* from, const internT* from_end, const internT*& from_next,
+//     externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xF1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x80));
+        assert(n[3] == char(0x83));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(n[0] == char(0xE1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0x83));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0x83));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0x83));
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t, 0x1000> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[0] == char(0));
+        assert(n[1] == char(0));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[0] == char(0));
+        assert(n[1] == char(0));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t, 0xFFFFFFFF, std::generate_header> C;
+        C c;
+        wchar_t w = 0x40003;
+        char n[7] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+7);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xF1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x80));
+        assert(n[6] == char(0x83));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xE1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0x83));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+5);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xD1));
+        assert(n[4] == char(0x93));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0x83));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0x56));
+        assert(n[4] == char(0x93));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0x83));
+    }
+    {
+        typedef std::codecvt_utf8<char32_t> C;
+        C c;
+        char32_t w = 0x40003;
+        char n[4] = {0};
+        const char32_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xF1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x80));
+        assert(n[3] == char(0x83));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(n[0] == char(0xE1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0x83));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0x83));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0x83));
+    }
+    {
+        typedef std::codecvt_utf8<char32_t, 0x1000> C;
+        C c;
+        char32_t w = 0x40003;
+        char n[4] = {0};
+        const char32_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[0] == char(0));
+        assert(n[1] == char(0));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[0] == char(0));
+        assert(n[1] == char(0));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+    }
+    {
+        typedef std::codecvt_utf8<char32_t, 0xFFFFFFFF, std::generate_header> C;
+        C c;
+        char32_t w = 0x40003;
+        char n[7] = {0};
+        const char32_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+7);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xF1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x80));
+        assert(n[6] == char(0x83));
+
+        w = 0x1005;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xE1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0x83));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+5);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xD1));
+        assert(n[4] == char(0x93));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0x83));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0x56));
+        assert(n[4] == char(0x93));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0x83));
+    }
+    {
+        typedef std::codecvt_utf8<char16_t> C;
+        C c;
+        char16_t w = 0x1005;
+        char n[4] = {0};
+        const char16_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+3);
+        assert(n[0] == char(0xE1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0x85));
+        assert(n[3] == char(0));
+    }
+    {
+        typedef std::codecvt_utf8<char16_t, 0x1000> C;
+        C c;
+        char16_t w = 0x1005;
+        char n[4] = {0};
+        const char16_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == &w);
+        assert(np == n);
+        assert(n[0] == char(0));
+        assert(n[1] == char(0));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+        assert(n[1] == char(0x93));
+        assert(n[2] == char(0));
+        assert(n[3] == char(0));
+    }
+    {
+        typedef std::codecvt_utf8<char16_t, 0xFFFFFFFF, std::generate_header> C;
+        C c;
+        char16_t w = 0x1005;
+        char n[7] = {0};
+        const char16_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+6);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xE1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0));
+
+        w = 0x453;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+5);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xD1));
+        assert(n[4] == char(0x93));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0));
+
+        w = 0x56;
+        r = c.out(m, &w, &w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == &w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0x56));
+        assert(n[4] == char(0x93));
+        assert(n[5] == char(0x85));
+        assert(n[6] == char(0));
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
new file mode 100644
index 0000000..1f0c237
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+//     unshift(stateT& state,
+//             externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+    {
+        typedef std::codecvt_utf8<char16_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+    {
+        typedef std::codecvt_utf8<char32_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
new file mode 100644
index 0000000..7690e61
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// bool always_noconv() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t> C;
+        C c;
+        bool r = c.always_noconv();
+        assert(r == false);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
new file mode 100644
index 0000000..bc17880
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int encoding() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t> C;
+        C c;
+        int r = c.encoding();
+        assert(r == 0);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
new file mode 100644
index 0000000..0cd9417
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+//     in(stateT& state,
+//        const externT* from, const externT* from_end, const externT*& from_next,
+//        internT* to, internT* to_end, internT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t> C;
+        C c;
+        wchar_t w[2] = {0};
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+4);
+        assert(w[0] == 0xD8C0);
+        assert(w[1] == 0xDC03);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(w[0] == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
+        C c;
+        wchar_t w[2] = {0};
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+        C c;
+        wchar_t w[2] = {0};
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+7);
+        assert(w[0] == 0xD8C0);
+        assert(w[1] == 0xDC03);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(w[0] == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t> C;
+        C c;
+        char32_t w[2] = {0};
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+4);
+        assert(w[0] == 0xD8C0);
+        assert(w[1] == 0xDC03);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(w[0] == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
+        C c;
+        char32_t w[2] = {0};
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char32_t w[2] = {0};
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char32_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+7);
+        assert(w[0] == 0xD8C0);
+        assert(w[1] == 0xDC03);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(w[0] == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t> C;
+        C c;
+        char16_t w[2] = {0};
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+4);
+        assert(w[0] == 0xD8C0);
+        assert(w[1] == 0xDC03);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(w[0] == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
+        C c;
+        char16_t w[2] = {0};
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+4, np, w, w+2, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char16_t w[2] = {0};
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        char16_t* wp = nullptr;
+        std::mbstate_t m;
+        const char* np = nullptr;
+        std::codecvt_base::result r = c.in(m, n, n+7, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+7);
+        assert(w[0] == 0xD8C0);
+        assert(w[1] == 0xDC03);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.in(m, n, n+3, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(w[0] == 0x1005);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.in(m, n, n+2, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(w[0] == 0x0453);
+
+        n[0] = char(0x56);
+        r = c.in(m, n, n+1, np, w, w+2, wp);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(w[0] == 0x0056);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
new file mode 100644
index 0000000..8f5be81
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
@@ -0,0 +1,235 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int length(stateT& state, const externT* from, const externT* from_end,
+//            size_t max) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 4);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+7, 2);
+        assert(r == 7);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 4);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+7, 2);
+        assert(r == 7);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 4);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
+        C c;
+        char n[4] = {char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+4, 2);
+        assert(r == 0);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 0);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::consume_header> C;
+        C c;
+        char n[7] = {char(0xEF), char(0xBB), char(0xBF), char(0xF1), char(0x80), char(0x80), char(0x83)};
+        std::mbstate_t m;
+        int r = c.length(m, n, n+7, 2);
+        assert(r == 7);
+
+        n[0] = char(0xE1);
+        n[1] = char(0x80);
+        n[2] = char(0x85);
+        r = c.length(m, n, n+3, 2);
+        assert(r == 3);
+
+        n[0] = char(0xD1);
+        n[1] = char(0x93);
+        r = c.length(m, n, n+2, 2);
+        assert(r == 2);
+
+        n[0] = char(0x56);
+        r = c.length(m, n, n+1, 2);
+        assert(r == 1);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
new file mode 100644
index 0000000..ef4d0b8
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// int max_length() const throw();
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 7);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 7);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 4);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t, 0xFFFFFFFF, std::consume_header> C;
+        C c;
+        int r = c.max_length();
+        assert(r == 7);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
new file mode 100644
index 0000000..29c5342
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
@@ -0,0 +1,415 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+// out(stateT& state,
+//     const internT* from, const internT* from_end, const internT*& from_next,
+//     externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t> C;
+        C c;
+        wchar_t w[2] = {0xD8C0, 0xDC03};
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+4);
+        assert(n[0] == char(0xF1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x80));
+        assert(n[3] == char(0x83));
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(n[0] == char(0xE1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x85));
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+    }
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t, 0x1000> C;
+        C c;
+        wchar_t w[2] = {0xD8C0, 0xDC03};
+        char n[4] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+    }
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::generate_header> C;
+        C c;
+        wchar_t w[2] = {0xD8C0, 0xDC03};
+        char n[7] = {0};
+        const wchar_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+7);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xF1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x80));
+        assert(n[6] == char(0x83));
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+6);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xE1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x85));
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+5);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xD1));
+        assert(n[4] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0x56));
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t> C;
+        C c;
+        char32_t w[2] = {0xD8C0, 0xDC03};
+        char n[4] = {0};
+        const char32_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+4);
+        assert(n[0] == char(0xF1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x80));
+        assert(n[3] == char(0x83));
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(n[0] == char(0xE1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x85));
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t, 0x1000> C;
+        C c;
+        char32_t w[2] = {0xD8C0, 0xDC03};
+        char n[4] = {0};
+        const char32_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t, 0x10ffff, std::generate_header> C;
+        C c;
+        char32_t w[2] = {0xD8C0, 0xDC03};
+        char n[7] = {0};
+        const char32_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+7);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xF1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x80));
+        assert(n[6] == char(0x83));
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+6);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xE1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x85));
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+5);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xD1));
+        assert(n[4] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0x56));
+    }
+
+    {
+        typedef std::codecvt_utf8_utf16<char16_t> C;
+        C c;
+        char16_t w[2] = {0xD8C0, 0xDC03};
+        char n[4] = {0};
+        const char16_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+4);
+        assert(n[0] == char(0xF1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x80));
+        assert(n[3] == char(0x83));
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+3);
+        assert(n[0] == char(0xE1));
+        assert(n[1] == char(0x80));
+        assert(n[2] == char(0x85));
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t, 0x1000> C;
+        C c;
+        char16_t w[2] = {0xD8C0, 0xDC03};
+        char n[4] = {0};
+        const char16_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::error);
+        assert(wp == w);
+        assert(np == n);
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+2);
+        assert(n[0] == char(0xD1));
+        assert(n[1] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+4, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+1);
+        assert(n[0] == char(0x56));
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::generate_header> C;
+        C c;
+        char16_t w[2] = {0xD8C0, 0xDC03};
+        char n[7] = {0};
+        const char16_t* wp = nullptr;
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.out(m, w, w+2, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+2);
+        assert(np == n+7);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xF1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x80));
+        assert(n[6] == char(0x83));
+
+        w[0] = 0x1005;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+6);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xE1));
+        assert(n[4] == char(0x80));
+        assert(n[5] == char(0x85));
+
+        w[0] = 0x453;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+5);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0xD1));
+        assert(n[4] == char(0x93));
+
+        w[0] = 0x56;
+        r = c.out(m, w, w+1, wp, n, n+7, np);
+        assert(r == std::codecvt_base::ok);
+        assert(wp == w+1);
+        assert(np == n+4);
+        assert(n[0] == char(0xEF));
+        assert(n[1] == char(0xBB));
+        assert(n[2] == char(0xBF));
+        assert(n[3] == char(0x56));
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
new file mode 100644
index 0000000..2bcade0
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+// template <class Elem, unsigned long Maxcode = 0x10ffff,
+//           codecvt_mode Mode = (codecvt_mode)0>
+// class codecvt_utf8_utf16
+//     : public codecvt<Elem, char, mbstate_t>
+// {
+//     // unspecified
+// };
+
+// result
+//     unshift(stateT& state,
+//             externT* to, externT* to_end, externT*& to_next) const;
+
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8_utf16<wchar_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char16_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+    {
+        typedef std::codecvt_utf8_utf16<char32_t> C;
+        C c;
+        char n[4] = {0};
+        std::mbstate_t m;
+        char* np = nullptr;
+        std::codecvt_base::result r = c.unshift(m, n, n+4, np);
+        assert(r == std::codecvt_base::noconv);
+    }
+}
diff --git a/final/test/localization/locale.stdcvt/version.pass.cpp b/final/test/localization/locale.stdcvt/version.pass.cpp
new file mode 100644
index 0000000..3885380
--- /dev/null
+++ b/final/test/localization/locale.stdcvt/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <codecvt>
+
+#include <codecvt>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/localization/locale.syn/nothing_to_do.pass.cpp b/final/test/localization/locale.syn/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locale.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isalnum.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isalnum.pass.cpp
new file mode 100644
index 0000000..376b334
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isalnum.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isalnum (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isalnum(' ', l));
+    assert(!std::isalnum('<', l));
+    assert(!std::isalnum('\x8', l));
+    assert( std::isalnum('A', l));
+    assert( std::isalnum('a', l));
+    assert( std::isalnum('z', l));
+    assert( std::isalnum('3', l));
+    assert(!std::isalnum('.', l));
+    assert( std::isalnum('f', l));
+    assert( std::isalnum('9', l));
+    assert(!std::isalnum('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isalpha.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isalpha.pass.cpp
new file mode 100644
index 0000000..d1a0e69
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isalpha.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isalpha (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isalpha(' ', l));
+    assert(!std::isalpha('<', l));
+    assert(!std::isalpha('\x8', l));
+    assert( std::isalpha('A', l));
+    assert( std::isalpha('a', l));
+    assert( std::isalpha('z', l));
+    assert(!std::isalpha('3', l));
+    assert(!std::isalpha('.', l));
+    assert( std::isalpha('f', l));
+    assert(!std::isalpha('9', l));
+    assert(!std::isalpha('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/iscntrl.pass.cpp b/final/test/localization/locales/locale.convenience/classification/iscntrl.pass.cpp
new file mode 100644
index 0000000..0bd45ac
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/iscntrl.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool iscntrl (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::iscntrl(' ', l));
+    assert(!std::iscntrl('<', l));
+    assert( std::iscntrl('\x8', l));
+    assert(!std::iscntrl('A', l));
+    assert(!std::iscntrl('a', l));
+    assert(!std::iscntrl('z', l));
+    assert(!std::iscntrl('3', l));
+    assert(!std::iscntrl('.', l));
+    assert(!std::iscntrl('f', l));
+    assert(!std::iscntrl('9', l));
+    assert(!std::iscntrl('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isdigit.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isdigit.pass.cpp
new file mode 100644
index 0000000..bdc0632
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isdigit.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isdigit (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isdigit(' ', l));
+    assert(!std::isdigit('<', l));
+    assert(!std::isdigit('\x8', l));
+    assert(!std::isdigit('A', l));
+    assert(!std::isdigit('a', l));
+    assert(!std::isdigit('z', l));
+    assert( std::isdigit('3', l));
+    assert(!std::isdigit('.', l));
+    assert(!std::isdigit('f', l));
+    assert( std::isdigit('9', l));
+    assert(!std::isdigit('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isgraph.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isgraph.pass.cpp
new file mode 100644
index 0000000..b294aa5
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isgraph.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isgraph (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isgraph(' ', l));
+    assert( std::isgraph('<', l));
+    assert(!std::isgraph('\x8', l));
+    assert( std::isgraph('A', l));
+    assert( std::isgraph('a', l));
+    assert( std::isgraph('z', l));
+    assert( std::isgraph('3', l));
+    assert( std::isgraph('.', l));
+    assert( std::isgraph('f', l));
+    assert( std::isgraph('9', l));
+    assert( std::isgraph('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/islower.pass.cpp b/final/test/localization/locales/locale.convenience/classification/islower.pass.cpp
new file mode 100644
index 0000000..e131e50
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/islower.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool islower (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::islower(' ', l));
+    assert(!std::islower('<', l));
+    assert(!std::islower('\x8', l));
+    assert(!std::islower('A', l));
+    assert( std::islower('a', l));
+    assert( std::islower('z', l));
+    assert(!std::islower('3', l));
+    assert(!std::islower('.', l));
+    assert( std::islower('f', l));
+    assert(!std::islower('9', l));
+    assert(!std::islower('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isprint.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isprint.pass.cpp
new file mode 100644
index 0000000..a8c39fa
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isprint.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isprint (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert( std::isprint(' ', l));
+    assert( std::isprint('<', l));
+    assert(!std::isprint('\x8', l));
+    assert( std::isprint('A', l));
+    assert( std::isprint('a', l));
+    assert( std::isprint('z', l));
+    assert( std::isprint('3', l));
+    assert( std::isprint('.', l));
+    assert( std::isprint('f', l));
+    assert( std::isprint('9', l));
+    assert( std::isprint('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/ispunct.pass.cpp b/final/test/localization/locales/locale.convenience/classification/ispunct.pass.cpp
new file mode 100644
index 0000000..b606d32
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/ispunct.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool ispunct (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::ispunct(' ', l));
+    assert( std::ispunct('<', l));
+    assert(!std::ispunct('\x8', l));
+    assert(!std::ispunct('A', l));
+    assert(!std::ispunct('a', l));
+    assert(!std::ispunct('z', l));
+    assert(!std::ispunct('3', l));
+    assert( std::ispunct('.', l));
+    assert(!std::ispunct('f', l));
+    assert(!std::ispunct('9', l));
+    assert( std::ispunct('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isspace.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isspace.pass.cpp
new file mode 100644
index 0000000..884b303
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isspace.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isspace (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert( std::isspace(' ', l));
+    assert(!std::isspace('<', l));
+    assert(!std::isspace('\x8', l));
+    assert(!std::isspace('A', l));
+    assert(!std::isspace('a', l));
+    assert(!std::isspace('z', l));
+    assert(!std::isspace('3', l));
+    assert(!std::isspace('.', l));
+    assert(!std::isspace('f', l));
+    assert(!std::isspace('9', l));
+    assert(!std::isspace('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isupper.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isupper.pass.cpp
new file mode 100644
index 0000000..8ce51bc
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isupper.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isupper (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isupper(' ', l));
+    assert(!std::isupper('<', l));
+    assert(!std::isupper('\x8', l));
+    assert( std::isupper('A', l));
+    assert(!std::isupper('a', l));
+    assert(!std::isupper('z', l));
+    assert(!std::isupper('3', l));
+    assert(!std::isupper('.', l));
+    assert(!std::isupper('f', l));
+    assert(!std::isupper('9', l));
+    assert(!std::isupper('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/classification/isxdigit.pass.cpp b/final/test/localization/locales/locale.convenience/classification/isxdigit.pass.cpp
new file mode 100644
index 0000000..3407695
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/classification/isxdigit.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> bool isxdigit (charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(!std::isxdigit(' ', l));
+    assert(!std::isxdigit('<', l));
+    assert(!std::isxdigit('\x8', l));
+    assert( std::isxdigit('A', l));
+    assert( std::isxdigit('a', l));
+    assert(!std::isxdigit('z', l));
+    assert( std::isxdigit('3', l));
+    assert(!std::isxdigit('.', l));
+    assert( std::isxdigit('f', l));
+    assert( std::isxdigit('9', l));
+    assert(!std::isxdigit('+', l));
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
new file mode 100644
index 0000000..6935c3e
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// wbuffer_convert(streambuf *bytebuf = 0, Codecvt *pcvt = new Codecvt,
+//                 state_type state = state_type());
+
+#include <locale>
+#include <codecvt>
+#include <sstream>
+#include <cassert>
+#include <new>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int main()
+{
+    typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_convertible<std::streambuf*, B>::value, "");
+    static_assert( std::is_constructible<B, std::streambuf*>::value, "");
+#endif
+    {
+        B b;
+        assert(b.rdbuf() == nullptr);
+        assert(new_called != 0);
+    }
+    assert(new_called == 0);
+    {
+        std::stringstream s;
+        B b(s.rdbuf());
+        assert(b.rdbuf() == s.rdbuf());
+        assert(new_called != 0);
+    }
+    assert(new_called == 0);
+    {
+        std::stringstream s;
+        B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>);
+        assert(b.rdbuf() == s.rdbuf());
+        assert(new_called != 0);
+    }
+    assert(new_called == 0);
+    {
+        std::stringstream s;
+        B b(s.rdbuf(), new std::codecvt_utf8<wchar_t>, std::mbstate_t());
+        assert(b.rdbuf() == s.rdbuf());
+        assert(new_called != 0);
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
new file mode 100644
index 0000000..24706b5
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// int_type overflow(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+struct test_buf
+    : public std::wbuffer_convert<std::codecvt_utf8<wchar_t> >
+{
+    typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > base;
+    typedef base::char_type   char_type;
+    typedef base::int_type    int_type;
+    typedef base::traits_type traits_type;
+
+    explicit test_buf(std::streambuf* sb) : base(sb) {}
+
+    char_type* pbase() const {return base::pbase();}
+    char_type* pptr()  const {return base::pptr();}
+    char_type* epptr() const {return base::epptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type overflow(int_type c = traits_type::eof()) {return base::overflow(c);}
+};
+
+int main()
+{
+    {
+        std::ofstream bs("overflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow(L'a') == L'a');
+        assert(f.pbase() != 0);
+        assert(f.pptr() == f.pbase());
+        assert(f.epptr() - f.pbase() == 4095);
+    }
+    {
+        std::ifstream bs("overflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.sgetc() == L'a');
+    }
+    std::remove("overflow.dat");
+    {
+        std::ofstream bs("overflow.dat");
+        test_buf f(bs.rdbuf());
+        f.pubsetbuf(0, 0);
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+        assert(f.overflow('a') == 'a');
+        assert(f.pbase() == 0);
+        assert(f.pptr() == 0);
+        assert(f.epptr() == 0);
+    }
+    {
+        std::ifstream bs("overflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.sgetc() == L'a');
+    }
+    std::remove("overflow.dat");
+    {
+        std::ofstream bs("overflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.sputc(0x4E51) == 0x4E51);
+        assert(f.sputc(0x4E52) == 0x4E52);
+        assert(f.sputc(0x4E53) == 0x4E53);
+    }
+    {
+        std::ifstream f("overflow.dat");
+        assert(f.is_open());
+        assert(f.get() == 0xE4);
+        assert(f.get() == 0xB9);
+        assert(f.get() == 0x91);
+        assert(f.get() == 0xE4);
+        assert(f.get() == 0xB9);
+        assert(f.get() == 0x92);
+        assert(f.get() == 0xE4);
+        assert(f.get() == 0xB9);
+        assert(f.get() == 0x93);
+        assert(f.get() == -1);
+    }
+    std::remove("overflow.dat");
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
new file mode 100644
index 0000000..bcfb16e
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// int_type pbackfail(int_type c = traits::eof());
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+struct test_buf
+    : public std::wbuffer_convert<std::codecvt_utf8<wchar_t> >
+{
+    typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > base;
+    typedef base::char_type   char_type;
+    typedef base::int_type    int_type;
+    typedef base::traits_type traits_type;
+
+    explicit test_buf(std::streambuf* sb) : base(sb) {}
+
+    char_type* eback() const {return base::eback();}
+    char_type* gptr()  const {return base::gptr();}
+    char_type* egptr() const {return base::egptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type pbackfail(int_type c = traits_type::eof()) {return base::pbackfail(c);}
+};
+
+int main()
+{
+    {
+        std::ifstream bs("underflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.sbumpc() == L'1');
+        assert(f.sgetc() == L'2');
+        assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
+    }
+    {
+        std::fstream bs("underflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.sbumpc() == L'1');
+        assert(f.sgetc() == L'2');
+        assert(f.pbackfail(L'a') == test_buf::traits_type::eof());
+        assert(f.sbumpc() == L'2');
+        assert(f.sgetc() == L'3');
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
new file mode 100644
index 0000000..ffd813f
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// streambuf *rdbuf(streambuf *bytebuf);
+
+#include <locale>
+#include <codecvt>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
+    {
+        std::stringstream s;
+        B b;
+        assert(b.rdbuf() == nullptr);
+        b.rdbuf(s.rdbuf());
+        assert(b.rdbuf() == s.rdbuf());
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
new file mode 100644
index 0000000..aa9d5e8
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// pos_type seekoff(off_type off, ios_base::seekdir way,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+// pos_type seekpos(pos_type sp,
+//                  ios_base::openmode which = ios_base::in | ios_base::out);
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+class test_codecvt
+    : public std::codecvt<wchar_t, char, std::mbstate_t>
+{
+    typedef std::codecvt<wchar_t, char, std::mbstate_t> base;
+public:
+    explicit test_codecvt(std::size_t refs = 0) : base(refs) {}
+    ~test_codecvt() {}
+};
+
+int main()
+{
+    {
+        wchar_t buf[10];
+        typedef std::wbuffer_convert<test_codecvt> test_buf;
+        typedef test_buf::pos_type pos_type;
+        std::fstream bs("seekoff.dat", std::ios::trunc | std::ios::in
+                                                       | std::ios::out);
+        test_buf f(bs.rdbuf());
+        f.pubsetbuf(buf, sizeof(buf)/sizeof(buf[0]));
+        f.sputn(L"abcdefghijklmnopqrstuvwxyz", 26);
+        assert(buf[0] == L'v');
+        pos_type p = f.pubseekoff(-15, std::ios_base::cur);
+        assert(p == 11);
+        assert(f.sgetc() == L'l');
+        f.pubseekoff(0, std::ios_base::beg);
+        assert(f.sgetc() == L'a');
+        f.pubseekoff(-1, std::ios_base::end);
+        assert(f.sgetc() == L'z');
+        assert(f.pubseekpos(p) == p);
+        assert(f.sgetc() == L'l');
+    }
+    std::remove("seekoff.dat");
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
new file mode 100644
index 0000000..6abf5ce
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// state_type state() const;
+
+#include <locale>
+#include <codecvt>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > B;
+    {
+        B b;
+        std::mbstate_t s = b.state();
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
new file mode 100644
index 0000000..189ec2b
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+#include <fstream>
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        std::ofstream bytestream("myfile.txt");
+        std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
+        std::wostream mystr(&mybuf);
+        mystr << L"Hello" << std::endl;
+    }
+    {
+        std::ifstream bytestream("myfile.txt");
+        std::wbuffer_convert<std::codecvt_utf8<wchar_t> > mybuf(bytestream.rdbuf());
+        std::wistream mystr(&mybuf);
+        std::wstring ws;
+        mystr >> ws;
+        assert(ws == L"Hello");
+    }
+    std::remove("myfile.txt");
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat
new file mode 100644
index 0000000..e2e107a
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.dat
@@ -0,0 +1 @@
+123456789
\ No newline at end of file
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
new file mode 100644
index 0000000..9c08a35
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wbuffer_convert<Codecvt, Elem, Tr>
+
+// int_type underflow();
+
+// This test is not entirely portable
+
+#include <locale>
+#include <codecvt>
+#include <fstream>
+#include <cassert>
+
+struct test_buf
+    : public std::wbuffer_convert<std::codecvt_utf8<wchar_t> >
+{
+    typedef std::wbuffer_convert<std::codecvt_utf8<wchar_t> > base;
+    typedef base::char_type   char_type;
+    typedef base::int_type    int_type;
+    typedef base::traits_type traits_type;
+
+    explicit test_buf(std::streambuf* sb) : base(sb) {}
+
+    char_type* eback() const {return base::eback();}
+    char_type* gptr()  const {return base::gptr();}
+    char_type* egptr() const {return base::egptr();}
+    void gbump(int n) {base::gbump(n);}
+
+    virtual int_type underflow() {return base::underflow();}
+};
+
+int main()
+{
+    {
+        std::ifstream bs("underflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == L'1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == L'1');
+        assert(f.egptr() - f.eback() == 9);
+    }
+    {
+        std::ifstream bs("underflow.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.eback() == 0);
+        assert(f.gptr() == 0);
+        assert(f.egptr() == 0);
+        assert(f.underflow() == L'1');
+        assert(f.eback() != 0);
+        assert(f.eback() == f.gptr());
+        assert(*f.gptr() == L'1');
+        assert(f.egptr() - f.eback() == 9);
+        f.gbump(8);
+        assert(f.sgetc() == L'9');
+        assert(f.eback()[0] == L'1');
+        assert(f.eback()[1] == L'2');
+        assert(f.eback()[2] == L'3');
+        assert(f.eback()[3] == L'4');
+        assert(f.gptr() - f.eback() == 8);
+        assert(*f.gptr() == L'9');
+        assert(f.egptr() - f.gptr() == 1);
+    }
+    {
+        std::ifstream bs("underflow_utf8.dat");
+        test_buf f(bs.rdbuf());
+        assert(f.sbumpc() == 0x4E51);
+        assert(f.sbumpc() == 0x4E52);
+        assert(f.sbumpc() == 0x4E53);
+        assert(f.sbumpc() == test_buf::traits_type::eof());
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat
new file mode 100644
index 0000000..ee7063e
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.buffer/underflow_utf8.dat
@@ -0,0 +1 @@
+乑乒乓
\ No newline at end of file
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp
new file mode 100644
index 0000000..8c66ad1
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.character/tolower.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> charT tolower(charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(std::tolower(' ', l) == ' ');
+    assert(std::tolower('<', l) == '<');
+    assert(std::tolower('\x8', l) == '\x8');
+    assert(std::tolower('A', l) == 'a');
+    assert(std::tolower('a', l) == 'a');
+    assert(std::tolower('z', l) == 'z');
+    assert(std::tolower('3', l) == '3');
+    assert(std::tolower('.', l) == '.');
+    assert(std::tolower('f', l) == 'f');
+    assert(std::tolower('9', l) == '9');
+    assert(std::tolower('+', l) == '+');
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp
new file mode 100644
index 0000000..3299a3d
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.character/toupper.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT> charT toupper(charT c, const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    std::locale l;
+    assert(std::toupper(' ', l) == ' ');
+    assert(std::toupper('<', l) == '<');
+    assert(std::toupper('\x8', l) == '\x8');
+    assert(std::toupper('A', l) == 'A');
+    assert(std::toupper('a', l) == 'A');
+    assert(std::toupper('z', l) == 'Z');
+    assert(std::toupper('3', l) == '3');
+    assert(std::toupper('.', l) == '.');
+    assert(std::toupper('f', l) == 'F');
+    assert(std::toupper('9', l) == '9');
+    assert(std::toupper('+', l) == '+');
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
new file mode 100644
index 0000000..06df185
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// size_t converted() const;
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    typedef std::codecvt_utf8<wchar_t> Codecvt;
+    typedef std::wstring_convert<Codecvt> Myconv;
+    Myconv myconv;
+    assert(myconv.converted() == 0);
+    std::string bs = myconv.to_bytes(L"\x40003");
+    assert(myconv.converted() == 1);
+    bs = myconv.to_bytes(L"\x40003\x65");
+    assert(myconv.converted() == 2);
+    std::wstring ws = myconv.from_bytes("\xF1\x80\x80\x83");
+    assert(myconv.converted() == 4);
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
new file mode 100644
index 0000000..9099b5e
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wstring_convert(Codecvt* pcvt = new Codecvt);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> Codecvt;
+        typedef std::wstring_convert<Codecvt> Myconv;
+        Myconv myconv;
+        assert(myconv.converted() == 0);
+    }
+    {
+        typedef std::codecvt_utf8<wchar_t> Codecvt;
+        typedef std::wstring_convert<Codecvt> Myconv;
+        Myconv myconv(new Codecvt);
+        assert(myconv.converted() == 0);
+#if _LIBCPP_STD_VER > 11
+        static_assert(!std::is_convertible<Codecvt*, Myconv>::value, "");
+        static_assert( std::is_constructible<Myconv, Codecvt*>::value, "");
+#endif
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
new file mode 100644
index 0000000..7651f8a
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wstring_convert(Codecvt* pcvt, state_type state);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::codecvt_utf8<wchar_t> Codecvt;
+        typedef std::wstring_convert<Codecvt> Myconv;
+        Myconv myconv(new Codecvt, std::mbstate_t());
+        assert(myconv.converted() == 0);
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
new file mode 100644
index 0000000..27a3da7
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wstring_convert(const byte_string& byte_err,
+//                 const wide_string& wide_err = wide_string());
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    typedef std::codecvt_utf8<wchar_t> Codecvt;
+    typedef std::wstring_convert<Codecvt> Myconv;
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_convertible<std::string, Myconv>::value, "");
+    static_assert( std::is_constructible<Myconv, std::string>::value, "");
+#endif
+    {
+        Myconv myconv;
+        try
+        {
+            myconv.to_bytes(L"\xDA83");
+            assert(false);
+        }
+        catch (const std::range_error&)
+        {
+        }
+        try
+        {
+            myconv.from_bytes('\xA5');
+            assert(false);
+        }
+        catch (const std::range_error&)
+        {
+        }
+    }
+    {
+        Myconv myconv("byte error");
+        std::string bs = myconv.to_bytes(L"\xDA83");
+        assert(bs == "byte error");
+        try
+        {
+            myconv.from_bytes('\xA5');
+            assert(false);
+        }
+        catch (const std::range_error&)
+        {
+        }
+    }
+    {
+        Myconv myconv("byte error", L"wide error");
+        std::string bs = myconv.to_bytes(L"\xDA83");
+        assert(bs == "byte error");
+        std::wstring ws = myconv.from_bytes('\xA5');
+        assert(ws == L"wide error");
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
new file mode 100644
index 0000000..8705a5f
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// wide_string from_bytes(char byte);
+// wide_string from_bytes(const char* ptr);
+// wide_string from_bytes(const byte_string& str);
+// wide_string from_bytes(const char* first, const char* last);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
+        std::string bs("\xF1\x80\x80\x83");
+        std::wstring ws = myconv.from_bytes('a');
+        assert(ws == L"a");
+        ws = myconv.from_bytes(bs.c_str());
+        assert(ws == L"\x40003");
+        ws = myconv.from_bytes(bs);
+        assert(ws == L"\x40003");
+        ws = myconv.from_bytes(bs.data(), bs.data() + bs.size());
+        assert(ws == L"\x40003");
+        ws = myconv.from_bytes("");
+        assert(ws.size() == 0);
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
new file mode 100644
index 0000000..08dfa25
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// state_type state() const;
+
+#include <locale>
+#include <codecvt>
+
+int main()
+{
+    typedef std::codecvt_utf8<wchar_t> Codecvt;
+    typedef std::wstring_convert<Codecvt> Myconv;
+    Myconv myconv;
+    std::mbstate_t s = myconv.state();
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
new file mode 100644
index 0000000..7253a18
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc>
+
+// byte_string to_bytes(Elem wchar);
+// byte_string to_bytes(const Elem* wptr);
+// byte_string to_bytes(const wide_string& wstr);
+// byte_string to_bytes(const Elem* first, const Elem* last);
+
+#include <locale>
+#include <codecvt>
+#include <cassert>
+
+int main()
+{
+    {
+        std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
+        std::wstring ws(1, L'\x40003');
+        std::string bs = myconv.to_bytes(ws[0]);
+        assert(bs == "\xF1\x80\x80\x83");
+        bs = myconv.to_bytes(ws.c_str());
+        assert(bs == "\xF1\x80\x80\x83");
+        bs = myconv.to_bytes(ws);
+        assert(bs == "\xF1\x80\x80\x83");
+        bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
+        assert(bs == "\xF1\x80\x80\x83");
+        bs = myconv.to_bytes(L"");
+        assert(bs.size() == 0);
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
new file mode 100644
index 0000000..d46c858
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template<class Codecvt, class Elem = wchar_t,
+//          class Wide_alloc = allocator<Elem>,
+//          class Byte_alloc = allocator<char>>
+// class wstring_convert
+// {
+// public:
+//     typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string;
+//     typedef basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
+//     typedef typename Codecvt::state_type                      state_type;
+//     typedef typename wide_string::traits_type::int_type       int_type;
+
+#include <locale>
+#include <codecvt>
+
+int main()
+{
+    {
+        typedef std::wstring_convert<std::codecvt_utf8<wchar_t> > myconv;
+        static_assert((std::is_same<myconv::byte_string, std::string>::value), "");
+        static_assert((std::is_same<myconv::wide_string, std::wstring>::value), "");
+        static_assert((std::is_same<myconv::state_type, std::mbstate_t>::value), "");
+        static_assert((std::is_same<myconv::int_type, std::char_traits<wchar_t>::int_type>::value), "");
+    }
+}
diff --git a/final/test/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp b/final/test/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/conversions/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locales/locale.convenience/nothing_to_do.pass.cpp b/final/test/localization/locales/locale.convenience/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locales/locale.convenience/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locales/locale.global.templates/has_facet.pass.cpp b/final/test/localization/locales/locale.global.templates/has_facet.pass.cpp
new file mode 100644
index 0000000..58767f0
--- /dev/null
+++ b/final/test/localization/locales/locale.global.templates/has_facet.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> bool has_facet(const locale& loc) throw();
+
+#include <locale>
+#include <cassert>
+
+struct my_facet
+    : public std::locale::facet
+{
+    static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+    std::locale loc;
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(!std::has_facet<my_facet>(loc));
+    std::locale loc2(loc, new my_facet);
+    assert(std::has_facet<my_facet>(loc2));
+}
diff --git a/final/test/localization/locales/locale.global.templates/use_facet.pass.cpp b/final/test/localization/locales/locale.global.templates/use_facet.pass.cpp
new file mode 100644
index 0000000..a40a2d2
--- /dev/null
+++ b/final/test/localization/locales/locale.global.templates/use_facet.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> const Facet& use_facet(const locale& loc);
+
+#include <locale>
+#include <cassert>
+
+int facet_count = 0;
+
+struct my_facet
+    : public std::locale::facet
+{
+    static std::locale::id id;
+
+    bool im_alive;
+
+    my_facet() : im_alive(true) {++facet_count;}
+    ~my_facet() {im_alive = false; --facet_count;}
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+    try
+    {
+        const my_facet& f = std::use_facet<my_facet>(std::locale());
+        assert(false);
+    }
+    catch (std::bad_cast&)
+    {
+    }
+    const my_facet* fp = 0;
+    {
+        std::locale loc(std::locale(), new my_facet);
+        const my_facet& f = std::use_facet<my_facet>(loc);
+        assert(f.im_alive);
+        fp = &f;
+        assert(fp->im_alive);
+        assert(facet_count == 1);
+    }
+    assert(facet_count == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/assign.pass.cpp b/final/test/localization/locales/locale/locale.cons/assign.pass.cpp
new file mode 100644
index 0000000..c894b62
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/assign.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// const locale& operator=(const locale& other) throw();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(LOCALE_ru_RU_UTF_8);
+        std::locale loc2;
+        loc2 = loc;
+        assert(loc == loc2);
+        check(loc);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/char_pointer.pass.cpp b/final/test/localization/locales/locale/locale.cons/char_pointer.pass.cpp
new file mode 100644
index 0000000..d279bf0
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/char_pointer.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// explicit locale(const char* std_name);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(LOCALE_ru_RU_UTF_8);
+        check(loc);
+        std::locale loc2(LOCALE_ru_RU_UTF_8);
+        check(loc2);
+        assert(loc == loc2);
+        std::locale loc3(LOCALE_zh_CN_UTF_8);
+        check(loc3);
+        assert(!(loc == loc3));
+        assert(loc != loc3);
+        try
+        {
+            std::locale((const char*)0);
+            assert(false);
+        }
+        catch (std::runtime_error&)
+        {
+        }
+        try
+        {
+            std::locale("spazbot");
+            assert(false);
+        }
+        catch (std::runtime_error&)
+        {
+        }
+        std::locale ok("");
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/copy.pass.cpp b/final/test/localization/locales/locale/locale.cons/copy.pass.cpp
new file mode 100644
index 0000000..73ef24b
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/copy.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other) throw();
+
+#include <locale>
+#include <cassert>
+#include <new>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(LOCALE_fr_FR_UTF_8);
+        std::locale loc2 = loc;
+        assert(loc == loc2);
+        check(loc);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/default.pass.cpp b/final/test/localization/locales/locale/locale.cons/default.pass.cpp
new file mode 100644
index 0000000..0d46a76
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/default.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale() throw();
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    int ok;
+    {
+        std::locale loc;
+        assert(new_called == 0);
+        assert(loc.name() == "C");
+        assert(new_called == 0);
+        check(loc);
+        assert(new_called == 0);
+        assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc);
+        ok = new_called;
+        std::locale loc2;
+        assert(new_called == ok);
+        check(loc2);
+        assert(new_called == ok);
+        assert(loc2 == std::locale(LOCALE_en_US_UTF_8));
+        assert(new_called == ok);
+    }
+    assert(new_called == ok);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp b/final/test/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp
new file mode 100644
index 0000000..f5b959a
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other, const char* std_name, category);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(LOCALE_ru_RU_UTF_8);
+        check(loc);
+        std::locale loc2(loc, LOCALE_en_US_UTF_8, std::locale::monetary);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp b/final/test/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp
new file mode 100644
index 0000000..cbf6185
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> locale(const locale& other, Facet* f);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+struct my_facet
+    : public std::locale::facet
+{
+    int test() const {return 5;}
+
+    static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+{
+    {
+        std::locale loc(LOCALE_ru_RU_UTF_8);
+        check(loc);
+        std::locale loc2(loc, new my_facet);
+        check(loc2);
+        assert((std::has_facet<my_facet>(loc2)));
+        const my_facet& f = std::use_facet<my_facet>(loc2);
+        assert(f.test() == 5);
+    }
+    assert(new_called == 0);
+}
+{
+    {
+        std::locale loc;
+        check(loc);
+        std::locale loc2(loc, (std::ctype<char>*)0);
+        check(loc2);
+        assert(loc == loc2);
+    }
+    assert(new_called == 0);
+}
+}
diff --git a/final/test/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp b/final/test/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp
new file mode 100644
index 0000000..87041a2
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other, const locale& one, category cats);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(LOCALE_ru_RU_UTF_8);
+        check(loc);
+        std::locale loc2(loc, std::locale(LOCALE_en_US_UTF_8), std::locale::monetary);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp b/final/test/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp
new file mode 100644
index 0000000..5774097
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// locale(const locale& other, const string& std_name, category cat);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(LOCALE_ru_RU_UTF_8);
+        check(loc);
+        std::locale loc2(loc, std::string(LOCALE_en_US_UTF_8), std::locale::monetary);
+        check(loc2);
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.cons/string.pass.cpp b/final/test/localization/locales/locale/locale.cons/string.pass.cpp
new file mode 100644
index 0000000..55694be
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.cons/string.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// explicit locale(const string& std_name);
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    {
+        std::locale loc(std::string(LOCALE_ru_RU_UTF_8));
+        check(loc);
+        std::locale loc2(std::string(LOCALE_ru_RU_UTF_8));
+        check(loc2);
+        assert(loc == loc2);
+        std::locale loc3(std::string(LOCALE_zh_CN_UTF_8));
+        check(loc3);
+        assert(!(loc == loc3));
+        assert(loc != loc3);
+    }
+    assert(new_called == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.members/combine.pass.cpp b/final/test/localization/locales/locale/locale.members/combine.pass.cpp
new file mode 100644
index 0000000..8d74da0
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.members/combine.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class Facet> locale combine(const locale& other) const;
+
+#include <locale>
+#include <new>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+struct my_facet
+    : public std::locale::facet
+{
+    int test() const {return 5;}
+
+    static std::locale::id id;
+};
+
+std::locale::id my_facet::id;
+
+int main()
+{
+{
+    {
+        std::locale loc;
+        std::locale loc2(loc, new my_facet);
+        std::locale loc3 = loc.combine<my_facet>(loc2);
+        check(loc3);
+        assert(loc3.name() == "*");
+        assert((std::has_facet<my_facet>(loc3)));
+        const my_facet& f = std::use_facet<my_facet>(loc3);
+        assert(f.test() == 5);
+    }
+    assert(new_called == 0);
+}
+{
+    {
+        std::locale loc;
+        std::locale loc2;
+        try
+        {
+            std::locale loc3 = loc.combine<my_facet>(loc2);
+            assert(false);
+        }
+        catch (std::runtime_error&)
+        {
+        }
+    }
+    assert(new_called == 0);
+}
+}
diff --git a/final/test/localization/locales/locale/locale.members/name.pass.cpp b/final/test/localization/locales/locale/locale.members/name.pass.cpp
new file mode 100644
index 0000000..9d9b142
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.members/name.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// basic_string<char> name() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::locale loc;
+        assert(loc.name() == "C");
+    }
+    {
+        std::locale loc(LOCALE_en_US_UTF_8);
+        assert(loc.name() == LOCALE_en_US_UTF_8);
+    }
+}
diff --git a/final/test/localization/locales/locale/locale.operators/compare.pass.cpp b/final/test/localization/locales/locale/locale.operators/compare.pass.cpp
new file mode 100644
index 0000000..4074052
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.operators/compare.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// template <class charT, class Traits, class Allocator>
+//   bool operator()(const basic_string<charT,Traits,Allocator>& s1,
+//                   const basic_string<charT,Traits,Allocator>& s2) const;
+
+#include <locale>
+#include <cassert>
+
+int main()
+{
+    {
+        std::locale l;
+        {
+            std::string s2("aaaaaaA");
+            std::string s3("BaaaaaA");
+            assert(l(s3, s2));
+        }
+        {
+            std::wstring s2(L"aaaaaaA");
+            std::wstring s3(L"BaaaaaA");
+            assert(l(s3, s2));
+        }
+    }
+}
diff --git a/final/test/localization/locales/locale/locale.operators/eq.pass.cpp b/final/test/localization/locales/locale/locale.operators/eq.pass.cpp
new file mode 100644
index 0000000..ec118e0
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.operators/eq.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// basic_string<char> name() const;
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    std::locale cloc;
+    std::locale copy(cloc);
+    std::locale n1(LOCALE_en_US_UTF_8);
+    std::locale n2(LOCALE_en_US_UTF_8);
+    std::locale noname1 = n1.combine<std::ctype<char> >(cloc);
+    std::locale nonamec = noname1;
+    std::locale noname2 = n1.combine<std::ctype<char> >(cloc);
+
+    assert(cloc == cloc);
+    assert(cloc == copy);
+    assert(cloc != n1);
+    assert(cloc != n2);
+    assert(cloc != noname1);
+    assert(cloc != nonamec);
+    assert(cloc != noname2);
+
+    assert(copy == cloc);
+    assert(copy == copy);
+    assert(copy != n1);
+    assert(copy != n2);
+    assert(copy != noname1);
+    assert(copy != nonamec);
+    assert(copy != noname2);
+
+    assert(n1 != cloc);
+    assert(n1 != copy);
+    assert(n1 == n1);
+    assert(n1 == n2);
+    assert(n1 != noname1);
+    assert(n1 != nonamec);
+    assert(n1 != noname2);
+
+    assert(n2 != cloc);
+    assert(n2 != copy);
+    assert(n2 == n1);
+    assert(n2 == n2);
+    assert(n2 != noname1);
+    assert(n2 != nonamec);
+    assert(n2 != noname2);
+
+    assert(noname1 != cloc);
+    assert(noname1 != copy);
+    assert(noname1 != n1);
+    assert(noname1 != n2);
+    assert(noname1 == noname1);
+    assert(noname1 == nonamec);
+    assert(noname1 != noname2);
+
+    assert(nonamec != cloc);
+    assert(nonamec != copy);
+    assert(nonamec != n1);
+    assert(nonamec != n2);
+    assert(nonamec == noname1);
+    assert(nonamec == nonamec);
+    assert(nonamec != noname2);
+
+    assert(noname2 != cloc);
+    assert(noname2 != copy);
+    assert(noname2 != n1);
+    assert(noname2 != n2);
+    assert(noname2 != noname1);
+    assert(noname2 != nonamec);
+    assert(noname2 == noname2);
+}
diff --git a/final/test/localization/locales/locale/locale.statics/classic.pass.cpp b/final/test/localization/locales/locale/locale.statics/classic.pass.cpp
new file mode 100644
index 0000000..078030c
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.statics/classic.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// static const locale& classic();
+
+#include <locale>
+#include <cassert>
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    std::locale loc = std::locale::classic();
+    assert(loc.name() == "C");
+    assert(loc == std::locale("C"));
+    check(loc);
+    check(std::locale("C"));
+}
diff --git a/final/test/localization/locales/locale/locale.statics/global.pass.cpp b/final/test/localization/locales/locale/locale.statics/global.pass.cpp
new file mode 100644
index 0000000..59a6bc6
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.statics/global.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// static const locale& classic();
+
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+void check(const std::locale& loc)
+{
+    assert(std::has_facet<std::collate<char> >(loc));
+    assert(std::has_facet<std::collate<wchar_t> >(loc));
+
+    assert(std::has_facet<std::ctype<char> >(loc));
+    assert(std::has_facet<std::ctype<wchar_t> >(loc));
+    assert((std::has_facet<std::codecvt<char, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char16_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<char32_t, char, std::mbstate_t> >(loc)));
+    assert((std::has_facet<std::codecvt<wchar_t, char, std::mbstate_t> >(loc)));
+
+    assert((std::has_facet<std::moneypunct<char> >(loc)));
+    assert((std::has_facet<std::moneypunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_get<char> >(loc)));
+    assert((std::has_facet<std::money_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::money_put<char> >(loc)));
+    assert((std::has_facet<std::money_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::numpunct<char> >(loc)));
+    assert((std::has_facet<std::numpunct<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_get<char> >(loc)));
+    assert((std::has_facet<std::num_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::num_put<char> >(loc)));
+    assert((std::has_facet<std::num_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::time_get<char> >(loc)));
+    assert((std::has_facet<std::time_get<wchar_t> >(loc)));
+    assert((std::has_facet<std::time_put<char> >(loc)));
+    assert((std::has_facet<std::time_put<wchar_t> >(loc)));
+
+    assert((std::has_facet<std::messages<char> >(loc)));
+    assert((std::has_facet<std::messages<wchar_t> >(loc)));
+}
+
+int main()
+{
+    std::locale loc;
+    assert(loc.name() == "C");
+    check(loc);
+    assert(std::locale::global(std::locale(LOCALE_en_US_UTF_8)) == loc);
+    std::locale loc2;
+    check(loc2);
+    assert(loc2 == std::locale(LOCALE_en_US_UTF_8));
+}
diff --git a/final/test/localization/locales/locale/locale.types/locale.category/category.pass.cpp b/final/test/localization/locales/locale/locale.types/locale.category/category.pass.cpp
new file mode 100644
index 0000000..399e4e8
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.types/locale.category/category.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <locale>
+
+// typedef int category;
+
+#include <locale>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+
+int main()
+{
+    static_assert((std::is_same<std::locale::category, int>::value), "");
+    assert(std::locale::none == 0);
+    assert(std::locale::collate);
+    assert(std::locale::ctype);
+    assert(std::locale::monetary);
+    assert(std::locale::numeric);
+    assert(std::locale::time);
+    assert(std::locale::messages);
+    assert((std::locale::collate
+          & std::locale::ctype
+          & std::locale::monetary
+          & std::locale::numeric
+          & std::locale::time
+          & std::locale::messages) == 0);
+    assert((std::locale::collate
+          | std::locale::ctype
+          | std::locale::monetary
+          | std::locale::numeric
+          | std::locale::time
+          | std::locale::messages)
+         == std::locale::all);
+
+    test(std::locale::none);
+    test(std::locale::collate);
+    test(std::locale::ctype);
+    test(std::locale::monetary);
+    test(std::locale::numeric);
+    test(std::locale::time);
+    test(std::locale::messages);
+    test(std::locale::all);
+}
diff --git a/final/test/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/final/test/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
new file mode 100644
index 0000000..4a7f77a
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::facet
+// {
+// protected:
+//     explicit facet(size_t refs = 0);
+//     virtual ~facet();
+//     facet(const facet&) = delete;
+//     void operator=(const facet&) = delete;
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+struct my_facet
+    : public std::locale::facet
+{
+    static int count;
+    my_facet(unsigned refs = 0)
+        : std::locale::facet(refs)
+        {++count;}
+
+    ~my_facet() {--count;}
+};
+
+int my_facet::count = 0;
+
+int main()
+{
+    my_facet* f = new my_facet;
+    f->__add_shared();
+    assert(my_facet::count == 1);
+    f->__release_shared();
+    assert(my_facet::count == 0);
+    f = new my_facet(1);
+    f->__add_shared();
+    assert(my_facet::count == 1);
+    f->__release_shared();
+    assert(my_facet::count == 1);
+    f->__release_shared();
+    assert(my_facet::count == 0);
+}
diff --git a/final/test/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/final/test/localization/locales/locale/locale.types/locale.id/id.pass.cpp
new file mode 100644
index 0000000..3233624
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.types/locale.id/id.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+// class locale::id
+// {
+// public:
+//     id();
+//     void operator=(const id&) = delete;
+//     id(const id&) = delete;
+// };
+
+// This test isn't portable
+
+#include <locale>
+#include <cassert>
+
+std::locale::id id0;
+std::locale::id id2;
+std::locale::id id1;
+
+int main()
+{
+    long id = id0.__get();
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id0.__get() == id+0);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id1.__get() == id+1);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+    assert(id2.__get() == id+2);
+}
diff --git a/final/test/localization/locales/locale/locale.types/nothing_to_do.pass.cpp b/final/test/localization/locales/locale/locale.types/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locales/locale/locale.types/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locales/locale/nothing_to_do.pass.cpp b/final/test/localization/locales/locale/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locales/locale/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/locales/nothing_to_do.pass.cpp b/final/test/localization/locales/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/locales/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/localization.general/nothing_to_do.pass.cpp b/final/test/localization/localization.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/localization/localization.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/localization/version.pass.cpp b/final/test/localization/version.pass.cpp
new file mode 100644
index 0000000..a64534c
--- /dev/null
+++ b/final/test/localization/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <locale>
+
+#include <locale>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/nothing_to_do.pass.cpp b/final/test/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/c.math/cmath.pass.cpp b/final/test/numerics/c.math/cmath.pass.cpp
new file mode 100644
index 0000000..7c74d5b
--- /dev/null
+++ b/final/test/numerics/c.math/cmath.pass.cpp
@@ -0,0 +1,1365 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+#include <cmath>
+#include <type_traits>
+#include <cassert>
+
+#include "hexfloat.h"
+
+// convertible to int/float/double/etc
+template <class T, int N=0>
+struct Value {
+    operator T () { return T(N); }
+};
+
+void test_abs()
+{
+    static_assert((std::is_same<decltype(std::abs((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::abs((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::abs((long double)0)), long double>::value), "");
+    assert(std::abs(-1.) == 1);
+}
+
+void test_acos()
+{
+    static_assert((std::is_same<decltype(std::acos((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acos((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acos((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::acosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acosl(0)), long double>::value), "");
+    assert(std::acos(1) == 0);
+}
+
+void test_asin()
+{
+    static_assert((std::is_same<decltype(std::asin((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asin((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asin((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::asinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asinl(0)), long double>::value), "");
+    assert(std::asin(0) == 0);
+}
+
+void test_atan()
+{
+    static_assert((std::is_same<decltype(std::atan((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atan((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atanl(0)), long double>::value), "");
+    assert(std::atan(0) == 0);
+}
+
+void test_atan2()
+{
+    static_assert((std::is_same<decltype(std::atan2((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2f(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atan2l(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atan2((int)0, (int)0)), double>::value), "");
+    assert(std::atan2(0,1) == 0);
+}
+
+void test_ceil()
+{
+    static_assert((std::is_same<decltype(std::ceil((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ceil((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::ceilf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ceill(0)), long double>::value), "");
+    assert(std::ceil(0) == 0);
+}
+
+void test_cos()
+{
+    static_assert((std::is_same<decltype(std::cos((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cos((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cos((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::cosf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cosl(0)), long double>::value), "");
+    assert(std::cos(0) == 1);
+}
+
+void test_cosh()
+{
+    static_assert((std::is_same<decltype(std::cosh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cosh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::coshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::coshl(0)), long double>::value), "");
+    assert(std::cosh(0) == 1);
+}
+
+void test_exp()
+{
+    static_assert((std::is_same<decltype(std::exp((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::exp((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::expf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::expl(0)), long double>::value), "");
+    assert(std::exp(0) == 1);
+}
+
+void test_fabs()
+{
+    static_assert((std::is_same<decltype(std::fabs((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fabs((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fabsf(0.0f)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fabsl(0.0L)), long double>::value), "");
+    assert(std::fabs(-1) == 1);
+}
+
+void test_floor()
+{
+    static_assert((std::is_same<decltype(std::floor((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::floor((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::floor((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::floorf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::floorl(0)), long double>::value), "");
+    assert(std::floor(1) == 1);
+}
+
+void test_fmod()
+{
+    static_assert((std::is_same<decltype(std::fmod((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmodf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmodl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmod((int)0, (int)0)), double>::value), "");
+    assert(std::fmod(1.5,1) == .5);
+}
+
+void test_frexp()
+{
+    int ip;
+    static_assert((std::is_same<decltype(std::frexp((float)0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((bool)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned short)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((int)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned int)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((unsigned long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::frexp((long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::frexpf(0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::frexpl(0, &ip)), long double>::value), "");
+    assert(std::frexp(0, &ip) == 0);
+}
+
+void test_ldexp()
+{
+    int ip = 1;
+    static_assert((std::is_same<decltype(std::ldexp((float)0, ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((bool)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned short)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((int)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned int)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((long long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((unsigned long long)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((double)0, ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexp((long double)0, ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::ldexpf(0, ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::ldexpl(0, ip)), long double>::value), "");
+    assert(std::ldexp(1, ip) == 2);
+}
+
+void test_log()
+{
+    static_assert((std::is_same<decltype(std::log((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::logf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::logl(0)), long double>::value), "");
+    assert(std::log(1) == 0);
+}
+
+void test_log10()
+{
+    static_assert((std::is_same<decltype(std::log10((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log10((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log10((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::log10f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log10l(0)), long double>::value), "");
+    assert(std::log10(1) == 0);
+}
+
+void test_modf()
+{
+    static_assert((std::is_same<decltype(std::modf((float)0, (float*)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::modf((double)0, (double*)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::modf((long double)0, (long double*)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::modff(0, (float*)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::modfl(0, (long double*)0)), long double>::value), "");
+    double i;
+    assert(std::modf(1., &i) == 0);
+}
+
+void test_pow()
+{
+    static_assert((std::is_same<decltype(std::pow((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::pow((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::powf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::powl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::pow((int)0, (int)0)), double>::value), "");
+//     static_assert((std::is_same<decltype(std::pow(Value<int>(), (int)0)), double>::value), "");
+//     static_assert((std::is_same<decltype(std::pow(Value<long double>(), (float)0)), long double>::value), "");
+//     static_assert((std::is_same<decltype(std::pow((float) 0, Value<float>())), float>::value), "");
+    assert(std::pow(1,1) == 1);
+//     assert(std::pow(Value<int,1>(), Value<float,1>())  == 1);
+//     assert(std::pow(1.0f, Value<double,1>()) == 1);
+//     assert(std::pow(1.0, Value<int,1>()) == 1);
+//     assert(std::pow(Value<long double,1>(), 1LL) == 1);
+}
+
+void test_sin()
+{
+    static_assert((std::is_same<decltype(std::sin((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sin((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sin((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::sinf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sinl(0)), long double>::value), "");
+    assert(std::sin(0) == 0);
+}
+
+void test_sinh()
+{
+    static_assert((std::is_same<decltype(std::sinh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sinh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::sinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sinhl(0)), long double>::value), "");
+    assert(std::sinh(0) == 0);
+}
+
+void test_sqrt()
+{
+    static_assert((std::is_same<decltype(std::sqrt((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrt((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::sqrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::sqrtl(0)), long double>::value), "");
+    assert(std::sqrt(4) == 2);
+}
+
+void test_tan()
+{
+    static_assert((std::is_same<decltype(std::tan((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tan((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tan((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::tanf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tanl(0)), long double>::value), "");
+    assert(std::tan(0) == 0);
+}
+
+void test_tanh()
+{
+    static_assert((std::is_same<decltype(std::tanh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tanh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::tanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tanhl(0)), long double>::value), "");
+    assert(std::tanh(0) == 0);
+}
+
+void test_signbit()
+{
+#ifdef signbit
+#error signbit defined
+#endif
+    static_assert((std::is_same<decltype(std::signbit((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::signbit((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::signbit(0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::signbit((long double)0)), bool>::value), "");
+    assert(std::signbit(-1.0) == true);
+}
+
+void test_fpclassify()
+{
+#ifdef fpclassify
+#error fpclassify defined
+#endif
+    static_assert((std::is_same<decltype(std::fpclassify((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fpclassify((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fpclassify(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fpclassify((long double)0)), int>::value), "");
+    assert(std::fpclassify(-1.0) == FP_NORMAL);
+}
+
+void test_isfinite()
+{
+#ifdef isfinite
+#error isfinite defined
+#endif
+    static_assert((std::is_same<decltype(std::isfinite((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isfinite((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isfinite(0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isfinite((long double)0)), bool>::value), "");
+    assert(std::isfinite(-1.0) == true);
+}
+
+void test_isinf()
+{
+#ifdef isinf
+#error isinf defined
+#endif
+    static_assert((std::is_same<decltype(std::isinf((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isinf((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isinf(0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isinf((long double)0)), bool>::value), "");
+    assert(std::isinf(-1.0) == false);
+}
+
+void test_isnan()
+{
+#ifdef isnan
+#error isnan defined
+#endif
+    static_assert((std::is_same<decltype(std::isnan((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnan((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnan(0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnan((long double)0)), bool>::value), "");
+    assert(std::isnan(-1.0) == false);
+}
+
+void test_isnormal()
+{
+#ifdef isnormal
+#error isnormal defined
+#endif
+    static_assert((std::is_same<decltype(std::isnormal((float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnormal((double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnormal(0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isnormal((long double)0)), bool>::value), "");
+    assert(std::isnormal(-1.0) == true);
+}
+
+void test_isgreater()
+{
+#ifdef isgreater
+#error isgreater defined
+#endif
+    static_assert((std::is_same<decltype(std::isgreater((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater(0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreater((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isgreater(-1.0, 0.F) == false);
+}
+
+void test_isgreaterequal()
+{
+#ifdef isgreaterequal
+#error isgreaterequal defined
+#endif
+    static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal(0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isgreaterequal((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isgreaterequal(-1.0, 0.F) == false);
+}
+
+void test_isless()
+{
+#ifdef isless
+#error isless defined
+#endif
+    static_assert((std::is_same<decltype(std::isless((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless(0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isless((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isless(-1.0, 0.F) == true);
+}
+
+void test_islessequal()
+{
+#ifdef islessequal
+#error islessequal defined
+#endif
+    static_assert((std::is_same<decltype(std::islessequal((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal(0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessequal((long double)0, (long double)0)), bool>::value), "");
+    assert(std::islessequal(-1.0, 0.F) == true);
+}
+
+void test_islessgreater()
+{
+#ifdef islessgreater
+#error islessgreater defined
+#endif
+    static_assert((std::is_same<decltype(std::islessgreater((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater(0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::islessgreater((long double)0, (long double)0)), bool>::value), "");
+    assert(std::islessgreater(-1.0, 0.F) == true);
+}
+
+void test_isunordered()
+{
+#ifdef isunordered
+#error isunordered defined
+#endif
+    static_assert((std::is_same<decltype(std::isunordered((float)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((float)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((float)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered(0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((double)0, (long double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((long double)0, (float)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((long double)0, (double)0)), bool>::value), "");
+    static_assert((std::is_same<decltype(std::isunordered((long double)0, (long double)0)), bool>::value), "");
+    assert(std::isunordered(-1.0, 0.F) == false);
+}
+
+void test_acosh()
+{
+    static_assert((std::is_same<decltype(std::acosh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::acosh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::acoshf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::acoshl(0)), long double>::value), "");
+    assert(std::acosh(1) == 0);
+}
+
+void test_asinh()
+{
+    static_assert((std::is_same<decltype(std::asinh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::asinh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::asinhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::asinhl(0)), long double>::value), "");
+    assert(std::asinh(0) == 0);
+}
+
+void test_atanh()
+{
+    static_assert((std::is_same<decltype(std::atanh((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::atanh((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::atanhf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::atanhl(0)), long double>::value), "");
+    assert(std::atanh(0) == 0);
+}
+
+void test_cbrt()
+{
+    static_assert((std::is_same<decltype(std::cbrt((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrt((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::cbrtf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::cbrtl(0)), long double>::value), "");
+    assert(std::cbrt(1) == 1);
+}
+
+void test_copysign()
+{
+    static_assert((std::is_same<decltype(std::copysign((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysignf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::copysignl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::copysign((int)0, (int)0)), double>::value), "");
+    assert(std::copysign(1,1) == 1);
+}
+
+void test_erf()
+{
+    static_assert((std::is_same<decltype(std::erf((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erf((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erf((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::erff(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erfl(0)), long double>::value), "");
+    assert(std::erf(0) == 0);
+}
+
+void test_erfc()
+{
+    static_assert((std::is_same<decltype(std::erfc((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::erfc((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::erfcf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::erfcl(0)), long double>::value), "");
+    assert(std::erfc(0) == 1);
+}
+
+void test_exp2()
+{
+    static_assert((std::is_same<decltype(std::exp2((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::exp2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::exp2l(0)), long double>::value), "");
+    assert(std::exp2(1) == 2);
+}
+
+void test_expm1()
+{
+    static_assert((std::is_same<decltype(std::expm1((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::expm1f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::expm1l(0)), long double>::value), "");
+    assert(std::expm1(0) == 0);
+}
+
+void test_fdim()
+{
+    static_assert((std::is_same<decltype(std::fdim((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdimf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fdiml(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fdim((int)0, (int)0)), double>::value), "");
+    assert(std::fdim(1,0) == 1);
+}
+
+void test_fma()
+{
+    static_assert((std::is_same<decltype(std::fma((bool)0, (float)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((char)0, (float)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((unsigned)0, (float)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (int)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (long)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((float)0, (float)0, (float)0)), float>::value), "");
+
+    static_assert((std::is_same<decltype(std::fma((bool)0, (double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((char)0, (double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((unsigned)0, (double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (int)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (long)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (double)0,  (double)0)), double>::value), "");
+
+    static_assert((std::is_same<decltype(std::fma((bool)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((char)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((unsigned)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (unsigned long long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (float)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((double)0, (long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fma((long double)0, (long double)0, (long double)0)), long double>::value), "");
+
+    static_assert((std::is_same<decltype(std::fmaf(0,0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmal(0,0,0)), long double>::value), "");
+    assert(std::fma(1,1,1) == 2);
+}
+
+void test_fmax()
+{
+    static_assert((std::is_same<decltype(std::fmax((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmaxf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmaxl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmax((int)0, (int)0)), double>::value), "");
+    assert(std::fmax(1,0) == 1);
+}
+
+void test_fmin()
+{
+    static_assert((std::is_same<decltype(std::fmin((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fminf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::fminl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::fmin((int)0, (int)0)), double>::value), "");
+    assert(std::fmin(1,0) == 0);
+}
+
+void test_hypot()
+{
+    static_assert((std::is_same<decltype(std::hypot((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypotf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::hypotl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::hypot((int)0, (int)0)), double>::value), "");
+    assert(std::hypot(3,4) == 5);
+}
+
+void test_ilogb()
+{
+    static_assert((std::is_same<decltype(std::ilogb((float)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((bool)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned short)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((int)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned int)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((long long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((unsigned long long)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogb((long double)0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogbf(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ilogbl(0)), int>::value), "");
+    assert(std::ilogb(1) == 0);
+}
+
+void test_lgamma()
+{
+    static_assert((std::is_same<decltype(std::lgamma((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::lgamma((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::lgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::lgammal(0)), long double>::value), "");
+    assert(std::lgamma(1) == 0);
+}
+
+void test_llrint()
+{
+    static_assert((std::is_same<decltype(std::llrint((float)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((bool)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned short)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((unsigned long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrint((long double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrintf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llrintl(0)), long long>::value), "");
+    assert(std::llrint(1) == 1LL);
+}
+
+void test_llround()
+{
+    static_assert((std::is_same<decltype(std::llround((float)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((bool)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned short)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned int)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((unsigned long long)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llround((long double)0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llroundf(0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::llroundl(0)), long long>::value), "");
+    assert(std::llround(1) == 1LL);
+}
+
+void test_log1p()
+{
+    static_assert((std::is_same<decltype(std::log1p((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log1p((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::log1pf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log1pl(0)), long double>::value), "");
+    assert(std::log1p(0) == 0);
+}
+
+void test_log2()
+{
+    static_assert((std::is_same<decltype(std::log2((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log2((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::log2((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::log2f(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::log2l(0)), long double>::value), "");
+    assert(std::log2(1) == 0);
+}
+
+void test_logb()
+{
+    static_assert((std::is_same<decltype(std::logb((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::logb((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::logb((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::logbf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::logbl(0)), long double>::value), "");
+    assert(std::logb(1) == 0);
+}
+
+void test_lrint()
+{
+    static_assert((std::is_same<decltype(std::lrint((float)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((bool)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned short)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((unsigned long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrint((long double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrintf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lrintl(0)), long>::value), "");
+    assert(std::lrint(1) == 1L);
+}
+
+void test_lround()
+{
+    static_assert((std::is_same<decltype(std::lround((float)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((bool)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned short)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned int)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((unsigned long long)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lround((long double)0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lroundf(0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::lroundl(0)), long>::value), "");
+    assert(std::lround(1) == 1L);
+}
+
+void test_nan()
+{
+    static_assert((std::is_same<decltype(std::nan("")), double>::value), "");
+    static_assert((std::is_same<decltype(std::nanf("")), float>::value), "");
+    static_assert((std::is_same<decltype(std::nanl("")), long double>::value), "");
+}
+
+void test_nearbyint()
+{
+    static_assert((std::is_same<decltype(std::nearbyint((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyint((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nearbyintl(0)), long double>::value), "");
+    assert(std::nearbyint(1) == 1);
+}
+
+void test_nextafter()
+{
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafterf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nextafterl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nextafter((int)0, (int)0)), double>::value), "");
+    assert(std::nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_nexttoward()
+{
+    static_assert((std::is_same<decltype(std::nexttoward((float)0, (long double)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((bool)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned short)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((int)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned int)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((long long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((unsigned long long)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((double)0, (long double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttoward((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::nexttowardf(0, (long double)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::nexttowardl(0, (long double)0)), long double>::value), "");
+    assert(std::nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
+}
+
+void test_remainder()
+{
+    static_assert((std::is_same<decltype(std::remainder((float)0, (float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((bool)0, (float)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((unsigned short)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((float)0, (unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((long double)0, (unsigned long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((double)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((long double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((float)0, (double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((float)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((double)0, (long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainderf(0,0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remainderl(0,0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remainder((int)0, (int)0)), double>::value), "");
+    assert(std::remainder(0.5,1) == 0.5);
+}
+
+void test_remquo()
+{
+    int ip;
+    static_assert((std::is_same<decltype(std::remquo((float)0, (float)0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((bool)0, (float)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((unsigned short)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((float)0, (unsigned int)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((double)0, (long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((long double)0, (unsigned long)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (unsigned long long)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((double)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((long double)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((float)0, (double)0, &ip)), double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((float)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((double)0, (long double)0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquof(0,0, &ip)), float>::value), "");
+    static_assert((std::is_same<decltype(std::remquol(0,0, &ip)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::remquo((int)0, (int)0, &ip)), double>::value), "");
+    assert(std::remquo(0.5,1, &ip) == 0.5);
+}
+
+void test_rint()
+{
+    static_assert((std::is_same<decltype(std::rint((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::rint((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::rint((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::rintf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::rintl(0)), long double>::value), "");
+    assert(std::rint(1) == 1);
+}
+
+void test_round()
+{
+    static_assert((std::is_same<decltype(std::round((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::round((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::round((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::roundf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::roundl(0)), long double>::value), "");
+    assert(std::round(1) == 1);
+}
+
+void test_scalbln()
+{
+    static_assert((std::is_same<decltype(std::scalbln((float)0, (long)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((bool)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned short)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((int)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned int)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((long long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((unsigned long long)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((double)0, (long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbln((long double)0, (long)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::scalblnf(0, (long)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalblnl(0, (long)0)), long double>::value), "");
+    assert(std::scalbln(1, 1) == 2);
+}
+
+void test_scalbn()
+{
+    static_assert((std::is_same<decltype(std::scalbn((float)0, (int)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((bool)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned short)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((int)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned int)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((long long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((unsigned long long)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((double)0, (int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbn((long double)0, (int)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::scalbnf(0, (int)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::scalbnl(0, (int)0)), long double>::value), "");
+    assert(std::scalbn(1, 1) == 2);
+}
+
+void test_tgamma()
+{
+    static_assert((std::is_same<decltype(std::tgamma((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::tgamma((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::tgammaf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::tgammal(0)), long double>::value), "");
+    assert(std::tgamma(1) == 1);
+}
+
+void test_trunc()
+{
+    static_assert((std::is_same<decltype(std::trunc((float)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((bool)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned short)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned int)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((unsigned long long)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((double)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::trunc((long double)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::truncf(0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::truncl(0)), long double>::value), "");
+    assert(std::trunc(1) == 1);
+}
+
+int main()
+{
+    test_abs();
+    test_acos();
+    test_asin();
+    test_atan();
+    test_atan2();
+    test_ceil();
+    test_cos();
+    test_cosh();
+    test_exp();
+    test_fabs();
+    test_floor();
+    test_fmod();
+    test_frexp();
+    test_ldexp();
+    test_log();
+    test_log10();
+    test_modf();
+    test_pow();
+    test_sin();
+    test_sinh();
+    test_sqrt();
+    test_tan();
+    test_tanh();
+    test_signbit();
+    test_fpclassify();
+    test_isfinite();
+    test_isinf();
+    test_isnan();
+    test_isnormal();
+    test_isgreater();
+    test_isgreaterequal();
+    test_isless();
+    test_islessequal();
+    test_islessgreater();
+    test_isunordered();
+    test_acosh();
+    test_asinh();
+    test_atanh();
+    test_cbrt();
+    test_copysign();
+    test_erf();
+    test_erfc();
+    test_exp2();
+    test_expm1();
+    test_fdim();
+    test_fma();
+    test_fmax();
+    test_fmin();
+    test_hypot();
+    test_ilogb();
+    test_lgamma();
+    test_llrint();
+    test_llround();
+    test_log1p();
+    test_log2();
+    test_logb();
+    test_lrint();
+    test_lround();
+    test_nan();
+    test_nearbyint();
+    test_nextafter();
+    test_nexttoward();
+    test_remainder();
+    test_remquo();
+    test_rint();
+    test_round();
+    test_scalbln();
+    test_scalbn();
+    test_tgamma();
+    test_trunc();
+}
diff --git a/final/test/numerics/c.math/ctgmath.pass.cpp b/final/test/numerics/c.math/ctgmath.pass.cpp
new file mode 100644
index 0000000..278217e
--- /dev/null
+++ b/final/test/numerics/c.math/ctgmath.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ctgmath>
+
+#include <ctgmath>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> cd;
+    double x = std::sin(0);
+}
diff --git a/final/test/numerics/c.math/tgmath_h.pass.cpp b/final/test/numerics/c.math/tgmath_h.pass.cpp
new file mode 100644
index 0000000..23143c7
--- /dev/null
+++ b/final/test/numerics/c.math/tgmath_h.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tgmath.h>
+
+#include <tgmath.h>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/numerics/c.math/version_cmath.pass.cpp b/final/test/numerics/c.math/version_cmath.pass.cpp
new file mode 100644
index 0000000..1249a90
--- /dev/null
+++ b/final/test/numerics/c.math/version_cmath.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cmath>
+
+#include <cmath>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/numerics/cfenv/cfenv.syn/cfenv.pass.cpp b/final/test/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
new file mode 100644
index 0000000..78f4784
--- /dev/null
+++ b/final/test/numerics/cfenv/cfenv.syn/cfenv.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfenv>
+
+#include <cfenv>
+#include <type_traits>
+
+#ifndef FE_DIVBYZERO
+#error FE_DIVBYZERO not defined
+#endif
+
+#ifndef FE_INEXACT
+#error FE_INEXACT not defined
+#endif
+
+#ifndef FE_INVALID
+#error FE_INVALID not defined
+#endif
+
+#ifndef FE_OVERFLOW
+#error FE_OVERFLOW not defined
+#endif
+
+#ifndef FE_UNDERFLOW
+#error FE_UNDERFLOW not defined
+#endif
+
+#ifndef FE_ALL_EXCEPT
+#error FE_ALL_EXCEPT not defined
+#endif
+
+#ifndef FE_DOWNWARD
+#error FE_DOWNWARD not defined
+#endif
+
+#ifndef FE_TONEAREST
+#error FE_TONEAREST not defined
+#endif
+
+#ifndef FE_TOWARDZERO
+#error FE_TOWARDZERO not defined
+#endif
+
+#ifndef FE_UPWARD
+#error FE_UPWARD not defined
+#endif
+
+#ifndef FE_DFL_ENV
+#error FE_DFL_ENV not defined
+#endif
+
+int main()
+{
+    std::fenv_t fenv = {0};
+    std::fexcept_t fex = 0;
+    static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fesetexceptflag(&fex, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fetestexcept(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fegetround()), int>::value), "");
+    static_assert((std::is_same<decltype(std::fesetround(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fegetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(std::feholdexcept(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fesetenv(&fenv)), int>::value), "");
+    static_assert((std::is_same<decltype(std::feupdateenv(&fenv)), int>::value), "");
+}
diff --git a/final/test/numerics/cfenv/version.pass.cpp b/final/test/numerics/cfenv/version.pass.cpp
new file mode 100644
index 0000000..4083e40
--- /dev/null
+++ b/final/test/numerics/cfenv/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cfenv>
+
+#include <cfenv>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/numerics/complex.number/cases.h b/final/test/numerics/complex.number/cases.h
new file mode 100644
index 0000000..cd6bd16
--- /dev/null
+++ b/final/test/numerics/complex.number/cases.h
@@ -0,0 +1,230 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// test cases
+
+#ifndef CASES_H
+#define CASES_H
+
+#include <complex>
+#include <cassert>
+
+std::complex<double> x[] =
+{
+    std::complex<double>( 1.e-6,  1.e-6),
+    std::complex<double>(-1.e-6,  1.e-6),
+    std::complex<double>(-1.e-6, -1.e-6),
+    std::complex<double>( 1.e-6, -1.e-6),
+
+    std::complex<double>( 1.e+6,  1.e-6),
+    std::complex<double>(-1.e+6,  1.e-6),
+    std::complex<double>(-1.e+6, -1.e-6),
+    std::complex<double>( 1.e+6, -1.e-6),
+
+    std::complex<double>( 1.e-6,  1.e+6),
+    std::complex<double>(-1.e-6,  1.e+6),
+    std::complex<double>(-1.e-6, -1.e+6),
+    std::complex<double>( 1.e-6, -1.e+6),
+
+    std::complex<double>( 1.e+6,  1.e+6),
+    std::complex<double>(-1.e+6,  1.e+6),
+    std::complex<double>(-1.e+6, -1.e+6),
+    std::complex<double>( 1.e+6, -1.e+6),
+
+    std::complex<double>(NAN, NAN),
+    std::complex<double>(-INFINITY, NAN),
+    std::complex<double>(-2, NAN),
+    std::complex<double>(-1, NAN),
+    std::complex<double>(-0.5, NAN),
+    std::complex<double>(-0., NAN),
+    std::complex<double>(+0., NAN),
+    std::complex<double>(0.5, NAN),
+    std::complex<double>(1, NAN),
+    std::complex<double>(2, NAN),
+    std::complex<double>(INFINITY, NAN),
+
+    std::complex<double>(NAN, -INFINITY),
+    std::complex<double>(-INFINITY, -INFINITY),
+    std::complex<double>(-2, -INFINITY),
+    std::complex<double>(-1, -INFINITY),
+    std::complex<double>(-0.5, -INFINITY),
+    std::complex<double>(-0., -INFINITY),
+    std::complex<double>(+0., -INFINITY),
+    std::complex<double>(0.5, -INFINITY),
+    std::complex<double>(1, -INFINITY),
+    std::complex<double>(2, -INFINITY),
+    std::complex<double>(INFINITY, -INFINITY),
+
+    std::complex<double>(NAN, -2),
+    std::complex<double>(-INFINITY, -2),
+    std::complex<double>(-2, -2),
+    std::complex<double>(-1, -2),
+    std::complex<double>(-0.5, -2),
+    std::complex<double>(-0., -2),
+    std::complex<double>(+0., -2),
+    std::complex<double>(0.5, -2),
+    std::complex<double>(1, -2),
+    std::complex<double>(2, -2),
+    std::complex<double>(INFINITY, -2),
+
+    std::complex<double>(NAN, -1),
+    std::complex<double>(-INFINITY, -1),
+    std::complex<double>(-2, -1),
+    std::complex<double>(-1, -1),
+    std::complex<double>(-0.5, -1),
+    std::complex<double>(-0., -1),
+    std::complex<double>(+0., -1),
+    std::complex<double>(0.5, -1),
+    std::complex<double>(1, -1),
+    std::complex<double>(2, -1),
+    std::complex<double>(INFINITY, -1),
+
+    std::complex<double>(NAN, -0.5),
+    std::complex<double>(-INFINITY, -0.5),
+    std::complex<double>(-2, -0.5),
+    std::complex<double>(-1, -0.5),
+    std::complex<double>(-0.5, -0.5),
+    std::complex<double>(-0., -0.5),
+    std::complex<double>(+0., -0.5),
+    std::complex<double>(0.5, -0.5),
+    std::complex<double>(1, -0.5),
+    std::complex<double>(2, -0.5),
+    std::complex<double>(INFINITY, -0.5),
+
+    std::complex<double>(NAN, -0.),
+    std::complex<double>(-INFINITY, -0.),
+    std::complex<double>(-2, -0.),
+    std::complex<double>(-1, -0.),
+    std::complex<double>(-0.5, -0.),
+    std::complex<double>(-0., -0.),
+    std::complex<double>(+0., -0.),
+    std::complex<double>(0.5, -0.),
+    std::complex<double>(1, -0.),
+    std::complex<double>(2, -0.),
+    std::complex<double>(INFINITY, -0.),
+
+    std::complex<double>(NAN, +0.),
+    std::complex<double>(-INFINITY, +0.),
+    std::complex<double>(-2, +0.),
+    std::complex<double>(-1, +0.),
+    std::complex<double>(-0.5, +0.),
+    std::complex<double>(-0., +0.),
+    std::complex<double>(+0., +0.),
+    std::complex<double>(0.5, +0.),
+    std::complex<double>(1, +0.),
+    std::complex<double>(2, +0.),
+    std::complex<double>(INFINITY, +0.),
+
+    std::complex<double>(NAN, 0.5),
+    std::complex<double>(-INFINITY, 0.5),
+    std::complex<double>(-2, 0.5),
+    std::complex<double>(-1, 0.5),
+    std::complex<double>(-0.5, 0.5),
+    std::complex<double>(-0., 0.5),
+    std::complex<double>(+0., 0.5),
+    std::complex<double>(0.5, 0.5),
+    std::complex<double>(1, 0.5),
+    std::complex<double>(2, 0.5),
+    std::complex<double>(INFINITY, 0.5),
+
+    std::complex<double>(NAN, 1),
+    std::complex<double>(-INFINITY, 1),
+    std::complex<double>(-2, 1),
+    std::complex<double>(-1, 1),
+    std::complex<double>(-0.5, 1),
+    std::complex<double>(-0., 1),
+    std::complex<double>(+0., 1),
+    std::complex<double>(0.5, 1),
+    std::complex<double>(1, 1),
+    std::complex<double>(2, 1),
+    std::complex<double>(INFINITY, 1),
+
+    std::complex<double>(NAN, 2),
+    std::complex<double>(-INFINITY, 2),
+    std::complex<double>(-2, 2),
+    std::complex<double>(-1, 2),
+    std::complex<double>(-0.5, 2),
+    std::complex<double>(-0., 2),
+    std::complex<double>(+0., 2),
+    std::complex<double>(0.5, 2),
+    std::complex<double>(1, 2),
+    std::complex<double>(2, 2),
+    std::complex<double>(INFINITY, 2),
+
+    std::complex<double>(NAN, INFINITY),
+    std::complex<double>(-INFINITY, INFINITY),
+    std::complex<double>(-2, INFINITY),
+    std::complex<double>(-1, INFINITY),
+    std::complex<double>(-0.5, INFINITY),
+    std::complex<double>(-0., INFINITY),
+    std::complex<double>(+0., INFINITY),
+    std::complex<double>(0.5, INFINITY),
+    std::complex<double>(1, INFINITY),
+    std::complex<double>(2, INFINITY),
+    std::complex<double>(INFINITY, INFINITY)
+};
+
+enum {zero, non_zero, inf, NaN, non_zero_nan};
+
+template <class T>
+int
+classify(const std::complex<T>& x)
+{
+    if (x == std::complex<T>())
+        return zero;
+    if (std::isinf(x.real()) || std::isinf(x.imag()))
+        return inf;
+    if (std::isnan(x.real()) && std::isnan(x.imag()))
+        return NaN;
+    if (std::isnan(x.real()))
+    {
+        if (x.imag() == T(0))
+            return NaN;
+        return non_zero_nan;
+    }
+    if (std::isnan(x.imag()))
+    {
+        if (x.real() == T(0))
+            return NaN;
+        return non_zero_nan;
+    }
+    return non_zero;
+}
+
+inline
+int
+classify(double x)
+{
+    if (x == 0)
+        return zero;
+    if (std::isinf(x))
+        return inf;
+    if (std::isnan(x))
+        return NaN;
+    return non_zero;
+}
+
+void is_about(float x, float y)
+{
+    assert(std::abs((x-y)/(x+y)) < 1.e-6);
+}
+
+void is_about(double x, double y)
+{
+    assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+void is_about(long double x, long double y)
+{
+    assert(std::abs((x-y)/(x+y)) < 1.e-14);
+}
+
+#endif  // CASES_H
diff --git a/final/test/numerics/complex.number/ccmplx/ccomplex.pass.cpp b/final/test/numerics/complex.number/ccmplx/ccomplex.pass.cpp
new file mode 100644
index 0000000..21aaa66
--- /dev/null
+++ b/final/test/numerics/complex.number/ccmplx/ccomplex.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ccomplex>
+
+#include <ccomplex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+    std::complex<double> d;
+}
diff --git a/final/test/numerics/complex.number/cmplx.over/arg.pass.cpp b/final/test/numerics/complex.number/cmplx.over/arg.pass.cpp
new file mode 100644
index 0000000..978c625
--- /dev/null
+++ b/final/test/numerics/complex.number/cmplx.over/arg.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   arg(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::arg(x)), double>::value), "");
+    assert(std::arg(x) == arg(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::arg(x)), T>::value), "");
+    assert(std::arg(x) == arg(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/final/test/numerics/complex.number/cmplx.over/conj.pass.cpp b/final/test/numerics/complex.number/cmplx.over/conj.pass.cpp
new file mode 100644
index 0000000..6adbf21
--- /dev/null
+++ b/final/test/numerics/complex.number/cmplx.over/conj.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>      complex<T>           conj(const complex<T>&);
+//                        complex<long double> conj(long double);
+//                        complex<double>      conj(double);
+// template<Integral T>   complex<double>      conj(T);
+//                        complex<float>       conj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::conj(x)), std::complex<double> >::value), "");
+    assert(std::conj(x) == conj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::conj(x)), std::complex<T> >::value), "");
+    assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+                                  !std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::conj(x)), std::complex<T> >::value), "");
+    assert(std::conj(x) == conj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/final/test/numerics/complex.number/cmplx.over/imag.pass.cpp b/final/test/numerics/complex.number/cmplx.over/imag.pass.cpp
new file mode 100644
index 0000000..30c95c3
--- /dev/null
+++ b/final/test/numerics/complex.number/cmplx.over/imag.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   imag(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T, int x>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::imag(T(x))), double>::value), "");
+    assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+    constexpr T val {x};
+    static_assert(std::imag(val) == 0, "");
+    constexpr std::complex<T> t{val, val};
+    static_assert(t.imag() == x, "" );
+#endif    
+}
+
+template <class T, int x>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::imag(T(x))), T>::value), "");
+    assert(std::imag(x) == 0);
+#if _LIBCPP_STD_VER > 11
+    constexpr T val {x};
+    static_assert(std::imag(val) == 0, "");
+    constexpr std::complex<T> t{val, val};
+    static_assert(t.imag() == x, "" );
+#endif    
+}
+
+template <class T>
+void
+test()
+{
+    test<T, 0>();
+    test<T, 1>();
+    test<T, 10>();
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/final/test/numerics/complex.number/cmplx.over/norm.pass.cpp b/final/test/numerics/complex.number/cmplx.over/norm.pass.cpp
new file mode 100644
index 0000000..badd5c0
--- /dev/null
+++ b/final/test/numerics/complex.number/cmplx.over/norm.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   norm(T x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::norm(x)), double>::value), "");
+    assert(std::norm(x) == norm(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::norm(x)), T>::value), "");
+    assert(std::norm(x) == norm(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/final/test/numerics/complex.number/cmplx.over/pow.pass.cpp b/final/test/numerics/complex.number/cmplx.over/pow.pass.cpp
new file mode 100644
index 0000000..3b1e9b3
--- /dev/null
+++ b/final/test/numerics/complex.number/cmplx.over/pow.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T, Arithmetic U>
+//   complex<promote<T, U>::type>
+//   pow(const T& x, const complex<U>& y);
+
+// template<Arithmetic T, Arithmetic U>
+//   complex<promote<T, U>::type>
+//   pow(const complex<T>& x, const U& y);
+
+// template<Arithmetic T, Arithmetic U>
+//   complex<promote<T, U>::type>
+//   pow(const complex<T>& x, const complex<U>& y);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+double
+promote(T, typename std::enable_if<std::is_integral<T>::value>::type* = 0);
+
+float promote(float);
+double promote(double);
+long double promote(long double);
+
+template <class T, class U>
+void
+test(T x, const std::complex<U>& y)
+{
+    typedef decltype(promote(x)+promote(real(y))) V;
+    static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+    assert(std::pow(x, y) == pow(std::complex<V>(x, 0), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, U y)
+{
+    typedef decltype(promote(real(x))+promote(y)) V;
+    static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+    assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y, 0)));
+}
+
+template <class T, class U>
+void
+test(const std::complex<T>& x, const std::complex<U>& y)
+{
+    typedef decltype(promote(real(x))+promote(real(y))) V;
+    static_assert((std::is_same<decltype(std::pow(x, y)), std::complex<V> >::value), "");
+    assert(std::pow(x, y) == pow(std::complex<V>(x), std::complex<V>(y)));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+    test(T(3), std::complex<U>(4, 5));
+    test(std::complex<U>(3, 4), T(5));
+}
+
+template <class T, class U>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0, typename std::enable_if<!std::is_integral<U>::value>::type* = 0)
+{
+    test(T(3), std::complex<U>(4, 5));
+    test(std::complex<T>(3, 4), U(5));
+    test(std::complex<T>(3, 4), std::complex<U>(5, 6));
+}
+
+int main()
+{
+    test<int, float>();
+    test<int, double>();
+    test<int, long double>();
+
+    test<unsigned, float>();
+    test<unsigned, double>();
+    test<unsigned, long double>();
+
+    test<long long, float>();
+    test<long long, double>();
+    test<long long, long double>();
+
+    test<float, double>();
+    test<float, long double>();
+
+    test<double, float>();
+    test<double, long double>();
+
+    test<long double, float>();
+    test<long double, double>();
+}
diff --git a/final/test/numerics/complex.number/cmplx.over/proj.pass.cpp b/final/test/numerics/complex.number/cmplx.over/proj.pass.cpp
new file mode 100644
index 0000000..60d6e72
--- /dev/null
+++ b/final/test/numerics/complex.number/cmplx.over/proj.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>    complex<T>           proj(const complex<T>&);
+//                      complex<long double> proj(long double);
+//                      complex<double>      proj(double);
+// template<Integral T> complex<double>      proj(T);
+//                      complex<float>       proj(float);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::proj(x)), std::complex<double> >::value), "");
+    assert(std::proj(x) == proj(std::complex<double>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
+    assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test(T x, typename std::enable_if<!std::is_integral<T>::value &&
+                                  !std::is_floating_point<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::proj(x)), std::complex<T> >::value), "");
+    assert(std::proj(x) == proj(std::complex<T>(x, 0)));
+}
+
+template <class T>
+void
+test()
+{
+    test<T>(0);
+    test<T>(1);
+    test<T>(10);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/final/test/numerics/complex.number/cmplx.over/real.pass.cpp b/final/test/numerics/complex.number/cmplx.over/real.pass.cpp
new file mode 100644
index 0000000..a5a4a35
--- /dev/null
+++ b/final/test/numerics/complex.number/cmplx.over/real.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<Arithmetic T>
+//   T
+//   real(const T& x);
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T, int x>
+void
+test(typename std::enable_if<std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::real(T(x))), double>::value), "");
+    assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+    constexpr T val {x};
+    static_assert(std::real(val) == val, "");
+    constexpr std::complex<T> t{val, val};
+    static_assert(t.real() == x, "" );
+#endif    
+}
+
+template <class T, int x>
+void
+test(typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
+{
+    static_assert((std::is_same<decltype(std::real(T(x))), T>::value), "");
+    assert(std::real(x) == x);
+#if _LIBCPP_STD_VER > 11
+    constexpr T val {x};
+    static_assert(std::real(val) == val, "");
+    constexpr std::complex<T> t{val, val};
+    static_assert(t.real() == x, "" );
+#endif    
+}
+
+template <class T>
+void
+test()
+{
+    test<T, 0>();
+    test<T, 1>();
+    test<T, 10>();
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<int>();
+    test<unsigned>();
+    test<long long>();
+}
diff --git a/final/test/numerics/complex.number/complex.literals/literals.pass.cpp b/final/test/numerics/complex.number/complex.literals/literals.pass.cpp
new file mode 100644
index 0000000..45b5991
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.literals/literals.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals::complex_literals;
+
+//  Make sure the types are right
+    static_assert ( std::is_same<decltype( 3.0il ), std::complex<long double>>::value, "" );
+    static_assert ( std::is_same<decltype( 3il   ), std::complex<long double>>::value, "" );
+    static_assert ( std::is_same<decltype( 3.0i  ), std::complex<double>>::value, "" );
+    static_assert ( std::is_same<decltype( 3i    ), std::complex<double>>::value, "" );
+    static_assert ( std::is_same<decltype( 3.0if ), std::complex<float>>::value, "" );
+    static_assert ( std::is_same<decltype( 3if   ), std::complex<float>>::value, "" );
+    
+    {
+    std::complex<long double> c1 = 3.0il;
+    assert ( c1 == std::complex<long double>(0, 3.0));
+    auto c2 = 3il;
+    assert ( c1 == c2 );
+    }
+    
+    {
+    std::complex<double> c1 = 3.0i;
+    assert ( c1 == std::complex<double>(0, 3.0));
+    auto c2 = 3i;
+    assert ( c1 == c2 );
+    }
+
+    {
+    std::complex<float> c1 = 3.0if;
+    assert ( c1 == std::complex<float>(0, 3.0));
+    auto c2 = 3if;
+    assert ( c1 == c2 );
+    }
+
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.literals/literals1.fail.cpp b/final/test/numerics/complex.number/complex.literals/literals1.fail.cpp
new file mode 100644
index 0000000..0f31d59
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.literals/literals1.fail.cpp
@@ -0,0 +1,20 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <complex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    std::complex<float> foo  = 1.0if;  // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.literals/literals1.pass.cpp b/final/test/numerics/complex.number/complex.literals/literals1.pass.cpp
new file mode 100644
index 0000000..46903bb
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.literals/literals1.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals;
+
+    {
+    std::complex<long double> c1 = 3.0il;
+    assert ( c1 == std::complex<long double>(0, 3.0));
+    auto c2 = 3il;
+    assert ( c1 == c2 );
+    }
+    
+    {
+    std::complex<double> c1 = 3.0i;
+    assert ( c1 == std::complex<double>(0, 3.0));
+    auto c2 = 3i;
+    assert ( c1 == c2 );
+    }
+
+    {
+    std::complex<float> c1 = 3.0if;
+    assert ( c1 == std::complex<float>(0, 3.0));
+    auto c2 = 3if;
+    assert ( c1 == c2 );
+    }
+
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.literals/literals2.pass.cpp b/final/test/numerics/complex.number/complex.literals/literals2.pass.cpp
new file mode 100644
index 0000000..8bd8acd
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.literals/literals2.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <complex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std;
+
+    {
+    std::complex<long double> c1 = 3.0il;
+    assert ( c1 == std::complex<long double>(0, 3.0));
+    auto c2 = 3il;
+    assert ( c1 == c2 );
+    }
+    
+    {
+    std::complex<double> c1 = 3.0i;
+    assert ( c1 == std::complex<double>(0, 3.0));
+    auto c2 = 3i;
+    assert ( c1 == c2 );
+    }
+
+    {
+    std::complex<float> c1 = 3.0if;
+    assert ( c1 == std::complex<float>(0, 3.0));
+    auto c2 = 3if;
+    assert ( c1 == c2 );
+    }
+
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp
new file mode 100644
index 0000000..d394294
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/assignment_complex.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator=(const complex&);
+// template<class X> complex& operator= (const complex<X>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T, class X>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    std::complex<T> c2(1.5, 2.5);
+    c = c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    std::complex<X> c3(3.5, -4.5);
+    c = c3;
+    assert(c.real() == 3.5);
+    assert(c.imag() == -4.5);
+}
+
+int main()
+{
+    test<float, float>();
+    test<float, double>();
+    test<float, long double>();
+
+    test<double, float>();
+    test<double, double>();
+    test<double, long double>();
+
+    test<long double, float>();
+    test<long double, double>();
+    test<long double, long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
new file mode 100644
index 0000000..87b7806
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/assignment_scalar.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator= (const T&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c = 1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+    c = -1.5;
+    assert(c.real() == -1.5);
+    assert(c.imag() == 0);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
new file mode 100644
index 0000000..cb28511
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/divide_equal_complex.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(-4, 7.5);
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == -4);
+    assert(c.imag() == 7.5);
+    c /= c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    c /= c2;
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+    
+    std::complex<T> c3;
+
+    c3 = c;
+    std::complex<int> ic (1,1);
+    c3 /= ic;
+    assert(c3.real() ==  0.5);
+    assert(c3.imag() == -0.5);
+    
+    c3 = c;
+    std::complex<float> fc (1,1);
+    c3 /= fc;
+    assert(c3.real() ==  0.5);
+    assert(c3.imag() == -0.5);
+    
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
new file mode 100644
index 0000000..89907d1
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/divide_equal_scalar.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator/=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(1);
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+    c /= 0.5;
+    assert(c.real() == 2);
+    assert(c.imag() == 0);
+    c /= 0.5;
+    assert(c.real() == 4);
+    assert(c.imag() == 0);
+    c /= -0.5;
+    assert(c.real() == -8);
+    assert(c.imag() == 0);
+    c.imag(2);
+    c /= 0.5;
+    assert(c.real() == -16);
+    assert(c.imag() == 4);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
new file mode 100644
index 0000000..67a1c71
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/minus_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c -= c2;
+    assert(c.real() == -1.5);
+    assert(c.imag() == -2.5);
+    c -= c2;
+    assert(c.real() == -3);
+    assert(c.imag() == -5);
+
+    std::complex<T> c3;
+
+    c3 = c;
+    std::complex<int> ic (1,1);
+    c3 -= ic;
+    assert(c3.real() == -4);
+    assert(c3.imag() == -6);
+
+    c3 = c;
+    std::complex<float> fc (1,1);
+    c3 -= fc;
+    assert(c3.real() == -4);
+    assert(c3.imag() == -6);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
new file mode 100644
index 0000000..ddec891
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/minus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator-=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c -= 1.5;
+    assert(c.real() == -1.5);
+    assert(c.imag() == 0);
+    c -= 1.5;
+    assert(c.real() == -3);
+    assert(c.imag() == 0);
+    c -= -1.5;
+    assert(c.real() == -1.5);
+    assert(c.imag() == 0);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
new file mode 100644
index 0000000..8c16f4c
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/plus_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c += c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    c += c2;
+    assert(c.real() == 3);
+    assert(c.imag() == 5);
+
+    std::complex<T> c3;
+
+    c3 = c;
+    std::complex<int> ic (1,1);
+    c3 += ic;
+    assert(c3.real() == 4);
+    assert(c3.imag() == 6);
+    
+    c3 = c;
+    std::complex<float> fc (1,1);
+    c3 += fc;
+    assert(c3.real() == 4);
+    assert(c3.imag() == 6);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
new file mode 100644
index 0000000..4dd8066
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/plus_equal_scalar.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator+=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c += 1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+    c += 1.5;
+    assert(c.real() == 3);
+    assert(c.imag() == 0);
+    c += -1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
new file mode 100644
index 0000000..84d6e59
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/times_equal_complex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const complex& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(1);
+    const std::complex<T> c2(1.5, 2.5);
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+    c *= c2;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+    c *= c2;
+    assert(c.real() == -4);
+    assert(c.imag() == 7.5);
+
+    std::complex<T> c3;
+
+    c3 = c;
+    std::complex<int> ic (1,1);
+    c3 *= ic;
+    assert(c3.real() == -11.5);
+    assert(c3.imag() ==   3.5);
+    
+    c3 = c;
+    std::complex<float> fc (1,1);
+    c3 *= fc;
+    assert(c3.real() == -11.5);
+    assert(c3.imag() ==   3.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp b/final/test/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
new file mode 100644
index 0000000..c94baa9
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.member.ops/times_equal_scalar.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// complex& operator*=(const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c(1);
+    assert(c.real() == 1);
+    assert(c.imag() == 0);
+    c *= 1.5;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 0);
+    c *= 1.5;
+    assert(c.real() == 2.25);
+    assert(c.imag() == 0);
+    c *= -1.5;
+    assert(c.real() == -3.375);
+    assert(c.imag() == 0);
+    c.imag(2);
+    c *= 1.5;
+    assert(c.real() == -5.0625);
+    assert(c.imag() == 3);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.members/construct.pass.cpp b/final/test/numerics/complex.number/complex.members/construct.pass.cpp
new file mode 100644
index 0000000..b4d870f
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.members/construct.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// constexpr complex(const T& re = T(), const T& im = T());
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    {
+    const std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    }
+    {
+    const std::complex<T> c = 7.5;
+    assert(c.real() == 7.5);
+    assert(c.imag() == 0);
+    }
+    {
+    const std::complex<T> c(8.5);
+    assert(c.real() == 8.5);
+    assert(c.imag() == 0);
+    }
+    {
+    const std::complex<T> c(10.5, -9.5);
+    assert(c.real() == 10.5);
+    assert(c.imag() == -9.5);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<T> c;
+    static_assert(c.real() == 0, "");
+    static_assert(c.imag() == 0, "");
+    }
+    {
+    constexpr std::complex<T> c = 7.5;
+    static_assert(c.real() == 7.5, "");
+    static_assert(c.imag() == 0, "");
+    }
+    {
+    constexpr std::complex<T> c(8.5);
+    static_assert(c.real() == 8.5, "");
+    static_assert(c.imag() == 0, "");
+    }
+    {
+    constexpr std::complex<T> c(10.5, -9.5);
+    static_assert(c.real() == 10.5, "");
+    static_assert(c.imag() == -9.5, "");
+    }
+#endif
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.members/real_imag.pass.cpp b/final/test/numerics/complex.number/complex.members/real_imag.pass.cpp
new file mode 100644
index 0000000..7ead855
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.members/real_imag.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// void real(T val);
+// void imag(T val);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+    constexpr std::complex<T> c1;
+    static_assert(c1.real() == 0, "");
+    static_assert(c1.imag() == 0, "");
+    constexpr std::complex<T> c2(3);
+    static_assert(c2.real() == 3, "");
+    static_assert(c2.imag() == 0, "");
+    constexpr std::complex<T> c3(3, 4);
+    static_assert(c3.real() == 3, "");
+    static_assert(c3.imag() == 4, "");
+#endif
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> c;
+    assert(c.real() == 0);
+    assert(c.imag() == 0);
+    c.real(3.5);
+    assert(c.real() == 3.5);
+    assert(c.imag() == 0);
+    c.imag(4.5);
+    assert(c.real() == 3.5);
+    assert(c.imag() == 4.5);
+    c.real(-4.5);
+    assert(c.real() == -4.5);
+    assert(c.imag() == 4.5);
+    c.imag(-5.5);
+    assert(c.real() == -4.5);
+    assert(c.imag() == -5.5);
+
+    test_constexpr<T> ();
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_constexpr<int> ();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
new file mode 100644
index 0000000..8611967
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_divide_complex.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator/(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(-4.0, 7.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(1.5, 2.5);
+    test(lhs, rhs, x);
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = x[i] / x[j];
+            switch (classify(x[i]))
+            {
+            case zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == zero);
+                    break;
+                case inf:
+                    assert(classify(r) == zero);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == inf);
+                    break;
+                case non_zero:
+                    assert(classify(r) == non_zero);
+                    break;
+                case inf:
+                    assert(classify(r) == zero);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case inf:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == inf);
+                    break;
+                case non_zero:
+                    assert(classify(r) == inf);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case NaN:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero_nan:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == inf);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
new file mode 100644
index 0000000..b23b381
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_divide_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator/(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(-4.0, 7.5);
+    T rhs(2);
+    std::complex<T>   x(-2, 3.75);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
new file mode 100644
index 0000000..970f021
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_equals_complex.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator==(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::complex<T> lhs(1.5,  2.5);
+    constexpr std::complex<T> rhs(1.5, -2.5);
+    static_assert( !(lhs == rhs), "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5, 2.5);
+    constexpr std::complex<T> rhs(1.5, 2.5);
+    static_assert(lhs == rhs, "");
+    }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    std::complex<T> rhs(1.5, -2.5);
+    assert( !(lhs == rhs));
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(1.5, 2.5);
+    assert(lhs == rhs);
+    }
+    test_constexpr<T> ();
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+//    test_constexpr<int> ();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
new file mode 100644
index 0000000..3c8b772
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_equals_scalar.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator==(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::complex<T> lhs(1.5, 2.5);
+    constexpr T rhs(-2.5);
+    static_assert(!(lhs == rhs), "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5, 0);
+    constexpr T rhs(-2.5);
+    static_assert(!(lhs == rhs), "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5, 2.5);
+    constexpr T rhs(1.5);
+    static_assert(!(lhs == rhs), "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5, 0);
+    constexpr T rhs(1.5);
+    static_assert( (lhs == rhs), "");
+    }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    T rhs(-2.5);
+    assert(!(lhs == rhs));
+    }
+    {
+    std::complex<T> lhs(1.5, 0);
+    T rhs(-2.5);
+    assert(!(lhs == rhs));
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(1.5);
+    assert(!(lhs == rhs));
+    }
+    {
+    std::complex<T> lhs(1.5, 0);
+    T rhs(1.5);
+    assert( (lhs == rhs));
+    }
+
+    test_constexpr<T> ();
+    }
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+//     test_constexpr<int> ();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
new file mode 100644
index 0000000..b2cddd2
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator-(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(-2.0, -2.0);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(5.0, -7.0);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
new file mode 100644
index 0000000..b630679
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_minus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator-(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(3.5);
+    std::complex<T>   x(-2.0, 2.5);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    T rhs(-3.5);
+    std::complex<T>   x(5.0, -2.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
new file mode 100644
index 0000000..ee138c1
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_not_equals_complex.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator!=(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::complex<T> lhs(1.5,  2.5);
+    constexpr std::complex<T> rhs(1.5, -2.5);
+    static_assert(lhs != rhs, "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5, 2.5);
+    constexpr std::complex<T> rhs(1.5, 2.5);
+    static_assert(!(lhs != rhs), "" );
+    }
+#endif
+}
+
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    std::complex<T> rhs(1.5, -2.5);
+    assert(lhs != rhs);
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(1.5, 2.5);
+    assert(!(lhs != rhs));
+    }
+
+    test_constexpr<T> ();
+    }
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+//   test_constexpr<int> ();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
new file mode 100644
index 0000000..efb1c0e
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_not_equals_scalar.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator!=(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::complex<T> lhs(1.5,  2.5);
+    constexpr T rhs(-2.5);
+    static_assert(lhs != rhs, "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5,  0);
+    constexpr T rhs(-2.5);
+    static_assert(lhs != rhs, "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5, 2.5);
+    constexpr T rhs(1.5);
+    static_assert(lhs != rhs, "");
+    }
+    {
+    constexpr std::complex<T> lhs(1.5, 0);
+    constexpr T rhs(1.5);
+    static_assert( !(lhs != rhs), "");
+    }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5,  2.5);
+    T rhs(-2.5);
+    assert(lhs != rhs);
+    }
+    {
+    std::complex<T> lhs(1.5,  0);
+    T rhs(-2.5);
+    assert(lhs != rhs);
+    }
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(1.5);
+    assert(lhs != rhs);
+    }
+    {
+    std::complex<T> lhs(1.5, 0);
+    T rhs(1.5);
+    assert( !(lhs != rhs));
+    }
+
+    test_constexpr<T> ();
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+//     test_constexpr<int> ();
+    }
diff --git a/final/test/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
new file mode 100644
index 0000000..02ed868
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator+(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(5.0, 7.0);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(-2.0, 2.0);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
new file mode 100644
index 0000000..eeec83f
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_plus_scalar.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator+(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(3.5);
+    std::complex<T>   x(5.0, 2.5);
+    test(lhs, rhs, x);
+    }
+    {
+    std::complex<T> lhs(1.5, -2.5);
+    T rhs(-3.5);
+    std::complex<T>   x(-2.0, -2.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
new file mode 100644
index 0000000..565eaa5
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_times_complex.pass.cpp
@@ -0,0 +1,161 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator*(const complex<T>& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(1.5, 2.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(-4.0, 7.5);
+    test(lhs, rhs, x);
+}
+
+// test edges
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = x[i] * x[j];
+            switch (classify(x[i]))
+            {
+            case zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == zero);
+                    break;
+                case non_zero:
+                    assert(classify(r) == zero);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == zero);
+                    break;
+                case non_zero:
+                    assert(classify(r) == non_zero);
+                    break;
+                case inf:
+                    assert(classify(r) == inf);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case inf:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == inf);
+                    break;
+                case inf:
+                    assert(classify(r) == inf);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == inf);
+                    break;
+                }
+                break;
+            case NaN:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == NaN);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            case non_zero_nan:
+                switch (classify(x[j]))
+                {
+                case zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero:
+                    assert(classify(r) == NaN);
+                    break;
+                case inf:
+                    assert(classify(r) == inf);
+                    break;
+                case NaN:
+                    assert(classify(r) == NaN);
+                    break;
+                case non_zero_nan:
+                    assert(classify(r) == NaN);
+                    break;
+                }
+                break;
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp b/final/test/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
new file mode 100644
index 0000000..0e829a4
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/complex_times_scalar.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator*(const complex<T>& lhs, const T& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& lhs, const T& rhs, std::complex<T> x)
+{
+    assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    std::complex<T> lhs(1.5, 2.5);
+    T rhs(1.5);
+    std::complex<T>   x(2.25, 3.75);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
new file mode 100644
index 0000000..e16f02e
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/scalar_divide_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator/(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs / rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    T lhs(-8.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(-1.5, 2.5);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
new file mode 100644
index 0000000..0cd9035
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/scalar_equals_complex.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator==(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr T lhs(-2.5);
+    constexpr std::complex<T> rhs(1.5,  2.5);
+    static_assert(!(lhs == rhs), "");
+    }
+    {
+    constexpr T lhs(-2.5);
+    constexpr std::complex<T> rhs(1.5,  0);
+    static_assert(!(lhs == rhs), "");
+    }
+    {
+    constexpr T lhs(1.5);
+    constexpr std::complex<T> rhs(1.5, 2.5);
+    static_assert(!(lhs == rhs), "");
+    }
+    {
+    constexpr T lhs(1.5);
+    constexpr std::complex<T> rhs(1.5, 0);
+    static_assert(lhs == rhs, "");
+    }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  2.5);
+    assert(!(lhs == rhs));
+    }
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  0);
+    assert(!(lhs == rhs));
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 2.5);
+    assert(!(lhs == rhs));
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 0);
+    assert(lhs == rhs);
+    }
+
+    test_constexpr<T> ();
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+//     test_constexpr<int>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
new file mode 100644
index 0000000..35a3749
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/scalar_minus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator-(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs - rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(-2.0, -4.5);
+    test(lhs, rhs, x);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(5.0, -4.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
new file mode 100644
index 0000000..7d6003c
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/scalar_not_equals_complex.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   bool
+//   operator!=(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test_constexpr()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr T lhs(-2.5);
+    constexpr std::complex<T> rhs(1.5,  2.5);
+    static_assert (lhs != rhs, "");
+    }
+    {
+    constexpr T lhs(-2.5);
+    constexpr std::complex<T> rhs(1.5,  0);
+    static_assert (lhs != rhs, "");
+    }
+    {
+    constexpr T lhs(1.5);
+    constexpr std::complex<T> rhs(1.5, 2.5);
+    static_assert (lhs != rhs, "");
+    }
+    {
+    constexpr T lhs(1.5);
+    constexpr std::complex<T> rhs(1.5, 0);
+    static_assert (!(lhs != rhs), "");
+    }
+#endif
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  2.5);
+    assert (lhs != rhs);
+    }
+    {
+    T lhs(-2.5);
+    std::complex<T> rhs(1.5,  0);
+    assert (lhs != rhs);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 2.5);
+    assert (lhs != rhs);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 0);
+    assert (!(lhs != rhs));
+    }
+
+    test_constexpr<T> ();
+    }
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+//     test_constexpr<int>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
new file mode 100644
index 0000000..ec0de5a
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/scalar_plus_complex.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator+(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs + rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(3.5, 4.5);
+    std::complex<T>   x(5.0, 4.5);
+    test(lhs, rhs, x);
+    }
+    {
+    T lhs(1.5);
+    std::complex<T> rhs(-3.5, 4.5);
+    std::complex<T>   x(-2.0, 4.5);
+    test(lhs, rhs, x);
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp b/final/test/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
new file mode 100644
index 0000000..ebff8b2
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/scalar_times_complex.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator*(const T& lhs, const complex<T>& rhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const T& lhs, const std::complex<T>& rhs, std::complex<T> x)
+{
+    assert(lhs * rhs == x);
+}
+
+template <class T>
+void
+test()
+{
+    T lhs(1.5);
+    std::complex<T> rhs(1.5, 2.5);
+    std::complex<T>   x(2.25, 3.75);
+    test(lhs, rhs, x);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/stream_input.pass.cpp b/final/test/numerics/complex.number/complex.ops/stream_input.pass.cpp
new file mode 100644
index 0000000..24644e3
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/stream_input.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits>
+//   basic_istream<charT, traits>&
+//   operator>>(basic_istream<charT, traits>& is, complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        std::istringstream is("5");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5, 0));
+        assert(is.eof());
+    }
+    {
+        std::istringstream is(" 5 ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is(" 5, ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is(" , 5, ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(0, 0));
+        assert(is.fail());
+    }
+    {
+        std::istringstream is("5.5 ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5.5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is(" ( 5.5 ) ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5.5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is("  5.5)");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(5.5, 0));
+        assert(is.good());
+    }
+    {
+        std::istringstream is("(5.5 ");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(0, 0));
+        assert(is.fail());
+    }
+    {
+        std::istringstream is("(5.5,");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(0, 0));
+        assert(is.fail());
+    }
+    {
+        std::istringstream is("( -5.5 , -6.5 )");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(-5.5, -6.5));
+        assert(!is.eof());
+    }
+    {
+        std::istringstream is("(-5.5,-6.5)");
+        std::complex<double> c;
+        is >> c;
+        assert(c == std::complex<double>(-5.5, -6.5));
+        assert(!is.eof());
+    }
+}
diff --git a/final/test/numerics/complex.number/complex.ops/stream_output.pass.cpp b/final/test/numerics/complex.number/complex.ops/stream_output.pass.cpp
new file mode 100644
index 0000000..edb381c
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/stream_output.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T, class charT, class traits>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
+
+#include <complex>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::complex<double> c(1, 2);
+    std::ostringstream os;
+    os << c;
+    assert(os.str() == "(1,2)");
+}
diff --git a/final/test/numerics/complex.number/complex.ops/unary_minus.pass.cpp b/final/test/numerics/complex.number/complex.ops/unary_minus.pass.cpp
new file mode 100644
index 0000000..6a3a201
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/unary_minus.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator-(const complex<T>& lhs);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(z.real() == 1.5);
+    assert(z.imag() == 2.5);
+    std::complex<T> c = -z;
+    assert(c.real() == -1.5);
+    assert(c.imag() == -2.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.ops/unary_plus.pass.cpp b/final/test/numerics/complex.number/complex.ops/unary_plus.pass.cpp
new file mode 100644
index 0000000..5edaad2
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.ops/unary_plus.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   operator+(const complex<T>&);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(z.real() == 1.5);
+    assert(z.imag() == 2.5);
+    std::complex<T> c = +z;
+    assert(c.real() == 1.5);
+    assert(c.imag() == 2.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp b/final/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
new file mode 100644
index 0000000..e8d07ce
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/double_float_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+//     constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp b/final/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
new file mode 100644
index 0000000..298aaa3
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/double_float_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+//     constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<double> cf = cd;
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp b/final/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
new file mode 100644
index 0000000..6ff74a2
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/double_long_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+//     explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<long double> cd(2.5, 3.5);
+    constexpr std::complex<double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp b/final/test/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
new file mode 100644
index 0000000..3866f6e
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/double_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<double>
+// {
+// public:
+//     explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/final/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp b/final/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
new file mode 100644
index 0000000..77ca9d7
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/float_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+//     explicit constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<float> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<double> cd(2.5, 3.5);
+    constexpr std::complex<float> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/float_double_implicit.fail.cpp b/final/test/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
new file mode 100644
index 0000000..d151975
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/float_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+//     explicit constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<float> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/final/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp b/final/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
new file mode 100644
index 0000000..4fb11b4
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/float_long_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+//     explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<float> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<long double> cd(2.5, 3.5);
+    constexpr std::complex<float> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp b/final/test/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
new file mode 100644
index 0000000..9401feb
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/float_long_double_implicit.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<float>
+// {
+// public:
+//     explicit constexpr complex(const complex<long double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    const std::complex<long double> cd(2.5, 3.5);
+    std::complex<float> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+}
diff --git a/final/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp b/final/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
new file mode 100644
index 0000000..dd10c80
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/long_double_double_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+//     constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<long double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<double> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp b/final/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
new file mode 100644
index 0000000..aab5394
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/long_double_double_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+//     constexpr complex(const complex<double>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<double> cd(2.5, 3.5);
+    std::complex<long double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<double> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf = cd;
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp b/final/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
new file mode 100644
index 0000000..a5f5101
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/long_double_float_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+//     constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<long double> cf(cd);
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf(cd);
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp b/final/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
new file mode 100644
index 0000000..25b9382
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.special/long_double_float_implicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<> class complex<long double>
+// {
+// public:
+//     constexpr complex(const complex<float>&);
+// };
+
+#include <complex>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::complex<float> cd(2.5, 3.5);
+    std::complex<long double> cf = cd;
+    assert(cf.real() == cd.real());
+    assert(cf.imag() == cd.imag());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::complex<float> cd(2.5, 3.5);
+    constexpr std::complex<long double> cf = cd;
+    static_assert(cf.real() == cd.real(), "");
+    static_assert(cf.imag() == cd.imag(), "");
+    }
+#endif
+}
diff --git a/final/test/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp b/final/test/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/acos.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/acos.pass.cpp
new file mode 100644
index 0000000..f8ee306
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/acos.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   acos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(acos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(INFINITY, 1), std::complex<T>(0, -INFINITY));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = acos(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            is_about(r.real(), pi/2);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            is_about(r.real(), pi/2);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            is_about(r.real(), pi/2);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && x[i].real() != 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            is_about(r.real(), pi);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(!std::signbit(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+        {
+            is_about(r.real(), 0.75 * pi);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+        {
+            is_about(r.real(), 0.25 * pi);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (!std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert( std::signbit(r.imag()));
+        }
+        else if (std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert( std::signbit(r.imag()));
+        }
+        else if (std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert(!std::signbit(r.imag()));
+        }
+        else if (!std::signbit(x[i].real()) && std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert(!std::signbit(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/acosh.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
new file mode 100644
index 0000000..88a5c79
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/acosh.pass.cpp
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   acosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(acosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(INFINITY, 1), std::complex<T>(INFINITY, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = acosh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(!std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (x[i].real() == 1 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(!std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi);
+            else
+                is_about(r.imag(),  pi);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -0.75 * pi);
+            else
+                is_about(r.imag(),  0.75 * pi);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -0.25 * pi);
+            else
+                is_about(r.imag(),  0.25 * pi);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/asin.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/asin.pass.cpp
new file mode 100644
index 0000000..c743be6
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/asin.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   asin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(asin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = asin(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            if (x[i].real() > 0)
+                is_about(r.real(),  pi/2);
+            else
+                is_about(r.real(), - pi/2);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            if (std::signbit(x[i].real()))
+                is_about(r.real(), -pi/4);
+            else
+                is_about(r.real(),  pi/4);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].real()) != std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/asinh.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
new file mode 100644
index 0000000..027bc6a
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/asinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   asinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(asinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = asinh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/4);
+            else
+                is_about(r.imag(),  pi/4);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/atan.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/atan.pass.cpp
new file mode 100644
index 0000000..69bc952
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/atan.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   atan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(atan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = atan(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> t2 = atanh(t1);
+        std::complex<double> z(imag(t2), -real(t2));
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/atanh.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
new file mode 100644
index 0000000..b821109
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/atanh.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   atanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(atanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = atanh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::abs(x[i].real()) == 1 && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (x[i].imag() > 0)
+                is_about(r.imag(),  pi/2);
+            else
+                is_about(r.imag(), -pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(x[i].real()) == std::signbit(r.real()));
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi/2);
+            else
+                is_about(r.imag(),  pi/2);
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else
+        {
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/cos.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/cos.pass.cpp
new file mode 100644
index 0000000..f25c967
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/cos.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   cos(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(cos(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = cos(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> z = cosh(t1);
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/cosh.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
new file mode 100644
index 0000000..acf4746
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/cosh.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   cosh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(cosh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = cosh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+        }
+        else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(!std::signbit(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(r.real()) == std::signbit(cos(x[i].imag())));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].real() * sin(x[i].imag())));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/exp.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/exp.pass.cpp
new file mode 100644
index 0000000..e8b5075
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/exp.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   exp(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(exp(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(1, 0));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = exp(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 1.0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(r.imag() == 0);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(r.imag() == 0);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() != 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].imag()) && std::abs(x[i].imag()) <= 1)
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/log.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/log.pass.cpp
new file mode 100644
index 0000000..800b924
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/log.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   log(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(log(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = log(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            if (std::signbit(x[i].real()))
+            {
+                assert(std::isinf(r.real()));
+                assert(r.real() < 0);
+                if (std::signbit(x[i].imag()))
+                    is_about(r.imag(), -pi);
+                else
+                    is_about(r.imag(), pi);
+            }
+            else
+            {
+                assert(std::isinf(r.real()));
+                assert(r.real() < 0);
+                assert(r.imag() == 0);
+                assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+            }
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            if (x[i].imag() > 0)
+                is_about(r.imag(), pi/2);
+            else
+                is_about(r.imag(), -pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()) && r.real() > 0);
+            if (r.imag() > 0)
+                is_about(r.imag(), pi);
+            else
+                is_about(r.imag(), -pi);
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()) && r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (x[i].real() == 1 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (x[i].real() == 0 && x[i].imag() == 1)
+        {
+            assert(r.real() == 0);
+            is_about(r.imag(), pi/2);
+        }
+        else if (x[i].real() == -1 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            if (std::signbit(x[i].imag()))
+                is_about(r.imag(), -pi);
+            else
+                is_about(r.imag(),  pi);
+        }
+        else if (x[i].real() == 0 && x[i].imag() == -1)
+        {
+            assert(r.real() == 0);
+            is_about(r.imag(), -pi/2);
+        }
+        else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) < 1)
+        {
+            assert( std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) > 1)
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/log10.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/log10.pass.cpp
new file mode 100644
index 0000000..ba03ebf
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/log10.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   log10(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(log10(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(-INFINITY, 0));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = log10(x[i]);
+        std::complex<double> z = log(x[i])/std::log(10);
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
new file mode 100644
index 0000000..258193d
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/pow_complex_complex.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   pow(const complex<T>& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const std::complex<T>& b, std::complex<T> x)
+{
+    std::complex<T> c = pow(a, b);
+    is_about(real(c), real(x));
+    is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(2, 3), std::complex<T>(2, 0), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = pow(x[i], x[j]);
+            std::complex<double> z = exp(x[j] * log(x[i]));
+            if (std::isnan(real(r)))
+                assert(std::isnan(real(z)));
+            else
+            {
+                assert(real(r) == real(z));
+                assert(std::signbit(real(r)) == std::signbit(real(z)));
+            }
+            if (std::isnan(imag(r)))
+                assert(std::isnan(imag(z)));
+            else
+            {
+                assert(imag(r) == imag(z));
+                assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp
new file mode 100644
index 0000000..03bd10d
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/pow_complex_scalar.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   pow(const complex<T>& x, const T& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& a, const T& b, std::complex<T> x)
+{
+    std::complex<T> c = pow(a, b);
+    is_about(real(c), real(x));
+    is_about(imag(c), imag(x));
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(2, 3), T(2), std::complex<T>(-5, 12));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = pow(x[i], real(x[j]));
+            std::complex<double> z = exp(std::complex<double>(real(x[j])) * log(x[i]));
+            if (std::isnan(real(r)))
+                assert(std::isnan(real(z)));
+            else
+            {
+                assert(real(r) == real(z));
+            }
+            if (std::isnan(imag(r)))
+                assert(std::isnan(imag(z)));
+            else
+            {
+                assert(imag(r) == imag(z));
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp
new file mode 100644
index 0000000..a48498c
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/pow_scalar_complex.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   pow(const T& x, const complex<T>& y);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& a, const std::complex<T>& b, std::complex<T> x)
+{
+    std::complex<T> c = pow(a, b);
+    is_about(real(c), real(x));
+    assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+    test(T(2), std::complex<T>(2), std::complex<T>(4));
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        for (unsigned j = 0; j < N; ++j)
+        {
+            std::complex<double> r = pow(real(x[i]), x[j]);
+            std::complex<double> z = exp(x[j] * log(std::complex<double>(real(x[i]))));
+            if (std::isnan(real(r)))
+                assert(std::isnan(real(z)));
+            else
+            {
+                assert(real(r) == real(z));
+            }
+            if (std::isnan(imag(r)))
+                assert(std::isnan(imag(z)));
+            else
+            {
+                assert(imag(r) == imag(z));
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/sin.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/sin.pass.cpp
new file mode 100644
index 0000000..068222a
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/sin.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   sin(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(sin(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = sin(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> t2 = sinh(t1);
+        std::complex<double> z(imag(t2), -real(t2));
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/sinh.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
new file mode 100644
index 0000000..dcd30e4
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/sinh.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   sinh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(sinh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = sinh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (x[i].real() == 0 && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (x[i].real() == 0 && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::signbit(r.real()) == std::signbit(x[i].real() * cos(x[i].imag())));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(r.imag()) == std::signbit(sin(x[i].imag())));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
new file mode 100644
index 0000000..69309d2
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/sqrt.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   sqrt(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    std::complex<T> a = sqrt(c);
+    is_about(real(a), real(x));
+    assert(std::abs(imag(c)) < 1.e-6);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(64, 0), std::complex<T>(8, 0));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = sqrt(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isinf(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 0);
+            assert(!std::signbit(r.real()));
+            assert(std::isinf(r.imag()));
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(r.imag() == 0);
+            assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isinf(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
+        {
+            assert(std::isinf(r.real()));
+            assert(r.real() > 0);
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && (std::isfinite(x[i].imag()) || std::isnan(x[i].imag())))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::signbit(x[i].imag()))
+        {
+            assert(!std::signbit(r.real()));
+            assert(std::signbit(r.imag()));
+        }
+        else
+        {
+            assert(!std::signbit(r.real()));
+            assert(!std::signbit(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp
new file mode 100644
index 0000000..8814276
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/tan.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   tan(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(tan(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+    test(std::complex<T>(10000, -10000), std::complex<T>(0, -1));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = tan(x[i]);
+        std::complex<double> t1(-imag(x[i]), real(x[i]));
+        std::complex<double> t2 = tanh(t1);
+        std::complex<double> z(imag(t2), -real(t2));
+        if (std::isnan(real(r)))
+            assert(std::isnan(real(z)));
+        else
+        {
+            assert(real(r) == real(z));
+            assert(std::signbit(real(r)) == std::signbit(real(z)));
+        }
+        if (std::isnan(imag(r)))
+            assert(std::isnan(imag(z)));
+        else
+        {
+            assert(imag(r) == imag(z));
+            assert(std::signbit(imag(r)) == std::signbit(imag(z)));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.transcendentals/tanh.pass.cpp b/final/test/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
new file mode 100644
index 0000000..907c0e6
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.transcendentals/tanh.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   tanh(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& c, std::complex<T> x)
+{
+    assert(tanh(c) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(0, 0), std::complex<T>(0, 0));
+}
+
+void test_edges()
+{
+    typedef std::complex<double> C;
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = tanh(x[i]);
+        if (x[i].real() == 0 && x[i].imag() == 0)
+        {
+            assert(r.real() == 0);
+            assert(std::signbit(r.real()) == std::signbit(x[i].real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(sin(2*x[i].imag())));
+        }
+        else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+        }
+        else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(r.real() == 1);
+            assert(r.imag() == 0);
+        }
+        else if (std::isnan(x[i].real()) && x[i].imag() == 0)
+        {
+            assert(std::isnan(r.real()));
+            assert(r.imag() == 0);
+            assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+        else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
+        {
+            assert(std::isnan(r.real()));
+            assert(std::isnan(r.imag()));
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/abs.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/abs.pass.cpp
new file mode 100644
index 0000000..5d841d6
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/abs.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   abs(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(3, 4);
+    assert(abs(z) == 5);
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = abs(x[i]);
+        switch (classify(x[i]))
+        {
+        case zero:
+            assert(r == 0);
+            assert(!std::signbit(r));
+            break;
+        case non_zero:
+            assert(std::isfinite(r) && r > 0);
+            break;
+        case inf:
+            assert(std::isinf(r) && r > 0);
+            break;
+        case NaN:
+            assert(std::isnan(r));
+            break;
+        case non_zero_nan:
+            assert(std::isnan(r));
+            break;
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/arg.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/arg.pass.cpp
new file mode 100644
index 0000000..a7da456
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/arg.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   arg(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1, 0);
+    assert(arg(z) == 0);
+}
+
+void test_edges()
+{
+    const double pi = std::atan2(+0., -0.);
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = arg(x[i]);
+        if (std::isnan(x[i].real()) || std::isnan(x[i].imag()))
+            assert(std::isnan(r));
+        else
+        {
+            switch (classify(x[i]))
+            {
+            case zero:
+                if (std::signbit(x[i].real()))
+                {
+                    if (std::signbit(x[i].imag()))
+                        is_about(r, -pi);
+                    else
+                        is_about(r, pi);
+                }
+                else
+                {
+                    assert(std::signbit(x[i].imag()) == std::signbit(r));
+                }
+                break;
+            case non_zero:
+                if (x[i].real() == 0)
+                {
+                    if (x[i].imag() < 0)
+                        is_about(r, -pi/2);
+                    else
+                        is_about(r, pi/2);
+                }
+                else if (x[i].imag() == 0)
+                {
+                    if (x[i].real() < 0)
+                    {
+                        if (std::signbit(x[i].imag()))
+                            is_about(r, -pi);
+                        else
+                            is_about(r, pi);
+                    }
+                    else
+                    {
+                        assert(r == 0);
+                        assert(std::signbit(x[i].imag()) == std::signbit(r));
+                    }
+                }
+                else if (x[i].imag() > 0)
+                    assert(r > 0);
+                else
+                    assert(r < 0);
+                break;
+            case inf:
+                if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
+                {
+                    if (x[i].real() < 0)
+                    {
+                        if (x[i].imag() > 0)
+                            is_about(r, 0.75 * pi);
+                        else
+                            is_about(r, -0.75 * pi);
+                    }
+                    else
+                    {
+                        if (x[i].imag() > 0)
+                            is_about(r, 0.25 * pi);
+                        else
+                            is_about(r, -0.25 * pi);
+                    }
+                }
+                else if (std::isinf(x[i].real()))
+                {
+                    if (x[i].real() < 0)
+                    {
+                        if (std::signbit(x[i].imag()))
+                            is_about(r, -pi);
+                        else
+                            is_about(r, pi);
+                    }
+                    else
+                    {
+                        assert(r == 0);
+                        assert(std::signbit(r) == std::signbit(x[i].imag()));
+                    }
+                }
+                else
+                {
+                    if (x[i].imag() < 0)
+                        is_about(r, -pi/2);
+                    else
+                        is_about(r, pi/2);
+                }
+                break;
+            }
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/conj.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/conj.pass.cpp
new file mode 100644
index 0000000..71f276d
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/conj.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   conj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+    assert(conj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(1, 2), std::complex<T>(1, -2));
+    test(std::complex<T>(-1, 2), std::complex<T>(-1, -2));
+    test(std::complex<T>(1, -2), std::complex<T>(1, 2));
+    test(std::complex<T>(-1, -2), std::complex<T>(-1, 2));
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/imag.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/imag.pass.cpp
new file mode 100644
index 0000000..fa7b733
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/imag.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   imag(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(imag(z) == 2.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/norm.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/norm.pass.cpp
new file mode 100644
index 0000000..48f774e
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/norm.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   norm(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(3, 4);
+    assert(norm(z) == 25);
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = norm(x[i]);
+        switch (classify(x[i]))
+        {
+        case zero:
+            assert(r == 0);
+            assert(!std::signbit(r));
+            break;
+        case non_zero:
+            assert(std::isfinite(r) && r > 0);
+            break;
+        case inf:
+            assert(std::isinf(r) && r > 0);
+            break;
+        case NaN:
+            assert(std::isnan(r));
+            break;
+        case non_zero_nan:
+            assert(std::isnan(r));
+            break;
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/polar.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/polar.pass.cpp
new file mode 100644
index 0000000..a8747bd
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/polar.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   polar(const T& rho, const T& theta = 0);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const T& rho, std::complex<T> x)
+{
+    assert(std::polar(rho) == x);
+}
+
+template <class T>
+void
+test(const T& rho, const T& theta, std::complex<T> x)
+{
+    assert(std::polar(rho, theta) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(T(0), std::complex<T>(0, 0));
+    test(T(1), std::complex<T>(1, 0));
+    test(T(100), std::complex<T>(100, 0));
+    test(T(0), T(0), std::complex<T>(0, 0));
+    test(T(1), T(0), std::complex<T>(1, 0));
+    test(T(100), T(0), std::complex<T>(100, 0));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        double r = real(x[i]);
+        double theta = imag(x[i]);
+        std::complex<double> z = std::polar(r, theta);
+        switch (classify(r))
+        {
+        case zero:
+            if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            else
+            {
+                assert(z == std::complex<double>());
+            }
+            break;
+        case non_zero:
+            if (std::signbit(r) || classify(theta) == inf || classify(theta) == NaN)
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            else
+            {
+                is_about(std::abs(z), r);
+            }
+            break;
+        case inf:
+            if (r < 0)
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            else
+            {
+                assert(classify(z) == inf);
+                if (classify(theta) != NaN && classify(theta) != inf)
+                {
+                    assert(classify(real(z)) != NaN);
+                    assert(classify(imag(z)) != NaN);
+                }
+            }
+            break;
+        case NaN:
+        case non_zero_nan:
+            {
+                int c = classify(z);
+                assert(c == NaN || c == non_zero_nan);
+            }
+            break;
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/proj.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/proj.pass.cpp
new file mode 100644
index 0000000..10bf7f8
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/proj.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   complex<T>
+//   proj(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+#include "../cases.h"
+
+template <class T>
+void
+test(const std::complex<T>& z, std::complex<T> x)
+{
+    assert(proj(z) == x);
+}
+
+template <class T>
+void
+test()
+{
+    test(std::complex<T>(1, 2), std::complex<T>(1, 2));
+    test(std::complex<T>(-1, 2), std::complex<T>(-1, 2));
+    test(std::complex<T>(1, -2), std::complex<T>(1, -2));
+    test(std::complex<T>(-1, -2), std::complex<T>(-1, -2));
+}
+
+void test_edges()
+{
+    const unsigned N = sizeof(x) / sizeof(x[0]);
+    for (unsigned i = 0; i < N; ++i)
+    {
+        std::complex<double> r = proj(x[i]);
+        switch (classify(x[i]))
+        {
+        case zero:
+        case non_zero:
+            assert(r == x[i]);
+            assert(std::signbit(real(r)) == std::signbit(real(x[i])));
+            assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+            break;
+        case inf:
+            assert(std::isinf(real(r)) && real(r) > 0);
+            assert(imag(r) == 0);
+            assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
+            break;
+        case NaN:
+        case non_zero_nan:
+            assert(classify(r) == classify(x[i]));
+            break;
+        }
+    }
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+    test_edges();
+}
diff --git a/final/test/numerics/complex.number/complex.value.ops/real.pass.cpp b/final/test/numerics/complex.number/complex.value.ops/real.pass.cpp
new file mode 100644
index 0000000..fbb51f0
--- /dev/null
+++ b/final/test/numerics/complex.number/complex.value.ops/real.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+//   T
+//   real(const complex<T>& x);
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z(1.5, 2.5);
+    assert(real(z) == 1.5);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/complex/types.pass.cpp b/final/test/numerics/complex.number/complex/types.pass.cpp
new file mode 100644
index 0000000..4da9a2a
--- /dev/null
+++ b/final/test/numerics/complex.number/complex/types.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+// template<class T>
+// class complex
+// {
+// public:
+//   typedef T value_type;
+//   ...
+// };
+
+#include <complex>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    typedef std::complex<T> C;
+    static_assert((std::is_same<typename C::value_type, T>::value), "");
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/layout.pass.cpp b/final/test/numerics/complex.number/layout.pass.cpp
new file mode 100644
index 0000000..a9f356d
--- /dev/null
+++ b/final/test/numerics/complex.number/layout.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+    std::complex<T> z;
+    T* a = (T*)&z;
+    assert(0 == z.real());
+    assert(0 == z.imag());
+    assert(a[0] == z.real());
+    assert(a[1] == z.imag());
+    a[0] = 5;
+    a[1] = 6;
+    assert(a[0] == z.real());
+    assert(a[1] == z.imag());
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/numerics/complex.number/version.pass.cpp b/final/test/numerics/complex.number/version.pass.cpp
new file mode 100644
index 0000000..316cfec
--- /dev/null
+++ b/final/test/numerics/complex.number/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/numerics/nothing_to_do.pass.cpp b/final/test/numerics/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp b/final/test/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numarray/class.gslice/gslice.access/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp b/final/test/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp
new file mode 100644
index 0000000..29cc34f
--- /dev/null
+++ b/final/test/numerics/numarray/class.gslice/gslice.cons/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class glice;
+
+// gslice();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::gslice gs;
+    assert(gs.start() == 0);
+    assert(gs.size().size() == 0);
+    assert(gs.stride().size() == 0);
+}
diff --git a/final/test/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp b/final/test/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp
new file mode 100644
index 0000000..931c0d3
--- /dev/null
+++ b/final/test/numerics/numarray/class.gslice/gslice.cons/start_size_stride.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class glice;
+
+// gslice(size_t start, const valarray<size_t>& size,
+//                      const valarray<size_t>& stride);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::size_t a1[] = {1, 2, 3};
+    std::size_t a2[] = {4, 5, 6};
+    std::valarray<std::size_t> size(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<std::size_t> stride(a2, sizeof(a2)/sizeof(a2[0]));
+    std::gslice gs(7, size, stride);
+    assert(gs.start() == 7);
+    std::valarray<std::size_t> r = gs.size();
+    assert(r.size() == 3);
+    assert(r[0] == 1);
+    assert(r[1] == 2);
+    assert(r[2] == 3);
+    r = gs.stride();
+    assert(r.size() == 3);
+    assert(r[0] == 4);
+    assert(r[1] == 5);
+    assert(r[2] == 6);
+}
diff --git a/final/test/numerics/numarray/class.gslice/nothing_to_do.pass.cpp b/final/test/numerics/numarray/class.gslice/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numarray/class.gslice/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numarray/class.slice/cons.slice/default.pass.cpp b/final/test/numerics/numarray/class.slice/cons.slice/default.pass.cpp
new file mode 100644
index 0000000..d0a6cc0
--- /dev/null
+++ b/final/test/numerics/numarray/class.slice/cons.slice/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class slice;
+
+// slice();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::slice s;
+    assert(s.start() == 0);
+    assert(s.size() == 0);
+    assert(s.stride() == 0);
+}
diff --git a/final/test/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp b/final/test/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp
new file mode 100644
index 0000000..84f7ed6
--- /dev/null
+++ b/final/test/numerics/numarray/class.slice/cons.slice/start_size_stride.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// class slice;
+
+// slice(size_t start, size_t size, size_t stride);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    std::slice s(1, 3, 2);
+    assert(s.start() == 1);
+    assert(s.size() == 3);
+    assert(s.stride() == 2);
+}
diff --git a/final/test/numerics/numarray/class.slice/nothing_to_do.pass.cpp b/final/test/numerics/numarray/class.slice/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numarray/class.slice/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp b/final/test/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numarray/class.slice/slice.access/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/default.fail.cpp b/final/test/numerics/numarray/template.gslice.array/default.fail.cpp
new file mode 100644
index 0000000..d691cbe
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// gslice_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::gslice_array<int> gs;
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp
new file mode 100644
index 0000000..d26a7b3
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.assign/gslice_array.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// const gslice_array& operator=(const gslice_array& ga) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23,
+                -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35,
+                -36, -37};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    const std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))]
+        = v2[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                            strides(st, sizeof(st)/sizeof(st[0])))];
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -3);
+    assert(v1[ 4] == -4);
+    assert(v1[ 5] == -5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] == -8);
+    assert(v1[ 9] == -9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -11);
+    assert(v1[12] == -12);
+    assert(v1[13] == -13);
+    assert(v1[14] == 14);
+    assert(v1[15] == -15);
+    assert(v1[16] == -16);
+    assert(v1[17] == -17);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -22);
+    assert(v1[23] == -23);
+    assert(v1[24] == -24);
+    assert(v1[25] == 25);
+    assert(v1[26] == -26);
+    assert(v1[27] == -27);
+    assert(v1[28] == -28);
+    assert(v1[29] == 29);
+    assert(v1[30] == -30);
+    assert(v1[31] == -31);
+    assert(v1[32] == -32);
+    assert(v1[33] == 33);
+    assert(v1[34] == -34);
+    assert(v1[35] == -35);
+    assert(v1[36] == -36);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp
new file mode 100644
index 0000000..2f960c1
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.assign/valarray.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] = v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 0);
+    assert(v1[ 4] == -1);
+    assert(v1[ 5] == -2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] == -4);
+    assert(v1[ 9] == -5);
+    assert(v1[10] == 10);
+    assert(v1[11] == -6);
+    assert(v1[12] == -7);
+    assert(v1[13] == -8);
+    assert(v1[14] == 14);
+    assert(v1[15] == -9);
+    assert(v1[16] == -10);
+    assert(v1[17] == -11);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -12);
+    assert(v1[23] == -13);
+    assert(v1[24] == -14);
+    assert(v1[25] == 25);
+    assert(v1[26] == -15);
+    assert(v1[27] == -16);
+    assert(v1[28] == -17);
+    assert(v1[29] == 29);
+    assert(v1[30] == -18);
+    assert(v1[31] == -19);
+    assert(v1[32] == -20);
+    assert(v1[33] == 33);
+    assert(v1[34] == -21);
+    assert(v1[35] == -22);
+    assert(v1[36] == -23);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..bd2ad70
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator+= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] += v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  3);
+    assert(v1[ 5] ==  3);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  4);
+    assert(v1[ 9] ==  4);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  5);
+    assert(v1[12] ==  5);
+    assert(v1[13] ==  5);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  6);
+    assert(v1[16] ==  6);
+    assert(v1[17] ==  6);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 10);
+    assert(v1[23] == 10);
+    assert(v1[24] == 10);
+    assert(v1[25] == 25);
+    assert(v1[26] == 11);
+    assert(v1[27] == 11);
+    assert(v1[28] == 11);
+    assert(v1[29] == 29);
+    assert(v1[30] == 12);
+    assert(v1[31] == 12);
+    assert(v1[32] == 12);
+    assert(v1[33] == 33);
+    assert(v1[34] == 13);
+    assert(v1[35] == 13);
+    assert(v1[36] == 13);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..6875c5e
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/and.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator&= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] &= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  3);
+    assert(v1[12] ==  8);
+    assert(v1[13] ==  9);
+    assert(v1[14] == 14);
+    assert(v1[15] == 10);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  4);
+    assert(v1[23] ==  6);
+    assert(v1[24] ==  8);
+    assert(v1[25] == 25);
+    assert(v1[26] == 16);
+    assert(v1[27] == 17);
+    assert(v1[28] == 16);
+    assert(v1[29] == 29);
+    assert(v1[30] == 18);
+    assert(v1[31] == 20);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  2);
+    assert(v1[35] ==  3);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..33a0032
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator/= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] /= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  1);
+    assert(v1[ 9] ==  1);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] ==  1);
+    assert(v1[13] ==  1);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  1);
+    assert(v1[16] ==  1);
+    assert(v1[17] ==  1);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  1);
+    assert(v1[23] ==  1);
+    assert(v1[24] ==  1);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  1);
+    assert(v1[27] ==  1);
+    assert(v1[28] ==  1);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  1);
+    assert(v1[31] ==  1);
+    assert(v1[32] ==  1);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  1);
+    assert(v1[35] ==  1);
+    assert(v1[36] ==  1);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..addc43d
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator%= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] %= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..37555fd
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator*= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] *= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  8);
+    assert(v1[ 5] == 15);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 28);
+    assert(v1[ 8] == 40);
+    assert(v1[ 9] == 54);
+    assert(v1[10] == 10);
+    assert(v1[11] == 77);
+    assert(v1[12] == 96);
+    assert(v1[13] == 117);
+    assert(v1[14] == 14);
+    assert(v1[15] == 150);
+    assert(v1[16] == 176);
+    assert(v1[17] == 204);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 286);
+    assert(v1[23] == 322);
+    assert(v1[24] == 360);
+    assert(v1[25] == 25);
+    assert(v1[26] == 416);
+    assert(v1[27] == 459);
+    assert(v1[28] == 504);
+    assert(v1[29] == 29);
+    assert(v1[30] == 570);
+    assert(v1[31] == 620);
+    assert(v1[32] == 672);
+    assert(v1[33] == 33);
+    assert(v1[34] == 748);
+    assert(v1[35] == 805);
+    assert(v1[36] == 864);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..24e96e8
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/or.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator|= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] |= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  7);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 15);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 31);
+    assert(v1[23] == 31);
+    assert(v1[24] == 31);
+    assert(v1[25] == 25);
+    assert(v1[26] == 26);
+    assert(v1[27] == 27);
+    assert(v1[28] == 30);
+    assert(v1[29] == 29);
+    assert(v1[30] == 31);
+    assert(v1[31] == 31);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 54);
+    assert(v1[35] == 55);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..ddaf4f7
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator<<= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] <<= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  6);
+    assert(v1[ 4] == 16);
+    assert(v1[ 5] == 40);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 112);
+    assert(v1[ 8] == 256);
+    assert(v1[ 9] == 576);
+    assert(v1[10] == 10);
+    assert(v1[11] == 1408);
+    assert(v1[12] == 3072);
+    assert(v1[13] == 6656);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15360);
+    assert(v1[16] == 32768);
+    assert(v1[17] == 69632);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 180224);
+    assert(v1[23] == 376832);
+    assert(v1[24] == 786432);
+    assert(v1[25] == 25);
+    assert(v1[26] == 1703936);
+    assert(v1[27] == 3538944);
+    assert(v1[28] == 7340032);
+    assert(v1[29] == 29);
+    assert(v1[30] == 15728640);
+    assert(v1[31] == 32505856);
+    assert(v1[32] == 67108864);
+    assert(v1[33] == 33);
+    assert(v1[34] == 142606336);
+    assert(v1[35] == 293601280);
+    assert(v1[36] == 603979776);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..4c06a29
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator>>= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] >>= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  0);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  0);
+    assert(v1[12] ==  0);
+    assert(v1[13] ==  0);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  0);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  0);
+    assert(v1[23] ==  0);
+    assert(v1[24] ==  0);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  0);
+    assert(v1[27] ==  0);
+    assert(v1[28] ==  0);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  0);
+    assert(v1[31] ==  0);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  0);
+    assert(v1[35] ==  0);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..3feda53
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator-= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] -= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..1259351
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator^= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] ^= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  6);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 12);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 27);
+    assert(v1[23] == 25);
+    assert(v1[24] == 23);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 14);
+    assert(v1[29] == 29);
+    assert(v1[30] == 13);
+    assert(v1[31] == 11);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 52);
+    assert(v1[35] == 52);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp b/final/test/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..5c5591a
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/gslice.array.fill/assign_value.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class gslice_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] = 51;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 51);
+    assert(v1[ 4] == 51);
+    assert(v1[ 5] == 51);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 51);
+    assert(v1[ 8] == 51);
+    assert(v1[ 9] == 51);
+    assert(v1[10] == 10);
+    assert(v1[11] == 51);
+    assert(v1[12] == 51);
+    assert(v1[13] == 51);
+    assert(v1[14] == 14);
+    assert(v1[15] == 51);
+    assert(v1[16] == 51);
+    assert(v1[17] == 51);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 51);
+    assert(v1[23] == 51);
+    assert(v1[24] == 51);
+    assert(v1[25] == 25);
+    assert(v1[26] == 51);
+    assert(v1[27] == 51);
+    assert(v1[28] == 51);
+    assert(v1[29] == 29);
+    assert(v1[30] == 51);
+    assert(v1[31] == 51);
+    assert(v1[32] == 51);
+    assert(v1[33] == 33);
+    assert(v1[34] == 51);
+    assert(v1[35] == 51);
+    assert(v1[36] == 51);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.gslice.array/types.pass.cpp b/final/test/numerics/numarray/template.gslice.array/types.pass.cpp
new file mode 100644
index 0000000..005d907
--- /dev/null
+++ b/final/test/numerics/numarray/template.gslice.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class gslice_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::gslice_array<int>::value_type, int>::value), "");
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/default.fail.cpp b/final/test/numerics/numarray/template.indirect.array/default.fail.cpp
new file mode 100644
index 0000000..2f5e5d8
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// indirect_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::indirect_array<int> ia;
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp
new file mode 100644
index 0000000..9c7c816
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.assign/indirect_array.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// const indirect_array& operator=(const indirect_array& ia) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23,
+                -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35,
+                -36, -37};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a1, N1);
+    const std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, S);
+    v1[ia] = v2[ia];
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -3);
+    assert(v1[ 4] == -4);
+    assert(v1[ 5] == -5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] == -8);
+    assert(v1[ 9] == -9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -11);
+    assert(v1[12] == -12);
+    assert(v1[13] == -13);
+    assert(v1[14] == 14);
+    assert(v1[15] == -15);
+    assert(v1[16] == -16);
+    assert(v1[17] == -17);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -22);
+    assert(v1[23] == -23);
+    assert(v1[24] == -24);
+    assert(v1[25] == 25);
+    assert(v1[26] == -26);
+    assert(v1[27] == -27);
+    assert(v1[28] == -28);
+    assert(v1[29] == 29);
+    assert(v1[30] == -30);
+    assert(v1[31] == -31);
+    assert(v1[32] == -32);
+    assert(v1[33] == 33);
+    assert(v1[34] == -34);
+    assert(v1[35] == -35);
+    assert(v1[36] == -36);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp
new file mode 100644
index 0000000..ad934aa
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.assign/valarray.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] = v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 0);
+    assert(v1[ 4] == -1);
+    assert(v1[ 5] == -2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] == -4);
+    assert(v1[ 9] == -5);
+    assert(v1[10] == 10);
+    assert(v1[11] == -6);
+    assert(v1[12] == -7);
+    assert(v1[13] == -8);
+    assert(v1[14] == 14);
+    assert(v1[15] == -9);
+    assert(v1[16] == -10);
+    assert(v1[17] == -11);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -12);
+    assert(v1[23] == -13);
+    assert(v1[24] == -14);
+    assert(v1[25] == 25);
+    assert(v1[26] == -15);
+    assert(v1[27] == -16);
+    assert(v1[28] == -17);
+    assert(v1[29] == 29);
+    assert(v1[30] == -18);
+    assert(v1[31] == -19);
+    assert(v1[32] == -20);
+    assert(v1[33] == 33);
+    assert(v1[34] == -21);
+    assert(v1[35] == -22);
+    assert(v1[36] == -23);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..fa966d1
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator+=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] += v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  3);
+    assert(v1[ 5] ==  3);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  4);
+    assert(v1[ 9] ==  4);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  5);
+    assert(v1[12] ==  5);
+    assert(v1[13] ==  5);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  6);
+    assert(v1[16] ==  6);
+    assert(v1[17] ==  6);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 10);
+    assert(v1[23] == 10);
+    assert(v1[24] == 10);
+    assert(v1[25] == 25);
+    assert(v1[26] == 11);
+    assert(v1[27] == 11);
+    assert(v1[28] == 11);
+    assert(v1[29] == 29);
+    assert(v1[30] == 12);
+    assert(v1[31] == 12);
+    assert(v1[32] == 12);
+    assert(v1[33] == 33);
+    assert(v1[34] == 13);
+    assert(v1[35] == 13);
+    assert(v1[36] == 13);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..60f0552
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/and.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator&=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] &= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  3);
+    assert(v1[12] ==  8);
+    assert(v1[13] ==  9);
+    assert(v1[14] == 14);
+    assert(v1[15] == 10);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  4);
+    assert(v1[23] ==  6);
+    assert(v1[24] ==  8);
+    assert(v1[25] == 25);
+    assert(v1[26] == 16);
+    assert(v1[27] == 17);
+    assert(v1[28] == 16);
+    assert(v1[29] == 29);
+    assert(v1[30] == 18);
+    assert(v1[31] == 20);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  2);
+    assert(v1[35] ==  3);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..11b5d83
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator/=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] /= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  1);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  1);
+    assert(v1[ 9] ==  1);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] ==  1);
+    assert(v1[13] ==  1);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  1);
+    assert(v1[16] ==  1);
+    assert(v1[17] ==  1);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  1);
+    assert(v1[23] ==  1);
+    assert(v1[24] ==  1);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  1);
+    assert(v1[27] ==  1);
+    assert(v1[28] ==  1);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  1);
+    assert(v1[31] ==  1);
+    assert(v1[32] ==  1);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  1);
+    assert(v1[35] ==  1);
+    assert(v1[36] ==  1);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..4c63684
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator%=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] %= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..e477353
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator*=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] *= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  8);
+    assert(v1[ 5] == 15);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 28);
+    assert(v1[ 8] == 40);
+    assert(v1[ 9] == 54);
+    assert(v1[10] == 10);
+    assert(v1[11] == 77);
+    assert(v1[12] == 96);
+    assert(v1[13] == 117);
+    assert(v1[14] == 14);
+    assert(v1[15] == 150);
+    assert(v1[16] == 176);
+    assert(v1[17] == 204);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 286);
+    assert(v1[23] == 322);
+    assert(v1[24] == 360);
+    assert(v1[25] == 25);
+    assert(v1[26] == 416);
+    assert(v1[27] == 459);
+    assert(v1[28] == 504);
+    assert(v1[29] == 29);
+    assert(v1[30] == 570);
+    assert(v1[31] == 620);
+    assert(v1[32] == 672);
+    assert(v1[33] == 33);
+    assert(v1[34] == 748);
+    assert(v1[35] == 805);
+    assert(v1[36] == 864);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..b74ce86
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/or.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator|=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] |= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  7);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 15);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 31);
+    assert(v1[23] == 31);
+    assert(v1[24] == 31);
+    assert(v1[25] == 25);
+    assert(v1[26] == 26);
+    assert(v1[27] == 27);
+    assert(v1[28] == 30);
+    assert(v1[29] == 29);
+    assert(v1[30] == 31);
+    assert(v1[31] == 31);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 54);
+    assert(v1[35] == 55);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..e23f142
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] <<= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  6);
+    assert(v1[ 4] == 16);
+    assert(v1[ 5] == 40);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 112);
+    assert(v1[ 8] == 256);
+    assert(v1[ 9] == 576);
+    assert(v1[10] == 10);
+    assert(v1[11] == 1408);
+    assert(v1[12] == 3072);
+    assert(v1[13] == 6656);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15360);
+    assert(v1[16] == 32768);
+    assert(v1[17] == 69632);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 180224);
+    assert(v1[23] == 376832);
+    assert(v1[24] == 786432);
+    assert(v1[25] == 25);
+    assert(v1[26] == 1703936);
+    assert(v1[27] == 3538944);
+    assert(v1[28] == 7340032);
+    assert(v1[29] == 29);
+    assert(v1[30] == 15728640);
+    assert(v1[31] == 32505856);
+    assert(v1[32] == 67108864);
+    assert(v1[33] == 33);
+    assert(v1[34] == 142606336);
+    assert(v1[35] == 293601280);
+    assert(v1[36] == 603979776);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..33db33f
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] >>= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  0);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  0);
+    assert(v1[ 9] ==  0);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  0);
+    assert(v1[12] ==  0);
+    assert(v1[13] ==  0);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  0);
+    assert(v1[16] ==  0);
+    assert(v1[17] ==  0);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  0);
+    assert(v1[23] ==  0);
+    assert(v1[24] ==  0);
+    assert(v1[25] == 25);
+    assert(v1[26] ==  0);
+    assert(v1[27] ==  0);
+    assert(v1[28] ==  0);
+    assert(v1[29] == 29);
+    assert(v1[30] ==  0);
+    assert(v1[31] ==  0);
+    assert(v1[32] ==  0);
+    assert(v1[33] == 33);
+    assert(v1[34] ==  0);
+    assert(v1[35] ==  0);
+    assert(v1[36] ==  0);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..dd2d35f
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator-=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] -= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  3);
+    assert(v1[ 9] ==  3);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  4);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] ==  5);
+    assert(v1[17] ==  5);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] ==  9);
+    assert(v1[23] ==  9);
+    assert(v1[24] ==  9);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 10);
+    assert(v1[29] == 29);
+    assert(v1[30] == 11);
+    assert(v1[31] == 11);
+    assert(v1[32] == 11);
+    assert(v1[33] == 33);
+    assert(v1[34] == 12);
+    assert(v1[35] == 12);
+    assert(v1[36] == 12);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..f2c3427
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator^=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {  1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,
+                 13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23, 24};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    std::size_t s[N2] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                         22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    std::valarray<std::size_t> ia(s, N2);
+    v1[ia] ^= v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  6);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] == 13);
+    assert(v1[ 9] == 15);
+    assert(v1[10] == 10);
+    assert(v1[11] == 12);
+    assert(v1[12] ==  4);
+    assert(v1[13] ==  4);
+    assert(v1[14] == 14);
+    assert(v1[15] ==  5);
+    assert(v1[16] == 27);
+    assert(v1[17] == 29);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 27);
+    assert(v1[23] == 25);
+    assert(v1[24] == 23);
+    assert(v1[25] == 25);
+    assert(v1[26] == 10);
+    assert(v1[27] == 10);
+    assert(v1[28] == 14);
+    assert(v1[29] == 29);
+    assert(v1[30] == 13);
+    assert(v1[31] == 11);
+    assert(v1[32] == 53);
+    assert(v1[33] == 33);
+    assert(v1[34] == 52);
+    assert(v1[35] == 52);
+    assert(v1[36] == 60);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp b/final/test/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..de2bb43
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/indirect.array.fill/assign_value.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class indirect_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a1, N1);
+    std::valarray<std::size_t> ia(s, S);
+    v1[ia] = 51;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 51);
+    assert(v1[ 4] == 51);
+    assert(v1[ 5] == 51);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 51);
+    assert(v1[ 8] == 51);
+    assert(v1[ 9] == 51);
+    assert(v1[10] == 10);
+    assert(v1[11] == 51);
+    assert(v1[12] == 51);
+    assert(v1[13] == 51);
+    assert(v1[14] == 14);
+    assert(v1[15] == 51);
+    assert(v1[16] == 51);
+    assert(v1[17] == 51);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == 51);
+    assert(v1[23] == 51);
+    assert(v1[24] == 51);
+    assert(v1[25] == 25);
+    assert(v1[26] == 51);
+    assert(v1[27] == 51);
+    assert(v1[28] == 51);
+    assert(v1[29] == 29);
+    assert(v1[30] == 51);
+    assert(v1[31] == 51);
+    assert(v1[32] == 51);
+    assert(v1[33] == 33);
+    assert(v1[34] == 51);
+    assert(v1[35] == 51);
+    assert(v1[36] == 51);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.indirect.array/types.pass.cpp b/final/test/numerics/numarray/template.indirect.array/types.pass.cpp
new file mode 100644
index 0000000..fe118ea
--- /dev/null
+++ b/final/test/numerics/numarray/template.indirect.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class indirect_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::indirect_array<int>::value_type, int>::value), "");
+}
diff --git a/final/test/numerics/numarray/template.mask.array/default.fail.cpp b/final/test/numerics/numarray/template.mask.array/default.fail.cpp
new file mode 100644
index 0000000..97476c6
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// mask_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::mask_array<int> s;
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp
new file mode 100644
index 0000000..3bab0df
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.assign/mask_array.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void mask_array& operator=(const mask_array& ma) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b1[N1] = {true,  false, false, true,  true,  false,
+                   false, true,  false, false, false, true};
+    int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b2[N2] = {true,  false, true, true,
+                   false, false, true, true};
+    std::valarray<int> v1(a1, N1);
+    const std::valarray<int> v2(a2, N2);
+    std::valarray<bool> vb1(b1, N1);
+    std::valarray<bool> vb2(b2, N2);
+    v1[vb1] = v2[vb2];
+    assert(v1.size() == 16);
+    assert(v1[ 0] == -1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -3);
+    assert(v1[ 4] == -4);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -8);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp
new file mode 100644
index 0000000..63949e2
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.assign/valarray.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] = v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  3);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  5);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..9847629
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/addition.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator+=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] += v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  5);
+    assert(v1[ 4] ==  7);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 11);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 16);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..7e110b1
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/and.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator&=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] &= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  2);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..9fe2438
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/divide.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator/=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] /= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  2);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..bd0ee08
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/modulo.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator%=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] %= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  1);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..13efefc
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/multiply.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator*=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] *= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  6);
+    assert(v1[ 4] == 12);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 28);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 55);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..9b06879
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/or.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator|=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] |= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  7);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 15);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..9c1f92a
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] <<= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == 12);
+    assert(v1[ 4] == 32);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 112);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 352);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..438d342
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] >>= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  0);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..16e387d
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator-=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] -= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] == -1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] ==  6);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..ae3c238
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.comp.assign/xor.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator^=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    int a2[] = {1, 2, 3, 4, 5};
+    const std::size_t N2 = sizeof(a2)/sizeof(a2[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<int> v2(a2, N2);
+    assert(N2 == std::count(b, b+N1, true));
+    std::valarray<bool> vb(b, N1);
+    v1[vb] ^= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  1);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  1);
+    assert(v1[ 4] ==  7);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == 14);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp b/final/test/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..c37916b
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/mask.array.fill/assign_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class mask_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    v1[vb] = -5;
+    assert(v1.size() == 16);
+    assert(v1[ 0] == -5);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] == -5);
+    assert(v1[ 4] == -5);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -5);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 10);
+    assert(v1[11] == -5);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.mask.array/types.pass.cpp b/final/test/numerics/numarray/template.mask.array/types.pass.cpp
new file mode 100644
index 0000000..c984c3f
--- /dev/null
+++ b/final/test/numerics/numarray/template.mask.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class mask_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::mask_array<int>::value_type, int>::value), "");
+}
diff --git a/final/test/numerics/numarray/template.slice.array/default.fail.cpp b/final/test/numerics/numarray/template.slice.array/default.fail.cpp
new file mode 100644
index 0000000..3b522f0
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/default.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// slice_array() = delete;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    std::slice_array<int> s;
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp
new file mode 100644
index 0000000..b2b111a
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// const slice_array& operator=(const slice_array& sa) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    const std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] = v2[std::slice(2, 5, 2)];
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -3);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -5);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -9);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -11);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
new file mode 100644
index 0000000..d385786
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] = v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -4);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -5);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp
new file mode 100644
index 0000000..8b5bf75
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator+= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] += v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  6);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  8);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp
new file mode 100644
index 0000000..dbcae84
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator&= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] &= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  0);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  5);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp
new file mode 100644
index 0000000..7178501
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator/= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] /= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -2);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -2);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -2);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp
new file mode 100644
index 0000000..e08fb51
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator%= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] %= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  0);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  1);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  2);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  3);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp
new file mode 100644
index 0000000..257c031
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator*= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] *= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -8);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -21);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -40);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -65);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp
new file mode 100644
index 0000000..0826708
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator|= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] |= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  7);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 14);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 13);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp
new file mode 100644
index 0000000..84360d8
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] <<= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  2);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == 16);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 56);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 160);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 416);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp
new file mode 100644
index 0000000..c39cd53
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] >>= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  1);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  0);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] ==  0);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  0);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp
new file mode 100644
index 0000000..e6419fb
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator-= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] -= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  2);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 10);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 14);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 18);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp
new file mode 100644
index 0000000..294106e
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator^= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {1, 2, 3, 4, 5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] ^= v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  0);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] ==  6);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] ==  4);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 14);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] ==  8);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp b/final/test/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp
new file mode 100644
index 0000000..4f7af4b
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    v1[std::slice(1, 5, 3)] = 20;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == 20);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == 20);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == 20);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == 20);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == 20);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.slice.array/types.pass.cpp b/final/test/numerics/numarray/template.slice.array/types.pass.cpp
new file mode 100644
index 0000000..8c40b15
--- /dev/null
+++ b/final/test/numerics/numarray/template.slice.array/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class slice_array
+// {
+// public:
+//     typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::slice_array<int>::value_type, int>::value), "");
+}
diff --git a/final/test/numerics/numarray/template.valarray/types.pass.cpp b/final/test/numerics/numarray/template.valarray/types.pass.cpp
new file mode 100644
index 0000000..71421e5
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T>
+// class valarray
+// {
+// public:
+//     typedef T value_type;
+//     ...
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::valarray<int>::value_type, int>::value), "");
+    static_assert((std::is_same<std::valarray<double>::value_type, double>::value), "");
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.access/access.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.access/access.pass.cpp
new file mode 100644
index 0000000..7bf164a
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.access/access.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type& operator[](size_t i);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {5, 4, 3, 2, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v[i] == a[i]);
+            v[i] = i;
+            assert(v[i] == i);
+        }
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp
new file mode 100644
index 0000000..b9736ee
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// const value_type& operator[](size_t i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {5, 4, 3, 2, 1};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        const std::valarray<T> v(a, N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v[i] == a[i]);
+        }
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp
new file mode 100644
index 0000000..2fc42ad
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2(a, N-2);
+        v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == v[i][j]);
+        }
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp
new file mode 100644
index 0000000..dff523f
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const gslice_array<value_type>& ga);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    std::valarray<int> v(24);
+    v = v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                          strides(st, sizeof(st)/sizeof(st[0])))];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp
new file mode 100644
index 0000000..6e8069c
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v(24);
+    v = v1[ia];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp
new file mode 100644
index 0000000..571f56a
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(initializer_list<value_type> il);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v2;
+        v2 = {1, 2, 3, 4, 5};
+        assert(v2.size() == N);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v2;
+        v2 = {1, 2.5, 3, 4.25, 5};
+        assert(v2.size() == N);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v2(a, N-2);
+        v2 = {T(1), T(2), T(3), T(4), T(5)};
+        assert(v2.size() == N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == a[i].size());
+            for (int j = 0; j < a[i].size(); ++j)
+                assert(v2[i][j] == a[i][j]);
+        }
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp
new file mode 100644
index 0000000..a52c9d9
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(5);
+    v2 = v1[vb];
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp
new file mode 100644
index 0000000..d4f7506
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(valarray&& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2;
+        v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2(a, N-2);
+        v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == a[i].size());
+            for (int j = 0; j < a[i].size(); ++j)
+                assert(v2[i][j] == a[i][j]);
+        }
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp
new file mode 100644
index 0000000..9a7517a
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::valarray<int> v(5);
+    v = v1[std::slice(1, 5, 3)];
+    assert(v.size() == 5);
+    assert(v[0] == 1);
+    assert(v[1] == 4);
+    assert(v[2] == 7);
+    assert(v[3] == 10);
+    assert(v[4] == 13);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp
new file mode 100644
index 0000000..b9d67f8
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        v = 7;
+        assert(v.size() == N);
+        for (int i = 0; i < v.size(); ++i)
+            assert(v[i] == 7);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp
new file mode 100644
index 0000000..5b1c1b9
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {0,  2,  0,  0,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 &= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp
new file mode 100644
index 0000000..2106a13
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 1,   2,  3,  0,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 &= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp
new file mode 100644
index 0000000..3992d0a
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {6, 14, 24, 36, 50};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v3 /= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp
new file mode 100644
index 0000000..7bd1cc8
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v2 /= 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp
new file mode 100644
index 0000000..e3d308a
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  9, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v3 -= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp
new file mode 100644
index 0000000..27ea8c2
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = {-2,  -1,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 -= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp
new file mode 100644
index 0000000..1754a55
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {0,  1,  2,  1,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v2 %= v1;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v2[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp
new file mode 100644
index 0000000..794a0b6
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {1,  2,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 %= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp
new file mode 100644
index 0000000..0d70b4e
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  7, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 |= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp
new file mode 100644
index 0000000..4030907
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 3,   3,  3,  7,  7};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 |= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp
new file mode 100644
index 0000000..fdf999c
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  9, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 += v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp
new file mode 100644
index 0000000..23d6d9d
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {4,  5,  6,  7,  8};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 += 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp
new file mode 100644
index 0000000..ad44e38
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,   3,    4,    5};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = {64, 256, 768, 2048, 5120};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 <<= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp
new file mode 100644
index 0000000..366407a
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 8,  16, 24, 32, 40};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 <<= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp
new file mode 100644
index 0000000..f7df16b
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,   3,    4,    5};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = {64, 256, 768, 2048, 5120};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v3 >>= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp
new file mode 100644
index 0000000..7c568b1
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 8,  16, 24, 32, 40};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v2 >>= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp
new file mode 100644
index 0000000..d3cf1eb
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {6, 14, 24, 36, 50};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 *= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp
new file mode 100644
index 0000000..aea9806
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 *= 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp
new file mode 100644
index 0000000..a10bd7e
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  5, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3(a3, N);
+        v1 ^= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp
new file mode 100644
index 0000000..327952f
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0,  7,  6};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        v1 ^= 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp
new file mode 100644
index 0000000..04ac2cd
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == v[i][j]);
+        }
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp
new file mode 100644
index 0000000..f46e0bf
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        std::valarray<int> v;
+        assert(v.size() == 0);
+    }
+    {
+        std::valarray<float> v;
+        assert(v.size() == 0);
+    }
+    {
+        std::valarray<double> v;
+        assert(v.size() == 0);
+    }
+    {
+        std::valarray<std::valarray<double> > v;
+        assert(v.size() == 0);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp
new file mode 100644
index 0000000..56601dc
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const gslice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                                         strides(st, sizeof(st)/sizeof(st[0])))]);
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp
new file mode 100644
index 0000000..dbca1f9
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v(v1[ia]);
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..1ab460f
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(initializer_list<value_type>);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v = {1, 2, 3, 4, 5};
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v = {1, 2, 3, 4, 5};
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp
new file mode 100644
index 0000000..be4f740
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(v1[vb]);
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp
new file mode 100644
index 0000000..6ac8773
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = std::move(v);
+        assert(v2.size() == N);
+        assert(v.size() == 0);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == a[i].size());
+            for (int j = 0; j < v2[i].size(); ++j)
+                assert(v2[i][j] == a[i][j]);
+        }
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp
new file mode 100644
index 0000000..3d3649e
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type* p, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+            assert(v[i] == a[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        assert(v.size() == N);
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v[i].size() == a[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v[i][j] == a[i][j]);
+        }
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
new file mode 100644
index 0000000..359073e
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// explicit valarray(size_t);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        std::valarray<int> v(100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 0);
+    }
+    {
+        std::valarray<double> v(100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 0);
+    }
+    {
+        std::valarray<std::valarray<double> > v(100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i].size() == 0);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp
new file mode 100644
index 0000000..b676414
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::valarray<int> v(v1[std::slice(1, 5, 3)]);
+    assert(v.size() == 5);
+    assert(v[0] == 1);
+    assert(v[1] == 4);
+    assert(v[2] == 7);
+    assert(v[3] == 10);
+    assert(v[4] == 13);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp
new file mode 100644
index 0000000..336c898
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type& x, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        std::valarray<int> v(5, 100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 5);
+    }
+    {
+        std::valarray<double> v(2.5, 100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i] == 2.5);
+    }
+    {
+        std::valarray<std::valarray<double> > v(std::valarray<double>(10), 100);
+        assert(v.size() == 100);
+        for (int i = 0; i < 100; ++i)
+            assert(v[i].size() == 10);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp
new file mode 100644
index 0000000..919a3a5
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(const value_type&)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(const T& t) {return t + 5;}
+
+int main()
+{
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+    }
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1+v1).apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp
new file mode 100644
index 0000000..dc7a1a1
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(value_type)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(T t) {return t + 5;}
+
+int main()
+{
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.apply(f);
+        assert(v2.size() == N1);
+    }
+    {
+        T a1[] = {1, 2, 3, 4,  5,  6,  7,  8,  9, 10};
+        T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1+v1).apply(f);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp
new file mode 100644
index 0000000..601a6df
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray cshift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(0);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(10);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(17);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(-3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(-10);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.cshift(-17);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.cshift(-17);
+        assert(v2.size() == N1);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 10, 12, 14, 16, 18, 20, 2, 4, 6};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).cshift(3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {16, 18, 20, 2, 4, 6, 8, 10, 12, 14};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).cshift(-3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/max.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
new file mode 100644
index 0000000..697d4cd
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type max() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, -5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.max() == 4.0);
+    }
+    {
+        typedef double T;
+        std::valarray<T> v1;
+        v1.max();
+    }
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, -5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert((2*v1).max() == 8.0);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/min.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
new file mode 100644
index 0000000..dac5934
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type min() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, 5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.min() == -3.0);
+    }
+    {
+        typedef double T;
+        std::valarray<T> v1;
+        v1.min();
+    }
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, -3, 4, 5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert((2*v1).min() == -6.0);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp
new file mode 100644
index 0000000..176d958
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void resize(size_t n, value_type x = value_type());
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        v1.resize(8);
+        assert(v1.size() == 8);
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == 0);
+        v1.resize(0);
+        assert(v1.size() == 0);
+        v1.resize(80);
+        assert(v1.size() == 80);
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == 0);
+        v1.resize(40);
+        assert(v1.size() == 40);
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == 0);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp
new file mode 100644
index 0000000..9a617a9
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray shift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(0);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(1);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(9);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(90);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(-1);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(-9);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = v1.shift(-90);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2 = v1.shift(-90);
+        assert(v2.size() == N1);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {8, 10, 12, 14, 16, 18, 20, 0, 0, 0};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).shift(3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+        T a2[] = {0, 0, 0, 2, 4, 6, 8, 10, 12, 14};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2 = (v1 + v1).shift(-3);
+        assert(v2.size() == N1);
+        for (unsigned i = 0; i < N1; ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/size.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/size.pass.cpp
new file mode 100644
index 0000000..0aae5b8
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/size.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// size_t size() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.size() == N1);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = 0;
+        std::valarray<T> v1(a1, N1);
+        assert(v1.size() == N1);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        std::valarray<T> v1;
+        assert(v1.size() == N1);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp
new file mode 100644
index 0000000..189f03d
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type sum() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5, 2.5, 3, 4, 5.5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N1);
+        assert(v1.sum() == 16.5);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp
new file mode 100644
index 0000000..a90a809
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void swap(valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = 0;
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = 0;
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1;
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        const unsigned N2 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        v1.swap(v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp
new file mode 100644
index 0000000..7bbd48c
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// gslice_array<value_type> operator[](const gslice& gs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+                36, 37, 38, 39, 40};
+    int a2[] = { -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9, -10, -11,
+                -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                      strides(st, sizeof(st)/sizeof(st[0])))] = v2;
+    assert(v1.size() == 41);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] ==  1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  0);
+    assert(v1[ 4] == -1);
+    assert(v1[ 5] == -2);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] == -4);
+    assert(v1[ 9] == -5);
+    assert(v1[10] == 10);
+    assert(v1[11] == -6);
+    assert(v1[12] == -7);
+    assert(v1[13] == -8);
+    assert(v1[14] == 14);
+    assert(v1[15] == -9);
+    assert(v1[16] == -10);
+    assert(v1[17] == -11);
+    assert(v1[18] == 18);
+    assert(v1[19] == 19);
+    assert(v1[20] == 20);
+    assert(v1[21] == 21);
+    assert(v1[22] == -12);
+    assert(v1[23] == -13);
+    assert(v1[24] == -14);
+    assert(v1[25] == 25);
+    assert(v1[26] == -15);
+    assert(v1[27] == -16);
+    assert(v1[28] == -17);
+    assert(v1[29] == 29);
+    assert(v1[30] == -18);
+    assert(v1[31] == -19);
+    assert(v1[32] == -20);
+    assert(v1[33] == 33);
+    assert(v1[34] == -21);
+    assert(v1[35] == -22);
+    assert(v1[36] == -23);
+    assert(v1[37] == 37);
+    assert(v1[38] == 38);
+    assert(v1[39] == 39);
+    assert(v1[40] == 40);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp
new file mode 100644
index 0000000..282dcf1
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const gslice& gs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+    std::size_t sz[] = {2, 4, 3};
+    std::size_t st[] = {19, 4, 1};
+    typedef std::valarray<std::size_t> sizes;
+    typedef std::valarray<std::size_t> strides;
+    std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+                                         strides(st, sizeof(st)/sizeof(st[0])))]);
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp
new file mode 100644
index 0000000..1bc4fb9
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<size_t>& vs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    const std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v = v1[ia];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp
new file mode 100644
index 0000000..d0b7438
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// indirect_array<value_type> operator[](const valarray<size_t>& vs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11,
+               12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+               24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+               36, 37, 38, 39, 40};
+    const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+    std::size_t s[] = { 3,  4,  5,  7,  8,  9, 11, 12, 13, 15, 16, 17,
+                       22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+    const std::size_t S = sizeof(s)/sizeof(s[0]);
+    std::valarray<int> v1(a, N1);
+    std::valarray<std::size_t> ia(s, S);
+    std::valarray<int> v(24);
+    v = v1[ia];
+    assert(v.size() == 24);
+    assert(v[ 0] ==  3);
+    assert(v[ 1] ==  4);
+    assert(v[ 2] ==  5);
+    assert(v[ 3] ==  7);
+    assert(v[ 4] ==  8);
+    assert(v[ 5] ==  9);
+    assert(v[ 6] == 11);
+    assert(v[ 7] == 12);
+    assert(v[ 8] == 13);
+    assert(v[ 9] == 15);
+    assert(v[10] == 16);
+    assert(v[11] == 17);
+    assert(v[12] == 22);
+    assert(v[13] == 23);
+    assert(v[14] == 24);
+    assert(v[15] == 26);
+    assert(v[16] == 27);
+    assert(v[17] == 28);
+    assert(v[18] == 30);
+    assert(v[19] == 31);
+    assert(v[20] == 32);
+    assert(v[21] == 34);
+    assert(v[22] == 35);
+    assert(v[23] == 36);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp
new file mode 100644
index 0000000..7f81910
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](slice s) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2 = v1[std::slice(1, 5, 3)];
+    assert(v2.size() == 5);
+    assert(v2[0] ==  1);
+    assert(v2[1] ==  4);
+    assert(v2[2] ==  7);
+    assert(v2[3] == 10);
+    assert(v2[4] == 13);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp
new file mode 100644
index 0000000..6bf9b43
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// slice_array<value_type> operator[](slice s);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    int a2[] = {-1, -2, -3, -4, -5};
+    std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+    std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+    v1[std::slice(1, 5, 3)] = v2;
+    assert(v1.size() == 16);
+    assert(v1[ 0] ==  0);
+    assert(v1[ 1] == -1);
+    assert(v1[ 2] ==  2);
+    assert(v1[ 3] ==  3);
+    assert(v1[ 4] == -2);
+    assert(v1[ 5] ==  5);
+    assert(v1[ 6] ==  6);
+    assert(v1[ 7] == -3);
+    assert(v1[ 8] ==  8);
+    assert(v1[ 9] ==  9);
+    assert(v1[10] == -4);
+    assert(v1[11] == 11);
+    assert(v1[12] == 12);
+    assert(v1[13] == -5);
+    assert(v1[14] == 14);
+    assert(v1[15] == 15);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp
new file mode 100644
index 0000000..10bdd82
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<bool>& vb) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(v1[vb]);
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp
new file mode 100644
index 0000000..cecf950
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// mask_array<value_type> operator[](const valarray<bool>& vb);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+    const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+    bool b[N1] = {true,  false, false, true,  true,  false,
+                  false, true,  false, false, false, true};
+    std::valarray<int> v1(a1, N1);
+    std::valarray<bool> vb(b, N1);
+    std::valarray<int> v2(5);
+    v2 = v1[vb];
+    assert(v2.size() == 5);
+    assert(v2[ 0] ==  0);
+    assert(v2[ 1] ==  3);
+    assert(v2[ 2] ==  4);
+    assert(v2[ 3] ==  7);
+    assert(v2[ 4] == 11);
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp
new file mode 100644
index 0000000..c1d240c
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator~() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = ~v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == ~v[i]);
+    }
+    {
+        typedef std::valarray<int> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = ~v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == ~v[i][j]);
+        }
+    }
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = ~(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == ~(2*v[i]));
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp
new file mode 100644
index 0000000..25674bb
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator-() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == -v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == -v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == -v[i][j]);
+        }
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = -(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == -2*v[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp
new file mode 100644
index 0000000..0b792c6
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray<bool> operator!() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<bool> v2 = !v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == !v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<bool> v2 = !(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == !2*v[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp b/final/test/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp
new file mode 100644
index 0000000..4bcdaf0
--- /dev/null
+++ b/final/test/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator+() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == +v[i]);
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == +v[i]);
+    }
+    {
+        typedef std::valarray<double> T;
+        T a[] = {T(1), T(2), T(3), T(4), T(5)};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +v;
+        assert(v2.size() == v.size());
+        for (int i = 0; i < N; ++i)
+        {
+            assert(v2[i].size() == v[i].size());
+            for (int j = 0; j < v[i].size(); ++j)
+                assert(v2[i][j] == +v[i][j]);
+        }
+    }
+    {
+        typedef double T;
+        T a[] = {1, 2.5, 3, 4.25, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        std::valarray<T> v2 = +(v + v);
+        assert(v2.size() == v.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == +2*v[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..9214e61
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {0,  2,  0,  0,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 & v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp
new file mode 100644
index 0000000..0976a88
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 1,   2,  3,  0,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 & 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp
new file mode 100644
index 0000000..e3dd180
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 1,   2,  3,  0,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 & v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..ff250af
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {6, 14, 24, 36, 50};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {1,  2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 / v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp
new file mode 100644
index 0000000..ffbebab
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {6, 12, 18, 24, 30};
+        T a2[] = {1,  2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 / 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp
new file mode 100644
index 0000000..1a7f2f0
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {3,  1,  1,  0,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 / v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..1f0354e
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {7,  9, 11, 13, 15};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {1,  2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 - v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp
new file mode 100644
index 0000000..382cab8
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = {-2,  -1,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 - 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp
new file mode 100644
index 0000000..7f00aba
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0, -1, -2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 - v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..0a9cf38
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {6,  7,  8,  9, 10};
+        T a2[] = {1,  2,  3,  4,  5};
+        T a3[] = {0,  1,  2,  1,  0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 % v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp
new file mode 100644
index 0000000..12c4c24
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {1,  2,  0,  1,  2};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 % 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp
new file mode 100644
index 0000000..1d73887
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {0,  1,  0,  3,  3};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 % v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..a23ea4f
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  7, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 | v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp
new file mode 100644
index 0000000..f617c27
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 3,   3,  3,  7,  7};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 | 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp
new file mode 100644
index 0000000..8903f43
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 3,   3,  3,  7,  7};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 | v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..1167772
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  9, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 + v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp
new file mode 100644
index 0000000..b1b4e69
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {4,  5,  6,  7,  8};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 + 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp
new file mode 100644
index 0000000..df22853
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {4,  5,  6,  7,  8};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 + v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..42a7c41
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,   3,    4,    5};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = {64, 256, 768, 2048, 5120};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 << v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp
new file mode 100644
index 0000000..753ba38
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 8,  16, 24, 32, 40};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 << 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp
new file mode 100644
index 0000000..640ce1a
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 6,  12, 24, 48, 96};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 << v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..8e6358d
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {64, 256, 768, 2048, 5120};
+        T a2[] = { 6,   7,   8,    9,   10};
+        T a3[] = { 1,   2,   3,    4,    5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 >> v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp
new file mode 100644
index 0000000..0c0ba54
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 8,  16, 24, 32, 40};
+        T a2[] = { 1,   2,  3,  4,  5};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 >> 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp
new file mode 100644
index 0000000..ad5418a
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = {20,  10,  5,  2,  1};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 40 >> v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..69a3bff
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {6, 14, 24, 36, 50};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 * v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp
new file mode 100644
index 0000000..c4fb410
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 * 6;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp
new file mode 100644
index 0000000..f5d8777
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6, 12, 18, 24, 30};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 6 * v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..71b505b
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  5};
+        T a2[] = {6,  7,  8,  9, 10};
+        T a3[] = {7,  5, 11, 13, 15};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = v1 ^ v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp
new file mode 100644
index 0000000..8dbe684
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0,  7,  6};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = v1 ^ 3;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp
new file mode 100644
index 0000000..face063
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = { 1,   2,  3,  4,  5};
+        T a2[] = { 2,   1,  0,  7,  6};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2 = 3 ^ v1;
+        assert(v1.size() == v2.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == a2[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..af2a1b3
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator&&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {true,  true,  false,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 && v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp
new file mode 100644
index 0000000..f34fe96
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator&&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 && 5;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  false,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 && 0;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp
new file mode 100644
index 0000000..c323d13
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator&&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 5 && v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  false,  false,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 0 && v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..6222e91
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator==(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {false,  false,  true,  false,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 == v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..dca6505
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator==(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  false,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 == 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..532219e
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator==(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  false,  false,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 == v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..75e6269
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {false,  false,  true,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 >= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..020706d
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 >= 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..faf2003
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  false,  false,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 >= v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..3276085
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {false,  false,  false,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 > v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp
new file mode 100644
index 0000000..1ab774c
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 > 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp
new file mode 100644
index 0000000..c5012d6
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  false,  false,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 > v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..ceb6658
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {true,  true,  true,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 <= v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..4a391a3
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  false,  false,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 <= 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..cf34e18
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  true,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 <= v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..0fa9948
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  2, 1};
+        bool a3[] = {true,  true,  false,  false,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 < v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp
new file mode 100644
index 0000000..7a47c90
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  false,  false,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 < 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp
new file mode 100644
index 0000000..4d6cbad
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {false,  false,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 < v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..c9675a9
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator!=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4, 10};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {true,  true,  false,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 != v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp
new file mode 100644
index 0000000..9daa728
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator!=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  true,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 != 2;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp
new file mode 100644
index 0000000..37439aa
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator!=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  false,  true,  true,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 2 != v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..9a2f84e
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator||(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  0,  4,  0};
+        T a2[] = {6,  7,  0,  9, 10};
+        bool a3[] = {true,  true,  false,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = v1 || v2;
+        assert(v1.size() == v2.size());
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp
new file mode 100644
index 0000000..789df5b
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator||(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  true};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 || 5;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<bool> v3 = v1 || 0;
+        assert(v1.size() == v3.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp
new file mode 100644
index 0000000..d669059
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<bool>
+//   operator||(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  true};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 5 || v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {1,  2,  3,  4,  0};
+        bool a3[] = {true,  true,  true,  true,  false};
+        const unsigned N = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v2(a2, N);
+        std::valarray<bool> v3 = 0 || v2;
+        assert(v2.size() == v3.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp
new file mode 100644
index 0000000..84f7394
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   void
+//   swap(valarray<T>& x, valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a1[] = {1, 2, 3, 4, 5};
+        const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+        const unsigned N2 = 0;
+        std::valarray<T> v1(a1, N1);
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        T a2[] = {6, 7, 8, 9, 10, 11, 12};
+        const unsigned N1 = 0;
+        const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+        std::valarray<T> v1;
+        std::valarray<T> v2(a2, N2);
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+    {
+        typedef int T;
+        const unsigned N1 = 0;
+        const unsigned N2 = 0;
+        std::valarray<T> v1;
+        std::valarray<T> v2;
+        std::valarray<T> v1_save = v1;
+        std::valarray<T> v2_save = v2;
+        swap(v1, v2);
+        assert(v1.size() == v2_save.size());
+        for (int i = 0; i < v1.size(); ++i)
+            assert(v1[i] == v2_save[i]);
+        assert(v2.size() == v1_save.size());
+        for (int i = 0; i < v2.size(); ++i)
+            assert(v2[i] == v1_save[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
new file mode 100644
index 0000000..7d112a6
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   abs(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {1.5,  -2.5,  3.4,  -4.5,  -5.0};
+        T a3[] = {1.5,   2.5,  3.4,   4.5,   5.0};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = abs(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(v3[i] == a3[i]);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
new file mode 100644
index 0000000..ef2451d
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   acos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {2.6905658417935308e+00,
+                  2.0943951023931957e+00,
+                  1.5707963267948966e+00,
+                  1.0471975511965976e+00,
+                  7.2273424781341566e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = acos(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
new file mode 100644
index 0000000..11c7c68
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   asin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-1.1197695149986342e+00,
+                  -5.2359877559829882e-01,
+                  0.0000000000000000e+00,
+                  5.2359877559829882e-01,
+                  8.4806207898148100e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = asin(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..b860413
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan2(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a2[] = {-.8,  .25, 0.375, -.5, .75};
+        T a3[] = {-2.2974386674766221e+00,
+                  -1.1071487177940904e+00,
+                   0.0000000000000000e+00,
+                   2.3561944901923448e+00,
+                   7.8539816339744828e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = atan2(v1, v2);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
new file mode 100644
index 0000000..94ffebf
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan2(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-8.7605805059819342e-01,
+                  -5.8800260354756750e-01,
+                   0.0000000000000000e+00,
+                   5.8800260354756750e-01,
+                   7.8539816339744828e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = atan2(v1, .75);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
new file mode 100644
index 0000000..360e70e
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan2(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {2.4468543773930902e+00,
+                  2.1587989303424640e+00,
+                  1.5707963267948966e+00,
+                  9.8279372324732905e-01,
+                  7.8539816339744828e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = atan2(.75, v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
new file mode 100644
index 0000000..e66118b
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   atan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-7.3281510178650666e-01,
+                  -4.6364760900080615e-01,
+                   0.0000000000000000e+00,
+                   4.6364760900080615e-01,
+                   6.4350110879328437e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = atan(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
new file mode 100644
index 0000000..baeb0d0
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   cos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {6.2160996827066450e-01,
+                  8.7758256189037276e-01,
+                  1.0000000000000000e+00,
+                  8.7758256189037276e-01,
+                  7.3168886887382090e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = cos(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
new file mode 100644
index 0000000..02a547a
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   cosh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {1.4330863854487743e+00,
+                  1.1276259652063807e+00,
+                  1.0000000000000000e+00,
+                  1.1276259652063807e+00,
+                  1.2946832846768448e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = cosh(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
new file mode 100644
index 0000000..dce9c55
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   exp(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {4.0656965974059911e-01,
+                  6.0653065971263342e-01,
+                  1.0000000000000000e+00,
+                  1.6487212707001282e+00,
+                  2.1170000166126748e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = exp(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
new file mode 100644
index 0000000..2b99081
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   log10(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.5, .75, 1, 3, 7};
+        T a3[] = {-3.0102999566398120e-01,
+                  -1.2493873660829995e-01,
+                   0.0000000000000000e+00,
+                   4.7712125471966244e-01,
+                   8.4509804001425681e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = log10(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
new file mode 100644
index 0000000..2c51cd6
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   log(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.5, .75, 1, 3, 7};
+        T a3[] = {-6.9314718055994529e-01,
+                  -2.8768207245178090e-01,
+                   0.0000000000000000e+00,
+                   1.0986122886681098e+00,
+                   1.9459101490553132e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = log(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
new file mode 100644
index 0000000..37ca742
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   pow(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.9, .5, 0., .5, .75};
+        T a2[] = {-.8,  .25, 0.375, -.5, .75};
+        T a3[] = {1.0879426248455297e+00,
+                  8.4089641525371450e-01,
+                  0.0000000000000000e+00,
+                  1.4142135623730949e+00,
+                  8.0592744886765644e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v2(a2, N);
+        std::valarray<T> v3 = pow(v1, v2);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
new file mode 100644
index 0000000..290ddc6
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   pow(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.9, .5, 0., .5, .75};
+        T a3[] = {8.1000000000000005e-01,
+                  2.5000000000000000e-01,
+                  0.0000000000000000e+00,
+                  2.5000000000000000e-01,
+                  5.6250000000000000e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = pow(v1, 2.0);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
new file mode 100644
index 0000000..f52990b
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   pow(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.9, .5, 0., .5, .75};
+        T a3[] = {1.8660659830736148e+00,
+                  1.4142135623730951e+00,
+                  1.0000000000000000e+00,
+                  1.4142135623730951e+00,
+                  1.6817928305074290e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = pow(2.0, v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
new file mode 100644
index 0000000..f05bd05
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   sin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-7.8332690962748330e-01,
+                  -4.7942553860420301e-01,
+                   0.0000000000000000e+00,
+                   4.7942553860420301e-01,
+                   6.8163876002333423e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = sin(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
new file mode 100644
index 0000000..73dca83
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   sinh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-1.0265167257081753e+00,
+                  -5.2109530549374738e-01,
+                   0.0000000000000000e+00,
+                   5.2109530549374738e-01,
+                   8.2231673193582999e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = sinh(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
new file mode 100644
index 0000000..193dcd2
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   sqrt(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {.5, .75, 1, 3, 7};
+        T a3[] = {7.0710678118654757e-01,
+                  8.6602540378443860e-01,
+                  1.0000000000000000e+00,
+                  1.7320508075688772e+00,
+                  2.6457513110645907e+00};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = sqrt(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
new file mode 100644
index 0000000..021dbc4
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   tan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-1.2601582175503390e+00,
+                  -5.4630248984379048e-01,
+                   0.0000000000000000e+00,
+                   5.4630248984379048e-01,
+                   9.3159645994407259e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = tan(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
new file mode 100644
index 0000000..4cc58c3
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+//   valarray<T>
+//   tanh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+    std::ostringstream o;
+    o.precision(p);
+    scientific(o);
+    o << x;
+    std::string a = o.str();
+    o.str("");
+    o << y;
+    return a == o.str();
+}
+
+int main()
+{
+    {
+        typedef double T;
+        T a1[] = {-.9, -.5, 0., .5, .75};
+        T a3[] = {-7.1629787019902447e-01,
+                  -4.6211715726000974e-01,
+                   0.0000000000000000e+00,
+                   4.6211715726000974e-01,
+                   6.3514895238728730e-01};
+        const unsigned N = sizeof(a1)/sizeof(a1[0]);
+        std::valarray<T> v1(a1, N);
+        std::valarray<T> v3 = tanh(v1);
+        assert(v3.size() == v1.size());
+        for (int i = 0; i < v3.size(); ++i)
+            assert(is_about(v3[i], a3[i], 10));
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.range/begin_const.pass.cpp b/final/test/numerics/numarray/valarray.range/begin_const.pass.cpp
new file mode 100644
index 0000000..873c484
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.range/begin_const.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   begin(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        const std::valarray<T> v(a, N);
+        assert(v[0] == 1);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.range/begin_non_const.pass.cpp b/final/test/numerics/numarray/valarray.range/begin_non_const.pass.cpp
new file mode 100644
index 0000000..0a39d00
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.range/begin_non_const.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   begin(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        *begin(v) = 10;
+        assert(v[0] == 10);
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.range/end_const.pass.cpp b/final/test/numerics/numarray/valarray.range/end_const.pass.cpp
new file mode 100644
index 0000000..7363508
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.range/end_const.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   end(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        const std::valarray<T> v(a, N);
+        assert(v[v.size()-1] == 5);
+        assert(end(v) - begin(v) == v.size());
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.range/end_non_const.pass.cpp b/final/test/numerics/numarray/valarray.range/end_non_const.pass.cpp
new file mode 100644
index 0000000..f095f5c
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.range/end_non_const.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+//   unspecified1
+//   end(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        T a[] = {1, 2, 3, 4, 5};
+        const unsigned N = sizeof(a)/sizeof(a[0]);
+        std::valarray<T> v(a, N);
+        *(end(v) - 1) = 10;
+        assert(v[v.size()-1] == 10);
+        assert(end(v) - begin(v) == v.size());
+    }
+}
diff --git a/final/test/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp b/final/test/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numarray/version.pass.cpp b/final/test/numerics/numarray/version.pass.cpp
new file mode 100644
index 0000000..85457d4
--- /dev/null
+++ b/final/test/numerics/numarray/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+#include <valarray>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/numerics/numeric.ops/accumulate/accumulate.pass.cpp b/final/test/numerics/numeric.ops/accumulate/accumulate.pass.cpp
new file mode 100644
index 0000000..aae97ef
--- /dev/null
+++ b/final/test/numerics/numeric.ops/accumulate/accumulate.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T>
+//   requires HasPlus<T, Iter::reference>
+//         && HasAssign<T, HasPlus<T, Iter::reference>::result_type>
+//   T
+//   accumulate(Iter first, Iter last, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+    assert(std::accumulate(first, last, init) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    unsigned sa = sizeof(ia) / sizeof(ia[0]);
+    test(Iter(ia), Iter(ia), 0, 0);
+    test(Iter(ia), Iter(ia), 10, 10);
+    test(Iter(ia), Iter(ia+1), 0, 1);
+    test(Iter(ia), Iter(ia+1), 10, 11);
+    test(Iter(ia), Iter(ia+2), 0, 3);
+    test(Iter(ia), Iter(ia+2), 10, 13);
+    test(Iter(ia), Iter(ia+sa), 0, 21);
+    test(Iter(ia), Iter(ia+sa), 10, 31);
+}
+
+int main()
+{
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp b/final/test/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp
new file mode 100644
index 0000000..19a8728
--- /dev/null
+++ b/final/test/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T,
+//           Callable<auto, const T&, Iter::reference> BinaryOperation>
+//   requires HasAssign<T, BinaryOperation::result_type>
+//         && CopyConstructible<BinaryOperation>
+//   T
+//   accumulate(Iter first, Iter last, T init, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+    assert(std::accumulate(first, last, init, std::multiplies<T>()) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5, 6};
+    unsigned sa = sizeof(ia) / sizeof(ia[0]);
+    test(Iter(ia), Iter(ia), 1, 1);
+    test(Iter(ia), Iter(ia), 10, 10);
+    test(Iter(ia), Iter(ia+1), 1, 1);
+    test(Iter(ia), Iter(ia+1), 10, 10);
+    test(Iter(ia), Iter(ia+2), 1, 2);
+    test(Iter(ia), Iter(ia+2), 10, 20);
+    test(Iter(ia), Iter(ia+sa), 1, 720);
+    test(Iter(ia), Iter(ia+sa), 10, 7200);
+}
+
+int main()
+{
+    test<input_iterator<const int*> >();
+    test<forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*> >();
+    test<const int*>();
+}
diff --git a/final/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp b/final/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp
new file mode 100644
index 0000000..46741e1
--- /dev/null
+++ b/final/test/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+//           OutputIterator<auto, const InIter::value_type&> OutIter>
+//   requires HasMinus<InIter::value_type, InIter::value_type>
+//         && Constructible<InIter::value_type, InIter::reference>
+//         && OutputIterator<OutIter,
+//                           HasMinus<InIter::value_type, InIter::value_type>::result_type>
+//         && MoveAssignable<InIter::value_type>
+//   OutIter
+//   adjacent_difference(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {15, 10, 6, 3, 1};
+    int ir[] = {15, -5, -4, -3, -2};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib));
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Y;
+
+class X
+{
+    int i_;
+
+    X& operator=(const X&);
+public:
+    explicit X(int i) : i_(i) {}
+    X(const X& x) : i_(x.i_) {}
+    X& operator=(X&& x)
+    {
+        i_ = x.i_;
+        x.i_ = -1;
+        return *this;
+    }
+
+    friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+
+    friend class Y;
+};
+
+class Y
+{
+    int i_;
+
+    Y& operator=(const Y&);
+public:
+    explicit Y(int i) : i_(i) {}
+    Y(const Y& y) : i_(y.i_) {}
+    void operator=(const X& x) {i_ = x.i_;}
+};
+
+#endif
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    X x[3] = {X(1), X(2), X(3)};
+    Y y[3] = {Y(1), Y(2), Y(3)};
+    std::adjacent_difference(x, x+3, y);
+#endif
+}
diff --git a/final/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp b/final/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
new file mode 100644
index 0000000..fb0bbdc
--- /dev/null
+++ b/final/test/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+//           OutputIterator<auto, const InIter::value_type&> OutIter,
+//           Callable<auto, const InIter::value_type&, const InIter::value_type&> BinaryOperation>
+//   requires Constructible<InIter::value_type, InIter::reference>
+//         && OutputIterator<OutIter, BinaryOperation::result_type>
+//         && MoveAssignable<InIter::value_type>
+//         && CopyConstructible<BinaryOperation>
+//   OutIter
+//   adjacent_difference(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {15, 10, 6, 3, 1};
+    int ir[] = {15, 25, 16, 9, 4};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib),
+                                         std::plus<int>());
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Y;
+
+class X
+{
+    int i_;
+
+    X& operator=(const X&);
+public:
+    explicit X(int i) : i_(i) {}
+    X(const X& x) : i_(x.i_) {}
+    X& operator=(X&& x)
+    {
+        i_ = x.i_;
+        x.i_ = -1;
+        return *this;
+    }
+
+    friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+
+    friend class Y;
+};
+
+class Y
+{
+    int i_;
+
+    Y& operator=(const Y&);
+public:
+    explicit Y(int i) : i_(i) {}
+    Y(const Y& y) : i_(y.i_) {}
+    void operator=(const X& x) {i_ = x.i_;}
+};
+
+#endif
+
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    X x[3] = {X(1), X(2), X(3)};
+    Y y[3] = {Y(1), Y(2), Y(3)};
+    std::adjacent_difference(x, x+3, y, std::minus<X>());
+#endif
+}
diff --git a/final/test/numerics/numeric.ops/inner.product/inner_product.pass.cpp b/final/test/numerics/numeric.ops/inner.product/inner_product.pass.cpp
new file mode 100644
index 0000000..68a8c49
--- /dev/null
+++ b/final/test/numerics/numeric.ops/inner.product/inner_product.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T>
+//   requires HasMultiply<Iter1::reference, Iter2::reference>
+//         && HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type>
+//         && HasAssign<T,
+//                      HasPlus<T,
+//                              HasMultiply<Iter1::reference,
+//                                          Iter2::reference>::result_type>::result_type>
+//   T
+//   inner_product(Iter1 first1, Iter1 last1, Iter2 first2, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+    assert(std::inner_product(first1, last1, first2, init) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int a[] = {1, 2, 3, 4, 5, 6};
+    int b[] = {6, 5, 4, 3, 2, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    test(Iter1(a), Iter1(a), Iter2(b), 0, 0);
+    test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 0, 6);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 10, 16);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 0, 16);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 10, 26);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 0, 56);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 66);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/final/test/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp b/final/test/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
new file mode 100644
index 0000000..31dbbd0
--- /dev/null
+++ b/final/test/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T,
+//           class BinaryOperation1,
+//           Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
+//   requires Callable<BinaryOperation1, const T&, BinaryOperation2::result_type>
+//         && HasAssign<T, BinaryOperation1::result_type>
+//         && CopyConstructible<BinaryOperation1>
+//         && CopyConstructible<BinaryOperation2>
+//   T
+//   inner_product(Iter1 first1, Iter1 last1, Iter2 first2,
+//                 T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+    assert(std::inner_product(first1, last1, first2, init,
+           std::multiplies<int>(), std::plus<int>()) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+    int a[] = {1, 2, 3, 4, 5, 6};
+    int b[] = {6, 5, 4, 3, 2, 1};
+    unsigned sa = sizeof(a) / sizeof(a[0]);
+    test(Iter1(a), Iter1(a), Iter2(b), 1, 1);
+    test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 1, 7);
+    test(Iter1(a), Iter1(a+1), Iter2(b), 10, 70);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 1, 49);
+    test(Iter1(a), Iter1(a+2), Iter2(b), 10, 490);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 1, 117649);
+    test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 1176490);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, input_iterator<const int*> >();
+    test<input_iterator<const int*>, forward_iterator<const int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<input_iterator<const int*>, random_access_iterator<const int*> >();
+    test<input_iterator<const int*>, const int*>();
+
+    test<forward_iterator<const int*>, input_iterator<const int*> >();
+    test<forward_iterator<const int*>, forward_iterator<const int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+    test<forward_iterator<const int*>, const int*>();
+
+    test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+    test<bidirectional_iterator<const int*>, const int*>();
+
+    test<random_access_iterator<const int*>, input_iterator<const int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+    test<random_access_iterator<const int*>, const int*>();
+
+    test<const int*, input_iterator<const int*> >();
+    test<const int*, forward_iterator<const int*> >();
+    test<const int*, bidirectional_iterator<const int*> >();
+    test<const int*, random_access_iterator<const int*> >();
+    test<const int*, const int*>();
+}
diff --git a/final/test/numerics/numeric.ops/numeric.iota/iota.pass.cpp b/final/test/numerics/numeric.ops/numeric.iota/iota.pass.cpp
new file mode 100644
index 0000000..eb7c837
--- /dev/null
+++ b/final/test/numerics/numeric.ops/numeric.iota/iota.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <class ForwardIterator, class T>
+//     void iota(ForwardIterator first, ForwardIterator last, T value);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5};
+    int ir[] = {5, 6, 7, 8, 9};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    std::iota(InIter(ia), InIter(ia+s), 5);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ia[i] == ir[i]);
+}
+
+int main()
+{
+    test<forward_iterator<int*> >();
+    test<bidirectional_iterator<int*> >();
+    test<random_access_iterator<int*> >();
+    test<int*>();
+}
diff --git a/final/test/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp b/final/test/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
new file mode 100644
index 0000000..cb468e0
--- /dev/null
+++ b/final/test/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter, OutputIterator<auto, const InIter::value_type&> OutIter>
+//   requires HasPlus<InIter::value_type, InIter::reference>
+//         && HasAssign<InIter::value_type,
+//                      HasPlus<InIter::value_type, InIter::reference>::result_type>
+//         && Constructible<InIter::value_type, InIter::reference>
+//   OutIter
+//   partial_sum(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5};
+    int ir[] = {1, 3, 6, 10, 15};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib));
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp b/final/test/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
new file mode 100644
index 0000000..d8f2a93
--- /dev/null
+++ b/final/test/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template<InputIterator InIter,
+//          OutputIterator<auto, const InIter::value_type&> OutIter,
+//          Callable<auto, const InIter::value_type&, InIter::reference> BinaryOperation>
+//   requires HasAssign<InIter::value_type, BinaryOperation::result_type>
+//         && Constructible<InIter::value_type, InIter::reference>
+//         && CopyConstructible<BinaryOperation>
+//   OutIter
+//   partial_sum(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+    int ia[] = {1, 2, 3, 4, 5};
+    int ir[] = {1, -1, -4, -8, -13};
+    const unsigned s = sizeof(ia) / sizeof(ia[0]);
+    int ib[s] = {0};
+    OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib), std::minus<int>());
+    assert(base(r) == ib + s);
+    for (unsigned i = 0; i < s; ++i)
+        assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+    test<input_iterator<const int*>, output_iterator<int*> >();
+    test<input_iterator<const int*>, forward_iterator<int*> >();
+    test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<input_iterator<const int*>, random_access_iterator<int*> >();
+    test<input_iterator<const int*>, int*>();
+
+    test<forward_iterator<const int*>, output_iterator<int*> >();
+    test<forward_iterator<const int*>, forward_iterator<int*> >();
+    test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<forward_iterator<const int*>, random_access_iterator<int*> >();
+    test<forward_iterator<const int*>, int*>();
+
+    test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+    test<bidirectional_iterator<const int*>, int*>();
+
+    test<random_access_iterator<const int*>, output_iterator<int*> >();
+    test<random_access_iterator<const int*>, forward_iterator<int*> >();
+    test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+    test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+    test<random_access_iterator<const int*>, int*>();
+
+    test<const int*, output_iterator<int*> >();
+    test<const int*, forward_iterator<int*> >();
+    test<const int*, bidirectional_iterator<int*> >();
+    test<const int*, random_access_iterator<int*> >();
+    test<const int*, int*>();
+}
diff --git a/final/test/numerics/numeric.ops/version.pass.cpp b/final/test/numerics/numeric.ops/version.pass.cpp
new file mode 100644
index 0000000..fb6e0a1
--- /dev/null
+++ b/final/test/numerics/numeric.ops/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+#include <numeric>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/numerics/numeric.requirements/nothing_to_do.pass.cpp b/final/test/numerics/numeric.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numeric.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/numerics.general/nothing_to_do.pass.cpp b/final/test/numerics/numerics.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/numerics.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/nothing_to_do.pass.cpp b/final/test/numerics/rand/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.adapt/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
new file mode 100644
index 0000000..18c8947
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine& operator=(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
new file mode 100644
index 0000000..d6c64fa
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp
new file mode 100644
index 0000000..d6b8b33
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::ranlux24_base Engine;
+        typedef std::ranlux24 Adaptor;
+        Engine e;
+        Adaptor a(e);
+        assert(a.base() == e);
+    }
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp
new file mode 100644
index 0000000..1e8e2fe
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::ranlux24_base Engine;
+        typedef std::ranlux24 Adaptor;
+        Engine e;
+        Engine e0 = e;
+        Adaptor a(std::move(e0));
+        assert(a.base() == e);
+    }
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..dba254f
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+    "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+    "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+    "5707268 2355175 0 0";
+    std::ranlux24 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "10880375256626 126660097854724 33643165434010 "
+    "78293780235492 179418984296008 96783156950859 238199764491708 "
+    "34339434557790 155299155394531 29014415493780 209265474179052 "
+    "263777435457028 0 0";
+    std::ranlux48 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..b64d4b3
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> explicit discard_block_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+    "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+    "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+    "889045 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux24 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "241408498702289 172342669275054 191026374555184 "
+    "61020585639411 231929771458953 142769679250755 198672786411514 "
+    "183712717244841 227473912549724 62843577252444 68782400568421 "
+    "159248704678140 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux48 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
new file mode 100644
index 0000000..ffdaebc
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24 e1;
+    std::ranlux24 e2(std::ranlux24_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+    std::ranlux48 e1;
+    std::ranlux48 e2(std::ranlux48_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
new file mode 100644
index 0000000..2dada0d
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24 e1;
+    std::ranlux24 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::ranlux48 e1;
+    std::ranlux48 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
new file mode 100644
index 0000000..f819d6a
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24 e;
+    assert(e() == 15039276u);
+    assert(e() == 16323925u);
+    assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+    std::ranlux48 e;
+    assert(e() == 23459059301164ull);
+    assert(e() == 28639057539807ull);
+    assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
new file mode 100644
index 0000000..4b742f0
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template <class charT, class traits,
+//           class Engine, size_t p, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const discard_block_engine<Engine, p, r>& x);
+//
+// template <class charT, class traits,
+//           class Engine, size_t p, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            discard_block_engine<Engine, p, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
new file mode 100644
index 0000000..2634aba
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::ranlux24::result_type,
+        std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::ranlux48::result_type,
+        std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
new file mode 100644
index 0000000..6a5ff14
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux24 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux48 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
new file mode 100644
index 0000000..0da09a3
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux24 e1;
+    std::ranlux24 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux48 e1;
+    std::ranlux48 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
new file mode 100644
index 0000000..53e4c29
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+//
+//     // engine characteristics
+//     static constexpr size_t block_size = p;
+//     static constexpr size_t used_block = r;
+//     static constexpr result_type min() { return Engine::min(); }
+//     static constexpr result_type max() { return Engine::max(); }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+    typedef std::ranlux24 E;
+    static_assert((E::block_size == 223), "");
+    static_assert((E::used_block == 23), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+    where(E::block_size);
+    where(E::used_block);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48 E;
+    static_assert((E::block_size == 389), "");
+    static_assert((E::used_block == 11), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+    where(E::block_size);
+    where(E::used_block);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
new file mode 100644
index 0000000..e4cd4f7
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine& operator=(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
new file mode 100644
index 0000000..e3e497e
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp
new file mode 100644
index 0000000..193f5c3
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::mt19937 Engine;
+        typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+        Engine e;
+        Adaptor a(e);
+        assert(a.base() == e);
+    }
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp
new file mode 100644
index 0000000..60a661d
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::mt19937 Engine;
+        typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+        Engine e;
+        Engine e0 = e;
+        Adaptor a(std::move(e0));
+        assert(a.base() == e);
+    }
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..8e8d309
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+    "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+    "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+    "5707268 2355175 0 0";
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "10880375256626 126660097854724 33643165434010 "
+    "78293780235492 179418984296008 96783156950859 238199764491708 "
+    "34339434557790 155299155394531 29014415493780 209265474179052 "
+    "263777435457028 0 0";
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..7965f43
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> explicit independent_bits_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+    "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+    "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+    "889045 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "241408498702289 172342669275054 191026374555184 "
+    "61020585639411 231929771458953 142769679250755 198672786411514 "
+    "183712717244841 227473912549724 62843577252444 68782400568421 "
+    "159248704678140 0 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
new file mode 100644
index 0000000..ccb6f37
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(std::ranlux24_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 2066486613);
+}
+
+void
+test2()
+{
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(std::ranlux48_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 18223106896348967647ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
new file mode 100644
index 0000000..2a356a1
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
new file mode 100644
index 0000000..1c2b2a8
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    // Workaround for lack of constexpr in C++03
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+#endif
+
+    static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+    static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+   typedef std::independent_bits_engine<rand1<unsigned, 0, 10>, 16, unsigned> E;
+
+    E e;
+    assert(e() == 6958);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 0, 100>, 16, unsigned> E;
+
+    E e;
+    assert(e() == 66);
+}
+
+void
+test3()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 32, unsigned> E;
+
+    E e(5);
+    assert(e() == 5);
+}
+
+void
+test4()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 7, unsigned> E;
+
+    E e(129);
+    assert(e() == 1);
+}
+
+void
+test5()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 1, unsigned> E;
+
+    E e(6);
+    assert(e() == 1);
+}
+
+void
+test6()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 11, unsigned> E;
+
+    E e(6);
+    assert(e() == 1365);
+}
+
+void
+test7()
+{
+    typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 32, unsigned> E;
+
+    E e(6);
+    assert(e() == 2863311530u);
+}
+
+void
+test8()
+{
+    typedef std::independent_bits_engine<std::mt19937, 64, unsigned long long> E;
+
+    E e(6);
+    assert(e() == 16470362623952407241ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+    test5();
+    test6();
+    test7();
+    test8();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
new file mode 100644
index 0000000..9bcf064
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template <class charT, class traits,
+//           class Engine, size_t w, class UIntType>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const independent_bits_engine<Engine, w, UIntType>& x);
+//
+// template <class charT, class traits,
+//           class Engine, size_t w, class UIntType>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            independent_bits_engine<Engine, w, UIntType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
new file mode 100644
index 0000000..78040ad
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    // Workaround for lack of constexpr in C++03
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+#endif
+
+    static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+    static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ < Min)
+            x_ = Min;
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned>::result_type,
+        unsigned>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned long long>::result_type,
+        unsigned long long>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
new file mode 100644
index 0000000..e8c24ca
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
new file mode 100644
index 0000000..ec83fff
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+    std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+    std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
new file mode 100644
index 0000000..20ca7d5
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+//
+//     // engine characteristics
+//     static constexpr result_type min() { return 0; }
+//     static constexpr result_type max() { return 2^w - 1; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+}
+
+void
+test2()
+{
+    typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
new file mode 100644
index 0000000..dae8c7c
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine& operator=(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
new file mode 100644
index 0000000..c9e9893
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp
new file mode 100644
index 0000000..a20c494
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::minstd_rand0 Engine;
+        typedef std::knuth_b Adaptor;
+        Engine e;
+        Adaptor a(e);
+        for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+            e();
+        assert(a.base() == e);
+    }
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp
new file mode 100644
index 0000000..9811787
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::minstd_rand0 Engine;
+        typedef std::knuth_b Adaptor;
+        Engine e;
+        Engine e0 = e;
+        Adaptor a(std::move(e0));
+        for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+            e();
+        assert(a.base() == e);
+    }
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..3202494
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "1771550148 168070 677268843 1194115201 1259501992 "
+        "703671065 407145426 1010275440 1693606898 1702877348 745024267 "
+        "1793193459 416963415 664975744 742430420 1148079870 637806795 "
+        "1527921388 165317290 1791337459 1435426120 375508442 1863429808 "
+        "1910758855 653618747 991426424 578291095 1974930990 1157900898 "
+        "343583572 25567821 221638147 1335692731 1341167826 1019292670 "
+        "774852571 606325389 700907908 1211405961 1955012967 1403137269 "
+        "1010152376 1772753897 486628401 1145807831 1106352968 1560917450 "
+        "679350398 1819071734 1561434646 781928982 1427964481 1669276942 "
+        "811199786 1608612146 1272705739 1428231253 1857946652 2097152784 "
+        "197742477 1300609030 99924397 97128425 349867255 408729299 1860625187 "
+        "2018133942 1420442476 1948474080 1025729457 1583749330 15184745 "
+        "1806938869 1655319056 296727307 638820415 1383963552 880037807 "
+        "1075545360 1321008721 1507631161 597371974 544717293 340756290 "
+        "1899563128 1465595994 634440068 777915521 545718511 2135841687 "
+        "1902073804 712854586 135760289 1095544109 285050585 1956649285 "
+        "987446484 259432572 891434194 1488577086 330596852 801096775 "
+        "1458514382 1872871416 1682074633 1153627723 1538775345 51662594 "
+        "709823970 739804705 2114844452 1188863267 1037076781 1172179215 "
+        "1948572574 533634468 902793804 1283497773 273836696 315894151 "
+        "653420473 1954002600 1601768276 64415940 306945492 577163950 "
+        "210874151 813838307 857078006 1737226413 376658679 1868110244 "
+        "1117951768 1080937173 1746896638 1842856729 1883887269 2141922362 "
+        "1020763473 1872318475 978729834 1935067665 1189895487 1205729145 "
+        "1034046923 1788963337 188263312 898072753 1393688555 1119406056 "
+        "1900835472 1375045132 1312008157 559007303 2142269543 413383599 "
+        "628550348 573639243 1100665718 464587168 65992084 1027393936 "
+        "1641360472 1918007189 69800406 609352380 35938117 569027612 902394793 "
+        "1019770837 221470752 669768613 1839284764 1979413630 1335703733 "
+        "1526078440 1403144959 1139398206 753967943 1785700701 1187714882 "
+        "1063522909 1123137582 192083544 680202567 1109090588 327456556 "
+        "1709233078 191596027 1076438936 1306955024 1530346852 127901445 "
+        "8455468 377129974 1199230721 1336700752 1103107597 703058228 "
+        "844612202 530372344 1910850558 47387421 1871435357 1168551137 "
+        "1101007744 1918050856 803711675 309982095 73743043 301259382 "
+        "1647477295 1644236294 859823662 638826571 1487427444 335916581 "
+        "15468904 140348241 895842081 410006250 1847504174 536600445 "
+        "1359845362 1400027760 288242141 1910039802 1453396858 1761991428 "
+        "2137921913 357210187 1414819544 1933136424 943782705 841706193 "
+        "1081202962 1919045067 333546776 988345562 337850989 314809455 "
+        "1750287624 853099962 1450233962 142805884 1399258689 247367726 "
+        "2128513937 1151147433 654730608 351121428 12778440 18876380 "
+        "1575222551 587014441 411835569 380613902 1771550148";
+    std::knuth_b e1(10);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..a08df07
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> explicit shuffle_order_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "1894661934 884942216 1899568837 1561547157 525417712 "
+        "242729120 1476874187 1208468883 1983666902 1953485886 1507290666 "
+        "1317123450 632390874 696850315 1734917114 218976032 1690682513 "
+        "1944862534 456017951 2072049961 1348874775 1700965693 828093387 "
+        "2071522749 1077957279 1055942061 413360419 238964088 475007126 "
+        "1248050783 1516729632 1044035134 9617501 580065782 1737324341 "
+        "2022534575 219953662 941840747 415472792 1381878747 200458524 "
+        "1852054372 1849850586 1318041283 1026024576 101363422 660501483 "
+        "705453438 298717379 1873705814 673416290 868766340 614560427 "
+        "1668238166 532360730 969915708 1972423626 1966307090 97417947 "
+        "920896215 588041576 495024338 522400288 1068491480 878048146 "
+        "1995051285 17282737 560668414 2143274709 127339385 1299331283 "
+        "99667038 66663006 1566161755 773555006 272986904 1065825536 "
+        "1168683925 1185292013 1144552919 1489883454 811887358 279732868 "
+        "628609193 1562647158 1833265343 1742736292 639398211 357562689 "
+        "896869717 501615326 1775469607 1032409784 43371928 955037563 "
+        "1023543663 1354331571 1071539244 562210166 138213162 1518791327 "
+        "1335204647 1727874626 2114964448 1058152392 1055171537 348065433 "
+        "190278003 399246038 1389247438 1639480282 382424917 2144508195 "
+        "1531185764 1342593547 1359065400 1176108308 1412845568 968776497 "
+        "5573525 1332437854 323541262 329396230 2097079291 1110029273 "
+        "1071549822 739994612 1011644107 1074473050 478563727 894301674 "
+        "290189565 280656618 1121689914 1630931232 579945916 1870220126 "
+        "71516543 1535179528 1893792038 1107650479 1893348357 93154853 "
+        "138035708 683805596 1535656875 1326628479 1469623399 1751042846 "
+        "661214234 1947241260 1780560187 690441964 1403944207 1687457460 "
+        "1428487938 1877084153 1618585041 1383427538 461185097 869443256 "
+        "1254069404 1739961370 1245924391 138197640 1257913073 1915996843 "
+        "641653536 1755587965 1889101622 1732723706 2009073422 1611621773 "
+        "315899200 738279016 94909546 1711873548 1620302377 181922632 "
+        "1704446343 1345319468 2076463060 357902023 157605314 1025175647 "
+        "865799248 138769064 124418006 1591838311 675218651 1096276609 "
+        "1858759850 732186041 769493777 735387805 894450150 638142050 "
+        "720101232 1671055379 636619387 898507955 118193981 63865192 "
+        "1787942091 204050966 2100684950 1580797970 1951284753 1020070334 "
+        "960149537 1041144801 823914651 558983501 1742229329 708805658 "
+        "804904097 1023665826 1260041465 1180659188 590074436 301564006 "
+        "324841922 714752380 1967212989 290476911 815113546 815183409 "
+        "1989370850 1182975807 870784323 171062356 1711897606 2024645183 "
+        "1333203966 314683764 1785282634 603713754 1904315050 1874254109 "
+        "1298675767 1967311508 1946285744 753588304 1847558969 1457540010 "
+        "528986741 97857407 1864449494 1868752281 1171249392 1353422942 "
+        "832597170 457192338 335135800 1925268166 1845956613 296546482 "
+        "1894661934";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::knuth_b e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
new file mode 100644
index 0000000..7b4bc58
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::knuth_b e1;
+    std::knuth_b e2(std::minstd_rand0::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 152607844u);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
new file mode 100644
index 0000000..6e04e26
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::knuth_b e1;
+    std::knuth_b e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
new file mode 100644
index 0000000..c218c17
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    // Workaround for lack of constexpr in C++03
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+#endif
+
+    static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+    static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+   typedef std::knuth_b E;
+
+    E e;
+    assert(e() == 152607844u);
+}
+
+void
+test2()
+{
+    typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+    typedef std::shuffle_order_engine<E0, 101> E;
+    E e;
+    e.discard(400);
+    assert(e() == 501);
+}
+
+void
+test3()
+{
+    typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+    typedef std::shuffle_order_engine<E0, 100> E;
+    E e;
+    e.discard(400);
+    assert(e() == 500);
+}
+
+int main()
+{
+    test1();
+    test2();
+    test3();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
new file mode 100644
index 0000000..6c8fdb9
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template <class charT, class traits,
+//           class Engine, size_t k>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const shuffle_order_engine<Engine, k>& x);
+//
+// template <class charT, class traits,
+//           class Engine, size_t k>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            shuffle_order_engine<Engine, k>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
new file mode 100644
index 0000000..3271d93
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+    // types
+    typedef UIntType result_type;
+
+private:
+    result_type x_;
+
+    static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+    // Workaround for lack of constexpr in C++03
+    static const result_type _Min = Min;
+    static const result_type _Max = Max;
+#endif
+
+    static _LIBCPP_CONSTEXPR  result_type min() {return Min;}
+    static _LIBCPP_CONSTEXPR  result_type max() {return Max;}
+
+    explicit rand1(result_type sd = Min) : x_(sd)
+    {
+        if (x_ < Min)
+            x_ = Min;
+        if (x_ > Max)
+            x_ = Max;
+    }
+
+    result_type operator()()
+    {
+        result_type r = x_;
+        if (x_ < Max)
+            ++x_;
+        else
+            x_ = Min;
+        return r;
+    }
+};
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::shuffle_order_engine<rand1<unsigned long, 0, 10>, 16>::result_type,
+        unsigned long>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::shuffle_order_engine<rand1<unsigned long long, 0, 10>, 16>::result_type,
+        unsigned long long>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
new file mode 100644
index 0000000..57ded84
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::knuth_b E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
new file mode 100644
index 0000000..4b4b099
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::knuth_b e1;
+    std::knuth_b e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
new file mode 100644
index 0000000..eb42d64
--- /dev/null
+++ b/final/test/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+//     // types
+//     typedef typename Engine::result_type result_type;
+//
+//     // engine characteristics
+//     static constexpr size_t table_size = k;
+//     static constexpr result_type min() { return Engine::min; }
+//     static constexpr result_type max() { return Engine::max; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+    typedef std::knuth_b E;
+    static_assert(E::table_size == 256, "");
+    /*static_*/assert((E::min() == 1)/*, ""*/);
+    /*static_*/assert((E::max() == 2147483646)/*, ""*/);
+    where(E::table_size);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.device/ctor.pass.cpp b/final/test/numerics/rand/rand.device/ctor.pass.cpp
new file mode 100644
index 0000000..dfa546b
--- /dev/null
+++ b/final/test/numerics/rand/rand.device/ctor.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// explicit random_device(const string& token = "/dev/urandom");
+
+#include <random>
+#include <cassert>
+#include <unistd.h>
+
+int main()
+{
+    try
+    {
+        std::random_device r("wrong file");
+        assert(false);
+    }
+    catch (const std::system_error& e)
+    {
+    }
+    {
+        std::random_device r;
+    }
+    {
+        int ec;
+        ec = close(STDIN_FILENO);
+        assert(!ec);
+        ec = close(STDOUT_FILENO);
+        assert(!ec);
+        ec = close(STDERR_FILENO);
+        assert(!ec);
+        std::random_device r;
+    }
+    {
+        std::random_device r("/dev/urandom");;
+    }
+    {
+        std::random_device r("/dev/random");;
+    }
+}
diff --git a/final/test/numerics/rand/rand.device/entropy.pass.cpp b/final/test/numerics/rand/rand.device/entropy.pass.cpp
new file mode 100644
index 0000000..f01e565
--- /dev/null
+++ b/final/test/numerics/rand/rand.device/entropy.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// double entropy() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::random_device r;
+    double e = r.entropy();
+}
diff --git a/final/test/numerics/rand/rand.device/eval.pass.cpp b/final/test/numerics/rand/rand.device/eval.pass.cpp
new file mode 100644
index 0000000..72aff07
--- /dev/null
+++ b/final/test/numerics/rand/rand.device/eval.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        std::random_device r;
+        std::random_device::result_type e = r();
+    }
+
+    try
+    {
+        std::random_device r("/dev/null");
+        r();
+        assert(false);
+    }
+    catch (const std::system_error& e)
+    {
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.dis/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp
new file mode 100644
index 0000000..e55c157
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution& operator=(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::bernoulli_distribution D;
+    D d1(0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp
new file mode 100644
index 0000000..c64f925
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::bernoulli_distribution D;
+    D d1(0.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp
new file mode 100644
index 0000000..5d511fc
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d;
+        assert(d.p() == 0.5);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        D d(0);
+        assert(d.p() == 0);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        D d(0.75);
+        assert(d.p() == 0.75);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp
new file mode 100644
index 0000000..a143b5a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(p);
+        assert(d.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp
new file mode 100644
index 0000000..b77c12e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bool operator=(const bernoulli_distribution& x,
+//                const bernoulli_distribution& y);
+// bool operator!(const bernoulli_distribution& x,
+//                const bernoulli_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d1(.25);
+        D d2(.25);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        D d1(.28);
+        D d2(.25);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
new file mode 100644
index 0000000..f071e85
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(.75);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.p();
+        double x_var = d.p()*(1-d.p());
+        double x_skew = (1 - 2 * d.p())/std::sqrt(x_var);
+        double x_kurtosis = (6 * sqr(d.p()) - 6 * d.p() + 1)/x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(.25);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.p();
+        double x_var = d.p()*(1-d.p());
+        double x_skew = (1 - 2 * d.p())/std::sqrt(x_var);
+        double x_kurtosis = (6 * sqr(d.p()) - 6 * d.p() + 1)/x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp
new file mode 100644
index 0000000..e03fb57
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(.75);
+        P p(.25);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.p();
+        double x_var = p.p()*(1-p.p());
+        double x_skew = (1 - 2 * p.p())/std::sqrt(x_var);
+        double x_kurtosis = (6 * sqr(p.p()) - 6 * p.p() + 1)/x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(.25);
+        P p(.75);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.p();
+        double x_var = p.p()*(1-p.p());
+        double x_skew = (1 - 2 * p.p())/std::sqrt(x_var);
+        double x_kurtosis = (6 * sqr(p.p()) - 6 * p.p() + 1)/x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp
new file mode 100644
index 0000000..1b4eae9
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        P p(.125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp
new file mode 100644
index 0000000..5f57145
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const bernoulli_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            bernoulli_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d1(.25);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp
new file mode 100644
index 0000000..8e669bb
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d(.25);
+        assert(d.max() == true);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp
new file mode 100644
index 0000000..296ad14
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        D d(.5);
+        assert(d.min() == false);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp
new file mode 100644
index 0000000..a24dd0d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p0(.7);
+        param_type p;
+        p = p0;
+        assert(p.p() == .7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp
new file mode 100644
index 0000000..6c4eaee
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p0(.125);
+        param_type p = p0;
+        assert(p.p() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp
new file mode 100644
index 0000000..c43f447
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.p() == 0.5);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p(0.25);
+        assert(p.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp
new file mode 100644
index 0000000..ee5dfe8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp
new file mode 100644
index 0000000..5a3b903
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp
new file mode 100644
index 0000000..9869ac6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp
new file mode 100644
index 0000000..4b6c4be
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::bernoulli_distribution D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, bool>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp
new file mode 100644
index 0000000..82473d2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// binomial_distribution& operator=(const binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::binomial_distribution<> D;
+    D d1(2, 0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp
new file mode 100644
index 0000000..7154948
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// binomial_distribution(const binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::binomial_distribution<> D;
+    D d1(2, 0.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp
new file mode 100644
index 0000000..5a3a22e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// explicit binomial_distribution(IntType t = 1, double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        D d;
+        assert(d.t() == 1);
+        assert(d.p() == 0.5);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        D d(3);
+        assert(d.t() == 3);
+        assert(d.p() == 0.5);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        D d(3, 0.75);
+        assert(d.t() == 3);
+        assert(d.p() == 0.75);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp
new file mode 100644
index 0000000..cfb98f2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// explicit binomial_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type P;
+        P p(5, 0.25);
+        D d(p);
+        assert(d.t() == 5);
+        assert(d.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp
new file mode 100644
index 0000000..738bdc8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// bool operator=(const binomial_distribution& x,
+//                const binomial_distribution& y);
+// bool operator!(const binomial_distribution& x,
+//                const binomial_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        D d1(3, .25);
+        D d2(3, .25);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        D d1(3, .28);
+        D d2(3, .25);
+        assert(d1 != d2);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        D d1(3, .25);
+        D d2(4, .25);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
new file mode 100644
index 0000000..3bfd2af
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
@@ -0,0 +1,462 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        D d(5, .75);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(30, .03125);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(40, .25);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.03);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(40, 0);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        // In this case:
+        //   skew     computes to 0./0. == nan
+        //   kurtosis computes to 0./0. == nan
+        //   x_skew     == inf
+        //   x_kurtosis == inf
+        //   These tests are commented out because UBSan warns about division by 0
+//        skew /= u.size() * dev * var;
+//        kurtosis /= u.size() * var * var;
+//        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+//        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+//        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(mean == x_mean);
+        assert(var == x_var);
+//        assert(skew == x_skew);
+//        assert(kurtosis == x_kurtosis);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(40, 1);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        // In this case:
+        //   skew     computes to 0./0. == nan
+        //   kurtosis computes to 0./0. == nan
+        //   x_skew     == -inf
+        //   x_kurtosis == inf
+        //   These tests are commented out because UBSan warns about division by 0
+//        skew /= u.size() * dev * var;
+//        kurtosis /= u.size() * var * var;
+//        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+//        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+//        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(mean == x_mean);
+        assert(var == x_var);
+//        assert(skew == x_skew);
+//        assert(kurtosis == x_kurtosis);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(400, 0.5);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(1, 0.5);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(0, 0.005);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        // In this case:
+        //   skew     computes to 0./0. == nan
+        //   kurtosis computes to 0./0. == nan
+        //   x_skew     == inf
+        //   x_kurtosis == inf
+        //   These tests are commented out because UBSan warns about division by 0
+//        skew /= u.size() * dev * var;
+//        kurtosis /= u.size() * var * var;
+//        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+//        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+//        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(mean == x_mean);
+        assert(var == x_var);
+//        assert(skew == x_skew);
+//        assert(kurtosis == x_kurtosis);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(0, 0);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        // In this case:
+        //   skew     computes to 0./0. == nan
+        //   kurtosis computes to 0./0. == nan
+        //   x_skew     == inf
+        //   x_kurtosis == inf
+        //   These tests are commented out because UBSan warns about division by 0
+//        skew /= u.size() * dev * var;
+//        kurtosis /= u.size() * var * var;
+//        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+//        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+//        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(mean == x_mean);
+        assert(var == x_var);
+//        assert(skew == x_skew);
+//        assert(kurtosis == x_kurtosis);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(0, 1);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        // In this case:
+        //   skew     computes to 0./0. == nan
+        //   kurtosis computes to 0./0. == nan
+        //   x_skew     == -inf
+        //   x_kurtosis == inf
+        //   These tests are commented out because UBSan warns about division by 0
+//        skew /= u.size() * dev * var;
+//        kurtosis /= u.size() * var * var;
+//        kurtosis -= 3;
+        double x_mean = d.t() * d.p();
+        double x_var = x_mean*(1-d.p());
+//        double x_skew = (1-2*d.p()) / std::sqrt(x_var);
+//        double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
+        assert(mean == x_mean);
+        assert(var == x_var);
+//        assert(skew == x_skew);
+//        assert(kurtosis == x_kurtosis);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp
new file mode 100644
index 0000000..df5caf0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        D d(16, .75);
+        P p(5, .75);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(0 <= v && v <= p.t());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.t() * p.p();
+        double x_var = x_mean*(1-p.p());
+        double x_skew = (1-2*p.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(16, .75);
+        P p(30, .03125);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(0 <= v && v <= p.t());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.t() * p.p();
+        double x_var = x_mean*(1-p.p());
+        double x_skew = (1-2*p.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(16, .75);
+        P p(40, .25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(0 <= v && v <= p.t());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.t() * p.p();
+        double x_var = x_mean*(1-p.p());
+        double x_skew = (1-2*p.p()) / std::sqrt(x_var);
+        double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.04);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp
new file mode 100644
index 0000000..88c8424
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type P;
+        P p(5, .125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp
new file mode 100644
index 0000000..1276454
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const binomial_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            binomial_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        D d1(7, .25);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp
new file mode 100644
index 0000000..9c88faa
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        D d(4, .25);
+        assert(d.max() == 4);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp
new file mode 100644
index 0000000..678a34b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        D d(4, .5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp
new file mode 100644
index 0000000..553f8ad
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(6, .7);
+        param_type p;
+        p = p0;
+        assert(p.t() == 6);
+        assert(p.p() == .7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp
new file mode 100644
index 0000000..a9770ef
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.t() == 10);
+        assert(p.p() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp
new file mode 100644
index 0000000..cadf84a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.t() == 1);
+        assert(p.p() == 0.5);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.t() == 10);
+        assert(p.p() == 0.5);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 0.25);
+        assert(p.t() == 10);
+        assert(p.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp
new file mode 100644
index 0000000..3c2c1fa
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(3, 0.75);
+        param_type p2(3, 0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(3, 0.75);
+        param_type p2(3, 0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp
new file mode 100644
index 0000000..6c74561
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp
new file mode 100644
index 0000000..612f5e2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::param_type P;
+        P p(10, 0.25);
+        D d(8, 0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp
new file mode 100644
index 0000000..0e71aa0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::binomial_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, int>::value), "");
+    }
+    {
+        typedef std::binomial_distribution<long> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, long>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp
new file mode 100644
index 0000000..f71b374
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// geometric_distribution& operator=(const geometric_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::geometric_distribution<> D;
+    D d1(0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp
new file mode 100644
index 0000000..00f3d04
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// geometric_distribution(const geometric_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::geometric_distribution<> D;
+    D d1(0.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp
new file mode 100644
index 0000000..4615428
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// explicit geometric_distribution(double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        D d;
+        assert(d.p() == 0.5);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        D d(0.75);
+        assert(d.p() == 0.75);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp
new file mode 100644
index 0000000..5cf93eb
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// explicit geometric_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(p);
+        assert(d.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp
new file mode 100644
index 0000000..38d423b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// bool operator=(const geometric_distribution& x,
+//                const geometric_distribution& y);
+// bool operator!(const geometric_distribution& x,
+//                const geometric_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        D d1(.25);
+        D d2(.25);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        D d1(.28);
+        D d2(.25);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
new file mode 100644
index 0000000..fb43728
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
@@ -0,0 +1,272 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(.03125);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+        double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.05);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+        double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(.25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+        double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+        double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.75);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+        double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.96875);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
+        double x_kurtosis = 6 + sqr(d.p()) / (1 - d.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp
new file mode 100644
index 0000000..282a977
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(.75);
+        P p(.03125);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - p.p()) / p.p();
+        double x_var = x_mean / p.p();
+        double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
+        double x_kurtosis = 6 + sqr(p.p()) / (1 - p.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(.75);
+        P p(.25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - p.p()) / p.p();
+        double x_var = x_mean / p.p();
+        double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
+        double x_kurtosis = 6 + sqr(p.p()) / (1 - p.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(.5);
+        P p(.75);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = (1 - p.p()) / p.p();
+        double x_var = x_mean / p.p();
+        double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
+        double x_kurtosis = 6 + sqr(p.p()) / (1 - p.p());
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp
new file mode 100644
index 0000000..00797a1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type P;
+        P p(.125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp
new file mode 100644
index 0000000..3e3752a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const geometric_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            geometric_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        D d1(.25);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp
new file mode 100644
index 0000000..b381bc4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        D d(.25);
+        assert(d.max() == std::numeric_limits<int>::max());
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp
new file mode 100644
index 0000000..56b75a7
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        D d(.5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp
new file mode 100644
index 0000000..98b84d5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.7);
+        param_type p;
+        p = p0;
+        assert(p.p() == .7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp
new file mode 100644
index 0000000..4397aec
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.125);
+        param_type p = p0;
+        assert(p.p() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp
new file mode 100644
index 0000000..c78525f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.p() == 0.5);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(0.25);
+        assert(p.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp
new file mode 100644
index 0000000..374f2b0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp
new file mode 100644
index 0000000..33a4c6f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp
new file mode 100644
index 0000000..e8aee01
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp
new file mode 100644
index 0000000..367e3f9
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::geometric_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, int>::value), "");
+    }
+    {
+        typedef std::geometric_distribution<long> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, long>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp
new file mode 100644
index 0000000..f62c52e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution& operator=(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::negative_binomial_distribution<> D;
+    D d1(2, 0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp
new file mode 100644
index 0000000..37c003d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::negative_binomial_distribution<> D;
+    D d1(2, 0.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp
new file mode 100644
index 0000000..babf1d4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(IntType t = 1, double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d;
+        assert(d.k() == 1);
+        assert(d.p() == 0.5);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d(3);
+        assert(d.k() == 3);
+        assert(d.p() == 0.5);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d(3, 0.75);
+        assert(d.k() == 3);
+        assert(d.p() == 0.75);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp
new file mode 100644
index 0000000..109a47e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type P;
+        P p(5, 0.25);
+        D d(p);
+        assert(d.k() == 5);
+        assert(d.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp
new file mode 100644
index 0000000..0bf34ee
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// bool operator=(const negative_binomial_distribution& x,
+//                const negative_binomial_distribution& y);
+// bool operator!(const negative_binomial_distribution& x,
+//                const negative_binomial_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d1(3, .25);
+        D d2(3, .25);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d1(3, .28);
+        D d2(3, .25);
+        assert(d1 != d2);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d1(3, .25);
+        D d2(4, .25);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
new file mode 100644
index 0000000..5476503
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
@@ -0,0 +1,270 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(5, .25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.k() * (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+        double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(30, .03125);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.k() * (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+        double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(40, .25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.k() * (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+        double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(40, 1);
+        const int N = 1000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.k() * (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+        double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+        assert(mean == x_mean);
+        assert(var == x_var);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(400, 0.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.k() * (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+        double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.04);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(1, 0.05);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.k() * (1 - d.p()) / d.p();
+        double x_var = x_mean / d.p();
+        double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+        double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp
new file mode 100644
index 0000000..9a78559
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(16, .75);
+        P p(5, .75);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.k() * (1 - p.p()) / p.p();
+        double x_var = x_mean / p.p();
+        double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+        double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(16, .75);
+        P p(30, .03125);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.k() * (1 - p.p()) / p.p();
+        double x_var = x_mean / p.p();
+        double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+        double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(16, .75);
+        P p(40, .25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.k() * (1 - p.p()) / p.p();
+        double x_var = x_mean / p.p();
+        double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+        double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp
new file mode 100644
index 0000000..65f4a97
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type P;
+        P p(5, .125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp
new file mode 100644
index 0000000..da5e8af
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const negative_binomial_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            negative_binomial_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d1(7, .25);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp
new file mode 100644
index 0000000..2fe7184
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d(4, .25);
+        assert(d.max() == std::numeric_limits<int>::max());
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp
new file mode 100644
index 0000000..15bec5a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        D d(4, .5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp
new file mode 100644
index 0000000..dc4d35c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(6, .7);
+        param_type p;
+        p = p0;
+        assert(p.k() == 6);
+        assert(p.p() == .7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp
new file mode 100644
index 0000000..ec5af5b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.k() == 10);
+        assert(p.p() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp
new file mode 100644
index 0000000..6d713ce
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.k() == 1);
+        assert(p.p() == 0.5);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.k() == 10);
+        assert(p.p() == 0.5);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 0.25);
+        assert(p.k() == 10);
+        assert(p.p() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp
new file mode 100644
index 0000000..b0f81cd
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(3, 0.75);
+        param_type p2(3, 0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(3, 0.75);
+        param_type p2(3, 0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp
new file mode 100644
index 0000000..282ca19
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp
new file mode 100644
index 0000000..05c204f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::param_type P;
+        P p(10, 0.25);
+        D d(8, 0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp
new file mode 100644
index 0000000..149f507
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::negative_binomial_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, int>::value), "");
+    }
+    {
+        typedef std::negative_binomial_distribution<long> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, long>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp
new file mode 100644
index 0000000..3003e0d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// cauchy_distribution& operator=(const cauchy_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::cauchy_distribution<> D;
+    D d1(.5, 2);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp
new file mode 100644
index 0000000..0321914
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// cauchy_distribution(const cauchy_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::cauchy_distribution<> D;
+    D d1(.5, 1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp
new file mode 100644
index 0000000..a0406b0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// explicit cauchy_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        D d;
+        assert(d.a() == 0);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        D d(14.5);
+        assert(d.a() == 14.5);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        D d(14.5, 5.25);
+        assert(d.a() == 14.5);
+        assert(d.b() == 5.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp
new file mode 100644
index 0000000..0973b60
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// explicit cauchy_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 10);
+        D d(p);
+        assert(d.a() == 0.25);
+        assert(d.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp
new file mode 100644
index 0000000..005e141
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// bool operator=(const cauchy_distribution& x,
+//                const cauchy_distribution& y);
+// bool operator!(const cauchy_distribution& x,
+//                const cauchy_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp
new file mode 100644
index 0000000..3a63a6d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+
+double
+f(double x, double a, double b)
+{
+    return 1/3.1415926535897932 * std::atan((x - a)/b) + .5;
+}
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        const double a = 10;
+        const double b = .5;
+        D d(a, b);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        const double a = -1.5;
+        const double b = 1;
+        D d(a, b);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        const double a = .5;
+        const double b = 2;
+        D d(a, b);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp
new file mode 100644
index 0000000..fa25953
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+
+double
+f(double x, double a, double b)
+{
+    return 1/3.1415926535897932 * std::atan((x - a)/b) + .5;
+}
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        const double a = 10;
+        const double b = .5;
+        D d;
+        P p(a, b);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        const double a = -1.5;
+        const double b = 1;
+        D d;
+        P p(a, b);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        const double a = .5;
+        const double b = 2;
+        D d;
+        P p(a, b);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp
new file mode 100644
index 0000000..0e2d6b0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        P p(.125, .5);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp
new file mode 100644
index 0000000..ca53792
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const cauchy_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            cauchy_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        D d1(7.5, 5.5);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp
new file mode 100644
index 0000000..263c177
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        D d(5, .25);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp
new file mode 100644
index 0000000..0d52179
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        D d(.5, .5);
+        assert(d.min() == -INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp
new file mode 100644
index 0000000..f8e0852
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75, 6);
+        param_type p;
+        p = p0;
+        assert(p.a() == .75);
+        assert(p.b() == 6);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp
new file mode 100644
index 0000000..28ef068
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.a() == 10);
+        assert(p.b() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp
new file mode 100644
index 0000000..8ae5137
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.a() == 0);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.a() == 10);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 5);
+        assert(p.a() == 10);
+        assert(p.b() == 5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp
new file mode 100644
index 0000000..6210321
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.75, .5);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.5, .5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp
new file mode 100644
index 0000000..56b1f6f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp
new file mode 100644
index 0000000..201ec60
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 5.5);
+        D d(0.75, 4);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp
new file mode 100644
index 0000000..919a7b1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::cauchy_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::cauchy_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp
new file mode 100644
index 0000000..0c3a0ae
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// chi_squared_distribution& operator=(const chi_squared_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::chi_squared_distribution<> D;
+    D d1(20.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp
new file mode 100644
index 0000000..9496184
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// chi_squared_distribution(const chi_squared_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::chi_squared_distribution<> D;
+    D d1(21.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp
new file mode 100644
index 0000000..27401d9
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// explicit chi_squared_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        D d;
+        assert(d.n() == 1);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        D d(14.5);
+        assert(d.n() == 14.5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp
new file mode 100644
index 0000000..afd5aa9
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// explicit chi_squared_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(p);
+        assert(d.n() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp
new file mode 100644
index 0000000..88630b0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// bool operator=(const chi_squared_distribution& x,
+//                const chi_squared_distribution& y);
+// bool operator!(const chi_squared_distribution& x,
+//                const chi_squared_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        D d1(2.5);
+        D d2(2.5);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        D d1(4);
+        D d2(4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp
new file mode 100644
index 0000000..e7782af
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(0.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.n();
+        double x_var = 2 * d.n();
+        double x_skew = std::sqrt(8 / d.n());
+        double x_kurtosis = 12 / d.n();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(1);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.n();
+        double x_var = 2 * d.n();
+        double x_skew = std::sqrt(8 / d.n());
+        double x_kurtosis = 12 / d.n();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.n();
+        double x_var = 2 * d.n();
+        double x_skew = std::sqrt(8 / d.n());
+        double x_kurtosis = 12 / d.n();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp
new file mode 100644
index 0000000..659a9c6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(0.5);
+        P p(1);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.n();
+        double x_var = 2 * p.n();
+        double x_skew = std::sqrt(8 / p.n());
+        double x_kurtosis = 12 / p.n();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1);
+        P p(2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.n();
+        double x_var = 2 * p.n();
+        double x_skew = std::sqrt(8 / p.n());
+        double x_kurtosis = 12 / p.n();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(2);
+        P p(.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.n();
+        double x_var = 2 * p.n();
+        double x_skew = std::sqrt(8 / p.n());
+        double x_kurtosis = 12 / p.n();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp
new file mode 100644
index 0000000..f12a051
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        P p(.125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp
new file mode 100644
index 0000000..de16fa1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const chi_squared_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            chi_squared_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        D d1(7);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp
new file mode 100644
index 0000000..adf4f96
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        D d(5);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp
new file mode 100644
index 0000000..4e51590
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        D d(.5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp
new file mode 100644
index 0000000..85730f6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75);
+        param_type p;
+        p = p0;
+        assert(p.n() == .75);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp
new file mode 100644
index 0000000..3ddb02b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10);
+        param_type p = p0;
+        assert(p.n() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp
new file mode 100644
index 0000000..34d8651
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.n() == 1);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.n() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp
new file mode 100644
index 0000000..cb738ea
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp
new file mode 100644
index 0000000..257016b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp
new file mode 100644
index 0000000..a8d4e52
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp
new file mode 100644
index 0000000..614da19
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::chi_squared_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::chi_squared_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp
new file mode 100644
index 0000000..f5294bd
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution& operator=(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::fisher_f_distribution<> D;
+    D d1(20, 0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp
new file mode 100644
index 0000000..047d513
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::fisher_f_distribution<> D;
+    D d1(20, 1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp
new file mode 100644
index 0000000..1dd628b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d;
+        assert(d.m() == 1);
+        assert(d.n() == 1);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d(14.5);
+        assert(d.m() == 14.5);
+        assert(d.n() == 1);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d(14.5, 5.25);
+        assert(d.m() == 14.5);
+        assert(d.n() == 5.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp
new file mode 100644
index 0000000..83a81cf
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 10);
+        D d(p);
+        assert(d.m() == 0.25);
+        assert(d.n() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp
new file mode 100644
index 0000000..405c906
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// bool operator=(const fisher_f_distribution& x,
+//                const fisher_f_distribution& y);
+// bool operator!(const fisher_f_distribution& x,
+//                const fisher_f_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
new file mode 100644
index 0000000..a3d083c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+    double r = 1;
+    for (; x > 1; --x)
+        r *= x;
+    return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+    double r = 0;
+    for (int j = a; j <= a+b-1; ++j)
+        r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+             std::pow(1-x, a+b-1-j);
+    return r;
+}
+
+double
+f(double x, double m, double n)
+{
+    return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+    // Purposefully only testing even integral values of m and n (for now)
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2, 4);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v >= 0);
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(4, 2);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v >= 0);
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(18, 20);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v >= 0);
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
new file mode 100644
index 0000000..3200be5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+    double r = 1;
+    for (; x > 1; --x)
+        r *= x;
+    return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+    double r = 0;
+    for (int j = a; j <= a+b-1; ++j)
+        r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+             std::pow(1-x, a+b-1-j);
+    return r;
+}
+
+double
+f(double x, double m, double n)
+{
+    return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+    // Purposefully only testing even integral values of m and n (for now)
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2, 4);
+        P p(4, 2);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v >= 0);
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(4, 2);
+        P p(6, 8);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v >= 0);
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(18, 20);
+        P p(16, 14);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v >= 0);
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < N; ++i)
+            assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp
new file mode 100644
index 0000000..572df9b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        P p(.125, .5);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp
new file mode 100644
index 0000000..8872a27
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const fisher_f_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            fisher_f_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d1(7, 5);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp
new file mode 100644
index 0000000..dfdbd5d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d(5, .25);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp
new file mode 100644
index 0000000..bd4c5d1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        D d(.5, .5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp
new file mode 100644
index 0000000..ea44645
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75, 6);
+        param_type p;
+        p = p0;
+        assert(p.m() == .75);
+        assert(p.n() == 6);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp
new file mode 100644
index 0000000..d6ce53a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.m() == 10);
+        assert(p.n() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp
new file mode 100644
index 0000000..1ab9138
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.m() == 1);
+        assert(p.n() == 1);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.m() == 10);
+        assert(p.n() == 1);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 5);
+        assert(p.m() == 10);
+        assert(p.n() == 5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp
new file mode 100644
index 0000000..16eea40
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.75, .5);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.5, .5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp
new file mode 100644
index 0000000..8391eed
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp
new file mode 100644
index 0000000..a7a1af6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 5.5);
+        D d(0.75, 4);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp
new file mode 100644
index 0000000..b765725
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::fisher_f_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::fisher_f_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp
new file mode 100644
index 0000000..4da6451
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution& operator=(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::lognormal_distribution<> D;
+    D d1(20, 0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp
new file mode 100644
index 0000000..777f4a1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::lognormal_distribution<> D;
+    D d1(20, 1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp
new file mode 100644
index 0000000..39d5339
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(result_type mean = 0, result_type stddev = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        D d;
+        assert(d.m() == 0);
+        assert(d.s() == 1);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        D d(14.5);
+        assert(d.m() == 14.5);
+        assert(d.s() == 1);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        D d(14.5, 5.25);
+        assert(d.m() == 14.5);
+        assert(d.s() == 5.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp
new file mode 100644
index 0000000..f165677
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 10);
+        D d(p);
+        assert(d.m() == 0.25);
+        assert(d.s() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp
new file mode 100644
index 0000000..5fee0fd
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// bool operator=(const lognormal_distribution& x,
+//                const lognormal_distribution& y);
+// bool operator!(const lognormal_distribution& x,
+//                const lognormal_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
new file mode 100644
index 0000000..d6e9369
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
@@ -0,0 +1,242 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-1./8192, 0.015625);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(d.m() + sqr(d.s())/2);
+        double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+        double x_skew = (std::exp(sqr(d.s())) + 2) *
+              std::sqrt((std::exp(sqr(d.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+                          3*std::exp(2*sqr(d.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.05);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.25);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-1./32, 0.25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(d.m() + sqr(d.s())/2);
+        double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+        double x_skew = (std::exp(sqr(d.s())) + 2) *
+              std::sqrt((std::exp(sqr(d.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+                          3*std::exp(2*sqr(d.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-1./8, 0.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(d.m() + sqr(d.s())/2);
+        double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+        double x_skew = (std::exp(sqr(d.s())) + 2) *
+              std::sqrt((std::exp(sqr(d.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+                          3*std::exp(2*sqr(d.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.02);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d;
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(d.m() + sqr(d.s())/2);
+        double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+        double x_skew = (std::exp(sqr(d.s())) + 2) *
+              std::sqrt((std::exp(sqr(d.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+                          3*std::exp(2*sqr(d.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.02);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.08);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.4);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-0.78125, 1.25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(d.m() + sqr(d.s())/2);
+        double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+        double x_skew = (std::exp(sqr(d.s())) + 2) *
+              std::sqrt((std::exp(sqr(d.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+                          3*std::exp(2*sqr(d.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.04);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.2);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
new file mode 100644
index 0000000..ccc9d81
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
@@ -0,0 +1,248 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d;
+        P p(-1./8192, 0.015625);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(p.m() + sqr(p.s())/2);
+        double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+        double x_skew = (std::exp(sqr(p.s())) + 2) *
+              std::sqrt((std::exp(sqr(p.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+                          3*std::exp(2*sqr(p.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.05);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.25);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d;
+        P p(-1./32, 0.25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(p.m() + sqr(p.s())/2);
+        double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+        double x_skew = (std::exp(sqr(p.s())) + 2) *
+              std::sqrt((std::exp(sqr(p.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+                          3*std::exp(2*sqr(p.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d;
+        P p(-1./8, 0.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(p.m() + sqr(p.s())/2);
+        double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+        double x_skew = (std::exp(sqr(p.s())) + 2) *
+              std::sqrt((std::exp(sqr(p.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+                          3*std::exp(2*sqr(p.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.02);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(3, 4);
+        P p;
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(p.m() + sqr(p.s())/2);
+        double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+        double x_skew = (std::exp(sqr(p.s())) + 2) *
+              std::sqrt((std::exp(sqr(p.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+                          3*std::exp(2*sqr(p.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.02);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.08);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.4);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d;
+        P p(-0.78125, 1.25);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(v > 0);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = std::exp(p.m() + sqr(p.s())/2);
+        double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+        double x_skew = (std::exp(sqr(p.s())) + 2) *
+              std::sqrt((std::exp(sqr(p.s())) - 1));
+        double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+                          3*std::exp(2*sqr(p.s())) - 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.04);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.2);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp
new file mode 100644
index 0000000..348ca6c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        P p(.125, .5);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp
new file mode 100644
index 0000000..4af0f2e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const lognormal_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            lognormal_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        D d1(7, 5);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp
new file mode 100644
index 0000000..7ebfc43
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        D d(5, .25);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp
new file mode 100644
index 0000000..6af4df7
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        D d(.5, .5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp
new file mode 100644
index 0000000..b23c770
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75, 6);
+        param_type p;
+        p = p0;
+        assert(p.m() == .75);
+        assert(p.s() == 6);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp
new file mode 100644
index 0000000..32ecc68
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.m() == 10);
+        assert(p.s() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp
new file mode 100644
index 0000000..2f109e3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.m() == 0);
+        assert(p.s() == 1);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.m() == 10);
+        assert(p.s() == 1);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 5);
+        assert(p.m() == 10);
+        assert(p.s() == 5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp
new file mode 100644
index 0000000..2f4293a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.75, .5);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.5, .5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp
new file mode 100644
index 0000000..6e53b26
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp
new file mode 100644
index 0000000..09c183f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 5.5);
+        D d(0.75, 4);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp
new file mode 100644
index 0000000..1a07000
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::lognormal_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::lognormal_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp
new file mode 100644
index 0000000..a7b2f71
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// normal_distribution& operator=(const normal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::normal_distribution<> D;
+    D d1(20, 0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp
new file mode 100644
index 0000000..63f5be3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// normal_distribution(const normal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::normal_distribution<> D;
+    D d1(20, 1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp
new file mode 100644
index 0000000..24a45f7
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// explicit normal_distribution(result_type mean = 0, result_type stddev = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        D d;
+        assert(d.mean() == 0);
+        assert(d.stddev() == 1);
+    }
+    {
+        typedef std::normal_distribution<> D;
+        D d(14.5);
+        assert(d.mean() == 14.5);
+        assert(d.stddev() == 1);
+    }
+    {
+        typedef std::normal_distribution<> D;
+        D d(14.5, 5.25);
+        assert(d.mean() == 14.5);
+        assert(d.stddev() == 5.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp
new file mode 100644
index 0000000..11c7fbd
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// explicit normal_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 10);
+        D d(p);
+        assert(d.mean() == 0.25);
+        assert(d.stddev() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp
new file mode 100644
index 0000000..b6bd3d3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// bool operator=(const normal_distribution& x,
+//                const normal_distribution& y);
+// bool operator!(const normal_distribution& x,
+//                const normal_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::normal_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp
new file mode 100644
index 0000000..7945d20
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(5, 4);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.mean();
+        double x_var = sqr(d.stddev());
+        double x_skew = 0;
+        double x_kurtosis = 0;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp
new file mode 100644
index 0000000..234cc89
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(5, 4);
+        P p(50, .5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.mean();
+        double x_var = sqr(p.stddev());
+        double x_skew = 0;
+        double x_kurtosis = 0;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp
new file mode 100644
index 0000000..8b5d432
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type P;
+        P p(.125, .5);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp
new file mode 100644
index 0000000..6d79433
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const normal_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            normal_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        D d1(7, 5);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp
new file mode 100644
index 0000000..3825704
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        D d(5, .25);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp
new file mode 100644
index 0000000..9ba754d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        D d(.5, .5);
+        assert(d.min() == -INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp
new file mode 100644
index 0000000..2f7329b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75, 6);
+        param_type p;
+        p = p0;
+        assert(p.mean() == .75);
+        assert(p.stddev() == 6);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp
new file mode 100644
index 0000000..bddf002
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.mean() == 10);
+        assert(p.stddev() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp
new file mode 100644
index 0000000..a1add14
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.mean() == 0);
+        assert(p.stddev() == 1);
+    }
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.mean() == 10);
+        assert(p.stddev() == 1);
+    }
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 5);
+        assert(p.mean() == 10);
+        assert(p.stddev() == 5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp
new file mode 100644
index 0000000..cf20938
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.75, .5);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.5, .5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp
new file mode 100644
index 0000000..8d9b97e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp
new file mode 100644
index 0000000..bb01bb1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 5.5);
+        D d(0.75, 4);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp
new file mode 100644
index 0000000..771685a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::normal_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::normal_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp
new file mode 100644
index 0000000..80c0a19
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// student_t_distribution& operator=(const student_t_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::student_t_distribution<> D;
+    D d1(20.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp
new file mode 100644
index 0000000..032cf77
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// student_t_distribution(const student_t_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::student_t_distribution<> D;
+    D d1(21.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp
new file mode 100644
index 0000000..7dfb97f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// explicit student_t_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        D d;
+        assert(d.n() == 1);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        D d(14.5);
+        assert(d.n() == 14.5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp
new file mode 100644
index 0000000..57dedea
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// explicit student_t_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(p);
+        assert(d.n() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp
new file mode 100644
index 0000000..73e8340
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// bool operator=(const student_t_distribution& x,
+//                const student_t_distribution& y);
+// bool operator!(const student_t_distribution& x,
+//                const student_t_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        D d1(2.5);
+        D d2(2.5);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        D d1(4);
+        D d2(4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp
new file mode 100644
index 0000000..0462c7b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(5.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 0;
+        double x_var = d.n() / (d.n() - 2);
+        double x_skew = 0;
+        double x_kurtosis = 6 / (d.n() - 4);
+        assert(std::abs(mean - x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(10);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 0;
+        double x_var = d.n() / (d.n() - 2);
+        double x_skew = 0;
+        double x_kurtosis = 6 / (d.n() - 4);
+        assert(std::abs(mean - x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(100);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 0;
+        double x_var = d.n() / (d.n() - 2);
+        double x_skew = 0;
+        double x_kurtosis = 6 / (d.n() - 4);
+        assert(std::abs(mean - x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp
new file mode 100644
index 0000000..9da114e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d;
+        P p(5.5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 0;
+        double x_var = p.n() / (p.n() - 2);
+        double x_skew = 0;
+        double x_kurtosis = 6 / (p.n() - 4);
+        assert(std::abs(mean - x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d;
+        P p(10);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 0;
+        double x_var = p.n() / (p.n() - 2);
+        double x_skew = 0;
+        double x_kurtosis = 6 / (p.n() - 4);
+        assert(std::abs(mean - x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d;
+        P p(100);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+            u.push_back(d(g, p));
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 0;
+        double x_var = p.n() / (p.n() - 2);
+        double x_skew = 0;
+        double x_kurtosis = 6 / (p.n() - 4);
+        assert(std::abs(mean - x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp
new file mode 100644
index 0000000..a702a9f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        P p(.125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp
new file mode 100644
index 0000000..d3ca6ee
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const student_t_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            student_t_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        D d1(7);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp
new file mode 100644
index 0000000..aab361e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        D d(5);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp
new file mode 100644
index 0000000..a615f8e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        D d(.5);
+        assert(d.min() == -INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp
new file mode 100644
index 0000000..e900c25
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75);
+        param_type p;
+        p = p0;
+        assert(p.n() == .75);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp
new file mode 100644
index 0000000..9ce6a91
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10);
+        param_type p = p0;
+        assert(p.n() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp
new file mode 100644
index 0000000..c9d0e13
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.n() == 1);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.n() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp
new file mode 100644
index 0000000..83634b2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp
new file mode 100644
index 0000000..6cdd5c4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp
new file mode 100644
index 0000000..681d335
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp
new file mode 100644
index 0000000..9a25ce2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::student_t_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::student_t_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp
new file mode 100644
index 0000000..c2a11a1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// exponential_distribution& operator=(const exponential_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::exponential_distribution<> D;
+    D d1(0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp
new file mode 100644
index 0000000..81ae8e0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// exponential_distribution(const exponential_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::exponential_distribution<> D;
+    D d1(1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp
new file mode 100644
index 0000000..92205a8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// explicit exponential_distribution(RealType lambda = 1.0);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        D d;
+        assert(d.lambda() == 1);
+    }
+    {
+        typedef std::exponential_distribution<> D;
+        D d(3.5);
+        assert(d.lambda() == 3.5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp
new file mode 100644
index 0000000..cd9782b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// explicit exponential_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(p);
+        assert(d.lambda() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp
new file mode 100644
index 0000000..e31a14d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// bool operator=(const exponential_distribution& x,
+//                const exponential_distribution& y);
+// bool operator!(const exponential_distribution& x,
+//                const exponential_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        D d1(.25);
+        D d2(.25);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::exponential_distribution<> D;
+        D d1(.28);
+        D d2(.25);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp
new file mode 100644
index 0000000..980a1d6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(.75);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 1/d.lambda();
+        double x_var = 1/sqr(d.lambda());
+        double x_skew = 2;
+        double x_kurtosis = 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 1/d.lambda();
+        double x_var = 1/sqr(d.lambda());
+        double x_skew = 2;
+        double x_kurtosis = 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(10);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 1/d.lambda();
+        double x_var = 1/sqr(d.lambda());
+        double x_skew = 2;
+        double x_kurtosis = 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp
new file mode 100644
index 0000000..327f004
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(.75);
+        P p(2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = 1/p.lambda();
+        double x_var = 1/sqr(p.lambda());
+        double x_skew = 2;
+        double x_kurtosis = 6;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp
new file mode 100644
index 0000000..f5bd810
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type P;
+        P p(.125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp
new file mode 100644
index 0000000..eaedc87
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const exponential_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            exponential_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        D d1(7);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp
new file mode 100644
index 0000000..204cd7c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        D d(.25);
+        D::result_type m = d.max();
+        assert(m == std::numeric_limits<D::result_type>::infinity());
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp
new file mode 100644
index 0000000..60af4bc
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        D d(.5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp
new file mode 100644
index 0000000..1f53521
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.7);
+        param_type p;
+        p = p0;
+        assert(p.lambda() == .7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp
new file mode 100644
index 0000000..360bd5d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.125);
+        param_type p = p0;
+        assert(p.lambda() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp
new file mode 100644
index 0000000..7d74c7f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.lambda() == 1);
+    }
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.lambda() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp
new file mode 100644
index 0000000..416d18c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp
new file mode 100644
index 0000000..3d73711
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp
new file mode 100644
index 0000000..6c295aa
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp
new file mode 100644
index 0000000..3d444e6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::exponential_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::exponential_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp
new file mode 100644
index 0000000..ff7cff4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// extreme_value_distribution& operator=(const extreme_value_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::extreme_value_distribution<> D;
+    D d1(.5, 2);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp
new file mode 100644
index 0000000..3037797
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// extreme_value_distribution(const extreme_value_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::extreme_value_distribution<> D;
+    D d1(.5, 1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp
new file mode 100644
index 0000000..f5068d9
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// explicit extreme_value_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d;
+        assert(d.a() == 0);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d(14.5);
+        assert(d.a() == 14.5);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d(14.5, 5.25);
+        assert(d.a() == 14.5);
+        assert(d.b() == 5.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp
new file mode 100644
index 0000000..cac0669
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// explicit extreme_value_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 10);
+        D d(p);
+        assert(d.a() == 0.25);
+        assert(d.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp
new file mode 100644
index 0000000..6280df4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// bool operator=(const extreme_value_distribution& x,
+//                const extreme_value_distribution& y);
+// bool operator!(const extreme_value_distribution& x,
+//                const extreme_value_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp
new file mode 100644
index 0000000..b01b087
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp
@@ -0,0 +1,188 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.5, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.a() + d.b() * 0.577215665;
+        double x_var = sqr(d.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.a() + d.b() * 0.577215665;
+        double x_var = sqr(d.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1.5, 3);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.a() + d.b() * 0.577215665;
+        double x_var = sqr(d.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(3, 4);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.a() + d.b() * 0.577215665;
+        double x_var = sqr(d.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp
new file mode 100644
index 0000000..96adcea
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp
@@ -0,0 +1,192 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-0.5, 1);
+        P p(0.5, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.a() + p.b() * 0.577215665;
+        double x_var = sqr(p.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-0.5, 1);
+        P p(1, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.a() + p.b() * 0.577215665;
+        double x_var = sqr(p.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-0.5, 1);
+        P p(1.5, 3);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.a() + p.b() * 0.577215665;
+        double x_var = sqr(p.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(-0.5, 1);
+        P p(3, 4);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.a() + p.b() * 0.577215665;
+        double x_var = sqr(p.b()) * 1.644934067;
+        double x_skew = 1.139547;
+        double x_kurtosis = 12./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp
new file mode 100644
index 0000000..1855d5f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        P p(.125, .5);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp
new file mode 100644
index 0000000..0beaf42
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const extreme_value_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            extreme_value_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d1(7.5, 5.5);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp
new file mode 100644
index 0000000..ca89e35
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d(5, .25);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp
new file mode 100644
index 0000000..1f98a5b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        D d(.5, .5);
+        assert(d.min() == -INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp
new file mode 100644
index 0000000..44f587f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75, 6);
+        param_type p;
+        p = p0;
+        assert(p.a() == .75);
+        assert(p.b() == 6);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp
new file mode 100644
index 0000000..6675bab
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.a() == 10);
+        assert(p.b() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp
new file mode 100644
index 0000000..3fe3d49
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.a() == 0);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.a() == 10);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 5);
+        assert(p.a() == 10);
+        assert(p.b() == 5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp
new file mode 100644
index 0000000..3b55d56
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.75, .5);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.5, .5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp
new file mode 100644
index 0000000..d6ffb5f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp
new file mode 100644
index 0000000..dcf0b16
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 5.5);
+        D d(0.75, 4);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp
new file mode 100644
index 0000000..44dd181
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::extreme_value_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::extreme_value_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp
new file mode 100644
index 0000000..671f4b1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// gamma_distribution& operator=(const gamma_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::gamma_distribution<> D;
+    D d1(20, 0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp
new file mode 100644
index 0000000..876ecb2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// gamma_distribution(const gamma_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::gamma_distribution<> D;
+    D d1(20, 1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp
new file mode 100644
index 0000000..5bc4bba
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// explicit gamma_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        D d;
+        assert(d.alpha() == 1);
+        assert(d.beta() == 1);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        D d(14.5);
+        assert(d.alpha() == 14.5);
+        assert(d.beta() == 1);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        D d(14.5, 5.25);
+        assert(d.alpha() == 14.5);
+        assert(d.beta() == 5.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp
new file mode 100644
index 0000000..35de51b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// explicit gamma_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 10);
+        D d(p);
+        assert(d.alpha() == 0.25);
+        assert(d.beta() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp
new file mode 100644
index 0000000..48331a6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// bool operator=(const gamma_distribution& x,
+//                const gamma_distribution& y);
+// bool operator!(const gamma_distribution& x,
+//                const gamma_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp
new file mode 100644
index 0000000..9ac36f7
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.5, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.alpha() * d.beta();
+        double x_var = d.alpha() * sqr(d.beta());
+        double x_skew = 2 / std::sqrt(d.alpha());
+        double x_kurtosis = 6 / d.alpha();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1, .5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.alpha() * d.beta();
+        double x_var = d.alpha() * sqr(d.beta());
+        double x_skew = 2 / std::sqrt(d.alpha());
+        double x_kurtosis = 6 / d.alpha();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2, 3);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.alpha() * d.beta();
+        double x_var = d.alpha() * sqr(d.beta());
+        double x_skew = 2 / std::sqrt(d.alpha());
+        double x_kurtosis = 6 / d.alpha();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp
new file mode 100644
index 0000000..a1784ee
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.5, 2);
+        P p(1, .5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.alpha() * p.beta();
+        double x_var = p.alpha() * sqr(p.beta());
+        double x_skew = 2 / std::sqrt(p.alpha());
+        double x_kurtosis = 6 / p.alpha();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1, .5);
+        P p(2, 3);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.alpha() * p.beta();
+        double x_var = p.alpha() * sqr(p.beta());
+        double x_skew = 2 / std::sqrt(p.alpha());
+        double x_kurtosis = 6 / p.alpha();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2, 3);
+        P p(.5, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() < v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.alpha() * p.beta();
+        double x_var = p.alpha() * sqr(p.beta());
+        double x_skew = 2 / std::sqrt(p.alpha());
+        double x_kurtosis = 6 / p.alpha();
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp
new file mode 100644
index 0000000..0aad32c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        P p(.125, .5);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp
new file mode 100644
index 0000000..a2a288a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const gamma_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            gamma_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        D d1(7, 5);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp
new file mode 100644
index 0000000..9ec5193
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        D d(5, .25);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp
new file mode 100644
index 0000000..a918c14
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        D d(.5, .5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp
new file mode 100644
index 0000000..31f346e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75, 6);
+        param_type p;
+        p = p0;
+        assert(p.alpha() == .75);
+        assert(p.beta() == 6);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp
new file mode 100644
index 0000000..c96cbcd
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.alpha() == 10);
+        assert(p.beta() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp
new file mode 100644
index 0000000..c0e34f0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.alpha() == 1);
+        assert(p.beta() == 1);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.alpha() == 10);
+        assert(p.beta() == 1);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 5);
+        assert(p.alpha() == 10);
+        assert(p.beta() == 5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp
new file mode 100644
index 0000000..2fe9c2d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.75, .5);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.5, .5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp
new file mode 100644
index 0000000..51e8eb1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp
new file mode 100644
index 0000000..7e22629
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 5.5);
+        D d(0.75, 4);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp
new file mode 100644
index 0000000..65459e0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::gamma_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::gamma_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp
new file mode 100644
index 0000000..5f14555
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// poisson_distribution& operator=(const poisson_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::poisson_distribution<> D;
+    D d1(0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp
new file mode 100644
index 0000000..8abf7ff
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// poisson_distribution(const poisson_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::poisson_distribution<> D;
+    D d1(1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp
new file mode 100644
index 0000000..0cc82ca
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// explicit poisson_distribution(RealType lambda = 1.0);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        D d;
+        assert(d.mean() == 1);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        D d(3.5);
+        assert(d.mean() == 3.5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp
new file mode 100644
index 0000000..a24d755
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// explicit poisson_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(p);
+        assert(d.mean() == 0.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp
new file mode 100644
index 0000000..7bea12e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// bool operator=(const poisson_distribution& x,
+//                const poisson_distribution& y);
+// bool operator!(const poisson_distribution& x,
+//                const poisson_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        D d1(.25);
+        D d2(.25);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        D d1(.28);
+        D d2(.25);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
new file mode 100644
index 0000000..7e4de3b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(2);
+        const int N = 100000;
+        std::vector<double> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.mean();
+        double x_var = d.mean();
+        double x_skew = 1 / std::sqrt(x_var);
+        double x_kurtosis = 1 / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(0.75);
+        const int N = 100000;
+        std::vector<double> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.mean();
+        double x_var = d.mean();
+        double x_skew = 1 / std::sqrt(x_var);
+        double x_kurtosis = 1 / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d(20);
+        const int N = 1000000;
+        std::vector<double> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.mean();
+        double x_var = d.mean();
+        double x_skew = 1 / std::sqrt(x_var);
+        double x_kurtosis = 1 / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp
new file mode 100644
index 0000000..dcd68ed
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(.75);
+        P p(2);
+        const int N = 100000;
+        std::vector<double> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.mean();
+        double x_var = p.mean();
+        double x_skew = 1 / std::sqrt(x_var);
+        double x_kurtosis = 1 / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d(2);
+        P p(.75);
+        const int N = 100000;
+        std::vector<double> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.mean();
+        double x_var = p.mean();
+        double x_skew = 1 / std::sqrt(x_var);
+        double x_kurtosis = 1 / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2);
+        P p(20);
+        const int N = 1000000;
+        std::vector<double> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v && v <= d.max());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.mean();
+        double x_var = p.mean();
+        double x_skew = 1 / std::sqrt(x_var);
+        double x_kurtosis = 1 / x_var;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp
new file mode 100644
index 0000000..3f5f367
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type P;
+        P p(.125);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp
new file mode 100644
index 0000000..6380559
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template <class CharT, class Traits, class IntType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const poisson_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class IntType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            poisson_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        D d1(7);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp
new file mode 100644
index 0000000..2dffab3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        D d(.25);
+        D::result_type m = d.max();
+        assert(m == std::numeric_limits<int>::max());
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp
new file mode 100644
index 0000000..607d49b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        D d(.5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp
new file mode 100644
index 0000000..1c31ea3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.7);
+        param_type p;
+        p = p0;
+        assert(p.mean() == .7);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp
new file mode 100644
index 0000000..19c0513
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.125);
+        param_type p = p0;
+        assert(p.mean() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp
new file mode 100644
index 0000000..081e3a2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.mean() == 1);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.mean() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp
new file mode 100644
index 0000000..cbee358
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.75);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75);
+        param_type p2(0.5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp
new file mode 100644
index 0000000..c3136e0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp
new file mode 100644
index 0000000..86fe1f4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class poisson_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25);
+        D d(0.75);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp
new file mode 100644
index 0000000..05e8b11
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::poisson_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, int>::value), "");
+    }
+    {
+        typedef std::poisson_distribution<unsigned long long> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, unsigned long long>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp
new file mode 100644
index 0000000..31a2c4a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// weibull_distribution& operator=(const weibull_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::weibull_distribution<> D;
+    D d1(20, 0.75);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp
new file mode 100644
index 0000000..68ef4df
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// weibull_distribution(const weibull_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::weibull_distribution<> D;
+    D d1(20, 1.75);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp
new file mode 100644
index 0000000..34c6705
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// explicit weibull_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        D d;
+        assert(d.a() == 1);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        D d(14.5);
+        assert(d.a() == 14.5);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        D d(14.5, 5.25);
+        assert(d.a() == 14.5);
+        assert(d.b() == 5.25);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp
new file mode 100644
index 0000000..5db4f1d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// explicit weibull_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 10);
+        D d(p);
+        assert(d.a() == 0.25);
+        assert(d.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp
new file mode 100644
index 0000000..4c681c1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// bool operator=(const weibull_distribution& x,
+//                const weibull_distribution& y);
+// bool operator!(const weibull_distribution& x,
+//                const weibull_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        D d1(2.5, 4);
+        D d2(2.5, 4.5);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp
new file mode 100644
index 0000000..2770dd8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.5, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+        double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+        double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+                        3*x_mean*x_var - sqr(x_mean)*x_mean) /
+                        (std::sqrt(x_var)*x_var);
+        double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
+                       4*x_skew*x_var*sqrt(x_var)*x_mean -
+                       6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1, .5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+        double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+        double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+                        3*x_mean*x_var - sqr(x_mean)*x_mean) /
+                        (std::sqrt(x_var)*x_var);
+        double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
+                       4*x_skew*x_var*sqrt(x_var)*x_mean -
+                       6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2, 3);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+        double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+        double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+                        3*x_mean*x_var - sqr(x_mean)*x_mean) /
+                        (std::sqrt(x_var)*x_var);
+        double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
+                       4*x_skew*x_var*sqrt(x_var)*x_mean -
+                       6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp
new file mode 100644
index 0000000..f69904c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp
@@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(0.5, 2);
+        P p(1, .5);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+        double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+        double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+                        3*x_mean*x_var - sqr(x_mean)*x_mean) /
+                        (std::sqrt(x_var)*x_var);
+        double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
+                       4*x_skew*x_var*sqrt(x_var)*x_mean -
+                       6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(1, .5);
+        P p(2, 3);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+        double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+        double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+                        3*x_mean*x_var - sqr(x_mean)*x_mean) /
+                        (std::sqrt(x_var)*x_var);
+        double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
+                       4*x_skew*x_var*sqrt(x_var)*x_mean -
+                       6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937 G;
+        G g;
+        D d(2, 3);
+        P p(.5, 2);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(d.min() <= v);
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+        double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+        double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+                        3*x_mean*x_var - sqr(x_mean)*x_mean) /
+                        (std::sqrt(x_var)*x_var);
+        double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
+                       4*x_skew*x_var*sqrt(x_var)*x_mean -
+                       6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp
new file mode 100644
index 0000000..5047a93
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        P p(.125, .5);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp
new file mode 100644
index 0000000..73b9aed
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+//            const weibull_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+//            weibull_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        D d1(7, 5);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp
new file mode 100644
index 0000000..d3a44b3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        D d(5, .25);
+        D::result_type m = d.max();
+        assert(m == INFINITY);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp
new file mode 100644
index 0000000..fee46ab
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        D d(.5, .5);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp
new file mode 100644
index 0000000..2d978cd
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(.75, 6);
+        param_type p;
+        p = p0;
+        assert(p.a() == .75);
+        assert(p.b() == 6);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp
new file mode 100644
index 0000000..815a2c7
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p0(10, .125);
+        param_type p = p0;
+        assert(p.a() == 10);
+        assert(p.b() == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp
new file mode 100644
index 0000000..3f9e29f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.a() == 1);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10);
+        assert(p.a() == 10);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p(10, 5);
+        assert(p.a() == 10);
+        assert(p.b() == 5);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp
new file mode 100644
index 0000000..b94e6c1
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.75, .5);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        param_type p1(0.75, .5);
+        param_type p2(0.5, .5);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp
new file mode 100644
index 0000000..102f68d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp
new file mode 100644
index 0000000..b200e43
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::param_type P;
+        P p(0.25, 5.5);
+        D d(0.75, 4);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp
new file mode 100644
index 0000000..6f82c70
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// public:
+//     // types
+//     typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::weibull_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::weibull_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp
new file mode 100644
index 0000000..aee3f74
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution& operator=(const discrete_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::discrete_distribution<> D;
+    double p[] = {2, 4, 1, 8};
+    D d1(p, p+4);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp
new file mode 100644
index 0000000..b133ac7
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution(const discrete_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::discrete_distribution<> D;
+    double p[] = {2, 4, 1, 8};
+    D d1(p, p+4);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp
new file mode 100644
index 0000000..3c1ed6a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        D d;
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp
new file mode 100644
index 0000000..34af693
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class UnaryOperation>
+//     discrete_distribution(size_t nw, double xmin, double xmax,
+//                           UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+    return x+1;
+}
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        D d(0, 0, 1, fw);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d(1, 0, 1, fw);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d(2, 0.5, 1.5, fw);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == .4375);
+        assert(p[1] == .5625);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d(4, 0, 2, fw);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 4);
+        assert(p[0] == .15625);
+        assert(p[1] == .21875);
+        assert(p[2] == .28125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp
new file mode 100644
index 0000000..bc4494b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::discrete_distribution<> D;
+        D d = {};
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d = {10};
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d = {10, 30};
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.25);
+        assert(p[1] == 0.75);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d = {30, 10};
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d = {30, 0, 10};
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d = {0, 30, 10};
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0.75);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        D d = {0, 0, 10};
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0);
+        assert(p[2] == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp
new file mode 100644
index 0000000..65e14ee
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class InputIterator>
+//     discrete_distribution(InputIterator firstW, InputIterator lastW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {1};
+        D d(p0, p0);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {10};
+        D d(p0, p0+1);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {10, 30};
+        D d(p0, p0+2);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.25);
+        assert(p[1] == 0.75);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {30, 10};
+        D d(p0, p0+2);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {30, 0, 10};
+        D d(p0, p0+3);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {0, 30, 10};
+        D d(p0, p0+3);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0.75);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {0, 0, 10};
+        D d(p0, p0+3);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0);
+        assert(p[2] == 1);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp
new file mode 100644
index 0000000..c12fe45
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// explicit discrete_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {10, 30};
+        P pa(p0, p0+2);
+        D d(pa);
+        std::vector<double> p = d.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.25);
+        assert(p[1] == 0.75);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp
new file mode 100644
index 0000000..bad0698
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// bool operator=(const discrete_distribution& x,
+//                const discrete_distribution& y);
+// bool operator!(const discrete_distribution& x,
+//                const discrete_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        D d1;
+        D d2;
+        assert(d1 == d2);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {1};
+        D d1(p0, p0+1);
+        D d2;
+        assert(d1 == d2);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {10, 30};
+        D d1(p0, p0+2);
+        D d2;
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp
new file mode 100644
index 0000000..ac9a18d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp
@@ -0,0 +1,277 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d;
+        const int N = 100;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            assert((double)u[i]/N == prob[i]);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {.3};
+        D d(p0, p0+1);
+        const int N = 100;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            assert((double)u[i]/N == prob[i]);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {.75, .25};
+        D d(p0, p0+2);
+        const int N = 1000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {0, 1};
+        D d(p0, p0+2);
+        const int N = 1000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        assert((double)u[0]/N == prob[0]);
+        assert((double)u[1]/N == prob[1]);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {1, 0};
+        D d(p0, p0+2);
+        const int N = 1000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        assert((double)u[0]/N == prob[0]);
+        assert((double)u[1]/N == prob[1]);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {.3, .1, .6};
+        D d(p0, p0+3);
+        const int N = 10000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {0, 25, 75};
+        D d(p0, p0+3);
+        const int N = 1000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            if (prob[i] != 0)
+                assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+            else
+                assert(u[i] == 0);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {25, 0, 75};
+        D d(p0, p0+3);
+        const int N = 1000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            if (prob[i] != 0)
+                assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+            else
+                assert(u[i] == 0);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {25, 75, 0};
+        D d(p0, p0+3);
+        const int N = 1000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            if (prob[i] != 0)
+                assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+            else
+                assert(u[i] == 0);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {0, 0, 1};
+        D d(p0, p0+3);
+        const int N = 100;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            if (prob[i] != 0)
+                assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+            else
+                assert(u[i] == 0);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {0, 1, 0};
+        D d(p0, p0+3);
+        const int N = 100;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            if (prob[i] != 0)
+                assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+            else
+                assert(u[i] == 0);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {1, 0, 0};
+        D d(p0, p0+3);
+        const int N = 100;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            if (prob[i] != 0)
+                assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+            else
+                assert(u[i] == 0);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        double p0[] = {33, 0, 0, 67};
+        D d(p0, p0+3);
+        const int N = 1000000;
+        std::vector<D::result_type> u(d.max()+1);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v <= d.max());
+            u[v]++;
+        }
+        std::vector<double> prob = d.probabilities();
+        for (int i = 0; i <= d.max(); ++i)
+            if (prob[i] != 0)
+                assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+            else
+                assert(u[i] == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp
new file mode 100644
index 0000000..4f18ad9
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        typedef std::minstd_rand G;
+        G g;
+        D d;
+        double p0[] = {.3, .1, .6};
+        P p(p0, p0+3);
+        const int N = 10000000;
+        std::vector<D::result_type> u(3);
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(0 <= v && v <= 2);
+            u[v]++;
+        }
+        std::vector<double> prob = p.probabilities();
+        for (int i = 0; i <= 2; ++i)
+            assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp
new file mode 100644
index 0000000..4970c5a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {.3, .1, .6};
+        P p(p0, p0+3);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp
new file mode 100644
index 0000000..9249950
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const discrete_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            discrete_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {.3, .1, .6};
+        D d1(p0, p0+3);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp
new file mode 100644
index 0000000..b1d1acd
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {.3, .1, .6};
+        D d(p0, p0+3);
+        assert(d.max() == 2);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {.3, .1, .6, .2};
+        D d(p0, p0+4);
+        assert(d.max() == 3);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp
new file mode 100644
index 0000000..ab93832
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        double p0[] = {.3, .1, .6};
+        D d(p0, p0+3);
+        assert(d.min() == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp
new file mode 100644
index 0000000..ea57852
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type param_type;
+        double d0[] = {.3, .1, .6};
+        param_type p0(d0, d0+3);
+        param_type p;
+        p = p0;
+        assert(p == p0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp
new file mode 100644
index 0000000..b65ebb0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type param_type;
+        double d0[] = {.3, .1, .6};
+        param_type p0(d0, d0+3);
+        param_type p = p0;
+        assert(p == p0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp
new file mode 100644
index 0000000..1071305
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {1};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp
new file mode 100644
index 0000000..6d43b22
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class UnaryOperation>
+//     param_type(size_t nw, double xmin, double xmax,
+//                           UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+    return x+1;
+}
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa(0, 0, 1, fw);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa(1, 0, 1, fw);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa(2, 0.5, 1.5, fw);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == .4375);
+        assert(p[1] == .5625);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa(4, 0, 2, fw);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 4);
+        assert(p[0] == .15625);
+        assert(p[1] == .21875);
+        assert(p[2] == .28125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp
new file mode 100644
index 0000000..79d8a0b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {10};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {10, 30};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.25);
+        assert(p[1] == 0.75);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {30, 10};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {30, 0, 10};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {0, 30, 10};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0.75);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        P pa = {0, 0, 10};
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0);
+        assert(p[2] == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp
new file mode 100644
index 0000000..7ef6467
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class InputIterator>
+//     param_type(InputIterator firstW, InputIterator lastW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {1};
+        P pa(p0, p0);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {10};
+        P pa(p0, p0+1);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 1);
+        assert(p[0] == 1);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {10, 30};
+        P pa(p0, p0+2);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.25);
+        assert(p[1] == 0.75);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {30, 10};
+        P pa(p0, p0+2);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 2);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {30, 0, 10};
+        P pa(p0, p0+3);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0.75);
+        assert(p[1] == 0);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {0, 30, 10};
+        P pa(p0, p0+3);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0.75);
+        assert(p[2] == 0.25);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double p0[] = {0, 0, 10};
+        P pa(p0, p0+3);
+        std::vector<double> p = pa.probabilities();
+        assert(p.size() == 3);
+        assert(p[0] == 0);
+        assert(p[1] == 0);
+        assert(p[2] == 1);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp
new file mode 100644
index 0000000..6ec2c2a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type param_type;
+        double p0[] = {30, 10};
+        param_type p1(p0, p0+2);
+        param_type p2(p0, p0+2);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type param_type;
+        double p0[] = {30, 10};
+        param_type p1(p0, p0+2);
+        param_type p2;
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp
new file mode 100644
index 0000000..086b760
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp
new file mode 100644
index 0000000..bc433ec
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::param_type P;
+        double d0[] = {.3, .1, .6};
+        P p(d0, d0+3);
+        D d;
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp
new file mode 100644
index 0000000..af73008
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::discrete_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, int>::value), "");
+    }
+    {
+        typedef std::discrete_distribution<long> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, long>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp
new file mode 100644
index 0000000..e5c9944
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution& operator=(const piecewise_constant_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::piecewise_constant_distribution<> D;
+    double p[] = {2, 4, 1, 8};
+    double b[] = {2, 4, 5, 8, 9};
+    D d1(b, b+5, p);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp
new file mode 100644
index 0000000..a3eb1f4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution(const piecewise_constant_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::piecewise_constant_distribution<> D;
+    double p[] = {2, 4, 1, 8};
+    double b[] = {2, 4, 5, 8, 9};
+    D d1(b, b+5, p);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp
new file mode 100644
index 0000000..d4f339f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d;
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp
new file mode 100644
index 0000000..74fa234
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class UnaryOperation>
+//     piecewise_constant_distribution(size_t nw, result_type xmin,
+//                                     result_type xmax, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+    return 2*x;
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d(0, 0, 1, fw);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d(1, 10, 12, fw);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 12);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 0.5);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d(2, 6, 14, fw);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 6);
+        assert(iv[1] == 10);
+        assert(iv[2] == 14);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 0.1);
+        assert(dn[1] == 0.15);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp
new file mode 100644
index 0000000..5708e45
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution(initializer_list<result_type> bl,
+//                                 UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+    return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d({}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d({12}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d({12, 14}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 12);
+        assert(iv[1] == 14);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 0.5);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d({5.5, 7.5, 11.5}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 5.5);
+        assert(iv[1] == 7.5);
+        assert(iv[2] == 11.5);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 0.203125);
+        assert(dn[1] == 0.1484375);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp
new file mode 100644
index 0000000..d994b0a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class InputIterator>
+//     piecewise_constant_distribution(InputIteratorB firstB,
+//                                     InputIteratorB lastB,
+//                                     InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10};
+        double p[] = {12};
+        D d(b, b, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10};
+        double p[] = {12};
+        D d(b, b+1, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 15};
+        double p[] = {12};
+        D d(b, b+2, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1/5.);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 15, 16};
+        double p[] = {.25, .75};
+        D d(b, b+3, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        assert(iv[2] == 16);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == .25/5.);
+        assert(dn[1] == .75);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        D d(b, b+4, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 4);
+        assert(iv[0] == 10);
+        assert(iv[1] == 14);
+        assert(iv[2] == 16);
+        assert(iv[3] == 17);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == .0625);
+        assert(dn[1] == .3125);
+        assert(dn[2] == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp
new file mode 100644
index 0000000..0ccdba6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// explicit piecewise_constant_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        P pa(b, b+4, p);
+        D d(pa);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 4);
+        assert(iv[0] == 10);
+        assert(iv[1] == 14);
+        assert(iv[2] == 16);
+        assert(iv[3] == 17);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == .0625);
+        assert(dn[1] == .3125);
+        assert(dn[2] == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp
new file mode 100644
index 0000000..2ef9d7b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// bool operator=(const piecewise_constant_distribution& x,
+//                const piecewise_constant_distribution& y);
+// bool operator!(const piecewise_constant_distribution& x,
+//                const piecewise_constant_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        D d1;
+        D d2;
+        assert(d1 == d2);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        D d1(b, b+4, p);
+        D d2(b, b+4, p);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        D d1(b, b+4, p);
+        D d2;
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
new file mode 100644
index 0000000..5e419f4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
@@ -0,0 +1,693 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x*x;
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {0, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 0, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 0, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {0, 25, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {0, 0, 1};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16};
+        double p[] = {75, 25};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16};
+        double p[] = {0, 25};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16};
+        double p[] = {1, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14};
+        double p[] = {1};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp
new file mode 100644
index 0000000..904e116
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x*x;
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d;
+        P pa(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, pa);
+            assert(10 <= v && v < 17);
+            u.push_back(v);
+        }
+        std::vector<double> prob(std::begin(p), std::end(p));
+        double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+        for (int i = 0; i < prob.size(); ++i)
+            prob[i] /= s;
+        std::sort(u.begin(), u.end());
+        for (int i = 0; i < Np; ++i)
+        {
+            typedef std::vector<D::result_type>::iterator I;
+            I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+            I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+            const size_t Ni = ub - lb;
+            if (prob[i] == 0)
+                assert(Ni == 0);
+            else
+            {
+                assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+                double mean = std::accumulate(lb, ub, 0.0) / Ni;
+                double var = 0;
+                double skew = 0;
+                double kurtosis = 0;
+                for (I j = lb; j != ub; ++j)
+                {
+                    double d = (*j - mean);
+                    double d2 = sqr(d);
+                    var += d2;
+                    skew += d * d2;
+                    kurtosis += d2 * d2;
+                }
+                var /= Ni;
+                double dev = std::sqrt(var);
+                skew /= Ni * dev * var;
+                kurtosis /= Ni * var * var;
+                kurtosis -= 3;
+                double x_mean = (b[i+1] + b[i]) / 2;
+                double x_var = sqr(b[i+1] - b[i]) / 12;
+                double x_skew = 0;
+                double x_kurtosis = -6./5;
+                assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+                assert(std::abs((var - x_var) / x_var) < 0.01);
+                assert(std::abs(skew - x_skew) < 0.01);
+                assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+            }
+        }
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp
new file mode 100644
index 0000000..fdda4e8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        P pa(b, b+Np+1, p);
+        D d(pa);
+        assert(d.param() == pa);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp
new file mode 100644
index 0000000..9af776d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const piecewise_constant_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            piecewise_constant_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d1(b, b+Np+1, p);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp
new file mode 100644
index 0000000..772c36e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        assert(d.max() == 17);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp
new file mode 100644
index 0000000..66618ba
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np+1, p);
+        assert(d.min() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp
new file mode 100644
index 0000000..4d3a503
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        P p0(b, b+Np+1, p);
+        P p1;
+        p1 = p0;
+        assert(p1 == p0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp
new file mode 100644
index 0000000..de63a54e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        P p0(b, b+Np+1, p);
+        P p1 = p0;
+        assert(p1 == p0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp
new file mode 100644
index 0000000..fd84d46
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa;
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp
new file mode 100644
index 0000000..98e3006
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class UnaryOperation>
+//     param_type(size_t nw, double xmin, double xmax,
+//                           UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+    return 2*x;
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa(0, 0, 1, fw);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa(1, 10, 12, fw);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 12);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 0.5);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa(2, 6, 14, fw);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 6);
+        assert(iv[1] == 10);
+        assert(iv[2] == 14);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 0.1);
+        assert(dn[1] == 0.15);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp
new file mode 100644
index 0000000..fa65309
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// param_type(initializer_list<result_type> bl, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+    return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa({}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa({12}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa({12, 14}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 12);
+        assert(iv[1] == 14);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 0.5);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        P pa({5.5, 7.5, 11.5}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 5.5);
+        assert(iv[1] == 7.5);
+        assert(iv[2] == 11.5);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 0.203125);
+        assert(dn[1] == 0.1484375);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp
new file mode 100644
index 0000000..98d467c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// template<class InputIterator>
+//     param_type(InputIteratorB firstB, InputIteratorB lastB,
+//                InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10};
+        double p[] = {12};
+        P pa(b, b, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10};
+        double p[] = {12};
+        P pa(b, b+1, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 15};
+        double p[] = {12};
+        P pa(b, b+2, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 1);
+        assert(dn[0] == 1/5.);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 15, 16};
+        double p[] = {.25, .75};
+        P pa(b, b+3, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        assert(iv[2] == 16);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == .25/5.);
+        assert(dn[1] == .75);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        P pa(b, b+4, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 4);
+        assert(iv[0] == 10);
+        assert(iv[1] == 14);
+        assert(iv[2] == 16);
+        assert(iv[3] == 17);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == .0625);
+        assert(dn[1] == .3125);
+        assert(dn[2] == .125);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp
new file mode 100644
index 0000000..9cc554e
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        P p1(b, b+4, p);
+        P p2(b, b+4, p);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        P p1(b, b+3, p);
+        P p2(b, b+4, p);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp
new file mode 100644
index 0000000..e039df3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp
new file mode 100644
index 0000000..1a3fedb
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5};
+        P pa(b, b+4, p);
+        D d;
+        d.param(pa);
+        assert(d.param() == pa);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp
new file mode 100644
index 0000000..7603259
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_constant_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::piecewise_constant_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::piecewise_constant_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp
new file mode 100644
index 0000000..0ba7dcb
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/assign.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution& operator=(const piecewise_linear_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::piecewise_linear_distribution<> D;
+    double p[] = {2, 4, 1, 8, 3};
+    double b[] = {2, 4, 5, 8, 9};
+    D d1(b, b+5, p);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp
new file mode 100644
index 0000000..536b139
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/copy.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(const piecewise_linear_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::piecewise_linear_distribution<> D;
+    double p[] = {2, 4, 1, 8, 2};
+    double b[] = {2, 4, 5, 8, 9};
+    D d1(b, b+5, p);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp
new file mode 100644
index 0000000..745bd6b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d;
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp
new file mode 100644
index 0000000..3ebaf77
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_func.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class UnaryOperation>
+//     piecewise_linear_distribution(size_t nw, result_type xmin,
+//                                     result_type xmax, UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+    return 2*x;
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d(0, 0, 1, fw);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 0);
+        assert(dn[1] == 2);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d(1, 10, 12, fw);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 12);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 20./44);
+        assert(dn[1] == 24./44);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d(2, 6, 14, fw);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 6);
+        assert(iv[1] == 10);
+        assert(iv[2] == 14);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == 0.075);
+        assert(dn[1] == 0.125);
+        assert(dn[2] == 0.175);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp
new file mode 100644
index 0000000..44c76f0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_init_func.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// piecewise_linear_distribution(initializer_list<result_type> bl,
+//                                 UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+    return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d({}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d({12}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d({10, 12}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 12);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 20./44);
+        assert(dn[1] == 24./44);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d({6, 10, 14}, f);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 6);
+        assert(iv[1] == 10);
+        assert(iv[2] == 14);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == 0.075);
+        assert(dn[1] == 0.125);
+        assert(dn[2] == 0.175);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp
new file mode 100644
index 0000000..5fce58b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_iterator.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class InputIterator>
+//     piecewise_linear_distribution(InputIteratorB firstB,
+//                                     InputIteratorB lastB,
+//                                     InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10};
+        double p[] = {12};
+        D d(b, b, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10};
+        double p[] = {12};
+        D d(b, b+1, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 15};
+        double p[] = {20, 20};
+        D d(b, b+2, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1/5.);
+        assert(dn[1] == 1/5.);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 15, 16};
+        double p[] = {.25, .75, .25};
+        D d(b, b+3, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        assert(iv[2] == 16);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == .25/3);
+        assert(dn[1] == .75/3);
+        assert(dn[2] == .25/3);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {0, 1, 1, 0};
+        D d(b, b+4, p);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 4);
+        assert(iv[0] == 10);
+        assert(iv[1] == 14);
+        assert(iv[2] == 16);
+        assert(iv[3] == 17);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 4);
+        assert(dn[0] == 0);
+        assert(dn[1] == 1/4.5);
+        assert(dn[2] == 1/4.5);
+        assert(dn[3] == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp
new file mode 100644
index 0000000..7dc47b4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/ctor_param.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// explicit piecewise_linear_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        P pa(b, b+4, p);
+        D d(pa);
+        std::vector<double> iv = d.intervals();
+        assert(iv.size() == 4);
+        assert(iv[0] == 10);
+        assert(iv[1] == 14);
+        assert(iv[2] == 16);
+        assert(iv[3] == 17);
+        std::vector<double> dn = d.densities();
+        assert(dn.size() == 4);
+        assert(dn[0] == 25/256.25);
+        assert(dn[1] == 62.5/256.25);
+        assert(dn[2] == 12.5/256.25);
+        assert(dn[3] == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp
new file mode 100644
index 0000000..766989c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eq.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// bool operator=(const piecewise_linear_distribution& x,
+//                const piecewise_linear_distribution& y);
+// bool operator!(const piecewise_linear_distribution& x,
+//                const piecewise_linear_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        D d1;
+        D d2;
+        assert(d1 == d2);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 1};
+        D d1(b, b+4, p);
+        D d2(b, b+4, p);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        D d1(b, b+4, p);
+        D d2;
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
new file mode 100644
index 0000000..b50e4cb
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval.pass.cpp
@@ -0,0 +1,341 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <iostream>
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x*x;
+}
+
+double
+f(double x, double a, double m, double b, double c)
+{
+    return a + m*(sqr(x) - sqr(b))/2 + c*(x-b);
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {0, 1, 1, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        int kp = -1;
+        double a;
+        double m;
+        double bk;
+        double c;
+        std::vector<double> areas(Np);
+        double S = 0;
+        for (int i = 0; i < areas.size(); ++i)
+        {
+            areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+            S += areas[i];
+        }
+        for (int i = 0; i < areas.size(); ++i)
+            areas[i] /= S;
+        for (int i = 0; i < Np+1; ++i)
+            p[i] /= S;
+        for (int i = 0; i < N; ++i)
+        {
+            int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+            if (k != kp)
+            {
+                a = 0;
+                for (int j = 0; j < k; ++j)
+                    a += areas[j];
+                m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+                bk = b[k];
+                c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+                kp = k;
+            }
+            assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+        }
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {0, 0, 1, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        int kp = -1;
+        double a;
+        double m;
+        double bk;
+        double c;
+        std::vector<double> areas(Np);
+        double S = 0;
+        for (int i = 0; i < areas.size(); ++i)
+        {
+            areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+            S += areas[i];
+        }
+        for (int i = 0; i < areas.size(); ++i)
+            areas[i] /= S;
+        for (int i = 0; i < Np+1; ++i)
+            p[i] /= S;
+        for (int i = 0; i < N; ++i)
+        {
+            int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+            if (k != kp)
+            {
+                a = 0;
+                for (int j = 0; j < k; ++j)
+                    a += areas[j];
+                m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+                bk = b[k];
+                c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+                kp = k;
+            }
+            assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+        }
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {1, 0, 0, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        int kp = -1;
+        double a;
+        double m;
+        double bk;
+        double c;
+        std::vector<double> areas(Np);
+        double S = 0;
+        for (int i = 0; i < areas.size(); ++i)
+        {
+            areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+            S += areas[i];
+        }
+        for (int i = 0; i < areas.size(); ++i)
+            areas[i] /= S;
+        for (int i = 0; i < Np+1; ++i)
+            p[i] /= S;
+        for (int i = 0; i < N; ++i)
+        {
+            int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+            if (k != kp)
+            {
+                a = 0;
+                for (int j = 0; j < k; ++j)
+                    a += areas[j];
+                m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+                bk = b[k];
+                c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+                kp = k;
+            }
+            assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+        }
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16};
+        double p[] = {0, 1, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        int kp = -1;
+        double a;
+        double m;
+        double bk;
+        double c;
+        std::vector<double> areas(Np);
+        double S = 0;
+        for (int i = 0; i < areas.size(); ++i)
+        {
+            areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+            S += areas[i];
+        }
+        for (int i = 0; i < areas.size(); ++i)
+            areas[i] /= S;
+        for (int i = 0; i < Np+1; ++i)
+            p[i] /= S;
+        for (int i = 0; i < N; ++i)
+        {
+            int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+            if (k != kp)
+            {
+                a = 0;
+                for (int j = 0; j < k; ++j)
+                    a += areas[j];
+                m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+                bk = b[k];
+                c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+                kp = k;
+            }
+            assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+        }
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14};
+        double p[] = {1, 1};
+        const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        int kp = -1;
+        double a;
+        double m;
+        double bk;
+        double c;
+        std::vector<double> areas(Np);
+        double S = 0;
+        for (int i = 0; i < areas.size(); ++i)
+        {
+            areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+            S += areas[i];
+        }
+        for (int i = 0; i < areas.size(); ++i)
+            areas[i] /= S;
+        for (int i = 0; i < Np+1; ++i)
+            p[i] /= S;
+        for (int i = 0; i < N; ++i)
+        {
+            int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+            if (k != kp)
+            {
+                a = 0;
+                for (int j = 0; j < k; ++j)
+                    a += areas[j];
+                m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+                bk = b[k];
+                c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+                kp = k;
+            }
+            assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+        }
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+        D d(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.min() <= v && v < d.max());
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        int kp = -1;
+        double a;
+        double m;
+        double bk;
+        double c;
+        std::vector<double> areas(Np);
+        double S = 0;
+        for (int i = 0; i < areas.size(); ++i)
+        {
+            areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+            S += areas[i];
+        }
+        for (int i = 0; i < areas.size(); ++i)
+            areas[i] /= S;
+        for (int i = 0; i < Np+1; ++i)
+            p[i] /= S;
+        for (int i = 0; i < N; ++i)
+        {
+            int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+            if (k != kp)
+            {
+                a = 0;
+                for (int j = 0; j < k; ++j)
+                    a += areas[j];
+                m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+                bk = b[k];
+                c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+                kp = k;
+            }
+            assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+        }
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
new file mode 100644
index 0000000..a8b4950
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/eval_param.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x*x;
+}
+
+double
+f(double x, double a, double m, double b, double c)
+{
+    return a + m*(sqr(x) - sqr(b))/2 + c*(x-b);
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        typedef std::mt19937_64 G;
+        G g;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]) - 1;
+        D d;
+        P pa(b, b+Np+1, p);
+        const int N = 1000000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, pa);
+            assert(10 <= v && v < 17);
+            u.push_back(v);
+        }
+        std::sort(u.begin(), u.end());
+        int kp = -1;
+        double a;
+        double m;
+        double bk;
+        double c;
+        std::vector<double> areas(Np);
+        double S = 0;
+        for (int i = 0; i < areas.size(); ++i)
+        {
+            areas[i] = (p[i]+p[i+1])*(b[i+1]-b[i])/2;
+            S += areas[i];
+        }
+        for (int i = 0; i < areas.size(); ++i)
+            areas[i] /= S;
+        for (int i = 0; i < Np+1; ++i)
+            p[i] /= S;
+        for (int i = 0; i < N; ++i)
+        {
+            int k = std::lower_bound(b, b+Np+1, u[i]) - b - 1;
+            if (k != kp)
+            {
+                a = 0;
+                for (int j = 0; j < k; ++j)
+                    a += areas[j];
+                m = (p[k+1] - p[k]) / (b[k+1] - b[k]);
+                bk = b[k];
+                c = (b[k+1]*p[k] - b[k]*p[k+1]) / (b[k+1] - b[k]);
+                kp = k;
+            }
+            assert(std::abs(f(u[i], a, m, bk, c) - double(i)/N) < .001);
+        }
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp
new file mode 100644
index 0000000..57a8ca5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/get_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 10};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        P pa(b, b+Np, p);
+        D d(pa);
+        assert(d.param() == pa);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp
new file mode 100644
index 0000000..1be2791
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/io.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const piecewise_linear_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            piecewise_linear_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 25};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d1(b, b+Np, p);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp
new file mode 100644
index 0000000..3dc12b6
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/max.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np, p);
+        assert(d.max() == 17);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp
new file mode 100644
index 0000000..4d4a760
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/min.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        D d(b, b+Np, p);
+        assert(d.min() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp
new file mode 100644
index 0000000..055b2f5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 2};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        P p0(b, b+Np, p);
+        P p1;
+        p1 = p0;
+        assert(p1 == p0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp
new file mode 100644
index 0000000..87d9494
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_copy.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 5};
+        const size_t Np = sizeof(p) / sizeof(p[0]);
+        P p0(b, b+Np, p);
+        P p1 = p0;
+        assert(p1 == p0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp
new file mode 100644
index 0000000..0bdf2c3
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa;
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp
new file mode 100644
index 0000000..27e93ab
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_func.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class UnaryOperation>
+//     param_type(size_t nw, double xmin, double xmax,
+//                           UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+    return 2*x;
+}
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa(0, 0, 1, fw);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 0);
+        assert(dn[1] == 2);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa(1, 10, 12, fw);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 12);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 20./44);
+        assert(dn[1] == 24./44);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa(2, 6, 14, fw);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 6);
+        assert(iv[1] == 10);
+        assert(iv[2] == 14);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == 0.075);
+        assert(dn[1] == 0.125);
+        assert(dn[2] == 0.175);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp
new file mode 100644
index 0000000..cfa4164
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_init_func.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// param_type(initializer_list<result_type> bl, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+    return x*2;
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa({}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa({12}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa({10, 12}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 12);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 20./44);
+        assert(dn[1] == 24./44);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        P pa({6, 10, 14}, f);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 6);
+        assert(iv[1] == 10);
+        assert(iv[2] == 14);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == 0.075);
+        assert(dn[1] == 0.125);
+        assert(dn[2] == 0.175);
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp
new file mode 100644
index 0000000..117a5ef
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_ctor_iterator.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// template<class InputIterator>
+//     param_type(InputIteratorB firstB, InputIteratorB lastB,
+//                InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10};
+        double p[] = {12};
+        P pa(b, b, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10};
+        double p[] = {12};
+        P pa(b, b+1, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 0);
+        assert(iv[1] == 1);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1);
+        assert(dn[1] == 1);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 15};
+        double p[] = {12, 12};
+        P pa(b, b+2, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 2);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 2);
+        assert(dn[0] == 1/5.);
+        assert(dn[1] == 1/5.);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 15, 16};
+        double p[] = {.25, .75, .25};
+        P pa(b, b+3, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 3);
+        assert(iv[0] == 10);
+        assert(iv[1] == 15);
+        assert(iv[2] == 16);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 3);
+        assert(dn[0] == .25/3);
+        assert(dn[1] == .75/3);
+        assert(dn[2] == .25/3);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {0, 1, 1, 0};
+        P pa(b, b+4, p);
+        std::vector<double> iv = pa.intervals();
+        assert(iv.size() == 4);
+        assert(iv[0] == 10);
+        assert(iv[1] == 14);
+        assert(iv[2] == 16);
+        assert(iv[3] == 17);
+        std::vector<double> dn = pa.densities();
+        assert(dn.size() == 4);
+        assert(dn[0] == 0);
+        assert(dn[1] == 1/4.5);
+        assert(dn[2] == 1/4.5);
+        assert(dn[3] == 0);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp
new file mode 100644
index 0000000..1adffc8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_eq.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        P p1(b, b+4, p);
+        P p2(b, b+4, p);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        P p1(b, b+3, p);
+        P p2(b, b+4, p);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp
new file mode 100644
index 0000000..cea1e3d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp
new file mode 100644
index 0000000..e85a2f0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/set_param.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::param_type P;
+        double b[] = {10, 14, 16, 17};
+        double p[] = {25, 62.5, 12.5, 0};
+        P pa(b, b+4, p);
+        D d;
+        d.param(pa);
+        assert(d.param() == pa);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp
new file mode 100644
index 0000000..a342129
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.plinear/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class piecewise_linear_distribution
+// {
+//     typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::piecewise_linear_distribution<> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, double>::value), "");
+    }
+    {
+        typedef std::piecewise_linear_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp
new file mode 100644
index 0000000..0e04ea4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// uniform_int_distribution& operator=(const uniform_int_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_int_distribution<long> D;
+    D d1(2, 5);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp
new file mode 100644
index 0000000..c09830c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// uniform_int_distribution(const uniform_int_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_int_distribution<long> D;
+    D d1(2, 5);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp
new file mode 100644
index 0000000..68f2ec0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// explicit uniform_int_distribution(IntType a = 0,
+//                                   IntType b = numeric_limits<IntType>::max());
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d;
+        assert(d.a() == 0);
+        assert(d.b() == std::numeric_limits<int>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(-6);
+        assert(d.a() == -6);
+        assert(d.b() == std::numeric_limits<int>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(-6, 106);
+        assert(d.a() == -6);
+        assert(d.b() == 106);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp
new file mode 100644
index 0000000..cc3e86a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// explicit uniform_int_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(p);
+        assert(d.a() == 3);
+        assert(d.b() == 8);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp
new file mode 100644
index 0000000..b7a5cff
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// bool operator=(const uniform_int_distribution& x,
+//                const uniform_int_distribution& y);
+// bool operator!(const uniform_int_distribution& x,
+//                const uniform_int_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 8);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 9);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
new file mode 100644
index 0000000..a4f1feb
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
@@ -0,0 +1,453 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::ranlux24_base G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::ranlux48_base G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::ranlux24 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::ranlux48 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::knuth_b G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d(-6, 106);
+        for (int i = 0; i < 10000; ++i)
+        {
+            int u = d(g);
+            assert(-6 <= u && u <= 106);
+        }
+    }
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(5, 100);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v <= d.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)d.a() + d.b()) / 2;
+        double x_var = (sqr((double)d.b() - d.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
+                            (5. * (sqr((double)d.b() - d.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
new file mode 100644
index 0000000..d83d48c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef std::minstd_rand G;
+        typedef D::param_type P;
+        G g;
+        D d(5, 100);
+        P p(-10, 20);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(p.a() <= v && v <= p.b());
+            u.push_back(v);
+        }
+        double mean = std::accumulate(u.begin(), u.end(),
+                                              double(0)) / u.size();
+        double var = 0;
+        double skew = 0;
+        double kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            double d = (u[i] - mean);
+            double d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        double dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        double x_mean = ((double)p.a() + p.b()) / 2;
+        double x_var = (sqr((double)p.b() - p.a() + 1) - 1) / 12;
+        double x_skew = 0;
+        double x_kurtosis = -6. * (sqr((double)p.b() - p.a() + 1) + 1) /
+                            (5. * (sqr((double)p.b() - p.a() + 1) - 1));
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp
new file mode 100644
index 0000000..ab8fa6c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp
new file mode 100644
index 0000000..0220a5a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const uniform_int_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            uniform_int_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d1(3, 8);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp
new file mode 100644
index 0000000..c0a262f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(3, 8);
+        assert(d.max() == 8);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp
new file mode 100644
index 0000000..3a0d3b2
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        D d(3, 8);
+        assert(d.min() == 3);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp
new file mode 100644
index 0000000..09c5609
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p;
+        p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp
new file mode 100644
index 0000000..1f01e98
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp
new file mode 100644
index 0000000..eba933c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.a() == 0);
+        assert(p.b() == std::numeric_limits<long>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p(5);
+        assert(p.a() == 5);
+        assert(p.b() == std::numeric_limits<long>::max());
+    }
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p(5, 10);
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp
new file mode 100644
index 0000000..5831f96
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(5, 10);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(6, 10);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp
new file mode 100644
index 0000000..4022cfb
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp
new file mode 100644
index 0000000..823837b
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(6, 7);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp
new file mode 100644
index 0000000..65c01d0
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class _IntType = int>
+// class uniform_int_distribution
+// {
+//     typedef IntType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_int_distribution<long> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, long>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp
new file mode 100644
index 0000000..9651a2f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// uniform_real_distribution& operator=(const uniform_real_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_real_distribution<float> D;
+    D d1(2, 5);
+    D d2;
+    assert(d1 != d2);
+    d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp
new file mode 100644
index 0000000..073c3a8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// uniform_real_distribution(const uniform_real_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::uniform_real_distribution<float> D;
+    D d1(2, 5);
+    D d2 = d1;
+    assert(d1 == d2);
+}
+
+int main()
+{
+    test1();
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp
new file mode 100644
index 0000000..03abc53
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// explicit uniform_real_distribution(RealType a = 0,
+//                                    RealType b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d;
+        assert(d.a() == 0);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(-6);
+        assert(d.a() == -6);
+        assert(d.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(-6, 106);
+        assert(d.a() == -6);
+        assert(d.b() == 106);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp
new file mode 100644
index 0000000..a6f4aff
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// explicit uniform_real_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef D::param_type P;
+        P p(3.5, 8);
+        D d(p);
+        assert(d.a() == 3.5);
+        assert(d.b() == 8);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp
new file mode 100644
index 0000000..5fcba43
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// bool operator=(const uniform_real_distribution& x,
+//                const uniform_real_distribution& y);
+// bool operator!(const uniform_real_distribution& x,
+//                const uniform_real_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 8);
+        assert(d1 == d2);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d1(3, 8);
+        D d2(3, 8.1);
+        assert(d1 != d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
new file mode 100644
index 0000000..188db2a
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
@@ -0,0 +1,472 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::minstd_rand0 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::mt19937 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::mt19937_64 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::ranlux24_base G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.02);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::ranlux48_base G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::ranlux24 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::ranlux48 G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::knuth_b G;
+        G g;
+        D d;
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(-1, 1);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs(mean - x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::minstd_rand G;
+        G g;
+        D d(5.5, 25);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g);
+            assert(d.a() <= v && v < d.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (d.a() + d.b()) / 2;
+        D::result_type x_var = sqr(d.b() - d.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
new file mode 100644
index 0000000..b5803f4
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+    return x * x;
+}
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef std::minstd_rand G;
+        typedef D::param_type P;
+        G g;
+        D d(5.5, 25);
+        P p(-10, 20);
+        const int N = 100000;
+        std::vector<D::result_type> u;
+        for (int i = 0; i < N; ++i)
+        {
+            D::result_type v = d(g, p);
+            assert(p.a() <= v && v < p.b());
+            u.push_back(v);
+        }
+        D::result_type mean = std::accumulate(u.begin(), u.end(),
+                                              D::result_type(0)) / u.size();
+        D::result_type var = 0;
+        D::result_type skew = 0;
+        D::result_type kurtosis = 0;
+        for (int i = 0; i < u.size(); ++i)
+        {
+            D::result_type d = (u[i] - mean);
+            D::result_type d2 = sqr(d);
+            var += d2;
+            skew += d * d2;
+            kurtosis += d2 * d2;
+        }
+        var /= u.size();
+        D::result_type dev = std::sqrt(var);
+        skew /= u.size() * dev * var;
+        kurtosis /= u.size() * var * var;
+        kurtosis -= 3;
+        D::result_type x_mean = (p.a() + p.b()) / 2;
+        D::result_type x_var = sqr(p.b() - p.a()) / 12;
+        D::result_type x_skew = 0;
+        D::result_type x_kurtosis = -6./5;
+        assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+        assert(std::abs((var - x_var) / x_var) < 0.01);
+        assert(std::abs(skew - x_skew) < 0.01);
+        assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp
new file mode 100644
index 0000000..0496d85
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp
new file mode 100644
index 0000000..17ff938
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const uniform_real_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            uniform_real_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d1(3, 8);
+        std::ostringstream os;
+        os << d1;
+        std::istringstream is(os.str());
+        D d2;
+        is >> d2;
+        assert(d1 == d2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp
new file mode 100644
index 0000000..6baa6d8
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/max.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(3, 8);
+        assert(d.max() == 8);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp
new file mode 100644
index 0000000..3974258
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        D d(3, 8);
+        assert(d.min() == 3);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp
new file mode 100644
index 0000000..07497fe
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p;
+        p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp
new file mode 100644
index 0000000..d64df7d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p0(5, 10);
+        param_type p = p0;
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp
new file mode 100644
index 0000000..8f21ebf
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p;
+        assert(p.a() == 0);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p(5);
+        assert(p.a() == 5);
+        assert(p.b() == 1);
+    }
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p(5, 10);
+        assert(p.a() == 5);
+        assert(p.b() == 10);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp
new file mode 100644
index 0000000..62df68c
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(5, 10);
+        assert(p1 == p2);
+    }
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        param_type p1(5, 10);
+        param_type p2(6, 10);
+        assert(p1 != p2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp
new file mode 100644
index 0000000..27c0998
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::param_type param_type;
+        typedef param_type::distribution_type distribution_type;
+        static_assert((std::is_same<D, distribution_type>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp
new file mode 100644
index 0000000..1ff121d
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<> D;
+        typedef D::param_type P;
+        P p(3, 8);
+        D d(6, 7);
+        d.param(p);
+        assert(d.param() == p);
+    }
+}
diff --git a/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp
new file mode 100644
index 0000000..b0e792f
--- /dev/null
+++ b/final/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class uniform_real_distribution
+// {
+//     typedef IntType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    {
+        typedef std::uniform_real_distribution<float> D;
+        typedef D::result_type result_type;
+        static_assert((std::is_same<result_type, float>::value), "");
+    }
+}
diff --git a/final/test/numerics/rand/rand.eng/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.eng/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
new file mode 100644
index 0000000..8c09f4f
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// linear_congruential_engine& operator=(const linear_congruential_engine&);
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> E;
+    E e1;
+    E e2;
+    assert(e1 == e2);
+    e1();
+    e2 = e1;
+    assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
new file mode 100644
index 0000000..4b2b20d
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/copy.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// linear_congruential_engine(const linear_congruential_engine&);
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> E;
+    E e1;
+    E e2 = e1;
+    assert(e1 == e2);
+    e1();
+    e2();
+    assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..311b7cd
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// explicit linear_congruential_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+template <class T>
+void
+test1()
+{
+    // c % m != 0 && s % m != 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "5");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 0> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "5");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 4> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+}
+
+template <class T>
+void
+test2()
+{
+    // c % m != 0 && s % m == 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+        E e(7);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "0");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 0> E;
+        E e(0);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "0");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 4> E;
+        E e(4);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "0");
+    }
+}
+
+template <class T>
+void
+test3()
+{
+    // c % m == 0 && s % m != 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 7> E;
+        E e(3);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "3");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 0> E;
+        E e(5);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "5");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 4> E;
+        E e(7);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "3");
+    }
+}
+
+template <class T>
+void
+test4()
+{
+    // c % m == 0 && s % m == 0
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 7> E;
+        E e(7);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 0> E;
+        E e(0);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+    {
+        typedef std::linear_congruential_engine<T, 2, 0, 4> E;
+        E e(8);
+        std::ostringstream os;
+        os << e;
+        assert(os.str() == "1");
+    }
+}
+
+int main()
+{
+    test1<unsigned short>();
+    test1<unsigned int>();
+    test1<unsigned long>();
+    test1<unsigned long long>();
+
+    test2<unsigned short>();
+    test2<unsigned int>();
+    test2<unsigned long>();
+    test2<unsigned long long>();
+
+    test3<unsigned short>();
+    test3<unsigned int>();
+    test3<unsigned long>();
+    test3<unsigned long long>();
+
+    test4<unsigned short>();
+    test4<unsigned int>();
+    test4<unsigned long>();
+    test4<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..db7118f
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/ctor_sseq.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// template<class Sseq> explicit linear_congruential_engine(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned a[] = {3, 5, 7};
+        std::seed_seq sseq(a, a+3);
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e1(sseq);
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e2(4);
+        assert(e1 == e2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
new file mode 100644
index 0000000..6c4a7f4
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// linear_congruential_engine();
+
+#include <random>
+#include <cassert>
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> LCE;
+    typedef typename LCE::result_type result_type;
+    LCE e1;
+    LCE e2;
+    e2.seed();
+    assert(e1 == e2);
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp
new file mode 100644
index 0000000..9e3372a
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/discard.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+rand0()
+{
+    typedef std::linear_congruential_engine<T, 16807, 0, 2147483647> E;
+    E e;
+    e.discard(9999);
+    assert(e() == 1043618065);
+}
+
+template <class T>
+void
+rand()
+{
+    typedef std::linear_congruential_engine<T, 48271, 0, 2147483647> E;
+    E e;
+    e.discard(9999);
+    assert(e() == 399268537);
+}
+
+template <class T>
+void
+other()
+{
+    typedef std::linear_congruential_engine<T, 48271, 123465789, 2147483647> E;
+    E e1;
+    E e2;
+    assert(e1 == e2);
+    e1.discard(1);
+    assert(e1 != e2);
+    e2();
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    rand0<unsigned int>();
+    rand0<unsigned long>();
+    rand0<unsigned long long>();
+
+    rand<unsigned int>();
+    rand<unsigned long>();
+    rand<unsigned long long>();
+
+    other<unsigned int>();
+    other<unsigned long>();
+    other<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp
new file mode 100644
index 0000000..6d0057d
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/eval.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+randu()
+{
+    typedef std::linear_congruential_engine<T, 65539, 0, 2147483648u> E;
+    E e(1);
+    assert(e() == 65539);
+    assert(e() == 393225);
+    assert(e() == 1769499);
+    assert(e() == 7077969);
+    assert(e() == 26542323);
+    assert(e() == 95552217);
+    assert(e() == 334432395);
+    assert(e() == 1146624417);
+    assert(e() == 1722371299);
+    assert(e() == 14608041);
+    assert(e() == 1766175739);
+    assert(e() == 1875647473);
+}
+
+template <class T>
+void
+minstd()
+{
+    typedef std::linear_congruential_engine<T, 16807, 0, 2147483647> E;
+    E e(1);
+    assert(e() == 16807);
+    assert(e() == 282475249);
+    assert(e() == 1622650073);
+    assert(e() == 984943658);
+    assert(e() == 1144108930);
+    assert(e() == 470211272);
+    assert(e() == 101027544);
+    assert(e() == 1457850878);
+    assert(e() == 1458777923);
+    assert(e() == 2007237709);
+    assert(e() == 823564440);
+    assert(e() == 1115438165);
+}
+
+template <class T>
+void
+Haldir()
+{
+    typedef std::linear_congruential_engine<T, 16807, 78125, 2147483647> E;
+    E e(207560540);
+    assert(e() == 956631177);
+    assert(e() == 2037688522);
+    assert(e() == 1509348670);
+    assert(e() == 1546336451);
+    assert(e() == 429714088);
+    assert(e() == 217250280);
+}
+
+int main()
+{
+    randu<unsigned int>();
+    randu<unsigned long>();
+    randu<unsigned long long>();
+
+    minstd<unsigned int>();
+    minstd<unsigned long>();
+    minstd<unsigned long long>();
+
+    Haldir<unsigned int>();
+    Haldir<unsigned long>();
+    Haldir<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp
new file mode 100644
index 0000000..28ebdf2
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/io.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// template <class charT, class traits,
+//           class UIntType, UIntType a, UIntType c, UIntType m>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const linear_congruential_engine<UIntType, a, c, m>& x);
+//
+// template <class charT, class traits,
+//           class UIntType, UIntType a, UIntType c, UIntType m>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            linear_congruential_engine<UIntType, a, c, m>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::linear_congruential_engine<unsigned, 48271, 0, 2147483647> E;
+        E e1;
+        e1.discard(100);
+        std::ostringstream os;
+        os << e1;
+        std::istringstream is(os.str());
+        E e2;
+        is >> e2;
+        assert(e1 == e2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp
new file mode 100644
index 0000000..d261f1d
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/result_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_same<
+        typename std::linear_congruential_engine<T, 0, 0, 0>::result_type,
+        T>::value), "");
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
new file mode 100644
index 0000000..1afbe75
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+template <class T>
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::linear_congruential_engine<T, 2, 3, 7> E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1<unsigned short>();
+    test1<unsigned int>();
+    test1<unsigned long>();
+    test1<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp
new file mode 100644
index 0000000..ca2793c
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/seed_sseq.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+//   class linear_congruential_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        unsigned a[] = {3, 5, 7};
+        std::seed_seq sseq(a, a+3);
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e1;
+        std::linear_congruential_engine<unsigned, 5, 7, 11> e2(4);
+        assert(e1 != e2);
+        e1.seed(sseq);
+        assert(e1 == e2);
+    }
+    {
+        unsigned a[] = {3, 5, 7, 9, 11};
+        std::seed_seq sseq(a, a+5);
+        typedef std::linear_congruential_engine<unsigned long long, 1, 1, 0x200000001ULL> E;
+        E e1(4309005589);
+        E e2(sseq);
+        assert(e1 == e2);
+    }
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
new file mode 100644
index 0000000..857a478
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, UIntType a, UIntType c, UIntType m>
+// class linear_congruential_engine
+// {
+// public:
+//     engine characteristics
+//     static constexpr result_type multiplier = a;
+//     static constexpr result_type increment = c;
+//     static constexpr result_type modulus = m;
+//     static constexpr result_type min() { return c == 0u ? 1u: 0u;}
+//     static constexpr result_type max() { return m - 1u;}
+//     static constexpr result_type default_seed = 1u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+template <class T, T a, T c, T m>
+void
+test1()
+{
+    typedef std::linear_congruential_engine<T, a, c, m> LCE;
+    typedef typename LCE::result_type result_type;
+    static_assert((LCE::multiplier == a), "");
+    static_assert((LCE::increment == c), "");
+    static_assert((LCE::modulus == m), "");
+    /*static_*/assert((LCE::min() == (c == 0u ? 1u: 0u))/*, ""*/);
+    /*static_*/assert((LCE::max() == result_type(m - 1u))/*, ""*/);
+    static_assert((LCE::default_seed == 1), "");
+    where(LCE::multiplier);
+    where(LCE::increment);
+    where(LCE::modulus);
+    where(LCE::default_seed);
+}
+
+template <class T>
+void
+test()
+{
+    test1<T, 0, 0, 0>();
+    test1<T, 0, 1, 2>();
+    test1<T, 1, 1, 2>();
+    const T M(~0);
+    test1<T, 0, 0, M>();
+    test1<T, 0, M-2, M>();
+    test1<T, 0, M-1, M>();
+    test1<T, M-2, 0, M>();
+    test1<T, M-2, M-2, M>();
+    test1<T, M-2, M-1, M>();
+    test1<T, M-1, 0, M>();
+    test1<T, M-1, M-2, M>();
+    test1<T, M-1, M-1, M>();
+}
+
+int main()
+{
+    test<unsigned short>();
+    test<unsigned int>();
+    test<unsigned long>();
+    test<unsigned long long>();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp
new file mode 100644
index 0000000..fda5b88
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// mersenne_twister_engine& operator=(const mersenne_twister_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp
new file mode 100644
index 0000000..57c015c
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/copy.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// mersenne_twister_engine(const mersenne_twister_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    E e1;
+    e1();
+    E e2(e1);
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..6920aac
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp
@@ -0,0 +1,245 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// explicit mersenne_twister_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "0 1 1812433255 1900727105 1208447044 2481403966 4042607538 337614300 "
+    "3232553940 1018809052 3202401494 1775180719 3192392114 594215549 184016991 "
+    "829906058 610491522 3879932251 3139825610 297902587 4075895579 2943625357 "
+    "3530655617 1423771745 2135928312 2891506774 1066338622 135451537 933040465 "
+    "2759011858 2273819758 3545703099 2516396728 1272276355 3172048492 "
+    "3267256201 2332199830 1975469449 392443598 1132453229 2900699076 "
+    "1998300999 3847713992 512669506 1227792182 1629110240 112303347 2142631694 "
+    "3647635483 1715036585 2508091258 1355887243 1884998310 3906360088 "
+    "952450269 3647883368 3962623343 3077504981 2023096077 3791588343 "
+    "3937487744 3455116780 1218485897 1374508007 2815569918 1367263917 "
+    "472908318 2263147545 1461547499 4126813079 2383504810 64750479 2963140275 "
+    "1709368606 4143643781 835933993 1881494649 674663333 2076403047 858036109 "
+    "1667579889 1706666497 607785554 1995775149 1941986352 3448871082 "
+    "2109910019 1474883361 1623095288 1831376534 2612738285 81681830 2204289242 "
+    "1365038485 251164610 4268495337 1805601714 1262528768 1442526919 "
+    "1675006593 965627108 646339161 499795587 840887574 380522518 3023789847 "
+    "1457635507 1947093157 2600365344 2729853143 1550618999 1390905853 "
+    "3021294812 882647559 838872117 1663880796 4222103589 2754172275 3844026123 "
+    "3199260319 4176064873 3591027019 2690294242 2978135515 3172796441 "
+    "3263669796 1451257057 1427035359 4174826006 2171992010 1537002090 "
+    "3122405306 4162452508 3271954368 3794310005 3240514581 1270412086 "
+    "3030475836 2281945856 2644171349 3109139423 4253563838 1289926431 "
+    "1396919653 733220100 2753316645 1196225013 3699575255 3569440056 "
+    "2675979228 2624079148 3463113149 863430286 623703199 2113837653 2656425919 "
+    "175981357 4271478366 4238022735 1665483419 86880610 2963435083 1830392943 "
+    "847801865 3237296945 332143967 3973606945 2671879697 2236330279 2360127810 "
+    "3283955434 203240344 4048139172 13189264 2263058814 247241371 1566765783 "
+    "3084408095 3719371299 1958375251 1985924622 1712739232 1861691451 "
+    "2644502937 2337807839 784993770 2962208780 2190810177 1523122731 "
+    "714888527 578678761 3698481324 1801168075 534650483 3390213921 3923356461 "
+    "3586009066 2059432114 52511333 1969897376 3630122061 524661135 3513619765 "
+    "563070233 501359785 477489274 658768624 938973567 1548584683 1345287459 "
+    "2488691004 3441144905 3849305094 2430000078 855172178 614463281 2092744749 "
+    "176381493 1655802051 2273888101 2474494847 3471978030 2138918303 575352373 "
+    "1658230985 1675972553 2946663114 915579339 284981499 53939948 3022598146 "
+    "1861218535 3403620774 4203516930 2360471119 3134536268 1383448498 "
+    "1307602316 3847663247 3027225131 3597251613 3186237127 725127595 "
+    "1928526954 1843386923 3560410503 54688266 1791983849 2519860352 4256389699 "
+    "2328812602 486464275 3578698363 301279829 1303654791 4181868765 971794070 "
+    "1933885487 3996807464 2144053754 4079903755 3775774765 3481760044 "
+    "1212862354 1067356423 3764189132 1609862325 2209601551 2565747501 "
+    "161962392 4045451782 2605574664 2520953090 3490240017 1082791980 44474324 "
+    "101811128 4268650669 4171338684 772375154 3920460306 2319139534 599033750 "
+    "2950874441 3373922995 1496848525 4095253594 1271943484 1498723121 "
+    "3097453329 3698082465 281869581 3148270661 3591477288 747441437 2809508504 "
+    "3896107498 303747862 2368081624 1844217645 886825352 287949781 1444561207 "
+    "2512101757 2062331723 741720931 1383797313 3876746355 2041045348 "
+    "2627599118 1124169970 200524822 3484820454 55883666 1135054804 669498692 "
+    "2677215504 3097911127 1509628615 617580381 2229022193 85601568 3243896546 "
+    "3715672328 912168347 2359163500 1180347564 4243175048 2092067103 880183327 "
+    "4000664709 2045044777 3500474644 1515175520 1862207123 186628841 "
+    "3337252925 708933575 4015964629 3136815297 3314919747 2891909013 "
+    "3316567785 3944275369 3608506218 2884839110 3054055598 2707439927 "
+    "1381111877 3275487281 4292456216 2639563270 3327301876 3576924628 "
+    "721056309 2002808140 748967365 52380958 2200261692 763456477 1708381337 "
+    "2038446433 2682979402 1526413779 2211263302 3879771969 75966584 3645059271 "
+    "2985763524 4085690255 82390958 1883631385 1647521260 1598026998 3038041577 "
+    "2501913134 3279302868 1738888524 805035483 756399074 3863810982 1097797270 "
+    "1505792529 898904527 583561003 717152376 3333867738 1099456544 1663473545 "
+    "1242141229 3828627682 1966201676 1713552361 3852160017 1584965284 21695908 "
+    "1013262144 145341901 3995441263 3462066219 2239637848 1214086163 "
+    "2428868268 1650037305 1545513388 1621198806 4232947817 1823092073 "
+    "256414624 1745018809 1357102386 2055139770 3280958307 2482431613 "
+    "1664870585 859130423 4097751123 3079768369 2470211009 2984880786 "
+    "2808568948 2877071923 1984903163 302768457 1866396789 869566317 3746415787 "
+    "4169433075 3025005404 3980733379 3539207278 3953071536 876960847 "
+    "2548872156 800507464 1865466907 1273317878 3754712872 1757188269 "
+    "3229950355 3731640200 2283390608 2204990292 411873449 447423849 1852437802 "
+    "472825525 3044219944 2913114194 1859709265 4053786194 574820536 2104496732 "
+    "865469814 2438352724 4208743605 4215067542 1364015250 4139974345 "
+    "3838747005 1818502786 2914274940 1402365828 1751123528 2302578077 "
+    "2463168652 1968705496 1730700144 3023943273 1139096844 2658667767 "
+    "2063547264 705791165 1444775274 2415454225 1575664730 921044163 648101324 "
+    "1212387162 4191962054 1787702169 1888718041 1518218010 3398792842 "
+    "4079359729 149721439 750400353 2661036076 3802767886 520152586 951852508 "
+    "2939585975 1375969109 385733137 3523607459 1902438415 4250996086 "
+    "2712727066 484493674 3932107461 1428488210 1764242548 3424801055 "
+    "4004904451 2226862072 2393366939 3609584727 3614444319 317349896 "
+    "3826527525 204023804 981902443 3356042039 3051207045 1869902661 561831895 "
+    "3706675415 1527687593 1227610446 2596341042 3191717368 3269246891 "
+    "557877074 4062070629 3052520266 3772487029 400039836 3195205275 4085394797 "
+    "1655557239 1345770144 2864727192 449281238 73189507 528365765 2727400656 "
+    "247880434 2408277395 777039183 2210179398 1088433648 2124356402 1555630141 "
+    "604790219 195012151 3312518356 923728373 3999251660 3313059535 3478133921 "
+    "3395026960 383464614 3425869222 2446885186 4032184426 157195416 3158909476 "
+    "1663750443 2046427584 1658453076 1784483001 3146546889 1238739785 "
+    "2297306523 3472330897 2953326031 2421672215 1221694592 1588568605 "
+    "2546987845 3375168573 2137961649 3056565164 330165219 235900365 1000384800 "
+    "2697255904 579122283 3050664825 73426122 1232986102 2940571064 3076486824 "
+    "1708182873 2796363264 292154131 4280019913 1102652157 1185393592 "
+    "1494991690 4270076389 2384840717 425785147 2385321880 317514772 3926962743 "
+    "392176856 3465421709 1878853468 122662664 2958252160 1858961315 2244939588 "
+    "2361884409 2860936803 683833250 3291277128 1686857206 1112632275 "
+    "1200680507 3342928196 2677058150 939442136 3407104669 2906783932 "
+    "3668048733 2030009470 1910839172 1234925283 3575831445 123595418 "
+    "2362440495 3048484911 1796872496";
+    std::mt19937 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "0 1 6364136223846793007 13885033948157127961 "
+    "15324573939901584278 12737837167382305846 15195339788985155882 "
+    "6554113247712070460 17235932740818599105 13007415075556305955 "
+    "6585479514541334743 8274505865835507625 1718218088692873364 "
+    "10390651247454232081 12911994993614796389 3986900029987203370 "
+    "6673827651897561714 4426752746717694792 7419158062930293690 "
+    "5800047417539173618 15710773105226458059 16164512590413496893 "
+    "3438015953120274172 3483801391287623267 293704481016263807 "
+    "11580856846363212652 3489109114147636336 3391036861618673611 "
+    "8265793309278544843 7557898467821912223 11008748280761875940 "
+    "15929443707841919885 8545695347411085846 10810459396490399532 "
+    "12233244910455127352 15556950738631379285 16711543556686614082 "
+    "12362193084052127890 16520645558585805174 5163125267185202360 "
+    "405552980610370477 17567412011316060306 18195950784827697319 "
+    "7893142112162906367 11294475722810961618 7284845498332539581 "
+    "8406882439401998138 4375387785957411470 9627875716250684710 "
+    "8860968026642934661 9743109216691708518 152611520104818631 "
+    "5897430410700879663 5351672954305365323 16325991383734641720 "
+    "9695181037355459478 15420132328343498044 17772146581546890572 "
+    "12095930435311226909 3066005052193896110 11579395203346116306 "
+    "9168946227698330317 18318927644793076250 16096433325093805476 "
+    "14945900876820434843 16826760579960858105 17664119339058295604 "
+    "17844797344364136942 1071414400549507565 16688779616725465582 "
+    "3684635020921274863 12774052823168116810 17270284502989966576 "
+    "1081012692742984704 4377021575203177546 18341292555997099853 "
+    "13297939683513494274 15065725504474304333 10796297883750572804 "
+    "15233335271871291997 8767977593699151062 3360856014170688284 "
+    "7828232912764786750 15167717223619970150 9622174963375022357 "
+    "18262792478991268448 1196631425707106493 5368342740538672272 "
+    "10381091599850241237 12108437846306626340 6150860188928778248 "
+    "3342980288459577584 12715439159457051276 17996971042887275859 "
+    "9749679821487730542 17763727344608586331 16024467606290078168 "
+    "7763401887585513696 4448278918811662063 16947956613780322662 "
+    "15144807360840708645 3878082612940188435 10709780449699561405 "
+    "1649555943517500922 3206645931693769562 12562913950237146427 "
+    "237213339742767727 12987800257476421358 1653669854585203688 "
+    "3485900643226898485 13961759114404652223 5243794832751327611 "
+    "10337687908642742498 16946139522050041809 16716562961992396380 "
+    "4275124606042261542 4055100795824867618 6424268654905981295 "
+    "3424516503413156556 2670380025813203539 10750762735193959951 "
+    "8790031149370411970 4021216986392972993 12076090355041998696 "
+    "14407920322903159838 10653597737935867030 15483225617438352002 "
+    "2497775263858626604 12295882369431088188 14256043521530136935 "
+    "2687322778627883798 3419797801078863201 8786888481486602641 "
+    "445698423634900693 9597067954623467255 7101345576557603992 "
+    "1498579197046783597 10403325187679734962 2464586980321053562 "
+    "2022012026329844477 10802281218030350853 6628929099856200904 "
+    "6828177972863192803 8589868113309334601 5245595233272009016 "
+    "5335692004673212054 4515133017699498525 15966447436053813932 "
+    "15199779177078162007 4190689609934804313 13003438276435994683 "
+    "8406046831313066396 10564320513686955057 12668913223662201488 "
+    "13130110932487580228 1030848205404711145 17684061609212954769 "
+    "12942207438298787911 10731611242140874687 5165052527778107352 "
+    "16323046249518133445 17119162873327029615 5754858052433703070 "
+    "3864761150247579030 9945988334920003074 11409854727071782565 "
+    "5000838138362434817 15526574143469400487 18094554078711846524 "
+    "5576294272011007484 3478525338408894755 11392694223389544658 "
+    "4692963068671452476 4459301637730340710 9699395817392066460 "
+    "14644636990626292085 18065377773424192622 5217202490849387226 "
+    "16175595974171756081 2109372019589047677 1624752883142646445 "
+    "13462209973053735966 12082930933973802402 1568864426788967895 "
+    "17047994306870001795 10556833209957537593 955604103878351641 "
+    "9062985603395234592 9757612676622840969 1767246562613391916 "
+    "9752598821733361274 7499745701633625047 7824811626141302622 "
+    "15819064077972391284 5660565551854829485 17645390577243129343 "
+    "7343780801046581776 2233358068547689666 8716657172695403744 "
+    "9129027798969787220 334709674395230649 2063182499026924878 "
+    "13089071159640936832 1765917316143960741 17552378408917656269 "
+    "3917018959478722819 15626740210483166037 1645962609209923821 "
+    "12277169606472643961 14545894350924442736 11485249378718653961 "
+    "9205208816702766530 10967561305613932827 3105992977398681914 "
+    "2125140299311648264 11619505070220308543 5030167448920096401 "
+    "4248170446421798953 16184577688118775567 9240607582885304823 "
+    "11838996733938359277 415426114101983968 14340734742548675134 "
+    "4124085748228276376 17686494750190224280 9472996569628985376 "
+    "1207013222233148636 3031046462562068367 45068538181330439 "
+    "8678647417835301152 10693327126492781235 3058899219097846020 "
+    "18377730418355022492 10269941972656742364 15986476992758938864 "
+    "14575856764093007010 14749682846448398393 1042926396621439263 "
+    "12184905641567868001 3518848236485931862 6718580865438347534 "
+    "6319395993260741012 2855168874111910691 2482146419106261786 "
+    "17290238774162848390 8071397865265268054 15873003794708011585 "
+    "14422764926380465297 14140979091525022882 3573480287238168646 "
+    "1525896111244666696 7537826952717918371 10482908122538761078 "
+    "17003233041653857 9473838740924911883 8438240966750123668 "
+    "10697754962581554225 15048771265786776312 9067877678399943713 "
+    "3399555692325948067 6150260207049997483 7165140289246675175 "
+    "14816202987105583988 4753550992948864498 10549400354582510015 "
+    "13212062554023586370 1585477630313819722 476999696494664205 "
+    "3208739183359199317 16011681780347380478 8149150693959772807 "
+    "803412833228911773 2360961455092949929 1517204230639934662 "
+    "13863717544358808032 16792122738584967930 12742474971940259289 "
+    "1859755681395355028 1540431035241590810 3883807554140904361 "
+    "16189061625447625933 12376367376041900879 8006563585771266211 "
+    "2682617767291542421 8593924529704142157 9070391845133329273 "
+    "3557484410564396342 9301398051805853085 12632514768298643219 "
+    "227653509634201118 7247795074312488552 4939136716843120792 "
+    "6533591052147596041 1308401457054431629 17488144120120152559 "
+    "14075631579093810083 4015705597302725704 6833920126528811473 "
+    "5095302940809114298 8312250184258072842 15770605014574863643 "
+    "14091690436120485477 15763282477731738396 16394237160547425954 "
+    "5066318118328746621 13140493775100916989 6371148952471982853 "
+    "15150289760867914983 4931341382074091848 12635920082410445322 "
+    "8498109357807439006 14836776625250834986";
+    std::mt19937_64 e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..45bc493
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/ctor_sseq.pass.cpp
@@ -0,0 +1,309 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "358595400 4166558815 2016177162 3414480257 "
+    "4027494649 3722317195 1190532340 3212207148 "
+    "3537847251 389019999 1098708832 3277907415 "
+    "1946784350 3608286140 2091419822 2227407035 "
+    "2229110723 1825348377 1276269279 314337202 "
+    "3182935337 1313150029 3118776508 3707918501 "
+    "1900972958 4054820954 3973178248 906260237 "
+    "1403942218 3139931556 2807126524 3940936448 "
+    "1316345796 631296613 2268418920 2914000794 "
+    "3760588399 3226216036 880155129 4183611084 "
+    "211541083 3755352858 1331383234 3036493096 "
+    "937478630 2092170412 777784402 93392729 "
+    "3644029210 1681392086 2427001226 3143870332 "
+    "3703581502 2017505388 1706274541 1049329728 "
+    "2452031492 3437261233 2581204087 1700889875 "
+    "1652573881 2127047692 3778506964 1960741508 "
+    "2739602360 3395905609 2123355622 3041272975 "
+    "784200748 3558951522 1002787860 4063320888 "
+    "1587315560 4042698976 659183308 3082256417 "
+    "2808969567 2361418535 3468698782 750700970 "
+    "2991209851 3581521382 962022878 2518967363 "
+    "1476525873 3865977235 2128790058 2380326689 "
+    "1396773405 312559410 1370621899 1154499924 "
+    "2963101919 2182689761 2071851902 1661288848 "
+    "2411351341 1362764020 1289894483 1951662807 "
+    "701821506 552267185 2356648449 3949188503 "
+    "1748307081 87795201 3718396254 4112205936 "
+    "2819888864 73923733 2800033151 839258139 "
+    "3801779069 3105962436 2111266436 1772784466 "
+    "3692264298 4148810953 3147390749 3537518553 "
+    "1695044978 1430225842 1252346204 3465285434 "
+    "3970017763 2920658411 2805151132 290569815 "
+    "3802301355 1493420394 1943029276 1667143611 "
+    "1049665988 1710824905 220168517 3997946231 "
+    "1014582791 4244598752 1147604069 2533886627 "
+    "598679964 761521020 431779255 3745982038 "
+    "768658283 3598262505 1765664789 279538641 "
+    "715144305 2371628432 2655860083 1759010423 "
+    "3568452003 1910107098 2801429529 3924547532 "
+    "3862672436 3933725740 1764550618 130893617 "
+    "1460692387 4135312761 2075529299 2880227367 "
+    "944557368 4166665482 2627749235 3732013815 "
+    "1595900818 1553312393 3529311831 3531462424 "
+    "2431328342 4075369692 1609967709 3704537555 "
+    "2067297464 397140475 920618678 2840795964 "
+    "4202512837 1286017648 7035910 1057207826 "
+    "2325188262 191593698 3697383848 3029712831 "
+    "2073681914 163454681 1329637200 290077398 "
+    "287239431 4205081522 1233889024 167173087 "
+    "3267660257 3406068803 2382354609 1680046927 "
+    "125183503 3559536309 3208900974 2912148541 "
+    "2882879316 1937001086 2919729069 892928802 "
+    "4141691387 2507406586 855548593 3418647837 "
+    "4035646154 2410275591 248715645 3180757482 "
+    "1880770722 362912336 2964920095 2319904154 "
+    "1493655850 4240733030 1834485846 1696040454 "
+    "3329457927 1865824694 847759208 1587231623 "
+    "3757294772 1161601118 3630323833 3007722125 "
+    "3726418007 2124238171 1205345 172659797 "
+    "3040354211 885213338 1857049013 447922412 "
+    "719906299 1370059380 1922204800 3960090489 "
+    "1658822644 1529626863 1565927273 3537718771 "
+    "2733237258 2180221377 921910745 2144937687 "
+    "1727603895 1315635304 4023867791 2401834107 "
+    "808854185 2408824497 343935326 185237544 "
+    "746732759 2641236122 4283215329 743609415 "
+    "1134726665 3892851319 1302851263 3473445597 "
+    "1326817414 2702766508 1943179285 4025685468 "
+    "932896770 199392138 2787362875 3450501893 "
+    "3351567147 2461286528 2227605848 2993751114 "
+    "3988215720 1320573368 2866560199 4153194990 "
+    "3007120042 3260751955 3171763740 2111121243 "
+    "3962825228 102681859 3368179132 802089147 "
+    "4029273561 424939445 4178414761 2592125109 "
+    "1960801088 2967746406 310701990 2364200202 "
+    "1320507009 3474372480 784693947 2952246664 "
+    "1891935330 2048385105 3530082191 3238151038 "
+    "3293189141 1316053288 2087004409 740799958 "
+    "1187748554 3607767334 1190185990 1408429481 "
+    "657134359 221834425 3907725865 1068016389 "
+    "1402423875 2598612116 2046886300 2345022518 "
+    "1196081924 357783981 4013683598 463491626 "
+    "3269206482 3332444286 886491955 2257342866 "
+    "475911113 833576299 2893727564 2866985145 "
+    "1413365115 2995166393 1486060436 161205225 "
+    "3181728373 3056027137 2040371876 2182305146 "
+    "3028448628 2214316977 1266227021 876938740 "
+    "276477469 752158077 2182179045 1381698878 "
+    "3424557652 666674427 968327842 2534296575 "
+    "265105940 961112540 2641188117 2319139814 "
+    "1750453329 3450138343 678025317 1477566458 "
+    "3773796420 2933993832 3326042905 4084805260 "
+    "444182455 255333481 785163068 2321290820 "
+    "2893603234 3005520266 541104079 1383277090 "
+    "2770755666 3764627833 583371929 2864949033 "
+    "1487681116 1811788361 240329486 3094213377 "
+    "958509875 2564379085 1636995945 2070894127 "
+    "2139004232 1747850055 3841512327 3325011872 "
+    "1161622604 639182193 3533652535 4022667522 "
+    "761048999 3337743670 254221568 2784956233 "
+    "2990252814 4207922787 275707208 261819597 "
+    "2071467265 4034945770 1999813410 3038921100 "
+    "2200194573 1328217451 2440612380 3862293692 "
+    "2733976812 2750523058 2920082515 3809044908 "
+    "4285231753 3131963297 3481602724 1396460739 "
+    "2011767965 2481047764 2958452120 3044188618 "
+    "2217236658 3448605566 757716104 1818279145 "
+    "2641228144 1312649639 1194087684 3845229729 "
+    "1747658356 874418803 1956637337 268670179 "
+    "2083040240 2577671381 3375334655 2587828868 "
+    "1383012799 3583445685 2594576715 3282337104 "
+    "4257972751 3440488071 3129180313 1830891395 "
+    "1594931092 2680778339 3984026324 1102770400 "
+    "2315820258 1263467048 1133254110 2400676748 "
+    "2251795328 1036154092 3313541051 2277356560 "
+    "1477696003 1417117088 3968537402 1404882202 "
+    "2011058180 4114080985 1727459502 4100235708 "
+    "2334509310 2829432554 377936301 1519324520 "
+    "3252826644 1193335837 1929125820 2165344238 "
+    "4160556243 223340988 670907625 1485396519 "
+    "936389509 3813712964 2706450987 3132506320 "
+    "875886515 557088991 2854916639 2955496008 "
+    "2881696287 265169077 3239923698 3649366121 "
+    "4072165960 1233904959 225406526 1767368993 "
+    "1894882500 2296582180 339255168 83200939 "
+    "2958376148 4100205346 1991250823 3806183082 "
+    "2691709980 2642354997 3024056146 1681065839 "
+    "3438299684 1638853652 362567001 2307868899 "
+    "988801086 1342833399 2303298376 1500039911 "
+    "765489391 4080464497 4155444368 980472018 "
+    "2026981853 3460406995 391970367 667377014 "
+    "4177754853 2657468948 3560690175 3030464357 "
+    "2948380657 1208800977 2316451404 4001932203 "
+    "1977856863 4265848271 3116200050 3037586215 "
+    "1335232764 930230766 1026089249 2482219415 "
+    "2613853154 1854543497 2909555107 3862874043 "
+    "2609355500 907364682 383900687 358164223 "
+    "232347546 2536276737 3118482806 1254103998 "
+    "2357334077 1204777304 1996643329 4046232717 "
+    "2570520290 3173323380 1201411457 2361883023 "
+    "806087062 2984143714 2355127569 864220085 "
+    "1787696713 1182652984 4200065581 100722519 "
+    "2380458669 2429592313 2618338302 1236529564 "
+    "1747130196 3711661325 1114068102 510380433 "
+    "93703089 2277774664 3220741441 1577998569 "
+    "2816701900 4206763045 2495239107 4080390459 "
+    "1307072677 20360728 1468385549 96049834 "
+    "3630657447 2809517346 3396111678 3043831060 "
+    "673178359 4256729562 1755211210 1969834535 "
+    "498315110 3717726302 1544859987 2239930949 "
+    "1595372585 294525219 3961637067 3591840665 "
+    "3324896933 2300077772 721255886 4197934760 "
+    "1468866696 2184812884 628246683 3385113037 "
+    "3041166140 3948531843 1176600829 228286131 "
+    "2447397608 712235937 3332826819 2676980703 "
+    "4019468871 1952389952 1202638254 3625447051";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::mt19937 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "17895233847644109640 14665081038668852234 15987230621890949369 "
+    "13796324649827964148 1670828176732799955 14078505147839608672 "
+    "15497470967856861790 9566640372296747182 7839811585250789315 "
+    "1350068003782415071 5639936432479386921 15925388701147119804 "
+    "17415323390466493342 3892358083553387400 13485903346102334794 "
+    "16926193162581531132 2711398308226914244 12515538113016451944 "
+    "13856492368211347055 17968472785843263993 16129117710261673051 "
+    "13041638543181171650 8985803498136324582 401118717516975186 "
+    "7221524024767248666 13502820261231663498 8665119664667372350 "
+    "4506836866186850029 14762924585995667460 7305266389803732087 "
+    "9135600275824854713 8421320656548229332 14585303533697565624 "
+    "13062167967956981222 15285580395823625260 17451830328116466708 "
+    "17363259891080004456 13238190509560321740 10142215382802200927 "
+    "3224236118694175902 15382517208605932923 10818882444738383326 "
+    "16604245792882032433 10223425285179753002 1342432445403828765 "
+    "4958539418185107403 9374581143772158175 7135181273441366910 "
+    "5853026900476841261 8382327930174454355 2371969498930803266 "
+    "16961635468480846337 377077518789053577 17661790013255465310 "
+    "317500018453124832 3604586262706855295 13340007089026272125 "
+    "7614051306438090372 17819007364113857386 15193526497275633437 "
+    "6142773218979108210 14883287611587512668 12544132362002344419 "
+    "1247987855434921372 6414191755211735979 7160327288923375132 "
+    "7347937017206972868 17171048313531629893 18230412825496997383 "
+    "10882960195884354661 3270707876715241884 16088870345045208503 "
+    "15454419782166694763 1200609322828949525 10186066554418904177 "
+    "7554892242763986291 8203847521335919011 16855803304338943001 "
+    "16895223408596071476 562183806034700250 17761033068687156643 "
+    "12370482348384718931 17895691979506634040 16028877286272943475 "
+    "6671425930002400146 15167515621662197335 17503579548680921174 "
+    "15910867647138768989 1705705354110203064 12201125760909412022 "
+    "5523403744441352645 4540673037752294406 822888669354888870 "
+    "13012517529113958824 702032511346794490 1245872939048413008 "
+    "18060687614291143943 718002942670251776 14628954120078526945 "
+    "7215746609592654001 15288092036204733967 12507582747898016110 "
+    "8319356319569362772 3835100005166188461 10769229288786702843 "
+    "14682980657311687345 10352054841727718090 13661249361946024317 "
+    "1558696616315734178 9963912474249467679 18213809676410642730 "
+    "7284438284457478230 8013656044128665351 6817107912809760616 "
+    "4989038816564331700 12918068165960947833 9123533477086273623 "
+    "741568181450204257 3801962339733348259 1923812112542486965 "
+    "5884360231397942779 17008459141377852544 6569697353326895092 "
+    "15194386425456240489 9363979514988323850 9212437218544795097 "
+    "5650610605870621879 10315798944006232463 10345822437227504297 "
+    "795589193815296350 11344022765750598871 3193778122705907169 "
+    "16719669104430190089 14918335244853046975 11608293761910939782 "
+    "17290187430985633813 856382712722415618 14819792788008454203 "
+    "10571145147196955435 12858063129221173592 5671819431516788648 "
+    "17837836658827607239 14004823010100183722 9067196699747632668 "
+    "441015230260308492 3444946658209715644 1825101023084664281 "
+    "11133092574473850025 12746373758552339264 10154162549097295782 "
+    "14922316177042921089 12679802872389794491 8797747037480461410 "
+    "13907752811248535439 5652405835046458389 3181711594575177977 "
+    "15495242712294857418 6049158560807439366 952771601159099159 "
+    "4587095466254740009 11160954054611782211 10071795025240457628 "
+    "1536670498623767300 1990681379653546894 14312739227381277138 "
+    "9695213786215402291 3580182943401628617 12313607438786545484 "
+    "12864141705426648443 692371170805382036 13125536612285239925 "
+    "9372929234002877092 9510419002221032820 3766423210161674061 "
+    "3230494342413727261 5934351496112072933 2863344864469097044 "
+    "10884720908958139042 4127946927340597780 9960629658622711061 "
+    "14818231351611083857 6346099615454582885 12601407558879514692 "
+    "17544105005554819865 1096648950913019831 9969868157190185788 "
+    "12908611252828823970 5941129863397152719 16168953427117105234 "
+    "12304862402025196697 7781571759256122972 13289545261301048078 "
+    "11013924305579914035 8894422550580466537 7506958826675805512 "
+    "14280817252893250439 2745266616282182732 17277225453205013047 "
+    "14335499905842065319 11961295941780577536 18072890757248426766 "
+    "1124506606842606920 17329960125355005185 13052066741624159010 "
+    "5704650516221677069 16588425097127709212 11813406583737887980 "
+    "16359723311775411283 13451679937172566665 5997753207634594468 "
+    "10656019008205694109 13074690560123889048 14811648124990806194 "
+    "7809449463531558024 5637787273252434288 16515135932856030468 "
+    "3755600163640125044 1153929634172103321 11071014283313196016 "
+    "11114640359080035583 15390782025450330559 14097530518721927499 "
+    "14776783751481098767 7863618667181998233 11513855295425132436 "
+    "4736362806980864724 5426549653049482466 10310828122060887518 "
+    "4450247941008370560 9781171949844602811 6086471549040450051 "
+    "6033923116291003194 17669843285681524740 17610378273478865070 "
+    "12152320288002263294 6525449125788834221 5125338396312613396 "
+    "9300082688721166268 959242243476884691 6379729471368150249 "
+    "16379772457647614853 13454012201619761707 2392678998182524851 "
+    "12693758700673471007 1138892516507202079 15673908144065302514 "
+    "5299581449349386824 7590792025124859454 9863745357571267780 "
+    "357345312340746112 17610247870912740564 16347431861769737095 "
+    "11348828299228888092 7220122803951857490 7038822841708464676 "
+    "9912221445023094105 5767425533670320190 6442622362743049032 "
+    "17525461567869579503 4211095256108567696 14862334876401617373 "
+    "2866362449624104511 11413742225973279461 13015745308569358847 "
+    "5191760666536228849 17188167935010684492 18321678815621002079 "
+    "13046333455321624690 3995310719038261500 10661051209947341089 "
+    "7965203671238327266 16590917686161852835 3897101637344795372 "
+    "1538303624766151695 10893225639252940698 5386335660311332214 "
+    "5174479122000384061 17378437193516866561 13629320139302700770 "
+    "10144210341964027265 12816799659000064406 3711797003976467729 "
+    "5079455890584507977 432599929275804205 10435019529328454317 "
+    "5310854040535477246 15941464006450157396 2192067269367387270 "
+    "9782967689631091633 6777452250210540865 18067909703113078220 "
+    "17525143578810667971 87448662189824165 412530897284614413 "
+    "12066785122245373863 13073154860645125438 18282514257379582711 "
+    "8460374908111578570 15967512883067334502 9620430172798103891 "
+    "1264976185047610409 15426838192579528907 9878758812321441445 "
+    "18029992505662864846 9383699886128308360 14538949787806484635 "
+    "16958815135940772668 980481467951972605 3059030058898313960 "
+    "11497544574740915907 8385450996898478663 15571176518627282350";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::mt19937_64 e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp
new file mode 100644
index 0000000..d92ffd8
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/default.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// explicit mersenne_twister_engine();
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    std::mt19937 e1;
+    std::mt19937 e2(std::mt19937::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 3499211612u);
+}
+
+void
+test2()
+{
+    std::mt19937_64 e1;
+    std::mt19937_64 e2(std::mt19937_64::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 14514284786278117030ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp
new file mode 100644
index 0000000..d20d661
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/discard.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    std::mt19937 e1;
+    std::mt19937 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::mt19937_64 e1;
+    std::mt19937_64 e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp
new file mode 100644
index 0000000..0b17a85
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/eval.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    std::mt19937 e;
+    assert(e() == 3499211612u);
+    assert(e() == 581869302u);
+    assert(e() == 3890346734u);
+}
+
+void
+test2()
+{
+    std::mt19937_64 e;
+    assert(e() == 14514284786278117030ull);
+    assert(e() == 4620546740167642908ull);
+    assert(e() == 13109570281517897720ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp
new file mode 100644
index 0000000..28e00ec
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/io.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+//
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// basic_ostream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp
new file mode 100644
index 0000000..26f3e15
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/result_type.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::mt19937::result_type,
+        std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::mt19937_64::result_type,
+        std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp
new file mode 100644
index 0000000..6f93e5b
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/seed_result_type.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::mt19937 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::mt19937_64 E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp
new file mode 100644
index 0000000..33292a0
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/seed_sseq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::mt19937 e1;
+    std::mt19937 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::mt19937_64 e1;
+    std::mt19937_64 e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
new file mode 100644
index 0000000..331d3c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template <class UIntType, size_t w, size_t n, size_t m, size_t r,
+//           UIntType a, size_t u, UIntType d, size_t s,
+//           UIntType b, size_t t, UIntType c, size_t l, UIntType f>
+// class mersenne_twister_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+//
+//     // engine characteristics
+//     static constexpr size_t word_size = w;
+//     static constexpr size_t state_size = n;
+//     static constexpr size_t shift_size = m;
+//     static constexpr size_t mask_bits = r;
+//     static constexpr result_type xor_mask = a;
+//     static constexpr size_t tempering_u = u;
+//     static constexpr result_type tempering_d = d;
+//     static constexpr size_t tempering_s = s;
+//     static constexpr result_type tempering_b = b;
+//     static constexpr size_t tempering_t = t;
+//     static constexpr result_type tempering_c = c;
+//     static constexpr size_t tempering_l = l;
+//     static constexpr result_type initialization_multiplier = f;
+//     static constexpr result_type min () { return 0; }
+//     static constexpr result_type max() { return 2^w - 1; }
+//     static constexpr result_type default_seed = 5489u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+    typedef std::mt19937 E;
+    static_assert((E::word_size == 32), "");
+    static_assert((E::state_size == 624), "");
+    static_assert((E::shift_size == 397), "");
+    static_assert((E::mask_bits == 31), "");
+    static_assert((E::xor_mask == 0x9908b0df), "");
+    static_assert((E::tempering_u == 11), "");
+    static_assert((E::tempering_d == 0xffffffff), "");
+    static_assert((E::tempering_s == 7), "");
+    static_assert((E::tempering_b == 0x9d2c5680), "");
+    static_assert((E::tempering_t == 15), "");
+    static_assert((E::tempering_c == 0xefc60000), "");
+    static_assert((E::tempering_l == 18), "");
+    static_assert((E::initialization_multiplier == 1812433253), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+    static_assert((E::default_seed == 5489u), "");
+    where(E::word_size);
+    where(E::state_size);
+    where(E::shift_size);
+    where(E::mask_bits);
+    where(E::xor_mask);
+    where(E::tempering_u);
+    where(E::tempering_d);
+    where(E::tempering_s);
+    where(E::tempering_b);
+    where(E::tempering_t);
+    where(E::tempering_c);
+    where(E::tempering_l);
+    where(E::initialization_multiplier);
+    where(E::default_seed);
+}
+
+void
+test2()
+{
+    typedef std::mt19937_64 E;
+    static_assert((E::word_size == 64), "");
+    static_assert((E::state_size == 312), "");
+    static_assert((E::shift_size == 156), "");
+    static_assert((E::mask_bits == 31), "");
+    static_assert((E::xor_mask == 0xb5026f5aa96619e9ull), "");
+    static_assert((E::tempering_u == 29), "");
+    static_assert((E::tempering_d == 0x5555555555555555ull), "");
+    static_assert((E::tempering_s == 17), "");
+    static_assert((E::tempering_b == 0x71d67fffeda60000ull), "");
+    static_assert((E::tempering_t == 37), "");
+    static_assert((E::tempering_c == 0xfff7eee000000000ull), "");
+    static_assert((E::tempering_l == 43), "");
+    static_assert((E::initialization_multiplier == 6364136223846793005ull), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+    static_assert((E::default_seed == 5489u), "");
+    where(E::word_size);
+    where(E::state_size);
+    where(E::shift_size);
+    where(E::mask_bits);
+    where(E::xor_mask);
+    where(E::tempering_u);
+    where(E::tempering_d);
+    where(E::tempering_s);
+    where(E::tempering_b);
+    where(E::tempering_t);
+    where(E::tempering_c);
+    where(E::tempering_l);
+    where(E::initialization_multiplier);
+    where(E::default_seed);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp
new file mode 100644
index 0000000..305d43a
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/assign.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// subtract_with_carry_engine& operator=(const subtract_with_carry_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    E e1(2);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    E e1(3);
+    e1();
+    E e2(5);
+    e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp
new file mode 100644
index 0000000..27f8816
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// subtract_with_carry_engine(const subtract_with_carry_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    E e1;
+    e1();
+    E e2 = e1;
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    E e1;
+    e1();
+    E e2(e1);
+    assert(e1 == e2);
+    assert(e1() == e2());
+    E::result_type k = e1();
+    assert(e1 != e2);
+    assert(e2() == k);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp
new file mode 100644
index 0000000..429298d
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// explicit subtract_with_carry_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+    "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+    "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+    "5707268 2355175 0";
+    std::ranlux24_base e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "10880375256626 126660097854724 33643165434010 "
+    "78293780235492 179418984296008 96783156950859 238199764491708 "
+    "34339434557790 155299155394531 29014415493780 209265474179052 "
+    "263777435457028 0";
+    std::ranlux48_base e1(0);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp
new file mode 100644
index 0000000..893f6dc
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/ctor_sseq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+    "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+    "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+    "889045 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux24_base e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+void
+test2()
+{
+    const char* a = "241408498702289 172342669275054 191026374555184 "
+    "61020585639411 231929771458953 142769679250755 198672786411514 "
+    "183712717244841 227473912549724 62843577252444 68782400568421 "
+    "159248704678140 0";
+    unsigned as[] = {3, 5, 7};
+    std::seed_seq sseq(as, as+3);
+    std::ranlux48_base e1(sseq);
+    std::ostringstream os;
+    os << e1;
+    assert(os.str() == a);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp
new file mode 100644
index 0000000..56e8759
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/default.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// explicit subtract_with_carry_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24_base e1;
+    std::ranlux24_base e2(std::ranlux24_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+    std::ranlux48_base e1;
+    std::ranlux48_base e2(std::ranlux48_base::default_seed);
+    assert(e1 == e2);
+    assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp
new file mode 100644
index 0000000..4ba9381
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24_base e1;
+    std::ranlux24_base e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    std::ranlux48_base e1;
+    std::ranlux48_base e2 = e1;
+    assert(e1 == e2);
+    e1.discard(3);
+    assert(e1 != e2);
+    e2();
+    e2();
+    e2();
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp
new file mode 100644
index 0000000..4482994
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/eval.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    std::ranlux24_base e;
+    assert(e() == 15039276u);
+    assert(e() == 16323925u);
+    assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+    std::ranlux48_base e;
+    assert(e() == 23459059301164ull);
+    assert(e() == 28639057539807ull);
+    assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp
new file mode 100644
index 0000000..834f5f6
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/io.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t s, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+//            const subtract_with_carry_engine<UIntType, w, s, r>& x);
+//
+// template <class charT, class traits,
+//           class UIntType, size_t w, size_t s, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+//            subtract_with_carry_engine<UIntType, w, s, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    E e1;
+    e1.discard(100);
+    std::ostringstream os;
+    os << e1;
+    std::istringstream is(os.str());
+    E e2;
+    is >> e2;
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp
new file mode 100644
index 0000000..6af195b
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/result_type.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+    static_assert((std::is_same<
+        std::ranlux24_base::result_type,
+        std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+    static_assert((std::is_same<
+        std::ranlux48_base::result_type,
+        std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp
new file mode 100644
index 0000000..fa6e741
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/seed_result_type.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux24_base E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+void
+test2()
+{
+    for (int s = 0; s < 20; ++s)
+    {
+        typedef std::ranlux48_base E;
+        E e1(s);
+        E e2;
+        e2.seed(s);
+        assert(e1 == e2);
+    }
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp
new file mode 100644
index 0000000..3470772
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/seed_sseq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine;
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux24_base e1;
+    std::ranlux24_base e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+void
+test2()
+{
+    unsigned a[] = {3, 5, 7};
+    std::seed_seq sseq(a, a+3);
+    std::ranlux48_base e1;
+    std::ranlux48_base e2(sseq);
+    assert(e1 != e2);
+    e1.seed(sseq);
+    assert(e1 == e2);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp b/final/test/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
new file mode 100644
index 0000000..75716a4
--- /dev/null
+++ b/final/test/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class UIntType, size_t w, size_t s, size_t r>
+// class subtract_with_carry_engine
+// {
+// public:
+//     // types
+//     typedef UIntType result_type;
+//
+//     // engine characteristics
+//     static constexpr size_t word_size = w;
+//     static constexpr size_t short_lag = s;
+//     static constexpr size_t long_lag = r;
+//     static constexpr result_type min() { return 0; }
+//     static constexpr result_type max() { return m-1; }
+//     static constexpr result_type default_seed = 19780503u;
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+    typedef std::ranlux24_base E;
+    static_assert((E::word_size == 24), "");
+    static_assert((E::short_lag == 10), "");
+    static_assert((E::long_lag == 24), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+    static_assert((E::default_seed == 19780503u), "");
+    where(E::word_size);
+    where(E::short_lag);
+    where(E::long_lag);
+    where(E::default_seed);
+}
+
+void
+test2()
+{
+    typedef std::ranlux48_base E;
+    static_assert((E::word_size == 48), "");
+    static_assert((E::short_lag == 5), "");
+    static_assert((E::long_lag == 12), "");
+    /*static_*/assert((E::min() == 0)/*, ""*/);
+    /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+    static_assert((E::default_seed == 19780503u), "");
+    where(E::word_size);
+    where(E::short_lag);
+    where(E::long_lag);
+    where(E::default_seed);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/numerics/rand/rand.predef/default_random_engine.pass.cpp b/final/test/numerics/rand/rand.predef/default_random_engine.pass.cpp
new file mode 100644
index 0000000..4265860
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/default_random_engine.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef minstd_rand0 default_random_engine;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::default_random_engine e;
+    e.discard(9999);
+    assert(e() == 399268537u);
+}
diff --git a/final/test/numerics/rand/rand.predef/knuth_b.pass.cpp b/final/test/numerics/rand/rand.predef/knuth_b.pass.cpp
new file mode 100644
index 0000000..69627d7
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/knuth_b.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef shuffle_order_engine<minstd_rand0, 256>                      knuth_b;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::knuth_b e;
+    e.discard(9999);
+    assert(e() == 1112339016u);
+}
diff --git a/final/test/numerics/rand/rand.predef/minstd_rand.pass.cpp b/final/test/numerics/rand/rand.predef/minstd_rand.pass.cpp
new file mode 100644
index 0000000..891e5cc
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/minstd_rand.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
+//                                                                 minstd_rand;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::minstd_rand e;
+    e.discard(9999);
+    assert(e() == 399268537u);
+}
diff --git a/final/test/numerics/rand/rand.predef/minstd_rand0.pass.cpp b/final/test/numerics/rand/rand.predef/minstd_rand0.pass.cpp
new file mode 100644
index 0000000..63848cf
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/minstd_rand0.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
+//                                                                 minstd_rand0;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::minstd_rand0 e;
+    e.discard(9999);
+    assert(e() == 1043618065u);
+}
diff --git a/final/test/numerics/rand/rand.predef/mt19937.pass.cpp b/final/test/numerics/rand/rand.predef/mt19937.pass.cpp
new file mode 100644
index 0000000..e3a7936
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/mt19937.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
+//                                 0x9908b0df,
+//                                 11, 0xffffffff,
+//                                 7,  0x9d2c5680,
+//                                 15, 0xefc60000,
+//                                 18, 1812433253>                      mt19937;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::mt19937 e;
+    e.discard(9999);
+    assert(e() == 4123659995u);
+}
diff --git a/final/test/numerics/rand/rand.predef/mt19937_64.pass.cpp b/final/test/numerics/rand/rand.predef/mt19937_64.pass.cpp
new file mode 100644
index 0000000..67896d2
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/mt19937_64.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
+//                                 0xb5026f5aa96619e9,
+//                                 29, 0x5555555555555555,
+//                                 17, 0x71d67fffeda60000,
+//                                 37, 0xfff7eee000000000,
+//                                 43, 6364136223846793005>          mt19937_64;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::mt19937_64 e;
+    e.discard(9999);
+    assert(e() == 9981545732273789042ull);
+}
diff --git a/final/test/numerics/rand/rand.predef/ranlux24.pass.cpp b/final/test/numerics/rand/rand.predef/ranlux24.pass.cpp
new file mode 100644
index 0000000..529586a
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/ranlux24.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef discard_block_engine<ranlux24_base, 223, 23>                ranlux24;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux24 e;
+    e.discard(9999);
+    assert(e() == 9901578u);
+}
diff --git a/final/test/numerics/rand/rand.predef/ranlux24_base.pass.cpp b/final/test/numerics/rand/rand.predef/ranlux24_base.pass.cpp
new file mode 100644
index 0000000..f731146
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/ranlux24_base.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>  ranlux24_base;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux24_base e;
+    e.discard(9999);
+    assert(e() == 7937952u);
+}
diff --git a/final/test/numerics/rand/rand.predef/ranlux48.pass.cpp b/final/test/numerics/rand/rand.predef/ranlux48.pass.cpp
new file mode 100644
index 0000000..f15dfd5
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/ranlux48.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef discard_block_engine<ranlux48_base, 389, 11>                ranlux48;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux48 e;
+    e.discard(9999);
+    assert(e() == 249142670248501ull);
+}
diff --git a/final/test/numerics/rand/rand.predef/ranlux48_base.pass.cpp b/final/test/numerics/rand/rand.predef/ranlux48_base.pass.cpp
new file mode 100644
index 0000000..4c3df3e
--- /dev/null
+++ b/final/test/numerics/rand/rand.predef/ranlux48_base.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// typedef subtract_with_carry_engine<uint_fast64_t, 48,  5, 12>  ranlux48_base;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::ranlux48_base e;
+    e.discard(9999);
+    assert(e() == 61839128582725ull);
+}
diff --git a/final/test/numerics/rand/rand.req/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.req/rand.req.adapt/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.req/rand.req.dst/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.req/rand.req.eng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.req/rand.req.genl/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.req/rand.req.seedseq/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.req/rand.req.urng/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.synopsis/version.pass.cpp b/final/test/numerics/rand/rand.synopsis/version.pass.cpp
new file mode 100644
index 0000000..eae6c49
--- /dev/null
+++ b/final/test/numerics/rand/rand.synopsis/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+#include <random>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.util/nothing_to_do.pass.cpp b/final/test/numerics/rand/rand.util/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp b/final/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
new file mode 100644
index 0000000..7433e28
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType, size_t bits, class URNG>
+//     RealType generate_canonical(URNG& g);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, 0>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits - 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef float F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits + 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, 0>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, 1>(r);
+        assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1)));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits - 1>(r);
+        assert(f ==
+            (16807 - E::min() +
+            (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+            ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits>(r);
+        assert(f ==
+            (16807 - E::min() +
+            (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+            ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+    }
+    {
+        typedef std::minstd_rand0 E;
+        typedef double F;
+        E r;
+        F f = std::generate_canonical<F, std::numeric_limits<F>::digits + 1>(r);
+        assert(f ==
+            (16807 - E::min() +
+            (282475249 - E::min()) * (E::max() - E::min() + F(1))) /
+            ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1))));
+    }
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp b/final/test/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp
new file mode 100644
index 0000000..6b5d750
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.seedseq/assign.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+    std::seed_seq s0;
+    std::seed_seq s;
+    s = s0;
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp b/final/test/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp
new file mode 100644
index 0000000..cf260fc
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.seedseq/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+
+int main()
+{
+    std::seed_seq s0;
+    std::seed_seq s(s0);
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp b/final/test/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp
new file mode 100644
index 0000000..bf4210a
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.seedseq/default.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// seed_seq();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    std::seed_seq s;
+    assert(s.size() == 0);
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp b/final/test/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp
new file mode 100644
index 0000000..9712f61
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.seedseq/generate.pass.cpp
@@ -0,0 +1,805 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class RandomAccessIterator>
+//     void generate(RandomAccessIterator begin, RandomAccessIterator end);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    {
+        // These numbers generated from a slightly altered version of dSFMT
+        //  http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html
+        unsigned a[] =
+        {
+            509928861u,
+            482551238u,
+            141770655u,
+            3445468037u,
+            1614807826u,
+            3110698871u,
+            809182926u,
+            2644632325u,
+            3885131857u,
+            1278630374u,
+            3648975313u,
+            1217833759u,
+            1509686260u,
+            2817190507u,
+            134525747u,
+            250267852u,
+            2559105345u,
+            2416641579u,
+            426100435u,
+            486929906u,
+            241178241u,
+            3531539379u,
+            704692991u,
+            3001633456u,
+            3990516671u,
+            2619782509u,
+            588842726u,
+            2871949673u,
+            621390331u,
+            2304055997u,
+            3809702625u,
+            2471383485u,
+            1630735687u,
+            2167939898u,
+            2070992669u,
+            2826890739u,
+            1714346061u,
+            1912761420u,
+            539780511u,
+            716119356u,
+            1342493369u,
+            1216009367u,
+            2864243850u,
+            36288867u,
+            2981095630u,
+            2480586007u,
+            1287539180u,
+            1804977887u,
+            2219960896u,
+            297158412u,
+            2839013626u,
+            1971706101u,
+            3588181149u,
+            1387242816u,
+            3713499635u,
+            3408234160u,
+            3179393218u,
+            1359207226u,
+            3119279997u,
+            2777679329u,
+            125221793u,
+            902631799u,
+            949389096u,
+            3415339313u,
+            4117407143u,
+            3119227103u,
+            1787026946u,
+            3917387257u,
+            3936044384u,
+            2242085379u,
+            1140709958u,
+            2523265662u,
+            3627073995u,
+            3604398568u,
+            1427913954u,
+            2465898599u,
+            3825653050u,
+            2090876078u,
+            232270946u,
+            3116274782u,
+            1252172657u,
+            3197497894u,
+            3983224490u,
+            1939344836u,
+            4158531887u,
+            88050086u,
+            2343094701u,
+            1067025562u,
+            3321491106u,
+            3772162169u,
+            909332669u,
+            1671671873u,
+            755193996u,
+            978524521u,
+            2164582730u,
+            1757783103u,
+            3411415001u,
+            850017018u,
+            3068762300u,
+            555996984u,
+            2404040146u,
+            3397007611u,
+            237680219u,
+            245818821u,
+            177824968u,
+            3220945682u,
+            304446762u,
+            2267298065u,
+            1878973555u,
+            3050739800u,
+            535731508u,
+            1160102565u,
+            4109066907u,
+            984269821u,
+            3681788896u,
+            60254699u,
+            3890962421u,
+            2991673698u,
+            3982271427u,
+            3514243671u,
+            1234870914u,
+            2069958363u,
+            3867828422u,
+            1847469687u,
+            503598128u,
+            967934988u,
+            289386211u,
+            393279961u,
+            835485527u,
+            3708682854u,
+            965218590u,
+            4020339834u,
+            2159101708u,
+            2575134771u,
+            376656690u,
+            3499375240u,
+            3105954900u,
+            2786692328u,
+            3458480699u,
+            1207173847u,
+            2051152535u,
+            2738812911u,
+            2954646330u,
+            2774866710u,
+            2162149150u,
+            3993372257u,
+            2868120585u,
+            3086420190u,
+            3791115537u,
+            3226697711u,
+            1818303409u,
+            4206013897u,
+            1245186807u,
+            1680347447u,
+            684800149u,
+            2372078492u,
+            2566952562u,
+            3310947940u,
+            3885964747u,
+            3270357885u,
+            2098965232u,
+            609044652u,
+            434910954u,
+            93043847u,
+            805217072u,
+            883298424u,
+            3850995479u,
+            1840717689u,
+            124278163u,
+            4250050101u,
+            2337070911u,
+            2576763405u,
+            2518189119u,
+            3059082421u,
+            1532107996u,
+            2920167825u,
+            2726963926u,
+            3951524890u,
+            1272835728u,
+            1039392592u,
+            1237920408u,
+            1996153268u,
+            647883626u,
+            4064365193u,
+            355588474u,
+            3625797533u,
+            1209959194u,
+            503163662u,
+            530295589u,
+            1668578780u,
+            969028048u,
+            2489337768u,
+            841218738u,
+            14126306u,
+            1854884627u,
+            3617055808u,
+            202224793u,
+            1744552899u,
+            1559016256u,
+            3455976027u,
+            1064269942u,
+            2990703287u,
+            1169718685u,
+            1411804743u,
+            290849805u,
+            756035681u,
+            1505272475u,
+            1426658932u,
+            16045749u,
+            3900455443u,
+            108521850u,
+            1009491914u,
+            3928801938u,
+            1022079325u,
+            3076867150u,
+            4268343543u,
+            2886814247u,
+            2005055376u,
+            1649037732u,
+            1954533894u,
+            3779223482u,
+            1093746989u,
+            2376482601u,
+            3561720470u,
+            1870836501u,
+            651953759u,
+            1504660027u,
+            2097900540u,
+            2252668945u,
+            2469849023u,
+            1986217648u,
+            2026387757u,
+            131611273u,
+            1467981299u,
+            3440588252u,
+            1916199579u,
+            959039804u,
+            2895114746u,
+            3292235117u,
+            649379239u,
+            28649189u,
+            3121113086u,
+            3829761771u,
+            1675837301u,
+            1636154723u,
+            3737794169u,
+            4082428060u,
+            1904712095u,
+            2483810990u,
+            979972563u,
+            1269082707u,
+            370986843u,
+            1233170438u,
+            3008501783u,
+            3905837878u,
+            1566704758u,
+            2380919351u,
+            159980022u,
+            1334100319u,
+            2492554074u,
+            137995234u,
+            2318192908u,
+            2608964837u,
+            1061756617u,
+            2760140790u,
+            4069446576u,
+            1995030350u,
+            1037005594u,
+            3489306635u,
+            1588786838u,
+            513304862u,
+            3305490303u,
+            2264317975u,
+            3441620307u,
+            4116970950u,
+            3121104936u,
+            1889858928u,
+            2336693483u,
+            3906421686u,
+            2112501080u,
+            2916376262u,
+            2244436629u,
+            663123276u,
+            774309763u,
+            258379821u,
+            3845948150u,
+            3747409682u,
+            275936617u,
+            563064995u,
+            4049677403u,
+            2099547498u,
+            699768412u,
+            1193153383u,
+            4289059706u,
+            3228950241u,
+            1258043728u,
+            1334659727u,
+            3780523664u,
+            1150773584u,
+            2509712235u,
+            2088544320u,
+            1610096547u,
+            3486280247u,
+            1737969289u,
+            1530372860u,
+            2563496419u,
+            2535243890u,
+            998106254u,
+            816066803u,
+            1138534811u,
+            1405672211u,
+            2094652173u,
+            1516292650u,
+            2618233360u,
+            3603340340u,
+            247950637u,
+            119238855u,
+            1858201484u,
+            3459729922u,
+            157759693u,
+            8278624u,
+            3223944237u,
+            3937209237u,
+            3820737454u,
+            839194830u,
+            2385155004u,
+            3872251779u,
+            1375779033u,
+            2333521764u,
+            4025446588u,
+            3839106064u,
+            374878047u,
+            1312756310u,
+            1661068116u,
+            1321601295u,
+            4254646350u,
+            3813168945u,
+            134103711u,
+            1535586498u,
+            82369644u,
+            411323516u,
+            761969086u,
+            819179215u,
+            582595825u,
+            3212591411u,
+            665647256u,
+            2372804634u,
+            2378814089u,
+            801724318u,
+            658137482u,
+            2084329677u,
+            2512952888u,
+            1573871611u,
+            570440739u,
+            3791634131u,
+            1754412850u,
+            406040873u,
+            2576963615u,
+            535767962u,
+            1405150444u,
+            3050488583u,
+            3870648463u,
+            2201665400u,
+            178518008u,
+            1050761986u,
+            1635790851u,
+            2757604743u,
+            1194306620u,
+            3895813535u,
+            259506203u,
+            1836108753u,
+            555242075u,
+            2574778399u,
+            777988603u,
+            2306149504u,
+            2810362568u,
+            402408487u,
+            2163697780u,
+            1982851065u,
+            153191404u,
+            1346605886u,
+            197579289u,
+            3847665347u,
+            2437615293u,
+            819252195u,
+            3379927756u,
+            1375088563u,
+            2650550959u,
+            2949512074u,
+            3616578300u,
+            1616680753u,
+            1943918335u,
+            2372676669u,
+            599487215u,
+            2422499758u,
+            3164569986u,
+            594265585u,
+            667867933u,
+            2382753501u,
+            1213715652u,
+            1470661916u,
+            566771851u,
+            463440918u,
+            3056034602u,
+            4101174909u,
+            130576467u,
+            2390765932u,
+            1878895359u,
+            2047260663u,
+            3236801323u,
+            1417182786u,
+            2650291174u,
+            541535507u,
+            2050658788u,
+            1497955566u,
+            2322165653u,
+            2177087336u,
+            1286897331u,
+            1168276780u,
+            2296212785u,
+            865258239u,
+            1996766009u,
+            2012854679u,
+            1601388981u,
+            2613134235u,
+            1657591526u,
+            2928355430u,
+            3608354462u,
+            744304148u,
+            4205438799u,
+            3436255438u,
+            2852837451u,
+            3546154475u,
+            2198801660u,
+            2941229067u,
+            1725744406u,
+            1576016233u,
+            326273484u,
+            3350602572u,
+            2525026956u,
+            529269391u,
+            742537386u,
+            966948684u,
+            4207482684u,
+            1647708147u,
+            772473614u,
+            4100132656u,
+            2071821864u,
+            1304991378u,
+            2104686786u,
+            494532571u,
+            1596637043u,
+            3530310572u,
+            3844404338u,
+            311529967u,
+            2146085784u,
+            1023590767u,
+            3264294551u,
+            1868912500u,
+            1616049700u,
+            4044971489u,
+            226083499u,
+            2644402452u,
+            671262u,
+            3856282165u,
+            2788249556u,
+            2975877350u,
+            3022011519u,
+            482463024u,
+            3197313892u,
+            2458947070u,
+            213085732u,
+            3423982376u,
+            1127434251u,
+            3003351323u,
+            3859782824u,
+            1452447943u,
+            1377205388u,
+            294467710u,
+            4017757977u,
+            4176004933u,
+            1973840971u,
+            1057204069u,
+            2631053578u,
+            1518315828u,
+            1733084351u,
+            2897935365u,
+            371135589u,
+            2166429075u,
+            1316999184u,
+            917942378u,
+            4234919037u,
+            3994887147u,
+            202839671u,
+            2611806597u,
+            1763402132u,
+            2528354843u,
+            2928374144u,
+            4287461088u,
+            3374274817u,
+            2515840515u,
+            1174711579u,
+            1526125414u,
+            1328334421u,
+            1467789564u,
+            746112865u,
+            2522923249u,
+            2846786366u,
+            785624778u,
+            3640382502u,
+            699425627u,
+            2333340032u,
+            879149811u,
+            1012137370u,
+            3671295088u,
+            1115225691u,
+            2008076767u,
+            3224593008u,
+            409074767u,
+            3405081375u,
+            1732184447u,
+            4131742042u,
+            2887579728u,
+            411122719u,
+            49575303u,
+            2452487329u,
+            132404436u,
+            2634269867u,
+            628865612u,
+            2089064207u,
+            3493619675u,
+            573570698u,
+            2803401952u,
+            1846326706u,
+            2776480783u,
+            3202282367u,
+            161406647u,
+            555882857u,
+            3002347158u,
+            3646590134u,
+            3970439001u,
+            3593229755u,
+            589030935u,
+            1156189491u,
+            4233262968u,
+            1884160487u,
+            1538393768u,
+            2259575756u,
+            1419917258u,
+            658738179u,
+            2762821193u,
+            3753817926u,
+            760570680u,
+            900223123u,
+            3199204483u,
+            3152387802u,
+            3518662321u,
+            1138026800u,
+            4166103824u,
+            4256962887u,
+            3860671603u,
+            2476911454u,
+            336216996u,
+            708885235u,
+            725397672u,
+            1803116762u,
+            2785555576u,
+            101740015u,
+            4078718445u,
+            1955237214u,
+            9650972u,
+            449296169u,
+            584729435u,
+            3295180521u,
+            589654348u,
+            4256205129u,
+            3872811168u,
+            1159848257u,
+            3914402308u,
+            739056677u,
+            2654817235u,
+            2975781832u,
+            2945335776u,
+            2792662538u,
+            4124362519u,
+            1578034244u,
+            347127450u,
+            818851140u,
+            2127100315u,
+            2486499071u,
+            4198130806u,
+            1869105609u,
+            1961961717u,
+            1651285423u,
+            376774848u,
+            2681263019u,
+            1185959234u,
+            1674813864u,
+            32812913u,
+            3511671436u,
+            3250344299u,
+            2961919237u,
+            722029715u,
+            3677835234u,
+            3534013806u,
+            2896926420u,
+            2405611392u,
+            1523923100u,
+            538451356u,
+            2872548905u,
+            3122230170u,
+            337087364u,
+            2659340735u,
+            3849128055u,
+            556114376u,
+            1997152544u,
+            3761450839u,
+            3143779940u,
+            3256759779u,
+            2844565122u,
+            228442897u,
+            3589092287u,
+            786119294u,
+            4089515771u,
+            3720982051u,
+            1236422652u,
+            2002271241u,
+            98809947u,
+            1925281885u,
+            3856119646u,
+            3522402037u,
+            2119723860u,
+            3500067577u,
+            3688915105u,
+            443441159u,
+            1795715271u,
+            2772968214u,
+            921416086u,
+            4274010930u,
+            3123194886u,
+            4156595625u,
+            2153773382u,
+            1880645824u,
+            1783695477u,
+            2639075904u,
+            2369609874u,
+            2020298024u,
+            3035677150u,
+            20152938u,
+            3700162244u,
+            2301383878u,
+            704787941u,
+            1912605772u,
+            801557569u,
+            3080244537u,
+            2116665331u,
+            2452111071u,
+            3506260614u,
+            862540580u,
+            1275699972u,
+            66210903u,
+            106773917u,
+            3693457478u,
+            2402783622u,
+            1239121180u,
+            676003037u,
+            2603048829u,
+            1725001637u,
+            1220274379u,
+            24507488u,
+            903764486u,
+            4189545897u,
+            1702746631u,
+            3218068652u,
+            3306659191u,
+            790973134u,
+            1265526960u,
+            3431804268u,
+            3325211765u,
+            3605213000u,
+            2877687268u,
+            2252987926u,
+            2380945092u,
+            858624424u,
+            1002964636u,
+            1862801950u,
+            1624111941u,
+            2506763607u,
+            760658520u,
+            2734479345u,
+            3411969548u,
+            771362694u,
+            3655222003u,
+            2713412965u,
+            2617767046u,
+            1779451182u,
+            3696950253u,
+            1494085808u,
+            1423735456u,
+            800705781u,
+            3797847307u,
+            3518984231u,
+            196474988u,
+            1813335502u,
+            2243046583u,
+            2578707704u,
+            2592488572u,
+            4085007200u,
+            3609770110u,
+            2731535571u,
+            3190540952u,
+            1865257805u,
+            1804143221u,
+            3166875197u,
+            1184225570u,
+            2013135819u,
+            3678444101u,
+            2569887572u,
+            3559018477u,
+            3823772506u,
+            1537738480u,
+            713705243u,
+            792081862u,
+            1581340885u,
+            3140030205u,
+            3435723625u,
+            3093218524u,
+            3683643763u,
+            753869336u,
+            590258834u,
+            608176704u,
+            180732483u,
+            31365344u,
+            29753898u,
+            2899243456u,
+            1020423361u,
+            152655309u,
+            3809554076u,
+            2069071231u,
+            4000441303u,
+            3046501174u,
+            1897816893u,
+            1610689080u,
+            2580357110u,
+            255270539u,
+            3363490012u,
+            3711397066u,
+            3983751767u,
+            1725231855u,
+            172296475u,
+            2179003295u,
+            660196982u,
+            526538193u,
+            2137670317u,
+            2219075701u,
+            1987239722u,
+            856404486u,
+            2976933454u,
+            3678014122u,
+            2713682703u,
+            3329090001u,
+            2248358519u,
+            3254616418u,
+            1747030903u,
+            1620566606u,
+            880370315u,
+            2337236788u,
+            2883145755u
+        };
+        const int n = 768;
+        unsigned b[n] = {0};
+        unsigned v[] = {3, 5, 7};
+        const int size = sizeof(v)/sizeof(v[0]);
+        std::seed_seq s(v, v + size);
+        s.generate(b, b + n);
+        for (int i = 0; i < n; ++i)
+            assert(a[i] == b[i]);
+    }
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp b/final/test/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp
new file mode 100644
index 0000000..d4ee9c1
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.seedseq/initializer_list.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class T>
+//     seed_seq(initializer_list<T> il);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    std::seed_seq s= {5, 4, 3, 2, 1};
+    assert(s.size() == 5);
+    unsigned b[5] = {0};
+    s.param(b);
+    assert(b[0] == 5);
+    assert(b[1] == 4);
+    assert(b[2] == 3);
+    assert(b[3] == 2);
+    assert(b[4] == 1);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp b/final/test/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp
new file mode 100644
index 0000000..2214dca
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.seedseq/iterator.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq;
+
+// template<class InputIterator>
+//     seed_seq(InputIterator begin, InputIterator end);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+    unsigned a[5] = {5, 4, 3, 2, 1};
+    std::seed_seq s(a, a+5);
+    assert(s.size() == 5);
+    unsigned b[5] = {0};
+    s.param(b);
+    assert(b[0] == 5);
+    assert(b[1] == 4);
+    assert(b[2] == 3);
+    assert(b[3] == 2);
+    assert(b[4] == 1);
+}
diff --git a/final/test/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp b/final/test/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp
new file mode 100644
index 0000000..430d9b7
--- /dev/null
+++ b/final/test/numerics/rand/rand.util/rand.util.seedseq/types.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class seed_seq
+// {
+// public:
+//     // types
+//     typedef uint_least32_t result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::seed_seq::result_type, std::uint_least32_t>::value), "");
+}
diff --git a/final/test/re/nothing_to_do.pass.cpp b/final/test/re/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/re/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.alg/nothing_to_do.pass.cpp b/final/test/re/re.alg/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/re/re.alg/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.alg/re.alg.match/awk.pass.cpp b/final/test/re/re.alg/re.alg.match/awk.pass.cpp
new file mode 100644
index 0000000..d2065a0
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/awk.pass.cpp
@@ -0,0 +1,1389 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT,
+//           class traits>
+//   bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                    match_results<BidirectionalIterator, Allocator>& m,
+//                    const basic_regex<charT, traits>& e,
+//                    regex_constants::match_flag_type flags
+//                                            = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+/*    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("a", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::awk)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::awk),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournamenttotour";
+        assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+               std::regex_constants::awk | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ttotour";
+        assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[a]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[ab]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_match(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(!std::regex_match(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_match(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+*/    {
+        std::cmatch m;
+        const char s[] = "m";
+       /* assert(std::regex_match(s, m,*/ std::regex("[a[=M=]z]"/*,
+                                                 std::regex_constants::awk*/);//));
+/*        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+*/    }
+/*    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::awk | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        const char r[] = "^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "\n\n\n";
+        assert(std::regex_match(s, m, std::regex("[\\n]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::awk),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournament";
+        assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournamenttotour";
+        assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+               std::regex_constants::awk | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ttotour";
+        assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::awk | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"\n\n\n";
+        assert(std::regex_match(s, m, std::wregex(L"[\\n]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+*/}
diff --git a/final/test/re/re.alg/re.alg.match/basic.fail.cpp b/final/test/re/re.alg/re.alg.match/basic.fail.cpp
new file mode 100644
index 0000000..d3b922c
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/basic.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+//   template <class ST, class SA, class Allocator, class charT, class traits> 
+//   bool regex_match(const basic_string<charT, ST, SA>&&, 
+//                    match_results<
+//                      typename basic_string<charT, ST, SA>::const_iterator, 
+//                      Allocator>&, 
+//                    const basic_regex<charT, traits>&, 
+//                    regex_constants::match_flag_type = 
+//                      regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::smatch m;
+        std::regex re{"*"};
+        std::regex_match(std::string("abcde"), m, re);
+    }
+}
+#endif
diff --git a/final/test/re/re.alg/re.alg.match/basic.pass.cpp b/final/test/re/re.alg/re.alg.match/basic.pass.cpp
new file mode 100644
index 0000000..55c7361
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/basic.pass.cpp
@@ -0,0 +1,1361 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        assert(!std::regex_match("a", m, std::regex()));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("a", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::basic)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::basic),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_match(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(!std::regex_match(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_match(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(!std::regex_match(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_match(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_match(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_match(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 1);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababbabb";
+        assert(std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "abb");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababbab";
+        assert(!std::regex_match(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aBAbbAbB";
+        assert(std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "Abb");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aBAbbAbB";
+        assert(!std::regex_match(s, m, std::regex("^\\(Ab*\\)*\\1$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[a]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[ab]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_match(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(!std::regex_match(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_match(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]\\{1,\\}",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+
+    {
+        std::wcmatch m;
+        assert(!std::regex_match(L"a", m, std::wregex()));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::basic),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_match(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(!std::regex_match(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_match(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(!std::regex_match(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_match(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_match(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 1);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababbabb";
+        assert(std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"abb");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababbab";
+        assert(!std::regex_match(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aBAbbAbB";
+        assert(std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"Abb");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aBAbbAbB";
+        assert(!std::regex_match(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.match/ecma.pass.cpp b/final/test/re/re.alg/re.alg.match/ecma.pass.cpp
new file mode 100644
index 0000000..162a6a7
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/ecma.pass.cpp
@@ -0,0 +1,1343 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("a")));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_match(s, m, std::regex("ab")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_match(s, m, std::regex("ba")));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab"),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("bc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_match(s, m, std::regex("ab*c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_match(s, m, std::regex("(ab)*c")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("^abc")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("^abc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_match(s, m, std::regex("^abc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("abc$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(!std::regex_match(s, m, std::regex("abc$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_match(s, m, std::regex("abc$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_match(s, m, std::regex("(.*).*")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(!std::regex_match(s, m, std::regex("(a*)*")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_match(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournamenttotour";
+        assert(!std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+               std::regex_constants::nosubs)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ttotour";
+        assert(std::regex_match(s, m, std::regex("(tour|to|t)+")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(!std::regex_match(s, m, std::regex("-(.*),\1-")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_match(s, m, std::regex("-.*,.*-")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[a]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[ab]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_match(s, m, std::regex("^[a-f]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_match(s, m, std::regex("^[a-f]$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(!std::regex_match(s, m, std::regex("q[^u]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_match(s, m, std::regex("q[^u]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]")));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(std::regex_match(s, m, std::regex("[a[=M=]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "foobar";
+        assert(std::regex_match(s, m, std::regex("[^\\0]*")));
+        assert(m.size() == 1);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "foo\0bar";
+        assert(std::regex_match(s, s+7, m, std::regex("[abfor\\0]*")));
+        assert(m.size() == 1);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[=M=]z]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]*")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]+")));
+        assert(m.size() == 0);
+    }
+    {
+        const char r[] = "^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr));
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Jeff Jeffs ";
+        assert(!std::regex_match(s, m, std::regex("Jeff(?=s\\b)")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Jeffs Jeff";
+        assert(!std::regex_match(s, m, std::regex("Jeff(?!s\\b)")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "5%k";
+        assert(std::regex_match(s, m, std::regex("\\d[\\W]k")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"a")));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_match(s, m, std::wregex(L"ab")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_match(s, m, std::wregex(L"ba")));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab"),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"bc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab*c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_match(s, m, std::wregex(L"(ab)*c")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"^abc")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"abc$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_match(s, m, std::wregex(L"(.*).*")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(!std::regex_match(s, m, std::wregex(L"(a*)*")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournament";
+        assert(!std::regex_match(s, m, std::wregex(L"tour|to|tournament")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournamenttotour";
+        assert(!std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+               std::regex_constants::nosubs)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ttotour";
+        assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_match(s, m, std::wregex(L"-.*,.*-")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[a]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[ab]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]")));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+")));
+        assert(m.size() == 0);
+    }
+    {
+        const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr));
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Jeff Jeffs ";
+        assert(!std::regex_match(s, m, std::wregex(L"Jeff(?=s\\b)")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Jeffs Jeff";
+        assert(!std::regex_match(s, m, std::wregex(L"Jeff(?!s\\b)")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"5%k";
+        assert(std::regex_match(s, m, std::wregex(L"\\d[\\W]k")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.match/egrep.pass.cpp b/final/test/re/re.alg/re.alg.match/egrep.pass.cpp
new file mode 100644
index 0000000..dd2e603
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/egrep.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+                std::regex_constants::egrep)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 10);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tournament");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ment";
+        assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+                std::regex_constants::egrep)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+                std::regex_constants::egrep)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 10);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tournament");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tourna";
+        assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
+                std::regex_constants::egrep)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tourna");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.match/extended.pass.cpp b/final/test/re/re.alg/re.alg.match/extended.pass.cpp
new file mode 100644
index 0000000..683f65b
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/extended.pass.cpp
@@ -0,0 +1,1357 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("a", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_match(s, m, std::regex("ba", std::regex_constants::extended)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_match(s, m, std::regex("ab", std::regex_constants::extended),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("bc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_match(s, m, std::regex("ab*c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_match(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(!std::regex_match(s, m, std::regex("cd((e)fg)hi",
+                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_match(s, m, std::regex("^abc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_match(s, m, std::regex("abc$", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_match(s, m, std::regex("a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_match(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(!std::regex_match(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_match(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_match(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_match(s, m, std::regex("tour|to|tournament",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournamenttotour";
+        assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+",
+               std::regex_constants::extended | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ttotour";
+        assert(std::regex_match(s, m, std::regex("(tour|to|t)+",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(!std::regex_match(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[a]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_match(s, m, std::regex("^[ab]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_match(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_match(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(!std::regex_match(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_match(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_match(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_match(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_match(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(std::regex_match(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_match(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::extended | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_match(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]*",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(!std::regex_match(s, m, std::regex("[ace1-9]+",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        const char r[] = "^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"a", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_match(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_match(s, m, std::wregex(L"ab", std::regex_constants::extended),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_match(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(!std::regex_match(s, m, std::wregex(L"cd((e)fg)hi",
+                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_match(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_match(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_match(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_match(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(!std::regex_match(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_match(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_match(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournament";
+        assert(std::regex_match(s, m, std::wregex(L"tour|to|tournament",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournamenttotour";
+        assert(std::regex_match(s, m, std::wregex(L"(tour|to|tournament)+",
+               std::regex_constants::extended | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ttotour";
+        assert(std::regex_match(s, m, std::wregex(L"(tour|to|t)+",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(!std::regex_match(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[a]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_match(s, m, std::wregex(L"^[ab]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_match(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_match(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_match(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_match(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_match(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::extended | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_match(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]*",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(!std::regex_match(s, m, std::wregex(L"[ace1-9]+",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_match(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.match/grep.pass.cpp b/final/test/re/re.alg/re.alg.match/grep.pass.cpp
new file mode 100644
index 0000000..2dc0966
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/grep.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
+                std::regex_constants::grep)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 10);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tournament");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ment";
+        assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
+                std::regex_constants::grep)));
+        assert(m.size() == 0);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.match/lookahead_capture.pass.cpp b/final/test/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
new file mode 100644
index 0000000..78e1e65
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// std::regex in ECMAScript mode should not ignore capture groups inside lookahead assertions. 
+// For example, matching /(?=(a))(a)/ to "a" should yield two captures: \1 = "a", \2 = "a"
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::regex re{"^(?=(.))a$"};
+        assert(re.mark_count() == 1);
+
+        std::string s{"a"};
+        std::smatch m;
+        assert(std::regex_match(s, m, re));
+        assert(m.size() == 2);
+        assert(m[0] == "a");
+        assert(m[1] == "a");
+    }
+
+    {
+        std::regex re{"^(a)(?=(.))(b)$"};
+        assert(re.mark_count() == 3);
+
+        std::string s{"ab"};
+        std::smatch m;
+        assert(std::regex_match(s, m, re));
+        assert(m.size() == 4);
+        assert(m[0] == "ab");
+        assert(m[1] == "a");
+        assert(m[2] == "b");
+        assert(m[3] == "b");
+    }
+
+    {
+        std::regex re{"^(.)(?=(.)(?=.(.)))(...)$"};
+        assert(re.mark_count() == 4);
+
+        std::string s{"abcd"};
+        std::smatch m;
+        assert(std::regex_match(s, m, re));
+        assert(m.size() == 5);
+        assert(m[0] == "abcd");
+        assert(m[1] == "a");
+        assert(m[2] == "b");
+        assert(m[3] == "d");
+        assert(m[4] == "bcd");
+    }
+
+    {
+        std::regex re{"^(a)(?!([^b]))(.c)$"};
+        assert(re.mark_count() == 3);
+
+        std::string s{"abc"};
+        std::smatch m;
+        assert(std::regex_match(s, m, re));
+        assert(m.size() == 4);
+        assert(m[0] == "abc");
+        assert(m[1] == "a");
+        assert(m[2] == "");
+        assert(m[3] == "bc");
+    }
+
+    {
+        std::regex re{"^(?!((b)))(?=(.))(?!(abc)).b$"};
+        assert(re.mark_count() == 4);
+
+        std::string s{"ab"};
+        std::smatch m;
+        assert(std::regex_match(s, m, re));
+        assert(m.size() == 5);
+        assert(m[0] == "ab");
+        assert(m[1] == "");
+        assert(m[2] == "");
+        assert(m[3] == "a");
+        assert(m[4] == "");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp b/final/test/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
new file mode 100644
index 0000000..6a45418
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_match(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16135
+
+#include <string>
+#include <regex>
+#include <cassert>
+
+void
+test1()
+{
+    std::string re{"\\{a\\}"};
+    std::string target{"{a}"};
+    std::regex regex{re};
+    std::smatch smatch;
+    assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test2()
+{
+    std::string re{"\\{a\\}"};
+    std::string target{"{a}"};
+    std::regex regex{re, std::regex::extended};
+    std::smatch smatch;
+    assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test3()
+{
+    std::string re{"\\{a\\}"};
+    std::string target{"{a}"};
+    std::regex regex{re, std::regex::awk};
+    std::smatch smatch;
+    assert((std::regex_match(target, smatch, regex)));
+}
+
+void
+test4()
+{
+    std::string re{"\\{a\\}"};
+    std::string target{"{a}"};
+    std::regex regex{re, std::regex::egrep};
+    std::smatch smatch;
+    assert((std::regex_match(target, smatch, regex)));
+}
+
+int
+main()
+{
+    test1();
+    test2();
+    test3();
+    test4();
+}
diff --git a/final/test/re/re.alg/re.alg.replace/test1.pass.cpp b/final/test/re/re.alg/re.alg.replace/test1.pass.cpp
new file mode 100644
index 0000000..9fd84fd
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.replace/test1.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class OutputIterator, class BidirectionalIterator,
+//           class traits, class charT, class ST, class SA>
+//     OutputIterator
+//     regex_replace(OutputIterator out,
+//                   BidirectionalIterator first, BidirectionalIterator last,
+//                   const basic_regex<charT, traits>& e,
+//                   const basic_string<charT, ST, SA>& fmt,
+//                   regex_constants::match_flag_type flags =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    std::string("123-$&"));
+        assert(r.base() == buf+40);
+        assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    std::string("123-$&"),
+                                    std::regex_constants::format_sed);
+        assert(r.base() == buf+43);
+        assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    std::string("123-&"),
+                                    std::regex_constants::format_sed);
+        assert(r.base() == buf+40);
+        assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    std::string("123-$&"),
+                                    std::regex_constants::format_no_copy);
+        assert(r.base() == buf+36);
+        assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    std::string("123-$&"),
+                                    std::regex_constants::format_first_only);
+        assert(r.base() == buf+32);
+        assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    std::string("123-$&"),
+                                    std::regex_constants::format_first_only |
+                                    std::regex_constants::format_no_copy);
+        assert(r.base() == buf+12);
+        assert(buf == std::string("123-555-1234"));
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.replace/test2.pass.cpp b/final/test/re/re.alg/re.alg.replace/test2.pass.cpp
new file mode 100644
index 0000000..63a4ed5
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.replace/test2.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class OutputIterator, class BidirectionalIterator,
+//           class traits, class charT, class ST, class SA>
+//     OutputIterator
+//     regex_replace(OutputIterator out,
+//                   BidirectionalIterator first, BidirectionalIterator last,
+//                   const basic_regex<charT, traits>& e,
+//                   const charT* fmt,
+//                   regex_constants::match_flag_type flags =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    "123-$&");
+        assert(r.base() == buf+40);
+        assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    "123-$&",
+                                    std::regex_constants::format_sed);
+        assert(r.base() == buf+43);
+        assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    "123-&",
+                                    std::regex_constants::format_sed);
+        assert(r.base() == buf+40);
+        assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    "123-$&",
+                                    std::regex_constants::format_no_copy);
+        assert(r.base() == buf+36);
+        assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    "123-$&",
+                                    std::regex_constants::format_first_only);
+        assert(r.base() == buf+32);
+        assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        typedef output_iterator<char*> Out;
+        typedef bidirectional_iterator<const char*> Bi;
+        char buf[100] = {0};
+        Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
+                                    Bi(std::end(phone_book)-1), phone_numbers,
+                                    "123-$&",
+                                    std::regex_constants::format_first_only |
+                                    std::regex_constants::format_no_copy);
+        assert(r.base() == buf+12);
+        assert(buf == std::string("123-555-1234"));
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.replace/test3.pass.cpp b/final/test/re/re.alg/re.alg.replace/test3.pass.cpp
new file mode 100644
index 0000000..d116786
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.replace/test3.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA, class FST, class FSA>>
+//     basic_string<charT, ST, SA>
+//     regex_replace(const basic_string<charT, ST, SA>& s,
+//                   const basic_regex<charT, traits>& e,
+//                   const basic_string<charT, FST, FSA>& fmt,
+//                   regex_constants::match_flag_type flags =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"));
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_sed);
+        assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-&"),
+                                           std::regex_constants::format_sed);
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234123-555-2345123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_first_only);
+        assert(r == "123-555-1234, 555-2345, 555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_first_only |
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.replace/test4.pass.cpp b/final/test/re/re.alg/re.alg.replace/test4.pass.cpp
new file mode 100644
index 0000000..fba1bc1
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.replace/test4.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA>
+//     basic_string<charT, ST, SA>
+//     regex_replace(const basic_string<charT, ST, SA>& s,
+//                   const basic_regex<charT, traits>& e, const charT* fmt,
+//                   regex_constants::match_flag_type flags =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&");
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_sed);
+        assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-&",
+                                           std::regex_constants::format_sed);
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234123-555-2345123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_first_only);
+        assert(r == "123-555-1234, 555-2345, 555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        std::string phone_book("555-1234, 555-2345, 555-3456");
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_first_only |
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.replace/test5.pass.cpp b/final/test/re/re.alg/re.alg.replace/test5.pass.cpp
new file mode 100644
index 0000000..7190e41
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.replace/test5.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT, class ST, class SA>
+//     basic_string<charT>
+//     regex_replace(const charT* s,
+//                   const basic_regex<charT, traits>& e,
+//                   const basic_string<charT, ST, SA>& fmt,
+//                   regex_constants::match_flag_type flags =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"));
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_sed);
+        assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-&"),
+                                           std::regex_constants::format_sed);
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234123-555-2345123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_first_only);
+        assert(r == "123-555-1234, 555-2345, 555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           std::string("123-$&"),
+                                           std::regex_constants::format_first_only |
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.replace/test6.pass.cpp b/final/test/re/re.alg/re.alg.replace/test6.pass.cpp
new file mode 100644
index 0000000..b017800
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.replace/test6.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class traits, class charT>
+//     basic_string<charT>
+//     regex_replace(const charT* s,
+//                   const basic_regex<charT, traits>& e,
+//                   const charT* fmt,
+//                   regex_constants::match_flag_type flags =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&");
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_sed);
+        assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-&",
+                                           std::regex_constants::format_sed);
+        assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234123-555-2345123-555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_first_only);
+        assert(r == "123-555-1234, 555-2345, 555-3456");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::string r = std::regex_replace(phone_book, phone_numbers,
+                                           "123-$&",
+                                           std::regex_constants::format_first_only |
+                                           std::regex_constants::format_no_copy);
+        assert(r == "123-555-1234");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/awk.pass.cpp b/final/test/re/re.alg/re.alg.search/awk.pass.cpp
new file mode 100644
index 0000000..57606c1
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/awk.pass.cpp
@@ -0,0 +1,1568 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("a", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::awk)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::awk),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "bc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+                                 std::regex_constants::awk)));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == "cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == "efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == "e");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "abc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournamenttotour";
+        assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+               std::regex_constants::awk | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ttotour";
+        assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[a]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[ab]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_search(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(std::regex_search(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == "qi");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_search(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::awk | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "1a45ce");
+    }
+    {
+        const char r[] = "^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "\n\n\n";
+        assert(std::regex_search(s, m, std::regex("[\\n]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::awk)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::awk),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"bc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+                                 std::regex_constants::awk)));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == L"cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == L"efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == L"e");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"abc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournament";
+        assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournamenttotour";
+        assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+               std::regex_constants::awk | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ttotour";
+        assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+                                              std::regex_constants::awk)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == L"qi");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::awk | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"1a45ce");
+    }
+    {
+        const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr), std::regex_constants::awk);
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"\n\n\n";
+        assert(std::regex_search(s, m, std::wregex(L"[\\n]+",
+                                                 std::regex_constants::awk)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/backup.pass.cpp b/final/test/re/re.alg/re.alg.search/backup.pass.cpp
new file mode 100644
index 0000000..6bfad42
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/backup.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <string>
+#include <list>
+#include <cassert>
+
+int main()
+{
+    // This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...)
+    // Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273.
+    {
+        std::string s{"aaaa a"};
+        std::regex re{"\\ba"};
+        std::sregex_iterator it{s.begin(), s.end(), re};
+        std::sregex_iterator end{};
+
+        assert(it->position(0) == 0);
+        assert(it->length(0) == 1);
+
+        ++it;
+        assert(it->position(0) == 5);
+        assert(it->length(0) == 1);
+
+        ++it;
+        assert(it == end);
+    }
+
+    // This regex_iterator uses regex_search(_BidirectionalIterator __first, ...)
+    {
+        std::string s{"aaaa a"};
+        std::list<char> l{s.begin(), s.end()};
+        std::regex re{"\\ba"};
+        std::regex_iterator<std::list<char>::iterator> it{l.begin(), l.end(), re};
+        std::regex_iterator<std::list<char>::iterator> end{};
+
+        assert(it->position(0) == 0);
+        assert(it->length(0) == 1);
+
+        ++it;
+        assert(it->position(0) == 5);
+        assert(it->length(0) == 1);
+
+        ++it;
+        assert(it == end);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/basic.fail.cpp b/final/test/re/re.alg/re.alg.search/basic.fail.cpp
new file mode 100644
index 0000000..692ee94
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/basic.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+//   template <class ST, class SA, class Allocator, class charT, class traits> 
+//   bool regex_search(const basic_string<charT, ST, SA>&&, 
+//                     match_results<
+//                       typename basic_string<charT, ST, SA>::const_iterator, 
+//                       Allocator>&, 
+//                     const basic_regex<charT, traits>&, 
+//                     regex_constants::match_flag_type = 
+//                       regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::smatch m;
+        std::regex re{"*"};
+        std::regex_search(std::string("abcde"), m, re);
+    }
+}
+#endif
diff --git a/final/test/re/re.alg/re.alg.search/basic.pass.cpp b/final/test/re/re.alg/re.alg.search/basic.pass.cpp
new file mode 100644
index 0000000..56396f3
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/basic.pass.cpp
@@ -0,0 +1,1541 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        assert(!std::regex_search("a", m, std::regex()));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("a", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::basic)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::basic),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "bc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_search(s, m, std::regex("\\(ab\\)*c", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd\\(\\(e\\)fg\\)hi",
+                                 std::regex_constants::basic)));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == "cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == "efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == "e");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "abc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_search(s, m, std::regex("\\(.*\\).*", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(std::regex_search(s, m, std::regex("\\(a*\\)*", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_search(s, m, std::regex("ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == sizeof(s)-1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_search(s, m, std::regex("a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_search(s, m, std::regex("-\\(.*\\),\\1-", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 1);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababbabb";
+        assert(std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "abb");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababbab";
+        assert(!std::regex_search(s, m, std::regex("^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aBAbbAbB";
+        assert(std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "Abb");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aBAbbAbB";
+        assert(!std::regex_search(s, m, std::regex("^\\(Ab*\\)*\\1$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[a]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[ab]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_search(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(std::regex_search(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == "qi");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_search(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]\\{1,\\}",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "1a45ce");
+    }
+    {
+        const char r[] = "^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+
+    {
+        std::wcmatch m;
+        assert(!std::regex_search(L"a", m, std::wregex()));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::basic)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::basic),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"bc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_search(s, m, std::wregex(L"\\(ab\\)*c", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd\\(\\(e\\)fg\\)hi",
+                                 std::regex_constants::basic)));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == L"cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == L"efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == L"e");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"abc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_search(s, m, std::wregex(L"\\(.*\\).*", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(std::regex_search(s, m, std::wregex(L"\\(a*\\)*", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_search(s, m, std::wregex(L"a.\\{3,5\\}c", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_search(s, m, std::wregex(L"-\\(.*\\),\\1-", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 1);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababbabb";
+        assert(std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"abb");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababbab";
+        assert(!std::regex_search(s, m, std::wregex(L"^\\(ab*\\)*\\1$", std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aBAbbAbB";
+        assert(std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"Abb");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aBAbbAbB";
+        assert(!std::regex_search(s, m, std::wregex(L"^\\(Ab*\\)*\\1$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == L"qi");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::basic | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]\\{1,\\}",
+                                                 std::regex_constants::basic)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"1a45ce");
+    }
+    {
+        const wchar_t r[] = L"^[-+]\\{0,1\\}[0-9]\\{1,\\}[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr), std::regex_constants::basic);
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/ecma.pass.cpp b/final/test/re/re.alg/re.alg.search/ecma.pass.cpp
new file mode 100644
index 0000000..8149157
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/ecma.pass.cpp
@@ -0,0 +1,1583 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("a")));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_search(s, m, std::regex("ab")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_search(s, m, std::regex("ba")));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(std::regex_search(s, m, std::regex("ab")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_search(s, m, std::regex("ab"),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("bc")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "bc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_search(s, m, std::regex("ab*c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_search(s, m, std::regex("(ab)*c")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == "cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == "efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == "e");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("^abc")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("^abc")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "abc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_search(s, m, std::regex("^abc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("abc$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(std::regex_search(s, m, std::regex("abc$")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_search(s, m, std::regex("abc$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_search(s, m, std::regex("(.*).*")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(std::regex_search(s, m, std::regex("(a*)*")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_search(s, m, std::regex("a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_search(s, m, std::regex("tour|to|tournament")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournamenttotour";
+        assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+               std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ttotour";
+        assert(std::regex_search(s, m, std::regex("(tour|to|t)+")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(!std::regex_search(s, m, std::regex("-(.*),\1-")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_search(s, m, std::regex("-.*,.*-")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[a]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[ab]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_search(s, m, std::regex("^[a-f]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_search(s, m, std::regex("^[a-f]$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(std::regex_search(s, m, std::regex("q[^u]")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == "qi");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_search(s, m, std::regex("q[^u]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]")));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(std::regex_search(s, m, std::regex("[a[=M=]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[=M=]z]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]*")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]+")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "1a45ce");
+    }
+    {
+        const char r[] = "^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr));
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Jeff Jeffs ";
+        assert(std::regex_search(s, m, std::regex("Jeff(?=s\\b)")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 5);
+        assert(m.str(0) == "Jeff");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Jeffs Jeff";
+        assert(std::regex_search(s, m, std::regex("Jeff(?!s\\b)")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 6);
+        assert(m.str(0) == "Jeff");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "5%k";
+        assert(std::regex_search(s, m, std::regex("\\d[\\W]k")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"a")));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_search(s, m, std::wregex(L"ab")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_search(s, m, std::wregex(L"ba")));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(std::regex_search(s, m, std::wregex(L"ab")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_search(s, m, std::wregex(L"ab"),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"bc")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"bc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab*c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_search(s, m, std::wregex(L"(ab)*c")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == L"cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == L"efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == L"e");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"^abc")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"^abc")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"abc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_search(s, m, std::wregex(L"^abc")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_search(s, m, std::wregex(L"abc$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_search(s, m, std::wregex(L"(.*).*")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(std::regex_search(s, m, std::wregex(L"(a*)*")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournament";
+        assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournamenttotour";
+        assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+               std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ttotour";
+        assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+")));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_search(s, m, std::wregex(L"-.*,.*-")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[a]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[ab]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(std::regex_search(s, m, std::wregex(L"q[^u]")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == L"qi");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_search(s, m, std::wregex(L"q[^u]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]")));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]")));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"1a45ce");
+    }
+    {
+        const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr));
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Jeff Jeffs ";
+        assert(std::regex_search(s, m, std::wregex(L"Jeff(?=s\\b)")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 5);
+        assert(m.str(0) == L"Jeff");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Jeffs Jeff";
+        assert(std::regex_search(s, m, std::wregex(L"Jeff(?!s\\b)")));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 6);
+        assert(m.str(0) == L"Jeff");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"5%k";
+        assert(std::regex_search(s, m, std::wregex(L"\\d[\\W]k")));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/egrep.pass.cpp b/final/test/re/re.alg/re.alg.search/egrep.pass.cpp
new file mode 100644
index 0000000..1dffed4
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/egrep.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+                std::regex_constants::egrep)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 10);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tournament");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ment";
+        assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+                std::regex_constants::egrep)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+                std::regex_constants::egrep)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 10);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tournament");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tourna";
+        assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+\ntourna",
+                std::regex_constants::egrep)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tourna");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/extended.pass.cpp b/final/test/re/re.alg/re.alg.search/extended.pass.cpp
new file mode 100644
index 0000000..8240872
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/extended.pass.cpp
@@ -0,0 +1,1537 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("a", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ab";
+        assert(!std::regex_search(s, m, std::regex("ba", std::regex_constants::extended)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(std::regex_search(s, m, std::regex("ab", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aab";
+        assert(!std::regex_search(s, m, std::regex("ab", std::regex_constants::extended),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("bc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "bc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(std::regex_search(s, m, std::regex("ab*c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ababc";
+        assert(std::regex_search(s, m, std::regex("(ab)*c", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == "ab");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+                                 std::regex_constants::extended)));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<char>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == "cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == "efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == "e");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcd";
+        assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "abc");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "aabc";
+        assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabc";
+        assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "efabcg";
+        assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "acc";
+        assert(std::regex_search(s, m, std::regex("a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abcdef";
+        assert(std::regex_search(s, m, std::regex("(.*).*", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "bc";
+        assert(std::regex_search(s, m, std::regex("(a*)*", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbc";
+        assert(std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "abbbbbbc";
+        assert(!std::regex_search(s, m, std::regex("ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adec";
+        assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefgc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghc";
+        assert(std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "adefghic";
+        assert(!std::regex_search(s, m, std::regex("a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_search(s, m, std::regex("tour|to|tournament",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "tournamenttotour";
+        assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+               std::regex_constants::extended | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ttotour";
+        assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == "tour");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(!std::regex_search(s, m, std::regex("-(.*),\1-", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-ab,ab-";
+        assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[a]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "a";
+        assert(std::regex_search(s, m, std::regex("^[ab]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "a");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "c";
+        assert(std::regex_search(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "g";
+        assert(!std::regex_search(s, m, std::regex("^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraqi";
+        assert(std::regex_search(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == "qi");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Iraq";
+        assert(!std::regex_search(s, m, std::regex("q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(std::regex_search(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AMB";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "AmB";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A5B";
+        assert(!std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "A?B";
+        assert(std::regex_search(s, m, std::regex("A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "-";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "z";
+        assert(std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(std::regex_search(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "Ch";
+        assert(std::regex_search(s, m, std::regex("[a[.ch.]z]",
+                   std::regex_constants::extended | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<char>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::cmatch m;
+        const char s[] = "m";
+        assert(!std::regex_search(s, m, std::regex("[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]*",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "01a45cef9";
+        assert(std::regex_search(s, m, std::regex("[ace1-9]+",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == "1a45ce");
+    }
+    {
+        const char r[] = "^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<char>::length(r);
+        typedef forward_iterator<const char*> FI;
+        typedef bidirectional_iterator<const char*> BI;
+        std::regex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+        std::match_results<BI> m;
+        const char s[] = "-40C";
+        std::ptrdiff_t ss = std::char_traits<char>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"a", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.empty());
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+1);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ab";
+        assert(!std::regex_search(s, m, std::wregex(L"ba", std::regex_constants::extended)));
+        assert(m.size() == 0);
+        assert(m.empty());
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aab";
+        assert(!std::regex_search(s, m, std::wregex(L"ab", std::regex_constants::extended),
+                                            std::regex_constants::match_continuous));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"bc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"bc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab*c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ababc";
+        assert(std::regex_search(s, m, std::wregex(L"(ab)*c", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 5);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 2);
+        assert(m.position(1) == 2);
+        assert(m.str(1) == L"ab");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi",
+                                 std::regex_constants::extended)));
+        assert(m.size() == 3);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+std::regex_traits<wchar_t>::length(s));
+        assert(m.length(0) == 7);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == L"cdefghi");
+        assert(m.length(1) == 3);
+        assert(m.position(1) == 4);
+        assert(m.str(1) == L"efg");
+        assert(m.length(2) == 1);
+        assert(m.position(2) == 4);
+        assert(m.str(2) == L"e");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcd";
+        assert(std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+4);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"abc");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"aabc";
+        assert(!std::regex_search(s, m, std::wregex(L"^abc", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabc";
+        assert(std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+5);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 2);
+        assert(m.str(0) == s+2);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"efabcg";
+        assert(!std::regex_search(s, m, std::wregex(L"abc$", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"acc";
+        assert(std::regex_search(s, m, std::wregex(L"a.c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+3);
+        assert(m.length(0) == 3);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abcdef";
+        assert(std::regex_search(s, m, std::wregex(L"(.*).*", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+6);
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 6);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"bc";
+        assert(std::regex_search(s, m, std::wregex(L"(a*)*", std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s+2);
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+        assert(m.length(1) == 0);
+        assert(m.position(1) == 0);
+        assert(m.str(1) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbc";
+        assert(std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"abbbbbbc";
+        assert(!std::regex_search(s, m, std::wregex(L"ab{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adec";
+        assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefgc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghc";
+        assert(std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"adefghic";
+        assert(!std::regex_search(s, m, std::wregex(L"a.{3,5}c", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournament";
+        assert(std::regex_search(s, m, std::wregex(L"tour|to|tournament",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"tournamenttotour";
+        assert(std::regex_search(s, m, std::wregex(L"(tour|to|tournament)+",
+               std::regex_constants::extended | std::regex_constants::nosubs)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"ttotour";
+        assert(std::regex_search(s, m, std::wregex(L"(tour|to|t)+",
+                                              std::regex_constants::extended)));
+        assert(m.size() == 2);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+        assert(m.length(1) == 4);
+        assert(m.position(1) == 3);
+        assert(m.str(1) == L"tour");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(!std::regex_search(s, m, std::wregex(L"-(.*),\1-", std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-ab,ab-";
+        assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[a]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"a";
+        assert(std::regex_search(s, m, std::wregex(L"^[ab]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"a");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"c";
+        assert(std::regex_search(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 1);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"g";
+        assert(!std::regex_search(s, m, std::wregex(L"^[a-f]$",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraqi";
+        assert(std::regex_search(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 2);
+        assert(m.position(0) == 3);
+        assert(m.str(0) == L"qi");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Iraq";
+        assert(!std::regex_search(s, m, std::wregex(L"q[^u]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AMB";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"AmB";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A5B";
+        assert(!std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"A?B";
+        assert(std::regex_search(s, m, std::wregex(L"A[^[:lower:]0-9]B",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"-";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"z";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[.hyphen.]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"Ch";
+        assert(std::regex_search(s, m, std::wregex(L"[a[.ch.]z]",
+                   std::regex_constants::extended | std::regex_constants::icase)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == std::char_traits<wchar_t>::length(s));
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+    std::locale::global(std::locale("C"));
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"m";
+        assert(!std::regex_search(s, m, std::wregex(L"[a[=M=]z]",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 0);
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]*",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == L"");
+    }
+    {
+        std::wcmatch m;
+        const wchar_t s[] = L"01a45cef9";
+        assert(std::regex_search(s, m, std::wregex(L"[ace1-9]+",
+                                                 std::regex_constants::extended)));
+        assert(m.size() == 1);
+        assert(m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<wchar_t>::length(s));
+        assert(m.length(0) == 6);
+        assert(m.position(0) == 1);
+        assert(m.str(0) == L"1a45ce");
+    }
+    {
+        const wchar_t r[] = L"^[-+]?[0-9]+[CF]$";
+        std::ptrdiff_t sr = std::char_traits<wchar_t>::length(r);
+        typedef forward_iterator<const wchar_t*> FI;
+        typedef bidirectional_iterator<const wchar_t*> BI;
+        std::wregex regex(FI(r), FI(r+sr), std::regex_constants::extended);
+        std::match_results<BI> m;
+        const wchar_t s[] = L"-40C";
+        std::ptrdiff_t ss = std::char_traits<wchar_t>::length(s);
+        assert(std::regex_search(BI(s), BI(s+ss), m, regex));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == BI(s));
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == m[0].second);
+        assert(m.length(0) == 4);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == s);
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/grep.pass.cpp b/final/test/re/re.alg/re.alg.search/grep.pass.cpp
new file mode 100644
index 0000000..113243e
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/grep.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::cmatch m;
+        const char s[] = "tournament";
+        assert(std::regex_search(s, m, std::regex("tour\nto\ntournament",
+                std::regex_constants::grep)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(!m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 10);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "tournament");
+    }
+    {
+        std::cmatch m;
+        const char s[] = "ment";
+        assert(std::regex_search(s, m, std::regex("tour\n\ntournament",
+                std::regex_constants::grep)));
+        assert(m.size() == 1);
+        assert(!m.prefix().matched);
+        assert(m.prefix().first == s);
+        assert(m.prefix().second == m[0].first);
+        assert(m.suffix().matched);
+        assert(m.suffix().first == m[0].second);
+        assert(m.suffix().second == s + std::char_traits<char>::length(s));
+        assert(m.length(0) == 0);
+        assert(m.position(0) == 0);
+        assert(m.str(0) == "");
+    }
+}
diff --git a/final/test/re/re.alg/re.alg.search/lookahead.pass.cpp b/final/test/re/re.alg/re.alg.search/lookahead.pass.cpp
new file mode 100644
index 0000000..9f5f954
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/lookahead.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+// http://llvm.org/bugs/show_bug.cgi?id=11118
+
+#include <regex>
+#include <cassert>
+
+int main() 
+{
+    assert(!std::regex_search("ab", std::regex("(?=^)b")));
+    assert(!std::regex_search("ab", std::regex("a(?=^)b")));
+}
diff --git a/final/test/re/re.alg/re.alg.search/no_update_pos.pass.cpp b/final/test/re/re.alg/re.alg.search/no_update_pos.pass.cpp
new file mode 100644
index 0000000..63fcdaf
--- /dev/null
+++ b/final/test/re/re.alg/re.alg.search/no_update_pos.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator, class Allocator, class charT, class traits>
+//     bool
+//     regex_search(BidirectionalIterator first, BidirectionalIterator last,
+//                  match_results<BidirectionalIterator, Allocator>& m,
+//                  const basic_regex<charT, traits>& e,
+//                  regex_constants::match_flag_type flags = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    // Iterating over /^a/ should yield one instance at the beginning
+    // of the text.
+
+    const char *text = "aaa\naa";
+    std::regex re{"^a"};
+    std::cregex_iterator it{text, text+6, re};
+    std::cregex_iterator end{};
+
+    assert(it->str() == "a");
+    assert(it->position(0) == 0);
+    assert(it->length(0) == 1);
+
+    ++it;
+    assert(it == end);
+}
diff --git a/final/test/re/re.alg/re.except/nothing_to_do.pass.cpp b/final/test/re/re.alg/re.except/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/re/re.alg/re.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.badexp/regex_error.pass.cpp b/final/test/re/re.badexp/regex_error.pass.cpp
new file mode 100644
index 0000000..02fecbd
--- /dev/null
+++ b/final/test/re/re.badexp/regex_error.pass.cpp
@@ -0,0 +1,96 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_error
+//     : public runtime_error
+// {
+// public:
+//     explicit regex_error(regex_constants::error_type ecode);
+//     regex_constants::error_type code() const;
+// };
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex_error e(std::regex_constants::error_collate);
+        assert(e.code() == std::regex_constants::error_collate);
+        assert(e.what() == std::string("The expression contained an invalid collating element name."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_ctype);
+        assert(e.code() == std::regex_constants::error_ctype);
+        assert(e.what() == std::string("The expression contained an invalid character class name."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_escape);
+        assert(e.code() == std::regex_constants::error_escape);
+        assert(e.what() == std::string("The expression contained an invalid escaped character, or a "
+               "trailing escape."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_backref);
+        assert(e.code() == std::regex_constants::error_backref);
+        assert(e.what() == std::string("The expression contained an invalid back reference."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_brack);
+        assert(e.code() == std::regex_constants::error_brack);
+        assert(e.what() == std::string("The expression contained mismatched [ and ]."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_paren);
+        assert(e.code() == std::regex_constants::error_paren);
+        assert(e.what() == std::string("The expression contained mismatched ( and )."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_brace);
+        assert(e.code() == std::regex_constants::error_brace);
+        assert(e.what() == std::string("The expression contained mismatched { and }."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_badbrace);
+        assert(e.code() == std::regex_constants::error_badbrace);
+        assert(e.what() == std::string("The expression contained an invalid range in a {} expression."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_range);
+        assert(e.code() == std::regex_constants::error_range);
+        assert(e.what() == std::string("The expression contained an invalid character range, "
+               "such as [b-a] in most encodings."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_space);
+        assert(e.code() == std::regex_constants::error_space);
+        assert(e.what() == std::string("There was insufficient memory to convert the expression into "
+               "a finite state machine."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_badrepeat);
+        assert(e.code() == std::regex_constants::error_badrepeat);
+        assert(e.what() == std::string("One of *?+{ was not preceded by a valid regular expression."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_complexity);
+        assert(e.code() == std::regex_constants::error_complexity);
+        assert(e.what() == std::string("The complexity of an attempted match against a regular "
+               "expression exceeded a pre-set level."));
+    }
+    {
+        std::regex_error e(std::regex_constants::error_stack);
+        assert(e.code() == std::regex_constants::error_stack);
+        assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
+               "expression could match the specified character sequence."));
+    }
+}
diff --git a/final/test/re/re.const/nothing_to_do.pass.cpp b/final/test/re/re.const/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.const/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.const/re.err/error_type.pass.cpp b/final/test/re/re.const/re.err/error_type.pass.cpp
new file mode 100644
index 0000000..150855b
--- /dev/null
+++ b/final/test/re/re.const/re.err/error_type.pass.cpp
@@ -0,0 +1,143 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// enum error_type
+// {
+//     error_collate    = unspecified,
+//     error_ctype      = unspecified,
+//     error_escape     = unspecified,
+//     error_backref    = unspecified,
+//     error_brack      = unspecified,
+//     error_paren      = unspecified,
+//     error_brace      = unspecified,
+//     error_badbrace   = unspecified,
+//     error_range      = unspecified,
+//     error_space      = unspecified,
+//     error_badrepeat  = unspecified,
+//     error_complexity = unspecified,
+//     error_stack      = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    assert(std::regex_constants::error_collate != 0);
+    assert(std::regex_constants::error_ctype != 0);
+    assert(std::regex_constants::error_escape != 0);
+    assert(std::regex_constants::error_backref != 0);
+    assert(std::regex_constants::error_brack != 0);
+    assert(std::regex_constants::error_paren != 0);
+    assert(std::regex_constants::error_brace != 0);
+    assert(std::regex_constants::error_badbrace != 0);
+    assert(std::regex_constants::error_range != 0);
+    assert(std::regex_constants::error_space != 0);
+    assert(std::regex_constants::error_badrepeat != 0);
+    assert(std::regex_constants::error_complexity != 0);
+    assert(std::regex_constants::error_stack != 0);
+
+    assert(std::regex_constants::error_collate != std::regex_constants::error_ctype);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_escape);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_backref);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_brack);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_paren);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_brace);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_badbrace);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_range);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_space);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_collate != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_escape);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_backref);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_brack);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_paren);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_brace);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_badbrace);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_range);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_space);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_ctype != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_escape != std::regex_constants::error_backref);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_brack);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_paren);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_brace);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_badbrace);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_range);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_space);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_escape != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_backref != std::regex_constants::error_brack);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_paren);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_brace);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_badbrace);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_range);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_space);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_backref != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_brack != std::regex_constants::error_paren);
+    assert(std::regex_constants::error_brack != std::regex_constants::error_brace);
+    assert(std::regex_constants::error_brack != std::regex_constants::error_badbrace);
+    assert(std::regex_constants::error_brack != std::regex_constants::error_range);
+    assert(std::regex_constants::error_brack != std::regex_constants::error_space);
+    assert(std::regex_constants::error_brack != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_brack != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_brack != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_paren != std::regex_constants::error_brace);
+    assert(std::regex_constants::error_paren != std::regex_constants::error_badbrace);
+    assert(std::regex_constants::error_paren != std::regex_constants::error_range);
+    assert(std::regex_constants::error_paren != std::regex_constants::error_space);
+    assert(std::regex_constants::error_paren != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_paren != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_paren != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_brace != std::regex_constants::error_badbrace);
+    assert(std::regex_constants::error_brace != std::regex_constants::error_range);
+    assert(std::regex_constants::error_brace != std::regex_constants::error_space);
+    assert(std::regex_constants::error_brace != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_brace != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_brace != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_badbrace != std::regex_constants::error_range);
+    assert(std::regex_constants::error_badbrace != std::regex_constants::error_space);
+    assert(std::regex_constants::error_badbrace != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_badbrace != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_badbrace != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_range != std::regex_constants::error_space);
+    assert(std::regex_constants::error_range != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_range != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_range != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_space != std::regex_constants::error_badrepeat);
+    assert(std::regex_constants::error_space != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_space != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_badrepeat != std::regex_constants::error_complexity);
+    assert(std::regex_constants::error_badrepeat != std::regex_constants::error_stack);
+
+    assert(std::regex_constants::error_complexity != std::regex_constants::error_stack);
+}
diff --git a/final/test/re/re.const/re.matchflag/match_flag_type.pass.cpp b/final/test/re/re.const/re.matchflag/match_flag_type.pass.cpp
new file mode 100644
index 0000000..b48703c
--- /dev/null
+++ b/final/test/re/re.const/re.matchflag/match_flag_type.pass.cpp
@@ -0,0 +1,128 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// emum match_flag_type  // bitmask type
+// {
+//     match_default     = 0,
+//     match_not_bol     = unspecified,
+//     match_not_eol     = unspecified,
+//     match_not_bow     = unspecified,
+//     match_not_eow     = unspecified,
+//     match_any         = unspecified,
+//     match_not_null    = unspecified,
+//     match_continuous  = unspecified,
+//     match_prev_avail  = unspecified,
+//     format_default    = 0,
+//     format_sed        = unspecified,
+//     format_no_copy    = unspecified,
+//     format_first_only = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    assert(std::regex_constants::match_default == 0);
+    assert(std::regex_constants::match_not_bol != 0);
+    assert(std::regex_constants::match_not_eol != 0);
+    assert(std::regex_constants::match_not_bow != 0);
+    assert(std::regex_constants::match_not_eow != 0);
+    assert(std::regex_constants::match_any != 0);
+    assert(std::regex_constants::match_not_null != 0);
+    assert(std::regex_constants::match_continuous != 0);
+    assert(std::regex_constants::match_prev_avail != 0);
+    assert(std::regex_constants::format_default == 0);
+    assert(std::regex_constants::format_sed != 0);
+    assert(std::regex_constants::format_no_copy != 0);
+    assert(std::regex_constants::format_first_only != 0);
+
+    assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eol) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_bow) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eow) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::match_any) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_null) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::match_continuous) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::match_prev_avail) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_not_bol & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_bow) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_eow) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::match_any) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_null) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::match_continuous) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::match_prev_avail) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_not_eol & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_eow) == 0);
+    assert((std::regex_constants::match_not_bow & std::regex_constants::match_any) == 0);
+    assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_null) == 0);
+    assert((std::regex_constants::match_not_bow & std::regex_constants::match_continuous) == 0);
+    assert((std::regex_constants::match_not_bow & std::regex_constants::match_prev_avail) == 0);
+    assert((std::regex_constants::match_not_bow & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_not_bow & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_not_bow & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::match_not_eow & std::regex_constants::match_any) == 0);
+    assert((std::regex_constants::match_not_eow & std::regex_constants::match_not_null) == 0);
+    assert((std::regex_constants::match_not_eow & std::regex_constants::match_continuous) == 0);
+    assert((std::regex_constants::match_not_eow & std::regex_constants::match_prev_avail) == 0);
+    assert((std::regex_constants::match_not_eow & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_not_eow & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_not_eow & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::match_any & std::regex_constants::match_not_null) == 0);
+    assert((std::regex_constants::match_any & std::regex_constants::match_continuous) == 0);
+    assert((std::regex_constants::match_any & std::regex_constants::match_prev_avail) == 0);
+    assert((std::regex_constants::match_any & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_any & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_any & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::match_not_null & std::regex_constants::match_continuous) == 0);
+    assert((std::regex_constants::match_not_null & std::regex_constants::match_prev_avail) == 0);
+    assert((std::regex_constants::match_not_null & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_not_null & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_not_null & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::match_continuous & std::regex_constants::match_prev_avail) == 0);
+    assert((std::regex_constants::match_continuous & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_continuous & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_continuous & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::match_prev_avail & std::regex_constants::format_sed) == 0);
+    assert((std::regex_constants::match_prev_avail & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::match_prev_avail & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::format_sed & std::regex_constants::format_no_copy) == 0);
+    assert((std::regex_constants::format_sed & std::regex_constants::format_first_only) == 0);
+
+    assert((std::regex_constants::format_no_copy & std::regex_constants::format_first_only) == 0);
+
+    std::regex_constants::match_flag_type e1 = std::regex_constants::match_not_bol;
+    std::regex_constants::match_flag_type e2 = std::regex_constants::match_not_eol;
+    e1 = ~e1;
+    e1 = e1 & e2;
+    e1 = e1 | e2;
+    e1 = e1 ^ e2;
+    e1 &= e2;
+    e1 |= e2;
+    e1 ^= e2;
+}
diff --git a/final/test/re/re.const/re.synopt/syntax_option_type.pass.cpp b/final/test/re/re.const/re.synopt/syntax_option_type.pass.cpp
new file mode 100644
index 0000000..1c4f824
--- /dev/null
+++ b/final/test/re/re.const/re.synopt/syntax_option_type.pass.cpp
@@ -0,0 +1,114 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// namespace regex_constants
+// {
+//
+// emum syntax_option_type  // bitmask type
+// {
+//     icase      = unspecified,
+//     nosubs     = unspecified,
+//     optimize   = unspecified,
+//     collate    = unspecified,
+//     ECMAScript = unspecified,
+//     basic      = unspecified,
+//     extended   = unspecified,
+//     awk        = unspecified,
+//     grep       = unspecified,
+//     egrep      = unspecified
+// };
+//
+// }
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    assert(std::regex_constants::icase != 0);
+    assert(std::regex_constants::nosubs != 0);
+    assert(std::regex_constants::optimize != 0);
+    assert(std::regex_constants::collate != 0);
+    assert(std::regex_constants::ECMAScript == 0);
+    assert(std::regex_constants::basic != 0);
+    assert(std::regex_constants::extended != 0);
+    assert(std::regex_constants::awk != 0);
+    assert(std::regex_constants::grep != 0);
+    assert(std::regex_constants::egrep != 0);
+
+    assert((std::regex_constants::icase & std::regex_constants::nosubs) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::optimize) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::collate) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::ECMAScript) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::basic) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::extended) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::awk) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::icase & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::nosubs & std::regex_constants::optimize) == 0);
+    assert((std::regex_constants::nosubs & std::regex_constants::collate) == 0);
+    assert((std::regex_constants::nosubs & std::regex_constants::ECMAScript) == 0);
+    assert((std::regex_constants::nosubs & std::regex_constants::basic) == 0);
+    assert((std::regex_constants::nosubs & std::regex_constants::extended) == 0);
+    assert((std::regex_constants::nosubs & std::regex_constants::awk) == 0);
+    assert((std::regex_constants::nosubs & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::nosubs & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::optimize & std::regex_constants::collate) == 0);
+    assert((std::regex_constants::optimize & std::regex_constants::ECMAScript) == 0);
+    assert((std::regex_constants::optimize & std::regex_constants::basic) == 0);
+    assert((std::regex_constants::optimize & std::regex_constants::extended) == 0);
+    assert((std::regex_constants::optimize & std::regex_constants::awk) == 0);
+    assert((std::regex_constants::optimize & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::optimize & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::collate & std::regex_constants::ECMAScript) == 0);
+    assert((std::regex_constants::collate & std::regex_constants::basic) == 0);
+    assert((std::regex_constants::collate & std::regex_constants::extended) == 0);
+    assert((std::regex_constants::collate & std::regex_constants::awk) == 0);
+    assert((std::regex_constants::collate & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::collate & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::ECMAScript & std::regex_constants::basic) == 0);
+    assert((std::regex_constants::ECMAScript & std::regex_constants::extended) == 0);
+    assert((std::regex_constants::ECMAScript & std::regex_constants::awk) == 0);
+    assert((std::regex_constants::ECMAScript & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::ECMAScript & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::basic & std::regex_constants::extended) == 0);
+    assert((std::regex_constants::basic & std::regex_constants::awk) == 0);
+    assert((std::regex_constants::basic & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::basic & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::extended & std::regex_constants::awk) == 0);
+    assert((std::regex_constants::extended & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::extended & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::awk & std::regex_constants::grep) == 0);
+    assert((std::regex_constants::awk & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::grep & std::regex_constants::egrep) == 0);
+
+    assert((std::regex_constants::icase | std::regex_constants::nosubs) != 0);
+    assert((std::regex_constants::icase ^ std::regex_constants::nosubs) != 0);
+
+    std::regex_constants::syntax_option_type e1 = std::regex_constants::icase;
+    std::regex_constants::syntax_option_type e2 = std::regex_constants::nosubs;
+    e1 = ~e1;
+    e1 = e1 & e2;
+    e1 = e1 | e2;
+    e1 = e1 ^ e2;
+    e1 &= e2;
+    e1 |= e2;
+    e1 ^= e2;
+}
diff --git a/final/test/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp b/final/test/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/defns.regex.collating.element/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp b/final/test/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/defns.regex.finite.state.machine/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp b/final/test/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/defns.regex.format.specifier/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp b/final/test/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/defns.regex.matched/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp b/final/test/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/defns.regex.primary.equivalence.class/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp b/final/test/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/defns.regex.regular.expression/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp b/final/test/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/defns.regex.subexpression/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.def/nothing_to_do.pass.cpp b/final/test/re/re.def/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.def/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.general/nothing_to_do.pass.cpp b/final/test/re/re.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.grammar/nothing_to_do.pass.cpp b/final/test/re/re.grammar/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/re/re.grammar/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.iter/nothing_to_do.pass.cpp b/final/test/re/re.iter/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/re/re.iter/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp b/final/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
new file mode 100644
index 0000000..9c17287
--- /dev/null
+++ b/final/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type&& re,
+//                      int submatch = 0,
+//                      regex_constants::match_flag_type m =
+//                        regex_constants::match_default) = delete;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::cregex_iterator i(
+            std::begin(phone_book), std::end(phone_book), 
+            std::regex("\\d{3}-\\d{4}"));
+    }
+}
+#endif
diff --git a/final/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp b/final/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
new file mode 100644
index 0000000..c9fc7a3
--- /dev/null
+++ b/final/test/re/re.iter/re.regiter/re.regiter.cnstr/cnstr.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                const regex_type& re,
+//                regex_constants::match_flag_type m = regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+        assert(i != std::cregex_iterator());
+        assert(i->size() == 1);
+        assert(i->position() == 0);
+        assert(i->str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_iterator());
+        assert(i->size() == 1);
+        assert(i->position() == 10);
+        assert(i->str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_iterator());
+        assert(i->size() == 1);
+        assert(i->position() == 20);
+        assert(i->str() == "555-3456");
+        ++i;
+        assert(i == std::cregex_iterator());
+    }
+}
diff --git a/final/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp b/final/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
new file mode 100644
index 0000000..9d4766d
--- /dev/null
+++ b/final/test/re/re.iter/re.regiter/re.regiter.cnstr/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+    typedef std::regex_iterator<const CharT*> I;
+    I i1;
+    assert(i1 == I());
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp b/final/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..16d1fa9
--- /dev/null
+++ b/final/test/re/re.iter/re.regiter/re.regiter.comp/tested_elsewhere.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_iterator& right) const;
+// bool operator!=(const regex_iterator& right) const;
+
+int main()
+{
+}
diff --git a/final/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp b/final/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
new file mode 100644
index 0000000..e4933fe
--- /dev/null
+++ b/final/test/re/re.iter/re.regiter/re.regiter.deref/deref.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+        assert(i != std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 0);
+        assert((*i).str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 10);
+        assert((*i).str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 20);
+        assert((*i).str() == "555-3456");
+        ++i;
+        assert(i == std::cregex_iterator());
+    }
+}
diff --git a/final/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp b/final/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
new file mode 100644
index 0000000..3ec0d6c
--- /dev/null
+++ b/final/test/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_iterator operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+        std::cregex_iterator i2 = i;
+        assert(i != std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 0);
+        assert((*i).str() == "555-1234");
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+        i++;
+        assert(i != std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 10);
+        assert((*i).str() == "555-2345");
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+        i++;
+        assert(i != std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 20);
+        assert((*i).str() == "555-3456");
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+        i++;
+        assert(i == std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "555-1234, 555-2345, 555-3456";
+        std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
+        std::cregex_iterator i2 = i;
+        assert(i != std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 0);
+        assert((*i).str() == "555-1234");
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 10);
+        assert((*i).str() == "555-2345");
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i).size() == 1);
+        assert((*i).position() == 20);
+        assert((*i).str() == "555-3456");
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+        ++i;
+        assert(i == std::cregex_iterator());
+        assert(i2!= std::cregex_iterator());
+        assert((*i2).size() == 1);
+        assert((*i2).position() == 0);
+        assert((*i2).str() == "555-1234");
+    }
+}
diff --git a/final/test/re/re.iter/re.regiter/types.pass.cpp b/final/test/re/re.iter/re.regiter/types.pass.cpp
new file mode 100644
index 0000000..db1d3eb
--- /dev/null
+++ b/final/test/re/re.iter/re.regiter/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+//           class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+//           class traits = regex_traits<charT>>
+// class regex_iterator
+// {
+// public:
+//     typedef basic_regex<charT, traits>           regex_type;
+//     typedef match_results<BidirectionalIterator> value_type;
+//     typedef ptrdiff_t                            difference_type;
+//     typedef const value_type*                    pointer;
+//     typedef const value_type&                    reference;
+//     typedef forward_iterator_tag                 iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+    typedef std::regex_iterator<const CharT*> I;
+    static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+    static_assert((std::is_same<typename I::value_type, std::match_results<const CharT*> >::value), "");
+    static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<typename I::pointer, const std::match_results<const CharT*>*>::value), "");
+    static_assert((std::is_same<typename I::reference, const std::match_results<const CharT*>&>::value), "");
+    static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
new file mode 100644
index 0000000..ed3c9fe
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/array.fail.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type&& re,
+//                      const int (&submatches)[N],
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        const int indices[] = {-1, 0, 1};
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     std::regex("\\d{3}-\\d{4}"), indices);
+    }
+}
+#endif
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp
new file mode 100644
index 0000000..a51b827
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/array.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// template <size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type& re,
+//                      const int (&submatches)[N],
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        const int indices[] = {-1, 0, 1};
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, indices);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-3456");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "3456");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
new file mode 100644
index 0000000..382815e
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+    typedef std::regex_token_iterator<const CharT*> I;
+    I i1;
+    assert(i1 == I());
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
new file mode 100644
index 0000000..13120f3
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/init.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type&& re,
+//                      initializer_list<int> submatches,
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                      std::regex("\\d{3}-\\d{4}"), {-1, 0, 1});
+    }
+}
+#endif
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
new file mode 100644
index 0000000..b40d7eb
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/init.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type& re,
+//                      initializer_list<int> submatches,
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, {-1, 0, 1});
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-3456");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "3456");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
new file mode 100644
index 0000000..dba11c2
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type&& re, int submatch = 0,
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     std::regex("\\d{3}-\\d{4}"), -1);
+    }
+}
+#endif
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
new file mode 100644
index 0000000..d811136
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type& re, int submatch = 0,
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, -1);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-3456");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, 1);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "3456");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
new file mode 100644
index 0000000..fd75a8b
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_iterator<BidirectionalIterator, charT, traits>
+
+// template <std::size_t N>
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type&& re,
+//                      const std::vector<int>& submatches,
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER <= 11
+#error
+#else
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+         std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::vector<int> v;
+        v.push_back(-1);
+        v.push_back(-1);
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     std::regex("\\d{3}-\\d{4}"), v);
+    }
+}
+#endif
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
new file mode 100644
index 0000000..b04f580
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
+//                      const regex_type& re,
+//                      const std::vector<int>& submatches,
+//                      regex_constants::match_flag_type m =
+//                                              regex_constants::match_default);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::vector<int> v;
+        v.push_back(-1);
+        v.push_back(-1);
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, v);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::vector<int> v;
+        v.push_back(-1);
+        v.push_back(0);
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, v);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-3456");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::vector<int> v;
+        v.push_back(-1);
+        v.push_back(0);
+        v.push_back(1);
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, v);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-3456");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "3456");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
new file mode 100644
index 0000000..d6399f1
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.comp/equal.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// bool operator==(const regex_token_iterator& right) const;
+// bool operator!=(const regex_token_iterator& right) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, -1);
+        assert(i != std::cregex_token_iterator());
+        assert(!(i == std::cregex_token_iterator()));
+        std::cregex_token_iterator i2 = i;
+        assert(i2 == i);
+        assert(!(i2 != i));
+        ++i;
+        assert(!(i2 == i));
+        assert(i2 != i);
+    }
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
new file mode 100644
index 0000000..b096e3c
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.deref/deref.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// const value_type& operator*() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, -1);
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == "start ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == ", ");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == " end");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers);
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == "555-1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == "555-2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == "555-3456");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, 1);
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == "1234");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == "2345");
+        ++i;
+        assert(i != std::cregex_token_iterator());
+        assert((*i).str() == "3456");
+        ++i;
+        assert(i == std::cregex_token_iterator());
+    }
+}
diff --git a/final/test/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp b/final/test/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
new file mode 100644
index 0000000..727ab7a
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class regex_token_iterator<BidirectionalIterator, charT, traits>
+
+// regex_token_iterator& operator++(int);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, -1);
+        std::cregex_token_iterator i2 = i;
+        std::cregex_token_iterator i3;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        assert(i2->str() == "start ");
+        i3 = i++;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        assert(i2->str() == "start ");
+        assert(i3->str() == "start ");
+        i3 = i++;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        assert(i2->str() == "start ");
+        assert(i3->str() == ", ");
+        i3 = i++;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        assert(i2->str() == "start ");
+        assert(i3->str() == ", ");
+        i3 = i++;
+        assert(i  == std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i2->str() == "start ");
+        assert(i3->str() == " end");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, -1);
+        std::cregex_token_iterator i2 = i;
+        std::cregex_token_iterator i3;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i->str() == "start ");
+        assert(i2->str() == "start ");
+        i3 = i;
+        ++i;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        assert(i2->str() == "start ");
+        assert(i3->str() == "start ");
+        i3 = i;
+        ++i;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i->str() == ", ");
+        assert(i2->str() == "start ");
+        assert(i3->str() == ", ");
+        i3 = i;
+        ++i;
+        assert(i  != std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i->str() == " end");
+        assert(i2->str() == "start ");
+        assert(i3->str() == ", ");
+        i3 = i;
+        ++i;
+        assert(i  == std::cregex_token_iterator());
+        assert(i2 != std::cregex_token_iterator());
+        assert(i3 != std::cregex_token_iterator());
+        assert(i2->str() == "start ");
+        assert(i3->str() == " end");
+    }
+    {
+        std::regex phone_numbers("\\d{3}-\\d{4}");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-1234");
+        i++;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-2345");
+        i++;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "555-3456");
+        i++;
+        assert(i == std::cregex_token_iterator());
+    }
+    {
+        std::regex phone_numbers("\\d{3}-(\\d{4})");
+        const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
+        std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
+                                     phone_numbers, 1);
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "1234");
+        i++;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "2345");
+        i++;
+        assert(i != std::cregex_token_iterator());
+        assert(i->str() == "3456");
+        i++;
+        assert(i == std::cregex_token_iterator());
+    }
+}
diff --git a/final/test/re/re.iter/re.tokiter/types.pass.cpp b/final/test/re/re.iter/re.tokiter/types.pass.cpp
new file mode 100644
index 0000000..89287bd
--- /dev/null
+++ b/final/test/re/re.iter/re.tokiter/types.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+//           class charT = typename iterator_traits< BidirectionalIterator>::value_type,
+//           class traits = regex_traits<charT>>
+// class regex_token_iterator
+// {
+// public:
+//     typedef basic_regex<charT, traits>       regex_type;
+//     typedef sub_match<BidirectionalIterator> value_type;
+//     typedef ptrdiff_t                        difference_type;
+//     typedef const value_type*                pointer;
+//     typedef const value_type&                reference;
+//     typedef forward_iterator_tag             iterator_category;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+    typedef std::regex_token_iterator<const CharT*> I;
+    static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
+    static_assert((std::is_same<typename I::value_type, std::sub_match<const CharT*> >::value), "");
+    static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<typename I::pointer, const std::sub_match<const CharT*>*>::value), "");
+    static_assert((std::is_same<typename I::reference, const std::sub_match<const CharT*>&>::value), "");
+    static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.regex/re.regex.assign/assign.il.pass.cpp b/final/test/re/re.regex/re.regex.assign/assign.il.pass.cpp
new file mode 100644
index 0000000..96cadf1
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/assign.il.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex&
+//    assign(initializer_list<charT> il,
+//           flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    std::regex r2;
+    r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'});
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+
+    r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex::extended);
+    assert(r2.flags() == std::regex::extended);
+    assert(r2.mark_count() == 2);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/re/re.regex/re.regex.assign/assign.pass.cpp b/final/test/re/re.regex/re.regex.assign/assign.pass.cpp
new file mode 100644
index 0000000..1bd0022
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/assign.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const basic_regex& that);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r1("(a([bc]))");
+    std::regex r2;
+    r2.assign(r1);
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp b/final/test/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
new file mode 100644
index 0000000..529a64a
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/assign_iter_iter_flag.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class InputIterator>
+//    basic_regex&
+//    assign(InputIterator first, InputIterator last,
+//           flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    typedef input_iterator<std::string::const_iterator> I;
+    typedef forward_iterator<std::string::const_iterator> F;
+    std::string s4("(a([bc]))");
+    std::regex r2;
+
+    r2.assign(I(s4.begin()), I(s4.end()));
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+
+    r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
+    assert(r2.flags() == std::regex::extended);
+    assert(r2.mark_count() == 2);
+
+    r2.assign(F(s4.begin()), F(s4.end()));
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+
+    r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
+    assert(r2.flags() == std::regex::extended);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp b/final/test/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp
new file mode 100644
index 0000000..dd39dee
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/assign_ptr_flag.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r2;
+    r2.assign("(a([bc]))");
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+
+    r2.assign("(a([bc]))", std::regex::extended);
+    assert(r2.flags() == std::regex::extended);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp b/final/test/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp
new file mode 100644
index 0000000..679cd9d
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/assign_ptr_size_flag.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& assign(const charT* ptr, size_t len, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r2;
+    r2.assign("(a([bc]))", 9, std::regex::extended);
+    assert(r2.flags() == std::regex::extended);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp b/final/test/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
new file mode 100644
index 0000000..46f984d
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/assign_string_flag.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class string_traits, class A>
+//   basic_regex& assign(const basic_string<charT, string_traits, A>& s,
+//                       flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r2;
+    r2.assign(std::string("(a([bc]))"));
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+
+    r2.assign(std::string("(a([bc]))"), std::regex::extended);
+    assert(r2.flags() == std::regex::extended);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.assign/copy.pass.cpp b/final/test/re/re.regex/re.regex.assign/copy.pass.cpp
new file mode 100644
index 0000000..2a616ff
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/copy.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(const basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r1("(a([bc]))");
+    std::regex r2;
+    r2 = r1;
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.assign/il.pass.cpp b/final/test/re/re.regex/re.regex.assign/il.pass.cpp
new file mode 100644
index 0000000..a9d8ada
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/il.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(initializer_list<charT> il);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    std::regex r2;
+    r2 = {'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'};
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/re/re.regex/re.regex.assign/ptr.pass.cpp b/final/test/re/re.regex/re.regex.assign/ptr.pass.cpp
new file mode 100644
index 0000000..4c42f82
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/ptr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex& operator=(const charT* ptr);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r2;
+    r2 = "(a([bc]))";
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.assign/string.pass.cpp b/final/test/re/re.regex/re.regex.assign/string.pass.cpp
new file mode 100644
index 0000000..7f09e53
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.assign/string.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+//    basic_regex& operator=(const basic_string<charT, ST, SA>& p);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r2;
+    r2 = std::string("(a([bc]))");
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.const/constants.pass.cpp b/final/test/re/re.regex/re.regex.const/constants.pass.cpp
new file mode 100644
index 0000000..85297b9
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.const/constants.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>>
+// class basic_regex
+// {
+// public:
+//     // constants:
+//     static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
+//     static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
+//     static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
+//     static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
+//     static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
+//     static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
+//     static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
+//     static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
+//     static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
+//     static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
+
+#include <regex>
+#include <type_traits>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+template <class CharT>
+void
+test()
+{
+    typedef std::basic_regex<CharT> BR;
+    static_assert((BR::icase == std::regex_constants::icase), "");
+    static_assert((BR::nosubs == std::regex_constants::nosubs), "");
+    static_assert((BR::optimize == std::regex_constants::optimize), "");
+    static_assert((BR::collate == std::regex_constants::collate), "");
+    static_assert((BR::ECMAScript == std::regex_constants::ECMAScript), "");
+    static_assert((BR::basic == std::regex_constants::basic), "");
+    static_assert((BR::extended == std::regex_constants::extended), "");
+    static_assert((BR::awk == std::regex_constants::awk), "");
+    static_assert((BR::grep == std::regex_constants::grep), "");
+    static_assert((BR::egrep == std::regex_constants::egrep), "");
+    where(BR::icase);
+    where(BR::nosubs);
+    where(BR::optimize);
+    where(BR::collate);
+    where(BR::ECMAScript);
+    where(BR::basic);
+    where(BR::extended);
+    where(BR::awk);
+    where(BR::grep);
+    where(BR::egrep);
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.regex/re.regex.construct/awk_oct.pass.cpp b/final/test/re/re.regex/re.regex.construct/awk_oct.pass.cpp
new file mode 100644
index 0000000..11fce3f
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/awk_oct.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+//    basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+int main() 
+{
+    using std::regex_constants::awk;
+
+    assert(std::regex_match("\4", std::regex{"\\4", awk}));
+    assert(std::regex_match("\41", std::regex{"\\41", awk}));
+    assert(std::regex_match("\141", std::regex{"\\141", awk}));
+    assert(std::regex_match("\1411", std::regex{"\\1411", awk}));
+}
diff --git a/final/test/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/final/test/re/re.regex/re.regex.construct/bad_escape.pass.cpp
new file mode 100644
index 0000000..9455527
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+//    basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+static bool error_escape_thrown(const char *pat) 
+{
+    bool result = false;
+    try {
+        std::regex re(pat);
+    } catch (std::regex_error &ex) {
+        result = (ex.code() == std::regex_constants::error_escape);
+    }
+    return result;
+}
+
+int main() 
+{
+    assert(error_escape_thrown("[\\a]"));
+    assert(error_escape_thrown("\\a"));
+
+    assert(error_escape_thrown("[\\e]"));
+    assert(error_escape_thrown("\\e"));
+
+    assert(error_escape_thrown("[\\c:]"));
+    assert(error_escape_thrown("\\c:"));
+    assert(error_escape_thrown("\\c"));
+    assert(!error_escape_thrown("[\\cA]"));
+    assert(!error_escape_thrown("\\cA"));
+
+}
diff --git a/final/test/re/re.regex/re.regex.construct/copy.pass.cpp b/final/test/re/re.regex/re.regex.construct/copy.pass.cpp
new file mode 100644
index 0000000..c2788f0
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/copy.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r1("(a([bc]))");
+    std::regex r2 = r1;
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.construct/default.pass.cpp b/final/test/re/re.regex/re.regex.construct/default.pass.cpp
new file mode 100644
index 0000000..d959c1e
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex();
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+    std::basic_regex<CharT> r;
+    assert(r.flags() == 0);
+    assert(r.mark_count() == 0);
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.regex/re.regex.construct/il_flg.pass.cpp b/final/test/re/re.regex/re.regex.construct/il_flg.pass.cpp
new file mode 100644
index 0000000..70d28df
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/il_flg.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(initializer_list<charT> il,
+//             flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+void
+test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+    std::basic_regex<char> r(il, f);
+    assert(r.flags() == f);
+    assert(r.mark_count() == mc);
+}
+
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    std::string s1("\\(a\\)");
+    std::string s2("\\(a[bc]\\)");
+    std::string s3("\\(a\\([bc]\\)\\)");
+    std::string s4("(a([bc]))");
+
+    test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::basic, 1);
+    test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::basic, 1);
+    test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::basic, 2);
+    test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::basic, 0);
+
+    test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::extended, 0);
+    test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::extended, 0);
+    test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::extended, 0);
+    test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::extended, 2);
+
+    test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+    test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+    test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::ECMAScript, 0);
+    test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::ECMAScript, 2);
+
+    test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::awk, 0);
+    test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::awk, 0);
+    test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::awk, 0);
+    test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::awk, 2);
+
+    test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::grep, 1);
+    test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::grep, 1);
+    test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::grep, 2);
+    test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::grep, 0);
+
+    test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::egrep, 0);
+    test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::egrep, 0);
+    test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::egrep, 0);
+    test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::egrep, 2);
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp b/final/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp
new file mode 100644
index 0000000..a38e162
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ForwardIterator>
+//    basic_regex(ForwardIterator first, ForwardIterator last);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, unsigned mc)
+{
+    std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last);
+    assert(r.flags() == std::regex_constants::ECMAScript);
+    assert(r.mark_count() == mc);
+}
+
+int main()
+{
+    typedef forward_iterator<std::string::const_iterator> F;
+    std::string s1("\\(a\\)");
+    std::string s2("\\(a[bc]\\)");
+    std::string s3("\\(a\\([bc]\\)\\)");
+    std::string s4("(a([bc]))");
+
+    test(F(s1.begin()), F(s1.end()), 0);
+    test(F(s2.begin()), F(s2.end()), 0);
+    test(F(s3.begin()), F(s3.end()), 0);
+    test(F(s4.begin()), F(s4.end()), 2);
+}
diff --git a/final/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp b/final/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
new file mode 100644
index 0000000..c4c440e
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ForwardIterator>
+//    basic_regex(ForwardIterator first, ForwardIterator last,
+//                flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter>
+void
+test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+    std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last, f);
+    assert(r.flags() == f);
+    assert(r.mark_count() == mc);
+}
+
+int main()
+{
+    typedef forward_iterator<std::string::const_iterator> F;
+    std::string s1("\\(a\\)");
+    std::string s2("\\(a[bc]\\)");
+    std::string s3("\\(a\\([bc]\\)\\)");
+    std::string s4("(a([bc]))");
+
+    test(F(s1.begin()), F(s1.end()), std::regex_constants::basic, 1);
+    test(F(s2.begin()), F(s2.end()), std::regex_constants::basic, 1);
+    test(F(s3.begin()), F(s3.end()), std::regex_constants::basic, 2);
+    test(F(s4.begin()), F(s4.end()), std::regex_constants::basic, 0);
+
+    test(F(s1.begin()), F(s1.end()), std::regex_constants::extended, 0);
+    test(F(s2.begin()), F(s2.end()), std::regex_constants::extended, 0);
+    test(F(s3.begin()), F(s3.end()), std::regex_constants::extended, 0);
+    test(F(s4.begin()), F(s4.end()), std::regex_constants::extended, 2);
+
+    test(F(s1.begin()), F(s1.end()), std::regex_constants::ECMAScript, 0);
+    test(F(s2.begin()), F(s2.end()), std::regex_constants::ECMAScript, 0);
+    test(F(s3.begin()), F(s3.end()), std::regex_constants::ECMAScript, 0);
+    test(F(s4.begin()), F(s4.end()), std::regex_constants::ECMAScript, 2);
+
+    test(F(s1.begin()), F(s1.end()), std::regex_constants::awk, 0);
+    test(F(s2.begin()), F(s2.end()), std::regex_constants::awk, 0);
+    test(F(s3.begin()), F(s3.end()), std::regex_constants::awk, 0);
+    test(F(s4.begin()), F(s4.end()), std::regex_constants::awk, 2);
+
+    test(F(s1.begin()), F(s1.end()), std::regex_constants::grep, 1);
+    test(F(s2.begin()), F(s2.end()), std::regex_constants::grep, 1);
+    test(F(s3.begin()), F(s3.end()), std::regex_constants::grep, 2);
+    test(F(s4.begin()), F(s4.end()), std::regex_constants::grep, 0);
+
+    test(F(s1.begin()), F(s1.end()), std::regex_constants::egrep, 0);
+    test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
+    test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
+    test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
+}
diff --git a/final/test/re/re.regex/re.regex.construct/ptr.pass.cpp b/final/test/re/re.regex/re.regex.construct/ptr.pass.cpp
new file mode 100644
index 0000000..b99b58b
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/ptr.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, unsigned mc)
+{
+    std::basic_regex<CharT> r(p);
+    assert(r.flags() == std::regex_constants::ECMAScript);
+    assert(r.mark_count() == mc);
+}
+
+int main()
+{
+    test("\\(a\\)", 0);
+    test("\\(a[bc]\\)", 0);
+    test("\\(a\\([bc]\\)\\)", 0);
+    test("(a([bc]))", 2);
+}
diff --git a/final/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp b/final/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
new file mode 100644
index 0000000..138e20e
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+    std::basic_regex<CharT> r(p, f);
+    assert(r.flags() == f);
+    assert(r.mark_count() == mc);
+}
+
+int main()
+{
+    test("\\(a\\)", std::regex_constants::basic, 1);
+    test("\\(a[bc]\\)", std::regex_constants::basic, 1);
+    test("\\(a\\([bc]\\)\\)", std::regex_constants::basic, 2);
+    test("(a([bc]))", std::regex_constants::basic, 0);
+
+    test("\\(a\\)", std::regex_constants::extended, 0);
+    test("\\(a[bc]\\)", std::regex_constants::extended, 0);
+    test("\\(a\\([bc]\\)\\)", std::regex_constants::extended, 0);
+    test("(a([bc]))", std::regex_constants::extended, 2);
+
+    test("\\(a\\)", std::regex_constants::ECMAScript, 0);
+    test("\\(a[bc]\\)", std::regex_constants::ECMAScript, 0);
+    test("\\(a\\([bc]\\)\\)", std::regex_constants::ECMAScript, 0);
+    test("(a([bc]))", std::regex_constants::ECMAScript, 2);
+
+    test("\\(a\\)", std::regex_constants::awk, 0);
+    test("\\(a[bc]\\)", std::regex_constants::awk, 0);
+    test("\\(a\\([bc]\\)\\)", std::regex_constants::awk, 0);
+    test("(a([bc]))", std::regex_constants::awk, 2);
+
+    test("\\(a\\)", std::regex_constants::grep, 1);
+    test("\\(a[bc]\\)", std::regex_constants::grep, 1);
+    test("\\(a\\([bc]\\)\\)", std::regex_constants::grep, 2);
+    test("(a([bc]))", std::regex_constants::grep, 0);
+
+    test("\\(a\\)", std::regex_constants::egrep, 0);
+    test("\\(a[bc]\\)", std::regex_constants::egrep, 0);
+    test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0);
+    test("(a([bc]))", std::regex_constants::egrep, 2);
+}
diff --git a/final/test/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp b/final/test/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
new file mode 100644
index 0000000..d623a15
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p, size_t len, flag_type f);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f,
+     unsigned mc)
+{
+    std::basic_regex<CharT> r(p, len, f);
+    assert(r.flags() == f);
+    assert(r.mark_count() == mc);
+}
+
+int main()
+{
+    test("\\(a\\)", 5, std::regex_constants::basic, 1);
+    test("\\(a[bc]\\)", 9, std::regex_constants::basic, 1);
+    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::basic, 2);
+    test("(a([bc]))", 9, std::regex_constants::basic, 0);
+
+    test("\\(a\\)", 5, std::regex_constants::extended, 0);
+    test("\\(a[bc]\\)", 9, std::regex_constants::extended, 0);
+    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::extended, 0);
+    test("(a([bc]))", 9, std::regex_constants::extended, 2);
+
+    test("\\(a\\)", 5, std::regex_constants::ECMAScript, 0);
+    test("\\(a[bc]\\)", 9, std::regex_constants::ECMAScript, 0);
+    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::ECMAScript, 0);
+    test("(a([bc]))", 9, std::regex_constants::ECMAScript, 2);
+
+    test("\\(a\\)", 5, std::regex_constants::awk, 0);
+    test("\\(a[bc]\\)", 9, std::regex_constants::awk, 0);
+    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::awk, 0);
+    test("(a([bc]))", 9, std::regex_constants::awk, 2);
+
+    test("\\(a\\)", 5, std::regex_constants::grep, 1);
+    test("\\(a[bc]\\)", 9, std::regex_constants::grep, 1);
+    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::grep, 2);
+    test("(a([bc]))", 9, std::regex_constants::grep, 0);
+
+    test("\\(a\\)", 5, std::regex_constants::egrep, 0);
+    test("\\(a[bc]\\)", 9, std::regex_constants::egrep, 0);
+    test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::egrep, 0);
+    test("(a([bc]))", 9, std::regex_constants::egrep, 2);
+}
diff --git a/final/test/re/re.regex/re.regex.construct/string.pass.cpp b/final/test/re/re.regex/re.regex.construct/string.pass.cpp
new file mode 100644
index 0000000..b58b8e0
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/string.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+//    basic_regex(const basic_string<charT, ST, SA>& s);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, unsigned mc)
+{
+    std::basic_regex<typename String::value_type> r(p);
+    assert(r.flags() == std::regex_constants::ECMAScript);
+    assert(r.mark_count() == mc);
+}
+
+int main()
+{
+    test(std::string("\\(a\\)"), 0);
+    test(std::string("\\(a[bc]\\)"), 0);
+    test(std::string("\\(a\\([bc]\\)\\)"), 0);
+    test(std::string("(a([bc]))"), 2);
+}
diff --git a/final/test/re/re.regex/re.regex.construct/string_flg.pass.cpp b/final/test/re/re.regex/re.regex.construct/string_flg.pass.cpp
new file mode 100644
index 0000000..768de56
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.construct/string_flg.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class ST, class SA>
+//    basic_regex(const basic_string<charT, ST, SA>& s,
+//                flag_type f = regex_constants::ECMAScript);
+
+#include <regex>
+#include <cassert>
+
+template <class String>
+void
+test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
+{
+    std::basic_regex<typename String::value_type> r(p, f);
+    assert(r.flags() == f);
+    assert(r.mark_count() == mc);
+}
+
+int main()
+{
+    test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
+    test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
+    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
+    test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
+
+    test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
+    test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
+    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
+    test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
+
+    test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
+    test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
+    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
+    test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
+
+    test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
+    test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
+    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
+    test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
+
+    test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
+    test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
+    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
+    test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
+
+    test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
+    test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
+    test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
+    test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
+}
diff --git a/final/test/re/re.regex/re.regex.locale/imbue.pass.cpp b/final/test/re/re.regex/re.regex.locale/imbue.pass.cpp
new file mode 100644
index 0000000..be0b26d
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.locale/imbue.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// locale_type imbue(locale_type loc);
+
+#include <regex>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    std::regex r;
+    std::locale loc = r.imbue(std::locale(LOCALE_en_US_UTF_8));
+    assert(loc.name() == "C");
+    assert(r.getloc().name() == LOCALE_en_US_UTF_8);
+    loc = r.imbue(std::locale("C"));
+    assert(loc.name() == LOCALE_en_US_UTF_8);
+    assert(r.getloc().name() == "C");
+}
diff --git a/final/test/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp b/final/test/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp b/final/test/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp
new file mode 100644
index 0000000..9d3c481
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.nonmemb/re.regex.nmswap/swap.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// template <class charT, class traits>
+//   void swap(basic_regex<charT, traits>& lhs, basic_regex<charT, traits>& rhs);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r1("(a([bc]))");
+    std::regex r2;
+    swap(r2, r1);
+    assert(r1.flags() == std::regex::ECMAScript);
+    assert(r1.mark_count() == 0);
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp b/final/test/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.operations/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.regex/re.regex.swap/swap.pass.cpp b/final/test/re/re.regex/re.regex.swap/swap.pass.cpp
new file mode 100644
index 0000000..cda8ef3
--- /dev/null
+++ b/final/test/re/re.regex/re.regex.swap/swap.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// void swap(basic_regex& e);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    std::regex r1("(a([bc]))");
+    std::regex r2;
+    r2.swap(r1);
+    assert(r1.flags() == std::regex::ECMAScript);
+    assert(r1.mark_count() == 0);
+    assert(r2.flags() == std::regex::ECMAScript);
+    assert(r2.mark_count() == 2);
+}
diff --git a/final/test/re/re.regex/types.pass.cpp b/final/test/re/re.regex/types.pass.cpp
new file mode 100644
index 0000000..02011ac
--- /dev/null
+++ b/final/test/re/re.regex/types.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>>
+// class basic_regex
+// {
+// public:
+//     // types:
+//     typedef charT                               value_type;
+//     typedef regex_constants::syntax_option_type flag_type;
+//     typedef typename traits::locale_type        locale_type;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::basic_regex<char>::value_type, char>::value), "");
+    static_assert((std::is_same<std::basic_regex<char>::flag_type,
+                                std::regex_constants::syntax_option_type>::value), "");
+    static_assert((std::is_same<std::basic_regex<char>::locale_type, std::locale>::value), "");
+
+    static_assert((std::is_same<std::basic_regex<wchar_t>::value_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
+                                std::regex_constants::syntax_option_type>::value), "");
+    static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), "");
+}
diff --git a/final/test/re/re.req/nothing_to_do.pass.cpp b/final/test/re/re.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/re/re.req/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/re/re.results/re.results.acc/begin_end.pass.cpp b/final/test/re/re.results/re.results.acc/begin_end.pass.cpp
new file mode 100644
index 0000000..80c06f2
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/begin_end.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_iterator begin() const;
+// const_iterator end() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+    std::match_results<const char*>::const_iterator i = m.begin();
+    std::match_results<const char*>::const_iterator e = m.end();
+
+    assert(e - i == m.size());
+    for (int j = 0; i != e; ++i, ++j)
+        assert(*i == m[j]);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp b/final/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp
new file mode 100644
index 0000000..a983c8a
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/cbegin_cend.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+    std::match_results<const char*>::const_iterator i = m.cbegin();
+    std::match_results<const char*>::const_iterator e = m.cend();
+
+    assert(e - i == m.size());
+    for (int j = 0; i != e; ++i, ++j)
+        assert(*i == m[j]);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.acc/index.pass.cpp b/final/test/re/re.results/re.results.acc/index.pass.cpp
new file mode 100644
index 0000000..b798969
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/index.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference operator[](size_type n) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+    assert(m[0].first == s+2);
+    assert(m[0].second == s+9);
+    assert(m[0].matched == true);
+
+    assert(m[1].first == s+4);
+    assert(m[1].second == s+7);
+    assert(m[1].matched == true);
+
+    assert(m[2].first == s+4);
+    assert(m[2].second == s+5);
+    assert(m[2].matched == true);
+
+    assert(m[3].first == s+11);
+    assert(m[3].second == s+11);
+    assert(m[3].matched == false);
+
+    assert(m[4].first == s+11);
+    assert(m[4].second == s+11);
+    assert(m[4].matched == false);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.acc/length.pass.cpp b/final/test/re/re.results/re.results.acc/length.pass.cpp
new file mode 100644
index 0000000..9102085
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/length.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// difference_type length(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+    assert(m.length() == m[0].length());
+    assert(m.length(0) == m[0].length());
+    assert(m.length(1) == m[1].length());
+    assert(m.length(2) == m[2].length());
+    assert(m.length(3) == m[3].length());
+    assert(m.length(4) == m[4].length());
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.acc/position.pass.cpp b/final/test/re/re.results/re.results.acc/position.pass.cpp
new file mode 100644
index 0000000..2698e2d
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/position.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// difference_type position(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+    assert(m.position() == std::distance(s, m[0].first));
+    assert(m.position(0) == std::distance(s, m[0].first));
+    assert(m.position(1) == std::distance(s, m[1].first));
+    assert(m.position(2) == std::distance(s, m[2].first));
+    assert(m.position(3) == std::distance(s, m[3].first));
+    assert(m.position(4) == std::distance(s, m[4].first));
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.acc/prefix.pass.cpp b/final/test/re/re.results/re.results.acc/prefix.pass.cpp
new file mode 100644
index 0000000..58cdabc
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/prefix.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference prefix() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+    assert(m.prefix().first == s);
+    assert(m.prefix().second == s+2);
+    assert(m.prefix().matched == true);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.acc/str.pass.cpp b/final/test/re/re.results/re.results.acc/str.pass.cpp
new file mode 100644
index 0000000..2ebfeab
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/str.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// string_type str(size_type sub = 0) const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+    assert(m.str() == std::string(m[0]));
+    assert(m.str(0) == std::string(m[0]));
+    assert(m.str(1) == std::string(m[1]));
+    assert(m.str(2) == std::string(m[2]));
+    assert(m.str(3) == std::string(m[3]));
+    assert(m.str(4) == std::string(m[4]));
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.acc/suffix.pass.cpp b/final/test/re/re.results/re.results.acc/suffix.pass.cpp
new file mode 100644
index 0000000..b842ea8
--- /dev/null
+++ b/final/test/re/re.results/re.results.acc/suffix.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// const_reference suffix() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+    assert(m.suffix().first == s+9);
+    assert(m.suffix().second == s+11);
+    assert(m.suffix().matched == true);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.all/get_allocator.pass.cpp b/final/test/re/re.results/re.results.all/get_allocator.pass.cpp
new file mode 100644
index 0000000..0436795
--- /dev/null
+++ b/final/test/re/re.results/re.results.all/get_allocator.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// allocator_type get_allocator() const;
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class CharT, class Allocator>
+void
+test(const Allocator& a)
+{
+    std::match_results<const CharT*, Allocator> m(a);
+    assert(m.size() == 0);
+    assert(m.str() == std::basic_string<CharT>());
+    assert(m.get_allocator() == a);
+}
+
+int main()
+{
+    test<char>(test_allocator<std::sub_match<const char*> >(3));
+    test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3));
+}
diff --git a/final/test/re/re.results/re.results.const/allocator.pass.cpp b/final/test/re/re.results/re.results.const/allocator.pass.cpp
new file mode 100644
index 0000000..a24c669
--- /dev/null
+++ b/final/test/re/re.results/re.results.const/allocator.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// match_results(const Allocator& a = Allocator());
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class CharT, class Allocator>
+void
+test(const Allocator& a)
+{
+    std::match_results<const CharT*, Allocator> m(a);
+    assert(m.size() == 0);
+    assert(m.str() == std::basic_string<CharT>());
+    assert(m.get_allocator() == a);
+}
+
+int main()
+{
+    test<char>(test_allocator<std::sub_match<const char*> >(3));
+    test<wchar_t>(test_allocator<std::sub_match<const wchar_t*> >(3));
+}
diff --git a/final/test/re/re.results/re.results.const/default.pass.cpp b/final/test/re/re.results/re.results.const/default.pass.cpp
new file mode 100644
index 0000000..e10fbfd
--- /dev/null
+++ b/final/test/re/re.results/re.results.const/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// match_results(const Allocator& a = Allocator());
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+    std::match_results<const CharT*> m;
+    assert(m.size() == 0);
+    assert(m.str() == std::basic_string<CharT>());
+    assert(m.get_allocator() == std::allocator<std::sub_match<const CharT*> >());
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.results/re.results.form/form1.pass.cpp b/final/test/re/re.results/re.results.form/form1.pass.cpp
new file mode 100644
index 0000000..9701c60
--- /dev/null
+++ b/final/test/re/re.results/re.results.form/form1.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class OutputIter>
+//   OutputIter
+//   format(OutputIter out, const char_type* fmt_first, const char_type* fmt_last,
+//          regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        char out[100] = {0};
+        const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        char* r = m.format(output_iterator<char*>(out),
+                    fmt, fmt + std::char_traits<char>::length(fmt)).base();
+        assert(r == out + 58);
+        assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        char out[100] = {0};
+        const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        char* r = m.format(output_iterator<char*>(out),
+                    fmt, fmt + std::char_traits<char>::length(fmt),
+                    std::regex_constants::format_sed).base();
+        assert(r == out + 59);
+        assert(std::string(out) == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        char out[100] = {0};
+        const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+        char* r = m.format(output_iterator<char*>(out),
+                    fmt, fmt + std::char_traits<char>::length(fmt),
+                    std::regex_constants::format_sed).base();
+        assert(r == out + 34);
+        assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
+    }
+
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wchar_t out[100] = {0};
+        const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+                    fmt, fmt + std::char_traits<wchar_t>::length(fmt)).base();
+        assert(r == out + 58);
+        assert(std::wstring(out) == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wchar_t out[100] = {0};
+        const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+                    fmt, fmt + std::char_traits<wchar_t>::length(fmt),
+                    std::regex_constants::format_sed).base();
+        assert(r == out + 59);
+        assert(std::wstring(out) == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wchar_t out[100] = {0};
+        const wchar_t fmt[] = L"match: &, m[1]: \\1, m[2]: \\2";
+        wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+                    fmt, fmt + std::char_traits<wchar_t>::length(fmt),
+                    std::regex_constants::format_sed).base();
+        assert(r == out + 34);
+        assert(std::wstring(out) == L"match: cdefghi, m[1]: efg, m[2]: e");
+    }
+}
diff --git a/final/test/re/re.results/re.results.form/form2.pass.cpp b/final/test/re/re.results/re.results.form/form2.pass.cpp
new file mode 100644
index 0000000..b18b7fb
--- /dev/null
+++ b/final/test/re/re.results/re.results.form/form2.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class OutputIter, class ST, class SA>
+//   OutputIter
+//   format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,
+//          regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "test_allocator.h"
+
+int main()
+{
+    typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > nstr;
+    typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t> > wstr;
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        char out[100] = {0};
+        nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        char* r = m.format(output_iterator<char*>(out), fmt).base();
+        assert(r == out + 58);
+        assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        char out[100] = {0};
+        nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        char* r = m.format(output_iterator<char*>(out),
+                    fmt, std::regex_constants::format_sed).base();
+        assert(r == out + 59);
+        assert(std::string(out) == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        char out[100] = {0};
+        nstr fmt("match: &, m[1]: \\1, m[2]: \\2");
+        char* r = m.format(output_iterator<char*>(out),
+                    fmt, std::regex_constants::format_sed).base();
+        assert(r == out + 34);
+        assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
+    }
+
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wchar_t out[100] = {0};
+        wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        wchar_t* r = m.format(output_iterator<wchar_t*>(out), fmt).base();
+        assert(r == out + 58);
+        assert(std::wstring(out) == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wchar_t out[100] = {0};
+        wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+                    fmt, std::regex_constants::format_sed).base();
+        assert(r == out + 59);
+        assert(std::wstring(out) == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wchar_t out[100] = {0};
+        wstr fmt(L"match: &, m[1]: \\1, m[2]: \\2");
+        wchar_t* r = m.format(output_iterator<wchar_t*>(out),
+                    fmt, std::regex_constants::format_sed).base();
+        assert(r == out + 34);
+        assert(std::wstring(out) == L"match: cdefghi, m[1]: efg, m[2]: e");
+    }
+}
diff --git a/final/test/re/re.results/re.results.form/form3.pass.cpp b/final/test/re/re.results/re.results.form/form3.pass.cpp
new file mode 100644
index 0000000..27f2388
--- /dev/null
+++ b/final/test/re/re.results/re.results.form/form3.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class ST, class SA>
+//   basic_string<char_type, ST, SA>
+//   format(const basic_string<char_type, ST, SA>& fmt,
+//          regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+    typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > nstr;
+    typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, test_allocator<wchar_t> > wstr;
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        nstr out = m.format(fmt);
+        assert(out == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        nstr fmt("prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        nstr out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        nstr fmt("match: &, m[1]: \\1, m[2]: \\2");
+        nstr out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == "match: cdefghi, m[1]: efg, m[2]: e");
+    }
+
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        wstr out = m.format(fmt);
+        assert(out == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wstr fmt(L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2");
+        wstr out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        wstr fmt(L"match: &, m[1]: \\1, m[2]: \\2");
+        wstr out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == L"match: cdefghi, m[1]: efg, m[2]: e");
+    }
+}
diff --git a/final/test/re/re.results/re.results.form/form4.pass.cpp b/final/test/re/re.results/re.results.form/form4.pass.cpp
new file mode 100644
index 0000000..1d44c32
--- /dev/null
+++ b/final/test/re/re.results/re.results.form/form4.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// string_type
+//   format(const char_type* fmt,
+//          regex_constants::match_flag_type flags = regex_constants::format_default) const;
+
+#include <iostream>
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        std::string out = m.format(fmt);
+        assert(out == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        std::string out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == "prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const char*> m;
+        const char s[] = "abcdefghijk";
+        assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+
+        const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+        std::string out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == "match: cdefghi, m[1]: efg, m[2]: e");
+    }
+
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        std::wstring out = m.format(fmt);
+        assert(out == L"prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        const wchar_t fmt[] = L"prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+        std::wstring out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == L"prefix: $`, match: $cdefghi, suffix: $', m[1]: $1, m[2]: $2");
+    }
+    {
+        std::match_results<const wchar_t*> m;
+        const wchar_t s[] = L"abcdefghijk";
+        assert(std::regex_search(s, m, std::wregex(L"cd((e)fg)hi")));
+
+        const wchar_t fmt[] = L"match: &, m[1]: \\1, m[2]: \\2";
+        std::wstring out = m.format(fmt, std::regex_constants::format_sed);
+        assert(out == L"match: cdefghi, m[1]: efg, m[2]: e");
+    }
+}
diff --git a/final/test/re/re.results/re.results.nonmember/equal.pass.cpp b/final/test/re/re.results/re.results.nonmember/equal.pass.cpp
new file mode 100644
index 0000000..7902b8e
--- /dev/null
+++ b/final/test/re/re.results/re.results.nonmember/equal.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class BidirectionalIterator, class Allocator>
+//    bool
+//    operator==(const match_results<BidirectionalIterator, Allocator>& m1,
+//               const match_results<BidirectionalIterator, Allocator>& m2);
+
+// template <class BidirectionalIterator, class Allocator>
+//    bool
+//    operator!=(const match_results<BidirectionalIterator, Allocator>& m1,
+//               const match_results<BidirectionalIterator, Allocator>& m2);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m1;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+    std::match_results<const char*> m2;
+
+    assert(m1 == m1);
+    assert(m1 != m2);
+
+    m2 = m1;
+
+    assert(m1 == m2);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.size/empty.pass.cpp b/final/test/re/re.results/re.results.size/empty.pass.cpp
new file mode 100644
index 0000000..6634d92
--- /dev/null
+++ b/final/test/re/re.results/re.results.size/empty.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// size_type size() const;
+// bool empty() const;
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+    std::match_results<const CharT*> m;
+    assert(m.empty());
+    assert(m.size() == 0);
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+    assert(!m.empty());
+    assert(m.size() == 3);
+}
+
+int main()
+{
+    test<char>();
+}
diff --git a/final/test/re/re.results/re.results.size/max_size.pass.cpp b/final/test/re/re.results/re.results.size/max_size.pass.cpp
new file mode 100644
index 0000000..0b31409
--- /dev/null
+++ b/final/test/re/re.results/re.results.size/max_size.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// size_type max_size() const;
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test()
+{
+    std::match_results<const CharT*> m;
+    assert(m.max_size() > 0);
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.results/re.results.state/ready.pass.cpp b/final/test/re/re.results/re.results.state/ready.pass.cpp
new file mode 100644
index 0000000..8f586c3
--- /dev/null
+++ b/final/test/re/re.results/re.results.state/ready.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// bool ready() const;
+
+#include <regex>
+#include <cassert>
+
+void
+test1()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(m.ready() == false);
+    std::regex_search(s, m, std::regex("cd((e)fg)hi"));
+    assert(m.ready() == true);
+}
+
+void
+test2()
+{
+    std::match_results<const char*> m;
+    const char s[] = "abcdefghijk";
+    assert(m.ready() == false);
+    std::regex_search(s, m, std::regex("z"));
+    assert(m.ready() == true);
+}
+
+int main()
+{
+    test1();
+    test2();
+}
diff --git a/final/test/re/re.results/re.results.swap/member_swap.pass.cpp b/final/test/re/re.results/re.results.swap/member_swap.pass.cpp
new file mode 100644
index 0000000..09b85c0
--- /dev/null
+++ b/final/test/re/re.results/re.results.swap/member_swap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// void swap(match_results& that);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m1;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+    std::match_results<const char*> m2;
+
+    std::match_results<const char*> m1_save = m1;
+    std::match_results<const char*> m2_save = m2;
+
+    m1.swap(m2);
+
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/re.results.swap/non_member_swap.pass.cpp b/final/test/re/re.results/re.results.swap/non_member_swap.pass.cpp
new file mode 100644
index 0000000..3f5e34d
--- /dev/null
+++ b/final/test/re/re.results/re.results.swap/non_member_swap.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// class match_results<BidirectionalIterator, Allocator>
+
+// template <class BidirectionalIterator, class Allocator>
+//    void swap(match_results<BidirectionalIterator, Allocator>& m1,
+//              match_results<BidirectionalIterator, Allocator>& m2);
+
+#include <regex>
+#include <cassert>
+
+void
+test()
+{
+    std::match_results<const char*> m1;
+    const char s[] = "abcdefghijk";
+    assert(std::regex_search(s, m1, std::regex("cd((e)fg)hi")));
+    std::match_results<const char*> m2;
+
+    std::match_results<const char*> m1_save = m1;
+    std::match_results<const char*> m2_save = m2;
+
+    swap(m1, m2);
+
+    assert(m1 == m2_save);
+    assert(m2 == m1_save);
+}
+
+int main()
+{
+    test();
+}
diff --git a/final/test/re/re.results/types.pass.cpp b/final/test/re/re.results/types.pass.cpp
new file mode 100644
index 0000000..4d55383
--- /dev/null
+++ b/final/test/re/re.results/types.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator,
+//           class Allocator = allocator<sub_match<BidirectionalIterator>>>
+// class match_results
+// {
+// public:
+//     typedef sub_match<BidirectionalIterator>                  value_type;
+//     typedef const value_type&                                 const_reference;
+//     typedef const_reference                                   reference;
+//     typedef /implementation-defined/                          const_iterator;
+//     typedef const_iterator                                    iterator;
+//     typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
+//     typedef typename allocator_traits<Allocator>::size_type   size_type;
+//     typedef Allocator                                         allocator_type;
+//     typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
+//     typedef basic_string<char_type>                           string_type;
+
+#include <regex>
+#include <type_traits>
+
+template <class CharT>
+void
+test()
+{
+    typedef std::match_results<CharT*> MR;
+    static_assert((std::is_same<typename MR::value_type, std::sub_match<CharT*> >::value), "");
+    static_assert((std::is_same<typename MR::const_reference, const std::sub_match<CharT*>& >::value), "");
+    static_assert((std::is_same<typename MR::reference, std::sub_match<CharT*>& >::value), "");
+    static_assert((!std::is_same<typename MR::const_iterator, void>::value), "");
+    static_assert((std::is_same<typename MR::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<typename MR::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<typename MR::allocator_type, std::allocator<std::sub_match<CharT*> > >::value), "");
+    static_assert((std::is_same<typename MR::char_type, CharT>::value), "");
+    static_assert((std::is_same<typename MR::string_type, std::basic_string<CharT> >::value), "");
+}
+
+int main()
+{
+    test<char>();
+    test<wchar_t>();
+}
diff --git a/final/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp b/final/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
new file mode 100644
index 0000000..c14d5bc
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.members/compare_string_type.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// int compare(const string_type& s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef char CharT;
+        typedef std::sub_match<const CharT*> SM;
+        typedef SM::string_type string;
+        SM sm = SM();
+        SM sm2 = SM();
+        assert(sm.compare(string()) == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.compare(string()) > 0);
+        assert(sm.compare(string("123")) == 0);
+    }
+    {
+        typedef wchar_t CharT;
+        typedef std::sub_match<const CharT*> SM;
+        typedef SM::string_type string;
+        SM sm = SM();
+        SM sm2 = SM();
+        assert(sm.compare(string()) == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.compare(string()) > 0);
+        assert(sm.compare(string(L"123")) == 0);
+    }
+}
diff --git a/final/test/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp b/final/test/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
new file mode 100644
index 0000000..0874742
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.members/compare_sub_match.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// int compare(const sub_match& s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef char CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM sm2 = SM();
+        assert(sm.compare(sm2) == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.compare(sm2) > 0);
+        sm2.first = s;
+        sm2.second = s + 3;
+        sm2.matched = true;
+        assert(sm.compare(sm2) == 0);
+    }
+    {
+        typedef wchar_t CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM sm2 = SM();
+        assert(sm.compare(sm2) == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.compare(sm2) > 0);
+        sm2.first = s;
+        sm2.second = s + 3;
+        sm2.matched = true;
+        assert(sm.compare(sm2) == 0);
+    }
+}
diff --git a/final/test/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp b/final/test/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
new file mode 100644
index 0000000..48c05ca
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.members/compare_value_type_ptr.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// int compare(const value_type* s) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef char CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM sm2 = SM();
+        assert(sm.compare("") == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.compare("") > 0);
+        assert(sm.compare("123") == 0);
+    }
+    {
+        typedef wchar_t CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM sm2 = SM();
+        assert(sm.compare(L"") == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.compare(L"") > 0);
+        assert(sm.compare(L"123") == 0);
+    }
+}
diff --git a/final/test/re/re.submatch/re.submatch.members/default.pass.cpp b/final/test/re/re.submatch/re.submatch.members/default.pass.cpp
new file mode 100644
index 0000000..451466a
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.members/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// constexpr sub_match();
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef char CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm;
+        assert(sm.matched == false);
+    }
+    {
+        typedef wchar_t CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm;
+        assert(sm.matched == false);
+    }
+}
diff --git a/final/test/re/re.submatch/re.submatch.members/length.pass.cpp b/final/test/re/re.submatch/re.submatch.members/length.pass.cpp
new file mode 100644
index 0000000..4874c0d
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.members/length.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// difference_type length() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef char CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        assert(sm.length() == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.length() == 3);
+    }
+    {
+        typedef wchar_t CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        assert(sm.length() == 0);
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        assert(sm.length() == 3);
+    }
+}
diff --git a/final/test/re/re.submatch/re.submatch.members/operator_string.pass.cpp b/final/test/re/re.submatch/re.submatch.members/operator_string.pass.cpp
new file mode 100644
index 0000000..dd856a5
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.members/operator_string.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// operator string_type() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef char CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM::string_type str = sm;
+        assert(str.empty());
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        str = sm;
+        assert(str == std::string("123"));
+    }
+    {
+        typedef wchar_t CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM::string_type str = sm;
+        assert(str.empty());
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        str = sm;
+        assert(str == std::wstring(L"123"));
+    }
+}
diff --git a/final/test/re/re.submatch/re.submatch.members/str.pass.cpp b/final/test/re/re.submatch/re.submatch.members/str.pass.cpp
new file mode 100644
index 0000000..ca5fd7d
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.members/str.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// string_type str() const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef char CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM::string_type str = sm.str();
+        assert(str.empty());
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        str = sm.str();
+        assert(str == std::string("123"));
+    }
+    {
+        typedef wchar_t CharT;
+        typedef std::sub_match<const CharT*> SM;
+        SM sm = SM();
+        SM::string_type str = sm.str();
+        assert(str.empty());
+        const CharT s[] = {'1', '2', '3', 0};
+        sm.first = s;
+        sm.second = s + 3;
+        sm.matched = true;
+        str = sm.str();
+        assert(str == std::wstring(L"123"));
+    }
+}
diff --git a/final/test/re/re.submatch/re.submatch.op/compare.pass.cpp b/final/test/re/re.submatch/re.submatch.op/compare.pass.cpp
new file mode 100644
index 0000000..45e72ad
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.op/compare.pass.cpp
@@ -0,0 +1,283 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// template <class BiIter>
+//     bool
+//     operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+//               const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+//               const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+//                     const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator==(const sub_match<BiIter>& lhs,
+//                const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator!=(const sub_match<BiIter>& lhs,
+//                const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator<(const sub_match<BiIter>& lhs,
+//               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool operator>(const sub_match<BiIter>& lhs,
+//                    const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator>=(const sub_match<BiIter>& lhs,
+//                const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter, class ST, class SA>
+//     bool
+//     operator<=(const sub_match<BiIter>& lhs,
+//                const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator==(typename iterator_traits<BiIter>::value_type const* lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator!=(typename iterator_traits<BiIter>::value_type const* lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<(typename iterator_traits<BiIter>::value_type const* lhs,
+//               const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>(typename iterator_traits<BiIter>::value_type const* lhs,
+//               const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>=(typename iterator_traits<BiIter>::value_type const* lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<=(typename iterator_traits<BiIter>::value_type const* lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator==(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator!=(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<(const sub_match<BiIter>& lhs,
+//               typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>(const sub_match<BiIter>& lhs,
+//               typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>=(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<=(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const* rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator==(typename iterator_traits<BiIter>::value_type const& lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator!=(typename iterator_traits<BiIter>::value_type const& lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<(typename iterator_traits<BiIter>::value_type const& lhs,
+//               const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>(typename iterator_traits<BiIter>::value_type const& lhs,
+//               const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>=(typename iterator_traits<BiIter>::value_type const& lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<=(typename iterator_traits<BiIter>::value_type const& lhs,
+//                const sub_match<BiIter>& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator==(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator!=(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<(const sub_match<BiIter>& lhs,
+//               typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>(const sub_match<BiIter>& lhs,
+//               typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator>=(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const& rhs);
+//
+// template <class BiIter>
+//     bool
+//     operator<=(const sub_match<BiIter>& lhs,
+//                typename iterator_traits<BiIter>::value_type const& rhs);
+
+#include <regex>
+#include <cassert>
+
+template <class CharT>
+void
+test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y)
+{
+    typedef std::basic_string<CharT> string;
+    typedef std::sub_match<typename string::const_iterator> sub_match;
+    sub_match sm1;
+    sm1.first = x.begin();
+    sm1.second = x.end();
+    sm1.matched = true;
+    sub_match sm2;
+    sm2.first = y.begin();
+    sm2.second = y.end();
+    sm2.matched = true;
+    assert((sm1 == sm2) == (x == y));
+    assert((sm1 != sm2) == (x != y));
+    assert((sm1 < sm2) == (x < y));
+    assert((sm1 > sm2) == (x > y));
+    assert((sm1 <= sm2) == (x <= y));
+    assert((sm1 >= sm2) == (x >= y));
+    assert((x == sm2) == (x == y));
+    assert((x != sm2) == (x != y));
+    assert((x < sm2) == (x < y));
+    assert((x > sm2) == (x > y));
+    assert((x <= sm2) == (x <= y));
+    assert((x >= sm2) == (x >= y));
+    assert((sm1 == y) == (x == y));
+    assert((sm1 != y) == (x != y));
+    assert((sm1 < y) == (x < y));
+    assert((sm1 > y) == (x > y));
+    assert((sm1 <= y) == (x <= y));
+    assert((sm1 >= y) == (x >= y));
+    assert((x.c_str() == sm2) == (x == y));
+    assert((x.c_str() != sm2) == (x != y));
+    assert((x.c_str() < sm2) == (x < y));
+    assert((x.c_str() > sm2) == (x > y));
+    assert((x.c_str() <= sm2) == (x <= y));
+    assert((x.c_str() >= sm2) == (x >= y));
+    assert((sm1 == y.c_str()) == (x == y));
+    assert((sm1 != y.c_str()) == (x != y));
+    assert((sm1 < y.c_str()) == (x < y));
+    assert((sm1 > y.c_str()) == (x > y));
+    assert((sm1 <= y.c_str()) == (x <= y));
+    assert((sm1 >= y.c_str()) == (x >= y));
+    assert((x[0] == sm2) == (string(1, x[0]) == y));
+    assert((x[0] != sm2) == (string(1, x[0]) != y));
+    assert((x[0] < sm2) == (string(1, x[0]) < y));
+    assert((x[0] > sm2) == (string(1, x[0]) > y));
+    assert((x[0] <= sm2) == (string(1, x[0]) <= y));
+    assert((x[0] >= sm2) == (string(1, x[0]) >= y));
+    assert((sm1 == y[0]) == (x == string(1, y[0])));
+    assert((sm1 != y[0]) == (x != string(1, y[0])));
+    assert((sm1 < y[0]) == (x < string(1, y[0])));
+    assert((sm1 > y[0]) == (x > string(1, y[0])));
+    assert((sm1 <= y[0]) == (x <= string(1, y[0])));
+    assert((sm1 >= y[0]) == (x >= string(1, y[0])));
+}
+
+int main()
+{
+    test(std::string("123"), std::string("123"));
+    test(std::string("1234"), std::string("123"));
+    test(std::wstring(L"123"), std::wstring(L"123"));
+    test(std::wstring(L"1234"), std::wstring(L"123"));
+}
diff --git a/final/test/re/re.submatch/re.submatch.op/stream.pass.cpp b/final/test/re/re.submatch/re.submatch.op/stream.pass.cpp
new file mode 100644
index 0000000..050bb06
--- /dev/null
+++ b/final/test/re/re.submatch/re.submatch.op/stream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator> class sub_match;
+
+// template <class charT, class ST, class BiIter>
+//     basic_ostream<charT, ST>&
+//     operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
+
+#include <regex>
+#include <sstream>
+#include <cassert>
+
+template <class CharT>
+void
+test(const std::basic_string<CharT>& s)
+{
+    typedef std::basic_string<CharT> string;
+    typedef std::sub_match<typename string::const_iterator> SM;
+    typedef std::basic_ostringstream<CharT> ostringstream;
+    SM sm;
+    sm.first = s.begin();
+    sm.second = s.end();
+    sm.matched = true;
+    ostringstream os;
+    os << sm;
+    assert(os.str() == s);
+}
+
+int main()
+{
+    test(std::string("123"));
+    test(std::wstring(L"123"));
+}
diff --git a/final/test/re/re.submatch/types.pass.cpp b/final/test/re/re.submatch/types.pass.cpp
new file mode 100644
index 0000000..47c7914
--- /dev/null
+++ b/final/test/re/re.submatch/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class BidirectionalIterator>
+// class sub_match
+//     : public pair<BidirectionalIterator, BidirectionalIterator>
+// {
+// public:
+//     typedef BidirectionalIterator                               iterator;
+//     typedef typename iterator_traits<iterator>::value_type      value_type;
+//     typedef typename iterator_traits<iterator>::difference_type difference_type;
+//     typedef basic_string<value_type>                            string_type;
+//
+//     bool matched;
+//     ...
+// };
+
+#include <regex>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::sub_match<char*> SM;
+        static_assert((std::is_same<SM::iterator, char*>::value), "");
+        static_assert((std::is_same<SM::value_type, char>::value), "");
+        static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
+        static_assert((std::is_same<SM::string_type, std::string>::value), "");
+        static_assert((std::is_convertible<SM*, std::pair<char*, char*>*>::value), "");
+
+        SM sm;
+        sm.first = nullptr;
+        sm.second = nullptr;
+        sm.matched = false;
+    }
+    {
+        typedef std::sub_match<wchar_t*> SM;
+        static_assert((std::is_same<SM::iterator, wchar_t*>::value), "");
+        static_assert((std::is_same<SM::value_type, wchar_t>::value), "");
+        static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
+        static_assert((std::is_same<SM::string_type, std::wstring>::value), "");
+        static_assert((std::is_convertible<SM*, std::pair<wchar_t*, wchar_t*>*>::value), "");
+
+        SM sm;
+        sm.first = nullptr;
+        sm.second = nullptr;
+        sm.matched = false;
+    }
+    {
+        static_assert((std::is_same<std::csub_match, std::sub_match<const char*> >::value), "");
+        static_assert((std::is_same<std::wcsub_match, std::sub_match<const wchar_t*> >::value), "");
+        static_assert((std::is_same<std::ssub_match, std::sub_match<std::string::const_iterator> >::value), "");
+        static_assert((std::is_same<std::wssub_match, std::sub_match<std::wstring::const_iterator> >::value), "");
+    }
+}
diff --git a/final/test/re/re.syn/cmatch.pass.cpp b/final/test/re/re.syn/cmatch.pass.cpp
new file mode 100644
index 0000000..1364b78
--- /dev/null
+++ b/final/test/re/re.syn/cmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<const char*>   cmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::match_results<const char*>, std::cmatch>::value), "");
+}
diff --git a/final/test/re/re.syn/cregex_iterator.pass.cpp b/final/test/re/re.syn/cregex_iterator.pass.cpp
new file mode 100644
index 0000000..7b6ac13
--- /dev/null
+++ b/final/test/re/re.syn/cregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<const char*>   cregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_iterator<const char*>, std::cregex_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/cregex_token_iterator.pass.cpp b/final/test/re/re.syn/cregex_token_iterator.pass.cpp
new file mode 100644
index 0000000..36ee9b6
--- /dev/null
+++ b/final/test/re/re.syn/cregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<const char*>   cregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_token_iterator<const char*>, std::cregex_token_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/csub_match.pass.cpp b/final/test/re/re.syn/csub_match.pass.cpp
new file mode 100644
index 0000000..e0de67b
--- /dev/null
+++ b/final/test/re/re.syn/csub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<const char*>   csub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::sub_match<const char*>, std::csub_match>::value), "");
+}
diff --git a/final/test/re/re.syn/regex.pass.cpp b/final/test/re/re.syn/regex.pass.cpp
new file mode 100644
index 0000000..a208442
--- /dev/null
+++ b/final/test/re/re.syn/regex.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef basic_regex<char>    regex;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::basic_regex<char>, std::regex>::value), "");
+}
diff --git a/final/test/re/re.syn/smatch.pass.cpp b/final/test/re/re.syn/smatch.pass.cpp
new file mode 100644
index 0000000..8732353
--- /dev/null
+++ b/final/test/re/re.syn/smatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<string::const_iterator>   smatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::match_results<std::string::const_iterator>, std::smatch>::value), "");
+}
diff --git a/final/test/re/re.syn/sregex_iterator.pass.cpp b/final/test/re/re.syn/sregex_iterator.pass.cpp
new file mode 100644
index 0000000..7acd961
--- /dev/null
+++ b/final/test/re/re.syn/sregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<string::const_iterator>   sregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_iterator<std::string::const_iterator>, std::sregex_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/sregex_token_iterator.pass.cpp b/final/test/re/re.syn/sregex_token_iterator.pass.cpp
new file mode 100644
index 0000000..185fd62
--- /dev/null
+++ b/final/test/re/re.syn/sregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<string::const_iterator>   sregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_token_iterator<std::string::const_iterator>, std::sregex_token_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/ssub_match.pass.cpp b/final/test/re/re.syn/ssub_match.pass.cpp
new file mode 100644
index 0000000..b378339
--- /dev/null
+++ b/final/test/re/re.syn/ssub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<string::const_iterator>   ssub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::sub_match<std::string::const_iterator>, std::ssub_match>::value), "");
+}
diff --git a/final/test/re/re.syn/wcmatch.pass.cpp b/final/test/re/re.syn/wcmatch.pass.cpp
new file mode 100644
index 0000000..3ca8ed5
--- /dev/null
+++ b/final/test/re/re.syn/wcmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<const wchar_t*>   wcmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::match_results<const wchar_t*>, std::wcmatch>::value), "");
+}
diff --git a/final/test/re/re.syn/wcregex_iterator.pass.cpp b/final/test/re/re.syn/wcregex_iterator.pass.cpp
new file mode 100644
index 0000000..99469ec
--- /dev/null
+++ b/final/test/re/re.syn/wcregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<const wchar_t*>   wcregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_iterator<const wchar_t*>, std::wcregex_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/wcregex_token_iterator.pass.cpp b/final/test/re/re.syn/wcregex_token_iterator.pass.cpp
new file mode 100644
index 0000000..f16911f
--- /dev/null
+++ b/final/test/re/re.syn/wcregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<const wchar_t*>   wcregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_token_iterator<const wchar_t*>, std::wcregex_token_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/wcsub_match.pass.cpp b/final/test/re/re.syn/wcsub_match.pass.cpp
new file mode 100644
index 0000000..7e8c872
--- /dev/null
+++ b/final/test/re/re.syn/wcsub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<const wchar_t*>   wcsub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::sub_match<const wchar_t*>, std::wcsub_match>::value), "");
+}
diff --git a/final/test/re/re.syn/wregex.pass.cpp b/final/test/re/re.syn/wregex.pass.cpp
new file mode 100644
index 0000000..635eac0
--- /dev/null
+++ b/final/test/re/re.syn/wregex.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef basic_regex<wchar_t> wregex;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::basic_regex<wchar_t>, std::wregex>::value), "");
+}
diff --git a/final/test/re/re.syn/wsmatch.pass.cpp b/final/test/re/re.syn/wsmatch.pass.cpp
new file mode 100644
index 0000000..092c7d1
--- /dev/null
+++ b/final/test/re/re.syn/wsmatch.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef match_results<wstring::const_iterator>   wsmatch;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::match_results<std::wstring::const_iterator>, std::wsmatch>::value), "");
+}
diff --git a/final/test/re/re.syn/wsregex_iterator.pass.cpp b/final/test/re/re.syn/wsregex_iterator.pass.cpp
new file mode 100644
index 0000000..0052716
--- /dev/null
+++ b/final/test/re/re.syn/wsregex_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_iterator<wstring::const_iterator>   wsregex_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_iterator<std::wstring::const_iterator>, std::wsregex_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/wsregex_token_iterator.pass.cpp b/final/test/re/re.syn/wsregex_token_iterator.pass.cpp
new file mode 100644
index 0000000..dc71991
--- /dev/null
+++ b/final/test/re/re.syn/wsregex_token_iterator.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef regex_token_iterator<wstring::const_iterator>   wsregex_token_iterator;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_token_iterator<std::wstring::const_iterator>, std::wsregex_token_iterator>::value), "");
+}
diff --git a/final/test/re/re.syn/wssub_match.pass.cpp b/final/test/re/re.syn/wssub_match.pass.cpp
new file mode 100644
index 0000000..2360a15
--- /dev/null
+++ b/final/test/re/re.syn/wssub_match.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// typedef sub_match<wstring::const_iterator>   wssub_match;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::sub_match<std::wstring::const_iterator>, std::wssub_match>::value), "");
+}
diff --git a/final/test/re/re.traits/default.pass.cpp b/final/test/re/re.traits/default.pass.cpp
new file mode 100644
index 0000000..c9a97e0
--- /dev/null
+++ b/final/test/re/re.traits/default.pass.cpp
@@ -0,0 +1,37 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// regex_traits();
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::regex_traits<char> t1;
+        assert(t1.getloc().name() == "C");
+        std::regex_traits<wchar_t> t2;
+        assert(t2.getloc().name() == "C");
+    }
+    {
+        std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+        std::regex_traits<char> t1;
+        assert(t1.getloc().name() == LOCALE_en_US_UTF_8);
+        std::regex_traits<wchar_t> t2;
+        assert(t2.getloc().name() == LOCALE_en_US_UTF_8);
+    }
+}
diff --git a/final/test/re/re.traits/getloc.pass.cpp b/final/test/re/re.traits/getloc.pass.cpp
new file mode 100644
index 0000000..27ab6cd
--- /dev/null
+++ b/final/test/re/re.traits/getloc.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// locale_type getloc()const;
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::regex_traits<char> t1;
+        assert(t1.getloc().name() == "C");
+        std::regex_traits<wchar_t> t2;
+        assert(t2.getloc().name() == "C");
+    }
+    {
+        std::locale::global(std::locale(LOCALE_en_US_UTF_8));
+        std::regex_traits<char> t1;
+        assert(t1.getloc().name() == LOCALE_en_US_UTF_8);
+        std::regex_traits<wchar_t> t2;
+        assert(t2.getloc().name() == LOCALE_en_US_UTF_8);
+    }
+}
diff --git a/final/test/re/re.traits/imbue.pass.cpp b/final/test/re/re.traits/imbue.pass.cpp
new file mode 100644
index 0000000..11eca41
--- /dev/null
+++ b/final/test/re/re.traits/imbue.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// locale_type imbue(locale_type l);
+
+#include <regex>
+#include <locale>
+#include <cassert>
+
+#include "platform_support.h" // locale name macros
+
+int main()
+{
+    {
+        std::regex_traits<char> t;
+        std::locale loc = t.imbue(std::locale(LOCALE_en_US_UTF_8));
+        assert(loc.name() == "C");
+        assert(t.getloc().name() == LOCALE_en_US_UTF_8);
+    }
+}
diff --git a/final/test/re/re.traits/isctype.pass.cpp b/final/test/re/re.traits/isctype.pass.cpp
new file mode 100644
index 0000000..ad69f05
--- /dev/null
+++ b/final/test/re/re.traits/isctype.pass.cpp
@@ -0,0 +1,279 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// bool isctype(charT c, char_class_type f) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex_traits<char> t;
+
+        std::string s("w");
+        assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "alnum";
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "alpha";
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "blank";
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "cntrl";
+        assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "digit";
+        assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "graph";
+        assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "lower";
+        assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "print";
+        assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "punct";
+        assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "space";
+        assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "upper";
+        assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+        s = "xdigit";
+        assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+    }
+    {
+        std::regex_traits<wchar_t> t;
+
+        std::wstring s(L"w");
+        assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"alnum";
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"alpha";
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"blank";
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"cntrl";
+        assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"digit";
+        assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"graph";
+        assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"lower";
+        assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"print";
+        assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"punct";
+        assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"space";
+        assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"upper";
+        assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+        s = L"xdigit";
+        assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+        assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+        assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+    }
+}
diff --git a/final/test/re/re.traits/length.pass.cpp b/final/test/re/re.traits/length.pass.cpp
new file mode 100644
index 0000000..473c233
--- /dev/null
+++ b/final/test/re/re.traits/length.pass.cpp
@@ -0,0 +1,31 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// static std::size_t length(const char_type* p);
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    assert(std::regex_traits<char>::length("") == 0);
+    assert(std::regex_traits<char>::length("1") == 1);
+    assert(std::regex_traits<char>::length("12") == 2);
+    assert(std::regex_traits<char>::length("123") == 3);
+
+    assert(std::regex_traits<wchar_t>::length(L"") == 0);
+    assert(std::regex_traits<wchar_t>::length(L"1") == 1);
+    assert(std::regex_traits<wchar_t>::length(L"12") == 2);
+    assert(std::regex_traits<wchar_t>::length(L"123") == 3);
+}
diff --git a/final/test/re/re.traits/lookup_classname.pass.cpp b/final/test/re/re.traits/lookup_classname.pass.cpp
new file mode 100644
index 0000000..75c0888
--- /dev/null
+++ b/final/test/re/re.traits/lookup_classname.pass.cpp
@@ -0,0 +1,209 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+//   char_class_type
+//   lookup_classname(ForwardIterator first, ForwardIterator last,
+//                    bool icase = false) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+template <class char_type>
+void
+test(const char_type* A, std::ctype_base::mask expected, bool icase = false)
+{
+    std::regex_traits<char_type> t;
+    typedef forward_iterator<const char_type*> F;
+    assert(t.lookup_classname(F(A), F(A + t.length(A)), icase) == expected);
+}
+
+int main()
+{
+    test("d", std::ctype_base::digit);
+    test("D", std::ctype_base::digit);
+    test("d", std::ctype_base::digit, true);
+    test("D", std::ctype_base::digit, true);
+
+    test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower);
+    test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower);
+    test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower, true);
+    test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower, true);
+
+    test("s", std::ctype_base::space);
+    test("S", std::ctype_base::space);
+    test("s", std::ctype_base::space, true);
+    test("S", std::ctype_base::space, true);
+
+    test("alnum", std::ctype_base::alnum);
+    test("AlNum", std::ctype_base::alnum);
+    test("alnum", std::ctype_base::alnum, true);
+    test("AlNum", std::ctype_base::alnum, true);
+
+    test("alpha", std::ctype_base::alpha);
+    test("Alpha", std::ctype_base::alpha);
+    test("alpha", std::ctype_base::alpha, true);
+    test("Alpha", std::ctype_base::alpha, true);
+
+    test("blank", std::ctype_base::blank);
+    test("Blank", std::ctype_base::blank);
+    test("blank", std::ctype_base::blank, true);
+    test("Blank", std::ctype_base::blank, true);
+
+    test("cntrl", std::ctype_base::cntrl);
+    test("Cntrl", std::ctype_base::cntrl);
+    test("cntrl", std::ctype_base::cntrl, true);
+    test("Cntrl", std::ctype_base::cntrl, true);
+
+    test("digit", std::ctype_base::digit);
+    test("Digit", std::ctype_base::digit);
+    test("digit", std::ctype_base::digit, true);
+    test("Digit", std::ctype_base::digit, true);
+
+    test("digit", std::ctype_base::digit);
+    test("DIGIT", std::ctype_base::digit);
+    test("digit", std::ctype_base::digit, true);
+    test("Digit", std::ctype_base::digit, true);
+
+    test("graph", std::ctype_base::graph);
+    test("GRAPH", std::ctype_base::graph);
+    test("graph", std::ctype_base::graph, true);
+    test("Graph", std::ctype_base::graph, true);
+
+    test("lower", std::ctype_base::lower);
+    test("LOWER", std::ctype_base::lower);
+    test("lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+    test("Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+    test("print", std::ctype_base::print);
+    test("PRINT", std::ctype_base::print);
+    test("print", std::ctype_base::print, true);
+    test("Print", std::ctype_base::print, true);
+
+    test("punct", std::ctype_base::punct);
+    test("PUNCT", std::ctype_base::punct);
+    test("punct", std::ctype_base::punct, true);
+    test("Punct", std::ctype_base::punct, true);
+
+    test("space", std::ctype_base::space);
+    test("SPACE", std::ctype_base::space);
+    test("space", std::ctype_base::space, true);
+    test("Space", std::ctype_base::space, true);
+
+    test("upper", std::ctype_base::upper);
+    test("UPPER", std::ctype_base::upper);
+    test("upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+    test("Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+    test("xdigit", std::ctype_base::xdigit);
+    test("XDIGIT", std::ctype_base::xdigit);
+    test("xdigit", std::ctype_base::xdigit, true);
+    test("Xdigit", std::ctype_base::xdigit, true);
+
+    test("dig", std::ctype_base::mask());
+    test("", std::ctype_base::mask());
+    test("digits", std::ctype_base::mask());
+
+    test(L"d", std::ctype_base::digit);
+    test(L"D", std::ctype_base::digit);
+    test(L"d", std::ctype_base::digit, true);
+    test(L"D", std::ctype_base::digit, true);
+
+    test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower);
+    test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower);
+    test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower, true);
+    test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+                      | std::ctype_base::upper | std::ctype_base::lower, true);
+
+    test(L"s", std::ctype_base::space);
+    test(L"S", std::ctype_base::space);
+    test(L"s", std::ctype_base::space, true);
+    test(L"S", std::ctype_base::space, true);
+
+    test(L"alnum", std::ctype_base::alnum);
+    test(L"AlNum", std::ctype_base::alnum);
+    test(L"alnum", std::ctype_base::alnum, true);
+    test(L"AlNum", std::ctype_base::alnum, true);
+
+    test(L"alpha", std::ctype_base::alpha);
+    test(L"Alpha", std::ctype_base::alpha);
+    test(L"alpha", std::ctype_base::alpha, true);
+    test(L"Alpha", std::ctype_base::alpha, true);
+
+    test(L"blank", std::ctype_base::blank);
+    test(L"Blank", std::ctype_base::blank);
+    test(L"blank", std::ctype_base::blank, true);
+    test(L"Blank", std::ctype_base::blank, true);
+
+    test(L"cntrl", std::ctype_base::cntrl);
+    test(L"Cntrl", std::ctype_base::cntrl);
+    test(L"cntrl", std::ctype_base::cntrl, true);
+    test(L"Cntrl", std::ctype_base::cntrl, true);
+
+    test(L"digit", std::ctype_base::digit);
+    test(L"Digit", std::ctype_base::digit);
+    test(L"digit", std::ctype_base::digit, true);
+    test(L"Digit", std::ctype_base::digit, true);
+
+    test(L"digit", std::ctype_base::digit);
+    test(L"DIGIT", std::ctype_base::digit);
+    test(L"digit", std::ctype_base::digit, true);
+    test(L"Digit", std::ctype_base::digit, true);
+
+    test(L"graph", std::ctype_base::graph);
+    test(L"GRAPH", std::ctype_base::graph);
+    test(L"graph", std::ctype_base::graph, true);
+    test(L"Graph", std::ctype_base::graph, true);
+
+    test(L"lower", std::ctype_base::lower);
+    test(L"LOWER", std::ctype_base::lower);
+    test(L"lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+    test(L"Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+    test(L"print", std::ctype_base::print);
+    test(L"PRINT", std::ctype_base::print);
+    test(L"print", std::ctype_base::print, true);
+    test(L"Print", std::ctype_base::print, true);
+
+    test(L"punct", std::ctype_base::punct);
+    test(L"PUNCT", std::ctype_base::punct);
+    test(L"punct", std::ctype_base::punct, true);
+    test(L"Punct", std::ctype_base::punct, true);
+
+    test(L"space", std::ctype_base::space);
+    test(L"SPACE", std::ctype_base::space);
+    test(L"space", std::ctype_base::space, true);
+    test(L"Space", std::ctype_base::space, true);
+
+    test(L"upper", std::ctype_base::upper);
+    test(L"UPPER", std::ctype_base::upper);
+    test(L"upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+    test(L"Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+    test(L"xdigit", std::ctype_base::xdigit);
+    test(L"XDIGIT", std::ctype_base::xdigit);
+    test(L"xdigit", std::ctype_base::xdigit, true);
+    test(L"Xdigit", std::ctype_base::xdigit, true);
+
+    test(L"dig", std::ctype_base::mask());
+    test(L"", std::ctype_base::mask());
+    test(L"digits", std::ctype_base::mask());
+}
diff --git a/final/test/re/re.traits/lookup_collatename.pass.cpp b/final/test/re/re.traits/lookup_collatename.pass.cpp
new file mode 100644
index 0000000..055b554
--- /dev/null
+++ b/final/test/re/re.traits/lookup_collatename.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+//   string_type
+//   lookup_collatename(ForwardIterator first, ForwardIterator last) const;
+
+#include <regex>
+#include <iterator>
+#include <cassert>
+#include "test_iterators.h"
+
+template <class char_type>
+void
+test(const char_type* A, const std::basic_string<char_type>& expected)
+{
+    std::regex_traits<char_type> t;
+    typedef forward_iterator<const char_type*> F;
+    assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected);
+}
+
+int main()
+{
+    test("NUL", std::string("\x00", 1));
+    test("alert", std::string("\x07"));
+    test("backspace", std::string("\x08"));
+    test("tab", std::string("\x09"));
+    test("carriage-return", std::string("\x0D"));
+    test("newline", std::string("\x0A"));
+    test("vertical-tab", std::string("\x0B"));
+    test("form-feed", std::string("\x0C"));
+    test("space", std::string(" "));
+    test("exclamation-mark", std::string("!"));
+    test("quotation-mark", std::string("\""));
+    test("number-sign", std::string("#"));
+    test("dollar-sign", std::string("$"));
+    test("percent-sign", std::string("%"));
+    test("ampersand", std::string("&"));
+    test("apostrophe", std::string("\'"));
+    test("left-parenthesis", std::string("("));
+    test("right-parenthesis", std::string(")"));
+    test("asterisk", std::string("*"));
+    test("plus-sign", std::string("+"));
+    test("comma", std::string(","));
+    test("hyphen-minus", std::string("-"));
+    test("hyphen", std::string("-"));
+    test("full-stop", std::string("."));
+    test("period", std::string("."));
+    test("slash", std::string("/"));
+    test("solidus", std::string("/"));
+    test("zero", std::string("0"));
+    test("one", std::string("1"));
+    test("two", std::string("2"));
+    test("three", std::string("3"));
+    test("four", std::string("4"));
+    test("five", std::string("5"));
+    test("six", std::string("6"));
+    test("seven", std::string("7"));
+    test("eight", std::string("8"));
+    test("nine", std::string("9"));
+    test("colon", std::string(":"));
+    test("semicolon", std::string(";"));
+    test("less-than-sign", std::string("<"));
+    test("equals-sign", std::string("="));
+    test("greater-than-sign", std::string(">"));
+    test("question-mark", std::string("?"));
+    test("commercial-at", std::string("@"));
+    for (char c = 'A'; c <= 'Z'; ++c)
+    {
+        const char a[2] = {c};
+        test(a, std::string(a));
+    }
+    test("left-square-bracket", std::string("["));
+    test("backslash", std::string("\\"));
+    test("reverse-solidus", std::string("\\"));
+    test("right-square-bracket", std::string("]"));
+    test("circumflex-accent", std::string("^"));
+    test("circumflex", std::string("^"));
+    test("low-line", std::string("_"));
+    test("underscore", std::string("_"));
+    test("grave-accent", std::string("`"));
+    for (char c = 'a'; c <= 'z'; ++c)
+    {
+        const char a[2] = {c};
+        test(a, std::string(a));
+    }
+    test("left-brace", std::string("{"));
+    test("left-curly-bracket", std::string("{"));
+    test("vertical-line", std::string("|"));
+    test("right-brace", std::string("}"));
+    test("right-curly-bracket", std::string("}"));
+    test("tilde", std::string("~"));
+
+    test("tild", std::string(""));
+    test("ch", std::string(""));
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    test("ch", std::string("ch"));
+    std::locale::global(std::locale("C"));
+
+    test(L"NUL", std::wstring(L"\x00", 1));
+    test(L"alert", std::wstring(L"\x07"));
+    test(L"backspace", std::wstring(L"\x08"));
+    test(L"tab", std::wstring(L"\x09"));
+    test(L"carriage-return", std::wstring(L"\x0D"));
+    test(L"newline", std::wstring(L"\x0A"));
+    test(L"vertical-tab", std::wstring(L"\x0B"));
+    test(L"form-feed", std::wstring(L"\x0C"));
+    test(L"space", std::wstring(L" "));
+    test(L"exclamation-mark", std::wstring(L"!"));
+    test(L"quotation-mark", std::wstring(L"\""));
+    test(L"number-sign", std::wstring(L"#"));
+    test(L"dollar-sign", std::wstring(L"$"));
+    test(L"percent-sign", std::wstring(L"%"));
+    test(L"ampersand", std::wstring(L"&"));
+    test(L"apostrophe", std::wstring(L"\'"));
+    test(L"left-parenthesis", std::wstring(L"("));
+    test(L"right-parenthesis", std::wstring(L")"));
+    test(L"asterisk", std::wstring(L"*"));
+    test(L"plus-sign", std::wstring(L"+"));
+    test(L"comma", std::wstring(L","));
+    test(L"hyphen-minus", std::wstring(L"-"));
+    test(L"hyphen", std::wstring(L"-"));
+    test(L"full-stop", std::wstring(L"."));
+    test(L"period", std::wstring(L"."));
+    test(L"slash", std::wstring(L"/"));
+    test(L"solidus", std::wstring(L"/"));
+    test(L"zero", std::wstring(L"0"));
+    test(L"one", std::wstring(L"1"));
+    test(L"two", std::wstring(L"2"));
+    test(L"three", std::wstring(L"3"));
+    test(L"four", std::wstring(L"4"));
+    test(L"five", std::wstring(L"5"));
+    test(L"six", std::wstring(L"6"));
+    test(L"seven", std::wstring(L"7"));
+    test(L"eight", std::wstring(L"8"));
+    test(L"nine", std::wstring(L"9"));
+    test(L"colon", std::wstring(L":"));
+    test(L"semicolon", std::wstring(L";"));
+    test(L"less-than-sign", std::wstring(L"<"));
+    test(L"equals-sign", std::wstring(L"="));
+    test(L"greater-than-sign", std::wstring(L">"));
+    test(L"question-mark", std::wstring(L"?"));
+    test(L"commercial-at", std::wstring(L"@"));
+    for (wchar_t c = L'A'; c <= L'Z'; ++c)
+    {
+        const wchar_t a[2] = {c};
+        test(a, std::wstring(a));
+    }
+    test(L"left-square-bracket", std::wstring(L"["));
+    test(L"backslash", std::wstring(L"\\"));
+    test(L"reverse-solidus", std::wstring(L"\\"));
+    test(L"right-square-bracket", std::wstring(L"]"));
+    test(L"circumflex-accent", std::wstring(L"^"));
+    test(L"circumflex", std::wstring(L"^"));
+    test(L"low-line", std::wstring(L"_"));
+    test(L"underscore", std::wstring(L"_"));
+    test(L"grave-accent", std::wstring(L"`"));
+    for (wchar_t c = L'a'; c <= L'z'; ++c)
+    {
+        const wchar_t a[2] = {c};
+        test(a, std::wstring(a));
+    }
+    test(L"left-brace", std::wstring(L"{"));
+    test(L"left-curly-bracket", std::wstring(L"{"));
+    test(L"vertical-line", std::wstring(L"|"));
+    test(L"right-brace", std::wstring(L"}"));
+    test(L"right-curly-bracket", std::wstring(L"}"));
+    test(L"tilde", std::wstring(L"~"));
+
+    test(L"tild", std::wstring(L""));
+    test(L"ch", std::wstring(L""));
+    std::locale::global(std::locale("cs_CZ.ISO8859-2"));
+    test(L"ch", std::wstring(L"ch"));
+    std::locale::global(std::locale("C"));
+}
diff --git a/final/test/re/re.traits/transform.pass.cpp b/final/test/re/re.traits/transform.pass.cpp
new file mode 100644
index 0000000..9b9feb1
--- /dev/null
+++ b/final/test/re/re.traits/transform.pass.cpp
@@ -0,0 +1,42 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+//   string_type transform(ForwardIterator first, ForwardIterator last) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::regex_traits<char> t;
+        const char a[] = "a";
+        const char B[] = "B";
+        typedef forward_iterator<const char*> F;
+        assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
+        t.imbue(std::locale("cs_CZ.ISO8859-2"));
+        assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
+    }
+    {
+        std::regex_traits<wchar_t> t;
+        const wchar_t a[] = L"a";
+        const wchar_t B[] = L"B";
+        typedef forward_iterator<const wchar_t*> F;
+        assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1)));
+        t.imbue(std::locale("cs_CZ.ISO8859-2"));
+        assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1)));
+    }
+}
diff --git a/final/test/re/re.traits/transform_primary.pass.cpp b/final/test/re/re.traits/transform_primary.pass.cpp
new file mode 100644
index 0000000..1e2aca6
--- /dev/null
+++ b/final/test/re/re.traits/transform_primary.pass.cpp
@@ -0,0 +1,47 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// template <class ForwardIterator>
+//   string_type
+//   transform_primary(ForwardIterator first, ForwardIterator last) const;
+
+#include <regex>
+#include <cassert>
+#include "test_iterators.h"
+
+int main()
+{
+    {
+        std::regex_traits<char> t;
+        const char A[] = "A";
+        const char Aacute[] = "\xC1";
+        typedef forward_iterator<const char*> F;
+        assert(t.transform_primary(F(A), F(A+1)) !=
+               t.transform_primary(F(Aacute), F(Aacute+1)));
+        t.imbue(std::locale("cs_CZ.ISO8859-2"));
+        assert(t.transform_primary(F(A), F(A+1)) ==
+               t.transform_primary(F(Aacute), F(Aacute+1)));
+    }
+    {
+        std::regex_traits<wchar_t> t;
+        const wchar_t A[] = L"A";
+        const wchar_t Aacute[] = L"\xC1";
+        typedef forward_iterator<const wchar_t*> F;
+        assert(t.transform_primary(F(A), F(A+1)) !=
+               t.transform_primary(F(Aacute), F(Aacute+1)));
+        t.imbue(std::locale("cs_CZ.ISO8859-2"));
+        assert(t.transform_primary(F(A), F(A+1)) ==
+               t.transform_primary(F(Aacute), F(Aacute+1)));
+    }
+}
diff --git a/final/test/re/re.traits/translate.pass.cpp b/final/test/re/re.traits/translate.pass.cpp
new file mode 100644
index 0000000..c352338
--- /dev/null
+++ b/final/test/re/re.traits/translate.pass.cpp
@@ -0,0 +1,34 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// charT translate(charT c) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex_traits<char> t;
+        assert(t.translate('a') == 'a');
+        assert(t.translate('B') == 'B');
+        assert(t.translate('c') == 'c');
+    }
+    {
+        std::regex_traits<wchar_t> t;
+        assert(t.translate(L'a') == L'a');
+        assert(t.translate(L'B') == L'B');
+        assert(t.translate(L'c') == L'c');
+    }
+}
diff --git a/final/test/re/re.traits/translate_nocase.pass.cpp b/final/test/re/re.traits/translate_nocase.pass.cpp
new file mode 100644
index 0000000..5e042ae
--- /dev/null
+++ b/final/test/re/re.traits/translate_nocase.pass.cpp
@@ -0,0 +1,67 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// charT translate_nocase(charT c) const;
+
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+#include <regex>
+#include <cassert>
+
+#include "platform_support.h"
+
+int main()
+{
+    {
+        std::regex_traits<char> t;
+        assert(t.translate_nocase(' ') == ' ');
+        assert(t.translate_nocase('A') == 'a');
+        assert(t.translate_nocase('\x07') == '\x07');
+        assert(t.translate_nocase('.') == '.');
+        assert(t.translate_nocase('a') == 'a');
+        assert(t.translate_nocase('1') == '1');
+        assert(t.translate_nocase('\xDA') == '\xDA');
+        assert(t.translate_nocase('\xFA') == '\xFA');
+        t.imbue(std::locale(LOCALE_en_US_UTF_8));
+        assert(t.translate_nocase(' ') == ' ');
+        assert(t.translate_nocase('A') == 'a');
+        assert(t.translate_nocase('\x07') == '\x07');
+        assert(t.translate_nocase('.') == '.');
+        assert(t.translate_nocase('a') == 'a');
+        assert(t.translate_nocase('1') == '1');
+        assert(t.translate_nocase('\xDA') == '\xFA');
+        assert(t.translate_nocase('\xFA') == '\xFA');
+    }
+    {
+        std::regex_traits<wchar_t> t;
+        assert(t.translate_nocase(L' ') == L' ');
+        assert(t.translate_nocase(L'A') == L'a');
+        assert(t.translate_nocase(L'\x07') == L'\x07');
+        assert(t.translate_nocase(L'.') == L'.');
+        assert(t.translate_nocase(L'a') == L'a');
+        assert(t.translate_nocase(L'1') == L'1');
+        assert(t.translate_nocase(L'\xDA') == L'\xDA');
+        assert(t.translate_nocase(L'\xFA') == L'\xFA');
+        t.imbue(std::locale(LOCALE_en_US_UTF_8));
+        assert(t.translate_nocase(L' ') == L' ');
+        assert(t.translate_nocase(L'A') == L'a');
+        assert(t.translate_nocase(L'\x07') == L'\x07');
+        assert(t.translate_nocase(L'.') == L'.');
+        assert(t.translate_nocase(L'a') == L'a');
+        assert(t.translate_nocase(L'1') == L'1');
+        assert(t.translate_nocase(L'\xDA') == L'\xFA');
+        assert(t.translate_nocase(L'\xFA') == L'\xFA');
+    }
+}
diff --git a/final/test/re/re.traits/types.pass.cpp b/final/test/re/re.traits/types.pass.cpp
new file mode 100644
index 0000000..50586a1
--- /dev/null
+++ b/final/test/re/re.traits/types.pass.cpp
@@ -0,0 +1,32 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT>
+// struct regex_traits
+// {
+// public:
+//     typedef charT                   char_type;
+//     typedef basic_string<char_type> string_type;
+//     typedef locale                  locale_type;
+
+#include <regex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::regex_traits<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::regex_traits<char>::string_type, std::string>::value), "");
+    static_assert((std::is_same<std::regex_traits<char>::locale_type, std::locale>::value), "");
+    static_assert((std::is_same<std::regex_traits<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::regex_traits<wchar_t>::string_type, std::wstring>::value), "");
+    static_assert((std::is_same<std::regex_traits<wchar_t>::locale_type, std::locale>::value), "");
+}
diff --git a/final/test/re/re.traits/value.pass.cpp b/final/test/re/re.traits/value.pass.cpp
new file mode 100644
index 0000000..349a29c
--- /dev/null
+++ b/final/test/re/re.traits/value.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT> struct regex_traits;
+
+// int value(charT ch, int radix) const;
+
+#include <regex>
+#include <cassert>
+
+int main()
+{
+    {
+        std::regex_traits<char> t;
+
+        for (char c = 0; c < '0'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == -1);
+        }
+        for (char c = '0'; c < '8'; ++c)
+        {
+            assert(t.value(c, 8) == c - '0');
+            assert(t.value(c, 10) == c - '0');
+            assert(t.value(c, 16) == c - '0');
+        }
+        for (char c = '8'; c < ':'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == c - '0');
+            assert(t.value(c, 16) == c - '0');
+        }
+        for (char c = ':'; c < 'A'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == -1);
+        }
+        for (char c = 'A'; c < 'G'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == c - 'A' +10);
+        }
+        for (char c = 'G'; c < 'a'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == -1);
+        }
+        for (char c = 'a'; c < 'g'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == c - 'a' +10);
+        }
+        for (int c = 'g'; c < 256; ++c)
+        {
+            assert(t.value(char(c), 8) == -1);
+            assert(t.value(char(c), 10) == -1);
+            assert(t.value(char(c), 16) == -1);
+        }
+    }
+    {
+        std::regex_traits<wchar_t> t;
+
+        for (wchar_t c = 0; c < '0'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == -1);
+        }
+        for (wchar_t c = '0'; c < '8'; ++c)
+        {
+            assert(t.value(c, 8) == c - '0');
+            assert(t.value(c, 10) == c - '0');
+            assert(t.value(c, 16) == c - '0');
+        }
+        for (wchar_t c = '8'; c < ':'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == c - '0');
+            assert(t.value(c, 16) == c - '0');
+        }
+        for (wchar_t c = ':'; c < 'A'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == -1);
+        }
+        for (wchar_t c = 'A'; c < 'G'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == c - 'A' +10);
+        }
+        for (wchar_t c = 'G'; c < 'a'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == -1);
+        }
+        for (wchar_t c = 'a'; c < 'g'; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == c - 'a' +10);
+        }
+        for (int c = 'g'; c < 0xFFFF; ++c)
+        {
+            assert(t.value(c, 8) == -1);
+            assert(t.value(c, 10) == -1);
+            assert(t.value(c, 16) == -1);
+        }
+    }
+}
diff --git a/final/test/strings/basic.string.hash/strings.pass.cpp b/final/test/strings/basic.string.hash/strings.pass.cpp
new file mode 100644
index 0000000..8ba166f
--- /dev/null
+++ b/final/test/strings/basic.string.hash/strings.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <string>
+#include <cassert>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    H h;
+    std::string g1 = "1234567890";
+    std::string g2 = "1234567891";
+    T s1(g1.begin(), g1.end());
+    T s2(g2.begin(), g2.end());
+    assert(h(s1) != h(s2));
+}
+
+int main()
+{
+    test<std::string>();
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<std::u16string>();
+    test<std::u32string>();
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+    test<std::wstring>();
+}
diff --git a/final/test/strings/basic.string.literals/literal.pass.cpp b/final/test/strings/basic.string.literals/literal.pass.cpp
new file mode 100644
index 0000000..dbb5f68
--- /dev/null
+++ b/final/test/strings/basic.string.literals/literal.pass.cpp
@@ -0,0 +1,47 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals::string_literals;
+
+    static_assert ( std::is_same<decltype(   "Hi"s), std::string>::value, "" );
+    static_assert ( std::is_same<decltype( u8"Hi"s), std::string>::value, "" );
+    static_assert ( std::is_same<decltype(  L"Hi"s), std::wstring>::value, "" );
+    static_assert ( std::is_same<decltype(  u"Hi"s), std::u16string>::value, "" );
+    static_assert ( std::is_same<decltype(  U"Hi"s), std::u32string>::value, "" );
+    
+    std::string foo;
+    std::wstring Lfoo;
+    std::u16string ufoo;
+    std::u32string Ufoo;
+    
+    foo  =   ""s;     assert( foo.size() == 0);
+    foo  = u8""s;     assert( foo.size() == 0);
+    Lfoo =  L""s;     assert(Lfoo.size() == 0);
+    ufoo =  u""s;     assert(ufoo.size() == 0);
+    Ufoo =  U""s;     assert(Ufoo.size() == 0);
+    
+    foo  =   " "s;     assert( foo.size() == 1);
+    foo  = u8" "s;     assert( foo.size() == 1);
+    Lfoo =  L" "s;     assert(Lfoo.size() == 1);
+    ufoo =  u" "s;     assert(ufoo.size() == 1);
+    Ufoo =  U" "s;     assert(Ufoo.size() == 1);
+    
+    foo  =   "ABC"s;     assert( foo ==   "ABC");   assert( foo == std::string   (  "ABC"));
+    foo  = u8"ABC"s;     assert( foo == u8"ABC");   assert( foo == std::string   (u8"ABC"));
+    Lfoo =  L"ABC"s;     assert(Lfoo ==  L"ABC");   assert(Lfoo == std::wstring  ( L"ABC"));
+    ufoo =  u"ABC"s;     assert(ufoo ==  u"ABC");   assert(ufoo == std::u16string( u"ABC"));
+    Ufoo =  U"ABC"s;     assert(Ufoo ==  U"ABC");   assert(Ufoo == std::u32string( U"ABC"));
+#endif
+}
diff --git a/final/test/strings/basic.string.literals/literal1.fail.cpp b/final/test/strings/basic.string.literals/literal1.fail.cpp
new file mode 100644
index 0000000..6ba0b30
--- /dev/null
+++ b/final/test/strings/basic.string.literals/literal1.fail.cpp
@@ -0,0 +1,22 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using std::string;
+
+    string foo  =   ""s;  // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/final/test/strings/basic.string.literals/literal1.pass.cpp b/final/test/strings/basic.string.literals/literal1.pass.cpp
new file mode 100644
index 0000000..f514374
--- /dev/null
+++ b/final/test/strings/basic.string.literals/literal1.pass.cpp
@@ -0,0 +1,20 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals;
+
+    std::string foo  =   ""s;
+#endif
+}
diff --git a/final/test/strings/basic.string.literals/literal2.fail.cpp b/final/test/strings/basic.string.literals/literal2.fail.cpp
new file mode 100644
index 0000000..68f1d25
--- /dev/null
+++ b/final/test/strings/basic.string.literals/literal2.fail.cpp
@@ -0,0 +1,20 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    std::string foo  =   ""s;  // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/final/test/strings/basic.string.literals/literal2.pass.cpp b/final/test/strings/basic.string.literals/literal2.pass.cpp
new file mode 100644
index 0000000..86d28e6
--- /dev/null
+++ b/final/test/strings/basic.string.literals/literal2.pass.cpp
@@ -0,0 +1,20 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals::string_literals;
+
+    std::string foo  =   ""s;
+#endif
+}
diff --git a/final/test/strings/basic.string.literals/literal3.pass.cpp b/final/test/strings/basic.string.literals/literal3.pass.cpp
new file mode 100644
index 0000000..98e3e40
--- /dev/null
+++ b/final/test/strings/basic.string.literals/literal3.pass.cpp
@@ -0,0 +1,20 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std;
+
+    string foo  =   ""s;
+#endif
+}
diff --git a/final/test/strings/basic.string/input_iterator.h b/final/test/strings/basic.string/input_iterator.h
new file mode 100644
index 0000000..fa6bb80
--- /dev/null
+++ b/final/test/strings/basic.string/input_iterator.h
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 INPUT_ITERATOR_H
+#define INPUT_ITERATOR_H
+
+#include <iterator>
+
+template <class It>
+class input_iterator
+{
+    It it_;
+public:
+    typedef typename std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int) {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+#endif  // INPUT_ITERATOR_H
diff --git a/final/test/strings/basic.string/string.access/at.pass.cpp b/final/test/strings/basic.string/string.access/at.pass.cpp
new file mode 100644
index 0000000..8fada8f
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/at.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reference at(size_type pos) const;
+//       reference at(size_type pos);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos)
+{
+    try
+    {
+        const S& cs = s;
+        assert(s.at(pos) == s[pos]);
+        assert(cs.at(pos) == cs[pos]);
+        assert(pos < cs.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos >= s.size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 0);
+    test(S("123"), 0);
+    test(S("123"), 1);
+    test(S("123"), 2);
+    test(S("123"), 3);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 0);
+    test(S("123"), 0);
+    test(S("123"), 1);
+    test(S("123"), 2);
+    test(S("123"), 3);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.access/back.pass.cpp b/final/test/strings/basic.string/string.access/back.pass.cpp
new file mode 100644
index 0000000..e915214
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/back.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT& back() const;
+//       charT& back();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    assert(&cs.back() == &cs[cs.size()-1]);
+    assert(&s.back() == &s[cs.size()-1]);
+    s.back() = typename S::value_type('z');
+    assert(s.back() == typename S::value_type('z'));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S("1"));
+    test(S("1234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S("1"));
+    test(S("1234567890123456789012345678901234567890"));
+    }
+#endif
+#ifdef _LIBCPP_DEBUG
+    {
+        std::string s;
+        char c = s.back();
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.access/db_back.pass.cpp b/final/test/strings/basic.string/string.access/db_back.pass.cpp
new file mode 100644
index 0000000..2b31fab
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/db_back.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s(1, '\0');
+    assert(s.back() == 0);
+    s.clear();
+    assert(s.back() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s(1, '\0');
+    assert(s.back() == 0);
+    s.clear();
+    assert(s.back() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.access/db_cback.pass.cpp b/final/test/strings/basic.string/string.access/db_cback.pass.cpp
new file mode 100644
index 0000000..7feb423
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/db_cback.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    const S s;
+    assert(s.back() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    const S s;
+    assert(s.back() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.access/db_cfront.pass.cpp b/final/test/strings/basic.string/string.access/db_cfront.pass.cpp
new file mode 100644
index 0000000..9f7785b
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/db_cfront.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    const S s;
+    assert(s.front() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    const S s;
+    assert(s.front() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.access/db_cindex.pass.cpp b/final/test/strings/basic.string/string.access/db_cindex.pass.cpp
new file mode 100644
index 0000000..6294200
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/db_cindex.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index const string out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    const S s;
+    assert(s[0] == 0);
+    assert(s[1] == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    const S s;
+    assert(s[0] == 0);
+    assert(s[1] == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.access/db_front.pass.cpp b/final/test/strings/basic.string/string.access/db_front.pass.cpp
new file mode 100644
index 0000000..ff675bc
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/db_front.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s(1, '\0');
+    assert(s.front() == 0);
+    s.clear();
+    assert(s.front() == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s(1, '\0');
+    assert(s.front() == 0);
+    s.clear();
+    assert(s.front() == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.access/db_index.pass.cpp b/final/test/strings/basic.string/string.access/db_index.pass.cpp
new file mode 100644
index 0000000..b20e201
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/db_index.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index string out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s;
+    assert(s[0] == 0);
+    assert(s[1] == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s;
+    assert(s[0] == 0);
+    assert(s[1] == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.access/front.pass.cpp b/final/test/strings/basic.string/string.access/front.pass.cpp
new file mode 100644
index 0000000..ed80916
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/front.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT& front() const;
+//       charT& front();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    assert(&cs.front() == &cs[0]);
+    assert(&s.front() == &s[0]);
+    s.front() = typename S::value_type('z');
+    assert(s.front() == typename S::value_type('z'));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S("1"));
+    test(S("1234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S("1"));
+    test(S("1234567890123456789012345678901234567890"));
+    }
+#endif
+#ifdef _LIBCPP_DEBUG
+    {
+        std::string s;
+        char c = s.front();
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.access/index.pass.cpp b/final/test/strings/basic.string/string.access/index.pass.cpp
new file mode 100644
index 0000000..cd31623
--- /dev/null
+++ b/final/test/strings/basic.string/string.access/index.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reference operator[](size_type pos) const;
+//       reference operator[](size_type pos);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s("0123456789");
+    const S& cs = s;
+    for (S::size_type i = 0; i < cs.size(); ++i)
+    {
+        assert(s[i] == '0' + i);
+        assert(cs[i] == s[i]);
+    }
+    assert(cs[cs.size()] == '\0');
+    const S s2 = S();
+    assert(s2[0] == '\0');
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s("0123456789");
+    const S& cs = s;
+    for (S::size_type i = 0; i < cs.size(); ++i)
+    {
+        assert(s[i] == '0' + i);
+        assert(cs[i] == s[i]);
+    }
+    assert(cs[cs.size()] == '\0');
+    const S s2 = S();
+    assert(s2[0] == '\0');
+    }
+#endif
+#ifdef _LIBCPP_DEBUG
+    {
+        std::string s;
+        char c = s[0];
+        assert(c == '\0');
+        c = s[1];
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/capacity.pass.cpp b/final/test/strings/basic.string/string.capacity/capacity.pass.cpp
new file mode 100644
index 0000000..bae7621
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/capacity.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type capacity() const;
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    S::allocator_type::throw_after = 0;
+    try
+    {
+        while (s.size() < s.capacity())
+            s.push_back(typename S::value_type());
+        assert(s.size() == s.capacity());
+    }
+    catch (...)
+    {
+        assert(false);
+    }
+    S::allocator_type::throw_after = INT_MAX;
+}
+
+int main()
+{
+    {
+    typedef std::basic_string<char, std::char_traits<char>, test_allocator<char> > S;
+    S s;
+    test(s);
+    s.assign(10, 'a');
+    s.erase(5);
+    test(s);
+    s.assign(100, 'a');
+    s.erase(50);
+    test(s);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s;
+    assert(s.capacity() > 0);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/clear.pass.cpp b/final/test/strings/basic.string/string.capacity/clear.pass.cpp
new file mode 100644
index 0000000..b73af75
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/clear.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void clear();
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    s.clear();
+    assert(s.size() == 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s;
+    test(s);
+
+    s.assign(10, 'a');
+    s.erase(5);
+    test(s);
+
+    s.assign(100, 'a');
+    s.erase(50);
+    test(s);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s;
+    test(s);
+
+    s.assign(10, 'a');
+    s.erase(5);
+    test(s);
+
+    s.assign(100, 'a');
+    s.erase(50);
+    test(s);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/empty.pass.cpp b/final/test/strings/basic.string/string.capacity/empty.pass.cpp
new file mode 100644
index 0000000..ac65f51
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/empty.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// bool empty() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    assert(s.empty() == (s.size() == 0));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    test(S("12345678901234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    test(S("12345678901234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/length.pass.cpp b/final/test/strings/basic.string/string.capacity/length.pass.cpp
new file mode 100644
index 0000000..d3ae1aa
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/length.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type length() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    assert(s.length() == s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    test(S("12345678901234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    test(S("12345678901234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/max_size.pass.cpp b/final/test/strings/basic.string/string.capacity/max_size.pass.cpp
new file mode 100644
index 0000000..e6a3aa4
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/max_size.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type max_size() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test1(const S& s)
+{
+    S s2(s);
+    const size_t sz = s2.max_size() - 1;
+    try { s2.resize(sz, 'x'); }
+    catch ( const std::bad_alloc & ) { return ; }
+    assert ( s2.size() ==  sz );
+}
+
+template <class S>
+void
+test2(const S& s)
+{
+    S s2(s);
+    const size_t sz = s2.max_size();
+    try { s2.resize(sz, 'x'); }
+    catch ( const std::bad_alloc & ) { return ; }
+    assert ( s.size() ==  sz );
+}
+
+template <class S>
+void
+test3(const S& s)
+{
+    S s2(s);
+    const size_t sz = s2.max_size() + 1;
+    try { s2.resize(sz, 'x'); }
+    catch ( const std::length_error & ) { return ; }
+    assert ( false );
+}
+
+template <class S>
+void
+test(const S& s)
+{
+    assert(s.max_size() >= s.size());
+    test1(s);
+    test2(s);
+    test3(s);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    test(S("12345678901234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    test(S("12345678901234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/reserve.pass.cpp b/final/test/strings/basic.string/string.capacity/reserve.pass.cpp
new file mode 100644
index 0000000..a155825
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/reserve.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void reserve(size_type res_arg=0);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    typename S::size_type old_cap = s.capacity();
+    S s0 = s;
+    s.reserve();
+    assert(s.__invariants());
+    assert(s == s0);
+    assert(s.capacity() <= old_cap);
+    assert(s.capacity() >= s.size());
+}
+
+template <class S>
+void
+test(S s, typename S::size_type res_arg)
+{
+    typename S::size_type old_cap = s.capacity();
+    S s0 = s;
+    try
+    {
+        s.reserve(res_arg);
+        assert(res_arg <= s.max_size());
+        assert(s == s0);
+        assert(s.capacity() >= res_arg);
+        assert(s.capacity() >= s.size());
+    }
+    catch (std::length_error&)
+    {
+        assert(res_arg > s.max_size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    {
+    S s;
+    test(s);
+
+    s.assign(10, 'a');
+    s.erase(5);
+    test(s);
+
+    s.assign(100, 'a');
+    s.erase(50);
+    test(s);
+    }
+    {
+    S s;
+    test(s, 5);
+    test(s, 10);
+    test(s, 50);
+    }
+    {
+    S s(100, 'a');
+    s.erase(50);
+    test(s, 5);
+    test(s, 10);
+    test(s, 50);
+    test(s, 100);
+    test(s, S::npos);
+    }
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    {
+    S s;
+    test(s);
+
+    s.assign(10, 'a');
+    s.erase(5);
+    test(s);
+
+    s.assign(100, 'a');
+    s.erase(50);
+    test(s);
+    }
+    {
+    S s;
+    test(s, 5);
+    test(s, 10);
+    test(s, 50);
+    }
+    {
+    S s(100, 'a');
+    s.erase(50);
+    test(s, 5);
+    test(s, 10);
+    test(s, 50);
+    test(s, 100);
+    test(s, S::npos);
+    }
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/resize_size.pass.cpp b/final/test/strings/basic.string/string.capacity/resize_size.pass.cpp
new file mode 100644
index 0000000..14fe209
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/resize_size.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void resize(size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, S expected)
+{
+    try
+    {
+        s.resize(n);
+        assert(s.__invariants());
+        assert(n <= s.max_size());
+        assert(s == expected);
+    }
+    catch (std::length_error&)
+    {
+        assert(n > s.max_size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 0, S());
+    test(S(), 1, S(1, '\0'));
+    test(S(), 10, S(10, '\0'));
+    test(S(), 100, S(100, '\0'));
+    test(S("12345"), 0, S());
+    test(S("12345"), 2, S("12"));
+    test(S("12345"), 5, S("12345"));
+    test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
+    test(S("12345678901234567890123456789012345678901234567890"), 0, S());
+    test(S("12345678901234567890123456789012345678901234567890"), 10,
+         S("1234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 50,
+         S("12345678901234567890123456789012345678901234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 60,
+         S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
+    test(S(), S::npos, S("not going to happen"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 0, S());
+    test(S(), 1, S(1, '\0'));
+    test(S(), 10, S(10, '\0'));
+    test(S(), 100, S(100, '\0'));
+    test(S("12345"), 0, S());
+    test(S("12345"), 2, S("12"));
+    test(S("12345"), 5, S("12345"));
+    test(S("12345"), 15, S("12345\0\0\0\0\0\0\0\0\0\0", 15));
+    test(S("12345678901234567890123456789012345678901234567890"), 0, S());
+    test(S("12345678901234567890123456789012345678901234567890"), 10,
+         S("1234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 50,
+         S("12345678901234567890123456789012345678901234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 60,
+         S("12345678901234567890123456789012345678901234567890\0\0\0\0\0\0\0\0\0\0", 60));
+    test(S(), S::npos, S("not going to happen"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/final/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp
new file mode 100644
index 0000000..f293df9
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/resize_size_char.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void resize(size_type n, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+    try
+    {
+        s.resize(n, c);
+        assert(s.__invariants());
+        assert(n <= s.max_size());
+        assert(s == expected);
+    }
+    catch (std::length_error&)
+    {
+        assert(n > s.max_size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S("a"));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+    test(S("12345"), 0, 'a', S());
+    test(S("12345"), 2, 'a', S("12"));
+    test(S("12345"), 5, 'a', S("12345"));
+    test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
+    test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
+    test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
+         S("1234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
+         S("12345678901234567890123456789012345678901234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
+         S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
+    test(S(), S::npos, 'a', S("not going to happen"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S("a"));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+    test(S("12345"), 0, 'a', S());
+    test(S("12345"), 2, 'a', S("12"));
+    test(S("12345"), 5, 'a', S("12345"));
+    test(S("12345"), 15, 'a', S("12345aaaaaaaaaa"));
+    test(S("12345678901234567890123456789012345678901234567890"), 0, 'a', S());
+    test(S("12345678901234567890123456789012345678901234567890"), 10, 'a',
+         S("1234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 50, 'a',
+         S("12345678901234567890123456789012345678901234567890"));
+    test(S("12345678901234567890123456789012345678901234567890"), 60, 'a',
+         S("12345678901234567890123456789012345678901234567890aaaaaaaaaa"));
+    test(S(), S::npos, 'a', S("not going to happen"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp b/final/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 0000000..aacbffd
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void shrink_to_fit();
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    typename S::size_type old_cap = s.capacity();
+    S s0 = s;
+    s.shrink_to_fit();
+    assert(s.__invariants());
+    assert(s == s0);
+    assert(s.capacity() <= old_cap);
+    assert(s.capacity() >= s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s;
+    test(s);
+
+    s.assign(10, 'a');
+    s.erase(5);
+    test(s);
+
+    s.assign(100, 'a');
+    s.erase(50);
+    test(s);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s;
+    test(s);
+
+    s.assign(10, 'a');
+    s.erase(5);
+    test(s);
+
+    s.assign(100, 'a');
+    s.erase(50);
+    test(s);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.capacity/size.pass.cpp b/final/test/strings/basic.string/string.capacity/size.pass.cpp
new file mode 100644
index 0000000..21b475a
--- /dev/null
+++ b/final/test/strings/basic.string/string.capacity/size.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type size() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::size_type c)
+{
+    assert(s.size() == c);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 0);
+    test(S("123"), 3);
+    test(S("12345678901234567890123456789012345678901234567890"), 50);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 0);
+    test(S("123"), 3);
+    test(S("12345678901234567890123456789012345678901234567890"), 50);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/alloc.pass.cpp b/final/test/strings/basic.string/string.cons/alloc.pass.cpp
new file mode 100644
index 0000000..512d118
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/alloc.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// explicit basic_string(const Allocator& a = Allocator());
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test()
+{
+    {
+    S s;
+    assert(s.__invariants());
+    assert(s.data());
+    assert(s.size() == 0);
+    assert(s.capacity() >= s.size());
+    assert(s.get_allocator() == typename S::allocator_type());
+    }
+    {
+    S s(typename S::allocator_type(5));
+    assert(s.__invariants());
+    assert(s.data());
+    assert(s.size() == 0);
+    assert(s.capacity() >= s.size());
+    assert(s.get_allocator() == typename S::allocator_type(5));
+    }
+}
+
+#if __cplusplus >= 201103L
+
+template <class S>
+void
+test2()
+{
+    {
+    S s;
+    assert(s.__invariants());
+    assert(s.data());
+    assert(s.size() == 0);
+    assert(s.capacity() >= s.size());
+    assert(s.get_allocator() == typename S::allocator_type());
+    }
+    {
+    S s(typename S::allocator_type{});
+    assert(s.__invariants());
+    assert(s.data());
+    assert(s.size() == 0);
+    assert(s.capacity() >= s.size());
+    assert(s.get_allocator() == typename S::allocator_type());
+    }
+}
+
+#endif
+
+int main()
+{
+    test<std::basic_string<char, std::char_traits<char>, test_allocator<char> > >();
+#if __cplusplus >= 201103L
+    test2<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >();
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/char_assignment.pass.cpp b/final/test/strings/basic.string/string.cons/char_assignment.pass.cpp
new file mode 100644
index 0000000..1c582bc
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/char_assignment.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& operator=(charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, typename S::value_type s2)
+{
+    typedef typename S::traits_type T;
+    s1 = s2;
+    assert(s1.__invariants());
+    assert(s1.size() == 1);
+    assert(T::eq(s1[0], s2));
+    assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 'a');
+    test(S("1"), 'a');
+    test(S("123456789"), 'a');
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 'a');
+    test(S("1"), 'a');
+    test(S("123456789"), 'a');
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), 'a');
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/copy.pass.cpp b/final/test/strings/basic.string/string.cons/copy.pass.cpp
new file mode 100644
index 0000000..9c9fc32
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/copy.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1)
+{
+    S s2 = s1;
+    assert(s2.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == s1.get_allocator());
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(A(3)));
+    test(S("1", A(5)));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(A{}));
+    test(S("1", A()));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/copy_alloc.pass.cpp b/final/test/strings/basic.string/string.cons/copy_alloc.pass.cpp
new file mode 100644
index 0000000..cf80210
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/copy_alloc.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string& str, const Allocator& alloc);
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, const typename S::allocator_type& a)
+{
+    S s2(s1, a);
+    assert(s2.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == a);
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(), A(3));
+    test(S("1"), A(5));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(), A());
+    test(S("1"), A());
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/copy_assignment.pass.cpp b/final/test/strings/basic.string/string.cons/copy_assignment.pass.cpp
new file mode 100644
index 0000000..ccb6c59
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/copy_assignment.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   operator=(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, const S& s2)
+{
+    s1 = s2;
+    assert(s1.__invariants());
+    assert(s1 == s2);
+    assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), S());
+    test(S("1"), S());
+    test(S(), S("1"));
+    test(S("1"), S("2"));
+    test(S("1"), S("2"));
+
+    test(S(),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("123456789"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S());
+    test(S("1"), S());
+    test(S(), S("1"));
+    test(S("1"), S("2"));
+    test(S("1"), S("2"));
+
+    test(S(),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("123456789"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/default_noexcept.pass.cpp b/final/test/strings/basic.string/string.cons/default_noexcept.pass.cpp
new file mode 100644
index 0000000..f935db8
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/default_noexcept.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string()
+//        noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::string C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+        static_assert(std::is_nothrow_default_constructible<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+        static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/dtor_noexcept.pass.cpp b/final/test/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 0000000..b3cc127
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// ~basic_string() // implied noexcept;
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+    ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::string C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+        static_assert(std::is_nothrow_destructible<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+        static_assert(!std::is_nothrow_destructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/initializer_list.pass.cpp b/final/test/strings/basic.string/string.cons/initializer_list.pass.cpp
new file mode 100644
index 0000000..d6ff850
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/initializer_list.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(initializer_list<charT> il, const Allocator& a = Allocator());
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::string s = {'a', 'b', 'c'};
+        assert(s == "abc");
+    }
+    {
+        std::wstring s;
+        s = {L'a', L'b', L'c'};
+        assert(s == L"abc");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s = {'a', 'b', 'c'};
+        assert(s == "abc");
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        S s;
+        s = {L'a', L'b', L'c'};
+        assert(s == L"abc");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp b/final/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
new file mode 100644
index 0000000..7530768
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/initializer_list_assignment.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& operator=(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::string s;
+        s = {'a', 'b', 'c'};
+        assert(s == "abc");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s;
+        s = {'a', 'b', 'c'};
+        assert(s == "abc");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/strings/basic.string/string.cons/iter_alloc.pass.cpp b/final/test/strings/basic.string/string.cons/iter_alloc.pass.cpp
new file mode 100644
index 0000000..664cb80
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/iter_alloc.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+//   basic_string(InputIterator begin, InputIterator end,
+//   const Allocator& a = Allocator());
+
+#include <string>
+#include <iterator>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../input_iterator.h"
+#include "min_allocator.h"
+
+template <class It>
+void
+test(It first, It last)
+{
+    typedef typename std::iterator_traits<It>::value_type charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(first, last);
+    assert(s2.__invariants());
+    assert(s2.size() == std::distance(first, last));
+    unsigned i = 0;
+    for (It it = first; it != last; ++it, ++i)
+        assert(s2[i] == *it);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class It, class A>
+void
+test(It first, It last, const A& a)
+{
+    typedef typename std::iterator_traits<It>::value_type charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+    typedef typename S::traits_type T;
+    S s2(first, last, a);
+    assert(s2.__invariants());
+    assert(s2.size() == std::distance(first, last));
+    unsigned i = 0;
+    for (It it = first; it != last; ++it, ++i)
+        assert(s2[i] == *it);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    const char* s = "12345678901234567890123456789012345678901234567890";
+
+    test(s, s);
+    test(s, s, A(2));
+
+    test(s, s+1);
+    test(s, s+1, A(2));
+
+    test(s, s+10);
+    test(s, s+10, A(2));
+
+    test(s, s+50);
+    test(s, s+50, A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s), A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+1));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+1), A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), A(2));
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A(2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    const char* s = "12345678901234567890123456789012345678901234567890";
+
+    test(s, s);
+    test(s, s, A());
+
+    test(s, s+1);
+    test(s, s+1, A());
+
+    test(s, s+10);
+    test(s, s+10, A());
+
+    test(s, s+50);
+    test(s, s+50, A());
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s), A());
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+1));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+1), A());
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), A());
+
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+50));
+    test(input_iterator<const char*>(s), input_iterator<const char*>(s+50), A());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/move.pass.cpp b/final/test/strings/basic.string/string.cons/move.pass.cpp
new file mode 100644
index 0000000..b94f189
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/move.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string<charT,traits,Allocator>&& str);
+
+#include <string>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s0)
+{
+    S s1 = s0;
+    S s2 = std::move(s0);
+    assert(s2.__invariants());
+    assert(s0.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == s1.get_allocator());
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(A(3)));
+    test(S("1", A(5)));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(A{}));
+    test(S("1", A()));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/strings/basic.string/string.cons/move_alloc.pass.cpp b/final/test/strings/basic.string/string.cons/move_alloc.pass.cpp
new file mode 100644
index 0000000..1f96314
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/move_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string&& str, const Allocator& alloc);
+
+#include <string>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+
+template <class S>
+void
+test(S s0, const typename S::allocator_type& a)
+{
+    S s1 = s0;
+    S s2(std::move(s0), a);
+    assert(s2.__invariants());
+    assert(s0.__invariants());
+    assert(s2 == s1);
+    assert(s2.capacity() >= s2.size());
+    assert(s2.get_allocator() == a);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(), A(3));
+    test(S("1"), A(5));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A(7));
+    }
+
+    int alloc_count = test_alloc_base::alloc_count;
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    S s1 ( "Twas brillig, and the slivy toves did gyre and gymbal in the wabe" );
+    S s2 (std::move(s1), A(1));
+    }
+    assert ( test_alloc_base::alloc_count == alloc_count );
+    
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(), A());
+    test(S("1"), A());
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"), A());
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp b/final/test/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 0000000..32c9514
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& operator=(basic_string&& c)
+//     noexcept(
+//          allocator_type::propagate_on_container_move_assignment::value &&
+//          is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::string C;
+        static_assert(std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+        static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/move_assignment.pass.cpp b/final/test/strings/basic.string/string.cons/move_assignment.pass.cpp
new file mode 100644
index 0000000..5bc1c8a
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/move_assignment.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   operator=(basic_string<charT,traits,Allocator>&& str);
+
+#include <string>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, S s2)
+{
+    S s0 = s2;
+    s1 = std::move(s2);
+    assert(s1.__invariants());
+    assert(s2.__invariants());
+    assert(s1 == s0);
+    assert(s1.capacity() >= s1.size());
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+    typedef std::string S;
+    test(S(), S());
+    test(S("1"), S());
+    test(S(), S("1"));
+    test(S("1"), S("2"));
+    test(S("1"), S("2"));
+
+    test(S(),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("123456789"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S());
+    test(S("1"), S());
+    test(S(), S("1"));
+    test(S("1"), S("2"));
+    test(S("1"), S("2"));
+
+    test(S(),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("123456789"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         S("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/strings/basic.string/string.cons/move_noexcept.pass.cpp b/final/test/strings/basic.string/string.cons/move_noexcept.pass.cpp
new file mode 100644
index 0000000..556aabd
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/move_noexcept.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(basic_string&&)
+//        noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::string C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+        static_assert(std::is_nothrow_move_constructible<C>::value, "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+        static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp b/final/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp
new file mode 100644
index 0000000..f6e9e00
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/pointer_alloc.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const charT* s, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class charT>
+void
+test(const charT* s)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    unsigned n = T::length(s);
+    S s2(s);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class charT, class A>
+void
+test(const charT* s, const A& a)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+    typedef typename S::traits_type T;
+    unsigned n = T::length(s);
+    S s2(s, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test("");
+    test("", A(2));
+
+    test("1");
+    test("1", A(2));
+
+    test("1234567980");
+    test("1234567980", A(2));
+
+    test("123456798012345679801234567980123456798012345679801234567980");
+    test("123456798012345679801234567980123456798012345679801234567980", A(2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test("");
+    test("", A());
+
+    test("1");
+    test("1", A());
+
+    test("1234567980");
+    test("1234567980", A());
+
+    test("123456798012345679801234567980123456798012345679801234567980");
+    test("123456798012345679801234567980123456798012345679801234567980", A());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp b/final/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp
new file mode 100644
index 0000000..c691613
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/pointer_assignment.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   operator=(const charT* s);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, const typename S::value_type* s2)
+{
+    typedef typename S::traits_type T;
+    s1 = s2;
+    assert(s1.__invariants());
+    assert(s1.size() == T::length(s2));
+    assert(T::compare(s1.data(), s2, s1.size()) == 0);
+    assert(s1.capacity() >= s1.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), "");
+    test(S("1"), "");
+    test(S(), "1");
+    test(S("1"), "2");
+    test(S("1"), "2");
+
+    test(S(),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("123456789"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), "");
+    test(S("1"), "");
+    test(S(), "1");
+    test(S("1"), "2");
+    test(S("1"), "2");
+
+    test(S(),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("123456789"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890"
+           "1234567890123456789012345678901234567890123456789012345678901234567890"),
+         "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp b/final/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
new file mode 100644
index 0000000..f1f107a
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/pointer_size_alloc.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const charT* s, size_type n, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class charT>
+void
+test(const charT* s, unsigned n)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(s, n);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class charT, class A>
+void
+test(const charT* s, unsigned n, const A& a)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+    typedef typename S::traits_type T;
+    S s2(s, n, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    assert(T::compare(s2.data(), s, n) == 0);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test("", 0);
+    test("", 0, A(2));
+
+    test("1", 1);
+    test("1", 1, A(2));
+
+    test("1234567980", 10);
+    test("1234567980", 10, A(2));
+
+    test("123456798012345679801234567980123456798012345679801234567980", 60);
+    test("123456798012345679801234567980123456798012345679801234567980", 60, A(2));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test("", 0);
+    test("", 0, A());
+
+    test("1", 1);
+    test("1", 1, A());
+
+    test("1234567980", 10);
+    test("1234567980", 10, A());
+
+    test("123456798012345679801234567980123456798012345679801234567980", 60);
+    test("123456798012345679801234567980123456798012345679801234567980", 60, A());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp b/final/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp
new file mode 100644
index 0000000..4dfe906
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/size_char_alloc.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(size_type n, charT c, const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class charT>
+void
+test(unsigned n, charT c)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(n, c);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class charT, class A>
+void
+test(unsigned n, charT c, const A& a)
+{
+    typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+    typedef typename S::traits_type T;
+    S s2(n, c, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class Tp>
+void
+test(Tp n, Tp c)
+{
+    typedef char charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, test_allocator<charT> > S;
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    S s2(n, c);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == A());
+    assert(s2.capacity() >= s2.size());
+}
+
+template <class Tp, class A>
+void
+test(Tp n, Tp c, const A& a)
+{
+    typedef char charT;
+    typedef std::basic_string<charT, std::char_traits<charT>, A> S;
+    typedef typename S::traits_type T;
+    S s2(n, c, a);
+    assert(s2.__invariants());
+    assert(s2.size() == n);
+    for (unsigned i = 0; i < n; ++i)
+        assert(s2[i] == c);
+    assert(s2.get_allocator() == a);
+    assert(s2.capacity() >= s2.size());
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test(0, 'a');
+    test(0, 'a', A(2));
+
+    test(1, 'a');
+    test(1, 'a', A(2));
+
+    test(10, 'a');
+    test(10, 'a', A(2));
+
+    test(100, 'a');
+    test(100, 'a', A(2));
+
+    test(100, 65);
+    test(100, 65, A(3));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test(0, 'a');
+    test(0, 'a', A());
+
+    test(1, 'a');
+    test(1, 'a', A());
+
+    test(10, 'a');
+    test(10, 'a', A());
+
+    test(100, 'a');
+    test(100, 'a', A());
+
+    test(100, 65);
+    test(100, 65, A());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.cons/substr.pass.cpp b/final/test/strings/basic.string/string.cons/substr.pass.cpp
new file mode 100644
index 0000000..2a9bf2a
--- /dev/null
+++ b/final/test/strings/basic.string/string.cons/substr.pass.cpp
@@ -0,0 +1,173 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string(const basic_string<charT,traits,Allocator>& str,
+//              size_type pos, size_type n = npos,
+//              const Allocator& a = Allocator());
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S str, unsigned pos)
+{
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    try
+    {
+        S s2(str, pos);
+        assert(s2.__invariants());
+        assert(pos <= str.size());
+        unsigned rlen = str.size() - pos;
+        assert(s2.size() == rlen);
+        assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+        assert(s2.get_allocator() == A());
+        assert(s2.capacity() >= s2.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+template <class S>
+void
+test(S str, unsigned pos, unsigned n)
+{
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    try
+    {
+        S s2(str, pos, n);
+        assert(s2.__invariants());
+        assert(pos <= str.size());
+        unsigned rlen = std::min<unsigned>(str.size() - pos, n);
+        assert(s2.size() == rlen);
+        assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+        assert(s2.get_allocator() == A());
+        assert(s2.capacity() >= s2.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+template <class S>
+void
+test(S str, unsigned pos, unsigned n, const typename S::allocator_type& a)
+{
+    typedef typename S::traits_type T;
+    typedef typename S::allocator_type A;
+    try
+    {
+        S s2(str, pos, n, a);
+        assert(s2.__invariants());
+        assert(pos <= str.size());
+        unsigned rlen = std::min<unsigned>(str.size() - pos, n);
+        assert(s2.size() == rlen);
+        assert(T::compare(s2.data(), str.data() + pos, rlen) == 0);
+        assert(s2.get_allocator() == a);
+        assert(s2.capacity() >= s2.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test(S(A(3)), 0);
+    test(S(A(3)), 1);
+    test(S("1", A(5)), 0);
+    test(S("1", A(5)), 1);
+    test(S("1", A(5)), 2);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 0);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 5);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 500);
+
+    test(S(A(3)), 0, 0);
+    test(S(A(3)), 0, 1);
+    test(S(A(3)), 1, 0);
+    test(S(A(3)), 1, 1);
+    test(S(A(3)), 1, 2);
+    test(S("1", A(5)), 0, 0);
+    test(S("1", A(5)), 0, 1);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100);
+
+    test(S(A(3)), 0, 0, A(4));
+    test(S(A(3)), 0, 1, A(4));
+    test(S(A(3)), 1, 0, A(4));
+    test(S(A(3)), 1, 1, A(4));
+    test(S(A(3)), 1, 2, A(4));
+    test(S("1", A(5)), 0, 0, A(6));
+    test(S("1", A(5)), 0, 1, A(6));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 0, A(8));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 1, A(8));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 10, A(8));
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A(7)), 50, 100, A(8));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+
+    test(S(A()), 0);
+    test(S(A()), 1);
+    test(S("1", A()), 0);
+    test(S("1", A()), 1);
+    test(S("1", A()), 2);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 0);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 5);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 500);
+
+    test(S(A()), 0, 0);
+    test(S(A()), 0, 1);
+    test(S(A()), 1, 0);
+    test(S(A()), 1, 1);
+    test(S(A()), 1, 2);
+    test(S("1", A()), 0, 0);
+    test(S("1", A()), 0, 1);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10);
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100);
+
+    test(S(A()), 0, 0, A());
+    test(S(A()), 0, 1, A());
+    test(S(A()), 1, 0, A());
+    test(S(A()), 1, 1, A());
+    test(S(A()), 1, 2, A());
+    test(S("1", A()), 0, 0, A());
+    test(S("1", A()), 0, 1, A());
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 0, A());
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 1, A());
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 10, A());
+    test(S("1234567890123456789012345678901234567890123456789012345678901234567890", A()), 50, 100, A());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/begin.pass.cpp b/final/test/strings/basic.string/string.iterators/begin.pass.cpp
new file mode 100644
index 0000000..55f2eb3
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/begin.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+//       iterator begin();
+// const_iterator begin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::iterator b = s.begin();
+    typename S::const_iterator cb = cs.begin();
+    if (!s.empty())
+    {
+        assert(*b == s[0]);
+    }
+    assert(b == cb);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/cbegin.pass.cpp b/final/test/strings/basic.string/string.iterators/cbegin.pass.cpp
new file mode 100644
index 0000000..d0c6ddb
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/cbegin.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_iterator cb = s.cbegin();
+    if (!s.empty())
+    {
+        assert(*cb == s[0]);
+    }
+    assert(cb == s.begin());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/cend.pass.cpp b/final/test/strings/basic.string/string.iterators/cend.pass.cpp
new file mode 100644
index 0000000..6b86d26
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/cend.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_iterator cend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_iterator ce = s.cend();
+    assert(ce == s.end());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/crbegin.pass.cpp b/final/test/strings/basic.string/string.iterators/crbegin.pass.cpp
new file mode 100644
index 0000000..6f29f43
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/crbegin.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_reverse_iterator cb = s.crbegin();
+    if (!s.empty())
+    {
+        assert(*cb == s.back());
+    }
+    assert(cb == s.rbegin());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/crend.pass.cpp b/final/test/strings/basic.string/string.iterators/crend.pass.cpp
new file mode 100644
index 0000000..1fb422c
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/crend.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const_reverse_iterator crend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    typename S::const_reverse_iterator ce = s.crend();
+    assert(ce == s.rend());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/db_iterators_2.pass.cpp b/final/test/strings/basic.string/string.iterators/db_iterators_2.pass.cpp
new file mode 100644
index 0000000..6cac187
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/db_iterators_2.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s1;
+    S s2;
+    bool b = s1.begin() < s2.begin();
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s1;
+    S s2;
+    bool b = s1.begin() < s2.begin();
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.iterators/db_iterators_3.pass.cpp b/final/test/strings/basic.string/string.iterators/db_iterators_3.pass.cpp
new file mode 100644
index 0000000..d90387e
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/db_iterators_3.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Subtract iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s1;
+    S s2;
+    int i = s1.begin() - s2.begin();
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s1;
+    S s2;
+    int i = s1.begin() - s2.begin();
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.iterators/db_iterators_4.pass.cpp b/final/test/strings/basic.string/string.iterators/db_iterators_4.pass.cpp
new file mode 100644
index 0000000..c4a2d0a
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/db_iterators_4.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string C;
+    C c(1, '\0');
+    C::iterator i = c.begin();
+    assert(i[0] == 0);
+    assert(i[1] == 0);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+    C c(1, '\0');
+    C::iterator i = c.begin();
+    assert(i[0] == 0);
+    assert(i[1] == 0);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.iterators/db_iterators_5.pass.cpp b/final/test/strings/basic.string/string.iterators/db_iterators_5.pass.cpp
new file mode 100644
index 0000000..ce44cb1
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/db_iterators_5.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string C;
+    C c(1, '\0');
+    C::iterator i = c.begin();
+    i += 1;
+    assert(i == c.end());
+    i = c.begin();
+    i += 2;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+    C c(1, '\0');
+    C::iterator i = c.begin();
+    i += 1;
+    assert(i == c.end());
+    i = c.begin();
+    i += 2;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.iterators/db_iterators_6.pass.cpp b/final/test/strings/basic.string/string.iterators/db_iterators_6.pass.cpp
new file mode 100644
index 0000000..8fab8ba
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/db_iterators_6.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string C;
+    C c(1, '\0');
+    C::iterator i = c.end();
+    --i;
+    assert(i == c.begin());
+    --i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+    C c(1, '\0');
+    C::iterator i = c.end();
+    --i;
+    assert(i == c.begin());
+    --i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.iterators/db_iterators_7.pass.cpp b/final/test/strings/basic.string/string.iterators/db_iterators_7.pass.cpp
new file mode 100644
index 0000000..d1cac07
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/db_iterators_7.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string C;
+    C c(1, '\0');
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+    C c(1, '\0');
+    C::iterator i = c.begin();
+    ++i;
+    assert(i == c.end());
+    ++i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.iterators/db_iterators_8.pass.cpp b/final/test/strings/basic.string/string.iterators/db_iterators_8.pass.cpp
new file mode 100644
index 0000000..914c77d
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/db_iterators_8.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    typedef std::string C;
+    C c(1, '\0');
+    C::iterator i = c.end();
+    char j = *i;
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> C;
+    C c(1, '\0');
+    C::iterator i = c.end();
+    char j = *i;
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.iterators/end.pass.cpp b/final/test/strings/basic.string/string.iterators/end.pass.cpp
new file mode 100644
index 0000000..02180bb
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/end.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+//       iterator end();
+// const_iterator end() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::iterator e = s.end();
+    typename S::const_iterator ce = cs.end();
+    if (s.empty())
+    {
+        assert(e == s.begin());
+        assert(ce == cs.begin());
+    }
+    assert(e - s.begin() == s.size());
+    assert(ce - cs.begin() == cs.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/iterators.pass.cpp b/final/test/strings/basic.string/string.iterators/iterators.pass.cpp
new file mode 100644
index 0000000..386cede
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/iterators.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    { // N3644 testing
+        typedef std::string C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+        assert ( ii1 == cii );
+        assert ( !(ii1 != ii2 ));
+        assert ( !(ii1 != cii ));
+    }
+
+    { // N3644 testing
+        typedef std::wstring C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );        
+        assert ( ii1 == cii );
+        assert ( !(ii1 != ii2 ));
+        assert ( !(ii1 != cii ));
+    }
+
+    { // N3644 testing
+        typedef std::u16string C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+        assert ( ii1 == cii );
+        assert ( !(ii1 != ii2 ));
+        assert ( !(ii1 != cii ));
+    }
+
+    { // N3644 testing
+        typedef std::u32string C;
+        C::iterator ii1{}, ii2{};
+        C::iterator ii4 = ii1;
+        C::const_iterator cii{};
+        assert ( ii1 == ii2 );
+        assert ( ii1 == ii4 );
+        assert ( ii1 == cii );
+        assert ( !(ii1 != ii2 ));
+        assert ( !(ii1 != cii ));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/rbegin.pass.cpp b/final/test/strings/basic.string/string.iterators/rbegin.pass.cpp
new file mode 100644
index 0000000..0111ad1
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/rbegin.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+//       reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::reverse_iterator b = s.rbegin();
+    typename S::const_reverse_iterator cb = cs.rbegin();
+    if (!s.empty())
+    {
+        assert(*b == s.back());
+    }
+    assert(b == cb);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.iterators/rend.pass.cpp b/final/test/strings/basic.string/string.iterators/rend.pass.cpp
new file mode 100644
index 0000000..750173d
--- /dev/null
+++ b/final/test/strings/basic.string/string.iterators/rend.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+//       reverse_iterator rend();
+// const_reverse_iterator rend() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s)
+{
+    const S& cs = s;
+    typename S::reverse_iterator e = s.rend();
+    typename S::const_reverse_iterator ce = cs.rend();
+    if (s.empty())
+    {
+        assert(e == s.rbegin());
+        assert(ce == cs.rbegin());
+    }
+    assert(e - s.rbegin() == s.size());
+    assert(ce - cs.rbegin() == cs.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S());
+    test(S("123"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S());
+    test(S("123"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp b/final/test/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp
new file mode 100644
index 0000000..fb28e49
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& append(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::string s("123");
+        s.append({'a', 'b', 'c'});
+        assert(s == "123abc");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s("123");
+        s.append({'a', 'b', 'c'});
+        assert(s == "123abc");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp
new file mode 100644
index 0000000..3bf2afa
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+//   basic_string& append(InputIterator first, InputIterator last);
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, It first, It last, S expected)
+{
+    s.append(first, last);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), s, s, S());
+    test(S(), s, s+1, S("A"));
+    test(S(), s, s+10, S("ABCDEFGHIJ"));
+    test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), s, s, S("12345"));
+    test(S("12345"), s, s+1, S("12345A"));
+    test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
+    test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), s, s, S("1234567890"));
+    test(S("1234567890"), s, s+1, S("1234567890A"));
+    test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), s, s, S("12345678901234567890"));
+    test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
+    test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
+    test(S("12345678901234567890"), s, s+52,
+         S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("12345"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("12345A"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("12345ABCDEFGHIJ"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("1234567890"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("1234567890A"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("12345678901234567890"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("12345678901234567890""A"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("12345678901234567890""ABCDEFGHIJ"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), s, s, S());
+    test(S(), s, s+1, S("A"));
+    test(S(), s, s+10, S("ABCDEFGHIJ"));
+    test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), s, s, S("12345"));
+    test(S("12345"), s, s+1, S("12345A"));
+    test(S("12345"), s, s+10, S("12345ABCDEFGHIJ"));
+    test(S("12345"), s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), s, s, S("1234567890"));
+    test(S("1234567890"), s, s+1, S("1234567890A"));
+    test(S("1234567890"), s, s+10, S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), s, s+52, S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), s, s, S("12345678901234567890"));
+    test(S("12345678901234567890"), s, s+1, S("12345678901234567890""A"));
+    test(S("12345678901234567890"), s, s+10, S("12345678901234567890""ABCDEFGHIJ"));
+    test(S("12345678901234567890"), s, s+52,
+         S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("12345"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("12345A"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("12345ABCDEFGHIJ"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("1234567890"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("1234567890A"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S("12345678901234567890"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("12345678901234567890""A"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("12345678901234567890""ABCDEFGHIJ"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp
new file mode 100644
index 0000000..5ae15f0
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& append(const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+    s.append(str);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S("12345"));
+    test(S("12345"), "12345", S("1234512345"));
+    test(S("12345"), "1234567890", S("123451234567890"));
+
+    test(S("12345678901234567890"), "", S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("1234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S("12345"));
+    test(S("12345"), "12345", S("1234512345"));
+    test(S("12345"), "1234567890", S("123451234567890"));
+
+    test(S("12345678901234567890"), "", S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("1234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp
new file mode 100644
index 0000000..5a9e8e2
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   append(const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
+{
+    s.append(str, n);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), "", 0, S());
+    test(S(), "12345", 3, S("123"));
+    test(S(), "12345", 4, S("1234"));
+    test(S(), "12345678901234567890", 0, S());
+    test(S(), "12345678901234567890", 1, S("1"));
+    test(S(), "12345678901234567890", 3, S("123"));
+    test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+    test(S("12345"), "", 0, S("12345"));
+    test(S("12345"), "12345", 5, S("1234512345"));
+    test(S("12345"), "1234567890", 10, S("123451234567890"));
+
+    test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "12345678901234567890", 20,
+         S("1234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), "", 0, S());
+    test(S(), "12345", 3, S("123"));
+    test(S(), "12345", 4, S("1234"));
+    test(S(), "12345678901234567890", 0, S());
+    test(S(), "12345678901234567890", 1, S("1"));
+    test(S(), "12345678901234567890", 3, S("123"));
+    test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+    test(S("12345"), "", 0, S("12345"));
+    test(S("12345"), "12345", 5, S("1234512345"));
+    test(S("12345"), "1234567890", 10, S("123451234567890"));
+
+    test(S("12345678901234567890"), "", 0, S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", 5, S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "12345678901234567890", 20,
+         S("1234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
new file mode 100644
index 0000000..b0a2eb5
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void push_back(charT c)
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::value_type c, S expected)
+{
+    s.push_back(c);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 'a', S(1, 'a'));
+    test(S("12345"), 'a', S("12345a"));
+    test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 'a', S(1, 'a'));
+    test(S("12345"), 'a', S("12345a"));
+    test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp
new file mode 100644
index 0000000..00e6ae3
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   append(size_type n, charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+    s.append(n, c);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S(1, 'a'));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+
+    test(S("12345"), 0, 'a', S("12345"));
+    test(S("12345"), 1, 'a', S("12345a"));
+    test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
+
+    test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
+    test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
+    test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S(1, 'a'));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+
+    test(S("12345"), 0, 'a', S("12345"));
+    test(S("12345"), 1, 'a', S("12345a"));
+    test(S("12345"), 10, 'a', S("12345aaaaaaaaaa"));
+
+    test(S("12345678901234567890"), 0, 'a', S("12345678901234567890"));
+    test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a"));
+    test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/string.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/string.pass.cpp
new file mode 100644
index 0000000..31f174b
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   append(const basic_string<charT,traits>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+    s.append(str);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S("12345"));
+    test(S("12345"), S("12345"), S("1234512345"));
+    test(S("12345"), S("1234567890"), S("123451234567890"));
+    test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+    test(S("1234567890"), S(), S("1234567890"));
+    test(S("1234567890"), S("12345"), S("123456789012345"));
+    test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S("12345678901234567890"));
+    test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+    test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("1234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S("12345"));
+    test(S("12345"), S("12345"), S("1234512345"));
+    test(S("12345"), S("1234567890"), S("123451234567890"));
+    test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+    test(S("1234567890"), S(), S("1234567890"));
+    test(S("1234567890"), S("12345"), S("123456789012345"));
+    test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S("12345678901234567890"));
+    test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+    test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("1234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
new file mode 100644
index 0000000..e8f54f4
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   append(const basic_string<charT,traits>& str, size_type pos, size_type n = npos);
+//  the "= npos" was added for C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
+{
+    try
+    {
+        s.append(str, pos, n);
+        assert(s.__invariants());
+        assert(pos <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+template <class S>
+void
+test_npos(S s, S str, typename S::size_type pos, S expected)
+{
+    try
+    {
+        s.append(str, pos);
+        assert(s.__invariants());
+        assert(pos <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), S(), 0, 0, S());
+    test(S(), S(), 1, 0, S());
+    test(S(), S("12345"), 0, 3, S("123"));
+    test(S(), S("12345"), 1, 4, S("2345"));
+    test(S(), S("12345"), 3, 15, S("45"));
+    test(S(), S("12345"), 5, 15, S(""));
+    test(S(), S("12345"), 6, 15, S("not happening"));
+    test(S(), S("12345678901234567890"), 0, 0, S());
+    test(S(), S("12345678901234567890"), 1, 1, S("2"));
+    test(S(), S("12345678901234567890"), 2, 3, S("345"));
+    test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+    test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+    test(S("12345"), S(), 0, 0, S("12345"));
+    test(S("12345"), S("12345"), 2, 2, S("1234534"));
+    test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
+
+    test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
+    test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
+    test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+         S("123456789012345678906789012345"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S(), 0, 0, S());
+    test(S(), S(), 1, 0, S());
+    test(S(), S("12345"), 0, 3, S("123"));
+    test(S(), S("12345"), 1, 4, S("2345"));
+    test(S(), S("12345"), 3, 15, S("45"));
+    test(S(), S("12345"), 5, 15, S(""));
+    test(S(), S("12345"), 6, 15, S("not happening"));
+    test(S(), S("12345678901234567890"), 0, 0, S());
+    test(S(), S("12345678901234567890"), 1, 1, S("2"));
+    test(S(), S("12345678901234567890"), 2, 3, S("345"));
+    test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+    test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+    test(S("12345"), S(), 0, 0, S("12345"));
+    test(S("12345"), S("12345"), 2, 2, S("1234534"));
+    test(S("12345"), S("1234567890"), 0, 100, S("123451234567890"));
+
+    test(S("12345678901234567890"), S(), 0, 0, S("12345678901234567890"));
+    test(S("12345678901234567890"), S("12345"), 1, 3, S("12345678901234567890234"));
+    test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+         S("123456789012345678906789012345"));
+    }
+#endif
+    {
+    typedef std::string S;
+    test_npos(S(), S(), 0, S());
+    test_npos(S(), S(), 1, S());
+    test_npos(S(), S("12345"), 0, S("12345"));
+    test_npos(S(), S("12345"), 1, S("2345"));
+    test_npos(S(), S("12345"), 3, S("45"));
+    test_npos(S(), S("12345"), 5, S(""));
+    test_npos(S(), S("12345"), 6, S("not happening"));
+    }
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
new file mode 100644
index 0000000..2dae107
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& assign(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::string s("123");
+        s.assign({'a', 'b', 'c'});
+        assert(s == "abc");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s("123");
+        s.assign({'a', 'b', 'c'});
+        assert(s == "abc");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
new file mode 100644
index 0000000..83b5dd1
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+//   basic_string& assign(InputIterator first, InputIterator last);
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, It first, It last, S expected)
+{
+    s.assign(first, last);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), s, s, S());
+    test(S(), s, s+1, S("A"));
+    test(S(), s, s+10, S("ABCDEFGHIJ"));
+    test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), s, s, S());
+    test(S("12345"), s, s+1, S("A"));
+    test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), s, s, S());
+    test(S("1234567890"), s, s+1, S("A"));
+    test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), s, s, S());
+    test(S("12345678901234567890"), s, s+1, S("A"));
+    test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("12345678901234567890"), s, s+52,
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), s, s, S());
+    test(S(), s, s+1, S("A"));
+    test(S(), s, s+10, S("ABCDEFGHIJ"));
+    test(S(), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), s, s, S());
+    test(S("12345"), s, s+1, S("A"));
+    test(S("12345"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("12345"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), s, s, S());
+    test(S("1234567890"), s, s+1, S("A"));
+    test(S("1234567890"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("1234567890"), s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), s, s, S());
+    test(S("12345678901234567890"), s, s+1, S("A"));
+    test(S("12345678901234567890"), s, s+10, S("ABCDEFGHIJ"));
+    test(S("12345678901234567890"), s, s+52,
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S(), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("12345"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("1234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s),
+         S());
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+1),
+         S("A"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+10),
+         S("ABCDEFGHIJ"));
+    test(S("12345678901234567890"), input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
new file mode 100644
index 0000000..adf24ac
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& assign(const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+    s.assign(str);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S());
+    test(S("12345"), "12345", S("12345"));
+    test(S("12345"), "1234567890", S("1234567890"));
+
+    test(S("12345678901234567890"), "", S());
+    test(S("12345678901234567890"), "12345", S("12345"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("12345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S());
+    test(S("12345"), "12345", S("12345"));
+    test(S("12345"), "1234567890", S("1234567890"));
+
+    test(S("12345678901234567890"), "", S());
+    test(S("12345678901234567890"), "12345", S("12345"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("12345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
new file mode 100644
index 0000000..476fe96
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   assign(const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, typename S::size_type n, S expected)
+{
+    s.assign(str, n);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), "", 0, S());
+    test(S(), "12345", 3, S("123"));
+    test(S(), "12345", 4, S("1234"));
+    test(S(), "12345678901234567890", 0, S());
+    test(S(), "12345678901234567890", 1, S("1"));
+    test(S(), "12345678901234567890", 3, S("123"));
+    test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+    test(S("12345"), "", 0, S());
+    test(S("12345"), "12345", 5, S("12345"));
+    test(S("12345"), "1234567890", 10, S("1234567890"));
+
+    test(S("12345678901234567890"), "", 0, S());
+    test(S("12345678901234567890"), "12345", 5, S("12345"));
+    test(S("12345678901234567890"), "12345678901234567890", 20,
+         S("12345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), "", 0, S());
+    test(S(), "12345", 3, S("123"));
+    test(S(), "12345", 4, S("1234"));
+    test(S(), "12345678901234567890", 0, S());
+    test(S(), "12345678901234567890", 1, S("1"));
+    test(S(), "12345678901234567890", 3, S("123"));
+    test(S(), "12345678901234567890", 20, S("12345678901234567890"));
+
+    test(S("12345"), "", 0, S());
+    test(S("12345"), "12345", 5, S("12345"));
+    test(S("12345"), "1234567890", 10, S("1234567890"));
+
+    test(S("12345678901234567890"), "", 0, S());
+    test(S("12345678901234567890"), "12345", 5, S("12345"));
+    test(S("12345678901234567890"), "12345678901234567890", 20,
+         S("12345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp
new file mode 100644
index 0000000..ac0e535
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   assign(basic_string<charT,traits>&& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+    s.assign(std::move(str));
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S());
+    test(S("12345"), S("12345"), S("12345"));
+    test(S("12345"), S("1234567890"), S("1234567890"));
+    test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("1234567890"), S(), S());
+    test(S("1234567890"), S("12345"), S("12345"));
+    test(S("1234567890"), S("1234567890"), S("1234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S());
+    test(S("12345678901234567890"), S("12345"), S("12345"));
+    test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("12345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S());
+    test(S("12345"), S("12345"), S("12345"));
+    test(S("12345"), S("1234567890"), S("1234567890"));
+    test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("1234567890"), S(), S());
+    test(S("1234567890"), S("12345"), S("12345"));
+    test(S("1234567890"), S("1234567890"), S("1234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S());
+    test(S("12345678901234567890"), S("12345"), S("12345"));
+    test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("12345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp
new file mode 100644
index 0000000..a8f7470
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   assign(size_type n, charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type n, typename S::value_type c, S expected)
+{
+    s.assign(n, c);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S(1, 'a'));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+
+    test(S("12345"), 0, 'a', S());
+    test(S("12345"), 1, 'a', S(1, 'a'));
+    test(S("12345"), 10, 'a', S(10, 'a'));
+
+    test(S("12345678901234567890"), 0, 'a', S());
+    test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
+    test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 0, 'a', S());
+    test(S(), 1, 'a', S(1, 'a'));
+    test(S(), 10, 'a', S(10, 'a'));
+    test(S(), 100, 'a', S(100, 'a'));
+
+    test(S("12345"), 0, 'a', S());
+    test(S("12345"), 1, 'a', S(1, 'a'));
+    test(S("12345"), 10, 'a', S(10, 'a'));
+
+    test(S("12345678901234567890"), 0, 'a', S());
+    test(S("12345678901234567890"), 1, 'a', S(1, 'a'));
+    test(S("12345678901234567890"), 10, 'a', S(10, 'a'));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
new file mode 100644
index 0000000..d7ddb77
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   assign(const basic_string<charT,traits>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+    s.assign(str);
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S());
+    test(S("12345"), S("12345"), S("12345"));
+    test(S("12345"), S("1234567890"), S("1234567890"));
+    test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("1234567890"), S(), S());
+    test(S("1234567890"), S("12345"), S("12345"));
+    test(S("1234567890"), S("1234567890"), S("1234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S());
+    test(S("12345678901234567890"), S("12345"), S("12345"));
+    test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("12345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S());
+    test(S("12345"), S("12345"), S("12345"));
+    test(S("12345"), S("1234567890"), S("1234567890"));
+    test(S("12345"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("1234567890"), S(), S());
+    test(S("1234567890"), S("12345"), S("12345"));
+    test(S("1234567890"), S("1234567890"), S("1234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S());
+    test(S("12345678901234567890"), S("12345"), S("12345"));
+    test(S("12345678901234567890"), S("1234567890"), S("1234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("12345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
new file mode 100644
index 0000000..5f5983e
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   assign(const basic_string<charT,traits>& str, size_type pos, size_type n=npos);
+// the =npos was added for C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, typename S::size_type pos, typename S::size_type n, S expected)
+{
+    try
+    {
+        s.assign(str, pos, n);
+        assert(s.__invariants());
+        assert(pos <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+template <class S>
+void
+test_npos(S s, S str, typename S::size_type pos, S expected)
+{
+    try
+    {
+        s.assign(str, pos);
+        assert(s.__invariants());
+        assert(pos <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), S(), 0, 0, S());
+    test(S(), S(), 1, 0, S());
+    test(S(), S("12345"), 0, 3, S("123"));
+    test(S(), S("12345"), 1, 4, S("2345"));
+    test(S(), S("12345"), 3, 15, S("45"));
+    test(S(), S("12345"), 5, 15, S(""));
+    test(S(), S("12345"), 6, 15, S("not happening"));
+    test(S(), S("12345678901234567890"), 0, 0, S());
+    test(S(), S("12345678901234567890"), 1, 1, S("2"));
+    test(S(), S("12345678901234567890"), 2, 3, S("345"));
+    test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+    test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+    test(S("12345"), S(), 0, 0, S());
+    test(S("12345"), S("12345"), 2, 2, S("34"));
+    test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
+
+    test(S("12345678901234567890"), S(), 0, 0, S());
+    test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
+    test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+         S("6789012345"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S(), 0, 0, S());
+    test(S(), S(), 1, 0, S());
+    test(S(), S("12345"), 0, 3, S("123"));
+    test(S(), S("12345"), 1, 4, S("2345"));
+    test(S(), S("12345"), 3, 15, S("45"));
+    test(S(), S("12345"), 5, 15, S(""));
+    test(S(), S("12345"), 6, 15, S("not happening"));
+    test(S(), S("12345678901234567890"), 0, 0, S());
+    test(S(), S("12345678901234567890"), 1, 1, S("2"));
+    test(S(), S("12345678901234567890"), 2, 3, S("345"));
+    test(S(), S("12345678901234567890"), 12, 13, S("34567890"));
+    test(S(), S("12345678901234567890"), 21, 13, S("not happening"));
+
+    test(S("12345"), S(), 0, 0, S());
+    test(S("12345"), S("12345"), 2, 2, S("34"));
+    test(S("12345"), S("1234567890"), 0, 100, S("1234567890"));
+
+    test(S("12345678901234567890"), S(), 0, 0, S());
+    test(S("12345678901234567890"), S("12345"), 1, 3, S("234"));
+    test(S("12345678901234567890"), S("12345678901234567890"), 5, 10,
+         S("6789012345"));
+    }
+#endif
+    {
+    typedef std::string S;
+    test_npos(S(), S(), 0, S());
+    test_npos(S(), S(), 1, S());
+    test_npos(S(), S("12345"), 0, S("12345"));
+    test_npos(S(), S("12345"), 1, S("2345"));
+    test_npos(S(), S("12345"), 3, S("45"));
+    test_npos(S(), S("12345"), 5, S(""));
+    test_npos(S(), S("12345"), 6, S("not happening"));
+    }
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
new file mode 100644
index 0000000..3380135
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type copy(charT* s, size_type n, size_type pos = 0) const;
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S str, typename S::value_type* s, typename S::size_type n,
+     typename S::size_type pos)
+{
+    try
+    {
+        const S& cs = str;
+        typename S::size_type r = cs.copy(s, n, pos);
+        assert(pos <= cs.size());
+        typename S::size_type rlen = std::min(n, cs.size() - pos);
+        assert(r == rlen);
+        for (r = 0; r < rlen; ++r)
+            assert(S::traits_type::eq(cs[pos+r], s[r]));
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > str.size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    char s[50];
+    test(S(""), s, 0, 0);
+    test(S(""), s, 0, 1);
+    test(S(""), s, 1, 0);
+    test(S("abcde"), s, 0, 0);
+    test(S("abcde"), s, 0, 1);
+    test(S("abcde"), s, 0, 2);
+    test(S("abcde"), s, 0, 4);
+    test(S("abcde"), s, 0, 5);
+    test(S("abcde"), s, 0, 6);
+    test(S("abcde"), s, 1, 0);
+    test(S("abcde"), s, 1, 1);
+    test(S("abcde"), s, 1, 2);
+    test(S("abcde"), s, 1, 4);
+    test(S("abcde"), s, 1, 5);
+    test(S("abcde"), s, 2, 0);
+    test(S("abcde"), s, 2, 1);
+    test(S("abcde"), s, 2, 2);
+    test(S("abcde"), s, 2, 4);
+    test(S("abcde"), s, 4, 0);
+    test(S("abcde"), s, 4, 1);
+    test(S("abcde"), s, 4, 2);
+    test(S("abcde"), s, 5, 0);
+    test(S("abcde"), s, 5, 1);
+    test(S("abcde"), s, 6, 0);
+    test(S("abcdefghijklmnopqrst"), s, 0, 0);
+    test(S("abcdefghijklmnopqrst"), s, 0, 1);
+    test(S("abcdefghijklmnopqrst"), s, 0, 2);
+    test(S("abcdefghijklmnopqrst"), s, 0, 10);
+    test(S("abcdefghijklmnopqrst"), s, 0, 19);
+    test(S("abcdefghijklmnopqrst"), s, 0, 20);
+    test(S("abcdefghijklmnopqrst"), s, 0, 21);
+    test(S("abcdefghijklmnopqrst"), s, 1, 0);
+    test(S("abcdefghijklmnopqrst"), s, 1, 1);
+    test(S("abcdefghijklmnopqrst"), s, 1, 2);
+    test(S("abcdefghijklmnopqrst"), s, 1, 9);
+    test(S("abcdefghijklmnopqrst"), s, 1, 18);
+    test(S("abcdefghijklmnopqrst"), s, 1, 19);
+    test(S("abcdefghijklmnopqrst"), s, 1, 20);
+    test(S("abcdefghijklmnopqrst"), s, 2, 0);
+    test(S("abcdefghijklmnopqrst"), s, 2, 1);
+    test(S("abcdefghijklmnopqrst"), s, 2, 2);
+    test(S("abcdefghijklmnopqrst"), s, 2, 9);
+    test(S("abcdefghijklmnopqrst"), s, 2, 17);
+    test(S("abcdefghijklmnopqrst"), s, 2, 18);
+    test(S("abcdefghijklmnopqrst"), s, 2, 19);
+    test(S("abcdefghijklmnopqrst"), s, 10, 0);
+    test(S("abcdefghijklmnopqrst"), s, 10, 1);
+    test(S("abcdefghijklmnopqrst"), s, 10, 2);
+    test(S("abcdefghijklmnopqrst"), s, 10, 5);
+    test(S("abcdefghijklmnopqrst"), s, 10, 9);
+    test(S("abcdefghijklmnopqrst"), s, 10, 10);
+    test(S("abcdefghijklmnopqrst"), s, 10, 11);
+    test(S("abcdefghijklmnopqrst"), s, 19, 0);
+    test(S("abcdefghijklmnopqrst"), s, 19, 1);
+    test(S("abcdefghijklmnopqrst"), s, 19, 2);
+    test(S("abcdefghijklmnopqrst"), s, 20, 0);
+    test(S("abcdefghijklmnopqrst"), s, 20, 1);
+    test(S("abcdefghijklmnopqrst"), s, 21, 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    char s[50];
+    test(S(""), s, 0, 0);
+    test(S(""), s, 0, 1);
+    test(S(""), s, 1, 0);
+    test(S("abcde"), s, 0, 0);
+    test(S("abcde"), s, 0, 1);
+    test(S("abcde"), s, 0, 2);
+    test(S("abcde"), s, 0, 4);
+    test(S("abcde"), s, 0, 5);
+    test(S("abcde"), s, 0, 6);
+    test(S("abcde"), s, 1, 0);
+    test(S("abcde"), s, 1, 1);
+    test(S("abcde"), s, 1, 2);
+    test(S("abcde"), s, 1, 4);
+    test(S("abcde"), s, 1, 5);
+    test(S("abcde"), s, 2, 0);
+    test(S("abcde"), s, 2, 1);
+    test(S("abcde"), s, 2, 2);
+    test(S("abcde"), s, 2, 4);
+    test(S("abcde"), s, 4, 0);
+    test(S("abcde"), s, 4, 1);
+    test(S("abcde"), s, 4, 2);
+    test(S("abcde"), s, 5, 0);
+    test(S("abcde"), s, 5, 1);
+    test(S("abcde"), s, 6, 0);
+    test(S("abcdefghijklmnopqrst"), s, 0, 0);
+    test(S("abcdefghijklmnopqrst"), s, 0, 1);
+    test(S("abcdefghijklmnopqrst"), s, 0, 2);
+    test(S("abcdefghijklmnopqrst"), s, 0, 10);
+    test(S("abcdefghijklmnopqrst"), s, 0, 19);
+    test(S("abcdefghijklmnopqrst"), s, 0, 20);
+    test(S("abcdefghijklmnopqrst"), s, 0, 21);
+    test(S("abcdefghijklmnopqrst"), s, 1, 0);
+    test(S("abcdefghijklmnopqrst"), s, 1, 1);
+    test(S("abcdefghijklmnopqrst"), s, 1, 2);
+    test(S("abcdefghijklmnopqrst"), s, 1, 9);
+    test(S("abcdefghijklmnopqrst"), s, 1, 18);
+    test(S("abcdefghijklmnopqrst"), s, 1, 19);
+    test(S("abcdefghijklmnopqrst"), s, 1, 20);
+    test(S("abcdefghijklmnopqrst"), s, 2, 0);
+    test(S("abcdefghijklmnopqrst"), s, 2, 1);
+    test(S("abcdefghijklmnopqrst"), s, 2, 2);
+    test(S("abcdefghijklmnopqrst"), s, 2, 9);
+    test(S("abcdefghijklmnopqrst"), s, 2, 17);
+    test(S("abcdefghijklmnopqrst"), s, 2, 18);
+    test(S("abcdefghijklmnopqrst"), s, 2, 19);
+    test(S("abcdefghijklmnopqrst"), s, 10, 0);
+    test(S("abcdefghijklmnopqrst"), s, 10, 1);
+    test(S("abcdefghijklmnopqrst"), s, 10, 2);
+    test(S("abcdefghijklmnopqrst"), s, 10, 5);
+    test(S("abcdefghijklmnopqrst"), s, 10, 9);
+    test(S("abcdefghijklmnopqrst"), s, 10, 10);
+    test(S("abcdefghijklmnopqrst"), s, 10, 11);
+    test(S("abcdefghijklmnopqrst"), s, 19, 0);
+    test(S("abcdefghijklmnopqrst"), s, 19, 1);
+    test(S("abcdefghijklmnopqrst"), s, 19, 2);
+    test(S("abcdefghijklmnopqrst"), s, 20, 0);
+    test(S("abcdefghijklmnopqrst"), s, 20, 1);
+    test(S("abcdefghijklmnopqrst"), s, 21, 0);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp
new file mode 100644
index 0000000..6c2929d
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db1.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::string l1("123");
+    std::string::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S l1("123");
+    S::const_iterator i = l1.end();
+    l1.erase(i);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp
new file mode 100644
index 0000000..d20fcd4
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_db2.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::string l1("123");
+    std::string l2("123");
+    std::string::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S l1("123");
+    S l2("123");
+    S::const_iterator i = l2.begin();
+    l1.erase(i);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 0000000..5015241
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db1.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::string l1("123");
+    std::string l2("123");
+    std::string::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S l1("123");
+    S l2("123");
+    S::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 0000000..6a23bf8
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db2.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::string l1("123");
+    std::string l2("123");
+    std::string::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S l1("123");
+    S l2("123");
+    S::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 0000000..a844381
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db3.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::string l1("123");
+    std::string l2("123");
+    std::string::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S l1("123");
+    S l2("123");
+    S::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 0000000..0549e81
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <string>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+    std::string l1("123");
+    std::string::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+    assert(false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S l1("123");
+    S::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+    assert(false);
+    }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
new file mode 100644
index 0000000..c44db71
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/iter.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator erase(const_iterator p);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, S expected)
+{
+    typename S::const_iterator p = s.begin() + pos;
+    typename S::iterator i = s.erase(p);
+    assert(s.__invariants());
+    assert(s == expected);
+    assert(i - s.begin() == pos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S("abcde"), 0, S("bcde"));
+    test(S("abcde"), 1, S("acde"));
+    test(S("abcde"), 2, S("abde"));
+    test(S("abcde"), 4, S("abcd"));
+    test(S("abcdefghij"), 0, S("bcdefghij"));
+    test(S("abcdefghij"), 1, S("acdefghij"));
+    test(S("abcdefghij"), 5, S("abcdeghij"));
+    test(S("abcdefghij"), 9, S("abcdefghi"));
+    test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S("abcde"), 0, S("bcde"));
+    test(S("abcde"), 1, S("acde"));
+    test(S("abcde"), 2, S("abde"));
+    test(S("abcde"), 4, S("abcd"));
+    test(S("abcdefghij"), 0, S("bcdefghij"));
+    test(S("abcdefghij"), 1, S("acdefghij"));
+    test(S("abcdefghij"), 5, S("abcdeghij"));
+    test(S("abcdefghij"), 9, S("abcdefghi"));
+    test(S("abcdefghijklmnopqrst"), 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
new file mode 100644
index 0000000..dbe6d7b
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/iter_iter.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, typename S::difference_type n, S expected)
+{
+    typename S::const_iterator first = s.cbegin() + pos;
+    typename S::const_iterator last = s.cbegin() + pos + n;
+    typename S::iterator i = s.erase(first, last);
+    assert(s.__invariants());
+    assert(s == expected);
+    assert(i - s.begin() == pos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, 0, S(""));
+    test(S("abcde"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 2, S("cde"));
+    test(S("abcde"), 0, 4, S("e"));
+    test(S("abcde"), 0, 5, S(""));
+    test(S("abcde"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 1, S("acde"));
+    test(S("abcde"), 1, 2, S("ade"));
+    test(S("abcde"), 1, 3, S("ae"));
+    test(S("abcde"), 1, 4, S("a"));
+    test(S("abcde"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 1, S("abde"));
+    test(S("abcde"), 2, 2, S("abe"));
+    test(S("abcde"), 2, 3, S("ab"));
+    test(S("abcde"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 1, S("abcd"));
+    test(S("abcde"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S("fghij"));
+    test(S("abcdefghij"), 0, 9, S("j"));
+    test(S("abcdefghij"), 0, 10, S(""));
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 4, S("afghij"));
+    test(S("abcdefghij"), 1, 8, S("aj"));
+    test(S("abcdefghij"), 1, 9, S("a"));
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 2, S("abcdehij"));
+    test(S("abcdefghij"), 5, 4, S("abcdej"));
+    test(S("abcdefghij"), 5, 5, S("abcde"));
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, 0, S(""));
+    test(S("abcde"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 2, S("cde"));
+    test(S("abcde"), 0, 4, S("e"));
+    test(S("abcde"), 0, 5, S(""));
+    test(S("abcde"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 1, S("acde"));
+    test(S("abcde"), 1, 2, S("ade"));
+    test(S("abcde"), 1, 3, S("ae"));
+    test(S("abcde"), 1, 4, S("a"));
+    test(S("abcde"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 1, S("abde"));
+    test(S("abcde"), 2, 2, S("abe"));
+    test(S("abcde"), 2, 3, S("ab"));
+    test(S("abcde"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 1, S("abcd"));
+    test(S("abcde"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S("fghij"));
+    test(S("abcdefghij"), 0, 9, S("j"));
+    test(S("abcdefghij"), 0, 10, S(""));
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 4, S("afghij"));
+    test(S("abcdefghij"), 1, 8, S("aj"));
+    test(S("abcdefghij"), 1, 9, S("a"));
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 2, S("abcdehij"));
+    test(S("abcdefghij"), 5, 4, S("abcdej"));
+    test(S("abcdefghij"), 5, 5, S("abcde"));
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
new file mode 100644
index 0000000..790ce40
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/pop_back.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S expected)
+{
+    s.pop_back();
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S("abcde"), S("abcd"));
+    test(S("abcdefghij"), S("abcdefghi"));
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S("abcde"), S("abcd"));
+    test(S("abcdefghij"), S("abcdefghi"));
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrs"));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::string s;
+        s.pop_back();
+        assert(false);
+    }
+#endif        
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
new file mode 100644
index 0000000..bc9ec1c
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
@@ -0,0 +1,280 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   erase(size_type pos = 0, size_type n = npos);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.erase(pos, n);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void
+test(S s, typename S::size_type pos, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.erase(pos);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void
+test(S s, S expected)
+{
+    s.erase();
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, 0, S(""));
+    test(S(""), 0, 1, S(""));
+    test(S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 2, S("cde"));
+    test(S("abcde"), 0, 4, S("e"));
+    test(S("abcde"), 0, 5, S(""));
+    test(S("abcde"), 0, 6, S(""));
+    test(S("abcde"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 1, S("acde"));
+    test(S("abcde"), 1, 2, S("ade"));
+    test(S("abcde"), 1, 3, S("ae"));
+    test(S("abcde"), 1, 4, S("a"));
+    test(S("abcde"), 1, 5, S("a"));
+    test(S("abcde"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 1, S("abde"));
+    test(S("abcde"), 2, 2, S("abe"));
+    test(S("abcde"), 2, 3, S("ab"));
+    test(S("abcde"), 2, 4, S("ab"));
+    test(S("abcde"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("abcd"));
+    test(S("abcde"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("abcde"));
+    test(S("abcde"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S("fghij"));
+    test(S("abcdefghij"), 0, 9, S("j"));
+    test(S("abcdefghij"), 0, 10, S(""));
+    test(S("abcdefghij"), 0, 11, S(""));
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 4, S("afghij"));
+    test(S("abcdefghij"), 1, 8, S("aj"));
+    test(S("abcdefghij"), 1, 9, S("a"));
+    test(S("abcdefghij"), 1, 10, S("a"));
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 2, S("abcdehij"));
+    test(S("abcdefghij"), 5, 4, S("abcdej"));
+    test(S("abcdefghij"), 5, 5, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("abcde"));
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("abcdefghi"));
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
+
+    test(S(""), 0, S(""));
+    test(S(""), 1, S("can't happen"));
+    test(S("abcde"), 0, S(""));
+    test(S("abcde"), 1, S("a"));
+    test(S("abcde"), 2, S("ab"));
+    test(S("abcde"), 4, S("abcd"));
+    test(S("abcde"), 5, S("abcde"));
+    test(S("abcde"), 6, S("can't happen"));
+    test(S("abcdefghij"), 0, S(""));
+    test(S("abcdefghij"), 1, S("a"));
+    test(S("abcdefghij"), 5, S("abcde"));
+    test(S("abcdefghij"), 9, S("abcdefghi"));
+    test(S("abcdefghij"), 10, S("abcdefghij"));
+    test(S("abcdefghij"), 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
+
+    test(S(""), S(""));
+    test(S("abcde"), S(""));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, 0, S(""));
+    test(S(""), 0, 1, S(""));
+    test(S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 2, S("cde"));
+    test(S("abcde"), 0, 4, S("e"));
+    test(S("abcde"), 0, 5, S(""));
+    test(S("abcde"), 0, 6, S(""));
+    test(S("abcde"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 1, S("acde"));
+    test(S("abcde"), 1, 2, S("ade"));
+    test(S("abcde"), 1, 3, S("ae"));
+    test(S("abcde"), 1, 4, S("a"));
+    test(S("abcde"), 1, 5, S("a"));
+    test(S("abcde"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 1, S("abde"));
+    test(S("abcde"), 2, 2, S("abe"));
+    test(S("abcde"), 2, 3, S("ab"));
+    test(S("abcde"), 2, 4, S("ab"));
+    test(S("abcde"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("abcd"));
+    test(S("abcde"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("abcde"));
+    test(S("abcde"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S("fghij"));
+    test(S("abcdefghij"), 0, 9, S("j"));
+    test(S("abcdefghij"), 0, 10, S(""));
+    test(S("abcdefghij"), 0, 11, S(""));
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 4, S("afghij"));
+    test(S("abcdefghij"), 1, 8, S("aj"));
+    test(S("abcdefghij"), 1, 9, S("a"));
+    test(S("abcdefghij"), 1, 10, S("a"));
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 2, S("abcdehij"));
+    test(S("abcdefghij"), 5, 4, S("abcdej"));
+    test(S("abcdefghij"), 5, 5, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("abcde"));
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("abcdefghi"));
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("can't happen"));
+
+    test(S(""), 0, S(""));
+    test(S(""), 1, S("can't happen"));
+    test(S("abcde"), 0, S(""));
+    test(S("abcde"), 1, S("a"));
+    test(S("abcde"), 2, S("ab"));
+    test(S("abcde"), 4, S("abcd"));
+    test(S("abcde"), 5, S("abcde"));
+    test(S("abcde"), 6, S("can't happen"));
+    test(S("abcdefghij"), 0, S(""));
+    test(S("abcdefghij"), 1, S("a"));
+    test(S("abcdefghij"), 5, S("abcde"));
+    test(S("abcdefghij"), 9, S("abcdefghi"));
+    test(S("abcdefghij"), 10, S("abcdefghij"));
+    test(S("abcdefghij"), 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 10, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 19, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 20, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 21, S("can't happen"));
+
+    test(S(""), S(""));
+    test(S("abcde"), S(""));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp
new file mode 100644
index 0000000..b9e5fa8
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, charT c);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S& s, typename S::const_iterator p, typename S::value_type c, S expected)
+{
+    bool sufficient_cap = s.size() < s.capacity();
+    typename S::difference_type pos = p - s.begin();
+    typename S::iterator i = s.insert(p, c);
+    assert(s.__invariants());
+    assert(s == expected);
+    assert(i - s.begin() == pos);
+    assert(*i == c);
+    if (sufficient_cap)
+        assert(i == p);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    S s;
+    test(s, s.begin(), '1', S("1"));
+    test(s, s.begin(), 'a', S("a1"));
+    test(s, s.end(), 'b', S("a1b"));
+    test(s, s.end()-1, 'c', S("a1cb"));
+    test(s, s.end()-2, 'd', S("a1dcb"));
+    test(s, s.end()-3, '2', S("a12dcb"));
+    test(s, s.end()-4, '3', S("a132dcb"));
+    test(s, s.end()-5, '4', S("a1432dcb"));
+    test(s, s.begin()+1, '5', S("a51432dcb"));
+    test(s, s.begin()+2, '6', S("a561432dcb"));
+    test(s, s.begin()+3, '7', S("a5671432dcb"));
+    test(s, s.begin()+4, 'A', S("a567A1432dcb"));
+    test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
+    test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    S s;
+    test(s, s.begin(), '1', S("1"));
+    test(s, s.begin(), 'a', S("a1"));
+    test(s, s.end(), 'b', S("a1b"));
+    test(s, s.end()-1, 'c', S("a1cb"));
+    test(s, s.end()-2, 'd', S("a1dcb"));
+    test(s, s.end()-3, '2', S("a12dcb"));
+    test(s, s.end()-4, '3', S("a132dcb"));
+    test(s, s.end()-5, '4', S("a1432dcb"));
+    test(s, s.begin()+1, '5', S("a51432dcb"));
+    test(s, s.begin()+2, '6', S("a561432dcb"));
+    test(s, s.begin()+3, '7', S("a5671432dcb"));
+    test(s, s.begin()+4, 'A', S("a567A1432dcb"));
+    test(s, s.begin()+5, 'B', S("a567AB1432dcb"));
+    test(s, s.begin()+6, 'C', S("a567ABC1432dcb"));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        typedef std::string S;
+        S s;
+        S s2;
+        s.insert(s2.begin(), '1');
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..e091662
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, initializer_list<charT> il);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::string s("123456");
+        std::string::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
+        assert(i - s.begin() == 3);
+        assert(s == "123abc456");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s("123456");
+        S::iterator i = s.insert(s.begin() + 3, {'a', 'b', 'c'});
+        assert(i - s.begin() == 3);
+        assert(s == "123abc456");
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::string s;
+        std::string s2;
+        s.insert(s2.begin(), {'a', 'b', 'c'});
+        assert(false);
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..38353dd
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+//   iterator insert(const_iterator p, InputIterator first, InputIterator last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "../../input_iterator.h"
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, typename S::difference_type pos, It first, It last, S expected)
+{
+    typename S::const_iterator p = s.cbegin() + pos;
+    typename S::iterator i = s.insert(p, first, last);
+    assert(s.__invariants());
+    assert(i - s.begin() == pos);
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), 0, s, s, S());
+    test(S(), 0, s, s+1, S("A"));
+    test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
+    test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), 0, s, s, S("12345"));
+    test(S("12345"), 1, s, s+1, S("1A2345"));
+    test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
+    test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), 0, s, s, S("1234567890"));
+    test(S("1234567890"), 1, s, s+1, S("1A234567890"));
+    test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+    test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
+    test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
+    test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
+    test(S("12345678901234567890"), 20, s, s+52,
+         S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345"));
+    test(S("12345"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A2345"));
+    test(S("12345"), 4, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
+    test(S("12345"), 5, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("1234567890"));
+    test(S("1234567890"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A234567890"));
+    test(S("1234567890"), 10, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), 8, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+    test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345678901234567890"));
+    test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("123A45678901234567890"));
+    test(S("12345678901234567890"), 15, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
+    test(S("12345678901234567890"), 20, input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+    test(S(), 0, s, s, S());
+    test(S(), 0, s, s+1, S("A"));
+    test(S(), 0, s, s+10, S("ABCDEFGHIJ"));
+    test(S(), 0, s, s+52, S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), 0, s, s, S("12345"));
+    test(S("12345"), 1, s, s+1, S("1A2345"));
+    test(S("12345"), 4, s, s+10, S("1234ABCDEFGHIJ5"));
+    test(S("12345"), 5, s, s+52, S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), 0, s, s, S("1234567890"));
+    test(S("1234567890"), 1, s, s+1, S("1A234567890"));
+    test(S("1234567890"), 10, s, s+10, S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), 8, s, s+52, S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+    test(S("12345678901234567890"), 3, s, s, S("12345678901234567890"));
+    test(S("12345678901234567890"), 3, s, s+1, S("123A45678901234567890"));
+    test(S("12345678901234567890"), 15, s, s+10, S("123456789012345ABCDEFGHIJ67890"));
+    test(S("12345678901234567890"), 20, s, s+52,
+         S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S());
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("A"));
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("ABCDEFGHIJ"));
+    test(S(), 0, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("12345"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345"));
+    test(S("12345"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A2345"));
+    test(S("12345"), 4, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234ABCDEFGHIJ5"));
+    test(S("12345"), 5, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+
+    test(S("1234567890"), 0, input_iterator<const char*>(s), input_iterator<const char*>(s), S("1234567890"));
+    test(S("1234567890"), 1, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("1A234567890"));
+    test(S("1234567890"), 10, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("1234567890ABCDEFGHIJ"));
+    test(S("1234567890"), 8, input_iterator<const char*>(s), input_iterator<const char*>(s+52), S("12345678ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz90"));
+
+    test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s), S("12345678901234567890"));
+    test(S("12345678901234567890"), 3, input_iterator<const char*>(s), input_iterator<const char*>(s+1), S("123A45678901234567890"));
+    test(S("12345678901234567890"), 15, input_iterator<const char*>(s), input_iterator<const char*>(s+10), S("123456789012345ABCDEFGHIJ67890"));
+    test(S("12345678901234567890"), 20, input_iterator<const char*>(s), input_iterator<const char*>(s+52),
+         S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::string v;
+        std::string v2;
+        char a[] = "123";
+        const int N = sizeof(a)/sizeof(a[0]);
+        std::string::iterator i = v.insert(v2.cbegin() + 10, a, a+N);
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp
new file mode 100644
index 0000000..739c894
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// iterator insert(const_iterator p, size_type n, charT c);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::difference_type pos, typename S::size_type n,
+     typename S::value_type c, S expected)
+{
+    typename S::const_iterator p = s.cbegin() + pos;
+    typename S::iterator i = s.insert(p, n, c);
+    assert(s.__invariants());
+    assert(i - s.begin() == pos);
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, 0, '1', S(""));
+    test(S(""), 0, 5, '1', S("11111"));
+    test(S(""), 0, 10, '1', S("1111111111"));
+    test(S(""), 0, 20, '1', S("11111111111111111111"));
+    test(S("abcde"), 0, 0, '1', S("abcde"));
+    test(S("abcde"), 0, 5, '1', S("11111abcde"));
+    test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+    test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+    test(S("abcde"), 1, 0, '1', S("abcde"));
+    test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+    test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+    test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+    test(S("abcde"), 2, 0, '1', S("abcde"));
+    test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+    test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+    test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+    test(S("abcde"), 4, 0, '1', S("abcde"));
+    test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+    test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+    test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+    test(S("abcde"), 5, 0, '1', S("abcde"));
+    test(S("abcde"), 5, 5, '1', S("abcde11111"));
+    test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+    test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+    test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+    test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+    test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+    test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+    test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+    test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+    test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+    test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+    test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+    test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+    test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+    test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+    test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+    test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+    test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+    test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+    test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, 0, '1', S(""));
+    test(S(""), 0, 5, '1', S("11111"));
+    test(S(""), 0, 10, '1', S("1111111111"));
+    test(S(""), 0, 20, '1', S("11111111111111111111"));
+    test(S("abcde"), 0, 0, '1', S("abcde"));
+    test(S("abcde"), 0, 5, '1', S("11111abcde"));
+    test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+    test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+    test(S("abcde"), 1, 0, '1', S("abcde"));
+    test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+    test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+    test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+    test(S("abcde"), 2, 0, '1', S("abcde"));
+    test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+    test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+    test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+    test(S("abcde"), 4, 0, '1', S("abcde"));
+    test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+    test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+    test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+    test(S("abcde"), 5, 0, '1', S("abcde"));
+    test(S("abcde"), 5, 5, '1', S("abcde11111"));
+    test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+    test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+    test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+    test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+    test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+    test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+    test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+    test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+    test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+    test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+    test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+    test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+    test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+    test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+    test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+    test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+    test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+    test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+    test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+    }
+#endif
+#if _LIBCPP_DEBUG >= 1
+    {
+        std::string s;
+        std::string s2;
+        s.insert(s2.begin(), 1, 'a');
+        assert(false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
new file mode 100644
index 0000000..734dd8d
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   insert(size_type pos, const charT* s);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, const typename S::value_type* str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, "", S(""));
+    test(S(""), 0, "12345", S("12345"));
+    test(S(""), 0, "1234567890", S("1234567890"));
+    test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
+    test(S(""), 1, "", S("can't happen"));
+    test(S(""), 1, "12345", S("can't happen"));
+    test(S(""), 1, "1234567890", S("can't happen"));
+    test(S(""), 1, "12345678901234567890", S("can't happen"));
+    test(S("abcde"), 0, "", S("abcde"));
+    test(S("abcde"), 0, "12345", S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
+    test(S("abcde"), 1, "", S("abcde"));
+    test(S("abcde"), 1, "12345", S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, "", S("abcde"));
+    test(S("abcde"), 2, "12345", S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, "", S("abcde"));
+    test(S("abcde"), 4, "12345", S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, "", S("abcde"));
+    test(S("abcde"), 5, "12345", S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcde"), 6, "", S("can't happen"));
+    test(S("abcde"), 6, "12345", S("can't happen"));
+    test(S("abcde"), 6, "1234567890", S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghij"), 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, "", S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, "", S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, "", S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, "", S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, "", S(""));
+    test(S(""), 0, "12345", S("12345"));
+    test(S(""), 0, "1234567890", S("1234567890"));
+    test(S(""), 0, "12345678901234567890", S("12345678901234567890"));
+    test(S(""), 1, "", S("can't happen"));
+    test(S(""), 1, "12345", S("can't happen"));
+    test(S(""), 1, "1234567890", S("can't happen"));
+    test(S(""), 1, "12345678901234567890", S("can't happen"));
+    test(S("abcde"), 0, "", S("abcde"));
+    test(S("abcde"), 0, "12345", S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", S("12345678901234567890abcde"));
+    test(S("abcde"), 1, "", S("abcde"));
+    test(S("abcde"), 1, "12345", S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, "", S("abcde"));
+    test(S("abcde"), 2, "12345", S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, "", S("abcde"));
+    test(S("abcde"), 4, "12345", S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, "", S("abcde"));
+    test(S("abcde"), 5, "12345", S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcde"), 6, "", S("can't happen"));
+    test(S("abcde"), 6, "12345", S("can't happen"));
+    test(S("abcde"), 6, "1234567890", S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghij"), 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, "", S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, "", S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, "", S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, "", S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, "", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
new file mode 100644
index 0000000..29b00ec
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
@@ -0,0 +1,692 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   insert(size_type pos, const charT* s, size_type n);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, const typename S::value_type* str,
+     typename S::size_type n, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, str, n);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, "", 0, S(""));
+    test(S(""), 0, "12345", 0, S(""));
+    test(S(""), 0, "12345", 1, S("1"));
+    test(S(""), 0, "12345", 2, S("12"));
+    test(S(""), 0, "12345", 4, S("1234"));
+    test(S(""), 0, "12345", 5, S("12345"));
+    test(S(""), 0, "1234567890", 0, S(""));
+    test(S(""), 0, "1234567890", 1, S("1"));
+    test(S(""), 0, "1234567890", 5, S("12345"));
+    test(S(""), 0, "1234567890", 9, S("123456789"));
+    test(S(""), 0, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, "12345678901234567890", 0, S(""));
+    test(S(""), 0, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S(""), 1, "", 0, S("can't happen"));
+    test(S(""), 1, "12345", 0, S("can't happen"));
+    test(S(""), 1, "12345", 1, S("can't happen"));
+    test(S(""), 1, "12345", 2, S("can't happen"));
+    test(S(""), 1, "12345", 4, S("can't happen"));
+    test(S(""), 1, "12345", 5, S("can't happen"));
+    test(S(""), 1, "1234567890", 0, S("can't happen"));
+    test(S(""), 1, "1234567890", 1, S("can't happen"));
+    test(S(""), 1, "1234567890", 5, S("can't happen"));
+    test(S(""), 1, "1234567890", 9, S("can't happen"));
+    test(S(""), 1, "1234567890", 10, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 0, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 1, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 10, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 19, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcde"), 0, "", 0, S("abcde"));
+    test(S("abcde"), 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 0, "12345", 1, S("1abcde"));
+    test(S("abcde"), 0, "12345", 2, S("12abcde"));
+    test(S("abcde"), 0, "12345", 4, S("1234abcde"));
+    test(S("abcde"), 0, "12345", 5, S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 0, "1234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, "1234567890", 5, S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", 9, S("123456789abcde"));
+    test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 1, "", 0, S("abcde"));
+    test(S("abcde"), 1, "12345", 0, S("abcde"));
+    test(S("abcde"), 1, "12345", 1, S("a1bcde"));
+    test(S("abcde"), 1, "12345", 2, S("a12bcde"));
+    test(S("abcde"), 1, "12345", 4, S("a1234bcde"));
+    test(S("abcde"), 1, "12345", 5, S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 1, "1234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, "1234567890", 5, S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde"));
+    test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, "", 0, S("abcde"));
+    test(S("abcde"), 2, "12345", 0, S("abcde"));
+    test(S("abcde"), 2, "12345", 1, S("ab1cde"));
+    test(S("abcde"), 2, "12345", 2, S("ab12cde"));
+    test(S("abcde"), 2, "12345", 4, S("ab1234cde"));
+    test(S("abcde"), 2, "12345", 5, S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 2, "1234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, "1234567890", 5, S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde"));
+    test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, "", 0, S("abcde"));
+    test(S("abcde"), 4, "12345", 0, S("abcde"));
+    test(S("abcde"), 4, "12345", 1, S("abcd1e"));
+    test(S("abcde"), 4, "12345", 2, S("abcd12e"));
+    test(S("abcde"), 4, "12345", 4, S("abcd1234e"));
+    test(S("abcde"), 4, "12345", 5, S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 4, "1234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, "1234567890", 5, S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e"));
+    test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, "", 0, S("abcde"));
+    test(S("abcde"), 5, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 6, "", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345", 1, S("can't happen"));
+    test(S("abcde"), 6, "12345", 2, S("can't happen"));
+    test(S("abcde"), 6, "12345", 4, S("can't happen"));
+    test(S("abcde"), 6, "12345", 5, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 5, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 9, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghij"), 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, "", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 2, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 4, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, "", 0, S(""));
+    test(S(""), 0, "12345", 0, S(""));
+    test(S(""), 0, "12345", 1, S("1"));
+    test(S(""), 0, "12345", 2, S("12"));
+    test(S(""), 0, "12345", 4, S("1234"));
+    test(S(""), 0, "12345", 5, S("12345"));
+    test(S(""), 0, "1234567890", 0, S(""));
+    test(S(""), 0, "1234567890", 1, S("1"));
+    test(S(""), 0, "1234567890", 5, S("12345"));
+    test(S(""), 0, "1234567890", 9, S("123456789"));
+    test(S(""), 0, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, "12345678901234567890", 0, S(""));
+    test(S(""), 0, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S(""), 1, "", 0, S("can't happen"));
+    test(S(""), 1, "12345", 0, S("can't happen"));
+    test(S(""), 1, "12345", 1, S("can't happen"));
+    test(S(""), 1, "12345", 2, S("can't happen"));
+    test(S(""), 1, "12345", 4, S("can't happen"));
+    test(S(""), 1, "12345", 5, S("can't happen"));
+    test(S(""), 1, "1234567890", 0, S("can't happen"));
+    test(S(""), 1, "1234567890", 1, S("can't happen"));
+    test(S(""), 1, "1234567890", 5, S("can't happen"));
+    test(S(""), 1, "1234567890", 9, S("can't happen"));
+    test(S(""), 1, "1234567890", 10, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 0, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 1, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 10, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 19, S("can't happen"));
+    test(S(""), 1, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcde"), 0, "", 0, S("abcde"));
+    test(S("abcde"), 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 0, "12345", 1, S("1abcde"));
+    test(S("abcde"), 0, "12345", 2, S("12abcde"));
+    test(S("abcde"), 0, "12345", 4, S("1234abcde"));
+    test(S("abcde"), 0, "12345", 5, S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 0, "1234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, "1234567890", 5, S("12345abcde"));
+    test(S("abcde"), 0, "1234567890", 9, S("123456789abcde"));
+    test(S("abcde"), 0, "1234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 1, "", 0, S("abcde"));
+    test(S("abcde"), 1, "12345", 0, S("abcde"));
+    test(S("abcde"), 1, "12345", 1, S("a1bcde"));
+    test(S("abcde"), 1, "12345", 2, S("a12bcde"));
+    test(S("abcde"), 1, "12345", 4, S("a1234bcde"));
+    test(S("abcde"), 1, "12345", 5, S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 1, "1234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, "1234567890", 5, S("a12345bcde"));
+    test(S("abcde"), 1, "1234567890", 9, S("a123456789bcde"));
+    test(S("abcde"), 1, "1234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 1, "12345678901234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, "", 0, S("abcde"));
+    test(S("abcde"), 2, "12345", 0, S("abcde"));
+    test(S("abcde"), 2, "12345", 1, S("ab1cde"));
+    test(S("abcde"), 2, "12345", 2, S("ab12cde"));
+    test(S("abcde"), 2, "12345", 4, S("ab1234cde"));
+    test(S("abcde"), 2, "12345", 5, S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 2, "1234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, "1234567890", 5, S("ab12345cde"));
+    test(S("abcde"), 2, "1234567890", 9, S("ab123456789cde"));
+    test(S("abcde"), 2, "1234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 2, "12345678901234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, "12345678901234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, "", 0, S("abcde"));
+    test(S("abcde"), 4, "12345", 0, S("abcde"));
+    test(S("abcde"), 4, "12345", 1, S("abcd1e"));
+    test(S("abcde"), 4, "12345", 2, S("abcd12e"));
+    test(S("abcde"), 4, "12345", 4, S("abcd1234e"));
+    test(S("abcde"), 4, "12345", 5, S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 4, "1234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, "1234567890", 5, S("abcd12345e"));
+    test(S("abcde"), 4, "1234567890", 9, S("abcd123456789e"));
+    test(S("abcde"), 4, "1234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 4, "12345678901234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, "12345678901234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, "", 0, S("abcde"));
+    test(S("abcde"), 5, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 6, "", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345", 1, S("can't happen"));
+    test(S("abcde"), 6, "12345", 2, S("can't happen"));
+    test(S("abcde"), 6, "12345", 4, S("can't happen"));
+    test(S("abcde"), 6, "12345", 5, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 5, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 9, S("can't happen"));
+    test(S("abcde"), 6, "1234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcde"), 6, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghij"), 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, "12345", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, "1234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, "12345", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, "1234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "12345", 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, "12345", 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, "12345", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "1234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, "1234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "12345", 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, "12345", 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, "12345", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "1234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "1234567890", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, "1234567890", 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, "1234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, "", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 2, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 4, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghij"), 11, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghij"), 11, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, "", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
new file mode 100644
index 0000000..fd85696
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
@@ -0,0 +1,212 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   insert(size_type pos, size_type n, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n,
+     typename S::value_type str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, n, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, 0, '1', S(""));
+    test(S(""), 0, 5, '1', S("11111"));
+    test(S(""), 0, 10, '1', S("1111111111"));
+    test(S(""), 0, 20, '1', S("11111111111111111111"));
+    test(S(""), 1, 0, '1', S("can't happen"));
+    test(S(""), 1, 5, '1', S("can't happen"));
+    test(S(""), 1, 10, '1', S("can't happen"));
+    test(S(""), 1, 20, '1', S("can't happen"));
+    test(S("abcde"), 0, 0, '1', S("abcde"));
+    test(S("abcde"), 0, 5, '1', S("11111abcde"));
+    test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+    test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+    test(S("abcde"), 1, 0, '1', S("abcde"));
+    test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+    test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+    test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+    test(S("abcde"), 2, 0, '1', S("abcde"));
+    test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+    test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+    test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+    test(S("abcde"), 4, 0, '1', S("abcde"));
+    test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+    test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+    test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+    test(S("abcde"), 5, 0, '1', S("abcde"));
+    test(S("abcde"), 5, 5, '1', S("abcde11111"));
+    test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+    test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+    test(S("abcde"), 6, 0, '1', S("can't happen"));
+    test(S("abcde"), 6, 5, '1', S("can't happen"));
+    test(S("abcde"), 6, 10, '1', S("can't happen"));
+    test(S("abcde"), 6, 20, '1', S("can't happen"));
+    test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+    test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+    test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+    test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+    test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+    test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+    test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+    test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+    test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+    test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+    test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+    test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+    test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+    test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+    test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+    test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+    test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+    test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, 0, '1', S(""));
+    test(S(""), 0, 5, '1', S("11111"));
+    test(S(""), 0, 10, '1', S("1111111111"));
+    test(S(""), 0, 20, '1', S("11111111111111111111"));
+    test(S(""), 1, 0, '1', S("can't happen"));
+    test(S(""), 1, 5, '1', S("can't happen"));
+    test(S(""), 1, 10, '1', S("can't happen"));
+    test(S(""), 1, 20, '1', S("can't happen"));
+    test(S("abcde"), 0, 0, '1', S("abcde"));
+    test(S("abcde"), 0, 5, '1', S("11111abcde"));
+    test(S("abcde"), 0, 10, '1', S("1111111111abcde"));
+    test(S("abcde"), 0, 20, '1', S("11111111111111111111abcde"));
+    test(S("abcde"), 1, 0, '1', S("abcde"));
+    test(S("abcde"), 1, 5, '1', S("a11111bcde"));
+    test(S("abcde"), 1, 10, '1', S("a1111111111bcde"));
+    test(S("abcde"), 1, 20, '1', S("a11111111111111111111bcde"));
+    test(S("abcde"), 2, 0, '1', S("abcde"));
+    test(S("abcde"), 2, 5, '1', S("ab11111cde"));
+    test(S("abcde"), 2, 10, '1', S("ab1111111111cde"));
+    test(S("abcde"), 2, 20, '1', S("ab11111111111111111111cde"));
+    test(S("abcde"), 4, 0, '1', S("abcde"));
+    test(S("abcde"), 4, 5, '1', S("abcd11111e"));
+    test(S("abcde"), 4, 10, '1', S("abcd1111111111e"));
+    test(S("abcde"), 4, 20, '1', S("abcd11111111111111111111e"));
+    test(S("abcde"), 5, 0, '1', S("abcde"));
+    test(S("abcde"), 5, 5, '1', S("abcde11111"));
+    test(S("abcde"), 5, 10, '1', S("abcde1111111111"));
+    test(S("abcde"), 5, 20, '1', S("abcde11111111111111111111"));
+    test(S("abcde"), 6, 0, '1', S("can't happen"));
+    test(S("abcde"), 6, 5, '1', S("can't happen"));
+    test(S("abcde"), 6, 10, '1', S("can't happen"));
+    test(S("abcde"), 6, 20, '1', S("can't happen"));
+    test(S("abcdefghij"), 0, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 5, '1', S("11111abcdefghij"));
+    test(S("abcdefghij"), 0, 10, '1', S("1111111111abcdefghij"));
+    test(S("abcdefghij"), 0, 20, '1', S("11111111111111111111abcdefghij"));
+    test(S("abcdefghij"), 1, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 5, '1', S("a11111bcdefghij"));
+    test(S("abcdefghij"), 1, 10, '1', S("a1111111111bcdefghij"));
+    test(S("abcdefghij"), 1, 20, '1', S("a11111111111111111111bcdefghij"));
+    test(S("abcdefghij"), 5, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 5, '1', S("abcde11111fghij"));
+    test(S("abcdefghij"), 5, 10, '1', S("abcde1111111111fghij"));
+    test(S("abcdefghij"), 5, 20, '1', S("abcde11111111111111111111fghij"));
+    test(S("abcdefghij"), 9, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 5, '1', S("abcdefghi11111j"));
+    test(S("abcdefghij"), 9, 10, '1', S("abcdefghi1111111111j"));
+    test(S("abcdefghij"), 9, 20, '1', S("abcdefghi11111111111111111111j"));
+    test(S("abcdefghij"), 10, 0, '1', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 5, '1', S("abcdefghij11111"));
+    test(S("abcdefghij"), 10, 10, '1', S("abcdefghij1111111111"));
+    test(S("abcdefghij"), 10, 20, '1', S("abcdefghij11111111111111111111"));
+    test(S("abcdefghij"), 11, 0, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 5, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 10, '1', S("can't happen"));
+    test(S("abcdefghij"), 11, 20, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 5, '1', S("11111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, '1', S("1111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, '1', S("11111111111111111111abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 5, '1', S("a11111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 10, '1', S("a1111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, '1', S("a11111111111111111111bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, '1', S("abcdefghij11111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, '1', S("abcdefghij1111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 20, '1', S("abcdefghij11111111111111111111klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 5, '1', S("abcdefghijklmnopqrs11111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 10, '1', S("abcdefghijklmnopqrs1111111111t"));
+    test(S("abcdefghijklmnopqrst"), 19, 20, '1', S("abcdefghijklmnopqrs11111111111111111111t"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, '1', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 5, '1', S("abcdefghijklmnopqrst11111"));
+    test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111"));
+    test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 5, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
new file mode 100644
index 0000000..8c18941
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   insert(size_type pos1, const basic_string& str);
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, S str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, S(""), S(""));
+    test(S(""), 0, S("12345"), S("12345"));
+    test(S(""), 0, S("1234567890"), S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
+    test(S(""), 1, S(""), S("can't happen"));
+    test(S(""), 1, S("12345"), S("can't happen"));
+    test(S(""), 1, S("1234567890"), S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), S("can't happen"));
+    test(S("abcde"), 0, S(""), S("abcde"));
+    test(S("abcde"), 0, S("12345"), S("12345abcde"));
+    test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+    test(S("abcde"), 1, S(""), S("abcde"));
+    test(S("abcde"), 1, S("12345"), S("a12345bcde"));
+    test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, S(""), S("abcde"));
+    test(S("abcde"), 2, S("12345"), S("ab12345cde"));
+    test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, S(""), S("abcde"));
+    test(S("abcde"), 4, S("12345"), S("abcd12345e"));
+    test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, S(""), S("abcde"));
+    test(S("abcde"), 5, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcde"), 6, S(""), S("can't happen"));
+    test(S("abcde"), 6, S("12345"), S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, S(""), S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, S(""), S(""));
+    test(S(""), 0, S("12345"), S("12345"));
+    test(S(""), 0, S("1234567890"), S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), S("12345678901234567890"));
+    test(S(""), 1, S(""), S("can't happen"));
+    test(S(""), 1, S("12345"), S("can't happen"));
+    test(S(""), 1, S("1234567890"), S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), S("can't happen"));
+    test(S("abcde"), 0, S(""), S("abcde"));
+    test(S("abcde"), 0, S("12345"), S("12345abcde"));
+    test(S("abcde"), 0, S("1234567890"), S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+    test(S("abcde"), 1, S(""), S("abcde"));
+    test(S("abcde"), 1, S("12345"), S("a12345bcde"));
+    test(S("abcde"), 1, S("1234567890"), S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), S("a12345678901234567890bcde"));
+    test(S("abcde"), 2, S(""), S("abcde"));
+    test(S("abcde"), 2, S("12345"), S("ab12345cde"));
+    test(S("abcde"), 2, S("1234567890"), S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), S("ab12345678901234567890cde"));
+    test(S("abcde"), 4, S(""), S("abcde"));
+    test(S("abcde"), 4, S("12345"), S("abcd12345e"));
+    test(S("abcde"), 4, S("1234567890"), S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), S("abcd12345678901234567890e"));
+    test(S("abcde"), 5, S(""), S("abcde"));
+    test(S("abcde"), 5, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcde"), 6, S(""), S("can't happen"));
+    test(S("abcde"), 6, S("12345"), S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghij"), 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 1, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 5, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 9, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("1234567890"), S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 10, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, S(""), S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
new file mode 100644
index 0000000..51c9e72
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
@@ -0,0 +1,1784 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   insert(size_type pos1, const basic_string<charT,traits,Allocator>& str,
+//          size_type pos2, size_type n=npos);
+// the "=npos" was added in C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, S str, typename S::size_type pos2,
+     typename S::size_type n, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos1, str, pos2, n);
+        assert(s.__invariants());
+        assert(pos1 <= old_size && pos2 <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size || pos2 > str.size());
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void
+test_npos(S s, typename S::size_type pos1, S str, typename S::size_type pos2, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.insert(pos1, str, pos2);
+        assert(s.__invariants());
+        assert(pos1 <= old_size && pos2 <= str.size());
+        assert(s == expected);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size || pos2 > str.size());
+        assert(s == s0);
+    }
+}
+
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, S(""), 0, 0, S(""));
+    test(S(""), 0, S(""), 0, 1, S(""));
+    test(S(""), 0, S(""), 1, 0, S("can't happen"));
+    test(S(""), 0, S("12345"), 0, 0, S(""));
+    test(S(""), 0, S("12345"), 0, 1, S("1"));
+    test(S(""), 0, S("12345"), 0, 2, S("12"));
+    test(S(""), 0, S("12345"), 0, 4, S("1234"));
+    test(S(""), 0, S("12345"), 0, 5, S("12345"));
+    test(S(""), 0, S("12345"), 0, 6, S("12345"));
+    test(S(""), 0, S("12345"), 1, 0, S(""));
+    test(S(""), 0, S("12345"), 1, 1, S("2"));
+    test(S(""), 0, S("12345"), 1, 2, S("23"));
+    test(S(""), 0, S("12345"), 1, 3, S("234"));
+    test(S(""), 0, S("12345"), 1, 4, S("2345"));
+    test(S(""), 0, S("12345"), 1, 5, S("2345"));
+    test(S(""), 0, S("12345"), 2, 0, S(""));
+    test(S(""), 0, S("12345"), 2, 1, S("3"));
+    test(S(""), 0, S("12345"), 2, 2, S("34"));
+    test(S(""), 0, S("12345"), 2, 3, S("345"));
+    test(S(""), 0, S("12345"), 2, 4, S("345"));
+    test(S(""), 0, S("12345"), 4, 0, S(""));
+    test(S(""), 0, S("12345"), 4, 1, S("5"));
+    test(S(""), 0, S("12345"), 4, 2, S("5"));
+    test(S(""), 0, S("12345"), 5, 0, S(""));
+    test(S(""), 0, S("12345"), 5, 1, S(""));
+    test(S(""), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S(""), 0, S("1234567890"), 0, 0, S(""));
+    test(S(""), 0, S("1234567890"), 0, 1, S("1"));
+    test(S(""), 0, S("1234567890"), 0, 5, S("12345"));
+    test(S(""), 0, S("1234567890"), 0, 9, S("123456789"));
+    test(S(""), 0, S("1234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, S("1234567890"), 0, 11, S("1234567890"));
+    test(S(""), 0, S("1234567890"), 1, 0, S(""));
+    test(S(""), 0, S("1234567890"), 1, 1, S("2"));
+    test(S(""), 0, S("1234567890"), 1, 4, S("2345"));
+    test(S(""), 0, S("1234567890"), 1, 8, S("23456789"));
+    test(S(""), 0, S("1234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, S("1234567890"), 1, 10, S("234567890"));
+    test(S(""), 0, S("1234567890"), 5, 0, S(""));
+    test(S(""), 0, S("1234567890"), 5, 1, S("6"));
+    test(S(""), 0, S("1234567890"), 5, 2, S("67"));
+    test(S(""), 0, S("1234567890"), 5, 4, S("6789"));
+    test(S(""), 0, S("1234567890"), 5, 5, S("67890"));
+    test(S(""), 0, S("1234567890"), 5, 6, S("67890"));
+    test(S(""), 0, S("1234567890"), 9, 0, S(""));
+    test(S(""), 0, S("1234567890"), 9, 1, S("0"));
+    test(S(""), 0, S("1234567890"), 9, 2, S("0"));
+    test(S(""), 0, S("1234567890"), 10, 0, S(""));
+    test(S(""), 0, S("1234567890"), 10, 1, S(""));
+    test(S(""), 0, S("1234567890"), 11, 0, S("can't happen"));
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), 0, S("12345678901234567890"), 0, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 0, 1, S("1"));
+    test(S(""), 0, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S(""), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 1, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 1, 1, S("2"));
+    test(S(""), 0, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S(""), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S(""), 0, S("12345678901234567890"), 10, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 10, 1, S("1"));
+    test(S(""), 0, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S(""), 0, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S(""), 0, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S(""), 0, S("12345678901234567890"), 19, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 19, 1, S("0"));
+    test(S(""), 0, S("12345678901234567890"), 19, 2, S("0"));
+    test(S(""), 0, S("12345678901234567890"), 20, 0, S(""));
+    test(S(""), 0, S("12345678901234567890"), 20, 1, S(""));
+    test(S(""), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S(""), 1, S(""), 0, 0, S("can't happen"));
+    test(S(""), 1, S(""), 0, 1, S("can't happen"));
+    test(S(""), 1, S(""), 1, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 4, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 5, S("can't happen"));
+    test(S(""), 1, S("12345"), 0, 6, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 3, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 4, S("can't happen"));
+    test(S(""), 1, S("12345"), 1, 5, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 3, S("can't happen"));
+    test(S(""), 1, S("12345"), 2, 4, S("can't happen"));
+    test(S(""), 1, S("12345"), 4, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 4, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 4, 2, S("can't happen"));
+    test(S(""), 1, S("12345"), 5, 0, S("can't happen"));
+    test(S(""), 1, S("12345"), 5, 1, S("can't happen"));
+    test(S(""), 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+    test(S(""), 1, S("1234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 5, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 9, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 0, 11, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 4, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 8, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 1, 10, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 2, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 4, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 5, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 5, 6, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 9, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 9, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 9, 2, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S(""), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S(""), 0, 1, S("abcde"));
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcde"), 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 2, S("12abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 4, S("1234abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, S("12345"), 0, 6, S("12345abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 2, S("23abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 3, S("234abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, S("12345"), 1, 5, S("2345abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 1, S("3abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 2, S("34abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 3, S("345abcde"));
+    test(S("abcde"), 0, S("12345"), 2, 4, S("345abcde"));
+    test(S("abcde"), 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 4, 1, S("5abcde"));
+    test(S("abcde"), 0, S("12345"), 4, 2, S("5abcde"));
+    test(S("abcde"), 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 9, S("123456789abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 0, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 8, S("23456789abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 1, 10, S("234567890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 1, S("6abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 2, S("67abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 4, S("6789abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 5, S("67890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 5, 6, S("67890abcde"));
+    test(S("abcde"), 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 9, 1, S("0abcde"));
+    test(S("abcde"), 0, S("1234567890"), 9, 2, S("0abcde"));
+    test(S("abcde"), 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 1, S("1abcde"));
+}
+
+template <class S>
+void test4()
+{
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 1, S("1abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 5, S("12345abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 9, S("123456789abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 19, 1, S("0abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 19, 2, S("0abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 2, S("a12bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 4, S("a1234bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, S("12345"), 0, 6, S("a12345bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 2, S("a23bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 3, S("a234bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, S("12345"), 1, 5, S("a2345bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 2, 1, S("a3bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 2, S("a34bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 3, S("a345bcde"));
+    test(S("abcde"), 1, S("12345"), 2, 4, S("a345bcde"));
+    test(S("abcde"), 1, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 4, 1, S("a5bcde"));
+    test(S("abcde"), 1, S("12345"), 4, 2, S("a5bcde"));
+    test(S("abcde"), 1, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 1, S("a1bcde"));
+}
+
+template <class S>
+void test5()
+{
+    test(S("abcde"), 1, S("1234567890"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 0, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 8, S("a23456789bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 1, 10, S("a234567890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 1, S("a6bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 2, S("a67bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 4, S("a6789bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 5, S("a67890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 5, 6, S("a67890bcde"));
+    test(S("abcde"), 1, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 9, 1, S("a0bcde"));
+    test(S("abcde"), 1, S("1234567890"), 9, 2, S("a0bcde"));
+    test(S("abcde"), 1, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 1, S("a1bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 5, S("a12345bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 19, 1, S("a0bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 19, 2, S("a0bcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 2, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, S("12345"), 0, 0, S("abcde"));
+}
+
+template <class S>
+void test6()
+{
+    test(S("abcde"), 2, S("12345"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("12345"), 0, 2, S("ab12cde"));
+    test(S("abcde"), 2, S("12345"), 0, 4, S("ab1234cde"));
+    test(S("abcde"), 2, S("12345"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, S("12345"), 0, 6, S("ab12345cde"));
+    test(S("abcde"), 2, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, S("12345"), 1, 2, S("ab23cde"));
+    test(S("abcde"), 2, S("12345"), 1, 3, S("ab234cde"));
+    test(S("abcde"), 2, S("12345"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, S("12345"), 1, 5, S("ab2345cde"));
+    test(S("abcde"), 2, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 2, 1, S("ab3cde"));
+    test(S("abcde"), 2, S("12345"), 2, 2, S("ab34cde"));
+    test(S("abcde"), 2, S("12345"), 2, 3, S("ab345cde"));
+    test(S("abcde"), 2, S("12345"), 2, 4, S("ab345cde"));
+    test(S("abcde"), 2, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 4, 1, S("ab5cde"));
+    test(S("abcde"), 2, S("12345"), 4, 2, S("ab5cde"));
+    test(S("abcde"), 2, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 0, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 8, S("ab23456789cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 1, 10, S("ab234567890cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 1, S("ab6cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 2, S("ab67cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 4, S("ab6789cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 5, S("ab67890cde"));
+    test(S("abcde"), 2, S("1234567890"), 5, 6, S("ab67890cde"));
+    test(S("abcde"), 2, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 9, 1, S("ab0cde"));
+    test(S("abcde"), 2, S("1234567890"), 9, 2, S("ab0cde"));
+    test(S("abcde"), 2, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
+}
+
+template <class S>
+void test7()
+{
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 1, S("ab1cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 5, S("ab12345cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 10, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 19, 1, S("ab0cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 19, 2, S("ab0cde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("12345"), 0, 2, S("abcd12e"));
+    test(S("abcde"), 4, S("12345"), 0, 4, S("abcd1234e"));
+    test(S("abcde"), 4, S("12345"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, S("12345"), 0, 6, S("abcd12345e"));
+    test(S("abcde"), 4, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, S("12345"), 1, 2, S("abcd23e"));
+    test(S("abcde"), 4, S("12345"), 1, 3, S("abcd234e"));
+    test(S("abcde"), 4, S("12345"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, S("12345"), 1, 5, S("abcd2345e"));
+    test(S("abcde"), 4, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 2, 1, S("abcd3e"));
+    test(S("abcde"), 4, S("12345"), 2, 2, S("abcd34e"));
+    test(S("abcde"), 4, S("12345"), 2, 3, S("abcd345e"));
+    test(S("abcde"), 4, S("12345"), 2, 4, S("abcd345e"));
+    test(S("abcde"), 4, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 4, 1, S("abcd5e"));
+    test(S("abcde"), 4, S("12345"), 4, 2, S("abcd5e"));
+    test(S("abcde"), 4, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("1234567890"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, S("1234567890"), 0, 9, S("abcd123456789e"));
+}
+
+template <class S>
+void test8()
+{
+    test(S("abcde"), 4, S("1234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 0, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 8, S("abcd23456789e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 1, 10, S("abcd234567890e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 5, 1, S("abcd6e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 2, S("abcd67e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 4, S("abcd6789e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 5, S("abcd67890e"));
+    test(S("abcde"), 4, S("1234567890"), 5, 6, S("abcd67890e"));
+    test(S("abcde"), 4, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 9, 1, S("abcd0e"));
+    test(S("abcde"), 4, S("1234567890"), 9, 2, S("abcd0e"));
+    test(S("abcde"), 4, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 1, S("abcd1e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 5, S("abcd12345e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 9, S("abcd123456789e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 10, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 19, 1, S("abcd0e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 19, 2, S("abcd0e"));
+    test(S("abcde"), 4, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 5, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 5, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, S("12345"), 0, 2, S("abcde12"));
+}
+
+template <class S>
+void test9()
+{
+    test(S("abcde"), 5, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcde"), 5, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcde"), 5, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcde"), 5, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcde"), 5, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcde"), 5, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcde"), 5, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcde"), 5, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcde"), 5, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcde"), 5, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcde"), 5, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcde"), 5, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 5, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcde"), 5, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcde"), 5, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcde"), 5, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcde"), 5, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcde"), 5, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcde"), 5, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcde"), 5, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcde"), 5, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcde"), 5, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcde"), 5, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test10()
+{
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcde"), 5, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcde"), 5, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 6, S(""), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S(""), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 0, 11, S("can't happen"));
+}
+
+template <class S>
+void test11()
+{
+    test(S("abcde"), 6, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcde"), 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 0, 5, S("12345abcdefghij"));
+}
+
+template <class S>
+void test12()
+{
+    test(S("abcdefghij"), 0, S("12345"), 0, 6, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 2, S("23abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 3, S("234abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 1, 5, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 1, S("3abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 2, S("34abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 3, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 2, 4, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 4, 1, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 4, 2, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 8, S("23456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 1, 10, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 1, S("6abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 2, S("67abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 4, S("6789abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 5, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 5, 6, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 9, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 9, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
+}
+
+template <class S>
+void test13()
+{
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 0, 6, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 2, S("a23bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 3, S("a234bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 1, 5, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 1, S("a3bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 2, S("a34bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 3, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 2, 4, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 4, 1, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 4, 2, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 1, S("a2bcdefghij"));
+}
+
+template <class S>
+void test14()
+{
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 1, S("a6bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 2, S("a67bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 4, S("a6789bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 5, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 5, 6, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 9, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 9, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 0, 6, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 0, S("abcdefghij"));
+}
+
+template <class S>
+void test15()
+{
+    test(S("abcdefghij"), 5, S("12345"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 2, S("abcde23fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 3, S("abcde234fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 1, 5, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 1, S("abcde3fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 2, S("abcde34fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 3, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 2, 4, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 4, 1, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 4, 2, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 0, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 8, S("abcde23456789fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 1, 10, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 1, S("abcde6fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 2, S("abcde67fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 4, S("abcde6789fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 5, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 5, 6, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 9, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 9, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
+}
+
+template <class S>
+void test16()
+{
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 19, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("12345"), 0, 6, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 2, S("abcdefghi23j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 3, S("abcdefghi234j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, S("12345"), 1, 5, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 1, S("abcdefghi3j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 2, S("abcdefghi34j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 3, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, S("12345"), 2, 4, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 4, 1, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, S("12345"), 4, 2, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 0, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
+}
+
+template <class S>
+void test17()
+{
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 1, 10, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 1, S("abcdefghi6j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 2, S("abcdefghi67j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 4, S("abcdefghi6789j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 5, S("abcdefghi67890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 5, 6, S("abcdefghi67890j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 9, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 9, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 19, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 2, S("abcdefghij23"));
+}
+
+template <class S>
+void test18()
+{
+    test(S("abcdefghij"), 10, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+}
+
+template <class S>
+void test19()
+{
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 1, 10, S("can't happen"));
+}
+
+template <class S>
+void test20()
+{
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test21()
+{
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test22()
+{
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test23()
+{
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test24()
+{
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 2, S("abcdefghij34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 3, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 2, 4, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 1, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 4, 2, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
+}
+
+template <class S>
+void test25()
+{
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
+}
+
+template <class S>
+void test26()
+{
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+}
+
+template <class S>
+void test27()
+{
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+}
+
+template <class S>
+void test28()
+{
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 5, 6, S("can't happen"));
+}
+
+template <class S>
+void test29()
+{
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+template <class S>
+void test30()
+{
+    test_npos(S(""), 0, S("12345678901234567890"),  0, S("12345678901234567890"));
+    test_npos(S(""), 0, S("12345678901234567890"),  1, S( "2345678901234567890"));
+    test_npos(S(""), 0, S("12345678901234567890"),  2, S(  "345678901234567890"));
+    test_npos(S(""), 0, S("12345678901234567890"),  3, S(   "45678901234567890"));
+    test_npos(S(""), 0, S("12345678901234567890"),  5, S(     "678901234567890"));
+    test_npos(S(""), 0, S("12345678901234567890"), 10, S(          "1234567890"));
+    test_npos(S(""), 0, S("12345678901234567890"), 21, S("can't happen"));
+    test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 0, S("abcdefghij12345klmnopqrst"));
+    test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 1, S("abcdefghij2345klmnopqrst"));
+    test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 3, S("abcdefghij45klmnopqrst"));
+    test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 5, S("abcdefghijklmnopqrst"));
+    test_npos(S("abcdefghijklmnopqrst"), 10, S("12345"), 6, S("can't happen"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    test12<S>();
+    test13<S>();
+    test14<S>();
+    test15<S>();
+    test16<S>();
+    test17<S>();
+    test18<S>();
+    test19<S>();
+    test20<S>();
+    test21<S>();
+    test22<S>();
+    test23<S>();
+    test24<S>();
+    test25<S>();
+    test26<S>();
+    test27<S>();
+    test28<S>();
+    test29<S>();
+    test30<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    test12<S>();
+    test13<S>();
+    test14<S>();
+    test15<S>();
+    test16<S>();
+    test17<S>();
+    test18<S>();
+    test19<S>();
+    test20<S>();
+    test21<S>();
+    test22<S>();
+    test23<S>();
+    test24<S>();
+    test25<S>();
+    test26<S>();
+    test27<S>();
+    test28<S>();
+    test29<S>();
+    test30<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
new file mode 100644
index 0000000..7384ae7
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/char.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& operator+=(charT c);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::value_type str, S expected)
+{
+    s += str;
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), 'a', S("a"));
+    test(S("12345"), 'a', S("12345a"));
+    test(S("1234567890"), 'a', S("1234567890a"));
+    test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), 'a', S("a"));
+    test(S("12345"), 'a', S("12345a"));
+    test(S("1234567890"), 'a', S("1234567890a"));
+    test(S("12345678901234567890"), 'a', S("12345678901234567890a"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
new file mode 100644
index 0000000..c291028
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& operator+=(initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::string s("123");
+        s += {'a', 'b', 'c'};
+        assert(s == "123abc");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s("123");
+        s += {'a', 'b', 'c'};
+        assert(s == "123abc");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp
new file mode 100644
index 0000000..77b20d1
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/pointer.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>& operator+=(const charT* s);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, const typename S::value_type* str, S expected)
+{
+    s += str;
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "1234567890", S("1234567890"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S("12345"));
+    test(S("12345"), "12345", S("1234512345"));
+    test(S("12345"), "1234567890", S("123451234567890"));
+    test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
+
+    test(S("1234567890"), "", S("1234567890"));
+    test(S("1234567890"), "12345", S("123456789012345"));
+    test(S("1234567890"), "1234567890", S("12345678901234567890"));
+    test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
+
+    test(S("12345678901234567890"), "", S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("1234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), "", S());
+    test(S(), "12345", S("12345"));
+    test(S(), "1234567890", S("1234567890"));
+    test(S(), "12345678901234567890", S("12345678901234567890"));
+
+    test(S("12345"), "", S("12345"));
+    test(S("12345"), "12345", S("1234512345"));
+    test(S("12345"), "1234567890", S("123451234567890"));
+    test(S("12345"), "12345678901234567890", S("1234512345678901234567890"));
+
+    test(S("1234567890"), "", S("1234567890"));
+    test(S("1234567890"), "12345", S("123456789012345"));
+    test(S("1234567890"), "1234567890", S("12345678901234567890"));
+    test(S("1234567890"), "12345678901234567890", S("123456789012345678901234567890"));
+
+    test(S("12345678901234567890"), "", S("12345678901234567890"));
+    test(S("12345678901234567890"), "12345", S("1234567890123456789012345"));
+    test(S("12345678901234567890"), "1234567890", S("123456789012345678901234567890"));
+    test(S("12345678901234567890"), "12345678901234567890",
+         S("1234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
new file mode 100644
index 0000000..3364979
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_op_plus_equal/string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   operator+=(const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, S str, S expected)
+{
+    s += str;
+    assert(s.__invariants());
+    assert(s == expected);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S("12345"));
+    test(S("12345"), S("12345"), S("1234512345"));
+    test(S("12345"), S("1234567890"), S("123451234567890"));
+    test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+    test(S("1234567890"), S(), S("1234567890"));
+    test(S("1234567890"), S("12345"), S("123456789012345"));
+    test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S("12345678901234567890"));
+    test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+    test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("1234567890123456789012345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(), S(), S());
+    test(S(), S("12345"), S("12345"));
+    test(S(), S("1234567890"), S("1234567890"));
+    test(S(), S("12345678901234567890"), S("12345678901234567890"));
+
+    test(S("12345"), S(), S("12345"));
+    test(S("12345"), S("12345"), S("1234512345"));
+    test(S("12345"), S("1234567890"), S("123451234567890"));
+    test(S("12345"), S("12345678901234567890"), S("1234512345678901234567890"));
+
+    test(S("1234567890"), S(), S("1234567890"));
+    test(S("1234567890"), S("12345"), S("123456789012345"));
+    test(S("1234567890"), S("1234567890"), S("12345678901234567890"));
+    test(S("1234567890"), S("12345678901234567890"), S("123456789012345678901234567890"));
+
+    test(S("12345678901234567890"), S(), S("12345678901234567890"));
+    test(S("12345678901234567890"), S("12345"), S("1234567890123456789012345"));
+    test(S("12345678901234567890"), S("1234567890"), S("123456789012345678901234567890"));
+    test(S("12345678901234567890"), S("12345678901234567890"),
+         S("1234567890123456789012345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
new file mode 100644
index 0000000..20455b2
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<charT> il);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    {
+        std::string s("123def456");
+        s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
+        assert(s == "123abc456");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s("123def456");
+        s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'});
+        assert(s == "123abc456");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp
new file mode 100644
index 0000000..9295c5b
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp
@@ -0,0 +1,976 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class InputIterator>
+//   basic_string&
+//   replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2);
+
+#include <string>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S, class It>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S expected)
+{
+    typename S::size_type old_size = s.size();
+    typename S::const_iterator first = s.begin() + pos1;
+    typename S::const_iterator last = s.begin() + pos1 + n1;
+    typename S::size_type xlen = last - first;
+    s.replace(first, last, f, l);
+    assert(s.__invariants());
+    assert(s == expected);
+    typename S::size_type rlen = std::distance(f, l);
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+const char* str = "12345678901234567890";
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+1, S("1"));
+    test(S(""), 0, 0, str, str+2, S("12"));
+    test(S(""), 0, 0, str, str+4, S("1234"));
+    test(S(""), 0, 0, str, str+5, S("12345"));
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+1, S("1"));
+    test(S(""), 0, 0, str, str+5, S("12345"));
+    test(S(""), 0, 0, str, str+9, S("123456789"));
+    test(S(""), 0, 0, str, str+10, S("1234567890"));
+    test(S(""), 0, 0, str, str+0, S(""));
+    test(S(""), 0, 0, str, str+1, S("1"));
+    test(S(""), 0, 0, str, str+10, S("1234567890"));
+    test(S(""), 0, 0, str, str+19, S("1234567890123456789"));
+    test(S(""), 0, 0, str, str+20, S("12345678901234567890"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+    test(S("abcde"), 0, 0, str, str+2, S("12abcde"));
+    test(S("abcde"), 0, 0, str, str+4, S("1234abcde"));
+    test(S("abcde"), 0, 0, str, str+5, S("12345abcde"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+    test(S("abcde"), 0, 0, str, str+5, S("12345abcde"));
+    test(S("abcde"), 0, 0, str, str+9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 0, 0, str, str+1, S("1abcde"));
+    test(S("abcde"), 0, 0, str, str+10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, str, str+19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, str, str+20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+    test(S("abcde"), 0, 1, str, str+2, S("12bcde"));
+    test(S("abcde"), 0, 1, str, str+4, S("1234bcde"));
+    test(S("abcde"), 0, 1, str, str+5, S("12345bcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+    test(S("abcde"), 0, 1, str, str+5, S("12345bcde"));
+    test(S("abcde"), 0, 1, str, str+9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, str, str+0, S("bcde"));
+    test(S("abcde"), 0, 1, str, str+1, S("1bcde"));
+    test(S("abcde"), 0, 1, str, str+10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, str, str+19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, str, str+20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+    test(S("abcde"), 0, 2, str, str+2, S("12cde"));
+    test(S("abcde"), 0, 2, str, str+4, S("1234cde"));
+    test(S("abcde"), 0, 2, str, str+5, S("12345cde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+    test(S("abcde"), 0, 2, str, str+5, S("12345cde"));
+    test(S("abcde"), 0, 2, str, str+9, S("123456789cde"));
+    test(S("abcde"), 0, 2, str, str+10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, str, str+0, S("cde"));
+    test(S("abcde"), 0, 2, str, str+1, S("1cde"));
+    test(S("abcde"), 0, 2, str, str+10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, str, str+19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, str, str+20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+1, S("1e"));
+    test(S("abcde"), 0, 4, str, str+2, S("12e"));
+    test(S("abcde"), 0, 4, str, str+4, S("1234e"));
+    test(S("abcde"), 0, 4, str, str+5, S("12345e"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+1, S("1e"));
+    test(S("abcde"), 0, 4, str, str+5, S("12345e"));
+    test(S("abcde"), 0, 4, str, str+9, S("123456789e"));
+    test(S("abcde"), 0, 4, str, str+10, S("1234567890e"));
+    test(S("abcde"), 0, 4, str, str+0, S("e"));
+    test(S("abcde"), 0, 4, str, str+1, S("1e"));
+    test(S("abcde"), 0, 4, str, str+10, S("1234567890e"));
+    test(S("abcde"), 0, 4, str, str+19, S("1234567890123456789e"));
+    test(S("abcde"), 0, 4, str, str+20, S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, str, str+0, S(""));
+    test(S("abcde"), 0, 5, str, str+0, S(""));
+    test(S("abcde"), 0, 5, str, str+1, S("1"));
+    test(S("abcde"), 0, 5, str, str+2, S("12"));
+    test(S("abcde"), 0, 5, str, str+4, S("1234"));
+    test(S("abcde"), 0, 5, str, str+5, S("12345"));
+    test(S("abcde"), 0, 5, str, str+0, S(""));
+    test(S("abcde"), 0, 5, str, str+1, S("1"));
+    test(S("abcde"), 0, 5, str, str+5, S("12345"));
+    test(S("abcde"), 0, 5, str, str+9, S("123456789"));
+    test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
+    test(S("abcde"), 0, 5, str, str+0, S(""));
+    test(S("abcde"), 0, 5, str, str+1, S("1"));
+    test(S("abcde"), 0, 5, str, str+10, S("1234567890"));
+    test(S("abcde"), 0, 5, str, str+19, S("1234567890123456789"));
+    test(S("abcde"), 0, 5, str, str+20, S("12345678901234567890"));
+    test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+    test(S("abcde"), 1, 0, str, str+2, S("a12bcde"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 1, 0, str, str+4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, str, str+5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+    test(S("abcde"), 1, 0, str, str+5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, str, str+9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 1, 0, str, str+1, S("a1bcde"));
+    test(S("abcde"), 1, 0, str, str+10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, str, str+19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, str, str+20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+    test(S("abcde"), 1, 1, str, str+2, S("a12cde"));
+    test(S("abcde"), 1, 1, str, str+4, S("a1234cde"));
+    test(S("abcde"), 1, 1, str, str+5, S("a12345cde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+    test(S("abcde"), 1, 1, str, str+5, S("a12345cde"));
+    test(S("abcde"), 1, 1, str, str+9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, str, str+0, S("acde"));
+    test(S("abcde"), 1, 1, str, str+1, S("a1cde"));
+    test(S("abcde"), 1, 1, str, str+10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, str, str+19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, str, str+20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+    test(S("abcde"), 1, 2, str, str+2, S("a12de"));
+    test(S("abcde"), 1, 2, str, str+4, S("a1234de"));
+    test(S("abcde"), 1, 2, str, str+5, S("a12345de"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+    test(S("abcde"), 1, 2, str, str+5, S("a12345de"));
+    test(S("abcde"), 1, 2, str, str+9, S("a123456789de"));
+    test(S("abcde"), 1, 2, str, str+10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, str, str+0, S("ade"));
+    test(S("abcde"), 1, 2, str, str+1, S("a1de"));
+    test(S("abcde"), 1, 2, str, str+10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, str, str+19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, str, str+20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+    test(S("abcde"), 1, 3, str, str+2, S("a12e"));
+    test(S("abcde"), 1, 3, str, str+4, S("a1234e"));
+    test(S("abcde"), 1, 3, str, str+5, S("a12345e"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+    test(S("abcde"), 1, 3, str, str+5, S("a12345e"));
+    test(S("abcde"), 1, 3, str, str+9, S("a123456789e"));
+    test(S("abcde"), 1, 3, str, str+10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, str, str+0, S("ae"));
+    test(S("abcde"), 1, 3, str, str+1, S("a1e"));
+    test(S("abcde"), 1, 3, str, str+10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, str, str+19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, str, str+20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+1, S("a1"));
+    test(S("abcde"), 1, 4, str, str+2, S("a12"));
+    test(S("abcde"), 1, 4, str, str+4, S("a1234"));
+    test(S("abcde"), 1, 4, str, str+5, S("a12345"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+1, S("a1"));
+    test(S("abcde"), 1, 4, str, str+5, S("a12345"));
+    test(S("abcde"), 1, 4, str, str+9, S("a123456789"));
+    test(S("abcde"), 1, 4, str, str+10, S("a1234567890"));
+    test(S("abcde"), 1, 4, str, str+0, S("a"));
+    test(S("abcde"), 1, 4, str, str+1, S("a1"));
+    test(S("abcde"), 1, 4, str, str+10, S("a1234567890"));
+    test(S("abcde"), 1, 4, str, str+19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, str, str+20, S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+    test(S("abcde"), 2, 0, str, str+2, S("ab12cde"));
+    test(S("abcde"), 2, 0, str, str+4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, str, str+5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+    test(S("abcde"), 2, 0, str, str+5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, str, str+9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 2, 0, str, str+1, S("ab1cde"));
+    test(S("abcde"), 2, 0, str, str+10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, str, str+19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, str, str+20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+    test(S("abcde"), 2, 1, str, str+2, S("ab12de"));
+    test(S("abcde"), 2, 1, str, str+4, S("ab1234de"));
+    test(S("abcde"), 2, 1, str, str+5, S("ab12345de"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcde"), 2, 1, str, str+5, S("ab12345de"));
+    test(S("abcde"), 2, 1, str, str+9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, str, str+0, S("abde"));
+    test(S("abcde"), 2, 1, str, str+1, S("ab1de"));
+    test(S("abcde"), 2, 1, str, str+10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, str, str+19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, str, str+20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+    test(S("abcde"), 2, 2, str, str+2, S("ab12e"));
+    test(S("abcde"), 2, 2, str, str+4, S("ab1234e"));
+    test(S("abcde"), 2, 2, str, str+5, S("ab12345e"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+    test(S("abcde"), 2, 2, str, str+5, S("ab12345e"));
+    test(S("abcde"), 2, 2, str, str+9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, str, str+0, S("abe"));
+    test(S("abcde"), 2, 2, str, str+1, S("ab1e"));
+    test(S("abcde"), 2, 2, str, str+10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, str, str+19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, str, str+20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+    test(S("abcde"), 2, 3, str, str+2, S("ab12"));
+    test(S("abcde"), 2, 3, str, str+4, S("ab1234"));
+    test(S("abcde"), 2, 3, str, str+5, S("ab12345"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+    test(S("abcde"), 2, 3, str, str+5, S("ab12345"));
+    test(S("abcde"), 2, 3, str, str+9, S("ab123456789"));
+    test(S("abcde"), 2, 3, str, str+10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, str, str+0, S("ab"));
+    test(S("abcde"), 2, 3, str, str+1, S("ab1"));
+    test(S("abcde"), 2, 3, str, str+10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, str, str+19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, str, str+20, S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+    test(S("abcde"), 4, 0, str, str+2, S("abcd12e"));
+    test(S("abcde"), 4, 0, str, str+4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, str, str+5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+    test(S("abcde"), 4, 0, str, str+5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, str, str+9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 4, 0, str, str+1, S("abcd1e"));
+    test(S("abcde"), 4, 0, str, str+10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, str, str+19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, str, str+20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+    test(S("abcde"), 4, 1, str, str+2, S("abcd12"));
+    test(S("abcde"), 4, 1, str, str+4, S("abcd1234"));
+    test(S("abcde"), 4, 1, str, str+5, S("abcd12345"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+    test(S("abcde"), 4, 1, str, str+5, S("abcd12345"));
+    test(S("abcde"), 4, 1, str, str+9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, str, str+0, S("abcd"));
+    test(S("abcde"), 4, 1, str, str+1, S("abcd1"));
+    test(S("abcde"), 4, 1, str, str+10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, str, str+19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, str, str+20, S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+    test(S("abcde"), 5, 0, str, str+2, S("abcde12"));
+    test(S("abcde"), 5, 0, str, str+4, S("abcde1234"));
+    test(S("abcde"), 5, 0, str, str+5, S("abcde12345"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+    test(S("abcde"), 5, 0, str, str+5, S("abcde12345"));
+    test(S("abcde"), 5, 0, str, str+9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, str, str+0, S("abcde"));
+    test(S("abcde"), 5, 0, str, str+1, S("abcde1"));
+    test(S("abcde"), 5, 0, str, str+10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, str, str+19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, str, str+20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+0, S("abcdefghij"));
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcdefghij"), 0, 0, str, str+1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, str, str+20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, str, str+20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, str, str+20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+    test(S("abcdefghij"), 0, 9, str, str+2, S("12j"));
+    test(S("abcdefghij"), 0, 9, str, str+4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, str, str+5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+    test(S("abcdefghij"), 0, 9, str, str+5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, str, str+9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, str, str+0, S("j"));
+    test(S("abcdefghij"), 0, 9, str, str+1, S("1j"));
+    test(S("abcdefghij"), 0, 9, str, str+10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, str, str+19, S("1234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, str, str+20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+    test(S("abcdefghij"), 0, 10, str, str+2, S("12"));
+    test(S("abcdefghij"), 0, 10, str, str+4, S("1234"));
+    test(S("abcdefghij"), 0, 10, str, str+5, S("12345"));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+    test(S("abcdefghij"), 0, 10, str, str+5, S("12345"));
+    test(S("abcdefghij"), 0, 10, str, str+9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, str, str+0, S(""));
+    test(S("abcdefghij"), 0, 10, str, str+1, S("1"));
+    test(S("abcdefghij"), 0, 10, str, str+10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, str, str+19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, str, str+20, S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, str, str+20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, str, str+20, S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test4()
+{
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, str, str+1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, str, str+20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, str, str+2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, str, str+4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, str, str+5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, str, str+9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, str, str+0, S("aj"));
+    test(S("abcdefghij"), 1, 8, str, str+1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, str, str+10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, str, str+19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, str, str+20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+    test(S("abcdefghij"), 1, 9, str, str+2, S("a12"));
+    test(S("abcdefghij"), 1, 9, str, str+4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, str, str+5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+    test(S("abcdefghij"), 1, 9, str, str+5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, str, str+9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, str, str+0, S("a"));
+    test(S("abcdefghij"), 1, 9, str, str+1, S("a1"));
+    test(S("abcdefghij"), 1, 9, str, str+10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, str, str+19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, str, str+20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, str, str+1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, str, str+20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, str, str+1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, str, str+20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, str, str+2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, str, str+4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, str, str+5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, str, str+9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, str, str+0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, str, str+1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, str, str+10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, str, str+19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, str, str+20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, str, str+2, S("abcde12j"));
+}
+
+template <class S>
+void test5()
+{
+    test(S("abcdefghij"), 5, 4, str, str+4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, str, str+5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, str, str+9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, str, str+0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, str, str+1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, str, str+10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, str, str+19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, str, str+20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, str, str+2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, str, str+4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, str, str+5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, str, str+9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, str, str+0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, str, str+1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, str, str+10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, str, str+19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, str, str+20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, str, str+2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, str, str+4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, str, str+5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, str, str+9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, str, str+1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, str, str+10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, str, str+19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, str, str+20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, str, str+2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, str, str+4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, str, str+5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, str, str+9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, str, str+0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, str, str+1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, str, str+10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, str, str+19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, str, str+20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, str, str+2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, str, str+4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, str, str+9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, str, str+0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, str, str+19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, str, str+20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, str, str+20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test6()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, str, str+20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, str, str+20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, str, str+20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, str, str+20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, str, str+20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, str, str+20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+0, S("aklmnopqrst"));
+}
+
+template <class S>
+void test7()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, str, str+20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, str, str+20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, str, str+20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, str, str+20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, str, str+20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, str, str+20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, str, str+20, S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, str, str+20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, str, str+20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, str, str+20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, str, str+20, S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
new file mode 100644
index 0000000..cb4ce61
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp
@@ -0,0 +1,285 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(const_iterator i1, const_iterator i2, const charT* s);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    typename S::const_iterator first = s.begin() + pos1;
+    typename S::const_iterator last = s.begin() + pos1 + n1;
+    typename S::size_type xlen = last - first;
+    s.replace(first, last, str);
+    assert(s.__invariants());
+    assert(s == expected);
+    typename S::size_type rlen = S::traits_type::length(str);
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, "", S(""));
+    test(S(""), 0, 0, "12345", S("12345"));
+    test(S(""), 0, 0, "1234567890", S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 0, 0, "", S("abcde"));
+    test(S("abcde"), 0, 0, "12345", S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", S("bcde"));
+    test(S("abcde"), 0, 1, "12345", S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", S("cde"));
+    test(S("abcde"), 0, 2, "12345", S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", S("e"));
+    test(S("abcde"), 0, 4, "12345", S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", S(""));
+    test(S("abcde"), 0, 5, "12345", S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", S("abcde"));
+    test(S("abcde"), 1, 0, "12345", S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", S("acde"));
+    test(S("abcde"), 1, 1, "12345", S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", S("ade"));
+    test(S("abcde"), 1, 2, "12345", S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", S("ae"));
+    test(S("abcde"), 1, 3, "12345", S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", S("a"));
+    test(S("abcde"), 1, 4, "12345", S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", S("abcde"));
+    test(S("abcde"), 2, 0, "12345", S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", S("abde"));
+    test(S("abcde"), 2, 1, "12345", S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", S("abe"));
+    test(S("abcde"), 2, 2, "12345", S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", S("ab"));
+    test(S("abcde"), 2, 3, "12345", S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", S("abcde"));
+    test(S("abcde"), 4, 0, "12345", S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", S("abcd"));
+    test(S("abcde"), 4, 1, "12345", S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", S("abcde"));
+    test(S("abcde"), 5, 0, "12345", S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", S(""));
+    test(S("abcdefghij"), 0, 10, "12345", S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcdefghij"), 1, 4, "", S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp
new file mode 100644
index 0000000..b1d6ab1
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp
@@ -0,0 +1,976 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, const typename S::value_type* str,
+     typename S::size_type n2, S expected)
+{
+    typename S::size_type old_size = s.size();
+    typename S::const_iterator first = s.begin() + pos1;
+    typename S::const_iterator last = s.begin() + pos1 + n1;
+    typename S::size_type xlen = last - first;
+    s.replace(first, last, str, n2);
+    assert(s.__invariants());
+    assert(s == expected);
+    typename S::size_type rlen = n2;
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, "", 0, S(""));
+    test(S(""), 0, 0, "12345", 0, S(""));
+    test(S(""), 0, 0, "12345", 1, S("1"));
+    test(S(""), 0, 0, "12345", 2, S("12"));
+    test(S(""), 0, 0, "12345", 4, S("1234"));
+    test(S(""), 0, 0, "12345", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 0, S(""));
+    test(S(""), 0, 0, "1234567890", 1, S("1"));
+    test(S(""), 0, 0, "1234567890", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 9, S("123456789"));
+    test(S(""), 0, 0, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 0, S(""));
+    test(S(""), 0, 0, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 0, "", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345", 2, S("12abcde"));
+    test(S("abcde"), 0, 0, "12345", 4, S("1234abcde"));
+    test(S("abcde"), 0, 0, "12345", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345", 2, S("12bcde"));
+    test(S("abcde"), 0, 1, "12345", 4, S("1234bcde"));
+    test(S("abcde"), 0, 1, "12345", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345", 2, S("12cde"));
+    test(S("abcde"), 0, 2, "12345", 4, S("1234cde"));
+    test(S("abcde"), 0, 2, "12345", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "1234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde"));
+    test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345", 2, S("12e"));
+    test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
+    test(S("abcde"), 0, 4, "12345", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "1234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "1234567890", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e"));
+    test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345", 2, S("12"));
+    test(S("abcde"), 0, 5, "12345", 4, S("1234"));
+    test(S("abcde"), 0, 5, "12345", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "1234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "1234567890", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 9, S("123456789"));
+    test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345", 2, S("a12cde"));
+    test(S("abcde"), 1, 1, "12345", 4, S("a1234cde"));
+    test(S("abcde"), 1, 1, "12345", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345", 2, S("a12de"));
+    test(S("abcde"), 1, 2, "12345", 4, S("a1234de"));
+    test(S("abcde"), 1, 2, "12345", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "1234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345", 2, S("a12e"));
+    test(S("abcde"), 1, 3, "12345", 4, S("a1234e"));
+    test(S("abcde"), 1, 3, "12345", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345", 2, S("a12"));
+    test(S("abcde"), 1, 4, "12345", 4, S("a1234"));
+    test(S("abcde"), 1, 4, "12345", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "1234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "1234567890", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789"));
+    test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345", 2, S("ab12cde"));
+    test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345", 2, S("ab12de"));
+    test(S("abcde"), 2, 1, "12345", 4, S("ab1234de"));
+    test(S("abcde"), 2, 1, "12345", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345", 2, S("ab12e"));
+    test(S("abcde"), 2, 2, "12345", 4, S("ab1234e"));
+    test(S("abcde"), 2, 2, "12345", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345", 2, S("ab12"));
+    test(S("abcde"), 2, 3, "12345", 4, S("ab1234"));
+    test(S("abcde"), 2, 3, "12345", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 0, S("ab"));
+    test(S("abcde"), 2, 3, "1234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345", 2, S("abcd12e"));
+    test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345", 2, S("abcd12"));
+    test(S("abcde"), 4, 1, "12345", 4, S("abcd1234"));
+    test(S("abcde"), 4, 1, "12345", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, 0, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, 0, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345", 2, S("12j"));
+    test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345", 2, S("12"));
+    test(S("abcdefghij"), 0, 10, "12345", 4, S("1234"));
+    test(S("abcdefghij"), 0, 10, "12345", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test4()
+{
+    test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345", 2, S("a12"));
+    test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
+}
+
+template <class S>
+void test5()
+{
+    test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test6()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
+}
+
+template <class S>
+void test7()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
new file mode 100644
index 0000000..b0e2234
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(const_iterator i1, const_iterator i2, size_type n, charT c);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, typename S::size_type n2,
+     typename S::value_type c, S expected)
+{
+    typename S::size_type old_size = s.size();
+    typename S::const_iterator first = s.begin() + pos1;
+    typename S::const_iterator last = s.begin() + pos1 + n1;
+    typename S::size_type xlen = last - first;
+    s.replace(first, last, n2, c);
+    assert(s.__invariants());
+    assert(s == expected);
+    typename S::size_type rlen = n2;
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, 0, '3', S(""));
+    test(S(""), 0, 0, 5, '3', S("33333"));
+    test(S(""), 0, 0, 10, '3', S("3333333333"));
+    test(S(""), 0, 0, 20, '3', S("33333333333333333333"));
+    test(S("abcde"), 0, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 0, 0, 5, '3', S("33333abcde"));
+    test(S("abcde"), 0, 0, 10, '3', S("3333333333abcde"));
+    test(S("abcde"), 0, 0, 20, '3', S("33333333333333333333abcde"));
+    test(S("abcde"), 0, 1, 0, '3', S("bcde"));
+    test(S("abcde"), 0, 1, 5, '3', S("33333bcde"));
+    test(S("abcde"), 0, 1, 10, '3', S("3333333333bcde"));
+    test(S("abcde"), 0, 1, 20, '3', S("33333333333333333333bcde"));
+    test(S("abcde"), 0, 2, 0, '3', S("cde"));
+    test(S("abcde"), 0, 2, 5, '3', S("33333cde"));
+    test(S("abcde"), 0, 2, 10, '3', S("3333333333cde"));
+    test(S("abcde"), 0, 2, 20, '3', S("33333333333333333333cde"));
+    test(S("abcde"), 0, 4, 0, '3', S("e"));
+    test(S("abcde"), 0, 4, 5, '3', S("33333e"));
+    test(S("abcde"), 0, 4, 10, '3', S("3333333333e"));
+    test(S("abcde"), 0, 4, 20, '3', S("33333333333333333333e"));
+    test(S("abcde"), 0, 5, 0, '3', S(""));
+    test(S("abcde"), 0, 5, 5, '3', S("33333"));
+    test(S("abcde"), 0, 5, 10, '3', S("3333333333"));
+    test(S("abcde"), 0, 5, 20, '3', S("33333333333333333333"));
+    test(S("abcde"), 1, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 1, 0, 5, '3', S("a33333bcde"));
+    test(S("abcde"), 1, 0, 10, '3', S("a3333333333bcde"));
+    test(S("abcde"), 1, 0, 20, '3', S("a33333333333333333333bcde"));
+    test(S("abcde"), 1, 1, 0, '3', S("acde"));
+    test(S("abcde"), 1, 1, 5, '3', S("a33333cde"));
+    test(S("abcde"), 1, 1, 10, '3', S("a3333333333cde"));
+    test(S("abcde"), 1, 1, 20, '3', S("a33333333333333333333cde"));
+    test(S("abcde"), 1, 2, 0, '3', S("ade"));
+    test(S("abcde"), 1, 2, 5, '3', S("a33333de"));
+    test(S("abcde"), 1, 2, 10, '3', S("a3333333333de"));
+    test(S("abcde"), 1, 2, 20, '3', S("a33333333333333333333de"));
+    test(S("abcde"), 1, 3, 0, '3', S("ae"));
+    test(S("abcde"), 1, 3, 5, '3', S("a33333e"));
+    test(S("abcde"), 1, 3, 10, '3', S("a3333333333e"));
+    test(S("abcde"), 1, 3, 20, '3', S("a33333333333333333333e"));
+    test(S("abcde"), 1, 4, 0, '3', S("a"));
+    test(S("abcde"), 1, 4, 5, '3', S("a33333"));
+    test(S("abcde"), 1, 4, 10, '3', S("a3333333333"));
+    test(S("abcde"), 1, 4, 20, '3', S("a33333333333333333333"));
+    test(S("abcde"), 2, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 2, 0, 5, '3', S("ab33333cde"));
+    test(S("abcde"), 2, 0, 10, '3', S("ab3333333333cde"));
+    test(S("abcde"), 2, 0, 20, '3', S("ab33333333333333333333cde"));
+    test(S("abcde"), 2, 1, 0, '3', S("abde"));
+    test(S("abcde"), 2, 1, 5, '3', S("ab33333de"));
+    test(S("abcde"), 2, 1, 10, '3', S("ab3333333333de"));
+    test(S("abcde"), 2, 1, 20, '3', S("ab33333333333333333333de"));
+    test(S("abcde"), 2, 2, 0, '3', S("abe"));
+    test(S("abcde"), 2, 2, 5, '3', S("ab33333e"));
+    test(S("abcde"), 2, 2, 10, '3', S("ab3333333333e"));
+    test(S("abcde"), 2, 2, 20, '3', S("ab33333333333333333333e"));
+    test(S("abcde"), 2, 3, 0, '3', S("ab"));
+    test(S("abcde"), 2, 3, 5, '3', S("ab33333"));
+    test(S("abcde"), 2, 3, 10, '3', S("ab3333333333"));
+    test(S("abcde"), 2, 3, 20, '3', S("ab33333333333333333333"));
+    test(S("abcde"), 4, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 4, 0, 5, '3', S("abcd33333e"));
+    test(S("abcde"), 4, 0, 10, '3', S("abcd3333333333e"));
+    test(S("abcde"), 4, 0, 20, '3', S("abcd33333333333333333333e"));
+    test(S("abcde"), 4, 1, 0, '3', S("abcd"));
+    test(S("abcde"), 4, 1, 5, '3', S("abcd33333"));
+    test(S("abcde"), 4, 1, 10, '3', S("abcd3333333333"));
+    test(S("abcde"), 4, 1, 20, '3', S("abcd33333333333333333333"));
+    test(S("abcde"), 5, 0, 0, '3', S("abcde"));
+    test(S("abcde"), 5, 0, 5, '3', S("abcde33333"));
+    test(S("abcde"), 5, 0, 10, '3', S("abcde3333333333"));
+    test(S("abcde"), 5, 0, 20, '3', S("abcde33333333333333333333"));
+    test(S("abcdefghij"), 0, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 5, '3', S("33333abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 10, '3', S("3333333333abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 20, '3', S("33333333333333333333abcdefghij"));
+    test(S("abcdefghij"), 0, 1, 0, '3', S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 5, '3', S("33333bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 10, '3', S("3333333333bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 20, '3', S("33333333333333333333bcdefghij"));
+    test(S("abcdefghij"), 0, 5, 0, '3', S("fghij"));
+    test(S("abcdefghij"), 0, 5, 5, '3', S("33333fghij"));
+    test(S("abcdefghij"), 0, 5, 10, '3', S("3333333333fghij"));
+    test(S("abcdefghij"), 0, 5, 20, '3', S("33333333333333333333fghij"));
+    test(S("abcdefghij"), 0, 9, 0, '3', S("j"));
+    test(S("abcdefghij"), 0, 9, 5, '3', S("33333j"));
+    test(S("abcdefghij"), 0, 9, 10, '3', S("3333333333j"));
+    test(S("abcdefghij"), 0, 9, 20, '3', S("33333333333333333333j"));
+    test(S("abcdefghij"), 0, 10, 0, '3', S(""));
+    test(S("abcdefghij"), 0, 10, 5, '3', S("33333"));
+    test(S("abcdefghij"), 0, 10, 10, '3', S("3333333333"));
+    test(S("abcdefghij"), 0, 10, 20, '3', S("33333333333333333333"));
+    test(S("abcdefghij"), 1, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, 5, '3', S("a33333bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 10, '3', S("a3333333333bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 20, '3', S("a33333333333333333333bcdefghij"));
+    test(S("abcdefghij"), 1, 1, 0, '3', S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, 5, '3', S("a33333cdefghij"));
+    test(S("abcdefghij"), 1, 1, 10, '3', S("a3333333333cdefghij"));
+    test(S("abcdefghij"), 1, 1, 20, '3', S("a33333333333333333333cdefghij"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcdefghij"), 1, 4, 0, '3', S("afghij"));
+    test(S("abcdefghij"), 1, 4, 5, '3', S("a33333fghij"));
+    test(S("abcdefghij"), 1, 4, 10, '3', S("a3333333333fghij"));
+    test(S("abcdefghij"), 1, 4, 20, '3', S("a33333333333333333333fghij"));
+    test(S("abcdefghij"), 1, 8, 0, '3', S("aj"));
+    test(S("abcdefghij"), 1, 8, 5, '3', S("a33333j"));
+    test(S("abcdefghij"), 1, 8, 10, '3', S("a3333333333j"));
+    test(S("abcdefghij"), 1, 8, 20, '3', S("a33333333333333333333j"));
+    test(S("abcdefghij"), 1, 9, 0, '3', S("a"));
+    test(S("abcdefghij"), 1, 9, 5, '3', S("a33333"));
+    test(S("abcdefghij"), 1, 9, 10, '3', S("a3333333333"));
+    test(S("abcdefghij"), 1, 9, 20, '3', S("a33333333333333333333"));
+    test(S("abcdefghij"), 5, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, 5, '3', S("abcde33333fghij"));
+    test(S("abcdefghij"), 5, 0, 10, '3', S("abcde3333333333fghij"));
+    test(S("abcdefghij"), 5, 0, 20, '3', S("abcde33333333333333333333fghij"));
+    test(S("abcdefghij"), 5, 1, 0, '3', S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, 5, '3', S("abcde33333ghij"));
+    test(S("abcdefghij"), 5, 1, 10, '3', S("abcde3333333333ghij"));
+    test(S("abcdefghij"), 5, 1, 20, '3', S("abcde33333333333333333333ghij"));
+    test(S("abcdefghij"), 5, 2, 0, '3', S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, 5, '3', S("abcde33333hij"));
+    test(S("abcdefghij"), 5, 2, 10, '3', S("abcde3333333333hij"));
+    test(S("abcdefghij"), 5, 2, 20, '3', S("abcde33333333333333333333hij"));
+    test(S("abcdefghij"), 5, 4, 0, '3', S("abcdej"));
+    test(S("abcdefghij"), 5, 4, 5, '3', S("abcde33333j"));
+    test(S("abcdefghij"), 5, 4, 10, '3', S("abcde3333333333j"));
+    test(S("abcdefghij"), 5, 4, 20, '3', S("abcde33333333333333333333j"));
+    test(S("abcdefghij"), 5, 5, 0, '3', S("abcde"));
+    test(S("abcdefghij"), 5, 5, 5, '3', S("abcde33333"));
+    test(S("abcdefghij"), 5, 5, 10, '3', S("abcde3333333333"));
+    test(S("abcdefghij"), 5, 5, 20, '3', S("abcde33333333333333333333"));
+    test(S("abcdefghij"), 9, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, 5, '3', S("abcdefghi33333j"));
+    test(S("abcdefghij"), 9, 0, 10, '3', S("abcdefghi3333333333j"));
+    test(S("abcdefghij"), 9, 0, 20, '3', S("abcdefghi33333333333333333333j"));
+    test(S("abcdefghij"), 9, 1, 0, '3', S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, 5, '3', S("abcdefghi33333"));
+    test(S("abcdefghij"), 9, 1, 10, '3', S("abcdefghi3333333333"));
+    test(S("abcdefghij"), 9, 1, 20, '3', S("abcdefghi33333333333333333333"));
+    test(S("abcdefghij"), 10, 0, 0, '3', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, 5, '3', S("abcdefghij33333"));
+    test(S("abcdefghij"), 10, 0, 10, '3', S("abcdefghij3333333333"));
+    test(S("abcdefghij"), 10, 0, 20, '3', S("abcdefghij33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 5, '3', S("33333abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 10, '3', S("3333333333abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 20, '3', S("33333333333333333333abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 0, '3', S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 5, '3', S("33333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 10, '3', S("3333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 20, '3', S("33333333333333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 0, '3', S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 5, '3', S("33333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 10, '3', S("3333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 20, '3', S("33333333333333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 0, '3', S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 5, '3', S("33333t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 10, '3', S("3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 20, '3', S("33333333333333333333t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 0, '3', S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 5, '3', S("33333"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 10, '3', S("3333333333"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 20, '3', S("33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 5, '3', S("a33333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 10, '3', S("a3333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 20, '3', S("a33333333333333333333bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 0, '3', S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 5, '3', S("a33333cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 10, '3', S("a3333333333cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 20, '3', S("a33333333333333333333cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 0, '3', S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 5, '3', S("a33333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 10, '3', S("a3333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 20, '3', S("a33333333333333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 0, '3', S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 5, '3', S("a33333t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 10, '3', S("a3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 20, '3', S("a33333333333333333333t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 0, '3', S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 5, '3', S("a33333"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 10, '3', S("a3333333333"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 20, '3', S("a33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 5, '3', S("abcdefghij33333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 10, '3', S("abcdefghij3333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 20, '3', S("abcdefghij33333333333333333333klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 0, '3', S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 5, '3', S("abcdefghij33333lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 10, '3', S("abcdefghij3333333333lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 20, '3', S("abcdefghij33333333333333333333lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 0, '3', S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 5, '3', S("abcdefghij33333pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 10, '3', S("abcdefghij3333333333pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 20, '3', S("abcdefghij33333333333333333333pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 0, '3', S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 5, '3', S("abcdefghij33333t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 10, '3', S("abcdefghij3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 20, '3', S("abcdefghij33333333333333333333t"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, 0, '3', S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 5, '3', S("abcdefghij33333"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 10, '3', S("abcdefghij3333333333"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 20, '3', S("abcdefghij33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 5, '3', S("abcdefghijklmnopqrs33333t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 10, '3', S("abcdefghijklmnopqrs3333333333t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 20, '3', S("abcdefghijklmnopqrs33333333333333333333t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 0, '3', S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 5, '3', S("abcdefghijklmnopqrs33333"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 10, '3', S("abcdefghijklmnopqrs3333333333"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 20, '3', S("abcdefghijklmnopqrs33333333333333333333"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 0, '3', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 5, '3', S("abcdefghijklmnopqrst33333"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 10, '3', S("abcdefghijklmnopqrst3333333333"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 20, '3', S("abcdefghijklmnopqrst33333333333333333333"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp
new file mode 100644
index 0000000..0f95492
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp
@@ -0,0 +1,285 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(const_iterator i1, const_iterator i2, const basic_string& str);
+
+#include <stdio.h>
+
+#include <string>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    typename S::const_iterator first = s.begin() + pos1;
+    typename S::const_iterator last = s.begin() + pos1 + n1;
+    typename S::size_type xlen = last - first;
+    s.replace(first, last, str);
+    assert(s.__invariants());
+    assert(s == expected);
+    typename S::size_type rlen = str.size();
+    assert(s.size() == old_size - xlen + rlen);
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, S(""), S(""));
+    test(S(""), 0, 0, S("12345"), S("12345"));
+    test(S(""), 0, 0, S("1234567890"), S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 0, 0, S(""), S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), S("12345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, S(""), S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), S("12345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, S(""), S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), S("12345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, S(""), S("e"));
+    test(S("abcde"), 0, 4, S("12345"), S("12345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, S(""), S(""));
+    test(S("abcde"), 0, 5, S("12345"), S("12345"));
+    test(S("abcde"), 0, 5, S("1234567890"), S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 1, 0, S(""), S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, S(""), S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), S("a12345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, S(""), S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), S("a12345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, S(""), S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), S("a12345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, S(""), S("a"));
+    test(S("abcde"), 1, 4, S("12345"), S("a12345"));
+    test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, S(""), S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, S(""), S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), S("ab12345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, S(""), S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), S("ab12345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, S(""), S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), S("ab12345"));
+    test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, S(""), S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, S(""), S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), S("abcd12345"));
+    test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, S(""), S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S(""), S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, S(""), S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, S(""), S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), S("12345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcdefghij"), 1, 4, S(""), S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, S(""), S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, S(""), S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, S(""), S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, S(""), S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, S(""), S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
new file mode 100644
index 0000000..914081b
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
@@ -0,0 +1,375 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(size_type pos, size_type n1, const charT* s);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n1,
+     const typename S::value_type* str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos, n1, str);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+        typename S::size_type xlen = std::min(n1, old_size - pos);
+        typename S::size_type rlen = S::traits_type::length(str);
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, "", S(""));
+    test(S(""), 0, 0, "12345", S("12345"));
+    test(S(""), 0, 0, "1234567890", S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", S("12345678901234567890"));
+    test(S(""), 0, 1, "", S(""));
+    test(S(""), 0, 1, "12345", S("12345"));
+    test(S(""), 0, 1, "1234567890", S("1234567890"));
+    test(S(""), 0, 1, "12345678901234567890", S("12345678901234567890"));
+    test(S(""), 1, 0, "", S("can't happen"));
+    test(S(""), 1, 0, "12345", S("can't happen"));
+    test(S(""), 1, 0, "1234567890", S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", S("can't happen"));
+    test(S("abcde"), 0, 0, "", S("abcde"));
+    test(S("abcde"), 0, 0, "12345", S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", S("bcde"));
+    test(S("abcde"), 0, 1, "12345", S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", S("cde"));
+    test(S("abcde"), 0, 2, "12345", S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", S("e"));
+    test(S("abcde"), 0, 4, "12345", S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", S(""));
+    test(S("abcde"), 0, 5, "12345", S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 0, 6, "", S(""));
+    test(S("abcde"), 0, 6, "12345", S("12345"));
+    test(S("abcde"), 0, 6, "1234567890", S("1234567890"));
+    test(S("abcde"), 0, 6, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", S("abcde"));
+    test(S("abcde"), 1, 0, "12345", S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", S("acde"));
+    test(S("abcde"), 1, 1, "12345", S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", S("ade"));
+    test(S("abcde"), 1, 2, "12345", S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", S("ae"));
+    test(S("abcde"), 1, 3, "12345", S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", S("a"));
+    test(S("abcde"), 1, 4, "12345", S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, "", S("a"));
+    test(S("abcde"), 1, 5, "12345", S("a12345"));
+    test(S("abcde"), 1, 5, "1234567890", S("a1234567890"));
+    test(S("abcde"), 1, 5, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", S("abcde"));
+    test(S("abcde"), 2, 0, "12345", S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", S("abde"));
+    test(S("abcde"), 2, 1, "12345", S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", S("abe"));
+    test(S("abcde"), 2, 2, "12345", S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", S("ab"));
+    test(S("abcde"), 2, 3, "12345", S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, "", S("ab"));
+    test(S("abcde"), 2, 4, "12345", S("ab12345"));
+    test(S("abcde"), 2, 4, "1234567890", S("ab1234567890"));
+    test(S("abcde"), 2, 4, "12345678901234567890", S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", S("abcde"));
+    test(S("abcde"), 4, 0, "12345", S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", S("abcd"));
+    test(S("abcde"), 4, 1, "12345", S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, "", S("abcd"));
+    test(S("abcde"), 4, 2, "12345", S("abcd12345"));
+    test(S("abcde"), 4, 2, "1234567890", S("abcd1234567890"));
+    test(S("abcde"), 4, 2, "12345678901234567890", S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", S("abcde"));
+    test(S("abcde"), 5, 0, "12345", S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, "", S("abcde"));
+    test(S("abcde"), 5, 1, "12345", S("abcde12345"));
+    test(S("abcde"), 5, 1, "1234567890", S("abcde1234567890"));
+    test(S("abcde"), 5, 1, "12345678901234567890", S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 6, 0, "", S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", S("can't happen"));
+    test(S("abcdefghij"), 0, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", S(""));
+    test(S("abcdefghij"), 0, 10, "12345", S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, "", S(""));
+    test(S("abcdefghij"), 0, 11, "12345", S("12345"));
+    test(S("abcdefghij"), 0, 11, "1234567890", S("1234567890"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 4, "", S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, "", S("a"));
+    test(S("abcdefghij"), 1, 10, "12345", S("a12345"));
+    test(S("abcdefghij"), 1, 10, "1234567890", S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, "", S("abcde"));
+    test(S("abcdefghij"), 5, 6, "12345", S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, "1234567890", S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, "", S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345", S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, "1234567890", S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, "", S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345", S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, 0, "", S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", S("can't happen"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
new file mode 100644
index 0000000..d987042
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
@@ -0,0 +1,1327 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(size_type pos, size_type n1, const charT* s, size_type n2);
+
+#include <stdio.h>
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n1,
+     const typename S::value_type* str, typename S::size_type n2,
+     S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos, n1, str, n2);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+        typename S::size_type xlen = std::min(n1, old_size - pos);
+        typename S::size_type rlen = n2;
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, "", 0, S(""));
+    test(S(""), 0, 0, "12345", 0, S(""));
+    test(S(""), 0, 0, "12345", 1, S("1"));
+    test(S(""), 0, 0, "12345", 2, S("12"));
+    test(S(""), 0, 0, "12345", 4, S("1234"));
+    test(S(""), 0, 0, "12345", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 0, S(""));
+    test(S(""), 0, 0, "1234567890", 1, S("1"));
+    test(S(""), 0, 0, "1234567890", 5, S("12345"));
+    test(S(""), 0, 0, "1234567890", 9, S("123456789"));
+    test(S(""), 0, 0, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 0, S(""));
+    test(S(""), 0, 0, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, 0, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, 0, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, 0, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S(""), 0, 1, "", 0, S(""));
+    test(S(""), 0, 1, "12345", 0, S(""));
+    test(S(""), 0, 1, "12345", 1, S("1"));
+    test(S(""), 0, 1, "12345", 2, S("12"));
+    test(S(""), 0, 1, "12345", 4, S("1234"));
+    test(S(""), 0, 1, "12345", 5, S("12345"));
+    test(S(""), 0, 1, "1234567890", 0, S(""));
+    test(S(""), 0, 1, "1234567890", 1, S("1"));
+    test(S(""), 0, 1, "1234567890", 5, S("12345"));
+    test(S(""), 0, 1, "1234567890", 9, S("123456789"));
+    test(S(""), 0, 1, "1234567890", 10, S("1234567890"));
+    test(S(""), 0, 1, "12345678901234567890", 0, S(""));
+    test(S(""), 0, 1, "12345678901234567890", 1, S("1"));
+    test(S(""), 0, 1, "12345678901234567890", 10, S("1234567890"));
+    test(S(""), 0, 1, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S(""), 0, 1, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S(""), 1, 0, "", 0, S("can't happen"));
+    test(S(""), 1, 0, "12345", 0, S("can't happen"));
+    test(S(""), 1, 0, "12345", 1, S("can't happen"));
+    test(S(""), 1, 0, "12345", 2, S("can't happen"));
+    test(S(""), 1, 0, "12345", 4, S("can't happen"));
+    test(S(""), 1, 0, "12345", 5, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 0, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 1, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 5, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 9, S("can't happen"));
+    test(S(""), 1, 0, "1234567890", 10, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S(""), 1, 0, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcde"), 0, 0, "", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345", 2, S("12abcde"));
+    test(S("abcde"), 0, 0, "12345", 4, S("1234abcde"));
+    test(S("abcde"), 0, 0, "12345", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, "1234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 1, S("1abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, "", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345", 2, S("12bcde"));
+    test(S("abcde"), 0, 1, "12345", 4, S("1234bcde"));
+    test(S("abcde"), 0, 1, "12345", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, "1234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 0, S("bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 1, S("1bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, "", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345", 2, S("12cde"));
+    test(S("abcde"), 0, 2, "12345", 4, S("1234cde"));
+    test(S("abcde"), 0, 2, "12345", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "1234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "1234567890", 5, S("12345cde"));
+    test(S("abcde"), 0, 2, "1234567890", 9, S("123456789cde"));
+    test(S("abcde"), 0, 2, "1234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 0, S("cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 1, S("1cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, "12345678901234567890", 20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, "", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345", 2, S("12e"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 0, 4, "12345", 4, S("1234e"));
+    test(S("abcde"), 0, 4, "12345", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "1234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "1234567890", 5, S("12345e"));
+    test(S("abcde"), 0, 4, "1234567890", 9, S("123456789e"));
+    test(S("abcde"), 0, 4, "1234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 0, S("e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 1, S("1e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 19, S("1234567890123456789e"));
+    test(S("abcde"), 0, 4, "12345678901234567890", 20, S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, "", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 0, S(""));
+    test(S("abcde"), 0, 5, "12345", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345", 2, S("12"));
+    test(S("abcde"), 0, 5, "12345", 4, S("1234"));
+    test(S("abcde"), 0, 5, "12345", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "1234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "1234567890", 5, S("12345"));
+    test(S("abcde"), 0, 5, "1234567890", 9, S("123456789"));
+    test(S("abcde"), 0, 5, "1234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 0, S(""));
+    test(S("abcde"), 0, 5, "12345678901234567890", 1, S("1"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 5, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 6, "", 0, S(""));
+    test(S("abcde"), 0, 6, "12345", 0, S(""));
+    test(S("abcde"), 0, 6, "12345", 1, S("1"));
+    test(S("abcde"), 0, 6, "12345", 2, S("12"));
+    test(S("abcde"), 0, 6, "12345", 4, S("1234"));
+    test(S("abcde"), 0, 6, "12345", 5, S("12345"));
+    test(S("abcde"), 0, 6, "1234567890", 0, S(""));
+    test(S("abcde"), 0, 6, "1234567890", 1, S("1"));
+    test(S("abcde"), 0, 6, "1234567890", 5, S("12345"));
+    test(S("abcde"), 0, 6, "1234567890", 9, S("123456789"));
+    test(S("abcde"), 0, 6, "1234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 0, S(""));
+    test(S("abcde"), 0, 6, "12345678901234567890", 1, S("1"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 6, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcde"), 1, 0, "", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345", 2, S("a12bcde"));
+    test(S("abcde"), 1, 0, "12345", 4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, "12345", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "1234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, "1234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, "", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345", 2, S("a12cde"));
+    test(S("abcde"), 1, 1, "12345", 4, S("a1234cde"));
+    test(S("abcde"), 1, 1, "12345", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "1234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "1234567890", 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, "1234567890", 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, "1234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 0, S("acde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 1, S("a1cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, "", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345", 2, S("a12de"));
+    test(S("abcde"), 1, 2, "12345", 4, S("a1234de"));
+    test(S("abcde"), 1, 2, "12345", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "1234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "1234567890", 5, S("a12345de"));
+    test(S("abcde"), 1, 2, "1234567890", 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, "1234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 0, S("ade"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 1, S("a1de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, "12345678901234567890", 20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, "", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345", 2, S("a12e"));
+    test(S("abcde"), 1, 3, "12345", 4, S("a1234e"));
+    test(S("abcde"), 1, 3, "12345", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "1234567890", 1, S("a1e"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcde"), 1, 3, "1234567890", 5, S("a12345e"));
+    test(S("abcde"), 1, 3, "1234567890", 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, "1234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 0, S("ae"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 1, S("a1e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, "12345678901234567890", 20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, "", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345", 2, S("a12"));
+    test(S("abcde"), 1, 4, "12345", 4, S("a1234"));
+    test(S("abcde"), 1, 4, "12345", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "1234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "1234567890", 5, S("a12345"));
+    test(S("abcde"), 1, 4, "1234567890", 9, S("a123456789"));
+    test(S("abcde"), 1, 4, "1234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 0, S("a"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 1, S("a1"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, "", 0, S("a"));
+    test(S("abcde"), 1, 5, "12345", 0, S("a"));
+    test(S("abcde"), 1, 5, "12345", 1, S("a1"));
+    test(S("abcde"), 1, 5, "12345", 2, S("a12"));
+    test(S("abcde"), 1, 5, "12345", 4, S("a1234"));
+    test(S("abcde"), 1, 5, "12345", 5, S("a12345"));
+    test(S("abcde"), 1, 5, "1234567890", 0, S("a"));
+    test(S("abcde"), 1, 5, "1234567890", 1, S("a1"));
+    test(S("abcde"), 1, 5, "1234567890", 5, S("a12345"));
+    test(S("abcde"), 1, 5, "1234567890", 9, S("a123456789"));
+    test(S("abcde"), 1, 5, "1234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 0, S("a"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 1, S("a1"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 5, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, "", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345", 2, S("ab12cde"));
+    test(S("abcde"), 2, 0, "12345", 4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, "12345", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "1234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "1234567890", 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, "1234567890", 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, "1234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, "12345678901234567890", 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, "", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345", 2, S("ab12de"));
+    test(S("abcde"), 2, 1, "12345", 4, S("ab1234de"));
+    test(S("abcde"), 2, 1, "12345", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "1234567890", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "1234567890", 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, "1234567890", 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, "1234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 0, S("abde"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 1, S("ab1de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, "12345678901234567890", 20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, "", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345", 2, S("ab12e"));
+    test(S("abcde"), 2, 2, "12345", 4, S("ab1234e"));
+    test(S("abcde"), 2, 2, "12345", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "1234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "1234567890", 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, "1234567890", 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, "1234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 0, S("abe"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 1, S("ab1e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, "12345678901234567890", 20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, "", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 0, S("ab"));
+    test(S("abcde"), 2, 3, "12345", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345", 2, S("ab12"));
+    test(S("abcde"), 2, 3, "12345", 4, S("ab1234"));
+    test(S("abcde"), 2, 3, "12345", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 0, S("ab"));
+    test(S("abcde"), 2, 3, "1234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "1234567890", 5, S("ab12345"));
+    test(S("abcde"), 2, 3, "1234567890", 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, "1234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 0, S("ab"));
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcde"), 2, 3, "12345678901234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, "12345678901234567890", 20, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, "", 0, S("ab"));
+    test(S("abcde"), 2, 4, "12345", 0, S("ab"));
+    test(S("abcde"), 2, 4, "12345", 1, S("ab1"));
+    test(S("abcde"), 2, 4, "12345", 2, S("ab12"));
+    test(S("abcde"), 2, 4, "12345", 4, S("ab1234"));
+    test(S("abcde"), 2, 4, "12345", 5, S("ab12345"));
+    test(S("abcde"), 2, 4, "1234567890", 0, S("ab"));
+    test(S("abcde"), 2, 4, "1234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 4, "1234567890", 5, S("ab12345"));
+    test(S("abcde"), 2, 4, "1234567890", 9, S("ab123456789"));
+    test(S("abcde"), 2, 4, "1234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 0, S("ab"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 1, S("ab1"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 4, "12345678901234567890", 20, S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, "", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345", 2, S("abcd12e"));
+    test(S("abcde"), 4, 0, "12345", 4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, "12345", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "1234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "1234567890", 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, "1234567890", 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, "1234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, "12345678901234567890", 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, "", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345", 2, S("abcd12"));
+    test(S("abcde"), 4, 1, "12345", 4, S("abcd1234"));
+    test(S("abcde"), 4, 1, "12345", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "1234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "1234567890", 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, "1234567890", 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, "1234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, "12345678901234567890", 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, "", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "12345", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "12345", 1, S("abcd1"));
+    test(S("abcde"), 4, 2, "12345", 2, S("abcd12"));
+    test(S("abcde"), 4, 2, "12345", 4, S("abcd1234"));
+    test(S("abcde"), 4, 2, "12345", 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, "1234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "1234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 2, "1234567890", 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, "1234567890", 9, S("abcd123456789"));
+    test(S("abcde"), 4, 2, "1234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 0, S("abcd"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 1, S("abcd1"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 2, "12345678901234567890", 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, "", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, 0, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, 0, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, "", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "12345", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "12345", 1, S("abcde1"));
+    test(S("abcde"), 5, 1, "12345", 2, S("abcde12"));
+    test(S("abcde"), 5, 1, "12345", 4, S("abcde1234"));
+    test(S("abcde"), 5, 1, "12345", 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, "1234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "1234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 1, "1234567890", 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, "1234567890", 9, S("abcde123456789"));
+    test(S("abcde"), 5, 1, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 0, S("abcde"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test4()
+{
+    test(S("abcde"), 6, 0, "", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 1, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 2, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 4, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345", 5, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 5, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 9, S("can't happen"));
+    test(S("abcde"), 6, 0, "1234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcde"), 6, 0, "12345678901234567890", 20, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "1234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, "", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "1234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, "", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, "12345", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "1234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, "12345678901234567890", 20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, "", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345", 2, S("12j"));
+    test(S("abcdefghij"), 0, 9, "12345", 4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, "12345", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, "1234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 0, S("j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 19, S("1234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, "12345678901234567890", 20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, "", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345", 2, S("12"));
+    test(S("abcdefghij"), 0, 10, "12345", 4, S("1234"));
+    test(S("abcdefghij"), 0, 10, "12345", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "1234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, "", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "12345", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "12345", 1, S("1"));
+    test(S("abcdefghij"), 0, 11, "12345", 2, S("12"));
+}
+
+template <class S>
+void test5()
+{
+    test(S("abcdefghij"), 0, 11, "12345", 4, S("1234"));
+    test(S("abcdefghij"), 0, 11, "12345", 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "1234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 9, S("123456789"));
+    test(S("abcdefghij"), 0, 11, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 0, S(""));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 11, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "1234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, "", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "1234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 4, "", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, "12345", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "1234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, "12345678901234567890", 20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, "", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345", 2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, "12345", 4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, "12345", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, "1234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, "12345678901234567890", 20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, "", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345", 2, S("a12"));
+    test(S("abcdefghij"), 1, 9, "12345", 4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, "12345", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, "", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "12345", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "12345", 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, "12345", 2, S("a12"));
+    test(S("abcdefghij"), 1, 10, "12345", 4, S("a1234"));
+    test(S("abcdefghij"), 1, 10, "12345", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 1, S("a1"));
+}
+
+template <class S>
+void test6()
+{
+    test(S("abcdefghij"), 1, 10, "1234567890", 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 10, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 10, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, "12345", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "1234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, "12345678901234567890", 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, "", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, "12345", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "1234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, "12345678901234567890", 20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, "", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, "12345", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, "1234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, "12345678901234567890", 20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, "", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345", 2, S("abcde12j"));
+    test(S("abcdefghij"), 5, 4, "12345", 4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, "12345", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, "1234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, "12345678901234567890", 20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, "", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345", 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, "12345", 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, "12345", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, "", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, "12345", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, "12345", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, "12345", 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 6, "12345", 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 6, "12345", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 6, "1234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 0, S("abcde"));
+}
+
+template <class S>
+void test7()
+{
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 6, "12345678901234567890", 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345", 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, "12345", 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, "12345", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, "1234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, "12345678901234567890", 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, "", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345", 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, "12345", 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, "12345", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, "1234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, "", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, "12345", 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 2, "12345", 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 2, "12345", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 2, "1234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 2, "12345678901234567890", 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, "", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 1, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 1, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 1, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, 0, "", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, "12345678901234567890", 20, S("can't happen"));
+}
+
+template <class S>
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "1234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, "12345678901234567890", 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "1234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, "12345678901234567890", 20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "1234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, "12345678901234567890", 20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "1234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, "12345678901234567890", 20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "1234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, "12345678901234567890", 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 2, S("a12bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test9()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "1234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, "12345678901234567890", 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "1234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, "12345678901234567890", 20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "1234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, "12345678901234567890", 20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "1234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, "12345678901234567890", 20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "1234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, "12345678901234567890", 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 1, S("abcdefghij1klmnopqrst"));
+}
+
+template <class S>
+void test10()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "1234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, "12345678901234567890", 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "1234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, "12345678901234567890", 20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "1234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, "12345678901234567890", 20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "1234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, "12345678901234567890", 20, S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "1234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, "12345678901234567890", 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "1234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test11()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "1234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, "12345678901234567890", 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "1234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, "12345678901234567890", 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "1234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, "12345678901234567890", 20, S("can't happen"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
new file mode 100644
index 0000000..33f57fd
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
@@ -0,0 +1,374 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(size_type pos, size_type n1, size_type n2, charT c);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos, typename S::size_type n1,
+     typename S::size_type n2, typename S::value_type c,
+     S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos, n1, n2, c);
+        assert(s.__invariants());
+        assert(pos <= old_size);
+        assert(s == expected);
+        typename S::size_type xlen = std::min(n1, old_size - pos);
+        typename S::size_type rlen = n2;
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, 0, '2', S(""));
+    test(S(""), 0, 0, 5, '2', S("22222"));
+    test(S(""), 0, 0, 10, '2', S("2222222222"));
+    test(S(""), 0, 0, 20, '2', S("22222222222222222222"));
+    test(S(""), 0, 1, 0, '2', S(""));
+    test(S(""), 0, 1, 5, '2', S("22222"));
+    test(S(""), 0, 1, 10, '2', S("2222222222"));
+    test(S(""), 0, 1, 20, '2', S("22222222222222222222"));
+    test(S(""), 1, 0, 0, '2', S("can't happen"));
+    test(S(""), 1, 0, 5, '2', S("can't happen"));
+    test(S(""), 1, 0, 10, '2', S("can't happen"));
+    test(S(""), 1, 0, 20, '2', S("can't happen"));
+    test(S("abcde"), 0, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 0, 0, 5, '2', S("22222abcde"));
+    test(S("abcde"), 0, 0, 10, '2', S("2222222222abcde"));
+    test(S("abcde"), 0, 0, 20, '2', S("22222222222222222222abcde"));
+    test(S("abcde"), 0, 1, 0, '2', S("bcde"));
+    test(S("abcde"), 0, 1, 5, '2', S("22222bcde"));
+    test(S("abcde"), 0, 1, 10, '2', S("2222222222bcde"));
+    test(S("abcde"), 0, 1, 20, '2', S("22222222222222222222bcde"));
+    test(S("abcde"), 0, 2, 0, '2', S("cde"));
+    test(S("abcde"), 0, 2, 5, '2', S("22222cde"));
+    test(S("abcde"), 0, 2, 10, '2', S("2222222222cde"));
+    test(S("abcde"), 0, 2, 20, '2', S("22222222222222222222cde"));
+    test(S("abcde"), 0, 4, 0, '2', S("e"));
+    test(S("abcde"), 0, 4, 5, '2', S("22222e"));
+    test(S("abcde"), 0, 4, 10, '2', S("2222222222e"));
+    test(S("abcde"), 0, 4, 20, '2', S("22222222222222222222e"));
+    test(S("abcde"), 0, 5, 0, '2', S(""));
+    test(S("abcde"), 0, 5, 5, '2', S("22222"));
+    test(S("abcde"), 0, 5, 10, '2', S("2222222222"));
+    test(S("abcde"), 0, 5, 20, '2', S("22222222222222222222"));
+    test(S("abcde"), 0, 6, 0, '2', S(""));
+    test(S("abcde"), 0, 6, 5, '2', S("22222"));
+    test(S("abcde"), 0, 6, 10, '2', S("2222222222"));
+    test(S("abcde"), 0, 6, 20, '2', S("22222222222222222222"));
+    test(S("abcde"), 1, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 1, 0, 5, '2', S("a22222bcde"));
+    test(S("abcde"), 1, 0, 10, '2', S("a2222222222bcde"));
+    test(S("abcde"), 1, 0, 20, '2', S("a22222222222222222222bcde"));
+    test(S("abcde"), 1, 1, 0, '2', S("acde"));
+    test(S("abcde"), 1, 1, 5, '2', S("a22222cde"));
+    test(S("abcde"), 1, 1, 10, '2', S("a2222222222cde"));
+    test(S("abcde"), 1, 1, 20, '2', S("a22222222222222222222cde"));
+    test(S("abcde"), 1, 2, 0, '2', S("ade"));
+    test(S("abcde"), 1, 2, 5, '2', S("a22222de"));
+    test(S("abcde"), 1, 2, 10, '2', S("a2222222222de"));
+    test(S("abcde"), 1, 2, 20, '2', S("a22222222222222222222de"));
+    test(S("abcde"), 1, 3, 0, '2', S("ae"));
+    test(S("abcde"), 1, 3, 5, '2', S("a22222e"));
+    test(S("abcde"), 1, 3, 10, '2', S("a2222222222e"));
+    test(S("abcde"), 1, 3, 20, '2', S("a22222222222222222222e"));
+    test(S("abcde"), 1, 4, 0, '2', S("a"));
+    test(S("abcde"), 1, 4, 5, '2', S("a22222"));
+    test(S("abcde"), 1, 4, 10, '2', S("a2222222222"));
+    test(S("abcde"), 1, 4, 20, '2', S("a22222222222222222222"));
+    test(S("abcde"), 1, 5, 0, '2', S("a"));
+    test(S("abcde"), 1, 5, 5, '2', S("a22222"));
+    test(S("abcde"), 1, 5, 10, '2', S("a2222222222"));
+    test(S("abcde"), 1, 5, 20, '2', S("a22222222222222222222"));
+    test(S("abcde"), 2, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 2, 0, 5, '2', S("ab22222cde"));
+    test(S("abcde"), 2, 0, 10, '2', S("ab2222222222cde"));
+    test(S("abcde"), 2, 0, 20, '2', S("ab22222222222222222222cde"));
+    test(S("abcde"), 2, 1, 0, '2', S("abde"));
+    test(S("abcde"), 2, 1, 5, '2', S("ab22222de"));
+    test(S("abcde"), 2, 1, 10, '2', S("ab2222222222de"));
+    test(S("abcde"), 2, 1, 20, '2', S("ab22222222222222222222de"));
+    test(S("abcde"), 2, 2, 0, '2', S("abe"));
+    test(S("abcde"), 2, 2, 5, '2', S("ab22222e"));
+    test(S("abcde"), 2, 2, 10, '2', S("ab2222222222e"));
+    test(S("abcde"), 2, 2, 20, '2', S("ab22222222222222222222e"));
+    test(S("abcde"), 2, 3, 0, '2', S("ab"));
+    test(S("abcde"), 2, 3, 5, '2', S("ab22222"));
+    test(S("abcde"), 2, 3, 10, '2', S("ab2222222222"));
+    test(S("abcde"), 2, 3, 20, '2', S("ab22222222222222222222"));
+    test(S("abcde"), 2, 4, 0, '2', S("ab"));
+    test(S("abcde"), 2, 4, 5, '2', S("ab22222"));
+    test(S("abcde"), 2, 4, 10, '2', S("ab2222222222"));
+    test(S("abcde"), 2, 4, 20, '2', S("ab22222222222222222222"));
+    test(S("abcde"), 4, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 4, 0, 5, '2', S("abcd22222e"));
+    test(S("abcde"), 4, 0, 10, '2', S("abcd2222222222e"));
+    test(S("abcde"), 4, 0, 20, '2', S("abcd22222222222222222222e"));
+    test(S("abcde"), 4, 1, 0, '2', S("abcd"));
+    test(S("abcde"), 4, 1, 5, '2', S("abcd22222"));
+    test(S("abcde"), 4, 1, 10, '2', S("abcd2222222222"));
+    test(S("abcde"), 4, 1, 20, '2', S("abcd22222222222222222222"));
+    test(S("abcde"), 4, 2, 0, '2', S("abcd"));
+    test(S("abcde"), 4, 2, 5, '2', S("abcd22222"));
+    test(S("abcde"), 4, 2, 10, '2', S("abcd2222222222"));
+    test(S("abcde"), 4, 2, 20, '2', S("abcd22222222222222222222"));
+    test(S("abcde"), 5, 0, 0, '2', S("abcde"));
+    test(S("abcde"), 5, 0, 5, '2', S("abcde22222"));
+    test(S("abcde"), 5, 0, 10, '2', S("abcde2222222222"));
+    test(S("abcde"), 5, 0, 20, '2', S("abcde22222222222222222222"));
+    test(S("abcde"), 5, 1, 0, '2', S("abcde"));
+    test(S("abcde"), 5, 1, 5, '2', S("abcde22222"));
+    test(S("abcde"), 5, 1, 10, '2', S("abcde2222222222"));
+    test(S("abcde"), 5, 1, 20, '2', S("abcde22222222222222222222"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 6, 0, 0, '2', S("can't happen"));
+    test(S("abcde"), 6, 0, 5, '2', S("can't happen"));
+    test(S("abcde"), 6, 0, 10, '2', S("can't happen"));
+    test(S("abcde"), 6, 0, 20, '2', S("can't happen"));
+    test(S("abcdefghij"), 0, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 5, '2', S("22222abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 10, '2', S("2222222222abcdefghij"));
+    test(S("abcdefghij"), 0, 0, 20, '2', S("22222222222222222222abcdefghij"));
+    test(S("abcdefghij"), 0, 1, 0, '2', S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 5, '2', S("22222bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 10, '2', S("2222222222bcdefghij"));
+    test(S("abcdefghij"), 0, 1, 20, '2', S("22222222222222222222bcdefghij"));
+    test(S("abcdefghij"), 0, 5, 0, '2', S("fghij"));
+    test(S("abcdefghij"), 0, 5, 5, '2', S("22222fghij"));
+    test(S("abcdefghij"), 0, 5, 10, '2', S("2222222222fghij"));
+    test(S("abcdefghij"), 0, 5, 20, '2', S("22222222222222222222fghij"));
+    test(S("abcdefghij"), 0, 9, 0, '2', S("j"));
+    test(S("abcdefghij"), 0, 9, 5, '2', S("22222j"));
+    test(S("abcdefghij"), 0, 9, 10, '2', S("2222222222j"));
+    test(S("abcdefghij"), 0, 9, 20, '2', S("22222222222222222222j"));
+    test(S("abcdefghij"), 0, 10, 0, '2', S(""));
+    test(S("abcdefghij"), 0, 10, 5, '2', S("22222"));
+    test(S("abcdefghij"), 0, 10, 10, '2', S("2222222222"));
+    test(S("abcdefghij"), 0, 10, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghij"), 0, 11, 0, '2', S(""));
+    test(S("abcdefghij"), 0, 11, 5, '2', S("22222"));
+    test(S("abcdefghij"), 0, 11, 10, '2', S("2222222222"));
+    test(S("abcdefghij"), 0, 11, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghij"), 1, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, 5, '2', S("a22222bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 10, '2', S("a2222222222bcdefghij"));
+    test(S("abcdefghij"), 1, 0, 20, '2', S("a22222222222222222222bcdefghij"));
+    test(S("abcdefghij"), 1, 1, 0, '2', S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, 5, '2', S("a22222cdefghij"));
+    test(S("abcdefghij"), 1, 1, 10, '2', S("a2222222222cdefghij"));
+    test(S("abcdefghij"), 1, 1, 20, '2', S("a22222222222222222222cdefghij"));
+    test(S("abcdefghij"), 1, 4, 0, '2', S("afghij"));
+    test(S("abcdefghij"), 1, 4, 5, '2', S("a22222fghij"));
+    test(S("abcdefghij"), 1, 4, 10, '2', S("a2222222222fghij"));
+    test(S("abcdefghij"), 1, 4, 20, '2', S("a22222222222222222222fghij"));
+    test(S("abcdefghij"), 1, 8, 0, '2', S("aj"));
+    test(S("abcdefghij"), 1, 8, 5, '2', S("a22222j"));
+    test(S("abcdefghij"), 1, 8, 10, '2', S("a2222222222j"));
+    test(S("abcdefghij"), 1, 8, 20, '2', S("a22222222222222222222j"));
+    test(S("abcdefghij"), 1, 9, 0, '2', S("a"));
+    test(S("abcdefghij"), 1, 9, 5, '2', S("a22222"));
+    test(S("abcdefghij"), 1, 9, 10, '2', S("a2222222222"));
+    test(S("abcdefghij"), 1, 9, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghij"), 1, 10, 0, '2', S("a"));
+    test(S("abcdefghij"), 1, 10, 5, '2', S("a22222"));
+    test(S("abcdefghij"), 1, 10, 10, '2', S("a2222222222"));
+    test(S("abcdefghij"), 1, 10, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghij"), 5, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, 5, '2', S("abcde22222fghij"));
+    test(S("abcdefghij"), 5, 0, 10, '2', S("abcde2222222222fghij"));
+    test(S("abcdefghij"), 5, 0, 20, '2', S("abcde22222222222222222222fghij"));
+    test(S("abcdefghij"), 5, 1, 0, '2', S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, 5, '2', S("abcde22222ghij"));
+    test(S("abcdefghij"), 5, 1, 10, '2', S("abcde2222222222ghij"));
+    test(S("abcdefghij"), 5, 1, 20, '2', S("abcde22222222222222222222ghij"));
+    test(S("abcdefghij"), 5, 2, 0, '2', S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, 5, '2', S("abcde22222hij"));
+    test(S("abcdefghij"), 5, 2, 10, '2', S("abcde2222222222hij"));
+    test(S("abcdefghij"), 5, 2, 20, '2', S("abcde22222222222222222222hij"));
+    test(S("abcdefghij"), 5, 4, 0, '2', S("abcdej"));
+    test(S("abcdefghij"), 5, 4, 5, '2', S("abcde22222j"));
+    test(S("abcdefghij"), 5, 4, 10, '2', S("abcde2222222222j"));
+    test(S("abcdefghij"), 5, 4, 20, '2', S("abcde22222222222222222222j"));
+    test(S("abcdefghij"), 5, 5, 0, '2', S("abcde"));
+    test(S("abcdefghij"), 5, 5, 5, '2', S("abcde22222"));
+    test(S("abcdefghij"), 5, 5, 10, '2', S("abcde2222222222"));
+    test(S("abcdefghij"), 5, 5, 20, '2', S("abcde22222222222222222222"));
+    test(S("abcdefghij"), 5, 6, 0, '2', S("abcde"));
+    test(S("abcdefghij"), 5, 6, 5, '2', S("abcde22222"));
+    test(S("abcdefghij"), 5, 6, 10, '2', S("abcde2222222222"));
+    test(S("abcdefghij"), 5, 6, 20, '2', S("abcde22222222222222222222"));
+    test(S("abcdefghij"), 9, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, 5, '2', S("abcdefghi22222j"));
+    test(S("abcdefghij"), 9, 0, 10, '2', S("abcdefghi2222222222j"));
+    test(S("abcdefghij"), 9, 0, 20, '2', S("abcdefghi22222222222222222222j"));
+    test(S("abcdefghij"), 9, 1, 0, '2', S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, 5, '2', S("abcdefghi22222"));
+    test(S("abcdefghij"), 9, 1, 10, '2', S("abcdefghi2222222222"));
+    test(S("abcdefghij"), 9, 1, 20, '2', S("abcdefghi22222222222222222222"));
+    test(S("abcdefghij"), 9, 2, 0, '2', S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, 5, '2', S("abcdefghi22222"));
+    test(S("abcdefghij"), 9, 2, 10, '2', S("abcdefghi2222222222"));
+    test(S("abcdefghij"), 9, 2, 20, '2', S("abcdefghi22222222222222222222"));
+    test(S("abcdefghij"), 10, 0, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghij"), 10, 0, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghij"), 10, 0, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghij"), 10, 1, 0, '2', S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghij"), 10, 1, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghij"), 10, 1, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghij"), 11, 0, 0, '2', S("can't happen"));
+    test(S("abcdefghij"), 11, 0, 5, '2', S("can't happen"));
+    test(S("abcdefghij"), 11, 0, 10, '2', S("can't happen"));
+    test(S("abcdefghij"), 11, 0, 20, '2', S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 5, '2', S("22222abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 10, '2', S("2222222222abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, 20, '2', S("22222222222222222222abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 0, '2', S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 5, '2', S("22222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 10, '2', S("2222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, 20, '2', S("22222222222222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 0, '2', S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 5, '2', S("22222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 10, '2', S("2222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, 20, '2', S("22222222222222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 0, '2', S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 5, '2', S("22222t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 10, '2', S("2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, 20, '2', S("22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 0, '2', S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 5, '2', S("22222"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 10, '2', S("2222222222"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 0, '2', S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 5, '2', S("22222"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 10, '2', S("2222222222"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, 20, '2', S("22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 5, '2', S("a22222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 10, '2', S("a2222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, 20, '2', S("a22222222222222222222bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 0, '2', S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 5, '2', S("a22222cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 10, '2', S("a2222222222cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, 20, '2', S("a22222222222222222222cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 0, '2', S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 5, '2', S("a22222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 10, '2', S("a2222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, 20, '2', S("a22222222222222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 0, '2', S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 5, '2', S("a22222t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 10, '2', S("a2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, 20, '2', S("a22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 0, '2', S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 5, '2', S("a22222"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 10, '2', S("a2222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 0, '2', S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 5, '2', S("a22222"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 10, '2', S("a2222222222"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, 20, '2', S("a22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 5, '2', S("abcdefghij22222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 10, '2', S("abcdefghij2222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, 20, '2', S("abcdefghij22222222222222222222klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 0, '2', S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 5, '2', S("abcdefghij22222lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 10, '2', S("abcdefghij2222222222lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, 20, '2', S("abcdefghij22222222222222222222lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 0, '2', S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 5, '2', S("abcdefghij22222pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 10, '2', S("abcdefghij2222222222pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, 20, '2', S("abcdefghij22222222222222222222pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 0, '2', S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 5, '2', S("abcdefghij22222t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 10, '2', S("abcdefghij2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, 20, '2', S("abcdefghij22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 0, '2', S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 0, '2', S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 5, '2', S("abcdefghij22222"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 10, '2', S("abcdefghij2222222222"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, 20, '2', S("abcdefghij22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 5, '2', S("abcdefghijklmnopqrs22222t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 10, '2', S("abcdefghijklmnopqrs2222222222t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, 20, '2', S("abcdefghijklmnopqrs22222222222222222222t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 0, '2', S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 5, '2', S("abcdefghijklmnopqrs22222"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 10, '2', S("abcdefghijklmnopqrs2222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, 20, '2', S("abcdefghijklmnopqrs22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 0, '2', S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 5, '2', S("abcdefghijklmnopqrs22222"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 10, '2', S("abcdefghijklmnopqrs2222222222"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, 20, '2', S("abcdefghijklmnopqrs22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 5, '2', S("abcdefghijklmnopqrst22222"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 10, '2', S("abcdefghijklmnopqrst2222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, 20, '2', S("abcdefghijklmnopqrst22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 0, '2', S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 5, '2', S("abcdefghijklmnopqrst22222"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 10, '2', S("abcdefghijklmnopqrst2222222222"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, 20, '2', S("abcdefghijklmnopqrst22222222222222222222"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 0, '2', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 5, '2', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 10, '2', S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, 20, '2', S("can't happen"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
new file mode 100644
index 0000000..c130780
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1, S str, S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos1, n1, str);
+        assert(s.__invariants());
+        assert(pos1 <= old_size);
+        assert(s == expected);
+        typename S::size_type xlen = std::min(n1, old_size - pos1);
+        typename S::size_type rlen = str.size();
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size);
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, S(""), S(""));
+    test(S(""), 0, 0, S("12345"), S("12345"));
+    test(S(""), 0, 0, S("1234567890"), S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), S("12345678901234567890"));
+    test(S(""), 0, 1, S(""), S(""));
+    test(S(""), 0, 1, S("12345"), S("12345"));
+    test(S(""), 0, 1, S("1234567890"), S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), S("12345678901234567890"));
+    test(S(""), 1, 0, S(""), S("can't happen"));
+    test(S(""), 1, 0, S("12345"), S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), S("can't happen"));
+    test(S("abcde"), 0, 0, S(""), S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), S("12345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 1, S(""), S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), S("12345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 2, S(""), S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), S("12345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), S("12345678901234567890cde"));
+    test(S("abcde"), 0, 4, S(""), S("e"));
+    test(S("abcde"), 0, 4, S("12345"), S("12345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), S("12345678901234567890e"));
+    test(S("abcde"), 0, 5, S(""), S(""));
+    test(S("abcde"), 0, 5, S("12345"), S("12345"));
+    test(S("abcde"), 0, 5, S("1234567890"), S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 0, 6, S(""), S(""));
+    test(S("abcde"), 0, 6, S("12345"), S("12345"));
+    test(S("abcde"), 0, 6, S("1234567890"), S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcde"), 1, 0, S(""), S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 1, S(""), S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), S("a12345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 2, S(""), S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), S("a12345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), S("a12345678901234567890de"));
+    test(S("abcde"), 1, 3, S(""), S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), S("a12345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), S("a12345678901234567890e"));
+    test(S("abcde"), 1, 4, S(""), S("a"));
+    test(S("abcde"), 1, 4, S("12345"), S("a12345"));
+    test(S("abcde"), 1, 4, S("1234567890"), S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, S(""), S("a"));
+    test(S("abcde"), 1, 5, S("12345"), S("a12345"));
+    test(S("abcde"), 1, 5, S("1234567890"), S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcde"), 2, 0, S(""), S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 1, S(""), S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), S("ab12345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 2, S(""), S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), S("ab12345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 3, S(""), S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), S("ab12345"));
+    test(S("abcde"), 2, 3, S("1234567890"), S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, S(""), S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), S("ab12345"));
+    test(S("abcde"), 2, 4, S("1234567890"), S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), S("ab12345678901234567890"));
+    test(S("abcde"), 4, 0, S(""), S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 1, S(""), S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), S("abcd12345"));
+    test(S("abcde"), 4, 1, S("1234567890"), S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, S(""), S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), S("abcd12345"));
+    test(S("abcde"), 4, 2, S("1234567890"), S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), S("abcd12345678901234567890"));
+    test(S("abcde"), 5, 0, S(""), S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, 0, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, S(""), S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), S("abcde12345"));
+    test(S("abcde"), 5, 1, S("1234567890"), S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890"));
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 6, 0, S(""), S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 1, S(""), S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 5, S(""), S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 9, S(""), S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 10, S(""), S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), S("12345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S(""), S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), S("12345"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghij"), 1, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 4, S(""), S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 8, S(""), S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 9, S(""), S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S(""), S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghij"), 5, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 1, S(""), S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 2, S(""), S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 4, S(""), S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 5, S(""), S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S(""), S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 9, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 1, S(""), S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S(""), S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S(""), S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 11, 0, S(""), S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), S("can't happen"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
new file mode 100644
index 0000000..ef0de89
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
@@ -0,0 +1,5966 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string<charT,traits,Allocator>&
+//   replace(size_type pos1, size_type n1, const basic_string<charT,traits,Allocator>& str,
+//           size_type pos2, size_type n2=npos);
+//  the "=npos" was added in C++14
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s, typename S::size_type pos1, typename S::size_type n1,
+     S str, typename S::size_type pos2, typename S::size_type n2,
+     S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos1, n1, str, pos2, n2);
+        assert(s.__invariants());
+        assert(pos1 <= old_size && pos2 <= str.size());
+        assert(s == expected);
+        typename S::size_type xlen = std::min(n1, old_size - pos1);
+        typename S::size_type rlen = std::min(n2, str.size() - pos2);
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size || pos2 > str.size());
+        assert(s == s0);
+    }
+}
+
+template <class S>
+void
+test_npos(S s, typename S::size_type pos1, typename S::size_type n1,
+     S str, typename S::size_type pos2,
+     S expected)
+{
+    typename S::size_type old_size = s.size();
+    S s0 = s;
+    try
+    {
+        s.replace(pos1, n1, str, pos2);
+        assert(s.__invariants());
+        assert(pos1 <= old_size && pos2 <= str.size());
+        assert(s == expected);
+        typename S::size_type xlen = std::min(n1, old_size - pos1);
+        typename S::size_type rlen = std::min(S::npos, str.size() - pos2);
+        assert(s.size() == old_size - xlen + rlen);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > old_size || pos2 > str.size());
+        assert(s == s0);
+    }
+}
+
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, S(""), 0, 0, S(""));
+    test(S(""), 0, 0, S(""), 0, 1, S(""));
+    test(S(""), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S(""), 0, 0, S("12345"), 0, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 0, 1, S("1"));
+    test(S(""), 0, 0, S("12345"), 0, 2, S("12"));
+    test(S(""), 0, 0, S("12345"), 0, 4, S("1234"));
+    test(S(""), 0, 0, S("12345"), 0, 5, S("12345"));
+    test(S(""), 0, 0, S("12345"), 0, 6, S("12345"));
+    test(S(""), 0, 0, S("12345"), 1, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 1, 1, S("2"));
+    test(S(""), 0, 0, S("12345"), 1, 2, S("23"));
+    test(S(""), 0, 0, S("12345"), 1, 3, S("234"));
+    test(S(""), 0, 0, S("12345"), 1, 4, S("2345"));
+    test(S(""), 0, 0, S("12345"), 1, 5, S("2345"));
+    test(S(""), 0, 0, S("12345"), 2, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 2, 1, S("3"));
+    test(S(""), 0, 0, S("12345"), 2, 2, S("34"));
+    test(S(""), 0, 0, S("12345"), 2, 3, S("345"));
+    test(S(""), 0, 0, S("12345"), 2, 4, S("345"));
+    test(S(""), 0, 0, S("12345"), 4, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 4, 1, S("5"));
+    test(S(""), 0, 0, S("12345"), 4, 2, S("5"));
+    test(S(""), 0, 0, S("12345"), 5, 0, S(""));
+    test(S(""), 0, 0, S("12345"), 5, 1, S(""));
+    test(S(""), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S(""), 0, 0, S("1234567890"), 0, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 0, 1, S("1"));
+    test(S(""), 0, 0, S("1234567890"), 0, 5, S("12345"));
+    test(S(""), 0, 0, S("1234567890"), 0, 9, S("123456789"));
+    test(S(""), 0, 0, S("1234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 0, S("1234567890"), 0, 11, S("1234567890"));
+    test(S(""), 0, 0, S("1234567890"), 1, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 1, 1, S("2"));
+    test(S(""), 0, 0, S("1234567890"), 1, 4, S("2345"));
+    test(S(""), 0, 0, S("1234567890"), 1, 8, S("23456789"));
+    test(S(""), 0, 0, S("1234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 0, S("1234567890"), 1, 10, S("234567890"));
+    test(S(""), 0, 0, S("1234567890"), 5, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 5, 1, S("6"));
+    test(S(""), 0, 0, S("1234567890"), 5, 2, S("67"));
+    test(S(""), 0, 0, S("1234567890"), 5, 4, S("6789"));
+    test(S(""), 0, 0, S("1234567890"), 5, 5, S("67890"));
+    test(S(""), 0, 0, S("1234567890"), 5, 6, S("67890"));
+    test(S(""), 0, 0, S("1234567890"), 9, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 9, 1, S("0"));
+    test(S(""), 0, 0, S("1234567890"), 9, 2, S("0"));
+    test(S(""), 0, 0, S("1234567890"), 10, 0, S(""));
+    test(S(""), 0, 0, S("1234567890"), 10, 1, S(""));
+    test(S(""), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 1, S("1"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 1, S("2"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 1, S("1"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S(""), 0, 0, S("12345678901234567890"), 19, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 19, 1, S("0"));
+    test(S(""), 0, 0, S("12345678901234567890"), 19, 2, S("0"));
+    test(S(""), 0, 0, S("12345678901234567890"), 20, 0, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 20, 1, S(""));
+    test(S(""), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S(""), 0, 1, S(""), 0, 0, S(""));
+    test(S(""), 0, 1, S(""), 0, 1, S(""));
+    test(S(""), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S(""), 0, 1, S("12345"), 0, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 0, 1, S("1"));
+    test(S(""), 0, 1, S("12345"), 0, 2, S("12"));
+    test(S(""), 0, 1, S("12345"), 0, 4, S("1234"));
+    test(S(""), 0, 1, S("12345"), 0, 5, S("12345"));
+    test(S(""), 0, 1, S("12345"), 0, 6, S("12345"));
+    test(S(""), 0, 1, S("12345"), 1, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 1, 1, S("2"));
+    test(S(""), 0, 1, S("12345"), 1, 2, S("23"));
+    test(S(""), 0, 1, S("12345"), 1, 3, S("234"));
+    test(S(""), 0, 1, S("12345"), 1, 4, S("2345"));
+    test(S(""), 0, 1, S("12345"), 1, 5, S("2345"));
+    test(S(""), 0, 1, S("12345"), 2, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 2, 1, S("3"));
+    test(S(""), 0, 1, S("12345"), 2, 2, S("34"));
+    test(S(""), 0, 1, S("12345"), 2, 3, S("345"));
+    test(S(""), 0, 1, S("12345"), 2, 4, S("345"));
+    test(S(""), 0, 1, S("12345"), 4, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 4, 1, S("5"));
+    test(S(""), 0, 1, S("12345"), 4, 2, S("5"));
+    test(S(""), 0, 1, S("12345"), 5, 0, S(""));
+    test(S(""), 0, 1, S("12345"), 5, 1, S(""));
+    test(S(""), 0, 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), 0, 1, S("1234567890"), 0, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 0, 1, S("1"));
+    test(S(""), 0, 1, S("1234567890"), 0, 5, S("12345"));
+    test(S(""), 0, 1, S("1234567890"), 0, 9, S("123456789"));
+    test(S(""), 0, 1, S("1234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 1, S("1234567890"), 0, 11, S("1234567890"));
+    test(S(""), 0, 1, S("1234567890"), 1, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 1, 1, S("2"));
+    test(S(""), 0, 1, S("1234567890"), 1, 4, S("2345"));
+    test(S(""), 0, 1, S("1234567890"), 1, 8, S("23456789"));
+    test(S(""), 0, 1, S("1234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 1, S("1234567890"), 1, 10, S("234567890"));
+    test(S(""), 0, 1, S("1234567890"), 5, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 5, 1, S("6"));
+    test(S(""), 0, 1, S("1234567890"), 5, 2, S("67"));
+    test(S(""), 0, 1, S("1234567890"), 5, 4, S("6789"));
+    test(S(""), 0, 1, S("1234567890"), 5, 5, S("67890"));
+    test(S(""), 0, 1, S("1234567890"), 5, 6, S("67890"));
+    test(S(""), 0, 1, S("1234567890"), 9, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 9, 1, S("0"));
+    test(S(""), 0, 1, S("1234567890"), 9, 2, S("0"));
+    test(S(""), 0, 1, S("1234567890"), 10, 0, S(""));
+    test(S(""), 0, 1, S("1234567890"), 10, 1, S(""));
+    test(S(""), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 1, S("1"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 1, S("2"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 1, S("1"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S(""), 0, 1, S("12345678901234567890"), 19, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 19, 1, S("0"));
+    test(S(""), 0, 1, S("12345678901234567890"), 19, 2, S("0"));
+    test(S(""), 0, 1, S("12345678901234567890"), 20, 0, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 20, 1, S(""));
+    test(S(""), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S(""), 1, 0, S(""), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S(""), 0, 1, S("can't happen"));
+    test(S(""), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+}
+
+template <class S>
+void test2()
+{
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S(""), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 2, S("12abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 4, S("1234abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 0, 6, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 2, S("23abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 3, S("234abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 1, 5, S("2345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 1, S("3abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 2, S("34abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 3, S("345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 2, 4, S("345abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 4, 1, S("5abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 4, 2, S("5abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 4, S("2345abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 8, S("23456789abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 1, 10, S("234567890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 1, S("6abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 2, S("67abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 4, S("6789abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 5, S("67890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 5, 6, S("67890abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 9, 1, S("0abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 9, 2, S("0abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S(""), 0, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S(""), 0, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 0, S("bcde"));
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcde"), 0, 1, S("12345"), 0, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 2, S("12bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 4, S("1234bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 0, 6, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 1, S("2bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 2, S("23bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 3, S("234bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 4, S("2345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 1, 5, S("2345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 1, S("3bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 2, S("34bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 3, S("345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 2, 4, S("345bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 4, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 4, 1, S("5bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 4, 2, S("5bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 5, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 5, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 1, S("2bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 4, S("2345bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 8, S("23456789bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 9, S("234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 1, 10, S("234567890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 1, S("6bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 2, S("67bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 4, S("6789bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 5, S("67890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 5, 6, S("67890bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 9, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 9, 1, S("0bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 9, 2, S("0bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 10, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 10, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 0, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 20, 1, S("bcde"));
+    test(S("abcde"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S(""), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S(""), 0, 1, S("cde"));
+    test(S("abcde"), 0, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 2, S("12cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 4, S("1234cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 5, S("12345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 0, 6, S("12345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 1, S("2cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 2, S("23cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 3, S("234cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 4, S("2345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 1, 5, S("2345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 1, S("3cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 2, S("34cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 3, S("345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 2, 4, S("345cde"));
+    test(S("abcde"), 0, 2, S("12345"), 4, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 4, 1, S("5cde"));
+    test(S("abcde"), 0, 2, S("12345"), 4, 2, S("5cde"));
+    test(S("abcde"), 0, 2, S("12345"), 5, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 5, 1, S("cde"));
+    test(S("abcde"), 0, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 5, S("12345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 9, S("123456789cde"));
+}
+
+template <class S>
+void test4()
+{
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 0, 11, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 1, S("2cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 4, S("2345cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 8, S("23456789cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 9, S("234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 1, 10, S("234567890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 1, S("6cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 2, S("67cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 4, S("6789cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 5, S("67890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 5, 6, S("67890cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 9, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 9, 1, S("0cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 9, 2, S("0cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 10, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 10, 1, S("cde"));
+    test(S("abcde"), 0, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 19, S("1234567890123456789cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 20, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 0, 21, S("12345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 1, S("2cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 9, S("234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 18, S("234567890123456789cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 19, S("2345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 1, 20, S("2345678901234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 1, S("1cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 5, S("12345cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 9, S("123456789cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 10, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 10, 11, S("1234567890cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 1, S("0cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 19, 2, S("0cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 0, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 20, 1, S("cde"));
+    test(S("abcde"), 0, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S(""), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S(""), 0, 1, S("e"));
+    test(S("abcde"), 0, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 2, S("12e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 4, S("1234e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 5, S("12345e"));
+    test(S("abcde"), 0, 4, S("12345"), 0, 6, S("12345e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 1, S("2e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 2, S("23e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 3, S("234e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 4, S("2345e"));
+    test(S("abcde"), 0, 4, S("12345"), 1, 5, S("2345e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 1, S("3e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 2, S("34e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 3, S("345e"));
+    test(S("abcde"), 0, 4, S("12345"), 2, 4, S("345e"));
+    test(S("abcde"), 0, 4, S("12345"), 4, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 4, 1, S("5e"));
+    test(S("abcde"), 0, 4, S("12345"), 4, 2, S("5e"));
+    test(S("abcde"), 0, 4, S("12345"), 5, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 5, 1, S("e"));
+    test(S("abcde"), 0, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 5, S("12345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 9, S("123456789e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 0, 11, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 1, S("2e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 4, S("2345e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 8, S("23456789e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 9, S("234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 1, 10, S("234567890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 1, S("6e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 2, S("67e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 4, S("6789e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 5, S("67890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 5, 6, S("67890e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 9, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 9, 1, S("0e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 9, 2, S("0e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 10, 0, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 10, 1, S("e"));
+    test(S("abcde"), 0, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 19, S("1234567890123456789e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 20, S("12345678901234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 0, 21, S("12345678901234567890e"));
+}
+
+template <class S>
+void test5()
+{
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 1, S("2e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 9, S("234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 18, S("234567890123456789e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 19, S("2345678901234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 1, 20, S("2345678901234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 1, S("1e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 5, S("12345e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 9, S("123456789e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 10, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 10, 11, S("1234567890e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 1, S("0e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 19, 2, S("0e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 0, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 20, 1, S("e"));
+    test(S("abcde"), 0, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S(""), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S(""), 0, 1, S(""));
+    test(S("abcde"), 0, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 0, 1, S("1"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 2, S("12"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 4, S("1234"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 5, S("12345"));
+    test(S("abcde"), 0, 5, S("12345"), 0, 6, S("12345"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 1, 1, S("2"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 2, S("23"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 3, S("234"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 5, S("12345"), 1, 5, S("2345"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 2, 1, S("3"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 2, S("34"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 3, S("345"));
+    test(S("abcde"), 0, 5, S("12345"), 2, 4, S("345"));
+    test(S("abcde"), 0, 5, S("12345"), 4, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 4, 1, S("5"));
+    test(S("abcde"), 0, 5, S("12345"), 4, 2, S("5"));
+    test(S("abcde"), 0, 5, S("12345"), 5, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 5, 1, S(""));
+    test(S("abcde"), 0, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 1, S("6"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 2, S("67"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcde"), 0, 5, S("1234567890"), 9, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 9, 1, S("0"));
+    test(S("abcde"), 0, 5, S("1234567890"), 9, 2, S("0"));
+    test(S("abcde"), 0, 5, S("1234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 10, 1, S(""));
+    test(S("abcde"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcde"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S(""), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S(""), 0, 1, S(""));
+    test(S("abcde"), 0, 6, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 0, 1, S("1"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 2, S("12"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 4, S("1234"));
+    test(S("abcde"), 0, 6, S("12345"), 0, 5, S("12345"));
+}
+
+template <class S>
+void test6()
+{
+    test(S("abcde"), 0, 6, S("12345"), 0, 6, S("12345"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 1, 1, S("2"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 2, S("23"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 3, S("234"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 6, S("12345"), 1, 5, S("2345"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 2, 1, S("3"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 2, S("34"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 3, S("345"));
+    test(S("abcde"), 0, 6, S("12345"), 2, 4, S("345"));
+    test(S("abcde"), 0, 6, S("12345"), 4, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 4, 1, S("5"));
+    test(S("abcde"), 0, 6, S("12345"), 4, 2, S("5"));
+    test(S("abcde"), 0, 6, S("12345"), 5, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 5, 1, S(""));
+    test(S("abcde"), 0, 6, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 1, S("6"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 2, S("67"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcde"), 0, 6, S("1234567890"), 9, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 9, 1, S("0"));
+    test(S("abcde"), 0, 6, S("1234567890"), 9, 2, S("0"));
+    test(S("abcde"), 0, 6, S("1234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 10, 1, S(""));
+    test(S("abcde"), 0, 6, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcde"), 0, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 2, S("a12bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 4, S("a1234bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 0, 6, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 2, S("a23bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 3, S("a234bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 1, 5, S("a2345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 1, S("a3bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 2, S("a34bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 3, S("a345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 2, 4, S("a345bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 4, 1, S("a5bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 4, 2, S("a5bcde"));
+    test(S("abcde"), 1, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 1, S("a2bcde"));
+}
+
+template <class S>
+void test7()
+{
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 4, S("a2345bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 1, S("a6bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 2, S("a67bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 4, S("a6789bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 5, S("a67890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 5, 6, S("a67890bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 9, 1, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 9, 2, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S(""), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S(""), 0, 1, S("acde"));
+    test(S("abcde"), 1, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 2, S("a12cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 4, S("a1234cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 0, 6, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 1, S("a2cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 2, S("a23cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 3, S("a234cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 4, S("a2345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 1, 5, S("a2345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 1, S("a3cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 2, S("a34cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 3, S("a345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 2, 4, S("a345cde"));
+    test(S("abcde"), 1, 1, S("12345"), 4, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 4, 1, S("a5cde"));
+    test(S("abcde"), 1, 1, S("12345"), 4, 2, S("a5cde"));
+    test(S("abcde"), 1, 1, S("12345"), 5, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 5, 1, S("acde"));
+    test(S("abcde"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 1, S("a2cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 4, S("a2345cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 8, S("a23456789cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 9, S("a234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 1, 10, S("a234567890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 1, S("a6cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 2, S("a67cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 4, S("a6789cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 5, S("a67890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 5, 6, S("a67890cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 9, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 9, 1, S("a0cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 9, 2, S("a0cde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 10, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 10, 1, S("acde"));
+    test(S("abcde"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cde"));
+}
+
+template <class S>
+void test8()
+{
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 0, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 20, 1, S("acde"));
+    test(S("abcde"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S(""), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S(""), 0, 1, S("ade"));
+    test(S("abcde"), 1, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 2, S("a12de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 4, S("a1234de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 5, S("a12345de"));
+    test(S("abcde"), 1, 2, S("12345"), 0, 6, S("a12345de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 1, S("a2de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 2, S("a23de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 3, S("a234de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 4, S("a2345de"));
+    test(S("abcde"), 1, 2, S("12345"), 1, 5, S("a2345de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 1, S("a3de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 2, S("a34de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 3, S("a345de"));
+    test(S("abcde"), 1, 2, S("12345"), 2, 4, S("a345de"));
+    test(S("abcde"), 1, 2, S("12345"), 4, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 4, 1, S("a5de"));
+    test(S("abcde"), 1, 2, S("12345"), 4, 2, S("a5de"));
+    test(S("abcde"), 1, 2, S("12345"), 5, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 5, 1, S("ade"));
+    test(S("abcde"), 1, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 5, S("a12345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 0, 11, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 1, S("a2de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 4, S("a2345de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 8, S("a23456789de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 9, S("a234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 1, 10, S("a234567890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 1, S("a6de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 2, S("a67de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 4, S("a6789de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 5, S("a67890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 5, 6, S("a67890de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 9, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 9, 1, S("a0de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 9, 2, S("a0de"));
+    test(S("abcde"), 1, 2, S("1234567890"), 10, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 10, 1, S("ade"));
+    test(S("abcde"), 1, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 19, S("a1234567890123456789de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 20, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 0, 21, S("a12345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 1, S("a2de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 9, S("a234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 18, S("a234567890123456789de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 19, S("a2345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 1, 20, S("a2345678901234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 1, S("a1de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 5, S("a12345de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 9, S("a123456789de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 10, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 10, 11, S("a1234567890de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 1, S("a0de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 19, 2, S("a0de"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 0, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 20, 1, S("ade"));
+    test(S("abcde"), 1, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S(""), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S(""), 0, 1, S("ae"));
+    test(S("abcde"), 1, 3, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 2, S("a12e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 4, S("a1234e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 5, S("a12345e"));
+    test(S("abcde"), 1, 3, S("12345"), 0, 6, S("a12345e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 1, S("a2e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 2, S("a23e"));
+}
+
+template <class S>
+void test9()
+{
+    test(S("abcde"), 1, 3, S("12345"), 1, 3, S("a234e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 4, S("a2345e"));
+    test(S("abcde"), 1, 3, S("12345"), 1, 5, S("a2345e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 1, S("a3e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 2, S("a34e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 3, S("a345e"));
+    test(S("abcde"), 1, 3, S("12345"), 2, 4, S("a345e"));
+    test(S("abcde"), 1, 3, S("12345"), 4, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 4, 1, S("a5e"));
+    test(S("abcde"), 1, 3, S("12345"), 4, 2, S("a5e"));
+    test(S("abcde"), 1, 3, S("12345"), 5, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 5, 1, S("ae"));
+    test(S("abcde"), 1, 3, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 5, S("a12345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 0, 11, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 1, S("a2e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 4, S("a2345e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 8, S("a23456789e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 9, S("a234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 1, 10, S("a234567890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 1, S("a6e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 2, S("a67e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 4, S("a6789e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 5, S("a67890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 5, 6, S("a67890e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 9, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 9, 1, S("a0e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 9, 2, S("a0e"));
+    test(S("abcde"), 1, 3, S("1234567890"), 10, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 10, 1, S("ae"));
+    test(S("abcde"), 1, 3, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 19, S("a1234567890123456789e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 20, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 0, 21, S("a12345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 1, S("a2e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 9, S("a234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 18, S("a234567890123456789e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 19, S("a2345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 1, 20, S("a2345678901234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 1, S("a1e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 5, S("a12345e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 9, S("a123456789e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 10, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 10, 11, S("a1234567890e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 1, S("a0e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 19, 2, S("a0e"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 0, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 20, 1, S("ae"));
+    test(S("abcde"), 1, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S(""), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S(""), 0, 1, S("a"));
+    test(S("abcde"), 1, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 2, S("a12"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 4, S("a1234"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 4, S("12345"), 0, 6, S("a12345"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 2, S("a23"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 3, S("a234"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 4, S("12345"), 1, 5, S("a2345"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 1, S("a3"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 2, S("a34"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 3, S("a345"));
+    test(S("abcde"), 1, 4, S("12345"), 2, 4, S("a345"));
+    test(S("abcde"), 1, 4, S("12345"), 4, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 4, 1, S("a5"));
+    test(S("abcde"), 1, 4, S("12345"), 4, 2, S("a5"));
+    test(S("abcde"), 1, 4, S("12345"), 5, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 5, 1, S("a"));
+    test(S("abcde"), 1, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 1, 10, S("a234567890"));
+}
+
+template <class S>
+void test10()
+{
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcde"), 1, 4, S("1234567890"), 9, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcde"), 1, 4, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcde"), 1, 4, S("1234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 10, 1, S("a"));
+    test(S("abcde"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcde"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S(""), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S(""), 0, 1, S("a"));
+    test(S("abcde"), 1, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 2, S("a12"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 4, S("a1234"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 5, S("12345"), 0, 6, S("a12345"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 2, S("a23"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 3, S("a234"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 5, S("12345"), 1, 5, S("a2345"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 1, S("a3"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 2, S("a34"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 3, S("a345"));
+    test(S("abcde"), 1, 5, S("12345"), 2, 4, S("a345"));
+    test(S("abcde"), 1, 5, S("12345"), 4, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 4, 1, S("a5"));
+    test(S("abcde"), 1, 5, S("12345"), 4, 2, S("a5"));
+    test(S("abcde"), 1, 5, S("12345"), 5, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 5, 1, S("a"));
+    test(S("abcde"), 1, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcde"), 1, 5, S("1234567890"), 9, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcde"), 1, 5, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcde"), 1, 5, S("1234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 10, 1, S("a"));
+    test(S("abcde"), 1, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 1, S("a1"));
+}
+
+template <class S>
+void test11()
+{
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcde"), 1, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 2, S("ab12cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 4, S("ab1234cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 0, 6, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 2, S("ab23cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 3, S("ab234cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 1, 5, S("ab2345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 1, S("ab3cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 2, S("ab34cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 3, S("ab345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 2, 4, S("ab345cde"));
+    test(S("abcde"), 2, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 4, 1, S("ab5cde"));
+    test(S("abcde"), 2, 0, S("12345"), 4, 2, S("ab5cde"));
+    test(S("abcde"), 2, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 0, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 4, S("ab2345cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 8, S("ab23456789cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 1, 10, S("ab234567890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 1, S("ab6cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 2, S("ab67cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 4, S("ab6789cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 5, S("ab67890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 5, 6, S("ab67890cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 9, 1, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 9, 2, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 19, S("ab1234567890123456789cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 20, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 0, 21, S("ab12345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 1, S("ab2cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 9, S("ab234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 18, S("ab234567890123456789cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 19, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 1, 20, S("ab2345678901234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 1, S("ab1cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 5, S("ab12345cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 9, S("ab123456789cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 10, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 10, 11, S("ab1234567890cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 1, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 19, 2, S("ab0cde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 2, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S(""), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S(""), 0, 1, S("abde"));
+    test(S("abcde"), 2, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 2, S("ab12de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 4, S("ab1234de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("12345"), 0, 6, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 1, S("ab2de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 2, S("ab23de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 3, S("ab234de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 4, S("ab2345de"));
+    test(S("abcde"), 2, 1, S("12345"), 1, 5, S("ab2345de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 0, S("abde"));
+}
+
+template <class S>
+void test12()
+{
+    test(S("abcde"), 2, 1, S("12345"), 2, 1, S("ab3de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 2, S("ab34de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 3, S("ab345de"));
+    test(S("abcde"), 2, 1, S("12345"), 2, 4, S("ab345de"));
+    test(S("abcde"), 2, 1, S("12345"), 4, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 4, 1, S("ab5de"));
+    test(S("abcde"), 2, 1, S("12345"), 4, 2, S("ab5de"));
+    test(S("abcde"), 2, 1, S("12345"), 5, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 5, 1, S("abde"));
+    test(S("abcde"), 2, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 0, 11, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 1, S("ab2de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 4, S("ab2345de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 8, S("ab23456789de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 9, S("ab234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 1, 10, S("ab234567890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 1, S("ab6de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 2, S("ab67de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 4, S("ab6789de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 5, S("ab67890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 5, 6, S("ab67890de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 9, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 9, 1, S("ab0de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 9, 2, S("ab0de"));
+    test(S("abcde"), 2, 1, S("1234567890"), 10, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 10, 1, S("abde"));
+    test(S("abcde"), 2, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 19, S("ab1234567890123456789de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 20, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 0, 21, S("ab12345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 1, S("ab2de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 9, S("ab234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 18, S("ab234567890123456789de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 19, S("ab2345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 1, 20, S("ab2345678901234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 1, S("ab1de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 5, S("ab12345de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 9, S("ab123456789de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 10, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 10, 11, S("ab1234567890de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 1, S("ab0de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 19, 2, S("ab0de"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 0, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 20, 1, S("abde"));
+    test(S("abcde"), 2, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S(""), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S(""), 0, 1, S("abe"));
+    test(S("abcde"), 2, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 2, S("ab12e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 4, S("ab1234e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("12345"), 0, 6, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 1, S("ab2e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 2, S("ab23e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 3, S("ab234e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 4, S("ab2345e"));
+    test(S("abcde"), 2, 2, S("12345"), 1, 5, S("ab2345e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 1, S("ab3e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 2, S("ab34e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 3, S("ab345e"));
+    test(S("abcde"), 2, 2, S("12345"), 2, 4, S("ab345e"));
+    test(S("abcde"), 2, 2, S("12345"), 4, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 4, 1, S("ab5e"));
+    test(S("abcde"), 2, 2, S("12345"), 4, 2, S("ab5e"));
+    test(S("abcde"), 2, 2, S("12345"), 5, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 5, 1, S("abe"));
+    test(S("abcde"), 2, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 0, 11, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 1, S("ab2e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 4, S("ab2345e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 8, S("ab23456789e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 9, S("ab234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 1, 10, S("ab234567890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 1, S("ab6e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 2, S("ab67e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 4, S("ab6789e"));
+}
+
+template <class S>
+void test13()
+{
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 5, S("ab67890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 5, 6, S("ab67890e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 9, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 9, 1, S("ab0e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 9, 2, S("ab0e"));
+    test(S("abcde"), 2, 2, S("1234567890"), 10, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 10, 1, S("abe"));
+    test(S("abcde"), 2, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 19, S("ab1234567890123456789e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 20, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 0, 21, S("ab12345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 1, S("ab2e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 9, S("ab234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 18, S("ab234567890123456789e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 19, S("ab2345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 1, 20, S("ab2345678901234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 1, S("ab1e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 5, S("ab12345e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 9, S("ab123456789e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 10, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 10, 11, S("ab1234567890e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 1, S("ab0e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 19, 2, S("ab0e"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 0, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 20, 1, S("abe"));
+    test(S("abcde"), 2, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S(""), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S(""), 0, 1, S("ab"));
+    test(S("abcde"), 2, 3, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 2, S("ab12"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 4, S("ab1234"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 3, S("12345"), 0, 6, S("ab12345"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 2, S("ab23"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 3, S("ab234"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 3, S("12345"), 1, 5, S("ab2345"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 1, S("ab3"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 2, S("ab34"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 3, S("ab345"));
+    test(S("abcde"), 2, 3, S("12345"), 2, 4, S("ab345"));
+    test(S("abcde"), 2, 3, S("12345"), 4, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 4, 1, S("ab5"));
+    test(S("abcde"), 2, 3, S("12345"), 4, 2, S("ab5"));
+    test(S("abcde"), 2, 3, S("12345"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 5, 1, S("ab"));
+    test(S("abcde"), 2, 3, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 0, 11, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 8, S("ab23456789"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 1, 10, S("ab234567890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 1, S("ab6"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 2, S("ab67"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 4, S("ab6789"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 5, S("ab67890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 5, 6, S("ab67890"));
+    test(S("abcde"), 2, 3, S("1234567890"), 9, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 9, 1, S("ab0"));
+    test(S("abcde"), 2, 3, S("1234567890"), 9, 2, S("ab0"));
+    test(S("abcde"), 2, 3, S("1234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 10, 1, S("ab"));
+    test(S("abcde"), 2, 3, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 1, S("ab1"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 5, S("ab12345"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 9, S("ab123456789"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 10, 11, S("ab1234567890"));
+}
+
+template <class S>
+void test14()
+{
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 1, S("ab0"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 19, 2, S("ab0"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 0, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 20, 1, S("ab"));
+    test(S("abcde"), 2, 3, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S(""), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S(""), 0, 1, S("ab"));
+    test(S("abcde"), 2, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 2, S("ab12"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 4, S("ab1234"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 4, S("12345"), 0, 6, S("ab12345"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 2, S("ab23"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 3, S("ab234"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 4, S("12345"), 1, 5, S("ab2345"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 1, S("ab3"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 2, S("ab34"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 3, S("ab345"));
+    test(S("abcde"), 2, 4, S("12345"), 2, 4, S("ab345"));
+    test(S("abcde"), 2, 4, S("12345"), 4, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 4, 1, S("ab5"));
+    test(S("abcde"), 2, 4, S("12345"), 4, 2, S("ab5"));
+    test(S("abcde"), 2, 4, S("12345"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 5, 1, S("ab"));
+    test(S("abcde"), 2, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 5, S("ab12345"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 9, S("ab123456789"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 0, 11, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 4, S("ab2345"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 8, S("ab23456789"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 1, 10, S("ab234567890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 1, S("ab6"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 2, S("ab67"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 4, S("ab6789"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 5, S("ab67890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 5, 6, S("ab67890"));
+    test(S("abcde"), 2, 4, S("1234567890"), 9, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 9, 1, S("ab0"));
+    test(S("abcde"), 2, 4, S("1234567890"), 9, 2, S("ab0"));
+    test(S("abcde"), 2, 4, S("1234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 10, 1, S("ab"));
+    test(S("abcde"), 2, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 19, S("ab1234567890123456789"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 20, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 0, 21, S("ab12345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 1, S("ab2"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 9, S("ab234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 18, S("ab234567890123456789"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 19, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 1, 20, S("ab2345678901234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 1, S("ab1"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 5, S("ab12345"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 9, S("ab123456789"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 10, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 10, 11, S("ab1234567890"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 1, S("ab0"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 19, 2, S("ab0"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 0, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 20, 1, S("ab"));
+    test(S("abcde"), 2, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 2, S("abcd12e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 4, S("abcd1234e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("12345"), 0, 6, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 2, S("abcd23e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 3, S("abcd234e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, 0, S("12345"), 1, 5, S("abcd2345e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 1, S("abcd3e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 2, S("abcd34e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 3, S("abcd345e"));
+    test(S("abcde"), 4, 0, S("12345"), 2, 4, S("abcd345e"));
+}
+
+template <class S>
+void test15()
+{
+    test(S("abcde"), 4, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 4, 1, S("abcd5e"));
+    test(S("abcde"), 4, 0, S("12345"), 4, 2, S("abcd5e"));
+    test(S("abcde"), 4, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 0, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 4, S("abcd2345e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 8, S("abcd23456789e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 1, 10, S("abcd234567890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 1, S("abcd6e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 2, S("abcd67e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 4, S("abcd6789e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 5, S("abcd67890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 5, 6, S("abcd67890e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 9, 1, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 9, 2, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 1, S("abcd2e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 9, S("abcd234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 18, S("abcd234567890123456789e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 1, S("abcd1e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 5, S("abcd12345e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 9, S("abcd123456789e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 10, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 10, 11, S("abcd1234567890e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 1, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 19, 2, S("abcd0e"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 4, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S(""), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S(""), 0, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 2, S("abcd12"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 4, S("abcd1234"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("12345"), 0, 6, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 2, S("abcd23"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 3, S("abcd234"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 1, S("12345"), 1, 5, S("abcd2345"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 1, S("abcd3"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 2, S("abcd34"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 3, S("abcd345"));
+    test(S("abcde"), 4, 1, S("12345"), 2, 4, S("abcd345"));
+    test(S("abcde"), 4, 1, S("12345"), 4, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 4, 1, S("abcd5"));
+    test(S("abcde"), 4, 1, S("12345"), 4, 2, S("abcd5"));
+    test(S("abcde"), 4, 1, S("12345"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 5, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 0, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 8, S("abcd23456789"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 1, 10, S("abcd234567890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 1, S("abcd6"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 2, S("abcd67"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 4, S("abcd6789"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 5, S("abcd67890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 5, 6, S("abcd67890"));
+    test(S("abcde"), 4, 1, S("1234567890"), 9, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 9, 1, S("abcd0"));
+}
+
+template <class S>
+void test16()
+{
+    test(S("abcde"), 4, 1, S("1234567890"), 9, 2, S("abcd0"));
+    test(S("abcde"), 4, 1, S("1234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 10, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 1, S("abcd1"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 5, S("abcd12345"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 1, S("abcd0"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 19, 2, S("abcd0"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 0, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 20, 1, S("abcd"));
+    test(S("abcde"), 4, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S(""), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S(""), 0, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 2, S("abcd12"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 4, S("abcd1234"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("12345"), 0, 6, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 2, S("abcd23"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 3, S("abcd234"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 2, S("12345"), 1, 5, S("abcd2345"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 1, S("abcd3"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 2, S("abcd34"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 3, S("abcd345"));
+    test(S("abcde"), 4, 2, S("12345"), 2, 4, S("abcd345"));
+    test(S("abcde"), 4, 2, S("12345"), 4, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 4, 1, S("abcd5"));
+    test(S("abcde"), 4, 2, S("12345"), 4, 2, S("abcd5"));
+    test(S("abcde"), 4, 2, S("12345"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 5, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 0, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 4, S("abcd2345"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 8, S("abcd23456789"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 1, 10, S("abcd234567890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 1, S("abcd6"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 2, S("abcd67"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 4, S("abcd6789"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 5, S("abcd67890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 5, 6, S("abcd67890"));
+    test(S("abcde"), 4, 2, S("1234567890"), 9, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 9, 1, S("abcd0"));
+    test(S("abcde"), 4, 2, S("1234567890"), 9, 2, S("abcd0"));
+    test(S("abcde"), 4, 2, S("1234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 10, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 19, S("abcd1234567890123456789"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 20, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 0, 21, S("abcd12345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 1, S("abcd2"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 9, S("abcd234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 18, S("abcd234567890123456789"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 19, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 1, 20, S("abcd2345678901234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 1, S("abcd1"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 5, S("abcd12345"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 9, S("abcd123456789"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 10, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 10, 11, S("abcd1234567890"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 0, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 1, S("abcd0"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 19, 2, S("abcd0"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 0, S("abcd"));
+}
+
+template <class S>
+void test17()
+{
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 20, 1, S("abcd"));
+    test(S("abcde"), 4, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 0, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcde"), 5, 0, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcde"), 5, 0, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcde"), 5, 0, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcde"), 5, 0, S("12345"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcde"), 5, 0, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcde"), 5, 0, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcde"), 5, 0, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S(""), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S(""), 0, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 1, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcde"), 5, 1, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcde"), 5, 1, S("12345"), 4, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcde"), 5, 1, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcde"), 5, 1, S("12345"), 5, 0, S("abcde"));
+}
+
+template <class S>
+void test18()
+{
+    test(S("abcde"), 5, 1, S("12345"), 5, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcde"), 5, 1, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcde"), 5, 1, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcde"), 5, 1, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcde"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S(""), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S(""), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("1234567890"), 11, 0, S("can't happen"));
+}
+
+template <class S>
+void test19()
+{
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcde"), 6, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 2, S("12abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 4, S("1234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 0, 6, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 2, S("23abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 3, S("234abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 1, 5, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 1, S("3abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 2, S("34abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 3, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 2, 4, S("345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 4, 1, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 4, 2, S("5abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S(""), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S(""), 0, 1, S("bcdefghij"));
+}
+
+template <class S>
+void test20()
+{
+    test(S("abcdefghij"), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 2, S("12bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 4, S("1234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 0, 6, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 1, S("2bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 2, S("23bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 3, S("234bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 4, S("2345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 1, 5, S("2345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 1, S("3bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 2, S("34bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 3, S("345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 2, 4, S("345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 4, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 4, 1, S("5bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 4, 2, S("5bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 5, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 5, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 10, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghij"));
+    test(S("abcdefghij"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S(""), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S(""), 0, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 2, S("12fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 4, S("1234fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 0, 6, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 1, S("2fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 2, S("23fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 3, S("234fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 4, S("2345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 1, 5, S("2345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 1, S("3fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 2, S("34fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 3, S("345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 2, 4, S("345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 4, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 4, 1, S("5fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 4, 2, S("5fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 5, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 5, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 1, S("1fghij"));
+}
+
+template <class S>
+void test21()
+{
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 0, 11, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 1, S("2fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 4, S("2345fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 8, S("23456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 9, S("234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 1, 10, S("234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 1, S("6fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 2, S("67fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 4, S("6789fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 5, S("67890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 5, 6, S("67890fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 1, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 9, 2, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 10, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 19, S("1234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 20, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 0, 21, S("12345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 1, S("2fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 9, S("234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 18, S("234567890123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 19, S("2345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 1, 20, S("2345678901234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 1, S("1fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 5, S("12345fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 9, S("123456789fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 10, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 10, 11, S("1234567890fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 1, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 19, 2, S("0fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 0, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 20, 1, S("fghij"));
+    test(S("abcdefghij"), 0, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S(""), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S(""), 0, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 2, S("12j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 4, S("1234j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 0, 6, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 1, S("2j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 2, S("23j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 3, S("234j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 4, S("2345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 1, 5, S("2345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 1, S("3j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 2, S("34j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 3, S("345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 2, 4, S("345j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 4, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 4, 1, S("5j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 4, 2, S("5j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 5, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 5, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 0, 11, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 1, S("2j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 4, S("2345j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 8, S("23456789j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 9, S("234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 1, 10, S("234567890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 1, S("6j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 2, S("67j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 4, S("6789j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 5, S("67890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 5, 6, S("67890j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 1, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 9, 2, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 10, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 19, S("1234567890123456789j"));
+}
+
+template <class S>
+void test22()
+{
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 20, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 0, 21, S("12345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 1, S("2j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 9, S("234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 18, S("234567890123456789j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 19, S("2345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 1, 20, S("2345678901234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 1, S("1j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 5, S("12345j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 9, S("123456789j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 10, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 10, 11, S("1234567890j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 1, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 19, 2, S("0j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 0, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 20, 1, S("j"));
+    test(S("abcdefghij"), 0, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S(""), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S(""), 0, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 2, S("12"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 4, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghij"), 0, 10, S("12345"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 5, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghij"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S(""), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S(""), 0, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 2, S("12"));
+}
+
+template <class S>
+void test23()
+{
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 4, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghij"), 0, 11, S("12345"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 5, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghij"), 0, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 2, S("a12bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 2, S("a23bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 3, S("a234bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 1, S("a3bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 2, S("a34bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 3, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 2, 4, S("a345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 4, 1, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 4, 2, S("a5bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghij"));
+}
+
+template <class S>
+void test24()
+{
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S(""), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), 0, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 2, S("a12cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 4, S("a1234cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 0, 6, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 1, S("a2cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 2, S("a23cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 3, S("a234cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 4, S("a2345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 1, 5, S("a2345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 1, S("a3cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 2, S("a34cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 3, S("a345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 2, 4, S("a345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 4, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 4, 1, S("a5cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 4, 2, S("a5cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 5, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 5, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 10, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghij"));
+}
+
+template <class S>
+void test25()
+{
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghij"));
+    test(S("abcdefghij"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S(""), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S(""), 0, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 2, S("a12fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 4, S("a1234fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 0, 6, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 1, S("a2fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 2, S("a23fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 3, S("a234fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 4, S("a2345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 1, 5, S("a2345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 1, S("a3fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 2, S("a34fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 3, S("a345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 2, 4, S("a345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 4, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 4, 1, S("a5fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 4, 2, S("a5fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 5, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 5, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 0, 11, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 1, S("a2fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 4, S("a2345fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 8, S("a23456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 9, S("a234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 1, 10, S("a234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 1, S("a6fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 2, S("a67fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 4, S("a6789fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 5, S("a67890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 5, 6, S("a67890fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 1, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 9, 2, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 10, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 19, S("a1234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 20, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 0, 21, S("a12345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 1, S("a2fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 9, S("a234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 18, S("a234567890123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 19, S("a2345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 1, 20, S("a2345678901234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 1, S("a1fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 5, S("a12345fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 9, S("a123456789fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 10, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 10, 11, S("a1234567890fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 1, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 19, 2, S("a0fghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 0, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 20, 1, S("afghij"));
+    test(S("abcdefghij"), 1, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S(""), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S(""), 0, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 2, S("a12j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 4, S("a1234j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 0, 6, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 0, S("aj"));
+}
+
+template <class S>
+void test26()
+{
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 1, S("a2j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 2, S("a23j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 3, S("a234j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 4, S("a2345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 1, 5, S("a2345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 1, S("a3j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 2, S("a34j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 3, S("a345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 2, 4, S("a345j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 4, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 4, 1, S("a5j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 4, 2, S("a5j"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 5, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 5, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 0, 11, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 1, S("a2j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 4, S("a2345j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 8, S("a23456789j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 9, S("a234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 1, 10, S("a234567890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 1, S("a6j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 2, S("a67j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 4, S("a6789j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 5, S("a67890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 5, 6, S("a67890j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 1, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 9, 2, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 10, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 19, S("a1234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 20, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 0, 21, S("a12345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 1, S("a2j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 9, S("a234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 18, S("a234567890123456789j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 19, S("a2345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 1, 20, S("a2345678901234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 1, S("a1j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 5, S("a12345j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 9, S("a123456789j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 10, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 10, 11, S("a1234567890j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 1, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 19, 2, S("a0j"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 0, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 20, 1, S("aj"));
+    test(S("abcdefghij"), 1, 8, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S(""), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S(""), 0, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 8, S("a23456789"));
+}
+
+template <class S>
+void test27()
+{
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghij"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S(""), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S(""), 0, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+}
+
+template <class S>
+void test28()
+{
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghij"), 1, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 2, S("abcde12fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 4, S("abcde1234fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 0, 6, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 2, S("abcde23fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 3, S("abcde234fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 1, 5, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 1, S("abcde3fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 2, S("abcde34fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 3, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 2, 4, S("abcde345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 4, 1, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 4, 2, S("abcde5fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 0, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 4, S("abcde2345fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 8, S("abcde23456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 1, 10, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 1, S("abcde6fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 2, S("abcde67fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 4, S("abcde6789fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 5, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 5, 6, S("abcde67890fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 9, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 1, S("abcde2fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 9, S("abcde234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 18, S("abcde234567890123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 1, S("abcde1fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 5, S("abcde12345fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 9, S("abcde123456789fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 10, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 10, 11, S("abcde1234567890fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 1, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 19, 2, S("abcde0fghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 5, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S(""), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S(""), 0, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 2, S("abcde12ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 4, S("abcde1234ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 0, 6, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 1, S("abcde2ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 2, S("abcde23ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 3, S("abcde234ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 4, S("abcde2345ghij"));
+}
+
+template <class S>
+void test29()
+{
+    test(S("abcdefghij"), 5, 1, S("12345"), 1, 5, S("abcde2345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 1, S("abcde3ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 2, S("abcde34ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 3, S("abcde345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 2, 4, S("abcde345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 4, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 4, 1, S("abcde5ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 4, 2, S("abcde5ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 5, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 5, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 0, 11, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 1, S("abcde2ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 4, S("abcde2345ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 8, S("abcde23456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 9, S("abcde234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 1, 10, S("abcde234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 1, S("abcde6ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 2, S("abcde67ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 4, S("abcde6789ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 5, S("abcde67890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 5, 6, S("abcde67890ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 1, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 9, 2, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 10, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 1, S("abcde2ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 9, S("abcde234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 18, S("abcde234567890123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 1, S("abcde1ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 5, S("abcde12345ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 9, S("abcde123456789ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 10, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 10, 11, S("abcde1234567890ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 1, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 19, 2, S("abcde0ghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 0, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 20, 1, S("abcdeghij"));
+    test(S("abcdefghij"), 5, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S(""), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S(""), 0, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 2, S("abcde12hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 4, S("abcde1234hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 0, 6, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 1, S("abcde2hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 2, S("abcde23hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 3, S("abcde234hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 4, S("abcde2345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 1, 5, S("abcde2345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 1, S("abcde3hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 2, S("abcde34hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 3, S("abcde345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 2, 4, S("abcde345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 4, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 4, 1, S("abcde5hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 4, 2, S("abcde5hij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 5, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 5, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 0, 11, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 1, S("abcde2hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 4, S("abcde2345hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 8, S("abcde23456789hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 9, S("abcde234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 1, 10, S("abcde234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 1, S("abcde6hij"));
+}
+
+template <class S>
+void test30()
+{
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 2, S("abcde67hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 4, S("abcde6789hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 5, S("abcde67890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 5, 6, S("abcde67890hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 1, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 9, 2, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 10, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 1, S("abcde2hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 9, S("abcde234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 18, S("abcde234567890123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 1, S("abcde1hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 5, S("abcde12345hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 9, S("abcde123456789hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 10, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 10, 11, S("abcde1234567890hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 1, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 19, 2, S("abcde0hij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 0, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 20, 1, S("abcdehij"));
+    test(S("abcdefghij"), 5, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S(""), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S(""), 0, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 2, S("abcde12j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 4, S("abcde1234j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 0, 6, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 1, S("abcde2j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 2, S("abcde23j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 3, S("abcde234j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 4, S("abcde2345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 1, 5, S("abcde2345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 1, S("abcde3j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 2, S("abcde34j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 3, S("abcde345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 2, 4, S("abcde345j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 4, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 4, 1, S("abcde5j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 4, 2, S("abcde5j"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 5, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 5, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 9, S("abcde123456789j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 0, 11, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 1, S("abcde2j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 4, S("abcde2345j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 8, S("abcde23456789j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 9, S("abcde234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 1, 10, S("abcde234567890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 1, S("abcde6j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 2, S("abcde67j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 4, S("abcde6789j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 5, S("abcde67890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 5, 6, S("abcde67890j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 1, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 9, 2, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 10, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 1, S("abcde2j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 9, S("abcde234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 18, S("abcde234567890123456789j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 1, S("abcde1j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 5, S("abcde12345j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 9, S("abcde123456789j"));
+}
+
+template <class S>
+void test31()
+{
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 10, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 10, 11, S("abcde1234567890j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 1, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 19, 2, S("abcde0j"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 0, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 20, 1, S("abcdej"));
+    test(S("abcdefghij"), 5, 4, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S(""), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S(""), 0, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 2, S("abcde34"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 4, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 5, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S(""), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S(""), 0, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 2, S("abcde12"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 4, S("abcde1234"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 0, 6, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 2, S("abcde23"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 3, S("abcde234"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 1, 5, S("abcde2345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 1, S("abcde3"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 2, S("abcde34"));
+}
+
+template <class S>
+void test32()
+{
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 3, S("abcde345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 2, 4, S("abcde345"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 4, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 4, 1, S("abcde5"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 4, 2, S("abcde5"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 5, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 0, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 4, S("abcde2345"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 8, S("abcde23456789"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 1, 10, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 1, S("abcde6"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 2, S("abcde67"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 4, S("abcde6789"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 5, S("abcde67890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 5, 6, S("abcde67890"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 9, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 10, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 19, S("abcde1234567890123456789"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 20, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 0, 21, S("abcde12345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 1, S("abcde2"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 9, S("abcde234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 18, S("abcde234567890123456789"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 19, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 1, 20, S("abcde2345678901234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 1, S("abcde1"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 5, S("abcde12345"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 9, S("abcde123456789"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 10, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 10, 11, S("abcde1234567890"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 1, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 19, 2, S("abcde0"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 0, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 20, 1, S("abcde"));
+    test(S("abcdefghij"), 5, 6, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 2, S("abcdefghi12j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 4, S("abcdefghi1234j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 0, 6, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 2, S("abcdefghi23j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 3, S("abcdefghi234j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 1, 5, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 1, S("abcdefghi3j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 2, S("abcdefghi34j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 3, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 2, 4, S("abcdefghi345j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 4, 1, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 4, 2, S("abcdefghi5j"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 0, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 4, S("abcdefghi2345j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 8, S("abcdefghi23456789j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 1, 10, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 1, S("abcdefghi6j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 2, S("abcdefghi67j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 4, S("abcdefghi6789j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 5, S("abcdefghi67890j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 5, 6, S("abcdefghi67890j"));
+}
+
+template <class S>
+void test33()
+{
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 9, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 1, S("abcdefghi2j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 9, S("abcdefghi234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 1, S("abcdefghi1j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 5, S("abcdefghi12345j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 9, S("abcdefghi123456789j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 1, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 19, 2, S("abcdefghi0j"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 9, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S(""), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S(""), 0, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 0, 6, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 2, S("abcdefghi23"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 3, S("abcdefghi234"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 1, 5, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 1, S("abcdefghi3"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 2, S("abcdefghi34"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 3, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 2, 4, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 4, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 4, 1, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 4, 2, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 5, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 8, S("abcdefghi23456789"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 1, 10, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 1, S("abcdefghi6"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 2, S("abcdefghi67"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 4, S("abcdefghi6789"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 5, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 5, 6, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 1, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 9, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 10, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
+}
+
+template <class S>
+void test34()
+{
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S(""), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S(""), 0, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 2, S("abcdefghi12"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 4, S("abcdefghi1234"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 0, 6, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 2, S("abcdefghi23"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 3, S("abcdefghi234"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 1, 5, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 1, S("abcdefghi3"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 2, S("abcdefghi34"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 3, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 2, 4, S("abcdefghi345"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 4, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 4, 1, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 4, 2, S("abcdefghi5"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 5, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 0, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 4, S("abcdefghi2345"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 8, S("abcdefghi23456789"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 1, 10, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 1, S("abcdefghi6"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 2, S("abcdefghi67"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 4, S("abcdefghi6789"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 5, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 5, 6, S("abcdefghi67890"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 1, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 9, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 10, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 19, S("abcdefghi1234567890123456789"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 20, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 0, 21, S("abcdefghi12345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 1, S("abcdefghi2"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 9, S("abcdefghi234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 18, S("abcdefghi234567890123456789"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 19, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 1, 20, S("abcdefghi2345678901234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 1, S("abcdefghi1"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 5, S("abcdefghi12345"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 9, S("abcdefghi123456789"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 10, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 10, 11, S("abcdefghi1234567890"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 1, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 19, 2, S("abcdefghi0"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 0, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 20, 1, S("abcdefghi"));
+    test(S("abcdefghij"), 9, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 4, 1, S("abcdefghij5"));
+}
+
+template <class S>
+void test35()
+{
+    test(S("abcdefghij"), 10, 0, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 0, S("abcdefghij"));
+}
+
+template <class S>
+void test36()
+{
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghij"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghij"), 11, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+template <class S>
+void test37()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 2, S("12abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 4, S("1234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 0, 6, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 2, S("23abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 3, S("234abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 4, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 1, 5, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 1, S("3abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 2, S("34abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 3, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 2, 4, S("345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 1, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 4, 2, S("5abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 0, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 4, S("2345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 8, S("23456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 1, 10, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 1, S("6abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 2, S("67abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 4, S("6789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 5, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 5, 6, S("67890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 9, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 19, S("1234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 20, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 0, 21, S("12345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 1, S("2abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 9, S("234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 18, S("234567890123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 19, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 1, 20, S("2345678901234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 1, S("1abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 5, S("12345abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 9, S("123456789abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 10, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 10, 11, S("1234567890abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 1, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 19, 2, S("0abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 2, S("12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 4, S("1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 0, 6, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 1, S("2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 2, S("23bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 3, S("234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 4, S("2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 1, 5, S("2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 1, S("3bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 2, S("34bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 3, S("345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 2, 4, S("345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 1, S("5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 4, 2, S("5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 5, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345"), 6, 0, S("can't happen"));
+}
+
+template <class S>
+void test38()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 0, 11, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 4, S("2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 8, S("23456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 1, 10, S("234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 1, S("6bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 2, S("67bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 4, S("6789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 5, S("67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 5, 6, S("67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 1, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 9, 2, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 10, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 19, S("1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 20, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 0, 21, S("12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 1, S("2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 9, S("234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 18, S("234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 19, S("2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 1, 20, S("2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 1, S("1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 5, S("12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 9, S("123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 10, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 10, 11, S("1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 1, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 19, 2, S("0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 0, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 20, 1, S("bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 2, S("12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 4, S("1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 0, 6, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 1, S("2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 2, S("23klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 3, S("234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 4, S("2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 1, 5, S("2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 1, S("3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 2, S("34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 3, S("345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 2, 4, S("345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 1, S("5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 4, 2, S("5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 5, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 0, 11, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 1, S("2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 4, S("2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 8, S("23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 9, S("234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 1, 10, S("234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 1, S("6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 2, S("67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 4, S("6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 5, S("67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 5, 6, S("67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 1, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 9, 2, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 10, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 1, S("1klmnopqrst"));
+}
+
+template <class S>
+void test39()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 19, S("1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 20, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 0, 21, S("12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 1, S("2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 9, S("234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 18, S("234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 19, S("2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 1, 20, S("2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 1, S("1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 5, S("12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 9, S("123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 10, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 10, 11, S("1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 1, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 19, 2, S("0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 0, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 20, 1, S("klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 2, S("12t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 4, S("1234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 0, 6, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 1, S("2t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 2, S("23t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 3, S("234t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 4, S("2345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 1, 5, S("2345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 1, S("3t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 2, S("34t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 3, S("345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 2, 4, S("345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 1, S("5t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 4, 2, S("5t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 5, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 0, 11, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 1, S("2t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 4, S("2345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 8, S("23456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 9, S("234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 1, 10, S("234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 1, S("6t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 2, S("67t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 4, S("6789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 5, S("67890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 5, 6, S("67890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 1, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 9, 2, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 10, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 19, S("1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 20, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 0, 21, S("12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 1, S("2t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 9, S("234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 18, S("234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 19, S("2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 1, 20, S("2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 1, S("1t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 5, S("12345t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 9, S("123456789t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 10, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 10, 11, S("1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 1, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 19, 2, S("0t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 0, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 20, 1, S("t"));
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 0, S(""));
+}
+
+template <class S>
+void test40()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 5, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 2, S("12"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 4, S("1234"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 0, 6, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 2, S("23"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 3, S("234"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 1, 5, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 1, S("3"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 2, S("34"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 3, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 2, 4, S("345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 1, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 4, 2, S("5"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 5, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 9, S("123456789"));
+}
+
+template <class S>
+void test41()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 0, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 4, S("2345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 8, S("23456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 1, 10, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 1, S("6"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 2, S("67"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 4, S("6789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 5, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 5, 6, S("67890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 9, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 10, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 19, S("1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 20, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 0, 21, S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 1, S("2"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 9, S("234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 18, S("234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 19, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 1, 20, S("2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 1, S("1"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 5, S("12345"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 9, S("123456789"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 10, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 10, 11, S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 1, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 19, 2, S("0"));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 0, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 20, 1, S(""));
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 2, S("a12bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 4, S("a1234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 0, 6, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 2, S("a23bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 3, S("a234bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 1, 5, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 1, S("a3bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 2, S("a34bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 3, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 2, 4, S("a345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 1, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 4, 2, S("a5bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 0, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 4, S("a2345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 8, S("a23456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 1, 10, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 1, S("a6bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 2, S("a67bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 4, S("a6789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 5, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 5, 6, S("a67890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 9, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 19, S("a1234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 20, S("a12345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 0, 21, S("a12345678901234567890bcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test42()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 1, S("a2bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 9, S("a234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 18, S("a234567890123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 19, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 1, 20, S("a2345678901234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 1, S("a1bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 5, S("a12345bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 9, S("a123456789bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 10, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 10, 11, S("a1234567890bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 1, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 19, 2, S("a0bcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 2, S("a12cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 4, S("a1234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 0, 6, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 1, S("a2cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 2, S("a23cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 3, S("a234cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 4, S("a2345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 1, 5, S("a2345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 1, S("a3cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 2, S("a34cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 3, S("a345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 2, 4, S("a345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 1, S("a5cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 4, 2, S("a5cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 5, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 0, 11, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 4, S("a2345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 8, S("a23456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 1, 10, S("a234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 1, S("a6cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 2, S("a67cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 4, S("a6789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 5, S("a67890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 5, 6, S("a67890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 1, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 9, 2, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 10, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 19, S("a1234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 20, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 0, 21, S("a12345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 1, S("a2cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 9, S("a234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 18, S("a234567890123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 19, S("a2345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 1, 20, S("a2345678901234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 1, S("a1cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 5, S("a12345cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 9, S("a123456789cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 10, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 10, 11, S("a1234567890cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 1, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 19, 2, S("a0cdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 0, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 20, 1, S("acdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 2, S("a12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 4, S("a1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 5, S("a12345klmnopqrst"));
+}
+
+template <class S>
+void test43()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 0, 6, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 1, S("a2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 2, S("a23klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 3, S("a234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 4, S("a2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 1, 5, S("a2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 1, S("a3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 2, S("a34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 3, S("a345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 2, 4, S("a345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 1, S("a5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 4, 2, S("a5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 5, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 0, 11, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 1, S("a2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 4, S("a2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 8, S("a23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 9, S("a234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 1, 10, S("a234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 1, S("a6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 2, S("a67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 4, S("a6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 5, S("a67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 5, 6, S("a67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 1, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 9, 2, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 10, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 19, S("a1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 20, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 0, 21, S("a12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 1, S("a2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 9, S("a234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 18, S("a234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 19, S("a2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 1, 20, S("a2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 1, S("a1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 5, S("a12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 9, S("a123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 10, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 10, 11, S("a1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 1, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 19, 2, S("a0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 0, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 20, 1, S("aklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 2, S("a12t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 4, S("a1234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 0, 6, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 1, S("a2t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 2, S("a23t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 3, S("a234t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 4, S("a2345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 1, 5, S("a2345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 1, S("a3t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 2, S("a34t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 3, S("a345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 2, 4, S("a345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 1, S("a5t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 4, 2, S("a5t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 5, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 0, 11, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 1, S("a2t"));
+}
+
+template <class S>
+void test44()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 4, S("a2345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 8, S("a23456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 9, S("a234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 1, 10, S("a234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 1, S("a6t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 2, S("a67t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 4, S("a6789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 5, S("a67890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 5, 6, S("a67890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 1, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 9, 2, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 10, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 19, S("a1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 20, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 0, 21, S("a12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 1, S("a2t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 9, S("a234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 18, S("a234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 19, S("a2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 1, 20, S("a2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 1, S("a1t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 5, S("a12345t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 9, S("a123456789t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 10, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 10, 11, S("a1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 1, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 19, 2, S("a0t"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 0, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 20, 1, S("at"));
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+}
+
+template <class S>
+void test45()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 2, S("a12"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 4, S("a1234"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 0, 6, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 2, S("a23"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 3, S("a234"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 1, 5, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 1, S("a3"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 2, S("a34"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 3, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 2, 4, S("a345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 1, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 4, 2, S("a5"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 5, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 0, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 4, S("a2345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 8, S("a23456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 1, 10, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 1, S("a6"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 2, S("a67"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 4, S("a6789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 5, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 5, 6, S("a67890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 9, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 10, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 19, S("a1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 20, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 0, 21, S("a12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 1, S("a2"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 9, S("a234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 18, S("a234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 19, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 1, 20, S("a2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 1, S("a1"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 5, S("a12345"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 9, S("a123456789"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 10, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 10, 11, S("a1234567890"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 1, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 19, 2, S("a0"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 0, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 20, 1, S("a"));
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 2, S("abcdefghij12klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 4, S("abcdefghij1234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 0, 6, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 2, S("abcdefghij23klmnopqrst"));
+}
+
+template <class S>
+void test46()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 3, S("abcdefghij234klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 1, 5, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 1, S("abcdefghij3klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 2, S("abcdefghij34klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 3, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 2, 4, S("abcdefghij345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 1, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 4, 2, S("abcdefghij5klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 0, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 4, S("abcdefghij2345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 8, S("abcdefghij23456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 1, 10, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 1, S("abcdefghij6klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 2, S("abcdefghij67klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 4, S("abcdefghij6789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 5, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 5, 6, S("abcdefghij67890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 9, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 1, S("abcdefghij2klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 9, S("abcdefghij234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 1, S("abcdefghij1klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 5, S("abcdefghij12345klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 9, S("abcdefghij123456789klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 1, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 19, 2, S("abcdefghij0klmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 2, S("abcdefghij12lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 4, S("abcdefghij1234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 0, 6, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 1, S("abcdefghij2lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 2, S("abcdefghij23lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 3, S("abcdefghij234lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 4, S("abcdefghij2345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 1, 5, S("abcdefghij2345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 1, S("abcdefghij3lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 2, S("abcdefghij34lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 3, S("abcdefghij345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 2, 4, S("abcdefghij345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 1, S("abcdefghij5lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 4, 2, S("abcdefghij5lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 5, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 0, 11, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 4, S("abcdefghij2345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 8, S("abcdefghij23456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 1, 10, S("abcdefghij234567890lmnopqrst"));
+}
+
+template <class S>
+void test47()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 1, S("abcdefghij6lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 2, S("abcdefghij67lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 4, S("abcdefghij6789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 5, S("abcdefghij67890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 5, 6, S("abcdefghij67890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 1, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 9, 2, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 10, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 1, S("abcdefghij2lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 9, S("abcdefghij234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 1, S("abcdefghij1lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 5, S("abcdefghij12345lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 9, S("abcdefghij123456789lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 1, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 19, 2, S("abcdefghij0lmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 0, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 20, 1, S("abcdefghijlmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 2, S("abcdefghij12pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 4, S("abcdefghij1234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 0, 6, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 1, S("abcdefghij2pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 2, S("abcdefghij23pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 3, S("abcdefghij234pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 4, S("abcdefghij2345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 1, 5, S("abcdefghij2345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 1, S("abcdefghij3pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 2, S("abcdefghij34pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 3, S("abcdefghij345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 2, 4, S("abcdefghij345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 1, S("abcdefghij5pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 4, 2, S("abcdefghij5pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 5, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 0, 11, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 1, S("abcdefghij2pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 4, S("abcdefghij2345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 8, S("abcdefghij23456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 9, S("abcdefghij234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 1, 10, S("abcdefghij234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 1, S("abcdefghij6pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 2, S("abcdefghij67pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 4, S("abcdefghij6789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 5, S("abcdefghij67890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 5, 6, S("abcdefghij67890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 1, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 9, 2, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 10, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 1, S("abcdefghij1pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 1, S("abcdefghij2pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 9, S("abcdefghij234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 1, S("abcdefghij1pqrst"));
+}
+
+template <class S>
+void test48()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 5, S("abcdefghij12345pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 9, S("abcdefghij123456789pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 1, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 19, 2, S("abcdefghij0pqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 0, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 20, 1, S("abcdefghijpqrst"));
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 2, S("abcdefghij12t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 4, S("abcdefghij1234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 0, 6, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 1, S("abcdefghij2t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 2, S("abcdefghij23t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 3, S("abcdefghij234t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 4, S("abcdefghij2345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 1, 5, S("abcdefghij2345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 1, S("abcdefghij3t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 2, S("abcdefghij34t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 3, S("abcdefghij345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 2, 4, S("abcdefghij345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 1, S("abcdefghij5t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 4, 2, S("abcdefghij5t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 5, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 0, 11, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 1, S("abcdefghij2t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 4, S("abcdefghij2345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 8, S("abcdefghij23456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 9, S("abcdefghij234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 1, 10, S("abcdefghij234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 1, S("abcdefghij6t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 2, S("abcdefghij67t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 4, S("abcdefghij6789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 5, S("abcdefghij67890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 5, 6, S("abcdefghij67890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 1, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 9, 2, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 10, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 1, S("abcdefghij2t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 9, S("abcdefghij234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 1, S("abcdefghij1t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 5, S("abcdefghij12345t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 9, S("abcdefghij123456789t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 1, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 19, 2, S("abcdefghij0t"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 0, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 20, 1, S("abcdefghijt"));
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 0, S("abcdefghij"));
+}
+
+template <class S>
+void test49()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 4, S("abcdefghij6789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 2, S("abcdefghij12"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 4, S("abcdefghij1234"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 0, 6, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 2, S("abcdefghij23"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 3, S("abcdefghij234"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 1, 5, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 1, S("abcdefghij3"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 2, S("abcdefghij34"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 3, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 2, 4, S("abcdefghij345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 1, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 4, 2, S("abcdefghij5"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 5, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 0, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 4, S("abcdefghij2345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 8, S("abcdefghij23456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 1, 10, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 1, S("abcdefghij6"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 2, S("abcdefghij67"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 4, S("abcdefghij6789"));
+}
+
+template <class S>
+void test50()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 5, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 5, 6, S("abcdefghij67890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 9, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 10, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 19, S("abcdefghij1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 20, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 0, 21, S("abcdefghij12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 1, S("abcdefghij2"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 9, S("abcdefghij234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 18, S("abcdefghij234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 19, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 1, 20, S("abcdefghij2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 1, S("abcdefghij1"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 5, S("abcdefghij12345"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 9, S("abcdefghij123456789"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 10, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 10, 11, S("abcdefghij1234567890"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 1, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 19, 2, S("abcdefghij0"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 0, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 20, 1, S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrs12t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrs23t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrs234t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrs3t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrs34t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrs345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrs5t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890t"));
+}
+
+template <class S>
+void test51()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0t"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 2, S("abcdefghijklmnopqrs12"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 4, S("abcdefghijklmnopqrs1234"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 0, 6, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 2, S("abcdefghijklmnopqrs23"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 3, S("abcdefghijklmnopqrs234"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 1, 5, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 1, S("abcdefghijklmnopqrs3"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 2, S("abcdefghijklmnopqrs34"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 3, S("abcdefghijklmnopqrs345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 2, 4, S("abcdefghijklmnopqrs345"));
+}
+
+template <class S>
+void test52()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 1, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 4, 2, S("abcdefghijklmnopqrs5"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 5, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 0, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 4, S("abcdefghijklmnopqrs2345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 8, S("abcdefghijklmnopqrs23456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 1, 10, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 1, S("abcdefghijklmnopqrs6"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 2, S("abcdefghijklmnopqrs67"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 4, S("abcdefghijklmnopqrs6789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 5, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 5, 6, S("abcdefghijklmnopqrs67890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 9, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 10, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrs1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrs12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrs2"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrs234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrs234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrs2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrs1"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrs12345"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrs123456789"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrs1234567890"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrs0"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrs"));
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+}
+
+template <class S>
+void test53()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 2, S("abcdefghijklmnopqrst12"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 4, S("abcdefghijklmnopqrst1234"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 0, 6, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 2, S("abcdefghijklmnopqrst23"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 3, S("abcdefghijklmnopqrst234"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 1, 5, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 1, S("abcdefghijklmnopqrst3"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 2, S("abcdefghijklmnopqrst34"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 3, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 2, 4, S("abcdefghijklmnopqrst345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 1, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 4, 2, S("abcdefghijklmnopqrst5"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 5, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 0, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 4, S("abcdefghijklmnopqrst2345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 8, S("abcdefghijklmnopqrst23456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 1, 10, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 1, S("abcdefghijklmnopqrst6"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 2, S("abcdefghijklmnopqrst67"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 4, S("abcdefghijklmnopqrst6789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 5, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 5, 6, S("abcdefghijklmnopqrst67890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 9, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 10, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 19, S("abcdefghijklmnopqrst1234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 20, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 0, 21, S("abcdefghijklmnopqrst12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 1, S("abcdefghijklmnopqrst2"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 9, S("abcdefghijklmnopqrst234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 18, S("abcdefghijklmnopqrst234567890123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 19, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 1, 20, S("abcdefghijklmnopqrst2345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 1, S("abcdefghijklmnopqrst1"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 5, S("abcdefghijklmnopqrst12345"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 9, S("abcdefghijklmnopqrst123456789"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 10, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 10, 11, S("abcdefghijklmnopqrst1234567890"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 0, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 1, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 19, 2, S("abcdefghijklmnopqrst0"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 0, S("abcdefghijklmnopqrst"));
+}
+
+template <class S>
+void test54()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 20, 1, S("abcdefghijklmnopqrst"));
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("12345678901234567890"), 21, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 0, 6, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 1, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 3, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 2, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 4, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345"), 6, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 0, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 8, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 1, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 4, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 5, 6, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 9, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("1234567890"), 11, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 0, 21, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 18, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 19, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 1, 20, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 5, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 9, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 10, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 10, 11, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 19, 2, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 0, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 20, 1, S("can't happen"));
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("12345678901234567890"), 21, 0, S("can't happen"));
+}
+
+template <class S>
+void test55()
+{
+    test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 10, S("abcdefghi1234567890"));
+    test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 19, S("abcdefghi0"));
+    test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi"));
+    test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 20, S("abcdefghi"));
+    test_npos(S("abcdefghij"), 9, 1, S("12345678901234567890"), 21, S("can't happen"));
+    test_npos(S("abcdefghij"), 9, 2, S(""), 0, S("abcdefghi"));
+    test_npos(S("abcdefghij"), 9, 2, S(""), 1, S("can't happen"));
+    test_npos(S("abcdefghij"), 9, 2, S("12345"), 0, S("abcdefghi12345"));
+    test_npos(S("abcdefghij"), 9, 2, S("12345"), 1, S("abcdefghi2345"));
+    test_npos(S("abcdefghij"), 9, 2, S("12345"), 2, S("abcdefghi345"));
+    test_npos(S("abcdefghij"), 9, 2, S("12345"), 4, S("abcdefghi5"));
+    test_npos(S("abcdefghij"), 9, 2, S("12345"), 5, S("abcdefghi"));
+    test_npos(S("abcdefghij"), 9, 2, S("12345"), 6, S("can't happen"));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    test12<S>();
+    test13<S>();
+    test14<S>();
+    test15<S>();
+    test16<S>();
+    test17<S>();
+    test18<S>();
+    test19<S>();
+    test20<S>();
+    test21<S>();
+    test22<S>();
+    test23<S>();
+    test24<S>();
+    test25<S>();
+    test26<S>();
+    test27<S>();
+    test28<S>();
+    test29<S>();
+    test30<S>();
+    test31<S>();
+    test32<S>();
+    test33<S>();
+    test34<S>();
+    test35<S>();
+    test36<S>();
+    test37<S>();
+    test38<S>();
+    test39<S>();
+    test40<S>();
+    test41<S>();
+    test42<S>();
+    test43<S>();
+    test44<S>();
+    test45<S>();
+    test46<S>();
+    test47<S>();
+    test48<S>();
+    test49<S>();
+    test50<S>();
+    test51<S>();
+    test52<S>();
+    test53<S>();
+    test54<S>();
+    test55<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    test12<S>();
+    test13<S>();
+    test14<S>();
+    test15<S>();
+    test16<S>();
+    test17<S>();
+    test18<S>();
+    test19<S>();
+    test20<S>();
+    test21<S>();
+    test22<S>();
+    test23<S>();
+    test24<S>();
+    test25<S>();
+    test26<S>();
+    test27<S>();
+    test28<S>();
+    test29<S>();
+    test30<S>();
+    test31<S>();
+    test32<S>();
+    test33<S>();
+    test34<S>();
+    test35<S>();
+    test36<S>();
+    test37<S>();
+    test38<S>();
+    test39<S>();
+    test40<S>();
+    test41<S>();
+    test42<S>();
+    test43<S>();
+    test44<S>();
+    test45<S>();
+    test46<S>();
+    test47<S>();
+    test48<S>();
+    test49<S>();
+    test50<S>();
+    test51<S>();
+    test52<S>();
+    test53<S>();
+    test54<S>();
+    test55<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp b/final/test/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp
new file mode 100644
index 0000000..4973bda
--- /dev/null
+++ b/final/test/strings/basic.string/string.modifiers/string_swap/swap.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void swap(basic_string& s);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, S s2)
+{
+    S s1_ = s1;
+    S s2_ = s2;
+    s1.swap(s2);
+    assert(s1.__invariants());
+    assert(s2.__invariants());
+    assert(s1 == s2_);
+    assert(s2 == s1_);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""));
+    test(S(""), S("12345"));
+    test(S(""), S("1234567890"));
+    test(S(""), S("12345678901234567890"));
+    test(S("abcde"), S(""));
+    test(S("abcde"), S("12345"));
+    test(S("abcde"), S("1234567890"));
+    test(S("abcde"), S("12345678901234567890"));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghij"), S("12345"));
+    test(S("abcdefghij"), S("1234567890"));
+    test(S("abcdefghij"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    test(S("abcdefghijklmnopqrst"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""));
+    test(S(""), S("12345"));
+    test(S(""), S("1234567890"));
+    test(S(""), S("12345678901234567890"));
+    test(S("abcde"), S(""));
+    test(S("abcde"), S("12345"));
+    test(S("abcde"), S("1234567890"));
+    test(S("abcde"), S("12345678901234567890"));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghij"), S("12345"));
+    test(S("abcdefghij"), S("1234567890"));
+    test(S("abcdefghij"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    test(S("abcdefghijklmnopqrst"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp b/final/test/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
new file mode 100644
index 0000000..4a912ea
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.io/get_line.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>& is,
+//           basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::istringstream in(" abc\n  def\n   ghij");
+        std::string s("initial text");
+        getline(in, s);
+        assert(in.good());
+        assert(s == " abc");
+        getline(in, s);
+        assert(in.good());
+        assert(s == "  def");
+        getline(in, s);
+        assert(in.eof());
+        assert(s == "   ghij");
+    }
+    {
+        std::wistringstream in(L" abc\n  def\n   ghij");
+        std::wstring s(L"initial text");
+        getline(in, s);
+        assert(in.good());
+        assert(s == L" abc");
+        getline(in, s);
+        assert(in.good());
+        assert(s == L"  def");
+        getline(in, s);
+        assert(in.eof());
+        assert(s == L"   ghij");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        std::istringstream in(" abc\n  def\n   ghij");
+        S s("initial text");
+        getline(in, s);
+        assert(in.good());
+        assert(s == " abc");
+        getline(in, s);
+        assert(in.good());
+        assert(s == "  def");
+        getline(in, s);
+        assert(in.eof());
+        assert(s == "   ghij");
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        std::wistringstream in(L" abc\n  def\n   ghij");
+        S s(L"initial text");
+        getline(in, s);
+        assert(in.good());
+        assert(s == L" abc");
+        getline(in, s);
+        assert(in.good());
+        assert(s == L"  def");
+        getline(in, s);
+        assert(in.eof());
+        assert(s == L"   ghij");
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
new file mode 100644
index 0000000..6596f2f
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.io/get_line_delim.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>& is,
+//           basic_string<charT,traits,Allocator>& str, charT delim);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::istringstream in(" abc*  def**   ghij");
+        std::string s("initial text");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == " abc");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == "  def");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == "");
+        getline(in, s, '*');
+        assert(in.eof());
+        assert(s == "   ghij");
+    }
+    {
+        std::wistringstream in(L" abc*  def**   ghij");
+        std::wstring s(L"initial text");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L" abc");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L"  def");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L"");
+        getline(in, s, L'*');
+        assert(in.eof());
+        assert(s == L"   ghij");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        std::istringstream in(" abc*  def**   ghij");
+        S s("initial text");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == " abc");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == "  def");
+        getline(in, s, '*');
+        assert(in.good());
+        assert(s == "");
+        getline(in, s, '*');
+        assert(in.eof());
+        assert(s == "   ghij");
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        std::wistringstream in(L" abc*  def**   ghij");
+        S s(L"initial text");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L" abc");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L"  def");
+        getline(in, s, L'*');
+        assert(in.good());
+        assert(s == L"");
+        getline(in, s, L'*');
+        assert(in.eof());
+        assert(s == L"   ghij");
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
new file mode 100644
index 0000000..84f52bb
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.io/get_line_delim_rv.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>&& is,
+//           basic_string<charT,traits,Allocator>& str, charT delim);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::string s("initial text");
+        getline(std::istringstream(" abc*  def*   ghij"), s, '*');
+        assert(s == " abc");
+    }
+    {
+        std::wstring s(L"initial text");
+        getline(std::wistringstream(L" abc*  def*   ghij"), s, L'*');
+        assert(s == L" abc");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s("initial text");
+        getline(std::istringstream(" abc*  def*   ghij"), s, '*');
+        assert(s == " abc");
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        S s(L"initial text");
+        getline(std::wistringstream(L" abc*  def*   ghij"), s, L'*');
+        assert(s == L" abc");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
new file mode 100644
index 0000000..a3c9911
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.io/get_line_rv.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   getline(basic_istream<charT,traits>&& is,
+//           basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::string s("initial text");
+        getline(std::istringstream(" abc\n  def\n   ghij"), s);
+        assert(s == " abc");
+    }
+    {
+        std::wstring s(L"initial text");
+        getline(std::wistringstream(L" abc\n  def\n   ghij"), s);
+        assert(s == L" abc");
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        S s("initial text");
+        getline(std::istringstream(" abc\n  def\n   ghij"), s);
+        assert(s == " abc");
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        S s(L"initial text");
+        getline(std::wistringstream(L" abc\n  def\n   ghij"), s);
+        assert(s == L" abc");
+    }
+#endif
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
new file mode 100644
index 0000000..af806bc
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.io/stream_extract.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_istream<charT,traits>&
+//   operator>>(basic_istream<charT,traits>& is,
+//              basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::istringstream in("a bc defghij");
+        std::string s("initial text");
+        in >> s;
+        assert(in.good());
+        assert(s == "a");
+        assert(in.peek() == ' ');
+        in >> s;
+        assert(in.good());
+        assert(s == "bc");
+        assert(in.peek() == ' ');
+        in.width(3);
+        in >> s;
+        assert(in.good());
+        assert(s == "def");
+        assert(in.peek() == 'g');
+        in >> s;
+        assert(in.eof());
+        assert(s == "ghij");
+        in >> s;
+        assert(in.fail());
+    }
+    {
+        std::wistringstream in(L"a bc defghij");
+        std::wstring s(L"initial text");
+        in >> s;
+        assert(in.good());
+        assert(s == L"a");
+        assert(in.peek() == L' ');
+        in >> s;
+        assert(in.good());
+        assert(s == L"bc");
+        assert(in.peek() == L' ');
+        in.width(3);
+        in >> s;
+        assert(in.good());
+        assert(s == L"def");
+        assert(in.peek() == L'g');
+        in >> s;
+        assert(in.eof());
+        assert(s == L"ghij");
+        in >> s;
+        assert(in.fail());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        std::istringstream in("a bc defghij");
+        S s("initial text");
+        in >> s;
+        assert(in.good());
+        assert(s == "a");
+        assert(in.peek() == ' ');
+        in >> s;
+        assert(in.good());
+        assert(s == "bc");
+        assert(in.peek() == ' ');
+        in.width(3);
+        in >> s;
+        assert(in.good());
+        assert(s == "def");
+        assert(in.peek() == 'g');
+        in >> s;
+        assert(in.eof());
+        assert(s == "ghij");
+        in >> s;
+        assert(in.fail());
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        std::wistringstream in(L"a bc defghij");
+        S s(L"initial text");
+        in >> s;
+        assert(in.good());
+        assert(s == L"a");
+        assert(in.peek() == L' ');
+        in >> s;
+        assert(in.good());
+        assert(s == L"bc");
+        assert(in.peek() == L' ');
+        in.width(3);
+        in >> s;
+        assert(in.good());
+        assert(s == L"def");
+        assert(in.peek() == L'g');
+        in >> s;
+        assert(in.eof());
+        assert(s == L"ghij");
+        in >> s;
+        assert(in.fail());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
new file mode 100644
index 0000000..102e8ea
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.io/stream_insert.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_ostream<charT, traits>&
+//   operator<<(basic_ostream<charT, traits>& os,
+//              const basic_string<charT,traits,Allocator>& str);
+
+#include <string>
+#include <sstream>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+    {
+        std::ostringstream out;
+        std::string s("some text");
+        out << s;
+        assert(out.good());
+        assert(s == out.str());
+    }
+    {
+        std::ostringstream out;
+        std::string s("some text");
+        out.width(12);
+        out << s;
+        assert(out.good());
+        assert("   " + s == out.str());
+    }
+    {
+        std::wostringstream out;
+        std::wstring s(L"some text");
+        out << s;
+        assert(out.good());
+        assert(s == out.str());
+    }
+    {
+        std::wostringstream out;
+        std::wstring s(L"some text");
+        out.width(12);
+        out << s;
+        assert(out.good());
+        assert(L"   " + s == out.str());
+    }
+#if __cplusplus >= 201103L
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+        S s("some text");
+        out << s;
+        assert(out.good());
+        assert(s == out.str());
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+        std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+        S s("some text");
+        out.width(12);
+        out << s;
+        assert(out.good());
+        assert("   " + s == out.str());
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+        S s(L"some text");
+        out << s;
+        assert(out.good());
+        assert(s == out.str());
+    }
+    {
+        typedef std::basic_string<wchar_t, std::char_traits<wchar_t>, min_allocator<wchar_t>> S;
+        std::basic_ostringstream<S::value_type, S::traits_type, S::allocator_type> out;
+        S s(L"some text");
+        out.width(12);
+        out << s;
+        assert(out.good());
+        assert(L"   " + s == out.str());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
new file mode 100644
index 0000000..cee5388
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.special/swap.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   void swap(basic_string<charT,traits,Allocator>& lhs,
+//             basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(S s1, S s2)
+{
+    S s1_ = s1;
+    S s2_ = s2;
+    swap(s1, s2);
+    assert(s1.__invariants());
+    assert(s2.__invariants());
+    assert(s1 == s2_);
+    assert(s2 == s1_);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""));
+    test(S(""), S("12345"));
+    test(S(""), S("1234567890"));
+    test(S(""), S("12345678901234567890"));
+    test(S("abcde"), S(""));
+    test(S("abcde"), S("12345"));
+    test(S("abcde"), S("1234567890"));
+    test(S("abcde"), S("12345678901234567890"));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghij"), S("12345"));
+    test(S("abcdefghij"), S("1234567890"));
+    test(S("abcdefghij"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    test(S("abcdefghijklmnopqrst"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""));
+    test(S(""), S("12345"));
+    test(S(""), S("1234567890"));
+    test(S(""), S("12345678901234567890"));
+    test(S("abcde"), S(""));
+    test(S("abcde"), S("12345"));
+    test(S("abcde"), S("1234567890"));
+    test(S("abcde"), S("12345678901234567890"));
+    test(S("abcdefghij"), S(""));
+    test(S("abcdefghij"), S("12345"));
+    test(S("abcdefghij"), S("1234567890"));
+    test(S("abcdefghij"), S("12345678901234567890"));
+    test(S("abcdefghijklmnopqrst"), S(""));
+    test(S("abcdefghijklmnopqrst"), S("12345"));
+    test(S("abcdefghijklmnopqrst"), S("1234567890"));
+    test(S("abcdefghijklmnopqrst"), S("12345678901234567890"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
new file mode 100644
index 0000000..4d5d796
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string.special/swap_noexcept.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// void swap(basic_string& c)
+//     noexcept(!allocator_type::propagate_on_container_swap::value ||
+//              __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+    typedef T value_type;
+    
+    some_alloc() {}
+    some_alloc(const some_alloc&);
+    void deallocate(void*, unsigned) {}
+
+    typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+    {
+        typedef std::string C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> C;
+        C c1, c2;
+        static_assert(noexcept(swap(c1, c2)), "");
+    }
+    {
+        typedef std::basic_string<char, std::char_traits<char>, some_alloc<char>> C;
+        C c1, c2;
+        static_assert(!noexcept(swap(c1, c2)), "");
+    }
+#endif
+}
diff --git "a/final/test/strings/basic.string/string.nonmembers/string_op\041=/pointer_string.pass.cpp" "b/final/test/strings/basic.string/string.nonmembers/string_op\041=/pointer_string.pass.cpp"
new file mode 100644
index 0000000..cc08982
--- /dev/null
+++ "b/final/test/strings/basic.string/string.nonmembers/string_op\041=/pointer_string.pass.cpp"
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test("", S(""), false);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test("", S(""), false);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+    }
+#endif
+}
diff --git "a/final/test/strings/basic.string/string.nonmembers/string_op\041=/string_pointer.pass.cpp" "b/final/test/strings/basic.string/string.nonmembers/string_op\041=/string_pointer.pass.cpp"
new file mode 100644
index 0000000..b496d70
--- /dev/null
+++ "b/final/test/strings/basic.string/string.nonmembers/string_op\041=/string_pointer.pass.cpp"
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator!=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), "", false);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), "", false);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+    }
+#endif
+}
diff --git "a/final/test/strings/basic.string/string.nonmembers/string_op\041=/string_string.pass.cpp" "b/final/test/strings/basic.string/string.nonmembers/string_op\041=/string_string.pass.cpp"
new file mode 100644
index 0000000..069b305
--- /dev/null
+++ "b/final/test/strings/basic.string/string.nonmembers/string_op\041=/string_string.pass.cpp"
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
+//                   const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs != rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
new file mode 100644
index 0000000..4e09bf2
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_op+/char_string.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>
+//   operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(charT lhs, basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(typename S::value_type lhs, const S& rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(typename S::value_type lhs, S&& rhs, const S& x)
+{
+    assert(lhs + move(rhs) == x);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0('a', S(""), S("a"));
+    test0('a', S("12345"), S("a12345"));
+    test0('a', S("1234567890"), S("a1234567890"));
+    test0('a', S("12345678901234567890"), S("a12345678901234567890"));
+    
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1('a', S(""), S("a"));
+    test1('a', S("12345"), S("a12345"));
+    test1('a', S("1234567890"), S("a1234567890"));
+    test1('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0('a', S(""), S("a"));
+    test0('a', S("12345"), S("a12345"));
+    test0('a', S("1234567890"), S("a1234567890"));
+    test0('a', S("12345678901234567890"), S("a12345678901234567890"));
+    
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1('a', S(""), S("a"));
+    test1('a', S("12345"), S("a12345"));
+    test1('a', S("1234567890"), S("a1234567890"));
+    test1('a', S("12345678901234567890"), S("a12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp
new file mode 100644
index 0000000..9dc8a51
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_op+/pointer_string.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>
+//   operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const charT* lhs, basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const typename S::value_type* lhs, const S& rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(const typename S::value_type* lhs, S&& rhs, const S& x)
+{
+    assert(lhs + move(rhs) == x);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0("", S(""), S(""));
+    test0("", S("12345"), S("12345"));
+    test0("", S("1234567890"), S("1234567890"));
+    test0("", S("12345678901234567890"), S("12345678901234567890"));
+    test0("abcde", S(""), S("abcde"));
+    test0("abcde", S("12345"), S("abcde12345"));
+    test0("abcde", S("1234567890"), S("abcde1234567890"));
+    test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+    test0("abcdefghij", S(""), S("abcdefghij"));
+    test0("abcdefghij", S("12345"), S("abcdefghij12345"));
+    test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+    test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+    test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+    test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1("", S(""), S(""));
+    test1("", S("12345"), S("12345"));
+    test1("", S("1234567890"), S("1234567890"));
+    test1("", S("12345678901234567890"), S("12345678901234567890"));
+    test1("abcde", S(""), S("abcde"));
+    test1("abcde", S("12345"), S("abcde12345"));
+    test1("abcde", S("1234567890"), S("abcde1234567890"));
+    test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+    test1("abcdefghij", S(""), S("abcdefghij"));
+    test1("abcdefghij", S("12345"), S("abcdefghij12345"));
+    test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+    test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+    test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+    test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0("", S(""), S(""));
+    test0("", S("12345"), S("12345"));
+    test0("", S("1234567890"), S("1234567890"));
+    test0("", S("12345678901234567890"), S("12345678901234567890"));
+    test0("abcde", S(""), S("abcde"));
+    test0("abcde", S("12345"), S("abcde12345"));
+    test0("abcde", S("1234567890"), S("abcde1234567890"));
+    test0("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+    test0("abcdefghij", S(""), S("abcdefghij"));
+    test0("abcdefghij", S("12345"), S("abcdefghij12345"));
+    test0("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+    test0("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test0("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+    test0("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+    test0("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test0("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1("", S(""), S(""));
+    test1("", S("12345"), S("12345"));
+    test1("", S("1234567890"), S("1234567890"));
+    test1("", S("12345678901234567890"), S("12345678901234567890"));
+    test1("abcde", S(""), S("abcde"));
+    test1("abcde", S("12345"), S("abcde12345"));
+    test1("abcde", S("1234567890"), S("abcde1234567890"));
+    test1("abcde", S("12345678901234567890"), S("abcde12345678901234567890"));
+    test1("abcdefghij", S(""), S("abcdefghij"));
+    test1("abcdefghij", S("12345"), S("abcdefghij12345"));
+    test1("abcdefghij", S("1234567890"), S("abcdefghij1234567890"));
+    test1("abcdefghij", S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test1("abcdefghijklmnopqrst", S(""), S("abcdefghijklmnopqrst"));
+    test1("abcdefghijklmnopqrst", S("12345"), S("abcdefghijklmnopqrst12345"));
+    test1("abcdefghijklmnopqrst", S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test1("abcdefghijklmnopqrst", S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
new file mode 100644
index 0000000..4d72db5
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_op+/string_char.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>
+//   operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs);
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const S& lhs, typename S::value_type rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(S&& lhs, typename S::value_type rhs, const S& x)
+{
+    assert(move(lhs) + rhs == x);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0(S(""), '1', S("1"));
+    test0(S("abcde"), '1', S("abcde1"));
+    test0(S("abcdefghij"), '1', S("abcdefghij1"));
+    test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1(S(""), '1', S("1"));
+    test1(S("abcde"), '1', S("abcde1"));
+    test1(S("abcdefghij"), '1', S("abcdefghij1"));
+    test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0(S(""), '1', S("1"));
+    test0(S("abcde"), '1', S("abcde1"));
+    test0(S("abcdefghij"), '1', S("abcdefghij1"));
+    test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1(S(""), '1', S("1"));
+    test1(S("abcde"), '1', S("abcde1"));
+    test1(S("abcdefghij"), '1', S("abcdefghij1"));
+    test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp
new file mode 100644
index 0000000..47fc1ca
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_op+/string_pointer.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>
+//   operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(basic_string<charT,traits,Allocator>&& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const S& lhs, const typename S::value_type* rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(S&& lhs, const typename S::value_type* rhs, const S& x)
+{
+    assert(move(lhs) + rhs == x);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0(S(""), "", S(""));
+    test0(S(""), "12345", S("12345"));
+    test0(S(""), "1234567890", S("1234567890"));
+    test0(S(""), "12345678901234567890", S("12345678901234567890"));
+    test0(S("abcde"), "", S("abcde"));
+    test0(S("abcde"), "12345", S("abcde12345"));
+    test0(S("abcde"), "1234567890", S("abcde1234567890"));
+    test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+    test0(S("abcdefghij"), "", S("abcdefghij"));
+    test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
+    test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+    test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+    test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+    test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1(S(""), "", S(""));
+    test1(S(""), "12345", S("12345"));
+    test1(S(""), "1234567890", S("1234567890"));
+    test1(S(""), "12345678901234567890", S("12345678901234567890"));
+    test1(S("abcde"), "", S("abcde"));
+    test1(S("abcde"), "12345", S("abcde12345"));
+    test1(S("abcde"), "1234567890", S("abcde1234567890"));
+    test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+    test1(S("abcdefghij"), "", S("abcdefghij"));
+    test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
+    test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+    test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+    test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+    test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0(S(""), "", S(""));
+    test0(S(""), "12345", S("12345"));
+    test0(S(""), "1234567890", S("1234567890"));
+    test0(S(""), "12345678901234567890", S("12345678901234567890"));
+    test0(S("abcde"), "", S("abcde"));
+    test0(S("abcde"), "12345", S("abcde12345"));
+    test0(S("abcde"), "1234567890", S("abcde1234567890"));
+    test0(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+    test0(S("abcdefghij"), "", S("abcdefghij"));
+    test0(S("abcdefghij"), "12345", S("abcdefghij12345"));
+    test0(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+    test0(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test0(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+    test0(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+    test0(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test0(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1(S(""), "", S(""));
+    test1(S(""), "12345", S("12345"));
+    test1(S(""), "1234567890", S("1234567890"));
+    test1(S(""), "12345678901234567890", S("12345678901234567890"));
+    test1(S("abcde"), "", S("abcde"));
+    test1(S("abcde"), "12345", S("abcde12345"));
+    test1(S("abcde"), "1234567890", S("abcde1234567890"));
+    test1(S("abcde"), "12345678901234567890", S("abcde12345678901234567890"));
+    test1(S("abcdefghij"), "", S("abcdefghij"));
+    test1(S("abcdefghij"), "12345", S("abcdefghij12345"));
+    test1(S("abcdefghij"), "1234567890", S("abcdefghij1234567890"));
+    test1(S("abcdefghij"), "12345678901234567890", S("abcdefghij12345678901234567890"));
+    test1(S("abcdefghijklmnopqrst"), "", S("abcdefghijklmnopqrst"));
+    test1(S("abcdefghijklmnopqrst"), "12345", S("abcdefghijklmnopqrst12345"));
+    test1(S("abcdefghijklmnopqrst"), "1234567890", S("abcdefghijklmnopqrst1234567890"));
+    test1(S("abcdefghijklmnopqrst"), "12345678901234567890", S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp
new file mode 100644
index 0000000..bf2ddd5
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_op+/string_string.pass.cpp
@@ -0,0 +1,221 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>
+//   operator+(const basic_string<charT,traits,Allocator>& lhs,
+//             const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const basic_string<charT,traits,Allocator>&& lhs,
+//             const basic_string<charT,traits,Allocator>& rhs);
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const basic_string<charT,traits,Allocator>& lhs,
+//             const basic_string<charT,traits,Allocator>&& rhs);
+
+// template<class charT, class traits, class Allocator>
+//   basic_string<charT,traits,Allocator>&&
+//   operator+(const basic_string<charT,traits,Allocator>&& lhs,
+//             const basic_string<charT,traits,Allocator>&& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test0(const S& lhs, const S& rhs, const S& x)
+{
+    assert(lhs + rhs == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class S>
+void
+test1(S&& lhs, const S& rhs, const S& x)
+{
+    assert(move(lhs) + rhs == x);
+}
+
+template <class S>
+void
+test2(const S& lhs, S&& rhs, const S& x)
+{
+    assert(lhs + move(rhs) == x);
+}
+
+template <class S>
+void
+test3(S&& lhs, S&& rhs, const S& x)
+{
+    assert(move(lhs) + move(rhs) == x);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0(S(""), S(""), S(""));
+    test0(S(""), S("12345"), S("12345"));
+    test0(S(""), S("1234567890"), S("1234567890"));
+    test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test0(S("abcde"), S(""), S("abcde"));
+    test0(S("abcde"), S("12345"), S("abcde12345"));
+    test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test0(S("abcdefghij"), S(""), S("abcdefghij"));
+    test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1(S(""), S(""), S(""));
+    test1(S(""), S("12345"), S("12345"));
+    test1(S(""), S("1234567890"), S("1234567890"));
+    test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test1(S("abcde"), S(""), S("abcde"));
+    test1(S("abcde"), S("12345"), S("abcde12345"));
+    test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test1(S("abcdefghij"), S(""), S("abcdefghij"));
+    test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+    test2(S(""), S(""), S(""));
+    test2(S(""), S("12345"), S("12345"));
+    test2(S(""), S("1234567890"), S("1234567890"));
+    test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test2(S("abcde"), S(""), S("abcde"));
+    test2(S("abcde"), S("12345"), S("abcde12345"));
+    test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test2(S("abcdefghij"), S(""), S("abcdefghij"));
+    test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+    test3(S(""), S(""), S(""));
+    test3(S(""), S("12345"), S("12345"));
+    test3(S(""), S("1234567890"), S("1234567890"));
+    test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test3(S("abcde"), S(""), S("abcde"));
+    test3(S("abcde"), S("12345"), S("abcde12345"));
+    test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test3(S("abcdefghij"), S(""), S("abcdefghij"));
+    test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0(S(""), S(""), S(""));
+    test0(S(""), S("12345"), S("12345"));
+    test0(S(""), S("1234567890"), S("1234567890"));
+    test0(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test0(S("abcde"), S(""), S("abcde"));
+    test0(S("abcde"), S("12345"), S("abcde12345"));
+    test0(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test0(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test0(S("abcdefghij"), S(""), S("abcdefghij"));
+    test0(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test0(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test0(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test0(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test0(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test0(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test0(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    test1(S(""), S(""), S(""));
+    test1(S(""), S("12345"), S("12345"));
+    test1(S(""), S("1234567890"), S("1234567890"));
+    test1(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test1(S("abcde"), S(""), S("abcde"));
+    test1(S("abcde"), S("12345"), S("abcde12345"));
+    test1(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test1(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test1(S("abcdefghij"), S(""), S("abcdefghij"));
+    test1(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test1(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test1(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test1(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test1(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test1(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test1(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+    test2(S(""), S(""), S(""));
+    test2(S(""), S("12345"), S("12345"));
+    test2(S(""), S("1234567890"), S("1234567890"));
+    test2(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test2(S("abcde"), S(""), S("abcde"));
+    test2(S("abcde"), S("12345"), S("abcde12345"));
+    test2(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test2(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test2(S("abcdefghij"), S(""), S("abcdefghij"));
+    test2(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test2(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test2(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test2(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test2(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test2(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test2(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+    test3(S(""), S(""), S(""));
+    test3(S(""), S("12345"), S("12345"));
+    test3(S(""), S("1234567890"), S("1234567890"));
+    test3(S(""), S("12345678901234567890"), S("12345678901234567890"));
+    test3(S("abcde"), S(""), S("abcde"));
+    test3(S("abcde"), S("12345"), S("abcde12345"));
+    test3(S("abcde"), S("1234567890"), S("abcde1234567890"));
+    test3(S("abcde"), S("12345678901234567890"), S("abcde12345678901234567890"));
+    test3(S("abcdefghij"), S(""), S("abcdefghij"));
+    test3(S("abcdefghij"), S("12345"), S("abcdefghij12345"));
+    test3(S("abcdefghij"), S("1234567890"), S("abcdefghij1234567890"));
+    test3(S("abcdefghij"), S("12345678901234567890"), S("abcdefghij12345678901234567890"));
+    test3(S("abcdefghijklmnopqrst"), S(""), S("abcdefghijklmnopqrst"));
+    test3(S("abcdefghijklmnopqrst"), S("12345"), S("abcdefghijklmnopqrst12345"));
+    test3(S("abcdefghijklmnopqrst"), S("1234567890"), S("abcdefghijklmnopqrst1234567890"));
+    test3(S("abcdefghijklmnopqrst"), S("12345678901234567890"), S("abcdefghijklmnopqrst12345678901234567890"));
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
new file mode 100644
index 0000000..19a5bdd
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_operator==/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test("", S(""), true);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test("", S(""), true);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
new file mode 100644
index 0000000..22006bb
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_operator==/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), "", true);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), "", true);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
new file mode 100644
index 0000000..0bff70a
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_operator==/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator==(const basic_string<charT,traits,Allocator>& lhs,
+//                   const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs == rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
new file mode 100644
index 0000000..f9fa204
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_opgt/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs > rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test("", S(""), false);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test("", S(""), false);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
new file mode 100644
index 0000000..daa6f40
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_opgt/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs > rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), "", false);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), "", false);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
new file mode 100644
index 0000000..95073bf
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_opgt/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>(const basic_string<charT,traits,Allocator>& lhs,
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs > rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
new file mode 100644
index 0000000..eab117a
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_opgt=/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs >= rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test("", S(""), true);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test("", S(""), true);
+    test("", S("abcde"), false);
+    test("", S("abcdefghij"), false);
+    test("", S("abcdefghijklmnopqrst"), false);
+    test("abcde", S(""), true);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), false);
+    test("abcde", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghij", S(""), true);
+    test("abcdefghij", S("abcde"), true);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), false);
+    test("abcdefghijklmnopqrst", S(""), true);
+    test("abcdefghijklmnopqrst", S("abcde"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), true);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
new file mode 100644
index 0000000..56b3b35
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_opgt=/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs >= rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), "", true);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), "", true);
+    test(S(""), "abcde", false);
+    test(S(""), "abcdefghij", false);
+    test(S(""), "abcdefghijklmnopqrst", false);
+    test(S("abcde"), "", true);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", false);
+    test(S("abcde"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghij"), "", true);
+    test(S("abcdefghij"), "abcde", true);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", false);
+    test(S("abcdefghijklmnopqrst"), "", true);
+    test(S("abcdefghijklmnopqrst"), "abcde", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", true);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
new file mode 100644
index 0000000..c02b202
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_opgt=/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs >= rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), false);
+    test(S(""), S("abcdefghij"), false);
+    test(S(""), S("abcdefghijklmnopqrst"), false);
+    test(S("abcde"), S(""), true);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), false);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghij"), S(""), true);
+    test(S("abcdefghij"), S("abcde"), true);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false);
+    test(S("abcdefghijklmnopqrst"), S(""), true);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
new file mode 100644
index 0000000..86f6a2d
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_oplt/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs < rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test("", S(""), false);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test("", S(""), false);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), false);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), false);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
new file mode 100644
index 0000000..b935da5
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_oplt/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs < rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), "", false);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), "", false);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", false);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", false);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
new file mode 100644
index 0000000..487e205
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<(const basic_string<charT,traits,Allocator>& lhs,
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs < rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""), false);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), false);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), false);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
new file mode 100644
index 0000000..2195940
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_oplt=/pointer_string.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const typename S::value_type* lhs, const S& rhs, bool x)
+{
+    assert((lhs <= rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test("", S(""), true);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test("", S(""), true);
+    test("", S("abcde"), true);
+    test("", S("abcdefghij"), true);
+    test("", S("abcdefghijklmnopqrst"), true);
+    test("abcde", S(""), false);
+    test("abcde", S("abcde"), true);
+    test("abcde", S("abcdefghij"), true);
+    test("abcde", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghij", S(""), false);
+    test("abcdefghij", S("abcde"), false);
+    test("abcdefghij", S("abcdefghij"), true);
+    test("abcdefghij", S("abcdefghijklmnopqrst"), true);
+    test("abcdefghijklmnopqrst", S(""), false);
+    test("abcdefghijklmnopqrst", S("abcde"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghij"), false);
+    test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
new file mode 100644
index 0000000..bb1bce8
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_oplt=/string_pointer.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const typename S::value_type* rhs, bool x)
+{
+    assert((lhs <= rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), "", true);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), "", true);
+    test(S(""), "abcde", true);
+    test(S(""), "abcdefghij", true);
+    test(S(""), "abcdefghijklmnopqrst", true);
+    test(S("abcde"), "", false);
+    test(S("abcde"), "abcde", true);
+    test(S("abcde"), "abcdefghij", true);
+    test(S("abcde"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghij"), "", false);
+    test(S("abcdefghij"), "abcde", false);
+    test(S("abcdefghij"), "abcdefghij", true);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
+    test(S("abcdefghijklmnopqrst"), "", false);
+    test(S("abcdefghijklmnopqrst"), "abcde", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp b/final/test/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
new file mode 100644
index 0000000..2b975f1
--- /dev/null
+++ b/final/test/strings/basic.string/string.nonmembers/string_oplt=/string_string.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<class charT, class traits, class Allocator>
+//   bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
+//                  const basic_string<charT,traits,Allocator>& rhs);
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& lhs, const S& rhs, bool x)
+{
+    assert((lhs <= rhs) == x);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""), true);
+    test(S(""), S("abcde"), true);
+    test(S(""), S("abcdefghij"), true);
+    test(S(""), S("abcdefghijklmnopqrst"), true);
+    test(S("abcde"), S(""), false);
+    test(S("abcde"), S("abcde"), true);
+    test(S("abcde"), S("abcdefghij"), true);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghij"), S(""), false);
+    test(S("abcdefghij"), S("abcde"), false);
+    test(S("abcdefghij"), S("abcdefghij"), true);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), true);
+    test(S("abcdefghijklmnopqrst"), S(""), false);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), false);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), true);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/nothing_to_do.pass.cpp b/final/test/strings/basic.string/string.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp b/final/test/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
new file mode 100644
index 0000000..3bdb800
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string.accessors/c_str.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT* c_str() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    typedef typename S::traits_type T;
+    const typename S::value_type* str = s.c_str();
+    if (s.size() > 0)
+    {
+        assert(T::compare(str, &s[0], s.size()) == 0);
+        assert(T::eq(str[s.size()], typename S::value_type()));
+    }
+    else
+        assert(T::eq(str[0], typename S::value_type()));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""));
+    test(S("abcde"));
+    test(S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""));
+    test(S("abcde"));
+    test(S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string.accessors/data.pass.cpp b/final/test/strings/basic.string/string.ops/string.accessors/data.pass.cpp
new file mode 100644
index 0000000..917248f
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string.accessors/data.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// const charT* data() const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s)
+{
+    typedef typename S::traits_type T;
+    const typename S::value_type* str = s.data();
+    if (s.size() > 0)
+    {
+        assert(T::compare(str, &s[0], s.size()) == 0);
+        assert(T::eq(str[s.size()], typename S::value_type()));
+    }
+    else
+        assert(T::eq(str[0], typename S::value_type()));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""));
+    test(S("abcde"));
+    test(S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""));
+    test(S("abcde"));
+    test(S("abcdefghij"));
+    test(S("abcdefghijklmnopqrst"));
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp b/final/test/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
new file mode 100644
index 0000000..6ba040d
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string.accessors/get_allocator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// allocator_type get_allocator() const;
+
+#include <string>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::allocator_type& a)
+{
+    assert(s.get_allocator() == a);
+}
+
+int main()
+{
+    {
+    typedef test_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(""), A());
+    test(S("abcde", A(1)), A(1));
+    test(S("abcdefghij", A(2)), A(2));
+    test(S("abcdefghijklmnopqrst", A(3)), A(3));
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef min_allocator<char> A;
+    typedef std::basic_string<char, std::char_traits<char>, A> S;
+    test(S(""), A());
+    test(S("abcde", A()), A());
+    test(S("abcdefghij", A()), A());
+    test(S("abcdefghijklmnopqrst", A()), A());
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp b/final/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
new file mode 100644
index 0000000..dda7428
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_compare/pointer.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(const charT *s) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, int x)
+{
+    assert(sign(s.compare(str)) == sign(x));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), "", 0);
+    test(S(""), "abcde", -5);
+    test(S(""), "abcdefghij", -10);
+    test(S(""), "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), "", 5);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdefghij", -5);
+    test(S("abcde"), "abcdefghijklmnopqrst", -15);
+    test(S("abcdefghij"), "", 10);
+    test(S("abcdefghij"), "abcde", 5);
+    test(S("abcdefghij"), "abcdefghij", 0);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghijklmnopqrst"), "", 20);
+    test(S("abcdefghijklmnopqrst"), "abcde", 15);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), "", 0);
+    test(S(""), "abcde", -5);
+    test(S(""), "abcdefghij", -10);
+    test(S(""), "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), "", 5);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdefghij", -5);
+    test(S("abcde"), "abcdefghijklmnopqrst", -15);
+    test(S("abcdefghij"), "", 10);
+    test(S("abcdefghij"), "abcde", 5);
+    test(S("abcdefghij"), "abcdefghij", 0);
+    test(S("abcdefghij"), "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghijklmnopqrst"), "", 20);
+    test(S("abcdefghijklmnopqrst"), "abcde", 15);
+    test(S("abcdefghijklmnopqrst"), "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", 0);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp b/final/test/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
new file mode 100644
index 0000000..9ed58a3
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos, size_type n1, const charT *s) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+     const typename S::value_type* str, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos1, n1, str)) == sign(x));
+        assert(pos1 <= s.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > s.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, "", 0);
+    test(S(""), 0, 0, "abcde", -5);
+    test(S(""), 0, 0, "abcdefghij", -10);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S(""), 0, 1, "", 0);
+    test(S(""), 0, 1, "abcde", -5);
+    test(S(""), 0, 1, "abcdefghij", -10);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", -20);
+    test(S(""), 1, 0, "", 0);
+    test(S(""), 1, 0, "abcde", 0);
+    test(S(""), 1, 0, "abcdefghij", 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 0);
+    test(S("abcde"), 0, 0, "", 0);
+    test(S("abcde"), 0, 0, "abcde", -5);
+    test(S("abcde"), 0, 0, "abcdefghij", -10);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 0, 1, "", 1);
+    test(S("abcde"), 0, 1, "abcde", -4);
+    test(S("abcde"), 0, 1, "abcdefghij", -9);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", -19);
+    test(S("abcde"), 0, 2, "", 2);
+    test(S("abcde"), 0, 2, "abcde", -3);
+    test(S("abcde"), 0, 2, "abcdefghij", -8);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", -18);
+    test(S("abcde"), 0, 4, "", 4);
+    test(S("abcde"), 0, 4, "abcde", -1);
+    test(S("abcde"), 0, 4, "abcdefghij", -6);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", -16);
+    test(S("abcde"), 0, 5, "", 5);
+    test(S("abcde"), 0, 5, "abcde", 0);
+    test(S("abcde"), 0, 5, "abcdefghij", -5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", -15);
+    test(S("abcde"), 0, 6, "", 5);
+    test(S("abcde"), 0, 6, "abcde", 0);
+    test(S("abcde"), 0, 6, "abcdefghij", -5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", -15);
+    test(S("abcde"), 1, 0, "", 0);
+    test(S("abcde"), 1, 0, "abcde", -5);
+    test(S("abcde"), 1, 0, "abcdefghij", -10);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 1, 1, "", 1);
+    test(S("abcde"), 1, 1, "abcde", 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 2, "", 2);
+    test(S("abcde"), 1, 2, "abcde", 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 3, "", 3);
+    test(S("abcde"), 1, 3, "abcde", 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 4, "", 4);
+    test(S("abcde"), 1, 4, "abcde", 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 1, 5, "", 4);
+    test(S("abcde"), 1, 5, "abcde", 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1);
+    test(S("abcde"), 2, 0, "", 0);
+    test(S("abcde"), 2, 0, "abcde", -5);
+    test(S("abcde"), 2, 0, "abcdefghij", -10);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 2, 1, "", 1);
+    test(S("abcde"), 2, 1, "abcde", 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 2, 2, "", 2);
+    test(S("abcde"), 2, 2, "abcde", 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 2, 3, "", 3);
+    test(S("abcde"), 2, 3, "abcde", 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 2, 4, "", 3);
+    test(S("abcde"), 2, 4, "abcde", 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 2);
+    test(S("abcde"), 4, 0, "", 0);
+    test(S("abcde"), 4, 0, "abcde", -5);
+    test(S("abcde"), 4, 0, "abcdefghij", -10);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 4, 1, "", 1);
+    test(S("abcde"), 4, 1, "abcde", 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 4);
+    test(S("abcde"), 4, 2, "", 1);
+    test(S("abcde"), 4, 2, "abcde", 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 4);
+    test(S("abcde"), 5, 0, "", 0);
+    test(S("abcde"), 5, 0, "abcde", -5);
+    test(S("abcde"), 5, 0, "abcdefghij", -10);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcde"), 5, 1, "", 0);
+    test(S("abcde"), 5, 1, "abcde", -5);
+    test(S("abcde"), 5, 1, "abcdefghij", -10);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", -20);
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 6, 0, "", 0);
+    test(S("abcde"), 6, 0, "abcde", 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0);
+    test(S("abcdefghij"), 0, 0, "", 0);
+    test(S("abcdefghij"), 0, 0, "abcde", -5);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 0, 1, "", 1);
+    test(S("abcdefghij"), 0, 1, "abcde", -4);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", -9);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", -19);
+    test(S("abcdefghij"), 0, 5, "", 5);
+    test(S("abcdefghij"), 0, 5, "abcde", 0);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", -5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", -15);
+    test(S("abcdefghij"), 0, 9, "", 9);
+    test(S("abcdefghij"), 0, 9, "abcde", 4);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", -1);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", -11);
+    test(S("abcdefghij"), 0, 10, "", 10);
+    test(S("abcdefghij"), 0, 10, "abcde", 5);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 0);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghij"), 0, 11, "", 10);
+    test(S("abcdefghij"), 0, 11, "abcde", 5);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 0);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghij"), 1, 0, "", 0);
+    test(S("abcdefghij"), 1, 0, "abcde", -5);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 1, 1, "", 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 4, "", 4);
+    test(S("abcdefghij"), 1, 4, "abcde", 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 8, "", 8);
+    test(S("abcdefghij"), 1, 8, "abcde", 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 9, "", 9);
+    test(S("abcdefghij"), 1, 9, "abcde", 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 1, 10, "", 9);
+    test(S("abcdefghij"), 1, 10, "abcde", 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghij"), 5, 0, "", 0);
+    test(S("abcdefghij"), 5, 0, "abcde", -5);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 5, 1, "", 1);
+    test(S("abcdefghij"), 5, 1, "abcde", 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 2, "", 2);
+    test(S("abcdefghij"), 5, 2, "abcde", 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 4, "", 4);
+    test(S("abcdefghij"), 5, 4, "abcde", 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 5, "", 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 5, 6, "", 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 5);
+    test(S("abcdefghij"), 9, 0, "", 0);
+    test(S("abcdefghij"), 9, 0, "abcde", -5);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 9, 1, "", 1);
+    test(S("abcdefghij"), 9, 1, "abcde", 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 9);
+    test(S("abcdefghij"), 9, 2, "", 1);
+    test(S("abcdefghij"), 9, 2, "abcde", 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 9);
+    test(S("abcdefghij"), 10, 0, "", 0);
+    test(S("abcdefghij"), 10, 0, "abcde", -5);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", -10);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 10, 1, "", 0);
+    test(S("abcdefghij"), 10, 1, "abcde", -5);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", -10);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghij"), 11, 0, "", 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0);
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", -20);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
new file mode 100644
index 0000000..ee804d9
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
@@ -0,0 +1,1323 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos, size_type n1, const charT *s, size_type n2) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos, typename S::size_type n1,
+     const typename S::value_type* str, typename S::size_type n2, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos, n1, str, n2)) == sign(x));
+        assert(pos <= s.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > s.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, "", 0, 0);
+    test(S(""), 0, 0, "abcde", 0, 0);
+    test(S(""), 0, 0, "abcde", 1, -1);
+    test(S(""), 0, 0, "abcde", 2, -2);
+    test(S(""), 0, 0, "abcde", 4, -4);
+    test(S(""), 0, 0, "abcde", 5, -5);
+    test(S(""), 0, 0, "abcdefghij", 0, 0);
+    test(S(""), 0, 0, "abcdefghij", 1, -1);
+    test(S(""), 0, 0, "abcdefghij", 5, -5);
+    test(S(""), 0, 0, "abcdefghij", 9, -9);
+    test(S(""), 0, 0, "abcdefghij", 10, -10);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S(""), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S(""), 0, 1, "", 0, 0);
+    test(S(""), 0, 1, "abcde", 0, 0);
+    test(S(""), 0, 1, "abcde", 1, -1);
+    test(S(""), 0, 1, "abcde", 2, -2);
+    test(S(""), 0, 1, "abcde", 4, -4);
+    test(S(""), 0, 1, "abcde", 5, -5);
+    test(S(""), 0, 1, "abcdefghij", 0, 0);
+    test(S(""), 0, 1, "abcdefghij", 1, -1);
+    test(S(""), 0, 1, "abcdefghij", 5, -5);
+    test(S(""), 0, 1, "abcdefghij", 9, -9);
+    test(S(""), 0, 1, "abcdefghij", 10, -10);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S(""), 0, 1, "abcdefghijklmnopqrst", 20, -20);
+    test(S(""), 1, 0, "", 0, 0);
+    test(S(""), 1, 0, "abcde", 0, 0);
+    test(S(""), 1, 0, "abcde", 1, 0);
+    test(S(""), 1, 0, "abcde", 2, 0);
+    test(S(""), 1, 0, "abcde", 4, 0);
+    test(S(""), 1, 0, "abcde", 5, 0);
+    test(S(""), 1, 0, "abcdefghij", 0, 0);
+    test(S(""), 1, 0, "abcdefghij", 1, 0);
+    test(S(""), 1, 0, "abcdefghij", 5, 0);
+    test(S(""), 1, 0, "abcdefghij", 9, 0);
+    test(S(""), 1, 0, "abcdefghij", 10, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S(""), 1, 0, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcde"), 0, 0, "", 0, 0);
+    test(S("abcde"), 0, 0, "abcde", 0, 0);
+    test(S("abcde"), 0, 0, "abcde", 1, -1);
+    test(S("abcde"), 0, 0, "abcde", 2, -2);
+    test(S("abcde"), 0, 0, "abcde", 4, -4);
+    test(S("abcde"), 0, 0, "abcde", 5, -5);
+    test(S("abcde"), 0, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 0, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 0, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 0, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 0, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 0, 1, "", 0, 1);
+    test(S("abcde"), 0, 1, "abcde", 0, 1);
+    test(S("abcde"), 0, 1, "abcde", 1, 0);
+    test(S("abcde"), 0, 1, "abcde", 2, -1);
+    test(S("abcde"), 0, 1, "abcde", 4, -3);
+    test(S("abcde"), 0, 1, "abcde", 5, -4);
+    test(S("abcde"), 0, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 0, 1, "abcdefghij", 1, 0);
+    test(S("abcde"), 0, 1, "abcdefghij", 5, -4);
+    test(S("abcde"), 0, 1, "abcdefghij", 9, -8);
+    test(S("abcde"), 0, 1, "abcdefghij", 10, -9);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test(S("abcde"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test(S("abcde"), 0, 2, "", 0, 2);
+    test(S("abcde"), 0, 2, "abcde", 0, 2);
+    test(S("abcde"), 0, 2, "abcde", 1, 1);
+    test(S("abcde"), 0, 2, "abcde", 2, 0);
+    test(S("abcde"), 0, 2, "abcde", 4, -2);
+    test(S("abcde"), 0, 2, "abcde", 5, -3);
+    test(S("abcde"), 0, 2, "abcdefghij", 0, 2);
+    test(S("abcde"), 0, 2, "abcdefghij", 1, 1);
+    test(S("abcde"), 0, 2, "abcdefghij", 5, -3);
+    test(S("abcde"), 0, 2, "abcdefghij", 9, -7);
+    test(S("abcde"), 0, 2, "abcdefghij", 10, -8);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 10, -8);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 19, -17);
+    test(S("abcde"), 0, 2, "abcdefghijklmnopqrst", 20, -18);
+    test(S("abcde"), 0, 4, "", 0, 4);
+    test(S("abcde"), 0, 4, "abcde", 0, 4);
+    test(S("abcde"), 0, 4, "abcde", 1, 3);
+    test(S("abcde"), 0, 4, "abcde", 2, 2);
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 0, 4, "abcde", 4, 0);
+    test(S("abcde"), 0, 4, "abcde", 5, -1);
+    test(S("abcde"), 0, 4, "abcdefghij", 0, 4);
+    test(S("abcde"), 0, 4, "abcdefghij", 1, 3);
+    test(S("abcde"), 0, 4, "abcdefghij", 5, -1);
+    test(S("abcde"), 0, 4, "abcdefghij", 9, -5);
+    test(S("abcde"), 0, 4, "abcdefghij", 10, -6);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 1, 3);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 10, -6);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 19, -15);
+    test(S("abcde"), 0, 4, "abcdefghijklmnopqrst", 20, -16);
+    test(S("abcde"), 0, 5, "", 0, 5);
+    test(S("abcde"), 0, 5, "abcde", 0, 5);
+    test(S("abcde"), 0, 5, "abcde", 1, 4);
+    test(S("abcde"), 0, 5, "abcde", 2, 3);
+    test(S("abcde"), 0, 5, "abcde", 4, 1);
+    test(S("abcde"), 0, 5, "abcde", 5, 0);
+    test(S("abcde"), 0, 5, "abcdefghij", 0, 5);
+    test(S("abcde"), 0, 5, "abcdefghij", 1, 4);
+    test(S("abcde"), 0, 5, "abcdefghij", 5, 0);
+    test(S("abcde"), 0, 5, "abcdefghij", 9, -4);
+    test(S("abcde"), 0, 5, "abcdefghij", 10, -5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 10, -5);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 19, -14);
+    test(S("abcde"), 0, 5, "abcdefghijklmnopqrst", 20, -15);
+    test(S("abcde"), 0, 6, "", 0, 5);
+    test(S("abcde"), 0, 6, "abcde", 0, 5);
+    test(S("abcde"), 0, 6, "abcde", 1, 4);
+    test(S("abcde"), 0, 6, "abcde", 2, 3);
+    test(S("abcde"), 0, 6, "abcde", 4, 1);
+    test(S("abcde"), 0, 6, "abcde", 5, 0);
+    test(S("abcde"), 0, 6, "abcdefghij", 0, 5);
+    test(S("abcde"), 0, 6, "abcdefghij", 1, 4);
+    test(S("abcde"), 0, 6, "abcdefghij", 5, 0);
+    test(S("abcde"), 0, 6, "abcdefghij", 9, -4);
+    test(S("abcde"), 0, 6, "abcdefghij", 10, -5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 10, -5);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 19, -14);
+    test(S("abcde"), 0, 6, "abcdefghijklmnopqrst", 20, -15);
+    test(S("abcde"), 1, 0, "", 0, 0);
+    test(S("abcde"), 1, 0, "abcde", 0, 0);
+    test(S("abcde"), 1, 0, "abcde", 1, -1);
+    test(S("abcde"), 1, 0, "abcde", 2, -2);
+    test(S("abcde"), 1, 0, "abcde", 4, -4);
+    test(S("abcde"), 1, 0, "abcde", 5, -5);
+    test(S("abcde"), 1, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 1, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 1, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 1, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 1, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 1, 1, "", 0, 1);
+    test(S("abcde"), 1, 1, "abcde", 0, 1);
+    test(S("abcde"), 1, 1, "abcde", 1, 1);
+    test(S("abcde"), 1, 1, "abcde", 2, 1);
+    test(S("abcde"), 1, 1, "abcde", 4, 1);
+    test(S("abcde"), 1, 1, "abcde", 5, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 1, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 2, "", 0, 2);
+    test(S("abcde"), 1, 2, "abcde", 0, 2);
+    test(S("abcde"), 1, 2, "abcde", 1, 1);
+    test(S("abcde"), 1, 2, "abcde", 2, 1);
+    test(S("abcde"), 1, 2, "abcde", 4, 1);
+    test(S("abcde"), 1, 2, "abcde", 5, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 0, 2);
+    test(S("abcde"), 1, 2, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 2, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 2, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 3, "", 0, 3);
+    test(S("abcde"), 1, 3, "abcde", 0, 3);
+    test(S("abcde"), 1, 3, "abcde", 1, 1);
+    test(S("abcde"), 1, 3, "abcde", 2, 1);
+    test(S("abcde"), 1, 3, "abcde", 4, 1);
+    test(S("abcde"), 1, 3, "abcde", 5, 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 0, 3);
+    test(S("abcde"), 1, 3, "abcdefghij", 1, 1);
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcde"), 1, 3, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 3, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 0, 3);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 3, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 4, "", 0, 4);
+    test(S("abcde"), 1, 4, "abcde", 0, 4);
+    test(S("abcde"), 1, 4, "abcde", 1, 1);
+    test(S("abcde"), 1, 4, "abcde", 2, 1);
+    test(S("abcde"), 1, 4, "abcde", 4, 1);
+    test(S("abcde"), 1, 4, "abcde", 5, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 0, 4);
+    test(S("abcde"), 1, 4, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 4, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 4, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 1, 5, "", 0, 4);
+    test(S("abcde"), 1, 5, "abcde", 0, 4);
+    test(S("abcde"), 1, 5, "abcde", 1, 1);
+    test(S("abcde"), 1, 5, "abcde", 2, 1);
+    test(S("abcde"), 1, 5, "abcde", 4, 1);
+    test(S("abcde"), 1, 5, "abcde", 5, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 0, 4);
+    test(S("abcde"), 1, 5, "abcdefghij", 1, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 5, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 9, 1);
+    test(S("abcde"), 1, 5, "abcdefghij", 10, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcde"), 1, 5, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcde"), 2, 0, "", 0, 0);
+    test(S("abcde"), 2, 0, "abcde", 0, 0);
+    test(S("abcde"), 2, 0, "abcde", 1, -1);
+    test(S("abcde"), 2, 0, "abcde", 2, -2);
+    test(S("abcde"), 2, 0, "abcde", 4, -4);
+    test(S("abcde"), 2, 0, "abcde", 5, -5);
+    test(S("abcde"), 2, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 2, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 2, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 2, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 2, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 2, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 2, 1, "", 0, 1);
+    test(S("abcde"), 2, 1, "abcde", 0, 1);
+    test(S("abcde"), 2, 1, "abcde", 1, 2);
+    test(S("abcde"), 2, 1, "abcde", 2, 2);
+    test(S("abcde"), 2, 1, "abcde", 4, 2);
+    test(S("abcde"), 2, 1, "abcde", 5, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 2, 1, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 1, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 1, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 2, 2, "", 0, 2);
+    test(S("abcde"), 2, 2, "abcde", 0, 2);
+    test(S("abcde"), 2, 2, "abcde", 1, 2);
+    test(S("abcde"), 2, 2, "abcde", 2, 2);
+    test(S("abcde"), 2, 2, "abcde", 4, 2);
+    test(S("abcde"), 2, 2, "abcde", 5, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 0, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 2, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 2, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 2, 3, "", 0, 3);
+    test(S("abcde"), 2, 3, "abcde", 0, 3);
+    test(S("abcde"), 2, 3, "abcde", 1, 2);
+    test(S("abcde"), 2, 3, "abcde", 2, 2);
+    test(S("abcde"), 2, 3, "abcde", 4, 2);
+    test(S("abcde"), 2, 3, "abcde", 5, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 0, 3);
+    test(S("abcde"), 2, 3, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 3, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 0, 3);
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 3, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 2, 4, "", 0, 3);
+    test(S("abcde"), 2, 4, "abcde", 0, 3);
+    test(S("abcde"), 2, 4, "abcde", 1, 2);
+    test(S("abcde"), 2, 4, "abcde", 2, 2);
+    test(S("abcde"), 2, 4, "abcde", 4, 2);
+    test(S("abcde"), 2, 4, "abcde", 5, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 0, 3);
+    test(S("abcde"), 2, 4, "abcdefghij", 1, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 5, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 9, 2);
+    test(S("abcde"), 2, 4, "abcdefghij", 10, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 0, 3);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 1, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 10, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 19, 2);
+    test(S("abcde"), 2, 4, "abcdefghijklmnopqrst", 20, 2);
+    test(S("abcde"), 4, 0, "", 0, 0);
+    test(S("abcde"), 4, 0, "abcde", 0, 0);
+    test(S("abcde"), 4, 0, "abcde", 1, -1);
+    test(S("abcde"), 4, 0, "abcde", 2, -2);
+    test(S("abcde"), 4, 0, "abcde", 4, -4);
+    test(S("abcde"), 4, 0, "abcde", 5, -5);
+    test(S("abcde"), 4, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 4, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 4, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 4, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 4, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 4, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 4, 1, "", 0, 1);
+    test(S("abcde"), 4, 1, "abcde", 0, 1);
+    test(S("abcde"), 4, 1, "abcde", 1, 4);
+    test(S("abcde"), 4, 1, "abcde", 2, 4);
+    test(S("abcde"), 4, 1, "abcde", 4, 4);
+    test(S("abcde"), 4, 1, "abcde", 5, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 0, 1);
+    test(S("abcde"), 4, 1, "abcdefghij", 1, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 5, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 9, 4);
+    test(S("abcde"), 4, 1, "abcdefghij", 10, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 10, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 19, 4);
+    test(S("abcde"), 4, 1, "abcdefghijklmnopqrst", 20, 4);
+    test(S("abcde"), 4, 2, "", 0, 1);
+    test(S("abcde"), 4, 2, "abcde", 0, 1);
+    test(S("abcde"), 4, 2, "abcde", 1, 4);
+    test(S("abcde"), 4, 2, "abcde", 2, 4);
+    test(S("abcde"), 4, 2, "abcde", 4, 4);
+    test(S("abcde"), 4, 2, "abcde", 5, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 0, 1);
+    test(S("abcde"), 4, 2, "abcdefghij", 1, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 5, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 9, 4);
+    test(S("abcde"), 4, 2, "abcdefghij", 10, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 10, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 19, 4);
+    test(S("abcde"), 4, 2, "abcdefghijklmnopqrst", 20, 4);
+    test(S("abcde"), 5, 0, "", 0, 0);
+    test(S("abcde"), 5, 0, "abcde", 0, 0);
+    test(S("abcde"), 5, 0, "abcde", 1, -1);
+    test(S("abcde"), 5, 0, "abcde", 2, -2);
+    test(S("abcde"), 5, 0, "abcde", 4, -4);
+    test(S("abcde"), 5, 0, "abcde", 5, -5);
+    test(S("abcde"), 5, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 5, 0, "abcdefghij", 1, -1);
+    test(S("abcde"), 5, 0, "abcdefghij", 5, -5);
+    test(S("abcde"), 5, 0, "abcdefghij", 9, -9);
+    test(S("abcde"), 5, 0, "abcdefghij", 10, -10);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 5, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcde"), 5, 1, "", 0, 0);
+    test(S("abcde"), 5, 1, "abcde", 0, 0);
+    test(S("abcde"), 5, 1, "abcde", 1, -1);
+    test(S("abcde"), 5, 1, "abcde", 2, -2);
+    test(S("abcde"), 5, 1, "abcde", 4, -4);
+    test(S("abcde"), 5, 1, "abcde", 5, -5);
+    test(S("abcde"), 5, 1, "abcdefghij", 0, 0);
+    test(S("abcde"), 5, 1, "abcdefghij", 1, -1);
+    test(S("abcde"), 5, 1, "abcdefghij", 5, -5);
+    test(S("abcde"), 5, 1, "abcdefghij", 9, -9);
+    test(S("abcde"), 5, 1, "abcdefghij", 10, -10);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcde"), 5, 1, "abcdefghijklmnopqrst", 20, -20);
+}
+
+template <class S>
+void test4()
+{
+    test(S("abcde"), 6, 0, "", 0, 0);
+    test(S("abcde"), 6, 0, "abcde", 0, 0);
+    test(S("abcde"), 6, 0, "abcde", 1, 0);
+    test(S("abcde"), 6, 0, "abcde", 2, 0);
+    test(S("abcde"), 6, 0, "abcde", 4, 0);
+    test(S("abcde"), 6, 0, "abcde", 5, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 0, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 1, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 5, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 9, 0);
+    test(S("abcde"), 6, 0, "abcdefghij", 10, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcde"), 6, 0, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcdefghij"), 0, 0, "", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 0, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 0, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 0, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 0, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 0, 1, "", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcde", 1, 0);
+    test(S("abcdefghij"), 0, 1, "abcde", 2, -1);
+    test(S("abcdefghij"), 0, 1, "abcde", 4, -3);
+    test(S("abcdefghij"), 0, 1, "abcde", 5, -4);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 1, 0);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 5, -4);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 9, -8);
+    test(S("abcdefghij"), 0, 1, "abcdefghij", 10, -9);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test(S("abcdefghij"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test(S("abcdefghij"), 0, 5, "", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcde", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcde", 1, 4);
+    test(S("abcdefghij"), 0, 5, "abcde", 2, 3);
+    test(S("abcdefghij"), 0, 5, "abcde", 4, 1);
+    test(S("abcdefghij"), 0, 5, "abcde", 5, 0);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 1, 4);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 5, 0);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 9, -4);
+    test(S("abcdefghij"), 0, 5, "abcdefghij", 10, -5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 1, 4);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 10, -5);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 19, -14);
+    test(S("abcdefghij"), 0, 5, "abcdefghijklmnopqrst", 20, -15);
+    test(S("abcdefghij"), 0, 9, "", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcde", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcde", 1, 8);
+    test(S("abcdefghij"), 0, 9, "abcde", 2, 7);
+    test(S("abcdefghij"), 0, 9, "abcde", 4, 5);
+    test(S("abcdefghij"), 0, 9, "abcde", 5, 4);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 1, 8);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 5, 4);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 9, 0);
+    test(S("abcdefghij"), 0, 9, "abcdefghij", 10, -1);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 1, 8);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 10, -1);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 19, -10);
+    test(S("abcdefghij"), 0, 9, "abcdefghijklmnopqrst", 20, -11);
+    test(S("abcdefghij"), 0, 10, "", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcde", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcde", 1, 9);
+    test(S("abcdefghij"), 0, 10, "abcde", 2, 8);
+    test(S("abcdefghij"), 0, 10, "abcde", 4, 6);
+    test(S("abcdefghij"), 0, 10, "abcde", 5, 5);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 0, 10, "abcdefghij", 10, 0);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 19, -9);
+    test(S("abcdefghij"), 0, 10, "abcdefghijklmnopqrst", 20, -10);
+    test(S("abcdefghij"), 0, 11, "", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcde", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcde", 1, 9);
+    test(S("abcdefghij"), 0, 11, "abcde", 2, 8);
+}
+
+template <class S>
+void test5()
+{
+    test(S("abcdefghij"), 0, 11, "abcde", 4, 6);
+    test(S("abcdefghij"), 0, 11, "abcde", 5, 5);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 0, 11, "abcdefghij", 10, 0);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 19, -9);
+    test(S("abcdefghij"), 0, 11, "abcdefghijklmnopqrst", 20, -10);
+    test(S("abcdefghij"), 1, 0, "", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 1, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 1, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 1, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 1, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 1, 1, "", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 1, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 4, "", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcde", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 4, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 4, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 4, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 4, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 8, "", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcde", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 8, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 8, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 8, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 0, 8);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 8, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 9, "", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcde", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 9, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 9, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 9, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 1, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 9, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 1, 10, "", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcde", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcde", 1, 1);
+    test(S("abcdefghij"), 1, 10, "abcde", 2, 1);
+    test(S("abcdefghij"), 1, 10, "abcde", 4, 1);
+    test(S("abcdefghij"), 1, 10, "abcde", 5, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 1, 1);
+}
+
+template <class S>
+void test6()
+{
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 5, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 9, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghij", 10, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghij"), 1, 10, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghij"), 5, 0, "", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 5, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 5, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 5, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 5, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 5, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 5, 1, "", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 1, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 1, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 1, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 1, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 2, "", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcde", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 2, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 2, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 2, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 0, 2);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 2, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 4, "", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcde", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 4, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 4, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 4, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 0, 4);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 4, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 5, "", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 5, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 5, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 5, 6, "", 0, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 0, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 1, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 2, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 4, 5);
+    test(S("abcdefghij"), 5, 6, "abcde", 5, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 0, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 1, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 5, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 9, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghij", 10, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 0, 5);
+}
+
+template <class S>
+void test7()
+{
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 1, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 10, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 19, 5);
+    test(S("abcdefghij"), 5, 6, "abcdefghijklmnopqrst", 20, 5);
+    test(S("abcdefghij"), 9, 0, "", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 9, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 9, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 9, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 9, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 9, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 9, 1, "", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcde", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcde", 1, 9);
+    test(S("abcdefghij"), 9, 1, "abcde", 2, 9);
+    test(S("abcdefghij"), 9, 1, "abcde", 4, 9);
+    test(S("abcdefghij"), 9, 1, "abcde", 5, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 5, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 9, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghij", 10, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 10, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 19, 9);
+    test(S("abcdefghij"), 9, 1, "abcdefghijklmnopqrst", 20, 9);
+    test(S("abcdefghij"), 9, 2, "", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcde", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcde", 1, 9);
+    test(S("abcdefghij"), 9, 2, "abcde", 2, 9);
+    test(S("abcdefghij"), 9, 2, "abcde", 4, 9);
+    test(S("abcdefghij"), 9, 2, "abcde", 5, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 1, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 5, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 9, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghij", 10, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 10, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 19, 9);
+    test(S("abcdefghij"), 9, 2, "abcdefghijklmnopqrst", 20, 9);
+    test(S("abcdefghij"), 10, 0, "", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcde", 1, -1);
+    test(S("abcdefghij"), 10, 0, "abcde", 2, -2);
+    test(S("abcdefghij"), 10, 0, "abcde", 4, -4);
+    test(S("abcdefghij"), 10, 0, "abcde", 5, -5);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 10, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 10, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 10, 1, "", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcde", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcde", 1, -1);
+    test(S("abcdefghij"), 10, 1, "abcde", 2, -2);
+    test(S("abcdefghij"), 10, 1, "abcde", 4, -4);
+    test(S("abcdefghij"), 10, 1, "abcde", 5, -5);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 1, -1);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 5, -5);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 9, -9);
+    test(S("abcdefghij"), 10, 1, "abcdefghij", 10, -10);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghij"), 10, 1, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghij"), 11, 0, "", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 1, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 2, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 4, 0);
+    test(S("abcdefghij"), 11, 0, "abcde", 5, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 1, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 5, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 9, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghij", 10, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcdefghij"), 11, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+template <class S>
+void test8()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 4, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcde", 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 9, -8);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghij", 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 19, -18);
+    test(S("abcdefghijklmnopqrst"), 0, 1, "abcdefghijklmnopqrst", 20, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 2, 8);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 4, 6);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcde", 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghij", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 19, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, "abcdefghijklmnopqrst", 20, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 2, 17);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 4, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcde", 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghij", 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, "abcdefghijklmnopqrst", 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcde", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 9, 11);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcde", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 9, 11);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, "abcdefghijklmnopqrst", 20, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 2, -2);
+}
+
+template <class S>
+void test9()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcde", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghij", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, "abcdefghijklmnopqrst", 20, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 1, -1);
+}
+
+template <class S>
+void test10()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcde", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghij", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, "abcdefghijklmnopqrst", 20, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 0, 0);
+}
+
+template <class S>
+void test11()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcde", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghij", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, "abcdefghijklmnopqrst", 20, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcde", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghij", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, "abcdefghijklmnopqrst", 20, 19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcde", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghij", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, "abcdefghijklmnopqrst", 20, -20);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcde", 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghij", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 19, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, "abcdefghijklmnopqrst", 20, 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp b/final/test/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
new file mode 100644
index 0000000..3deb617
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos1, size_type n1, const basic_string& str) const;
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+     const S& str, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos1, n1, str)) == sign(x));
+        assert(pos1 <= s.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > s.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, S(""), 0);
+    test(S(""), 0, 0, S("abcde"), -5);
+    test(S(""), 0, 0, S("abcdefghij"), -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S(""), 0, 1, S(""), 0);
+    test(S(""), 0, 1, S("abcde"), -5);
+    test(S(""), 0, 1, S("abcdefghij"), -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), -20);
+    test(S(""), 1, 0, S(""), 0);
+    test(S(""), 1, 0, S("abcde"), 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcde"), 0, 0, S(""), 0);
+    test(S("abcde"), 0, 0, S("abcde"), -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 0, 1, S(""), 1);
+    test(S("abcde"), 0, 1, S("abcde"), -4);
+    test(S("abcde"), 0, 1, S("abcdefghij"), -9);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+    test(S("abcde"), 0, 2, S(""), 2);
+    test(S("abcde"), 0, 2, S("abcde"), -3);
+    test(S("abcde"), 0, 2, S("abcdefghij"), -8);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), -18);
+    test(S("abcde"), 0, 4, S(""), 4);
+    test(S("abcde"), 0, 4, S("abcde"), -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), -6);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), -16);
+    test(S("abcde"), 0, 5, S(""), 5);
+    test(S("abcde"), 0, 5, S("abcde"), 0);
+    test(S("abcde"), 0, 5, S("abcdefghij"), -5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), -15);
+    test(S("abcde"), 0, 6, S(""), 5);
+    test(S("abcde"), 0, 6, S("abcde"), 0);
+    test(S("abcde"), 0, 6, S("abcdefghij"), -5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), -15);
+    test(S("abcde"), 1, 0, S(""), 0);
+    test(S("abcde"), 1, 0, S("abcde"), -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 1, 1, S(""), 1);
+    test(S("abcde"), 1, 1, S("abcde"), 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 2, S(""), 2);
+    test(S("abcde"), 1, 2, S("abcde"), 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 3, S(""), 3);
+    test(S("abcde"), 1, 3, S("abcde"), 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 4, S(""), 4);
+    test(S("abcde"), 1, 4, S("abcde"), 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 1, 5, S(""), 4);
+    test(S("abcde"), 1, 5, S("abcde"), 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcde"), 2, 0, S(""), 0);
+    test(S("abcde"), 2, 0, S("abcde"), -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 2, 1, S(""), 1);
+    test(S("abcde"), 2, 1, S("abcde"), 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 2, 2, S(""), 2);
+    test(S("abcde"), 2, 2, S("abcde"), 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 2, 3, S(""), 3);
+    test(S("abcde"), 2, 3, S("abcde"), 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 2, 4, S(""), 3);
+    test(S("abcde"), 2, 4, S("abcde"), 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 2);
+    test(S("abcde"), 4, 0, S(""), 0);
+    test(S("abcde"), 4, 0, S("abcde"), -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 4, 1, S(""), 1);
+    test(S("abcde"), 4, 1, S("abcde"), 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 4);
+    test(S("abcde"), 4, 2, S(""), 1);
+    test(S("abcde"), 4, 2, S("abcde"), 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 4);
+    test(S("abcde"), 5, 0, S(""), 0);
+    test(S("abcde"), 5, 0, S("abcde"), -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), 5, 1, S(""), 0);
+    test(S("abcde"), 5, 1, S("abcde"), -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), -20);
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), 6, 0, S(""), 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcdefghij"), 0, 0, S(""), 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 0, 1, S(""), 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), -4);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+    test(S("abcdefghij"), 0, 5, S(""), 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), -15);
+    test(S("abcdefghij"), 0, 9, S(""), 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), -11);
+    test(S("abcdefghij"), 0, 10, S(""), 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghij"), 0, 11, S(""), 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghij"), 1, 0, S(""), 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 1, 1, S(""), 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 4, S(""), 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 8, S(""), 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 9, S(""), 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 1, 10, S(""), 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghij"), 5, 0, S(""), 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 5, 1, S(""), 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 2, S(""), 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 4, S(""), 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 5, S(""), 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 5, 6, S(""), 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 5);
+    test(S("abcdefghij"), 9, 0, S(""), 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 9, 1, S(""), 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 9);
+    test(S("abcdefghij"), 9, 2, S(""), 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 9);
+    test(S("abcdefghij"), 10, 0, S(""), 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 10, 1, S(""), 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghij"), 11, 0, S(""), 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0);
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), -20);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
new file mode 100644
index 0000000..122e6e9
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
@@ -0,0 +1,5948 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(size_type pos1, size_type n1, const basic_string& str,
+//             size_type pos2, size_type n2=npos) const;
+//  the "=npos" was added in C++14
+
+#include <string>
+#include <stdexcept>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos1, typename S::size_type n1,
+     const S& str, typename S::size_type pos2, typename S::size_type n2, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
+        assert(pos1 <= s.size());
+        assert(pos2 <= str.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > s.size() || pos2 > str.size());
+    }
+}
+
+template <class S>
+void
+test_npos(const S& s, typename S::size_type pos1, typename S::size_type n1,
+     const S& str, typename S::size_type pos2, int x)
+{
+    try
+    {
+        assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
+        assert(pos1 <= s.size());
+        assert(pos2 <= str.size());
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos1 > s.size() || pos2 > str.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), 0, 0, S(""), 0, 0, 0);
+    test(S(""), 0, 0, S(""), 0, 1, 0);
+    test(S(""), 0, 0, S(""), 1, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 0, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 0, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 0, 2, -2);
+    test(S(""), 0, 0, S("abcde"), 0, 4, -4);
+    test(S(""), 0, 0, S("abcde"), 0, 5, -5);
+    test(S(""), 0, 0, S("abcde"), 0, 6, -5);
+    test(S(""), 0, 0, S("abcde"), 1, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 1, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 1, 2, -2);
+    test(S(""), 0, 0, S("abcde"), 1, 3, -3);
+    test(S(""), 0, 0, S("abcde"), 1, 4, -4);
+    test(S(""), 0, 0, S("abcde"), 1, 5, -4);
+    test(S(""), 0, 0, S("abcde"), 2, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 2, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 2, 2, -2);
+    test(S(""), 0, 0, S("abcde"), 2, 3, -3);
+    test(S(""), 0, 0, S("abcde"), 2, 4, -3);
+    test(S(""), 0, 0, S("abcde"), 4, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 4, 1, -1);
+    test(S(""), 0, 0, S("abcde"), 4, 2, -1);
+    test(S(""), 0, 0, S("abcde"), 5, 0, 0);
+    test(S(""), 0, 0, S("abcde"), 5, 1, 0);
+    test(S(""), 0, 0, S("abcde"), 6, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S(""), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S(""), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S(""), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S(""), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S(""), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S(""), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S(""), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S(""), 0, 1, S(""), 0, 0, 0);
+    test(S(""), 0, 1, S(""), 0, 1, 0);
+    test(S(""), 0, 1, S(""), 1, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 0, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 0, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 0, 2, -2);
+    test(S(""), 0, 1, S("abcde"), 0, 4, -4);
+    test(S(""), 0, 1, S("abcde"), 0, 5, -5);
+    test(S(""), 0, 1, S("abcde"), 0, 6, -5);
+    test(S(""), 0, 1, S("abcde"), 1, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 1, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 1, 2, -2);
+    test(S(""), 0, 1, S("abcde"), 1, 3, -3);
+    test(S(""), 0, 1, S("abcde"), 1, 4, -4);
+    test(S(""), 0, 1, S("abcde"), 1, 5, -4);
+    test(S(""), 0, 1, S("abcde"), 2, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 2, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 2, 2, -2);
+    test(S(""), 0, 1, S("abcde"), 2, 3, -3);
+    test(S(""), 0, 1, S("abcde"), 2, 4, -3);
+    test(S(""), 0, 1, S("abcde"), 4, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 4, 1, -1);
+    test(S(""), 0, 1, S("abcde"), 4, 2, -1);
+    test(S(""), 0, 1, S("abcde"), 5, 0, 0);
+    test(S(""), 0, 1, S("abcde"), 5, 1, 0);
+    test(S(""), 0, 1, S("abcde"), 6, 0, 0);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), 0, 1, S("abcdefghij"), 0, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 5, -5);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 9, -9);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 10, -10);
+    test(S(""), 0, 1, S("abcdefghij"), 0, 11, -10);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 4, -4);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 8, -8);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 9, -9);
+    test(S(""), 0, 1, S("abcdefghij"), 1, 10, -9);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 2, -2);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 4, -4);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S(""), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S(""), 0, 1, S("abcdefghij"), 9, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 9, 1, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 9, 2, -1);
+    test(S(""), 0, 1, S("abcdefghij"), 10, 0, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 10, 1, 0);
+    test(S(""), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S(""), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S(""), 1, 0, S(""), 0, 0, 0);
+    test(S(""), 1, 0, S(""), 0, 1, 0);
+    test(S(""), 1, 0, S(""), 1, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 4, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 5, 0);
+    test(S(""), 1, 0, S("abcde"), 0, 6, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 3, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 4, 0);
+    test(S(""), 1, 0, S("abcde"), 1, 5, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 3, 0);
+    test(S(""), 1, 0, S("abcde"), 2, 4, 0);
+    test(S(""), 1, 0, S("abcde"), 4, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 4, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 4, 2, 0);
+    test(S(""), 1, 0, S("abcde"), 5, 0, 0);
+    test(S(""), 1, 0, S("abcde"), 5, 1, 0);
+    test(S(""), 1, 0, S("abcde"), 6, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 5, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 9, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 10, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 0, 11, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 4, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 8, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 9, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 1, 10, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 2, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 4, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 5, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 5, 6, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 9, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 9, 2, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S(""), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+}
+
+template <class S>
+void test2()
+{
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S(""), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 0, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 0, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 0, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 0, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 0, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 0, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 0, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 0, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 0, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 0, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 0, 1);
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcde"), 0, 1, S("abcde"), 0, 1, 0);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 2, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 4, -3);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 5, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 0, 6, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 0, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 1, 0);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 5, -4);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 9, -8);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 10, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 0, 11, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 2, S(""), 0, 0, 2);
+    test(S("abcde"), 0, 2, S(""), 0, 1, 2);
+    test(S("abcde"), 0, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 2, 0);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 4, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 5, -3);
+    test(S("abcde"), 0, 2, S("abcde"), 0, 6, -3);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 2, S("abcde"), 4, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 2, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 2, S("abcde"), 5, 0, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 5, 1, 2);
+    test(S("abcde"), 0, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 5, -3);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 9, -7);
+}
+
+template <class S>
+void test4()
+{
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 10, -8);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 0, 11, -8);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcde"), 0, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 10, -8);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 19, -17);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 20, -18);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 0, 21, -18);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcde"), 0, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 4, S(""), 0, 0, 4);
+    test(S("abcde"), 0, 4, S(""), 0, 1, 4);
+    test(S("abcde"), 0, 4, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 1, 3);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 4, 0);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 5, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 0, 6, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 4, S("abcde"), 4, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 4, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 4, S("abcde"), 5, 0, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 5, 1, 4);
+    test(S("abcde"), 0, 4, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 1, 3);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 5, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 9, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 10, -6);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 0, 11, -6);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcde"), 0, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 1, 3);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 10, -6);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 19, -15);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 20, -16);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 0, 21, -16);
+}
+
+template <class S>
+void test5()
+{
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcde"), 0, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 5, S(""), 0, 0, 5);
+    test(S("abcde"), 0, 5, S(""), 0, 1, 5);
+    test(S("abcde"), 0, 5, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 2, 3);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 5, 0);
+    test(S("abcde"), 0, 5, S("abcde"), 0, 6, 0);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 5, S("abcde"), 4, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 5, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 5, S("abcde"), 5, 0, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 5, 1, 5);
+    test(S("abcde"), 0, 5, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 5, 0);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 9, -4);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 10, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 0, 11, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcde"), 0, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcde"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 0, 6, S(""), 0, 0, 5);
+    test(S("abcde"), 0, 6, S(""), 0, 1, 5);
+    test(S("abcde"), 0, 6, S(""), 1, 0, 0);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 2, 3);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 0, 6, S("abcde"), 0, 5, 0);
+}
+
+template <class S>
+void test6()
+{
+    test(S("abcde"), 0, 6, S("abcde"), 0, 6, 0);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 1, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 0, 6, S("abcde"), 4, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 4, 1, -4);
+    test(S("abcde"), 0, 6, S("abcde"), 4, 2, -4);
+    test(S("abcde"), 0, 6, S("abcde"), 5, 0, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 5, 1, 5);
+    test(S("abcde"), 0, 6, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 5, 0);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 9, -4);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 10, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 0, 11, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 8, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 9, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 1, 10, -1);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 1, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 2, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 4, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 9, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 9, 1, -9);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 9, 2, -9);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 10, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 10, 1, 5);
+    test(S("abcde"), 0, 6, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 10, -5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 19, -14);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 20, -15);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 0, 21, -15);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcde"), 0, 6, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 1, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 1, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 1, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 1, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 1, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 1, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 1, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 1, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 1, -1);
+}
+
+template <class S>
+void test7()
+{
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 1, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 1, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 1, 0);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 2, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 3, -2);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 4, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 1, 5, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 1, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 1, 0);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 4, -3);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 8, -7);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 9, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 1, 10, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+}
+
+template <class S>
+void test8()
+{
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 2, S(""), 0, 0, 2);
+    test(S("abcde"), 1, 2, S(""), 0, 1, 2);
+    test(S("abcde"), 1, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 2, 0);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 3, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 4, -2);
+    test(S("abcde"), 1, 2, S("abcde"), 1, 5, -2);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 2, S("abcde"), 4, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 2, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 2, S("abcde"), 5, 0, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 5, 1, 2);
+    test(S("abcde"), 1, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 4, -2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 8, -6);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 9, -7);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 1, 10, -7);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcde"), 1, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 9, -7);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 18, -16);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 19, -17);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 1, 20, -17);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcde"), 1, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 3, S(""), 0, 0, 3);
+    test(S("abcde"), 1, 3, S(""), 0, 1, 3);
+    test(S("abcde"), 1, 3, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 1, 2);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 2, 1);
+}
+
+template <class S>
+void test9()
+{
+    test(S("abcde"), 1, 3, S("abcde"), 1, 3, 0);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 4, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 1, 5, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 3, S("abcde"), 4, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 3, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 3, S("abcde"), 5, 0, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 5, 1, 3);
+    test(S("abcde"), 1, 3, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 1, 2);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 4, -1);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 8, -5);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 9, -6);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 1, 10, -6);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 9, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 10, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 10, 1, 3);
+    test(S("abcde"), 1, 3, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 1, 2);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 9, -6);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 18, -15);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 19, -16);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 1, 20, -16);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 0, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 20, 1, 3);
+    test(S("abcde"), 1, 3, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 4, S(""), 0, 0, 4);
+    test(S("abcde"), 1, 4, S(""), 0, 1, 4);
+    test(S("abcde"), 1, 4, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 2, 2);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 4, 0);
+    test(S("abcde"), 1, 4, S("abcde"), 1, 5, 0);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 4, S("abcde"), 4, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 4, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 4, S("abcde"), 5, 0, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 5, 1, 4);
+    test(S("abcde"), 1, 4, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 4, 0);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 8, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 9, -5);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 1, 10, -5);
+}
+
+template <class S>
+void test10()
+{
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcde"), 1, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcde"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 1, 5, S(""), 0, 0, 4);
+    test(S("abcde"), 1, 5, S(""), 0, 1, 4);
+    test(S("abcde"), 1, 5, S(""), 1, 0, 0);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 1, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 2, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 4, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 5, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 0, 6, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 2, 2);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 4, 0);
+    test(S("abcde"), 1, 5, S("abcde"), 1, 5, 0);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 1, 5, S("abcde"), 4, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 4, 1, -3);
+    test(S("abcde"), 1, 5, S("abcde"), 4, 2, -3);
+    test(S("abcde"), 1, 5, S("abcde"), 5, 0, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 5, 1, 4);
+    test(S("abcde"), 1, 5, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 1, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 5, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 9, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 10, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 0, 11, 1);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 4, 0);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 8, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 9, -5);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 1, 10, -5);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 1, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 2, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 5, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 5, 6, -4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 9, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 9, 1, -8);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 9, 2, -8);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 10, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 10, 1, 4);
+    test(S("abcde"), 1, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 9, -5);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 18, -14);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 19, -15);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 1, 20, -15);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 1, -9);
+}
+
+template <class S>
+void test11()
+{
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcde"), 1, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 2, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 2, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 2, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 2, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 2, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 2, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 2, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 2, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 2, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 2, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 2, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 2, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 0, 1);
+}
+
+template <class S>
+void test12()
+{
+    test(S("abcde"), 2, 1, S("abcde"), 2, 1, 0);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 2, -1);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 3, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 2, 4, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 2, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 4, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 10, 11, -8);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 2, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 2, S(""), 0, 0, 2);
+    test(S("abcde"), 2, 2, S(""), 0, 1, 2);
+    test(S("abcde"), 2, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 1, 1);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 2, 0);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 3, -1);
+    test(S("abcde"), 2, 2, S("abcde"), 2, 4, -1);
+    test(S("abcde"), 2, 2, S("abcde"), 4, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 2, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 2, S("abcde"), 5, 0, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 5, 1, 2);
+    test(S("abcde"), 2, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 4, -3);
+}
+
+template <class S>
+void test13()
+{
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 10, 11, -8);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcde"), 2, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 3, S(""), 0, 0, 3);
+    test(S("abcde"), 2, 3, S(""), 0, 1, 3);
+    test(S("abcde"), 2, 3, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 2, 1);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 3, 0);
+    test(S("abcde"), 2, 3, S("abcde"), 2, 4, 0);
+    test(S("abcde"), 2, 3, S("abcde"), 4, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 3, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 3, S("abcde"), 5, 0, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 5, 1, 3);
+    test(S("abcde"), 2, 3, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 4, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 9, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 10, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 10, 1, 3);
+    test(S("abcde"), 2, 3, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 10, 11, -8);
+}
+
+template <class S>
+void test14()
+{
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 0, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 20, 1, 3);
+    test(S("abcde"), 2, 3, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 2, 4, S(""), 0, 0, 3);
+    test(S("abcde"), 2, 4, S(""), 0, 1, 3);
+    test(S("abcde"), 2, 4, S(""), 1, 0, 0);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 1, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 2, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 4, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 5, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 0, 6, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 1, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 2, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 3, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 4, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 1, 5, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 2, 1);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 3, 0);
+    test(S("abcde"), 2, 4, S("abcde"), 2, 4, 0);
+    test(S("abcde"), 2, 4, S("abcde"), 4, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 4, 1, -2);
+    test(S("abcde"), 2, 4, S("abcde"), 4, 2, -2);
+    test(S("abcde"), 2, 4, S("abcde"), 5, 0, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 5, 1, 3);
+    test(S("abcde"), 2, 4, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 1, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 5, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 9, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 10, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 0, 11, 2);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 1, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 4, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 8, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 9, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 1, 10, 1);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 1, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 2, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 4, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 5, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 5, 6, -3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 9, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 9, 1, -7);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 9, 2, -7);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 10, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 10, 1, 3);
+    test(S("abcde"), 2, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 1, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 10, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 19, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 20, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 0, 21, 2);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 1, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 9, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 19, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 1, 20, 1);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 1, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 5, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 10, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 10, 11, -8);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 1, -17);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 19, 2, -17);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 0, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 20, 1, 3);
+    test(S("abcde"), 2, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 4, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 4, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 4, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 4, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 4, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 4, 0, S("abcde"), 2, 4, -3);
+}
+
+template <class S>
+void test15()
+{
+    test(S("abcde"), 4, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 4, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 4, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 4, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 4, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 4, 1, S(""), 0, 0, 1);
+    test(S("abcde"), 4, 1, S(""), 0, 1, 1);
+    test(S("abcde"), 4, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 2, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 4, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 5, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 0, 6, 4);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 2, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 3, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 4, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 1, 5, 3);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 2, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 3, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 2, 4, 2);
+    test(S("abcde"), 4, 1, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 4, 1, 0);
+    test(S("abcde"), 4, 1, S("abcde"), 4, 2, 0);
+    test(S("abcde"), 4, 1, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 4, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 5, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 9, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 10, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 0, 11, 4);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 4, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 8, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 9, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 1, 10, 3);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 2, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 4, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 5, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 5, 6, -1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 9, 1, -5);
+}
+
+template <class S>
+void test16()
+{
+    test(S("abcde"), 4, 1, S("abcdefghij"), 9, 2, -5);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 4, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 10, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 19, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 20, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 0, 21, 4);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 9, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 18, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 19, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 1, 20, 3);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 1, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 5, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 9, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 10, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 10, 11, -6);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 1, -15);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 19, 2, -15);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 4, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 4, 2, S(""), 0, 0, 1);
+    test(S("abcde"), 4, 2, S(""), 0, 1, 1);
+    test(S("abcde"), 4, 2, S(""), 1, 0, 0);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 1, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 2, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 4, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 5, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 0, 6, 4);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 1, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 2, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 3, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 4, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 1, 5, 3);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 1, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 2, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 3, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 2, 4, 2);
+    test(S("abcde"), 4, 2, S("abcde"), 4, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 4, 1, 0);
+    test(S("abcde"), 4, 2, S("abcde"), 4, 2, 0);
+    test(S("abcde"), 4, 2, S("abcde"), 5, 0, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 5, 1, 1);
+    test(S("abcde"), 4, 2, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 1, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 5, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 9, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 10, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 0, 11, 4);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 1, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 4, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 8, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 9, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 1, 10, 3);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 2, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 4, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 5, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 5, 6, -1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 9, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 9, 1, -5);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 9, 2, -5);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 10, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 10, 1, 1);
+    test(S("abcde"), 4, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 10, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 19, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 20, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 0, 21, 4);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 9, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 18, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 19, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 1, 20, 3);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 1, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 5, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 9, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 10, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 10, 11, -6);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 1, -15);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 19, 2, -15);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+}
+
+template <class S>
+void test17()
+{
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcde"), 4, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 5, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 5, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 5, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 5, 0, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 5, 0, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 5, 0, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 5, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 5, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 5, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 5, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 5, 1, S(""), 0, 0, 0);
+    test(S("abcde"), 5, 1, S(""), 0, 1, 0);
+    test(S("abcde"), 5, 1, S(""), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 2, -2);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 4, -4);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 5, -5);
+    test(S("abcde"), 5, 1, S("abcde"), 0, 6, -5);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 2, -2);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 3, -3);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 4, -4);
+    test(S("abcde"), 5, 1, S("abcde"), 1, 5, -4);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 2, -2);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 3, -3);
+    test(S("abcde"), 5, 1, S("abcde"), 2, 4, -3);
+    test(S("abcde"), 5, 1, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 4, 1, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 4, 2, -1);
+    test(S("abcde"), 5, 1, S("abcde"), 5, 0, 0);
+}
+
+template <class S>
+void test18()
+{
+    test(S("abcde"), 5, 1, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 5, 1, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 5, -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 10, -10);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 0, 11, -10);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 4, -4);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 8, -8);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 1, 10, -9);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 2, -2);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 9, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 9, 2, -1);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 5, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcde"), 6, 0, S(""), 0, 0, 0);
+    test(S("abcde"), 6, 0, S(""), 0, 1, 0);
+    test(S("abcde"), 6, 0, S(""), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 4, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 5, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 0, 6, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 3, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 4, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 1, 5, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 3, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 2, 4, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 4, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 4, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 4, 2, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 5, 0, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 5, 1, 0);
+    test(S("abcde"), 6, 0, S("abcde"), 6, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 5, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 0, 11, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 4, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 8, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 1, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 2, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 4, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 5, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 5, 6, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 9, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 9, 2, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghij"), 11, 0, 0);
+}
+
+template <class S>
+void test19()
+{
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcde"), 6, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 0, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 0, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S(""), 0, 1, 1);
+}
+
+template <class S>
+void test20()
+{
+    test(S("abcdefghij"), 0, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 1, 0);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 2, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 4, -3);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 5, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 0, 6, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 0, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 5, -4);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 9, -8);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 10, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 0, 11, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 5, S(""), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S(""), 0, 1, 5);
+    test(S("abcdefghij"), 0, 5, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 1, 4);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 2, 3);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 5, 0);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 0, 6, 0);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 4, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 5, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 5, 1, 5);
+    test(S("abcdefghij"), 0, 5, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 1, 4);
+}
+
+template <class S>
+void test21()
+{
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 5, 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 9, -4);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 10, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 0, 11, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 1, 4);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 10, -5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 19, -14);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 20, -15);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 0, 21, -15);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghij"), 0, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 9, S(""), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S(""), 0, 1, 9);
+    test(S("abcdefghij"), 0, 9, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 1, 8);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 2, 7);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 5, 4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 0, 6, 4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghij"), 0, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 1, 8);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 5, 4);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 9, 0);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 10, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 0, 11, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 1, 8);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 10, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 19, -10);
+}
+
+template <class S>
+void test22()
+{
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 20, -11);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 0, 21, -11);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghij"), 0, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 10, S(""), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S(""), 0, 1, 10);
+    test(S("abcdefghij"), 0, 10, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 2, 8);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 4, 6);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 4, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 5, 1, 10);
+    test(S("abcdefghij"), 0, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghij"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 0, 11, S(""), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S(""), 0, 1, 10);
+    test(S("abcdefghij"), 0, 11, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 2, 8);
+}
+
+template <class S>
+void test23()
+{
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 4, 6);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 3, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 1, 5, -1);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 1, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 3, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 2, 4, -2);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 4, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 4, 1, -4);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 4, 2, -4);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 5, 1, 10);
+    test(S("abcdefghij"), 0, 11, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 19, -9);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 20, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 0, 21, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghij"), 0, 11, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 1, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 1, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 0, 11, -10);
+}
+
+template <class S>
+void test24()
+{
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 1, 0);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 3, -2);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 4, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 1, 5, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 4, -3);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 8, -7);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 9, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 1, 10, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+}
+
+template <class S>
+void test25()
+{
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 4, S(""), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S(""), 0, 1, 4);
+    test(S("abcdefghij"), 1, 4, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 1, 3);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 2, 2);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 3, 1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 4, 0);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 1, 5, 0);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 4, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 5, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 5, 1, 4);
+    test(S("abcdefghij"), 1, 4, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 1, 3);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 4, 0);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 8, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 9, -5);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 1, 10, -5);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 1, 3);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 9, -5);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 18, -14);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 19, -15);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 1, 20, -15);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcdefghij"), 1, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 8, S(""), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S(""), 0, 1, 8);
+    test(S("abcdefghij"), 1, 8, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 0, 8);
+}
+
+template <class S>
+void test26()
+{
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 1, 7);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 2, 6);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 3, 5);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 4, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 5, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 5, 1, 8);
+    test(S("abcdefghij"), 1, 8, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 1, 7);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 8, 0);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 10, 1, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 1, 7);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 18, -10);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 19, -11);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 1, 20, -11);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 0, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 20, 1, 8);
+    test(S("abcdefghij"), 1, 8, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 9, S(""), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S(""), 0, 1, 9);
+    test(S("abcdefghij"), 1, 9, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 2, 7);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 3, 6);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 1, 5, 5);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghij"), 1, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 8, 1);
+}
+
+template <class S>
+void test27()
+{
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghij"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 1, 10, S(""), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S(""), 0, 1, 9);
+    test(S("abcdefghij"), 1, 10, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 2, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 4, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 0, 6, 1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 2, 7);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 3, 6);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 1, 5, 5);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 2, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 3, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 2, 4, -1);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 4, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 4, 1, -3);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 4, 2, -3);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 5, 1, 9);
+    test(S("abcdefghij"), 1, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 4, 5);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 8, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 18, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 19, -10);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 1, 20, -10);
+}
+
+template <class S>
+void test28()
+{
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghij"), 1, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 5, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 5, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 5, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 5, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 4, 4);
+}
+
+template <class S>
+void test29()
+{
+    test(S("abcdefghij"), 5, 1, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 1, 0);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 2, -1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 4, -3);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 5, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 2, S(""), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S(""), 0, 1, 2);
+    test(S("abcdefghij"), 5, 2, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 4, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 5, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 5, 1, 2);
+    test(S("abcdefghij"), 5, 2, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 1, 1);
+}
+
+template <class S>
+void test30()
+{
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 2, 0);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 4, -2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 5, -3);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 5, 6, -3);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 10, 1, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 0, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 20, 1, 2);
+    test(S("abcdefghij"), 5, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 4, S(""), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S(""), 0, 1, 4);
+    test(S("abcdefghij"), 5, 4, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 4, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 5, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 5, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 1, 3);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 2, 2);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 4, 0);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 5, -1);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 5, 6, -1);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 10, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 9, -5);
+}
+
+template <class S>
+void test31()
+{
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 0, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 20, 1, 4);
+    test(S("abcdefghij"), 5, 4, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 5, S(""), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S(""), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 2, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 4, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 5, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 2, 3);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 4, 1);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghij"), 5, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 5, 6, S(""), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S(""), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 2, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 4, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 0, 6, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 2, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 3, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 1, 5, 4);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 1, 3);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 2, 3);
+}
+
+template <class S>
+void test32()
+{
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 3, 3);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 2, 4, 3);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 4, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 4, 1, 1);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 4, 2, 1);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 5, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 9, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 0, 11, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 4, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 8, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 1, 10, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 2, 3);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 4, 1);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 1, -4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 9, 2, -4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 10, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 19, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 20, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 0, 21, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 1, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 9, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 18, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 19, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 1, 20, 4);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 1, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 9, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 1, -14);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 19, 2, -14);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghij"), 5, 6, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 9, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 9, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 9, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 5, 6, -5);
+}
+
+template <class S>
+void test33()
+{
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 9, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 9, 1, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 9, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 2, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 4, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 0, 6, 9);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 2, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 3, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 1, 5, 8);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 1, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 2, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 3, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 2, 4, 7);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 4, 1, 5);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 4, 2, 5);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 9, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 9, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 0, 11, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 8, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 1, 10, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 2, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 4, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 5, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 5, 6, 4);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 19, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 20, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 0, 21, 9);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 18, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 19, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 1, 20, 8);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 5, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 9, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 10, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 10, 11, -1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 1, -10);
+}
+
+template <class S>
+void test34()
+{
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 19, 2, -10);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 9, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 9, 2, S(""), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S(""), 0, 1, 1);
+    test(S("abcdefghij"), 9, 2, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 2, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 4, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 0, 6, 9);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 2, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 3, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 1, 5, 8);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 1, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 2, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 3, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 2, 4, 7);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 4, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 4, 1, 5);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 4, 2, 5);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 5, 1, 1);
+    test(S("abcdefghij"), 9, 2, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 5, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 9, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 0, 11, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 4, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 8, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 1, 10, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 1, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 2, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 4, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 5, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 5, 6, 4);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 1, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 10, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 19, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 20, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 0, 21, 9);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 9, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 18, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 19, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 1, 20, 8);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 5, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 9, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 10, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 10, 11, -1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 1, -10);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 19, 2, -10);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghij"), 9, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 10, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 10, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 4, 1, -1);
+}
+
+template <class S>
+void test35()
+{
+    test(S("abcdefghij"), 10, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 10, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 10, 1, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 10, 1, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 0, 6, -5);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 3, -3);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 1, 5, -4);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 3, -3);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 2, 4, -3);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 4, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 4, 2, -1);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 10, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 0, 0);
+}
+
+template <class S>
+void test36()
+{
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghij"), 11, 0, S(""), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S(""), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S(""), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 0, 6, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 3, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 1, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 3, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 2, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 4, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 4, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 8, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 4, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghij"), 11, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+}
+
+template <class S>
+void test37()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 0, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcde"), 6, 0, 0);
+}
+
+template <class S>
+void test38()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 0, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 19, -18);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 0, 21, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 4, 6);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 0, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 5, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 1, 9);
+}
+
+template <class S>
+void test39()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 19, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 20, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 0, 21, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 0, 6, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 5, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 0, 11, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 10, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 0, 21, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 20, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 19, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 0, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 0, 20);
+}
+
+template <class S>
+void test40()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 0, 6, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 5, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 9, 11);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 10, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 20, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 20, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 0, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 4, 16);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 0, 6, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 1, 5, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 1, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 2, 4, -2);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 4, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 5, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 9, 11);
+}
+
+template <class S>
+void test41()
+{
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 8, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 1, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 1, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 2, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 4, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 9, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 10, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 9, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 18, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 1, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 5, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 9, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 1, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 19, 2, -19);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 0, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 20, 1, 20);
+    test(S("abcdefghijklmnopqrst"), 0, 21, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+}
+
+template <class S>
+void test42()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 3, -2);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 1, 5, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 8, -7);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 1, 10, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 18, -17);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 19, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 1, 20, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 5, 1);
+}
+
+template <class S>
+void test43()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 2, 7);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 3, 6);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 1, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 8, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 18, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 19, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 1, 20, -10);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 0, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 2, 16);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 3, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 1, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 5, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 1, 17);
+}
+
+template <class S>
+void test44()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 8, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 10, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 19, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 1, 20, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 0, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 20, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 18, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 3, 16);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 1, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 5, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 8, 11);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 1, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 10, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 18, 1);
+}
+
+template <class S>
+void test45()
+{
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 20, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 19, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 4, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 0, 6, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 3, 16);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 1, 5, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 3, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 2, 4, -1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 1, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 4, 2, -3);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 5, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 5, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 0, 11, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 4, 15);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 8, 11);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 1, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 1, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 2, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 5, 6, -4);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 1, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 9, 2, -8);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 10, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 10, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 19, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 20, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 0, 21, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 18, 1);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 5, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 1, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 19, 2, -18);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 0, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 20, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 1, 20, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 2, -2);
+}
+
+template <class S>
+void test46()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 1, 10, 9);
+}
+
+template <class S>
+void test47()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 9, -8);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 10, 11, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 0, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 10, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 1, 4);
+}
+
+template <class S>
+void test48()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 9, -4);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 10, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 10, 11, -5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 0, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 20, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 5, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 0, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 5, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 5, 4);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 10, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 10, 11, -1);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 0, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 20, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 9, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 0, 10);
+}
+
+template <class S>
+void test49()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 5, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 4, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 10, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 4, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 0, 6, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 2, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 3, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 1, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 1, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 2, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 3, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 2, 4, 8);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 1, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 4, 2, 6);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 5, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 5, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 9, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 0, 11, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 4, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 8, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 1, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 1, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 2, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 4, 5);
+}
+
+template <class S>
+void test50()
+{
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 5, 6, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 9, 2, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 10, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 10, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 19, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 20, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 0, 21, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 18, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 19, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 1, 20, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 5, 5);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 9, 1);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 1, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 19, 2, -9);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 0, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 20, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 10, 11, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+}
+
+template <class S>
+void test51()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 0, 6, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 3, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 1, 5, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 3, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 2, 4, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 1, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 4, 2, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 0, 11, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 8, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 1, 10, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 1, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 2, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 5, 6, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 9, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 20, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 0, 21, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 18, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 19, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 1, 20, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 10, 11, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 0, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 2, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 4, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 0, 6, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 2, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 3, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 1, 5, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 1, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 2, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 3, 17);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 2, 4, 17);
+}
+
+template <class S>
+void test52()
+{
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 1, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 4, 2, 15);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 5, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 5, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 9, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 0, 11, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 4, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 8, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 1, 10, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 1, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 2, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 4, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 5, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 5, 6, 14);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 1, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 9, 2, 10);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 10, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 1, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 10, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 19, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 20, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 0, 21, 19);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 1, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 9, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 18, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 19, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 1, 20, 18);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 1, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 5, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 9, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 10, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 10, 11, 9);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 0, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 20, 1, 1);
+    test(S("abcdefghijklmnopqrst"), 19, 2, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 1, -1);
+}
+
+template <class S>
+void test53()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 0, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 1, 5, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 3, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 2, 4, -3);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 4, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 0, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 8, -8);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 1, 10, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 2, -2);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 4, -4);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 5, 6, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 9, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 20, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 0, 21, -20);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 18, -18);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 19, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 1, 20, -19);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 5, -5);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 9, -9);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 10, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 10, 11, -10);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 1, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 19, 2, -1);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 0, 0);
+}
+
+template <class S>
+void test54()
+{
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 20, 1, S("abcdefghijklmnopqrst"), 21, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S(""), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 0, 6, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 3, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 1, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 3, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 2, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 4, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcde"), 6, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 0, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 8, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 1, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 4, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 5, 6, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 9, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghij"), 11, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 0, 21, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 18, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 19, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 1, 20, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 5, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 9, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 10, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 10, 11, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 19, 2, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 0, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 20, 1, 0);
+    test(S("abcdefghijklmnopqrst"), 21, 0, S("abcdefghijklmnopqrst"), 21, 0, 0);
+}
+
+template<class S>
+void test55()
+{
+    test_npos(S(""), 0, 0, S(""), 0, 0);
+    test_npos(S(""), 0, 0, S("abcde"), 0, -5);
+    test_npos(S("abcde"), 0, 0, S("abcdefghij"), 0, -10);
+    test_npos(S("abcde"), 0, 0, S("abcdefghij"), 1, -9);
+    test_npos(S("abcde"), 0, 0, S("abcdefghij"), 5, -5);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    test12<S>();
+    test13<S>();
+    test14<S>();
+    test15<S>();
+    test16<S>();
+    test17<S>();
+    test18<S>();
+    test19<S>();
+    test20<S>();
+    test21<S>();
+    test22<S>();
+    test23<S>();
+    test24<S>();
+    test25<S>();
+    test26<S>();
+    test27<S>();
+    test28<S>();
+    test29<S>();
+    test30<S>();
+    test31<S>();
+    test32<S>();
+    test33<S>();
+    test34<S>();
+    test35<S>();
+    test36<S>();
+    test37<S>();
+    test38<S>();
+    test39<S>();
+    test40<S>();
+    test41<S>();
+    test42<S>();
+    test43<S>();
+    test44<S>();
+    test45<S>();
+    test46<S>();
+    test47<S>();
+    test48<S>();
+    test49<S>();
+    test50<S>();
+    test51<S>();
+    test52<S>();
+    test53<S>();
+    test54<S>();
+    test55<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    test4<S>();
+    test5<S>();
+    test6<S>();
+    test7<S>();
+    test8<S>();
+    test9<S>();
+    test10<S>();
+    test11<S>();
+    test12<S>();
+    test13<S>();
+    test14<S>();
+    test15<S>();
+    test16<S>();
+    test17<S>();
+    test18<S>();
+    test19<S>();
+    test20<S>();
+    test21<S>();
+    test22<S>();
+    test23<S>();
+    test24<S>();
+    test25<S>();
+    test26<S>();
+    test27<S>();
+    test28<S>();
+    test29<S>();
+    test30<S>();
+    test31<S>();
+    test32<S>();
+    test33<S>();
+    test34<S>();
+    test35<S>();
+    test36<S>();
+    test37<S>();
+    test38<S>();
+    test39<S>();
+    test40<S>();
+    test41<S>();
+    test42<S>();
+    test43<S>();
+    test44<S>();
+    test45<S>();
+    test46<S>();
+    test47<S>();
+    test48<S>();
+    test49<S>();
+    test50<S>();
+    test51<S>();
+    test52<S>();
+    test53<S>();
+    test54<S>();
+    test55<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_compare/string.pass.cpp b/final/test/strings/basic.string/string.ops/string_compare/string.pass.cpp
new file mode 100644
index 0000000..7de95a8
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_compare/string.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int compare(const basic_string& str) const
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int sign(int x)
+{
+    if (x == 0)
+        return 0;
+    if (x < 0)
+        return -1;
+    return 1;
+}
+
+template <class S>
+void
+test(const S& s, const S& str, int x)
+{
+    assert(sign(s.compare(str)) == sign(x));
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), -5);
+    test(S(""), S("abcdefghij"), -10);
+    test(S(""), S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), S(""), 5);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdefghij"), -5);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
+    test(S("abcdefghij"), S(""), 10);
+    test(S("abcdefghij"), S("abcde"), 5);
+    test(S("abcdefghij"), S("abcdefghij"), 0);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghijklmnopqrst"), S(""), 20);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), -5);
+    test(S(""), S("abcdefghij"), -10);
+    test(S(""), S("abcdefghijklmnopqrst"), -20);
+    test(S("abcde"), S(""), 5);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdefghij"), -5);
+    test(S("abcde"), S("abcdefghijklmnopqrst"), -15);
+    test(S("abcdefghij"), S(""), 10);
+    test(S("abcdefghij"), S("abcde"), 5);
+    test(S("abcdefghij"), S("abcdefghij"), 0);
+    test(S("abcdefghij"), S("abcdefghijklmnopqrst"), -10);
+    test(S("abcdefghijklmnopqrst"), S(""), 20);
+    test(S("abcdefghijklmnopqrst"), S("abcde"), 15);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghij"), 10);
+    test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), 0);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
new file mode 100644
index 0000000..590173e
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.not.of/char_size.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_not_of(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_first_not_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 'q', 0, S::npos);
+    test(S(""), 'q', 1, S::npos);
+    test(S("kitcj"), 'q', 0, 0);
+    test(S("qkamf"), 'q', 1, 1);
+    test(S("nhmko"), 'q', 2, 2);
+    test(S("tpsaf"), 'q', 4, 4);
+    test(S("lahfb"), 'q', 5, S::npos);
+    test(S("irkhs"), 'q', 6, S::npos);
+    test(S("gmfhdaipsr"), 'q', 0, 0);
+    test(S("kantesmpgj"), 'q', 1, 1);
+    test(S("odaftiegpm"), 'q', 5, 5);
+    test(S("oknlrstdpi"), 'q', 9, 9);
+    test(S("eolhfgpjqk"), 'q', 10, S::npos);
+    test(S("pcdrofikas"), 'q', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+    test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+
+    test(S(""), 'q', S::npos);
+    test(S("q"), 'q', S::npos);
+    test(S("qqq"), 'q', S::npos);
+    test(S("csope"), 'q', 0);
+    test(S("gfsmthlkon"), 'q', 0);
+    test(S("laenfsbridchgotmkqpj"), 'q', 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 'q', 0, S::npos);
+    test(S(""), 'q', 1, S::npos);
+    test(S("kitcj"), 'q', 0, 0);
+    test(S("qkamf"), 'q', 1, 1);
+    test(S("nhmko"), 'q', 2, 2);
+    test(S("tpsaf"), 'q', 4, 4);
+    test(S("lahfb"), 'q', 5, S::npos);
+    test(S("irkhs"), 'q', 6, S::npos);
+    test(S("gmfhdaipsr"), 'q', 0, 0);
+    test(S("kantesmpgj"), 'q', 1, 1);
+    test(S("odaftiegpm"), 'q', 5, 5);
+    test(S("oknlrstdpi"), 'q', 9, 9);
+    test(S("eolhfgpjqk"), 'q', 10, S::npos);
+    test(S("pcdrofikas"), 'q', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'q', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'q', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'q', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'q', 19, 19);
+    test(S("hkbgspofltajcnedqmri"), 'q', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'q', 21, S::npos);
+
+    test(S(""), 'q', S::npos);
+    test(S("q"), 'q', S::npos);
+    test(S("qqq"), 'q', S::npos);
+    test(S("csope"), 'q', 0);
+    test(S("gfsmthlkon"), 'q', 0);
+    test(S("laenfsbridchgotmkqpj"), 'q', 0);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..53d3a95
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, 0);
+    test(S("qanej"), "dfkap", 0, 0);
+    test(S("clbao"), "ihqrfebgad", 0, 0);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+    test(S("srdfq"), "", 1, 1);
+    test(S("oemth"), "ikcrq", 1, 1);
+    test(S("cdaih"), "dmajblfhsg", 1, 3);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+    test(S("cshmd"), "", 2, 2);
+    test(S("lhcdo"), "oebqi", 2, 2);
+    test(S("qnsoh"), "kojhpmbsfe", 2, S::npos);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+    test(S("fmtsp"), "", 4, 4);
+    test(S("khbpm"), "aobjd", 4, 4);
+    test(S("pbsji"), "pcbahntsje", 4, 4);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, S::npos);
+    test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, S::npos);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, 0);
+    test(S("daiprenocl"), "ashjd", 0, 2);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 1);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+    test(S("qpghtfbaji"), "", 1, 1);
+    test(S("gfshlcmdjr"), "nadkh", 1, 1);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 4);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+    test(S("crnklpmegd"), "", 5, 5);
+    test(S("jsbtafedoc"), "prqgn", 5, 5);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 6);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+    test(S("lmofqdhpki"), "", 9, 9);
+    test(S("hnefkqimca"), "rtjpa", 9, S::npos);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, S::npos);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 1);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 3);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 11);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 13);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, S::npos);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", 0);
+    test(S("lahfb"), "irkhs", 0);
+    test(S("gmfhd"), "kantesmpgj", 2);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+    test(S("eolhfgpjqk"), "", 0);
+    test(S("nbatdlmekr"), "bnrpe", 2);
+    test(S("jdmciepkaq"), "jtdaefblso", 2);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), "", 0);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 0);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 1);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..14ac4b2
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.not.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, 0);
+    test(S("binja"), "gfsrt", 0, 0, 0);
+    test(S("latkm"), "pfsoc", 0, 1, 0);
+    test(S("lecfr"), "tpflm", 0, 2, 0);
+    test(S("eqkst"), "sgkec", 0, 4, 1);
+    test(S("cdafr"), "romds", 0, 5, 0);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+    test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 1);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+    test(S("clrgb"), "", 1, 0, 1);
+    test(S("tjmek"), "osmia", 1, 0, 1);
+    test(S("bgstp"), "ckonl", 1, 1, 1);
+    test(S("hstrk"), "ilcaj", 1, 2, 1);
+    test(S("kmspj"), "lasiq", 1, 4, 1);
+    test(S("tjboh"), "kfqmr", 1, 5, 1);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 3);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+    test(S("ndrhl"), "", 2, 0, 2);
+    test(S("mrecp"), "otkgb", 2, 0, 2);
+    test(S("qlasf"), "cqsjl", 2, 1, 2);
+    test(S("smaqd"), "dpifl", 2, 2, 2);
+    test(S("hjeni"), "oapht", 2, 4, 2);
+    test(S("ocmfj"), "cifts", 2, 5, 2);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+    test(S("fklad"), "tpksqhamle", 2, 1, 2);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 3);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 3);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+    test(S("cjgao"), "", 4, 0, 4);
+    test(S("kjplq"), "mabns", 4, 0, 4);
+    test(S("herni"), "bdnrp", 4, 1, 4);
+    test(S("tadrb"), "scidp", 4, 2, 4);
+    test(S("pkfeo"), "agbjl", 4, 4, 4);
+    test(S("hoser"), "jfmpr", 4, 5, S::npos);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, S::npos);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, S::npos);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, S::npos);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, S::npos);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, S::npos);
+    test(S("ktdor"), "kipnf", 5, 5, S::npos);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+    test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, S::npos);
+    test(S("bhlki"), "heatr", 6, 5, S::npos);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+    test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, 0);
+    test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 2);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 4);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 1);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+    test(S("shbcqnmoar"), "", 1, 0, 1);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 2);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 4);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 3);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 5);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 5);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 5);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+    test(S("ectnhskflp"), "", 5, 0, 5);
+    test(S("fgtianblpq"), "pijag", 5, 0, 5);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+    test(S("astedncjhk"), "qcloh", 5, 2, 5);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 6);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 6);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 6);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 8);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+    test(S("shoiedtcjb"), "", 9, 0, 9);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+    test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, S::npos);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, S::npos);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, S::npos);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+    test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+    test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 11);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 2);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 2);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 3);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 2);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 2);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 13);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 11);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 11);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 11);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 11);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, S::npos);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, S::npos);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, S::npos);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp
new file mode 100644
index 0000000..4fb072f
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.not.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_not_of(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_first_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, 0);
+    test(S("qanej"), S("dfkap"), 0, 0);
+    test(S("clbao"), S("ihqrfebgad"), 0, 0);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+    test(S("srdfq"), S(""), 1, 1);
+    test(S("oemth"), S("ikcrq"), 1, 1);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 3);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+    test(S("cshmd"), S(""), 2, 2);
+    test(S("lhcdo"), S("oebqi"), 2, 2);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, S::npos);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+    test(S("fmtsp"), S(""), 4, 4);
+    test(S("khbpm"), S("aobjd"), 4, 4);
+    test(S("pbsji"), S("pcbahntsje"), 4, 4);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, S::npos);
+    test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, S::npos);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, 0);
+    test(S("daiprenocl"), S("ashjd"), 0, 2);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 1);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+    test(S("qpghtfbaji"), S(""), 1, 1);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 4);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+    test(S("crnklpmegd"), S(""), 5, 5);
+    test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 6);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+    test(S("lmofqdhpki"), S(""), 9, 9);
+    test(S("hnefkqimca"), S("rtjpa"), 9, S::npos);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 1);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 3);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 11);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 13);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, S::npos);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), 0);
+    test(S("lahfb"), S("irkhs"), 0);
+    test(S("gmfhd"), S("kantesmpgj"), 2);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+    test(S("eolhfgpjqk"), S(""), 0);
+    test(S("nbatdlmekr"), S("bnrpe"), 2);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 2);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), 0);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 0);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 1);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
new file mode 100644
index 0000000..32d0e86
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.of/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_of(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_first_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 'e', 0, S::npos);
+    test(S(""), 'e', 1, S::npos);
+    test(S("kitcj"), 'e', 0, S::npos);
+    test(S("qkamf"), 'e', 1, S::npos);
+    test(S("nhmko"), 'e', 2, S::npos);
+    test(S("tpsaf"), 'e', 4, S::npos);
+    test(S("lahfb"), 'e', 5, S::npos);
+    test(S("irkhs"), 'e', 6, S::npos);
+    test(S("gmfhdaipsr"), 'e', 0, S::npos);
+    test(S("kantesmpgj"), 'e', 1, 4);
+    test(S("odaftiegpm"), 'e', 5, 6);
+    test(S("oknlrstdpi"), 'e', 9, S::npos);
+    test(S("eolhfgpjqk"), 'e', 10, S::npos);
+    test(S("pcdrofikas"), 'e', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+    test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+    test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+    test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+    test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+
+    test(S(""), 'e', S::npos);
+    test(S("csope"), 'e', 4);
+    test(S("gfsmthlkon"), 'e', S::npos);
+    test(S("laenfsbridchgotmkqpj"), 'e', 2);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 'e', 0, S::npos);
+    test(S(""), 'e', 1, S::npos);
+    test(S("kitcj"), 'e', 0, S::npos);
+    test(S("qkamf"), 'e', 1, S::npos);
+    test(S("nhmko"), 'e', 2, S::npos);
+    test(S("tpsaf"), 'e', 4, S::npos);
+    test(S("lahfb"), 'e', 5, S::npos);
+    test(S("irkhs"), 'e', 6, S::npos);
+    test(S("gmfhdaipsr"), 'e', 0, S::npos);
+    test(S("kantesmpgj"), 'e', 1, 4);
+    test(S("odaftiegpm"), 'e', 5, 6);
+    test(S("oknlrstdpi"), 'e', 9, S::npos);
+    test(S("eolhfgpjqk"), 'e', 10, S::npos);
+    test(S("pcdrofikas"), 'e', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'e', 0, 7);
+    test(S("bnrpehidofmqtcksjgla"), 'e', 1, 4);
+    test(S("jdmciepkaqgotsrfnhlb"), 'e', 10, S::npos);
+    test(S("jtdaefblsokrmhpgcnqi"), 'e', 19, S::npos);
+    test(S("hkbgspofltajcnedqmri"), 'e', 20, S::npos);
+    test(S("oselktgbcapndfjihrmq"), 'e', 21, S::npos);
+
+    test(S(""), 'e', S::npos);
+    test(S("csope"), 'e', 4);
+    test(S("gfsmthlkon"), 'e', S::npos);
+    test(S("laenfsbridchgotmkqpj"), 'e', 2);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..6dd176d
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.of/pointer_size.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_first_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, S::npos);
+    test(S("qanej"), "dfkap", 0, 1);
+    test(S("clbao"), "ihqrfebgad", 0, 2);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+    test(S("srdfq"), "", 1, S::npos);
+    test(S("oemth"), "ikcrq", 1, S::npos);
+    test(S("cdaih"), "dmajblfhsg", 1, 1);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+    test(S("cshmd"), "", 2, S::npos);
+    test(S("lhcdo"), "oebqi", 2, 4);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+    test(S("fmtsp"), "", 4, S::npos);
+    test(S("khbpm"), "aobjd", 4, S::npos);
+    test(S("pbsji"), "pcbahntsje", 4, S::npos);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, S::npos);
+    test(S("onmje"), "fbslrjiqkm", 5, S::npos);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, S::npos);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, S::npos);
+    test(S("daiprenocl"), "ashjd", 0, 0);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+    test(S("qpghtfbaji"), "", 1, S::npos);
+    test(S("gfshlcmdjr"), "nadkh", 1, 3);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+    test(S("crnklpmegd"), "", 5, S::npos);
+    test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+    test(S("lmofqdhpki"), "", 9, S::npos);
+    test(S("hnefkqimca"), "rtjpa", 9, 9);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, S::npos);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, S::npos);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, S::npos);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, S::npos);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, S::npos);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 3);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 3);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+    test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, S::npos);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", S::npos);
+    test(S("lahfb"), "irkhs", 2);
+    test(S("gmfhd"), "kantesmpgj", 0);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", 0);
+    test(S("eolhfgpjqk"), "", S::npos);
+    test(S("nbatdlmekr"), "bnrpe", 0);
+    test(S("jdmciepkaq"), "jtdaefblso", 0);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 0);
+    test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 1);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 0);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..9e98a6a
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, S::npos);
+    test(S("binja"), "gfsrt", 0, 0, S::npos);
+    test(S("latkm"), "pfsoc", 0, 1, S::npos);
+    test(S("lecfr"), "tpflm", 0, 2, S::npos);
+    test(S("eqkst"), "sgkec", 0, 4, 0);
+    test(S("cdafr"), "romds", 0, 5, 1);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+    test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 1);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+    test(S("clrgb"), "", 1, 0, S::npos);
+    test(S("tjmek"), "osmia", 1, 0, S::npos);
+    test(S("bgstp"), "ckonl", 1, 1, S::npos);
+    test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+    test(S("kmspj"), "lasiq", 1, 4, 2);
+    test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 3);
+    test(S("gfcql"), "skbgtahqej", 1, 5, S::npos);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 2);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 4);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+    test(S("ndrhl"), "", 2, 0, S::npos);
+    test(S("mrecp"), "otkgb", 2, 0, S::npos);
+    test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+    test(S("smaqd"), "dpifl", 2, 2, 4);
+    test(S("hjeni"), "oapht", 2, 4, S::npos);
+    test(S("ocmfj"), "cifts", 2, 5, 3);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+    test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 3);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 3);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+    test(S("cjgao"), "", 4, 0, S::npos);
+    test(S("kjplq"), "mabns", 4, 0, S::npos);
+    test(S("herni"), "bdnrp", 4, 1, S::npos);
+    test(S("tadrb"), "scidp", 4, 2, S::npos);
+    test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+    test(S("hoser"), "jfmpr", 4, 5, 4);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, S::npos);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, S::npos);
+    test(S("ktdor"), "kipnf", 5, 5, S::npos);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, S::npos);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, S::npos);
+    test(S("jcons"), "ledihrsgpf", 5, 10, S::npos);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, S::npos);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, S::npos);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, S::npos);
+    test(S("bhlki"), "heatr", 6, 5, S::npos);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, S::npos);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, S::npos);
+    test(S("jblqp"), "njolbmspac", 6, 10, S::npos);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, S::npos);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+    test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 8);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 8);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 1);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 3);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 5);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 1);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 4);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+    test(S("shbcqnmoar"), "", 1, 0, S::npos);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 4);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 4);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+    test(S("ectnhskflp"), "", 5, 0, S::npos);
+    test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+    test(S("astedncjhk"), "qcloh", 5, 2, 6);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, S::npos);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 6);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 7);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, S::npos);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+    test(S("shoiedtcjb"), "", 9, 0, S::npos);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+    test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, S::npos);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, S::npos);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, S::npos);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, S::npos);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, S::npos);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, S::npos);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, S::npos);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, S::npos);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, S::npos);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, S::npos);
+    test(S("beanrfodgj"), "odpte", 10, 5, S::npos);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, S::npos);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, S::npos);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, S::npos);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, S::npos);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, S::npos);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, S::npos);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, S::npos);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, S::npos);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, S::npos);
+    test(S("qghptonrea"), "eaqkl", 11, 5, S::npos);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, S::npos);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, S::npos);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, S::npos);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, S::npos);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, S::npos);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 4);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 3);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 3);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 3);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 19);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 2);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 2);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 2);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 16);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 1);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 6);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 6);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 19);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 4);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 7);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 12);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, S::npos);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 15);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, S::npos);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 11);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 11);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 18);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, S::npos);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, S::npos);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, S::npos);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, S::npos);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, S::npos);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, S::npos);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, S::npos);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, S::npos);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, S::npos);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, S::npos);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, S::npos);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, S::npos);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, S::npos);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, S::npos);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, S::npos);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, S::npos);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, S::npos);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, S::npos);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, S::npos);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, S::npos);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, S::npos);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, S::npos);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, S::npos);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, S::npos);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, S::npos);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, S::npos);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, S::npos);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, S::npos);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, S::npos);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, S::npos);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp
new file mode 100644
index 0000000..e409edc
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.first.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_first_of(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_first_of(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_first_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, S::npos);
+    test(S("qanej"), S("dfkap"), 0, 1);
+    test(S("clbao"), S("ihqrfebgad"), 0, 2);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+    test(S("srdfq"), S(""), 1, S::npos);
+    test(S("oemth"), S("ikcrq"), 1, S::npos);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+    test(S("cshmd"), S(""), 2, S::npos);
+    test(S("lhcdo"), S("oebqi"), 2, 4);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+    test(S("fmtsp"), S(""), 4, S::npos);
+    test(S("khbpm"), S("aobjd"), 4, S::npos);
+    test(S("pbsji"), S("pcbahntsje"), 4, S::npos);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, S::npos);
+    test(S("onmje"), S("fbslrjiqkm"), 5, S::npos);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, S::npos);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, S::npos);
+    test(S("daiprenocl"), S("ashjd"), 0, 0);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+    test(S("qpghtfbaji"), S(""), 1, S::npos);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 3);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+    test(S("crnklpmegd"), S(""), 5, S::npos);
+    test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+    test(S("lmofqdhpki"), S(""), 9, S::npos);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, S::npos);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, S::npos);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, S::npos);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, S::npos);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, S::npos);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 3);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 3);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, S::npos);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, S::npos);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, S::npos);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, S::npos);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, S::npos);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), S::npos);
+    test(S("lahfb"), S("irkhs"), 2);
+    test(S("gmfhd"), S("kantesmpgj"), 0);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 0);
+    test(S("eolhfgpjqk"), S(""), S::npos);
+    test(S("nbatdlmekr"), S("bnrpe"), 0);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 0);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 0);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 1);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 0);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
new file mode 100644
index 0000000..b130f92
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.not.of/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_not_of(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_last_not_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 'i', 0, S::npos);
+    test(S(""), 'i', 1, S::npos);
+    test(S("kitcj"), 'i', 0, 0);
+    test(S("qkamf"), 'i', 1, 1);
+    test(S("nhmko"), 'i', 2, 2);
+    test(S("tpsaf"), 'i', 4, 4);
+    test(S("lahfb"), 'i', 5, 4);
+    test(S("irkhs"), 'i', 6, 4);
+    test(S("gmfhdaipsr"), 'i', 0, 0);
+    test(S("kantesmpgj"), 'i', 1, 1);
+    test(S("odaftiegpm"), 'i', 5, 4);
+    test(S("oknlrstdpi"), 'i', 9, 8);
+    test(S("eolhfgpjqk"), 'i', 10, 9);
+    test(S("pcdrofikas"), 'i', 11, 9);
+    test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+    test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+    test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+
+    test(S(""), 'i', S::npos);
+    test(S("csope"), 'i', 4);
+    test(S("gfsmthlkon"), 'i', 9);
+    test(S("laenfsbridchgotmkqpj"), 'i', 19);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 'i', 0, S::npos);
+    test(S(""), 'i', 1, S::npos);
+    test(S("kitcj"), 'i', 0, 0);
+    test(S("qkamf"), 'i', 1, 1);
+    test(S("nhmko"), 'i', 2, 2);
+    test(S("tpsaf"), 'i', 4, 4);
+    test(S("lahfb"), 'i', 5, 4);
+    test(S("irkhs"), 'i', 6, 4);
+    test(S("gmfhdaipsr"), 'i', 0, 0);
+    test(S("kantesmpgj"), 'i', 1, 1);
+    test(S("odaftiegpm"), 'i', 5, 4);
+    test(S("oknlrstdpi"), 'i', 9, 8);
+    test(S("eolhfgpjqk"), 'i', 10, 9);
+    test(S("pcdrofikas"), 'i', 11, 9);
+    test(S("nbatdlmekrgcfqsophij"), 'i', 0, 0);
+    test(S("bnrpehidofmqtcksjgla"), 'i', 1, 1);
+    test(S("jdmciepkaqgotsrfnhlb"), 'i', 10, 10);
+    test(S("jtdaefblsokrmhpgcnqi"), 'i', 19, 18);
+    test(S("hkbgspofltajcnedqmri"), 'i', 20, 18);
+    test(S("oselktgbcapndfjihrmq"), 'i', 21, 19);
+
+    test(S(""), 'i', S::npos);
+    test(S("csope"), 'i', 4);
+    test(S("gfsmthlkon"), 'i', 9);
+    test(S("laenfsbridchgotmkqpj"), 'i', 19);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..3e6bd9d
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, 0);
+    test(S("qanej"), "dfkap", 0, 0);
+    test(S("clbao"), "ihqrfebgad", 0, 0);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, S::npos);
+    test(S("srdfq"), "", 1, 1);
+    test(S("oemth"), "ikcrq", 1, 1);
+    test(S("cdaih"), "dmajblfhsg", 1, 0);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, S::npos);
+    test(S("cshmd"), "", 2, 2);
+    test(S("lhcdo"), "oebqi", 2, 2);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 1);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, S::npos);
+    test(S("fmtsp"), "", 4, 4);
+    test(S("khbpm"), "aobjd", 4, 4);
+    test(S("pbsji"), "pcbahntsje", 4, 4);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, S::npos);
+    test(S("eqmpa"), "", 5, 4);
+    test(S("omigs"), "kocgb", 5, 4);
+    test(S("onmje"), "fbslrjiqkm", 5, 4);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, S::npos);
+    test(S("schfa"), "", 6, 4);
+    test(S("igdsc"), "qngpd", 6, 4);
+    test(S("brqgo"), "rodhqklgmb", 6, S::npos);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, S::npos);
+    test(S("hcjitbfapl"), "", 0, 0);
+    test(S("daiprenocl"), "ashjd", 0, S::npos);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, S::npos);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, S::npos);
+    test(S("qpghtfbaji"), "", 1, 1);
+    test(S("gfshlcmdjr"), "nadkh", 1, 1);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 0);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, S::npos);
+    test(S("crnklpmegd"), "", 5, 5);
+    test(S("jsbtafedoc"), "prqgn", 5, 5);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 4);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, S::npos);
+    test(S("lmofqdhpki"), "", 9, 9);
+    test(S("hnefkqimca"), "rtjpa", 9, 8);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 9);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, S::npos);
+    test(S("elgofjmbrq"), "", 10, 9);
+    test(S("mjqdgalkpc"), "dplqa", 10, 9);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, 9);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, S::npos);
+    test(S("eqsgalomhb"), "", 11, 9);
+    test(S("akiteljmoh"), "lofbc", 11, 9);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, 8);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, S::npos);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 0);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 9);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 9);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), "", 19, 19);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 16);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, 19);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 18);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 19);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, 19);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 19);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 19);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", 4);
+    test(S("lahfb"), "irkhs", 4);
+    test(S("gmfhd"), "kantesmpgj", 4);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", S::npos);
+    test(S("eolhfgpjqk"), "", 9);
+    test(S("nbatdlmekr"), "bnrpe", 8);
+    test(S("jdmciepkaq"), "jtdaefblso", 9);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), "", 19);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 18);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 17);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..4db7762
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.not.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, 0);
+    test(S("binja"), "gfsrt", 0, 0, 0);
+    test(S("latkm"), "pfsoc", 0, 1, 0);
+    test(S("lecfr"), "tpflm", 0, 2, 0);
+    test(S("eqkst"), "sgkec", 0, 4, S::npos);
+    test(S("cdafr"), "romds", 0, 5, 0);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, 0);
+    test(S("lbisk"), "pedfirsglo", 0, 1, 0);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, 0);
+    test(S("ehmja"), "dabckmepqj", 0, 9, S::npos);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, 0);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, 0);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, 0);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, 0);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, S::npos);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, S::npos);
+    test(S("clrgb"), "", 1, 0, 1);
+    test(S("tjmek"), "osmia", 1, 0, 1);
+    test(S("bgstp"), "ckonl", 1, 1, 1);
+    test(S("hstrk"), "ilcaj", 1, 2, 1);
+    test(S("kmspj"), "lasiq", 1, 4, 1);
+    test(S("tjboh"), "kfqmr", 1, 5, 1);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, 1);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, 1);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 1);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 1);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 1);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, 1);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, 1);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, S::npos);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, S::npos);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, S::npos);
+    test(S("ndrhl"), "", 2, 0, 2);
+    test(S("mrecp"), "otkgb", 2, 0, 2);
+    test(S("qlasf"), "cqsjl", 2, 1, 2);
+    test(S("smaqd"), "dpifl", 2, 2, 2);
+    test(S("hjeni"), "oapht", 2, 4, 2);
+    test(S("ocmfj"), "cifts", 2, 5, 2);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, 2);
+    test(S("fklad"), "tpksqhamle", 2, 1, 2);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 1);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 1);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 2);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, 2);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, 2);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 2);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, S::npos);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, S::npos);
+    test(S("cjgao"), "", 4, 0, 4);
+    test(S("kjplq"), "mabns", 4, 0, 4);
+    test(S("herni"), "bdnrp", 4, 1, 4);
+    test(S("tadrb"), "scidp", 4, 2, 4);
+    test(S("pkfeo"), "agbjl", 4, 4, 4);
+    test(S("hoser"), "jfmpr", 4, 5, 3);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, 4);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, 4);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 4);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 3);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 2);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, 4);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, 4);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 3);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 2);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, S::npos);
+    test(S("klopi"), "", 5, 0, 4);
+    test(S("dajhn"), "psthd", 5, 0, 4);
+    test(S("jbgno"), "rpmjd", 5, 1, 4);
+    test(S("hkjae"), "dfsmk", 5, 2, 4);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, 4);
+    test(S("ktdor"), "kipnf", 5, 5, 4);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, 4);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, 4);
+    test(S("armql"), "pcdgltbrfj", 5, 5, 3);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, 4);
+    test(S("jcons"), "ledihrsgpf", 5, 10, 3);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, 4);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, 4);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 1);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 2);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, S::npos);
+    test(S("gajqn"), "", 6, 0, 4);
+    test(S("stedk"), "hrnat", 6, 0, 4);
+    test(S("tjkaf"), "gsqdt", 6, 1, 4);
+    test(S("dthpe"), "bspkd", 6, 2, 4);
+    test(S("klhde"), "ohcmb", 6, 4, 4);
+    test(S("bhlki"), "heatr", 6, 5, 4);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, 4);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, 4);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, 4);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, 4);
+    test(S("jblqp"), "njolbmspac", 6, 10, 3);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, 4);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, 4);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 1);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, S::npos);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, S::npos);
+    test(S("jnkrfhotgl"), "", 0, 0, 0);
+    test(S("dltjfngbko"), "rqegt", 0, 0, 0);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, 0);
+    test(S("skrflobnqm"), "jqirk", 0, 2, 0);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, 0);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, 0);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, 0);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, 0);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, S::npos);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, S::npos);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, 0);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, 0);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, 0);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, 0);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, S::npos);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, S::npos);
+    test(S("shbcqnmoar"), "", 1, 0, 1);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, 1);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, 1);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 0);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, 1);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 0);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, 1);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, 1);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 0);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 1);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, S::npos);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, 1);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, 1);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, S::npos);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, S::npos);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, S::npos);
+    test(S("ectnhskflp"), "", 5, 0, 5);
+    test(S("fgtianblpq"), "pijag", 5, 0, 5);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, 5);
+    test(S("astedncjhk"), "qcloh", 5, 2, 5);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 5);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 5);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, 5);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 4);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, 5);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 3);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 5);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, 5);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, 5);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 1);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, S::npos);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, S::npos);
+    test(S("shoiedtcjb"), "", 9, 0, 9);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, 9);
+    test(S("dqmregkcfl"), "akmle", 9, 1, 9);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 9);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 9);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 8);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, 9);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 9);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 8);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 9);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 9);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, 9);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 9);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 9);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 3);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, S::npos);
+    test(S("ncjpmaekbs"), "", 10, 0, 9);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, 9);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, 9);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, 9);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, 9);
+    test(S("beanrfodgj"), "odpte", 10, 5, 9);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, 9);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 9);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 8);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 9);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 8);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, 9);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 9);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 7);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 5);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, S::npos);
+    test(S("cqjohampgd"), "", 11, 0, 9);
+    test(S("hobitmpsan"), "aocjb", 11, 0, 9);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, 9);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, 9);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, 9);
+    test(S("qghptonrea"), "eaqkl", 11, 5, 7);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, 9);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 9);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 9);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 7);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 8);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, 9);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, 9);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 8);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, S::npos);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, S::npos);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, 0);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, 0);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, 0);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, 0);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, 0);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, 0);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, 0);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, 0);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, 0);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, 0);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, 0);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, 0);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, 0);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, 0);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, S::npos);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, S::npos);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, 1);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, 1);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, 1);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 0);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 0);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, 1);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, 1);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, 1);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, 1);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 0);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 0);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, 1);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, 1);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 0);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, S::npos);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, S::npos);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, 10);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, 10);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, 10);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 10);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 9);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 10);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, 10);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 10);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 10);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 8);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 10);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, 10);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, 10);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 8);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, S::npos);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, S::npos);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, 19);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, 19);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 19);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 19);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 19);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 17);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, 19);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 19);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 19);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 19);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 19);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, 19);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 19);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 18);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 7);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, S::npos);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, 19);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, 19);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 19);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 19);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 18);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 18);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, 19);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 19);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 18);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 18);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 17);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, 19);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 19);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 19);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 1);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, S::npos);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, 19);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, 19);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 19);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 19);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 19);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 19);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, 19);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 19);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 18);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 19);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 19);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, 19);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 19);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 19);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 7);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp
new file mode 100644
index 0000000..ba93adb
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.not.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_not_of(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_last_not_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, 0);
+    test(S("qanej"), S("dfkap"), 0, 0);
+    test(S("clbao"), S("ihqrfebgad"), 0, 0);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, S::npos);
+    test(S("srdfq"), S(""), 1, 1);
+    test(S("oemth"), S("ikcrq"), 1, 1);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 0);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, S::npos);
+    test(S("cshmd"), S(""), 2, 2);
+    test(S("lhcdo"), S("oebqi"), 2, 2);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 1);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, S::npos);
+    test(S("fmtsp"), S(""), 4, 4);
+    test(S("khbpm"), S("aobjd"), 4, 4);
+    test(S("pbsji"), S("pcbahntsje"), 4, 4);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, S::npos);
+    test(S("eqmpa"), S(""), 5, 4);
+    test(S("omigs"), S("kocgb"), 5, 4);
+    test(S("onmje"), S("fbslrjiqkm"), 5, 4);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, S::npos);
+    test(S("schfa"), S(""), 6, 4);
+    test(S("igdsc"), S("qngpd"), 6, 4);
+    test(S("brqgo"), S("rodhqklgmb"), 6, S::npos);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, S::npos);
+    test(S("hcjitbfapl"), S(""), 0, 0);
+    test(S("daiprenocl"), S("ashjd"), 0, S::npos);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, S::npos);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, S::npos);
+    test(S("qpghtfbaji"), S(""), 1, 1);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, 1);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 0);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, S::npos);
+    test(S("crnklpmegd"), S(""), 5, 5);
+    test(S("jsbtafedoc"), S("prqgn"), 5, 5);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 4);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, S::npos);
+    test(S("lmofqdhpki"), S(""), 9, 9);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 8);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 9);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, S::npos);
+    test(S("elgofjmbrq"), S(""), 10, 9);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, 9);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, 9);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, S::npos);
+    test(S("eqsgalomhb"), S(""), 11, 9);
+    test(S("akiteljmoh"), S("lofbc"), 11, 9);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 8);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, S::npos);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, 0);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, 0);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, S::npos);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, S::npos);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, 1);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, 1);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 0);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, S::npos);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, 10);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 9);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 9);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, S::npos);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, 19);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 19);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 16);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, S::npos);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, 19);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 18);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 19);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, S::npos);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, 19);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 19);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 19);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), 4);
+    test(S("lahfb"), S("irkhs"), 4);
+    test(S("gmfhd"), S("kantesmpgj"), 4);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), S::npos);
+    test(S("eolhfgpjqk"), S(""), 9);
+    test(S("nbatdlmekr"), S("bnrpe"), 8);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 9);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), S::npos);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), 19);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 18);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 17);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
new file mode 100644
index 0000000..12765b7
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.of/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_of(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find_last_of(c) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 'm', 0, S::npos);
+    test(S(""), 'm', 1, S::npos);
+    test(S("kitcj"), 'm', 0, S::npos);
+    test(S("qkamf"), 'm', 1, S::npos);
+    test(S("nhmko"), 'm', 2, 2);
+    test(S("tpsaf"), 'm', 4, S::npos);
+    test(S("lahfb"), 'm', 5, S::npos);
+    test(S("irkhs"), 'm', 6, S::npos);
+    test(S("gmfhdaipsr"), 'm', 0, S::npos);
+    test(S("kantesmpgj"), 'm', 1, S::npos);
+    test(S("odaftiegpm"), 'm', 5, S::npos);
+    test(S("oknlrstdpi"), 'm', 9, S::npos);
+    test(S("eolhfgpjqk"), 'm', 10, S::npos);
+    test(S("pcdrofikas"), 'm', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+    test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+    test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+    test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+    test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+    test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+
+    test(S(""), 'm', S::npos);
+    test(S("csope"), 'm', S::npos);
+    test(S("gfsmthlkon"), 'm', 3);
+    test(S("laenfsbridchgotmkqpj"), 'm', 15);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 'm', 0, S::npos);
+    test(S(""), 'm', 1, S::npos);
+    test(S("kitcj"), 'm', 0, S::npos);
+    test(S("qkamf"), 'm', 1, S::npos);
+    test(S("nhmko"), 'm', 2, 2);
+    test(S("tpsaf"), 'm', 4, S::npos);
+    test(S("lahfb"), 'm', 5, S::npos);
+    test(S("irkhs"), 'm', 6, S::npos);
+    test(S("gmfhdaipsr"), 'm', 0, S::npos);
+    test(S("kantesmpgj"), 'm', 1, S::npos);
+    test(S("odaftiegpm"), 'm', 5, S::npos);
+    test(S("oknlrstdpi"), 'm', 9, S::npos);
+    test(S("eolhfgpjqk"), 'm', 10, S::npos);
+    test(S("pcdrofikas"), 'm', 11, S::npos);
+    test(S("nbatdlmekrgcfqsophij"), 'm', 0, S::npos);
+    test(S("bnrpehidofmqtcksjgla"), 'm', 1, S::npos);
+    test(S("jdmciepkaqgotsrfnhlb"), 'm', 10, 2);
+    test(S("jtdaefblsokrmhpgcnqi"), 'm', 19, 12);
+    test(S("hkbgspofltajcnedqmri"), 'm', 20, 17);
+    test(S("oselktgbcapndfjihrmq"), 'm', 21, 18);
+
+    test(S(""), 'm', S::npos);
+    test(S("csope"), 'm', S::npos);
+    test(S("gfsmthlkon"), 'm', 3);
+    test(S("laenfsbridchgotmkqpj"), 'm', 15);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
new file mode 100644
index 0000000..f1b447c
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.of/pointer_size.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find_last_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, S::npos);
+    test(S(""), "laenf", 0, S::npos);
+    test(S(""), "pqlnkmbdjo", 0, S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "bjaht", 1, S::npos);
+    test(S(""), "hjlcmgpket", 1, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 1, S::npos);
+    test(S("fodgq"), "", 0, S::npos);
+    test(S("qanej"), "dfkap", 0, S::npos);
+    test(S("clbao"), "ihqrfebgad", 0, S::npos);
+    test(S("mekdn"), "ngtjfcalbseiqrphmkdo", 0, 0);
+    test(S("srdfq"), "", 1, S::npos);
+    test(S("oemth"), "ikcrq", 1, S::npos);
+    test(S("cdaih"), "dmajblfhsg", 1, 1);
+    test(S("qohtk"), "oqftjhdmkgsblacenirp", 1, 1);
+    test(S("cshmd"), "", 2, S::npos);
+    test(S("lhcdo"), "oebqi", 2, S::npos);
+    test(S("qnsoh"), "kojhpmbsfe", 2, 2);
+    test(S("pkrof"), "acbsjqogpltdkhinfrem", 2, 2);
+    test(S("fmtsp"), "", 4, S::npos);
+    test(S("khbpm"), "aobjd", 4, 2);
+    test(S("pbsji"), "pcbahntsje", 4, 3);
+    test(S("mprdj"), "fhepcrntkoagbmldqijs", 4, 4);
+    test(S("eqmpa"), "", 5, S::npos);
+    test(S("omigs"), "kocgb", 5, 3);
+    test(S("onmje"), "fbslrjiqkm", 5, 3);
+    test(S("oqmrj"), "jeidpcmalhfnqbgtrsko", 5, 4);
+    test(S("schfa"), "", 6, S::npos);
+    test(S("igdsc"), "qngpd", 6, 2);
+    test(S("brqgo"), "rodhqklgmb", 6, 4);
+    test(S("tnrph"), "thdjgafrlbkoiqcspmne", 6, 4);
+    test(S("hcjitbfapl"), "", 0, S::npos);
+    test(S("daiprenocl"), "ashjd", 0, 0);
+    test(S("litpcfdghe"), "mgojkldsqh", 0, 0);
+    test(S("aidjksrolc"), "imqnaghkfrdtlopbjesc", 0, 0);
+    test(S("qpghtfbaji"), "", 1, S::npos);
+    test(S("gfshlcmdjr"), "nadkh", 1, S::npos);
+    test(S("nkodajteqp"), "ofdrqmkebl", 1, 1);
+    test(S("gbmetiprqd"), "bdfjqgatlksriohemnpc", 1, 1);
+    test(S("crnklpmegd"), "", 5, S::npos);
+    test(S("jsbtafedoc"), "prqgn", 5, S::npos);
+    test(S("qnmodrtkeb"), "pejafmnokr", 5, 5);
+    test(S("cpebqsfmnj"), "odnqkgijrhabfmcestlp", 5, 5);
+    test(S("lmofqdhpki"), "", 9, S::npos);
+    test(S("hnefkqimca"), "rtjpa", 9, 9);
+    test(S("drtasbgmfp"), "ktsrmnqagd", 9, 7);
+    test(S("lsaijeqhtr"), "rtdhgcisbnmoaqkfpjle", 9, 9);
+    test(S("elgofjmbrq"), "", 10, S::npos);
+    test(S("mjqdgalkpc"), "dplqa", 10, 8);
+    test(S("kthqnfcerm"), "dkacjoptns", 10, 6);
+    test(S("dfsjhanorc"), "hqfimtrgnbekpdcsjalo", 10, 9);
+    test(S("eqsgalomhb"), "", 11, S::npos);
+    test(S("akiteljmoh"), "lofbc", 11, 8);
+    test(S("hlbdfreqjo"), "astoegbfpn", 11, 9);
+    test(S("taqobhlerg"), "pdgreqomsncafklhtibj", 11, 9);
+    test(S("snafbdlghrjkpqtoceim"), "", 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), "lbtqd", 0, S::npos);
+    test(S("pnracgfkjdiholtbqsem"), "tboimldpjh", 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), "slcerthdaiqjfnobgkpm", 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), "", 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), "aqibs", 1, S::npos);
+    test(S("rbtaqjhgkneisldpmfoc"), "gtfblmqinc", 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), "mkqpbtdalgniorhfescj", 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), "", 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), "pblas", 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), "arosdhcfme", 10, 10);
+    test(S("crsplifgtqedjohnabmk"), "blkhjeogicatqfnpdmsr", 10, 10);
+    test(S("niptglfbosehkamrdqcj"), "", 19, S::npos);
+    test(S("copqdhstbingamjfkler"), "djkqc", 19, 16);
+    test(S("mrtaefilpdsgocnhqbjk"), "lgokshjtpb", 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), "bqjhtkfepimcnsgrlado", 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), "", 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), "nocfa", 20, 19);
+    test(S("spocfaktqdbiejlhngmr"), "bgtajmiedc", 20, 18);
+    test(S("rphmlekgfscndtaobiqj"), "lsckfnqgdahejiopbtmr", 20, 19);
+    test(S("liatsqdoegkmfcnbhrpj"), "", 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), "gfsrt", 21, 12);
+    test(S("latkmisecnorjbfhqpdg"), "pfsocbhjtm", 21, 17);
+    test(S("lecfratdjkhnsmqpoigb"), "tpflmdnoicjgkberhqsa", 21, 19);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", S::npos);
+    test(S(""), "laenf", S::npos);
+    test(S(""), "pqlnkmbdjo", S::npos);
+    test(S(""), "qkamfogpnljdcshbreti", S::npos);
+    test(S("nhmko"), "", S::npos);
+    test(S("lahfb"), "irkhs", 2);
+    test(S("gmfhd"), "kantesmpgj", 1);
+    test(S("odaft"), "oknlrstdpiqmjbaghcfe", 4);
+    test(S("eolhfgpjqk"), "", S::npos);
+    test(S("nbatdlmekr"), "bnrpe", 9);
+    test(S("jdmciepkaq"), "jtdaefblso", 8);
+    test(S("hkbgspoflt"), "oselktgbcapndfjihrmq", 9);
+    test(S("gprdcokbnjhlsfmtieqa"), "", S::npos);
+    test(S("qjghlnftcaismkropdeb"), "bjaht", 19);
+    test(S("pnalfrdtkqcmojiesbhg"), "hjlcmgpket", 19);
+    test(S("pniotcfrhqsmgdkjbael"), "htaobedqikfplcgjsmrn", 19);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..7f96e63
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.of/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, S::npos);
+    test(S(""), "irkhs", 0, 0, S::npos);
+    test(S(""), "kante", 0, 1, S::npos);
+    test(S(""), "oknlr", 0, 2, S::npos);
+    test(S(""), "pcdro", 0, 4, S::npos);
+    test(S(""), "bnrpe", 0, 5, S::npos);
+    test(S(""), "jtdaefblso", 0, 0, S::npos);
+    test(S(""), "oselktgbca", 0, 1, S::npos);
+    test(S(""), "eqgaplhckj", 0, 5, S::npos);
+    test(S(""), "bjahtcmnlp", 0, 9, S::npos);
+    test(S(""), "hjlcmgpket", 0, 10, S::npos);
+    test(S(""), "htaobedqikfplcgjsmrn", 0, 0, S::npos);
+    test(S(""), "hpqiarojkcdlsgnmfetb", 0, 1, S::npos);
+    test(S(""), "dfkaprhjloqetcsimnbg", 0, 10, S::npos);
+    test(S(""), "ihqrfebgadntlpmjksoc", 0, 19, S::npos);
+    test(S(""), "ngtjfcalbseiqrphmkdo", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "lbtqd", 1, 0, S::npos);
+    test(S(""), "tboim", 1, 1, S::npos);
+    test(S(""), "slcer", 1, 2, S::npos);
+    test(S(""), "cbjfs", 1, 4, S::npos);
+    test(S(""), "aqibs", 1, 5, S::npos);
+    test(S(""), "gtfblmqinc", 1, 0, S::npos);
+    test(S(""), "mkqpbtdalg", 1, 1, S::npos);
+    test(S(""), "kphatlimcd", 1, 5, S::npos);
+    test(S(""), "pblasqogic", 1, 9, S::npos);
+    test(S(""), "arosdhcfme", 1, 10, S::npos);
+    test(S(""), "blkhjeogicatqfnpdmsr", 1, 0, S::npos);
+    test(S(""), "bmhineprjcoadgstflqk", 1, 1, S::npos);
+    test(S(""), "djkqcmetslnghpbarfoi", 1, 10, S::npos);
+    test(S(""), "lgokshjtpbemarcdqnfi", 1, 19, S::npos);
+    test(S(""), "bqjhtkfepimcnsgrlado", 1, 20, S::npos);
+    test(S("eaint"), "", 0, 0, S::npos);
+    test(S("binja"), "gfsrt", 0, 0, S::npos);
+    test(S("latkm"), "pfsoc", 0, 1, S::npos);
+    test(S("lecfr"), "tpflm", 0, 2, S::npos);
+    test(S("eqkst"), "sgkec", 0, 4, 0);
+    test(S("cdafr"), "romds", 0, 5, S::npos);
+    test(S("prbhe"), "qhjistlgmr", 0, 0, S::npos);
+    test(S("lbisk"), "pedfirsglo", 0, 1, S::npos);
+    test(S("hrlpd"), "aqcoslgrmk", 0, 5, S::npos);
+    test(S("ehmja"), "dabckmepqj", 0, 9, 0);
+    test(S("mhqgd"), "pqscrjthli", 0, 10, S::npos);
+    test(S("tgklq"), "kfphdcsjqmobliagtren", 0, 0, S::npos);
+    test(S("bocjs"), "rokpefncljibsdhqtagm", 0, 1, S::npos);
+    test(S("grbsd"), "afionmkphlebtcjqsgrd", 0, 10, S::npos);
+    test(S("ofjqr"), "aenmqplidhkofrjbctsg", 0, 19, 0);
+    test(S("btlfi"), "osjmbtcadhiklegrpqnf", 0, 20, 0);
+    test(S("clrgb"), "", 1, 0, S::npos);
+    test(S("tjmek"), "osmia", 1, 0, S::npos);
+    test(S("bgstp"), "ckonl", 1, 1, S::npos);
+    test(S("hstrk"), "ilcaj", 1, 2, S::npos);
+    test(S("kmspj"), "lasiq", 1, 4, S::npos);
+    test(S("tjboh"), "kfqmr", 1, 5, S::npos);
+    test(S("ilbcj"), "klnitfaobg", 1, 0, S::npos);
+    test(S("jkngf"), "gjhmdlqikp", 1, 1, S::npos);
+    test(S("gfcql"), "skbgtahqej", 1, 5, 0);
+    test(S("dqtlg"), "bjsdgtlpkf", 1, 9, 0);
+    test(S("bthpg"), "bjgfmnlkio", 1, 10, 0);
+    test(S("dgsnq"), "lbhepotfsjdqigcnamkr", 1, 0, S::npos);
+    test(S("rmfhp"), "tebangckmpsrqdlfojhi", 1, 1, S::npos);
+    test(S("jfdam"), "joflqbdkhtegimscpanr", 1, 10, 1);
+    test(S("edapb"), "adpmcohetfbsrjinlqkg", 1, 19, 1);
+    test(S("brfsm"), "iacldqjpfnogbsrhmetk", 1, 20, 1);
+    test(S("ndrhl"), "", 2, 0, S::npos);
+    test(S("mrecp"), "otkgb", 2, 0, S::npos);
+    test(S("qlasf"), "cqsjl", 2, 1, S::npos);
+    test(S("smaqd"), "dpifl", 2, 2, S::npos);
+    test(S("hjeni"), "oapht", 2, 4, 0);
+    test(S("ocmfj"), "cifts", 2, 5, 1);
+    test(S("hmftq"), "nmsckbgalo", 2, 0, S::npos);
+    test(S("fklad"), "tpksqhamle", 2, 1, S::npos);
+    test(S("dirnm"), "tpdrchmkji", 2, 5, 2);
+    test(S("hrgdc"), "ijagfkblst", 2, 9, 2);
+    test(S("ifakg"), "kpocsignjb", 2, 10, 0);
+    test(S("ebrgd"), "pecqtkjsnbdrialgmohf", 2, 0, S::npos);
+    test(S("rcjml"), "aiortphfcmkjebgsndql", 2, 1, S::npos);
+    test(S("peqmt"), "sdbkeamglhipojqftrcn", 2, 10, 1);
+    test(S("frehn"), "ljqncehgmfktroapidbs", 2, 19, 2);
+    test(S("tqolf"), "rtcfodilamkbenjghqps", 2, 20, 2);
+    test(S("cjgao"), "", 4, 0, S::npos);
+    test(S("kjplq"), "mabns", 4, 0, S::npos);
+    test(S("herni"), "bdnrp", 4, 1, S::npos);
+    test(S("tadrb"), "scidp", 4, 2, S::npos);
+    test(S("pkfeo"), "agbjl", 4, 4, S::npos);
+    test(S("hoser"), "jfmpr", 4, 5, 4);
+    test(S("kgrsp"), "rbpefghsmj", 4, 0, S::npos);
+    test(S("pgejb"), "apsfntdoqc", 4, 1, S::npos);
+    test(S("thlnq"), "ndkjeisgcl", 4, 5, 3);
+    test(S("nbmit"), "rnfpqatdeo", 4, 9, 4);
+    test(S("jgmib"), "bntjlqrfik", 4, 10, 4);
+    test(S("ncrfj"), "kcrtmpolnaqejghsfdbi", 4, 0, S::npos);
+    test(S("ncsik"), "lobheanpkmqidsrtcfgj", 4, 1, S::npos);
+    test(S("sgbfh"), "athdkljcnreqbgpmisof", 4, 10, 4);
+    test(S("dktbn"), "qkdmjialrscpbhefgont", 4, 19, 4);
+    test(S("fthqm"), "dmasojntqleribkgfchp", 4, 20, 4);
+    test(S("klopi"), "", 5, 0, S::npos);
+    test(S("dajhn"), "psthd", 5, 0, S::npos);
+    test(S("jbgno"), "rpmjd", 5, 1, S::npos);
+    test(S("hkjae"), "dfsmk", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("gbhqo"), "skqne", 5, 4, 3);
+    test(S("ktdor"), "kipnf", 5, 5, 0);
+    test(S("ldprn"), "hmrnqdgifl", 5, 0, S::npos);
+    test(S("egmjk"), "fsmjcdairn", 5, 1, S::npos);
+    test(S("armql"), "pcdgltbrfj", 5, 5, 4);
+    test(S("cdhjo"), "aekfctpirg", 5, 9, 0);
+    test(S("jcons"), "ledihrsgpf", 5, 10, 4);
+    test(S("cbrkp"), "mqcklahsbtirgopefndj", 5, 0, S::npos);
+    test(S("fhgna"), "kmlthaoqgecrnpdbjfis", 5, 1, S::npos);
+    test(S("ejfcd"), "sfhbamcdptojlkrenqgi", 5, 10, 4);
+    test(S("kqjhe"), "pbniofmcedrkhlstgaqj", 5, 19, 4);
+    test(S("pbdjl"), "mongjratcskbhqiepfdl", 5, 20, 4);
+    test(S("gajqn"), "", 6, 0, S::npos);
+    test(S("stedk"), "hrnat", 6, 0, S::npos);
+    test(S("tjkaf"), "gsqdt", 6, 1, S::npos);
+    test(S("dthpe"), "bspkd", 6, 2, S::npos);
+    test(S("klhde"), "ohcmb", 6, 4, 2);
+    test(S("bhlki"), "heatr", 6, 5, 1);
+    test(S("lqmoh"), "pmblckedfn", 6, 0, S::npos);
+    test(S("mtqin"), "aceqmsrbik", 6, 1, S::npos);
+    test(S("dpqbr"), "lmbtdehjrn", 6, 5, 3);
+    test(S("kdhmo"), "teqmcrlgib", 6, 9, 3);
+    test(S("jblqp"), "njolbmspac", 6, 10, 4);
+    test(S("qmjgl"), "pofnhidklamecrbqjgst", 6, 0, S::npos);
+    test(S("rothp"), "jbhckmtgrqnosafedpli", 6, 1, S::npos);
+    test(S("ghknq"), "dobntpmqklicsahgjerf", 6, 10, 4);
+    test(S("eopfi"), "tpdshainjkbfoemlrgcq", 6, 19, 4);
+    test(S("dsnmg"), "oldpfgeakrnitscbjmqh", 6, 20, 4);
+    test(S("jnkrfhotgl"), "", 0, 0, S::npos);
+    test(S("dltjfngbko"), "rqegt", 0, 0, S::npos);
+    test(S("bmjlpkiqde"), "dashm", 0, 1, S::npos);
+    test(S("skrflobnqm"), "jqirk", 0, 2, S::npos);
+    test(S("jkpldtshrm"), "rckeg", 0, 4, S::npos);
+    test(S("ghasdbnjqo"), "jscie", 0, 5, S::npos);
+    test(S("igrkhpbqjt"), "efsphndliq", 0, 0, S::npos);
+    test(S("ikthdgcamf"), "gdicosleja", 0, 1, S::npos);
+    test(S("pcofgeniam"), "qcpjibosfl", 0, 5, 0);
+    test(S("rlfjgesqhc"), "lrhmefnjcq", 0, 9, 0);
+    test(S("itphbqsker"), "dtablcrseo", 0, 10, S::npos);
+    test(S("skjafcirqm"), "apckjsftedbhgomrnilq", 0, 0, S::npos);
+    test(S("tcqomarsfd"), "pcbrgflehjtiadnsokqm", 0, 1, S::npos);
+    test(S("rocfeldqpk"), "nsiadegjklhobrmtqcpf", 0, 10, S::npos);
+    test(S("cfpegndlkt"), "cpmajdqnolikhgsbretf", 0, 19, 0);
+    test(S("fqbtnkeasj"), "jcflkntmgiqrphdosaeb", 0, 20, 0);
+    test(S("shbcqnmoar"), "", 1, 0, S::npos);
+    test(S("bdoshlmfin"), "ontrs", 1, 0, S::npos);
+    test(S("khfrebnsgq"), "pfkna", 1, 1, S::npos);
+    test(S("getcrsaoji"), "ekosa", 1, 2, 1);
+    test(S("fjiknedcpq"), "anqhk", 1, 4, S::npos);
+    test(S("tkejgnafrm"), "jekca", 1, 5, 1);
+    test(S("jnakolqrde"), "ikemsjgacf", 1, 0, S::npos);
+    test(S("lcjptsmgbe"), "arolgsjkhm", 1, 1, S::npos);
+    test(S("itfsmcjorl"), "oftkbldhre", 1, 5, 1);
+    test(S("omchkfrjea"), "gbkqdoeftl", 1, 9, 0);
+    test(S("cigfqkated"), "sqcflrgtim", 1, 10, 1);
+    test(S("tscenjikml"), "fmhbkislrjdpanogqcet", 1, 0, S::npos);
+    test(S("qcpaemsinf"), "rnioadktqlgpbcjsmhef", 1, 1, S::npos);
+    test(S("gltkojeipd"), "oakgtnldpsefihqmjcbr", 1, 10, 1);
+    test(S("qistfrgnmp"), "gbnaelosidmcjqktfhpr", 1, 19, 1);
+    test(S("bdnpfcqaem"), "akbripjhlosndcmqgfet", 1, 20, 1);
+    test(S("ectnhskflp"), "", 5, 0, S::npos);
+    test(S("fgtianblpq"), "pijag", 5, 0, S::npos);
+    test(S("mfeqklirnh"), "jrckd", 5, 1, S::npos);
+    test(S("astedncjhk"), "qcloh", 5, 2, S::npos);
+    test(S("fhlqgcajbr"), "thlmp", 5, 4, 2);
+    test(S("epfhocmdng"), "qidmo", 5, 5, 4);
+    test(S("apcnsibger"), "lnegpsjqrd", 5, 0, S::npos);
+    test(S("aqkocrbign"), "rjqdablmfs", 5, 1, 5);
+    test(S("ijsmdtqgce"), "enkgpbsjaq", 5, 5, S::npos);
+    test(S("clobgsrken"), "kdsgoaijfh", 5, 9, 5);
+    test(S("jbhcfposld"), "trfqgmckbe", 5, 10, 4);
+    test(S("oqnpblhide"), "igetsracjfkdnpoblhqm", 5, 0, S::npos);
+    test(S("lroeasctif"), "nqctfaogirshlekbdjpm", 5, 1, S::npos);
+    test(S("bpjlgmiedh"), "csehfgomljdqinbartkp", 5, 10, 5);
+    test(S("pamkeoidrj"), "qahoegcmplkfsjbdnitr", 5, 19, 5);
+    test(S("espogqbthk"), "dpteiajrqmsognhlfbkc", 5, 20, 5);
+    test(S("shoiedtcjb"), "", 9, 0, S::npos);
+    test(S("ebcinjgads"), "tqbnh", 9, 0, S::npos);
+    test(S("dqmregkcfl"), "akmle", 9, 1, S::npos);
+    test(S("ngcrieqajf"), "iqfkm", 9, 2, 6);
+    test(S("qosmilgnjb"), "tqjsr", 9, 4, 8);
+    test(S("ikabsjtdfl"), "jplqg", 9, 5, 9);
+    test(S("ersmicafdh"), "oilnrbcgtj", 9, 0, S::npos);
+    test(S("fdnplotmgh"), "morkglpesn", 9, 1, 7);
+    test(S("fdbicojerm"), "dmicerngat", 9, 5, 9);
+    test(S("mbtafndjcq"), "radgeskbtc", 9, 9, 6);
+    test(S("mlenkpfdtc"), "ljikprsmqo", 9, 10, 5);
+    test(S("ahlcifdqgs"), "trqihkcgsjamfdbolnpe", 9, 0, S::npos);
+    test(S("bgjemaltks"), "lqmthbsrekajgnofcipd", 9, 1, 6);
+    test(S("pdhslbqrfc"), "jtalmedribkgqsopcnfh", 9, 10, 7);
+    test(S("dirhtsnjkc"), "spqfoiclmtagejbndkrh", 9, 19, 9);
+    test(S("dlroktbcja"), "nmotklspigjrdhcfaebq", 9, 20, 9);
+    test(S("ncjpmaekbs"), "", 10, 0, S::npos);
+    test(S("hlbosgmrak"), "hpmsd", 10, 0, S::npos);
+    test(S("pqfhsgilen"), "qnpor", 10, 1, 1);
+    test(S("gqtjsbdckh"), "otdma", 10, 2, 2);
+    test(S("cfkqpjlegi"), "efhjg", 10, 4, 7);
+    test(S("beanrfodgj"), "odpte", 10, 5, 7);
+    test(S("adtkqpbjfi"), "bctdgfmolr", 10, 0, S::npos);
+    test(S("iomkfthagj"), "oaklidrbqg", 10, 1, 1);
+}
+
+template <class S>
+void test2()
+{
+    test(S("sdpcilonqj"), "dnjfsagktr", 10, 5, 9);
+    test(S("gtfbdkqeml"), "nejaktmiqg", 10, 9, 8);
+    test(S("bmeqgcdorj"), "pjqonlebsf", 10, 10, 9);
+    test(S("etqlcanmob"), "dshmnbtolcjepgaikfqr", 10, 0, S::npos);
+    test(S("roqmkbdtia"), "iogfhpabtjkqlrnemcds", 10, 1, 8);
+    test(S("kadsithljf"), "ngridfabjsecpqltkmoh", 10, 10, 9);
+    test(S("sgtkpbfdmh"), "athmknplcgofrqejsdib", 10, 19, 9);
+    test(S("qgmetnabkl"), "ldobhmqcafnjtkeisgrp", 10, 20, 9);
+    test(S("cqjohampgd"), "", 11, 0, S::npos);
+    test(S("hobitmpsan"), "aocjb", 11, 0, S::npos);
+    test(S("tjehkpsalm"), "jbrnk", 11, 1, 1);
+    test(S("ngfbojitcl"), "tqedg", 11, 2, 7);
+    test(S("rcfkdbhgjo"), "nqskp", 11, 4, 3);
+    test(S("qghptonrea"), "eaqkl", 11, 5, 9);
+    test(S("hnprfgqjdl"), "reaoicljqm", 11, 0, S::npos);
+    test(S("hlmgabenti"), "lsftgajqpm", 11, 1, 1);
+    test(S("ofcjanmrbs"), "rlpfogmits", 11, 5, 7);
+    test(S("jqedtkornm"), "shkncmiaqj", 11, 9, 9);
+    test(S("rfedlasjmg"), "fpnatrhqgs", 11, 10, 9);
+    test(S("talpqjsgkm"), "sjclemqhnpdbgikarfot", 11, 0, S::npos);
+    test(S("lrkcbtqpie"), "otcmedjikgsfnqbrhpla", 11, 1, S::npos);
+    test(S("cipogdskjf"), "bonsaefdqiprkhlgtjcm", 11, 10, 9);
+    test(S("nqedcojahi"), "egpscmahijlfnkrodqtb", 11, 19, 9);
+    test(S("hefnrkmctj"), "kmqbfepjthgilscrndoa", 11, 20, 9);
+    test(S("atqirnmekfjolhpdsgcb"), "", 0, 0, S::npos);
+    test(S("echfkmlpribjnqsaogtd"), "prboq", 0, 0, S::npos);
+    test(S("qnhiftdgcleajbpkrosm"), "fjcqh", 0, 1, S::npos);
+    test(S("chamfknorbedjitgslpq"), "fmosa", 0, 2, S::npos);
+    test(S("njhqpibfmtlkaecdrgso"), "qdbok", 0, 4, S::npos);
+    test(S("ebnghfsqkprmdcljoiat"), "amslg", 0, 5, S::npos);
+    test(S("letjomsgihfrpqbkancd"), "smpltjneqb", 0, 0, S::npos);
+    test(S("nblgoipcrqeaktshjdmf"), "flitskrnge", 0, 1, S::npos);
+    test(S("cehkbngtjoiflqapsmrd"), "pgqihmlbef", 0, 5, S::npos);
+    test(S("mignapfoklbhcqjetdrs"), "cfpdqjtgsb", 0, 9, S::npos);
+    test(S("ceatbhlsqjgpnokfrmdi"), "htpsiaflom", 0, 10, S::npos);
+    test(S("ocihkjgrdelpfnmastqb"), "kpjfiaceghsrdtlbnomq", 0, 0, S::npos);
+    test(S("noelgschdtbrjfmiqkap"), "qhtbomidljgafneksprc", 0, 1, S::npos);
+    test(S("dkclqfombepritjnghas"), "nhtjobkcefldimpsaqgr", 0, 10, S::npos);
+    test(S("miklnresdgbhqcojftap"), "prabcjfqnoeskilmtgdh", 0, 19, 0);
+    test(S("htbcigojaqmdkfrnlsep"), "dtrgmchilkasqoebfpjn", 0, 20, 0);
+    test(S("febhmqtjanokscdirpgl"), "", 1, 0, S::npos);
+    test(S("loakbsqjpcrdhftniegm"), "sqome", 1, 0, S::npos);
+    test(S("reagphsqflbitdcjmkno"), "smfte", 1, 1, S::npos);
+    test(S("jitlfrqemsdhkopncabg"), "ciboh", 1, 2, 1);
+    test(S("mhtaepscdnrjqgbkifol"), "haois", 1, 4, 1);
+    test(S("tocesrfmnglpbjihqadk"), "abfki", 1, 5, S::npos);
+    test(S("lpfmctjrhdagneskbqoi"), "frdkocntmq", 1, 0, S::npos);
+    test(S("lsmqaepkdhncirbtjfgo"), "oasbpedlnr", 1, 1, S::npos);
+    test(S("epoiqmtldrabnkjhcfsg"), "kltqmhgand", 1, 5, S::npos);
+    test(S("emgasrilpknqojhtbdcf"), "gdtfjchpmr", 1, 9, 1);
+    test(S("hnfiagdpcklrjetqbsom"), "ponmcqblet", 1, 10, 1);
+    test(S("nsdfebgajhmtricpoklq"), "sgphqdnofeiklatbcmjr", 1, 0, S::npos);
+    test(S("atjgfsdlpobmeiqhncrk"), "ljqprsmigtfoneadckbh", 1, 1, S::npos);
+    test(S("sitodfgnrejlahcbmqkp"), "ligeojhafnkmrcsqtbdp", 1, 10, 1);
+    test(S("fraghmbiceknltjpqosd"), "lsimqfnjarbopedkhcgt", 1, 19, 1);
+    test(S("pmafenlhqtdbkirjsogc"), "abedmfjlghniorcqptks", 1, 20, 1);
+    test(S("pihgmoeqtnakrjslcbfd"), "", 10, 0, S::npos);
+    test(S("gjdkeprctqblnhiafsom"), "hqtoa", 10, 0, S::npos);
+    test(S("mkpnblfdsahrcqijteog"), "cahif", 10, 1, S::npos);
+    test(S("gckarqnelodfjhmbptis"), "kehis", 10, 2, 7);
+    test(S("gqpskidtbclomahnrjfe"), "kdlmh", 10, 4, 10);
+    test(S("pkldjsqrfgitbhmaecno"), "paeql", 10, 5, 6);
+    test(S("aftsijrbeklnmcdqhgop"), "aghoqiefnb", 10, 0, S::npos);
+    test(S("mtlgdrhafjkbiepqnsoc"), "jrbqaikpdo", 10, 1, 9);
+    test(S("pqgirnaefthokdmbsclj"), "smjonaeqcl", 10, 5, 5);
+    test(S("kpdbgjmtherlsfcqoina"), "eqbdrkcfah", 10, 9, 10);
+    test(S("jrlbothiknqmdgcfasep"), "kapmsienhf", 10, 10, 9);
+    test(S("mjogldqferckabinptsh"), "jpqotrlenfcsbhkaimdg", 10, 0, S::npos);
+    test(S("apoklnefbhmgqcdrisjt"), "jlbmhnfgtcqprikeados", 10, 1, S::npos);
+    test(S("ifeopcnrjbhkdgatmqls"), "stgbhfmdaljnpqoicker", 10, 10, 10);
+    test(S("ckqhaiesmjdnrgolbtpf"), "oihcetflbjagdsrkmqpn", 10, 19, 10);
+    test(S("bnlgapfimcoterskqdjh"), "adtclebmnpjsrqfkigoh", 10, 20, 10);
+    test(S("kgdlrobpmjcthqsafeni"), "", 19, 0, S::npos);
+    test(S("dfkechomjapgnslbtqir"), "beafg", 19, 0, S::npos);
+    test(S("rloadknfbqtgmhcsipje"), "iclat", 19, 1, 16);
+    test(S("mgjhkolrnadqbpetcifs"), "rkhnf", 19, 2, 7);
+    test(S("cmlfakiojdrgtbsphqen"), "clshq", 19, 4, 16);
+    test(S("kghbfipeomsntdalrqjc"), "dtcoj", 19, 5, 19);
+    test(S("eldiqckrnmtasbghjfpo"), "rqosnjmfth", 19, 0, S::npos);
+    test(S("abqjcfedgotihlnspkrm"), "siatdfqglh", 19, 1, 15);
+    test(S("qfbadrtjsimkolcenhpg"), "mrlshtpgjq", 19, 5, 17);
+    test(S("abseghclkjqifmtodrnp"), "adlcskgqjt", 19, 9, 16);
+    test(S("ibmsnlrjefhtdokacqpg"), "drshcjknaf", 19, 10, 16);
+    test(S("mrkfciqjebaponsthldg"), "etsaqroinghpkjdlfcbm", 19, 0, S::npos);
+    test(S("mjkticdeoqshpalrfbgn"), "sgepdnkqliambtrocfhj", 19, 1, 10);
+    test(S("rqnoclbdejgiphtfsakm"), "nlmcjaqgbsortfdihkpe", 19, 10, 19);
+    test(S("plkqbhmtfaeodjcrsing"), "racfnpmosldibqkghjet", 19, 19, 19);
+    test(S("oegalhmstjrfickpbndq"), "fjhdsctkqeiolagrnmbp", 19, 20, 19);
+    test(S("rdtgjcaohpblniekmsfq"), "", 20, 0, S::npos);
+    test(S("ofkqbnjetrmsaidphglc"), "ejanp", 20, 0, S::npos);
+    test(S("grkpahljcftesdmonqib"), "odife", 20, 1, 15);
+    test(S("jimlgbhfqkteospardcn"), "okaqd", 20, 2, 12);
+    test(S("gftenihpmslrjkqadcob"), "lcdbi", 20, 4, 19);
+    test(S("bmhldogtckrfsanijepq"), "fsqbj", 20, 5, 19);
+    test(S("nfqkrpjdesabgtlcmoih"), "bigdomnplq", 20, 0, S::npos);
+    test(S("focalnrpiqmdkstehbjg"), "apiblotgcd", 20, 1, 3);
+    test(S("rhqdspkmebiflcotnjga"), "acfhdenops", 20, 5, 19);
+    test(S("rahdtmsckfboqlpniegj"), "jopdeamcrk", 20, 9, 19);
+    test(S("fbkeiopclstmdqranjhg"), "trqncbkgmh", 20, 10, 19);
+    test(S("lifhpdgmbconstjeqark"), "tomglrkencbsfjqpihda", 20, 0, S::npos);
+}
+
+template <class S>
+void test3()
+{
+    test(S("pboqganrhedjmltsicfk"), "gbkhdnpoietfcmrslajq", 20, 1, 4);
+    test(S("klchabsimetjnqgorfpd"), "rtfnmbsglkjaichoqedp", 20, 10, 17);
+    test(S("sirfgmjqhctndbklaepo"), "ohkmdpfqbsacrtjnlgei", 20, 19, 19);
+    test(S("rlbdsiceaonqjtfpghkm"), "dlbrteoisgphmkncajfq", 20, 20, 19);
+    test(S("ecgdanriptblhjfqskom"), "", 21, 0, S::npos);
+    test(S("fdmiarlpgcskbhoteqjn"), "sjrlo", 21, 0, S::npos);
+    test(S("rlbstjqopignecmfadkh"), "qjpor", 21, 1, 6);
+    test(S("grjpqmbshektdolcafni"), "odhfn", 21, 2, 13);
+    test(S("sakfcohtqnibprjmlged"), "qtfin", 21, 4, 10);
+    test(S("mjtdglasihqpocebrfkn"), "hpqfo", 21, 5, 17);
+    test(S("okaplfrntghqbmeicsdj"), "fabmertkos", 21, 0, S::npos);
+    test(S("sahngemrtcjidqbklfpo"), "brqtgkmaej", 21, 1, 14);
+    test(S("dlmsipcnekhbgoaftqjr"), "nfrdeihsgl", 21, 5, 19);
+    test(S("ahegrmqnoiklpfsdbcjt"), "hlfrosekpi", 21, 9, 14);
+    test(S("hdsjbnmlegtkqripacof"), "atgbkrjdsm", 21, 10, 16);
+    test(S("pcnedrfjihqbalkgtoms"), "blnrptjgqmaifsdkhoec", 21, 0, S::npos);
+    test(S("qjidealmtpskrbfhocng"), "ctpmdahebfqjgknloris", 21, 1, 17);
+    test(S("qeindtagmokpfhsclrbj"), "apnkeqthrmlbfodiscgj", 21, 10, 17);
+    test(S("kpfegbjhsrnodltqciam"), "jdgictpframeoqlsbknh", 21, 19, 19);
+    test(S("hnbrcplsjfgiktoedmaq"), "qprlsfojamgndekthibc", 21, 20, 19);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp
new file mode 100644
index 0000000..351c672
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find.last.of/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find_last_of(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find_last_of(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x < s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find_last_of(str) == x);
+    if (x != S::npos)
+        assert(x < s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, S::npos);
+    test(S(""), S("laenf"), 0, S::npos);
+    test(S(""), S("pqlnkmbdjo"), 0, S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("bjaht"), 1, S::npos);
+    test(S(""), S("hjlcmgpket"), 1, S::npos);
+    test(S(""), S("htaobedqikfplcgjsmrn"), 1, S::npos);
+    test(S("fodgq"), S(""), 0, S::npos);
+    test(S("qanej"), S("dfkap"), 0, S::npos);
+    test(S("clbao"), S("ihqrfebgad"), 0, S::npos);
+    test(S("mekdn"), S("ngtjfcalbseiqrphmkdo"), 0, 0);
+    test(S("srdfq"), S(""), 1, S::npos);
+    test(S("oemth"), S("ikcrq"), 1, S::npos);
+    test(S("cdaih"), S("dmajblfhsg"), 1, 1);
+    test(S("qohtk"), S("oqftjhdmkgsblacenirp"), 1, 1);
+    test(S("cshmd"), S(""), 2, S::npos);
+    test(S("lhcdo"), S("oebqi"), 2, S::npos);
+    test(S("qnsoh"), S("kojhpmbsfe"), 2, 2);
+    test(S("pkrof"), S("acbsjqogpltdkhinfrem"), 2, 2);
+    test(S("fmtsp"), S(""), 4, S::npos);
+    test(S("khbpm"), S("aobjd"), 4, 2);
+    test(S("pbsji"), S("pcbahntsje"), 4, 3);
+    test(S("mprdj"), S("fhepcrntkoagbmldqijs"), 4, 4);
+    test(S("eqmpa"), S(""), 5, S::npos);
+    test(S("omigs"), S("kocgb"), 5, 3);
+    test(S("onmje"), S("fbslrjiqkm"), 5, 3);
+    test(S("oqmrj"), S("jeidpcmalhfnqbgtrsko"), 5, 4);
+    test(S("schfa"), S(""), 6, S::npos);
+    test(S("igdsc"), S("qngpd"), 6, 2);
+    test(S("brqgo"), S("rodhqklgmb"), 6, 4);
+    test(S("tnrph"), S("thdjgafrlbkoiqcspmne"), 6, 4);
+    test(S("hcjitbfapl"), S(""), 0, S::npos);
+    test(S("daiprenocl"), S("ashjd"), 0, 0);
+    test(S("litpcfdghe"), S("mgojkldsqh"), 0, 0);
+    test(S("aidjksrolc"), S("imqnaghkfrdtlopbjesc"), 0, 0);
+    test(S("qpghtfbaji"), S(""), 1, S::npos);
+    test(S("gfshlcmdjr"), S("nadkh"), 1, S::npos);
+    test(S("nkodajteqp"), S("ofdrqmkebl"), 1, 1);
+    test(S("gbmetiprqd"), S("bdfjqgatlksriohemnpc"), 1, 1);
+    test(S("crnklpmegd"), S(""), 5, S::npos);
+    test(S("jsbtafedoc"), S("prqgn"), 5, S::npos);
+    test(S("qnmodrtkeb"), S("pejafmnokr"), 5, 5);
+    test(S("cpebqsfmnj"), S("odnqkgijrhabfmcestlp"), 5, 5);
+    test(S("lmofqdhpki"), S(""), 9, S::npos);
+    test(S("hnefkqimca"), S("rtjpa"), 9, 9);
+    test(S("drtasbgmfp"), S("ktsrmnqagd"), 9, 7);
+    test(S("lsaijeqhtr"), S("rtdhgcisbnmoaqkfpjle"), 9, 9);
+    test(S("elgofjmbrq"), S(""), 10, S::npos);
+    test(S("mjqdgalkpc"), S("dplqa"), 10, 8);
+    test(S("kthqnfcerm"), S("dkacjoptns"), 10, 6);
+    test(S("dfsjhanorc"), S("hqfimtrgnbekpdcsjalo"), 10, 9);
+    test(S("eqsgalomhb"), S(""), 11, S::npos);
+    test(S("akiteljmoh"), S("lofbc"), 11, 8);
+    test(S("hlbdfreqjo"), S("astoegbfpn"), 11, 9);
+    test(S("taqobhlerg"), S("pdgreqomsncafklhtibj"), 11, 9);
+    test(S("snafbdlghrjkpqtoceim"), S(""), 0, S::npos);
+    test(S("aemtbrgcklhndjisfpoq"), S("lbtqd"), 0, S::npos);
+    test(S("pnracgfkjdiholtbqsem"), S("tboimldpjh"), 0, 0);
+    test(S("dicfltehbsgrmojnpkaq"), S("slcerthdaiqjfnobgkpm"), 0, 0);
+    test(S("jlnkraeodhcspfgbqitm"), S(""), 1, S::npos);
+    test(S("lhosrngtmfjikbqpcade"), S("aqibs"), 1, S::npos);
+    test(S("rbtaqjhgkneisldpmfoc"), S("gtfblmqinc"), 1, 1);
+    test(S("gpifsqlrdkbonjtmheca"), S("mkqpbtdalgniorhfescj"), 1, 1);
+    test(S("hdpkobnsalmcfijregtq"), S(""), 10, S::npos);
+    test(S("jtlshdgqaiprkbcoenfm"), S("pblas"), 10, 10);
+    test(S("fkdrbqltsgmcoiphneaj"), S("arosdhcfme"), 10, 10);
+    test(S("crsplifgtqedjohnabmk"), S("blkhjeogicatqfnpdmsr"), 10, 10);
+    test(S("niptglfbosehkamrdqcj"), S(""), 19, S::npos);
+    test(S("copqdhstbingamjfkler"), S("djkqc"), 19, 16);
+    test(S("mrtaefilpdsgocnhqbjk"), S("lgokshjtpb"), 19, 19);
+    test(S("kojatdhlcmigpbfrqnes"), S("bqjhtkfepimcnsgrlado"), 19, 19);
+    test(S("eaintpchlqsbdgrkjofm"), S(""), 20, S::npos);
+    test(S("gjnhidfsepkrtaqbmclo"), S("nocfa"), 20, 19);
+    test(S("spocfaktqdbiejlhngmr"), S("bgtajmiedc"), 20, 18);
+    test(S("rphmlekgfscndtaobiqj"), S("lsckfnqgdahejiopbtmr"), 20, 19);
+    test(S("liatsqdoegkmfcnbhrpj"), S(""), 21, S::npos);
+    test(S("binjagtfldkrspcomqeh"), S("gfsrt"), 21, 12);
+    test(S("latkmisecnorjbfhqpdg"), S("pfsocbhjtm"), 21, 17);
+    test(S("lecfratdjkhnsmqpoigb"), S("tpflmdnoicjgkberhqsa"), 21, 19);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), S::npos);
+    test(S(""), S("laenf"), S::npos);
+    test(S(""), S("pqlnkmbdjo"), S::npos);
+    test(S(""), S("qkamfogpnljdcshbreti"), S::npos);
+    test(S("nhmko"), S(""), S::npos);
+    test(S("lahfb"), S("irkhs"), 2);
+    test(S("gmfhd"), S("kantesmpgj"), 1);
+    test(S("odaft"), S("oknlrstdpiqmjbaghcfe"), 4);
+    test(S("eolhfgpjqk"), S(""), S::npos);
+    test(S("nbatdlmekr"), S("bnrpe"), 9);
+    test(S("jdmciepkaq"), S("jtdaefblso"), 8);
+    test(S("hkbgspoflt"), S("oselktgbcapndfjihrmq"), 9);
+    test(S("gprdcokbnjhlsfmtieqa"), S(""), S::npos);
+    test(S("qjghlnftcaismkropdeb"), S("bjaht"), 19);
+    test(S("pnalfrdtkqcmojiesbhg"), S("hjlcmgpket"), 19);
+    test(S("pniotcfrhqsmgdkjbael"), S("htaobedqikfplcgjsmrn"), 19);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp
new file mode 100644
index 0000000..24e58fc
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(charT c, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find(c, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.find(c) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + 1 <= s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 'c', 0, S::npos);
+    test(S(""), 'c', 1, S::npos);
+    test(S("abcde"), 'c', 0, 2);
+    test(S("abcde"), 'c', 1, 2);
+    test(S("abcde"), 'c', 2, 2);
+    test(S("abcde"), 'c', 4, S::npos);
+    test(S("abcde"), 'c', 5, S::npos);
+    test(S("abcde"), 'c', 6, S::npos);
+    test(S("abcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcde"), 'c', 5, 7);
+    test(S("abcdeabcde"), 'c', 9, S::npos);
+    test(S("abcdeabcde"), 'c', 10, S::npos);
+    test(S("abcdeabcde"), 'c', 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+
+    test(S(""), 'c', S::npos);
+    test(S("abcde"), 'c', 2);
+    test(S("abcdeabcde"), 'c', 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 'c', 0, S::npos);
+    test(S(""), 'c', 1, S::npos);
+    test(S("abcde"), 'c', 0, 2);
+    test(S("abcde"), 'c', 1, 2);
+    test(S("abcde"), 'c', 2, 2);
+    test(S("abcde"), 'c', 4, S::npos);
+    test(S("abcde"), 'c', 5, S::npos);
+    test(S("abcde"), 'c', 6, S::npos);
+    test(S("abcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcde"), 'c', 5, 7);
+    test(S("abcdeabcde"), 'c', 9, S::npos);
+    test(S("abcdeabcde"), 'c', 10, S::npos);
+    test(S("abcdeabcde"), 'c', 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 0, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 1, 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 10, 12);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 21, S::npos);
+
+    test(S(""), 'c', S::npos);
+    test(S("abcde"), 'c', 2);
+    test(S("abcdeabcde"), 'c', 2);
+    test(S("abcdeabcdeabcdeabcde"), 'c', 2);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
new file mode 100644
index 0000000..e00d7fd
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find/pointer_size.pass.cpp
@@ -0,0 +1,164 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const charT* s, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.find(str, pos) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(pos <= x && x + n <= s.size());
+    }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.find(str) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(0 <= x && x + n <= s.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0);
+    test(S(""), "abcde", 0, S::npos);
+    test(S(""), "abcdeabcde", 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S(""), "", 1, S::npos);
+    test(S(""), "abcde", 1, S::npos);
+    test(S(""), "abcdeabcde", 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 0, 0);
+    test(S("abcde"), "abcde", 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcde"), "", 1, 1);
+    test(S("abcde"), "abcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 2, 2);
+    test(S("abcde"), "abcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+    test(S("abcde"), "", 4, 4);
+    test(S("abcde"), "abcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+    test(S("abcde"), "", 5, 5);
+    test(S("abcde"), "abcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcde"), "", 6, S::npos);
+    test(S("abcde"), "abcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+    test(S("abcdeabcde"), "", 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcdeabcde"), "", 1, 1);
+    test(S("abcdeabcde"), "abcde", 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "", 5, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "", 9, 9);
+    test(S("abcdeabcde"), "abcde", 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "", 10, 10);
+    test(S("abcdeabcde"), "abcde", 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "", 11, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", 0);
+    test(S(""), "abcde", S::npos);
+    test(S(""), "abcdeabcde", S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcde"), "", 0);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdeabcde", S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcde"), "", 0);
+    test(S("abcdeabcde"), "abcde", 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..3006c46
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type n, typename S::size_type x)
+{
+    assert(s.find(str, pos, n) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, 0);
+    test(S(""), "abcde", 0, 0, 0);
+    test(S(""), "abcde", 0, 1, S::npos);
+    test(S(""), "abcde", 0, 2, S::npos);
+    test(S(""), "abcde", 0, 4, S::npos);
+    test(S(""), "abcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 9, S::npos);
+    test(S(""), "abcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S(""), "", 1, 0, S::npos);
+    test(S(""), "abcde", 1, 0, S::npos);
+    test(S(""), "abcde", 1, 1, S::npos);
+    test(S(""), "abcde", 1, 2, S::npos);
+    test(S(""), "abcde", 1, 4, S::npos);
+    test(S(""), "abcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 0, S::npos);
+    test(S(""), "abcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 9, S::npos);
+    test(S(""), "abcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 1, 0);
+    test(S("abcde"), "abcde", 0, 2, 0);
+    test(S("abcde"), "abcde", 0, 4, 0);
+    test(S("abcde"), "abcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcde"), "", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 1, S::npos);
+    test(S("abcde"), "abcde", 1, 2, S::npos);
+    test(S("abcde"), "abcde", 1, 4, S::npos);
+    test(S("abcde"), "abcde", 1, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcde", 1, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 1, S::npos);
+    test(S("abcde"), "abcde", 2, 2, S::npos);
+    test(S("abcde"), "abcde", 2, 4, S::npos);
+    test(S("abcde"), "abcde", 2, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcde", 2, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+    test(S("abcde"), "", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 1, S::npos);
+    test(S("abcde"), "abcde", 4, 2, S::npos);
+    test(S("abcde"), "abcde", 4, 4, S::npos);
+    test(S("abcde"), "abcde", 4, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcde", 4, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+    test(S("abcde"), "", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 1, S::npos);
+    test(S("abcde"), "abcde", 5, 2, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), "abcde", 5, 4, S::npos);
+    test(S("abcde"), "abcde", 5, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcde", 5, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcde"), "", 6, 0, S::npos);
+    test(S("abcde"), "abcde", 6, 0, S::npos);
+    test(S("abcde"), "abcde", 6, 1, S::npos);
+    test(S("abcde"), "abcde", 6, 2, S::npos);
+    test(S("abcde"), "abcde", 6, 4, S::npos);
+    test(S("abcde"), "abcde", 6, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 0, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 1, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 5, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+    test(S("abcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcde", 1, 2, 5);
+    test(S("abcdeabcde"), "abcde", 1, 4, 5);
+    test(S("abcdeabcde"), "abcde", 1, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcde"), "", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcde", 5, 2, 5);
+    test(S("abcdeabcde"), "abcde", 5, 4, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcdeabcde"), "", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 9, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+    test(S("abcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 10, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 1, S::npos);
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdeabcde"), "abcdeabcde", 10, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcde"), "", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 2, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 4, S::npos);
+    test(S("abcdeabcde"), "abcde", 11, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 5, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 9, S::npos);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 5);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, S::npos);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp
new file mode 100644
index 0000000..a89df4e
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_find/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type find(const basic_string& str, size_type pos = 0) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.find(str, pos) == x);
+    if (x != S::npos)
+        assert(pos <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.find(str) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, 0);
+    test(S(""), S("abcde"), 0, S::npos);
+    test(S(""), S("abcdeabcde"), 0, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S(""), S(""), 1, S::npos);
+    test(S(""), S("abcde"), 1, S::npos);
+    test(S(""), S("abcdeabcde"), 1, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 0, 0);
+    test(S("abcde"), S("abcde"), 0, 0);
+    test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcde"), S(""), 1, 1);
+    test(S("abcde"), S("abcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 2, 2);
+    test(S("abcde"), S("abcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+    test(S("abcde"), S(""), 4, 4);
+    test(S("abcde"), S("abcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+    test(S("abcde"), S(""), 5, 5);
+    test(S("abcde"), S("abcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcde"), S(""), 6, S::npos);
+    test(S("abcde"), S("abcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+    test(S("abcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcde"), S("abcde"), 1, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S(""), 5, 5);
+    test(S("abcdeabcde"), S("abcde"), 5, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S(""), 9, 9);
+    test(S("abcdeabcde"), S("abcde"), 9, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcde"), S("abcde"), 10, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S(""), 11, S::npos);
+    test(S("abcdeabcde"), S("abcde"), 11, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcde"), 11, S::npos);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 5);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, S::npos);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), S::npos);
+    test(S(""), S("abcdeabcde"), S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcde"), S(""), 0);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdeabcde"), S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcde"), S(""), 0);
+    test(S("abcdeabcde"), S("abcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
new file mode 100644
index 0000000..cbc0c9b
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_rfind/char_size.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(charT c, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.rfind(c, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + 1 <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, typename S::value_type c, typename S::size_type x)
+{
+    assert(s.rfind(c) == x);
+    if (x != S::npos)
+        assert(x + 1 <= s.size());
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 'b', 0, S::npos);
+    test(S(""), 'b', 1, S::npos);
+    test(S("abcde"), 'b', 0, S::npos);
+    test(S("abcde"), 'b', 1, 1);
+    test(S("abcde"), 'b', 2, 1);
+    test(S("abcde"), 'b', 4, 1);
+    test(S("abcde"), 'b', 5, 1);
+    test(S("abcde"), 'b', 6, 1);
+    test(S("abcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcde"), 'b', 5, 1);
+    test(S("abcdeabcde"), 'b', 9, 6);
+    test(S("abcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcde"), 'b', 11, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+    test(S(""), 'b', S::npos);
+    test(S("abcde"), 'b', 1);
+    test(S("abcdeabcde"), 'b', 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 'b', 0, S::npos);
+    test(S(""), 'b', 1, S::npos);
+    test(S("abcde"), 'b', 0, S::npos);
+    test(S("abcde"), 'b', 1, 1);
+    test(S("abcde"), 'b', 2, 1);
+    test(S("abcde"), 'b', 4, 1);
+    test(S("abcde"), 'b', 5, 1);
+    test(S("abcde"), 'b', 6, 1);
+    test(S("abcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcde"), 'b', 5, 1);
+    test(S("abcdeabcde"), 'b', 9, 6);
+    test(S("abcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcde"), 'b', 11, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 0, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 10, 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 19, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 20, 16);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 21, 16);
+
+    test(S(""), 'b', S::npos);
+    test(S("abcde"), 'b', 1);
+    test(S("abcdeabcde"), 'b', 6);
+    test(S("abcdeabcdeabcdeabcde"), 'b', 16);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
new file mode 100644
index 0000000..450aebe
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_rfind/pointer_size.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const charT* s, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+     typename S::size_type x)
+{
+    assert(s.rfind(str, pos) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type n = S::traits_type::length(str);
+        assert(x <= pos && x + n <= s.size());
+    }
+}
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type x)
+{
+    assert(s.rfind(str) == x);
+    if (x != S::npos)
+    {
+        typename S::size_type pos = s.size();
+        typename S::size_type n = S::traits_type::length(str);
+        assert(x <= pos && x + n <= s.size());
+    }
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0);
+    test(S(""), "abcde", 0, S::npos);
+    test(S(""), "abcdeabcde", 0, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S(""), "", 1, 0);
+    test(S(""), "abcde", 1, S::npos);
+    test(S(""), "abcdeabcde", 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 0, 0);
+    test(S("abcde"), "abcde", 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcde"), "", 1, 1);
+    test(S("abcde"), "abcde", 1, 0);
+    test(S("abcde"), "abcdeabcde", 1, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcde"), "", 2, 2);
+    test(S("abcde"), "abcde", 2, 0);
+    test(S("abcde"), "abcdeabcde", 2, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, S::npos);
+    test(S("abcde"), "", 4, 4);
+    test(S("abcde"), "abcde", 4, 0);
+    test(S("abcde"), "abcdeabcde", 4, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, S::npos);
+    test(S("abcde"), "", 5, 5);
+    test(S("abcde"), "abcde", 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcde"), "", 6, 5);
+    test(S("abcde"), "abcde", 6, 0);
+    test(S("abcde"), "abcdeabcde", 6, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, S::npos);
+    test(S("abcdeabcde"), "", 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, S::npos);
+    test(S("abcdeabcde"), "", 1, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, S::npos);
+    test(S("abcdeabcde"), "", 5, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, S::npos);
+    test(S("abcdeabcde"), "", 9, 9);
+    test(S("abcdeabcde"), "abcde", 9, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, S::npos);
+    test(S("abcdeabcde"), "", 10, 10);
+    test(S("abcdeabcde"), "abcde", 10, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, S::npos);
+    test(S("abcdeabcde"), "", 11, 10);
+    test(S("abcdeabcde"), "abcde", 11, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), "", 0);
+    test(S(""), "abcde", S::npos);
+    test(S(""), "abcdeabcde", S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcde"), "", 5);
+    test(S("abcde"), "abcde", 0);
+    test(S("abcde"), "abcdeabcde", S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcde"), "", 10);
+    test(S("abcdeabcde"), "abcde", 5);
+    test(S("abcdeabcde"), "abcdeabcde", 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
new file mode 100644
index 0000000..47baf40
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_rfind/pointer_size_size.pass.cpp
@@ -0,0 +1,387 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const charT* s, size_type pos, size_type n) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const typename S::value_type* str, typename S::size_type pos,
+      typename S::size_type n, typename S::size_type x)
+{
+    assert(s.rfind(str, pos, n) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + n <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), "", 0, 0, 0);
+    test(S(""), "abcde", 0, 0, 0);
+    test(S(""), "abcde", 0, 1, S::npos);
+    test(S(""), "abcde", 0, 2, S::npos);
+    test(S(""), "abcde", 0, 4, S::npos);
+    test(S(""), "abcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcde", 0, 5, S::npos);
+    test(S(""), "abcdeabcde", 0, 9, S::npos);
+    test(S(""), "abcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S(""), "", 1, 0, 0);
+    test(S(""), "abcde", 1, 0, 0);
+    test(S(""), "abcde", 1, 1, S::npos);
+    test(S(""), "abcde", 1, 2, S::npos);
+    test(S(""), "abcde", 1, 4, S::npos);
+    test(S(""), "abcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 0, 0);
+    test(S(""), "abcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcde", 1, 5, S::npos);
+    test(S(""), "abcdeabcde", 1, 9, S::npos);
+    test(S(""), "abcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 0, 0);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 1, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S(""), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 0, 0);
+    test(S("abcde"), "abcde", 0, 1, 0);
+    test(S("abcde"), "abcde", 0, 2, 0);
+    test(S("abcde"), "abcde", 0, 4, 0);
+    test(S("abcde"), "abcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcde"), "abcdeabcde", 0, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcde"), "", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 0, 1);
+    test(S("abcde"), "abcde", 1, 1, 0);
+    test(S("abcde"), "abcde", 1, 2, 0);
+    test(S("abcde"), "abcde", 1, 4, 0);
+    test(S("abcde"), "abcde", 1, 5, 0);
+    test(S("abcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcde"), "abcdeabcde", 1, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcde"), "", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 0, 2);
+    test(S("abcde"), "abcde", 2, 1, 0);
+    test(S("abcde"), "abcde", 2, 2, 0);
+    test(S("abcde"), "abcde", 2, 4, 0);
+    test(S("abcde"), "abcde", 2, 5, 0);
+    test(S("abcde"), "abcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcde", 2, 1, 0);
+    test(S("abcde"), "abcdeabcde", 2, 5, 0);
+    test(S("abcde"), "abcdeabcde", 2, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 0, 2);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 2, 20, S::npos);
+    test(S("abcde"), "", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 0, 4);
+    test(S("abcde"), "abcde", 4, 1, 0);
+    test(S("abcde"), "abcde", 4, 2, 0);
+    test(S("abcde"), "abcde", 4, 4, 0);
+    test(S("abcde"), "abcde", 4, 5, 0);
+    test(S("abcde"), "abcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcde", 4, 1, 0);
+    test(S("abcde"), "abcdeabcde", 4, 5, 0);
+    test(S("abcde"), "abcdeabcde", 4, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 0, 4);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 4, 20, S::npos);
+    test(S("abcde"), "", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 0, 5);
+    test(S("abcde"), "abcde", 5, 1, 0);
+    test(S("abcde"), "abcde", 5, 2, 0);
+}
+
+template <class S>
+void test1()
+{
+    test(S("abcde"), "abcde", 5, 4, 0);
+    test(S("abcde"), "abcde", 5, 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcde", 5, 1, 0);
+    test(S("abcde"), "abcdeabcde", 5, 5, 0);
+    test(S("abcde"), "abcdeabcde", 5, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcde"), "", 6, 0, 5);
+    test(S("abcde"), "abcde", 6, 0, 5);
+    test(S("abcde"), "abcde", 6, 1, 0);
+    test(S("abcde"), "abcde", 6, 2, 0);
+    test(S("abcde"), "abcde", 6, 4, 0);
+    test(S("abcde"), "abcde", 6, 5, 0);
+    test(S("abcde"), "abcdeabcde", 6, 0, 5);
+    test(S("abcde"), "abcdeabcde", 6, 1, 0);
+    test(S("abcde"), "abcdeabcde", 6, 5, 0);
+    test(S("abcde"), "abcdeabcde", 6, 9, S::npos);
+    test(S("abcde"), "abcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 0, 5);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 1, 0);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 10, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 19, S::npos);
+    test(S("abcde"), "abcdeabcdeabcdeabcde", 6, 20, S::npos);
+    test(S("abcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, S::npos);
+    test(S("abcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcde", 1, 2, 0);
+    test(S("abcdeabcde"), "abcde", 1, 4, 0);
+    test(S("abcdeabcde"), "abcde", 1, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 1, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, S::npos);
+    test(S("abcdeabcde"), "", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcde", 5, 2, 5);
+    test(S("abcdeabcde"), "abcde", 5, 4, 5);
+    test(S("abcdeabcde"), "abcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 5, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 0, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 5, 20, S::npos);
+    test(S("abcdeabcde"), "", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcde", 9, 2, 5);
+    test(S("abcdeabcde"), "abcde", 9, 4, 5);
+    test(S("abcdeabcde"), "abcde", 9, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 9, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 0, 9);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 9, 20, S::npos);
+    test(S("abcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcde", 10, 1, 5);
+    test(S("abcdeabcde"), "abcde", 10, 2, 5);
+    test(S("abcdeabcde"), "abcde", 10, 4, 5);
+    test(S("abcdeabcde"), "abcde", 10, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 1, 5);
+}
+
+template <class S>
+void test2()
+{
+    test(S("abcdeabcde"), "abcdeabcde", 10, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 10, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, S::npos);
+    test(S("abcdeabcde"), "", 11, 0, 10);
+    test(S("abcdeabcde"), "abcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcde", 11, 2, 5);
+    test(S("abcdeabcde"), "abcde", 11, 4, 5);
+    test(S("abcdeabcde"), "abcde", 11, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 5, 5);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 9, 0);
+    test(S("abcdeabcde"), "abcdeabcde", 11, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 0, 10);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 1, 5);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 10, 0);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 19, S::npos);
+    test(S("abcdeabcde"), "abcdeabcdeabcdeabcde", 11, 20, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), "", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 0, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 2, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 4, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 1, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 5, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 9, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 1, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 0, 1);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 1, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 2, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 4, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 5, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 0, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 1, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 10, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 19, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 19, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 0, 19);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 19, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 20, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 20, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 0, 20);
+}
+
+template <class S>
+void test3()
+{
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 20, 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), "", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 2, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 4, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcde", 21, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 5, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 9, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcde", 21, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 0, 20);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 1, 15);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), "abcdeabcdeabcdeabcde", 21, 20, 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    test2<S>();
+    test3<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp b/final/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
new file mode 100644
index 0000000..05e6e51
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_rfind/string_size.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// size_type rfind(const basic_string& str, size_type pos = npos) const;
+
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type pos, typename S::size_type x)
+{
+    assert(s.rfind(str, pos) == x);
+    if (x != S::npos)
+        assert(x <= pos && x + str.size() <= s.size());
+}
+
+template <class S>
+void
+test(const S& s, const S& str, typename S::size_type x)
+{
+    assert(s.rfind(str) == x);
+    if (x != S::npos)
+        assert(0 <= x && x + str.size() <= s.size());
+}
+
+template <class S>
+void test0()
+{
+    test(S(""), S(""), 0, 0);
+    test(S(""), S("abcde"), 0, S::npos);
+    test(S(""), S("abcdeabcde"), 0, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S(""), S(""), 1, 0);
+    test(S(""), S("abcde"), 1, S::npos);
+    test(S(""), S("abcdeabcde"), 1, S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 0, 0);
+    test(S("abcde"), S("abcde"), 0, 0);
+    test(S("abcde"), S("abcdeabcde"), 0, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcde"), S(""), 1, 1);
+    test(S("abcde"), S("abcde"), 1, 0);
+    test(S("abcde"), S("abcdeabcde"), 1, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcde"), S(""), 2, 2);
+    test(S("abcde"), S("abcde"), 2, 0);
+    test(S("abcde"), S("abcdeabcde"), 2, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 2, S::npos);
+    test(S("abcde"), S(""), 4, 4);
+    test(S("abcde"), S("abcde"), 4, 0);
+    test(S("abcde"), S("abcdeabcde"), 4, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 4, S::npos);
+    test(S("abcde"), S(""), 5, 5);
+    test(S("abcde"), S("abcde"), 5, 0);
+    test(S("abcde"), S("abcdeabcde"), 5, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcde"), S(""), 6, 5);
+    test(S("abcde"), S("abcde"), 6, 0);
+    test(S("abcde"), S("abcdeabcde"), 6, S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), 6, S::npos);
+    test(S("abcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, S::npos);
+    test(S("abcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcde"), S("abcde"), 1, 0);
+    test(S("abcdeabcde"), S("abcdeabcde"), 1, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, S::npos);
+    test(S("abcdeabcde"), S(""), 5, 5);
+    test(S("abcdeabcde"), S("abcde"), 5, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 5, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 5, S::npos);
+    test(S("abcdeabcde"), S(""), 9, 9);
+    test(S("abcdeabcde"), S("abcde"), 9, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 9, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 9, S::npos);
+    test(S("abcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcde"), S("abcde"), 10, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 10, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, S::npos);
+    test(S("abcdeabcde"), S(""), 11, 10);
+    test(S("abcdeabcde"), S("abcde"), 11, 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 11, 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), 11, S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 1, 1);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 1, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 10, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 19, 19);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 19, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 19, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 19, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 20, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 20, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 20, 0);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 21, 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 21, 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 21, 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 21, 0);
+}
+
+template <class S>
+void test1()
+{
+    test(S(""), S(""), 0);
+    test(S(""), S("abcde"), S::npos);
+    test(S(""), S("abcdeabcde"), S::npos);
+    test(S(""), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcde"), S(""), 5);
+    test(S("abcde"), S("abcde"), 0);
+    test(S("abcde"), S("abcdeabcde"), S::npos);
+    test(S("abcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcde"), S(""), 10);
+    test(S("abcdeabcde"), S("abcde"), 5);
+    test(S("abcdeabcde"), S("abcdeabcde"), 0);
+    test(S("abcdeabcde"), S("abcdeabcdeabcdeabcde"), S::npos);
+    test(S("abcdeabcdeabcdeabcde"), S(""), 20);
+    test(S("abcdeabcdeabcdeabcde"), S("abcde"), 15);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcde"), 10);
+    test(S("abcdeabcdeabcdeabcde"), S("abcdeabcdeabcdeabcde"), 0);
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test0<S>();
+    test1<S>();
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test0<S>();
+    test1<S>();
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/final/test/strings/basic.string/string.ops/string_substr/substr.pass.cpp
new file mode 100644
index 0000000..a73f70c
--- /dev/null
+++ b/final/test/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -0,0 +1,166 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// basic_string substr(size_type pos = 0, size_type n = npos) const;
+
+#include <string>
+#include <stdexcept>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class S>
+void
+test(const S& s, typename S::size_type pos, typename S::size_type n)
+{
+    try
+    {
+        S str = s.substr(pos, n);
+        assert(str.__invariants());
+        assert(pos <= s.size());
+        typename S::size_type rlen = std::min(n, s.size() - pos);
+        assert(str.size() == rlen);
+        assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
+    }
+    catch (std::out_of_range&)
+    {
+        assert(pos > s.size());
+    }
+}
+
+int main()
+{
+    {
+    typedef std::string S;
+    test(S(""), 0, 0);
+    test(S(""), 1, 0);
+    test(S("pniot"), 0, 0);
+    test(S("htaob"), 0, 1);
+    test(S("fodgq"), 0, 2);
+    test(S("hpqia"), 0, 4);
+    test(S("qanej"), 0, 5);
+    test(S("dfkap"), 1, 0);
+    test(S("clbao"), 1, 1);
+    test(S("ihqrf"), 1, 2);
+    test(S("mekdn"), 1, 3);
+    test(S("ngtjf"), 1, 4);
+    test(S("srdfq"), 2, 0);
+    test(S("qkdrs"), 2, 1);
+    test(S("ikcrq"), 2, 2);
+    test(S("cdaih"), 2, 3);
+    test(S("dmajb"), 4, 0);
+    test(S("karth"), 4, 1);
+    test(S("lhcdo"), 5, 0);
+    test(S("acbsj"), 6, 0);
+    test(S("pbsjikaole"), 0, 0);
+    test(S("pcbahntsje"), 0, 1);
+    test(S("mprdjbeiak"), 0, 5);
+    test(S("fhepcrntko"), 0, 9);
+    test(S("eqmpaidtls"), 0, 10);
+    test(S("joidhalcmq"), 1, 0);
+    test(S("omigsphflj"), 1, 1);
+    test(S("kocgbphfji"), 1, 4);
+    test(S("onmjekafbi"), 1, 8);
+    test(S("fbslrjiqkm"), 1, 9);
+    test(S("oqmrjahnkg"), 5, 0);
+    test(S("jeidpcmalh"), 5, 1);
+    test(S("schfalibje"), 5, 2);
+    test(S("crliponbqe"), 5, 4);
+    test(S("igdscopqtm"), 5, 5);
+    test(S("qngpdkimlc"), 9, 0);
+    test(S("thdjgafrlb"), 9, 1);
+    test(S("hcjitbfapl"), 10, 0);
+    test(S("mgojkldsqh"), 11, 0);
+    test(S("gfshlcmdjreqipbontak"), 0, 0);
+    test(S("nadkhpfemgclosibtjrq"), 0, 1);
+    test(S("nkodajteqplrbifhmcgs"), 0, 10);
+    test(S("ofdrqmkeblthacpgijsn"), 0, 19);
+    test(S("gbmetiprqdoasckjfhln"), 0, 20);
+    test(S("bdfjqgatlksriohemnpc"), 1, 0);
+    test(S("crnklpmegdqfiashtojb"), 1, 1);
+    test(S("ejqcnahdrkfsmptilgbo"), 1, 9);
+    test(S("jsbtafedocnirgpmkhql"), 1, 18);
+    test(S("prqgnlbaejsmkhdctoif"), 1, 19);
+    test(S("qnmodrtkebhpasifgcjl"), 10, 0);
+    test(S("pejafmnokrqhtisbcdgl"), 10, 1);
+    test(S("cpebqsfmnjdolhkratgi"), 10, 5);
+    test(S("odnqkgijrhabfmcestlp"), 10, 9);
+    test(S("lmofqdhpkibagnrcjste"), 10, 10);
+    test(S("lgjqketopbfahrmnsicd"), 19, 0);
+    test(S("ktsrmnqagdecfhijpobl"), 19, 1);
+    test(S("lsaijeqhtrbgcdmpfkno"), 20, 0);
+    test(S("dplqartnfgejichmoskb"), 21, 0);
+    }
+#if __cplusplus >= 201103L
+    {
+    typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
+    test(S(""), 0, 0);
+    test(S(""), 1, 0);
+    test(S("pniot"), 0, 0);
+    test(S("htaob"), 0, 1);
+    test(S("fodgq"), 0, 2);
+    test(S("hpqia"), 0, 4);
+    test(S("qanej"), 0, 5);
+    test(S("dfkap"), 1, 0);
+    test(S("clbao"), 1, 1);
+    test(S("ihqrf"), 1, 2);
+    test(S("mekdn"), 1, 3);
+    test(S("ngtjf"), 1, 4);
+    test(S("srdfq"), 2, 0);
+    test(S("qkdrs"), 2, 1);
+    test(S("ikcrq"), 2, 2);
+    test(S("cdaih"), 2, 3);
+    test(S("dmajb"), 4, 0);
+    test(S("karth"), 4, 1);
+    test(S("lhcdo"), 5, 0);
+    test(S("acbsj"), 6, 0);
+    test(S("pbsjikaole"), 0, 0);
+    test(S("pcbahntsje"), 0, 1);
+    test(S("mprdjbeiak"), 0, 5);
+    test(S("fhepcrntko"), 0, 9);
+    test(S("eqmpaidtls"), 0, 10);
+    test(S("joidhalcmq"), 1, 0);
+    test(S("omigsphflj"), 1, 1);
+    test(S("kocgbphfji"), 1, 4);
+    test(S("onmjekafbi"), 1, 8);
+    test(S("fbslrjiqkm"), 1, 9);
+    test(S("oqmrjahnkg"), 5, 0);
+    test(S("jeidpcmalh"), 5, 1);
+    test(S("schfalibje"), 5, 2);
+    test(S("crliponbqe"), 5, 4);
+    test(S("igdscopqtm"), 5, 5);
+    test(S("qngpdkimlc"), 9, 0);
+    test(S("thdjgafrlb"), 9, 1);
+    test(S("hcjitbfapl"), 10, 0);
+    test(S("mgojkldsqh"), 11, 0);
+    test(S("gfshlcmdjreqipbontak"), 0, 0);
+    test(S("nadkhpfemgclosibtjrq"), 0, 1);
+    test(S("nkodajteqplrbifhmcgs"), 0, 10);
+    test(S("ofdrqmkeblthacpgijsn"), 0, 19);
+    test(S("gbmetiprqdoasckjfhln"), 0, 20);
+    test(S("bdfjqgatlksriohemnpc"), 1, 0);
+    test(S("crnklpmegdqfiashtojb"), 1, 1);
+    test(S("ejqcnahdrkfsmptilgbo"), 1, 9);
+    test(S("jsbtafedocnirgpmkhql"), 1, 18);
+    test(S("prqgnlbaejsmkhdctoif"), 1, 19);
+    test(S("qnmodrtkebhpasifgcjl"), 10, 0);
+    test(S("pejafmnokrqhtisbcdgl"), 10, 1);
+    test(S("cpebqsfmnjdolhkratgi"), 10, 5);
+    test(S("odnqkgijrhabfmcestlp"), 10, 9);
+    test(S("lmofqdhpkibagnrcjste"), 10, 10);
+    test(S("lgjqketopbfahrmnsicd"), 19, 0);
+    test(S("ktsrmnqagdecfhijpobl"), 19, 1);
+    test(S("lsaijeqhtrbgcdmpfkno"), 20, 0);
+    test(S("dplqartnfgejichmoskb"), 21, 0);
+    }
+#endif
+}
diff --git a/final/test/strings/basic.string/string.require/nothing_to_do.pass.cpp b/final/test/strings/basic.string/string.require/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/basic.string/string.require/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/basic.string/test_traits.h b/final/test/strings/basic.string/test_traits.h
new file mode 100644
index 0000000..f635b1d
--- /dev/null
+++ b/final/test/strings/basic.string/test_traits.h
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 TEST_TRAITS_H
+#define TEST_TRAITS_H
+
+template <class charT>
+struct test_traits
+{
+    typedef charT     char_type;
+};
+
+#endif  // TEST_TRAITS_H
diff --git a/final/test/strings/basic.string/types.pass.cpp b/final/test/strings/basic.string/types.pass.cpp
new file mode 100644
index 0000000..dcb3bbc
--- /dev/null
+++ b/final/test/strings/basic.string/types.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Test nested types and default template args:
+
+// template<class charT, class traits = char_traits<charT>,
+//   class Allocator = allocator<charT> >
+// {
+// public:
+//     // types:
+//     typedef traits traits_type;
+//     typedef typename traits::char_type value_type;
+//     typedef Allocator allocator_type;
+//     typedef typename Allocator::size_type size_type;
+//     typedef typename Allocator::difference_type difference_type;
+//     typedef typename Allocator::reference reference;
+//     typedef typename Allocator::const_reference const_reference;
+//     typedef typename Allocator::pointer pointer;
+//     typedef typename Allocator::const_pointer const_pointer;
+//     typedef implementation-defined iterator; // See 23.1
+//     typedef implementation-defined const_iterator; // See 23.1
+//     typedef std::reverse_iterator<iterator> reverse_iterator;
+//     typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+//     static const size_type npos = -1;
+// };
+
+#include <string>
+#include <iterator>
+#include <type_traits>
+
+#include "test_traits.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class Traits, class Allocator>
+void
+test()
+{
+    typedef std::basic_string<typename Traits::char_type, Traits, Allocator> S;
+
+    static_assert((std::is_same<typename S::traits_type, Traits>::value), "");
+    static_assert((std::is_same<typename S::value_type, typename Traits::char_type>::value), "");
+    static_assert((std::is_same<typename S::value_type, typename Allocator::value_type>::value), "");
+    static_assert((std::is_same<typename S::allocator_type, Allocator>::value), "");
+    static_assert((std::is_same<typename S::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
+    static_assert((std::is_same<typename S::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
+    static_assert((std::is_same<typename S::reference, typename S::value_type&>::value), "");
+    static_assert((std::is_same<typename S::const_reference, const typename S::value_type&>::value), "");
+    static_assert((std::is_same<typename S::pointer, typename std::allocator_traits<Allocator>::pointer>::value), "");
+    static_assert((std::is_same<typename S::const_pointer, typename std::allocator_traits<Allocator>::const_pointer>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename S::iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename std::iterator_traits<typename S::const_iterator>::iterator_category,
+        std::random_access_iterator_tag>::value), "");
+    static_assert((std::is_same<
+        typename S::reverse_iterator,
+        std::reverse_iterator<typename S::iterator> >::value), "");
+    static_assert((std::is_same<
+        typename S::const_reverse_iterator,
+        std::reverse_iterator<typename S::const_iterator> >::value), "");
+    static_assert(S::npos == -1, "");
+}
+
+int main()
+{
+    test<test_traits<char>, test_allocator<char> >();
+    test<std::char_traits<wchar_t>, std::allocator<wchar_t> >();
+    static_assert((std::is_same<std::basic_string<char>::traits_type,
+                                std::char_traits<char> >::value), "");
+    static_assert((std::is_same<std::basic_string<char>::allocator_type,
+                                std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+    test<std::char_traits<char>, min_allocator<char> >();
+#endif
+}
diff --git a/final/test/strings/c.strings/cctype.pass.cpp b/final/test/strings/c.strings/cctype.pass.cpp
new file mode 100644
index 0000000..867338f
--- /dev/null
+++ b/final/test/strings/c.strings/cctype.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cctype>
+
+#include <cctype>
+#include <type_traits>
+#include <cassert>
+
+#ifdef isalnum
+#error isalnum defined
+#endif
+
+#ifdef isalpha
+#error isalpha defined
+#endif
+
+#ifdef isblank
+#error isblank defined
+#endif
+
+#ifdef iscntrl
+#error iscntrl defined
+#endif
+
+#ifdef isdigit
+#error isdigit defined
+#endif
+
+#ifdef isgraph
+#error isgraph defined
+#endif
+
+#ifdef islower
+#error islower defined
+#endif
+
+#ifdef isprint
+#error isprint defined
+#endif
+
+#ifdef ispunct
+#error ispunct defined
+#endif
+
+#ifdef isspace
+#error isspace defined
+#endif
+
+#ifdef isupper
+#error isupper defined
+#endif
+
+#ifdef isxdigit
+#error isxdigit defined
+#endif
+
+#ifdef tolower
+#error tolower defined
+#endif
+
+#ifdef toupper
+#error toupper defined
+#endif
+
+int main()
+{
+    static_assert((std::is_same<decltype(std::isalnum(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isalpha(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isblank(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iscntrl(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isgraph(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::islower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isprint(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::ispunct(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isspace(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isupper(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::isxdigit(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::tolower(0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::toupper(0)), int>::value), "");
+
+    assert(isalnum('a'));
+    assert(isalpha('a'));
+    assert(isblank(' '));
+    assert(!iscntrl(' '));
+    assert(!isdigit('a'));
+    assert(isgraph('a'));
+    assert(islower('a'));
+    assert(isprint('a'));
+    assert(!ispunct('a'));
+    assert(!isspace('a'));
+    assert(!isupper('a'));
+    assert(isxdigit('a'));
+    assert(tolower('A') == 'a');
+    assert(toupper('a') == 'A');
+}
diff --git a/final/test/strings/c.strings/cstring.pass.cpp b/final/test/strings/c.strings/cstring.pass.cpp
new file mode 100644
index 0000000..5ed7e6c
--- /dev/null
+++ b/final/test/strings/c.strings/cstring.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstring>
+
+#include <cstring>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+int main()
+{
+    std::size_t s = 0;
+    void* vp = 0;
+    const void* vpc = 0;
+    char* cp = 0;
+    const char* cpc = 0;
+    static_assert((std::is_same<decltype(std::memcpy(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::memmove(vp, vpc, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::strcpy(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strncpy(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strcat(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strncat(cp, cpc, s)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::memcmp(vpc, vpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strcmp(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strncmp(cpc, cpc, s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strcoll(cpc, cpc)), int>::value), "");
+    static_assert((std::is_same<decltype(std::strxfrm(cp, cpc, s)), std::size_t>::value), "");
+//    static_assert((std::is_same<decltype(std::memchr(vpc, 0, s)), const void*>::value), "");
+    static_assert((std::is_same<decltype(std::memchr(vp, 0, s)), void*>::value), "");
+//    static_assert((std::is_same<decltype(std::strchr(cpc, 0)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strcspn(cpc, cpc)), std::size_t>::value), "");
+//    static_assert((std::is_same<decltype(std::strpbrk(cpc, cpc)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strpbrk(cp, cpc)), char*>::value), "");
+//    static_assert((std::is_same<decltype(std::strrchr(cpc, 0)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strrchr(cp, 0)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strspn(cpc, cpc)), std::size_t>::value), "");
+//    static_assert((std::is_same<decltype(std::strstr(cpc, cpc)), const char*>::value), "");
+    static_assert((std::is_same<decltype(std::strstr(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strtok(cp, cpc)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::memset(vp, 0, s)), void*>::value), "");
+    static_assert((std::is_same<decltype(std::strerror(0)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::strlen(cpc)), std::size_t>::value), "");
+}
diff --git a/final/test/strings/c.strings/cuchar.pass.cpp b/final/test/strings/c.strings/cuchar.pass.cpp
new file mode 100644
index 0000000..d4c15db
--- /dev/null
+++ b/final/test/strings/c.strings/cuchar.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <cuchar>
+
+#include <cuchar>
+
+int main()
+{
+}
diff --git a/final/test/strings/c.strings/cwchar.pass.cpp b/final/test/strings/c.strings/cwchar.pass.cpp
new file mode 100644
index 0000000..d0481b7
--- /dev/null
+++ b/final/test/strings/c.strings/cwchar.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwchar>
+
+#include <cwchar>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef WCHAR_MAX
+#error WCHAR_MAX not defined
+#endif
+
+#ifndef WCHAR_MIN
+#error WCHAR_MIN not defined
+#endif
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+int main()
+{
+    std::mbstate_t mb = {0};
+    std::size_t s = 0;
+    std::tm *tm = 0;
+    std::wint_t w = 0;
+    ::FILE* fp = 0;
+#ifdef __APPLE__
+    __darwin_va_list va;
+#else
+    __builtin_va_list va;
+#endif
+    char* ns = 0;
+    wchar_t* ws = 0;
+    static_assert((std::is_same<decltype(std::fwprintf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::fwscanf(fp, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::swprintf(ws, s, L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::swscanf(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfwprintf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vfwscanf(fp, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vswprintf(ws, s, L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vswscanf(L"", L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vwprintf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::wscanf(L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::fgetwc(fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::fgetws(ws, 0, fp)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::fputwc(L' ', fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::fputws(L"", fp)), int>::value), "");
+    static_assert((std::is_same<decltype(std::fwide(fp, 0)), int>::value), "");
+    static_assert((std::is_same<decltype(std::getwc(fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::getwchar()), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::putwc(L' ', fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::putwchar(L' ')), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::ungetwc(L' ', fp)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcstod(L"", (wchar_t**)0)), double>::value), "");
+    static_assert((std::is_same<decltype(std::wcstof(L"", (wchar_t**)0)), float>::value), "");
+    static_assert((std::is_same<decltype(std::wcstold(L"", (wchar_t**)0)), long double>::value), "");
+    static_assert((std::is_same<decltype(std::wcstol(L"", (wchar_t**)0, 0)), long>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoll(L"", (wchar_t**)0, 0)), long long>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), "");
+    static_assert((std::is_same<decltype(std::wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), "");
+    static_assert((std::is_same<decltype(std::wcscpy(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsncpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcscat(ws, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsncat(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcscmp(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::wcscoll(L"", L"")), int>::value), "");
+    static_assert((std::is_same<decltype(std::wcsncmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wcsxfrm(ws, L"", s)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcschr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcscspn(L"", L"")), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcslen(L"")), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsspn(L"", L"")), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcsstr((const wchar_t*)0, L"")), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsstr((wchar_t*)0, L"")), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemchr((const wchar_t*)0, L' ', s)), const wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemcmp(L"", L"", s)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wmemcpy(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemmove(ws, L"", s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wmemset(ws, L' ', s)), wchar_t*>::value), "");
+    static_assert((std::is_same<decltype(std::wcsftime(ws, s, L"", tm)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::btowc(0)), wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::wctob(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::mbsinit(&mb)), int>::value), "");
+    static_assert((std::is_same<decltype(std::mbrlen("", s, &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::mbrtowc(ws, "", s, &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcrtomb(ns, L' ', &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::mbsrtowcs(ws, (const char**)0, s, &mb)), std::size_t>::value), "");
+    static_assert((std::is_same<decltype(std::wcsrtombs(ns, (const wchar_t**)0, s, &mb)), std::size_t>::value), "");
+}
diff --git a/final/test/strings/c.strings/cwctype.pass.cpp b/final/test/strings/c.strings/cwctype.pass.cpp
new file mode 100644
index 0000000..6d66415
--- /dev/null
+++ b/final/test/strings/c.strings/cwctype.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwctype>
+
+#include <cwctype>
+#include <type_traits>
+
+#ifndef WEOF
+#error WEOF not defined
+#endif
+
+#ifdef iswalnum
+#error iswalnum defined
+#endif
+
+#ifdef iswalpha
+#error iswalpha defined
+#endif
+
+#ifdef iswblank
+#error iswblank defined
+#endif
+
+#ifdef iswcntrl
+#error iswcntrl defined
+#endif
+
+#ifdef iswdigit
+#error iswdigit defined
+#endif
+
+#ifdef iswgraph
+#error iswgraph defined
+#endif
+
+#ifdef iswlower
+#error iswlower defined
+#endif
+
+#ifdef iswprint
+#error iswprint defined
+#endif
+
+#ifdef iswpunct
+#error iswpunct defined
+#endif
+
+#ifdef iswspace
+#error iswspace defined
+#endif
+
+#ifdef iswupper
+#error iswupper defined
+#endif
+
+#ifdef iswxdigit
+#error iswxdigit defined
+#endif
+
+#ifdef iswctype
+#error iswctype defined
+#endif
+
+#ifdef wctype
+#error wctype defined
+#endif
+
+#ifdef towlower
+#error towlower defined
+#endif
+
+#ifdef towupper
+#error towupper defined
+#endif
+
+#ifdef towctrans
+#error towctrans defined
+#endif
+
+#ifdef wctrans
+#error wctrans defined
+#endif
+
+int main()
+{
+    std::wint_t w = 0;
+    std::wctrans_t wctr = 0;
+    std::wctype_t wct = 0;
+    static_assert((std::is_same<decltype(std::iswalnum(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswalpha(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswblank(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswcntrl(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswgraph(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswlower(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswprint(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswpunct(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswspace(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswupper(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswxdigit(w)), int>::value), "");
+    static_assert((std::is_same<decltype(std::iswctype(w, wct)), int>::value), "");
+    static_assert((std::is_same<decltype(std::wctype("")), std::wctype_t>::value), "");
+    static_assert((std::is_same<decltype(std::towlower(w)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::towupper(w)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::towctrans(w, wctr)), std::wint_t>::value), "");
+    static_assert((std::is_same<decltype(std::wctrans("")), std::wctrans_t>::value), "");
+}
diff --git a/final/test/strings/c.strings/version_cctype.pass.cpp b/final/test/strings/c.strings/version_cctype.pass.cpp
new file mode 100644
index 0000000..e0919d9
--- /dev/null
+++ b/final/test/strings/c.strings/version_cctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cctype>
+
+#include <cctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/strings/c.strings/version_cstring.pass.cpp b/final/test/strings/c.strings/version_cstring.pass.cpp
new file mode 100644
index 0000000..87e705a
--- /dev/null
+++ b/final/test/strings/c.strings/version_cstring.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstring>
+
+#include <cstring>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/strings/c.strings/version_cuchar.pass.cpp b/final/test/strings/c.strings/version_cuchar.pass.cpp
new file mode 100644
index 0000000..fa47f0f
--- /dev/null
+++ b/final/test/strings/c.strings/version_cuchar.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: apple-darwin
+
+// <cuchar>
+
+#include <cuchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/strings/c.strings/version_cwchar.pass.cpp b/final/test/strings/c.strings/version_cwchar.pass.cpp
new file mode 100644
index 0000000..72e9855
--- /dev/null
+++ b/final/test/strings/c.strings/version_cwchar.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwchar>
+
+#include <cwchar>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/strings/c.strings/version_cwctype.pass.cpp b/final/test/strings/c.strings/version_cwctype.pass.cpp
new file mode 100644
index 0000000..461482a
--- /dev/null
+++ b/final/test/strings/c.strings/version_cwctype.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cwctype>
+
+#include <cwctype>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp b/final/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp
new file mode 100644
index 0000000..2c3deae
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char c = '\0';
+    std::char_traits<char>::assign(c, 'a');
+    assert(c == 'a');
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp
new file mode 100644
index 0000000..2b19299
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    char s2[3] = {0};
+    assert(std::char_traits<char>::assign(s2, 3, char(5)) == s2);
+    assert(s2[0] == char(5));
+    assert(s2[1] == char(5));
+    assert(s2[2] == char(5));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp
new file mode 100644
index 0000000..a7190e7
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::compare("", "", 0) == 0);
+
+    assert(std::char_traits<char>::compare("1", "1", 1) == 0);
+    assert(std::char_traits<char>::compare("1", "2", 1) < 0);
+    assert(std::char_traits<char>::compare("2", "1", 1) > 0);
+
+    assert(std::char_traits<char>::compare("12", "12", 2) == 0);
+    assert(std::char_traits<char>::compare("12", "13", 2) < 0);
+    assert(std::char_traits<char>::compare("12", "22", 2) < 0);
+    assert(std::char_traits<char>::compare("13", "12", 2) > 0);
+    assert(std::char_traits<char>::compare("22", "12", 2) > 0);
+
+    assert(std::char_traits<char>::compare("123", "123", 3) == 0);
+    assert(std::char_traits<char>::compare("123", "223", 3) < 0);
+    assert(std::char_traits<char>::compare("123", "133", 3) < 0);
+    assert(std::char_traits<char>::compare("123", "124", 3) < 0);
+    assert(std::char_traits<char>::compare("223", "123", 3) > 0);
+    assert(std::char_traits<char>::compare("133", "123", 3) > 0);
+    assert(std::char_traits<char>::compare("124", "123", 3) > 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp
new file mode 100644
index 0000000..e57a677
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    char s2[3] = {0};
+    assert(std::char_traits<char>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == char(1));
+    assert(s2[1] == char(2));
+    assert(s2[2] == char(3));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp
new file mode 100644
index 0000000..39fba6b
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::eof() == EOF);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp
new file mode 100644
index 0000000..f7f84e8
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char c = '\0';
+    assert(std::char_traits<char>::eq('a', 'a'));
+    assert(!std::char_traits<char>::eq('a', 'A'));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp
new file mode 100644
index 0000000..bdaf431
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert( std::char_traits<char>::eq_int_type('a', 'a'));
+    assert(!std::char_traits<char>::eq_int_type('a', 'A'));
+    assert(!std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), 'A'));
+    assert( std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(),
+                                                std::char_traits<char>::eof()));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp
new file mode 100644
index 0000000..816b358
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    assert(std::char_traits<char>::find(s1, 3, char(1)) == s1);
+    assert(std::char_traits<char>::find(s1, 3, char(2)) == s1+1);
+    assert(std::char_traits<char>::find(s1, 3, char(3)) == s1+2);
+    assert(std::char_traits<char>::find(s1, 3, char(4)) == 0);
+    assert(std::char_traits<char>::find(s1, 3, char(0)) == 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp
new file mode 100644
index 0000000..56844ef
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::length("") == 0);
+    assert(std::char_traits<char>::length("a") == 1);
+    assert(std::char_traits<char>::length("aa") == 2);
+    assert(std::char_traits<char>::length("aaa") == 3);
+    assert(std::char_traits<char>::length("aaaa") == 4);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
new file mode 100644
index 0000000..3ff9c0f
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char c = '\0';
+    assert(!std::char_traits<char>::lt('a', 'a'));
+    assert( std::char_traits<char>::lt('A', 'a'));
+    assert(!std::char_traits<char>::lt('A' + 127, 'a'));
+    assert(!std::char_traits<char>::lt('A' - 127, 'a'));
+    assert( std::char_traits<char>::lt('A', 'a' + 127));
+    assert( std::char_traits<char>::lt('A', 'a' - 127));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp
new file mode 100644
index 0000000..691b28d
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    char s1[] = {1, 2, 3};
+    assert(std::char_traits<char>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == char(2));
+    assert(s1[1] == char(3));
+    assert(s1[2] == char(3));
+    s1[2] = char(0);
+    assert(std::char_traits<char>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == char(2));
+    assert(s1[1] == char(2));
+    assert(s1[2] == char(3));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp
new file mode 100644
index 0000000..6980096
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::not_eof('a') == 'a');
+    assert(std::char_traits<char>::not_eof('A') == 'A');
+    assert(std::char_traits<char>::not_eof(0) == 0);
+    assert(std::char_traits<char>::not_eof(std::char_traits<char>::eof()) !=
+           std::char_traits<char>::eof());
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp
new file mode 100644
index 0000000..498abfa
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::to_char_type('a') == 'a');
+    assert(std::char_traits<char>::to_char_type('A') == 'A');
+    assert(std::char_traits<char>::to_char_type(0) == 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp
new file mode 100644
index 0000000..aa9594c
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<char>::to_int_type('a') == 'a');
+    assert(std::char_traits<char>::to_int_type('A') == 'A');
+    assert(std::char_traits<char>::to_int_type(0) == 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp
new file mode 100644
index 0000000..ff4a93a
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char>
+
+// typedef char      char_type;
+// typedef int       int_type;
+// typedef streamoff off_type;
+// typedef streampos pos_type;
+// typedef mbstate_t state_type;
+
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::char_traits<char>::char_type, char>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::int_type, int>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::pos_type, std::streampos>::value), "");
+    static_assert((std::is_same<std::char_traits<char>::state_type, std::mbstate_t>::value), "");
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp
new file mode 100644
index 0000000..af87052
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    char16_t c = u'\0';
+    std::char_traits<char16_t>::assign(c, u'a');
+    assert(c == u'a');
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp
new file mode 100644
index 0000000..4d53439
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    char16_t s2[3] = {0};
+    assert(std::char_traits<char16_t>::assign(s2, 3, char16_t(5)) == s2);
+    assert(s2[0] == char16_t(5));
+    assert(s2[1] == char16_t(5));
+    assert(s2[2] == char16_t(5));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp
new file mode 100644
index 0000000..9f8461e
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0);
+
+    assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0);
+    assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0);
+    assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0);
+
+    assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0);
+    assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0);
+    assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0);
+    assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0);
+    assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0);
+
+    assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0);
+    assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0);
+    assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0);
+    assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0);
+    assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0);
+    assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0);
+    assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0);
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp
new file mode 100644
index 0000000..1ef4463
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    char16_t s2[3] = {0};
+    assert(std::char_traits<char16_t>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == char16_t(1));
+    assert(s2[1] == char16_t(2));
+    assert(s2[2] == char16_t(3));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp
new file mode 100644
index 0000000..4e5a183
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    std::char_traits<char16_t>::int_type i = std::char_traits<char16_t>::eof();
+#endif
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp
new file mode 100644
index 0000000..8216934
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    char16_t c = u'\0';
+    assert(std::char_traits<char16_t>::eq(u'a', u'a'));
+    assert(!std::char_traits<char16_t>::eq(u'a', u'A'));
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp
new file mode 100644
index 0000000..a20aa7d
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert( std::char_traits<char16_t>::eq_int_type(u'a', u'a'));
+    assert(!std::char_traits<char16_t>::eq_int_type(u'a', u'A'));
+    assert(!std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), u'A'));
+#endif
+    assert( std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(),
+                                                    std::char_traits<char16_t>::eof()));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp
new file mode 100644
index 0000000..0952d5a
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(1)) == s1);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(2)) == s1+1);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(3)) == s1+2);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0);
+    assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp
new file mode 100644
index 0000000..9f6acca
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char16_t>::length(u"") == 0);
+    assert(std::char_traits<char16_t>::length(u"a") == 1);
+    assert(std::char_traits<char16_t>::length(u"aa") == 2);
+    assert(std::char_traits<char16_t>::length(u"aaa") == 3);
+    assert(std::char_traits<char16_t>::length(u"aaaa") == 4);
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp
new file mode 100644
index 0000000..135ecc0
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    char16_t c = u'\0';
+    assert(!std::char_traits<char16_t>::lt(u'a', u'a'));
+    assert( std::char_traits<char16_t>::lt(u'A', u'a'));
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp
new file mode 100644
index 0000000..1839b91
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char16_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char16_t>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == char16_t(2));
+    assert(s1[1] == char16_t(3));
+    assert(s1[2] == char16_t(3));
+    s1[2] = char16_t(0);
+    assert(std::char_traits<char16_t>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == char16_t(2));
+    assert(s1[1] == char16_t(2));
+    assert(s1[2] == char16_t(3));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp
new file mode 100644
index 0000000..3c213e6
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char16_t>::not_eof(u'a') == u'a');
+    assert(std::char_traits<char16_t>::not_eof(u'A') == u'A');
+#endif
+    assert(std::char_traits<char16_t>::not_eof(0) == 0);
+    assert(std::char_traits<char16_t>::not_eof(std::char_traits<char16_t>::eof()) !=
+           std::char_traits<char16_t>::eof());
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp
new file mode 100644
index 0000000..ab47403
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char16_t>::to_char_type(u'a') == u'a');
+    assert(std::char_traits<char16_t>::to_char_type(u'A') == u'A');
+#endif
+    assert(std::char_traits<char16_t>::to_char_type(0) == 0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp
new file mode 100644
index 0000000..11eb8f5
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char16_t>::to_int_type(u'a') == u'a');
+    assert(std::char_traits<char16_t>::to_int_type(u'A') == u'A');
+#endif
+    assert(std::char_traits<char16_t>::to_int_type(0) == 0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp
new file mode 100644
index 0000000..a40296b
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char16_t>
+
+// typedef char16_t       char_type;
+// typedef uint_least16_t int_type;
+// typedef streamoff      off_type;
+// typedef u16streampos   pos_type;
+// typedef mbstate_t      state_type;
+
+#include <string>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    static_assert((std::is_same<std::char_traits<char16_t>::char_type, char16_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::int_type, std::uint_least16_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::pos_type, std::u16streampos>::value), "");
+    static_assert((std::is_same<std::char_traits<char16_t>::state_type, std::mbstate_t>::value), "");
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp
new file mode 100644
index 0000000..35dcd96
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    char32_t c = U'\0';
+    std::char_traits<char32_t>::assign(c, U'a');
+    assert(c == U'a');
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp
new file mode 100644
index 0000000..cce0420
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    char32_t s2[3] = {0};
+    assert(std::char_traits<char32_t>::assign(s2, 3, char32_t(5)) == s2);
+    assert(s2[0] == char32_t(5));
+    assert(s2[1] == char32_t(5));
+    assert(s2[2] == char32_t(5));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp
new file mode 100644
index 0000000..ee3019c
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0);
+
+    assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0);
+    assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0);
+    assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0);
+
+    assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0);
+    assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0);
+    assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0);
+    assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0);
+    assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0);
+
+    assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0);
+    assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0);
+    assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0);
+    assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0);
+    assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0);
+    assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0);
+    assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0);
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp
new file mode 100644
index 0000000..5f23514
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    char32_t s2[3] = {0};
+    assert(std::char_traits<char32_t>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == char32_t(1));
+    assert(s2[1] == char32_t(2));
+    assert(s2[2] == char32_t(3));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp
new file mode 100644
index 0000000..8f804aa
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    std::char_traits<char32_t>::int_type i = std::char_traits<char32_t>::eof();
+#endif
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp
new file mode 100644
index 0000000..ffeff0c
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    char32_t c = U'\0';
+    assert(std::char_traits<char32_t>::eq(U'a', U'a'));
+    assert(!std::char_traits<char32_t>::eq(U'a', U'A'));
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp
new file mode 100644
index 0000000..eb5c696
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert( std::char_traits<char32_t>::eq_int_type(U'a', U'a'));
+    assert(!std::char_traits<char32_t>::eq_int_type(U'a', U'A'));
+    assert(!std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), U'A'));
+#endif
+    assert( std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(),
+                                                    std::char_traits<char32_t>::eof()));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp
new file mode 100644
index 0000000..148fc0c
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(1)) == s1);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(2)) == s1+1);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(3)) == s1+2);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(4)) == 0);
+    assert(std::char_traits<char32_t>::find(s1, 3, char32_t(0)) == 0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp
new file mode 100644
index 0000000..d80ce05
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char32_t>::length(U"") == 0);
+    assert(std::char_traits<char32_t>::length(U"a") == 1);
+    assert(std::char_traits<char32_t>::length(U"aa") == 2);
+    assert(std::char_traits<char32_t>::length(U"aaa") == 3);
+    assert(std::char_traits<char32_t>::length(U"aaaa") == 4);
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp
new file mode 100644
index 0000000..f667507
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    char32_t c = U'\0';
+    assert(!std::char_traits<char32_t>::lt(U'a', U'a'));
+    assert( std::char_traits<char32_t>::lt(U'A', U'a'));
+#endif
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
new file mode 100644
index 0000000..6fbc6d9
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    char32_t s1[] = {1, 2, 3};
+    assert(std::char_traits<char32_t>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == char32_t(2));
+    assert(s1[1] == char32_t(3));
+    assert(s1[2] == char32_t(3));
+    s1[2] = char32_t(0);
+    assert(std::char_traits<char32_t>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == char32_t(2));
+    assert(s1[1] == char32_t(2));
+    assert(s1[2] == char32_t(3));
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp
new file mode 100644
index 0000000..d794417
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char32_t>::not_eof(U'a') == U'a');
+    assert(std::char_traits<char32_t>::not_eof(U'A') == U'A');
+#endif
+    assert(std::char_traits<char32_t>::not_eof(0) == 0);
+    assert(std::char_traits<char32_t>::not_eof(std::char_traits<char32_t>::eof()) !=
+           std::char_traits<char32_t>::eof());
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp
new file mode 100644
index 0000000..1f67242
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char32_t>::to_char_type(U'a') == U'a');
+    assert(std::char_traits<char32_t>::to_char_type(U'A') == U'A');
+#endif
+    assert(std::char_traits<char32_t>::to_char_type(0) == 0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp
new file mode 100644
index 0000000..a378186
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+#if __cplusplus >= 201103L
+    assert(std::char_traits<char32_t>::to_int_type(U'a') == U'a');
+    assert(std::char_traits<char32_t>::to_int_type(U'A') == U'A');
+#endif
+    assert(std::char_traits<char32_t>::to_int_type(0) == 0);
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp
new file mode 100644
index 0000000..3b48af1
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<char32_t>
+
+// typedef char32_t       char_type;
+// typedef uint_least32_t int_type;
+// typedef streamoff      off_type;
+// typedef u32streampos   pos_type;
+// typedef mbstate_t      state_type;
+
+#include <string>
+#include <type_traits>
+#include <cstdint>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    static_assert((std::is_same<std::char_traits<char32_t>::char_type, char32_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::int_type, std::uint_least32_t>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::pos_type, std::u32streampos>::value), "");
+    static_assert((std::is_same<std::char_traits<char32_t>::state_type, std::mbstate_t>::value), "");
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
new file mode 100644
index 0000000..7dcf08c
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static void assign(char_type& c1, const char_type& c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t c = L'\0';
+    std::char_traits<wchar_t>::assign(c, L'a');
+    assert(c == L'a');
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp
new file mode 100644
index 0000000..4c5ff47
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* assign(char_type* s, size_t n, char_type a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    wchar_t s2[3] = {0};
+    assert(std::char_traits<wchar_t>::assign(s2, 3, wchar_t(5)) == s2);
+    assert(s2[0] == wchar_t(5));
+    assert(s2[1] == wchar_t(5));
+    assert(s2[2] == wchar_t(5));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
new file mode 100644
index 0000000..046398b
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static int compare(const char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::compare(L"", L"", 0) == 0);
+
+    assert(std::char_traits<wchar_t>::compare(L"1", L"1", 1) == 0);
+    assert(std::char_traits<wchar_t>::compare(L"1", L"2", 1) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"2", L"1", 1) > 0);
+
+    assert(std::char_traits<wchar_t>::compare(L"12", L"12", 2) == 0);
+    assert(std::char_traits<wchar_t>::compare(L"12", L"13", 2) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"12", L"22", 2) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"13", L"12", 2) > 0);
+    assert(std::char_traits<wchar_t>::compare(L"22", L"12", 2) > 0);
+
+    assert(std::char_traits<wchar_t>::compare(L"123", L"123", 3) == 0);
+    assert(std::char_traits<wchar_t>::compare(L"123", L"223", 3) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"123", L"133", 3) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"123", L"124", 3) < 0);
+    assert(std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0);
+    assert(std::char_traits<wchar_t>::compare(L"133", L"123", 3) > 0);
+    assert(std::char_traits<wchar_t>::compare(L"124", L"123", 3) > 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp
new file mode 100644
index 0000000..71ed6fb
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    wchar_t s2[3] = {0};
+    assert(std::char_traits<wchar_t>::copy(s2, s1, 3) == s2);
+    assert(s2[0] == wchar_t(1));
+    assert(s2[1] == wchar_t(2));
+    assert(s2[2] == wchar_t(3));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp
new file mode 100644
index 0000000..61499b5
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type eof();
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::eof() == WEOF);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
new file mode 100644
index 0000000..98d0926
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool eq(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t c = L'\0';
+    assert(std::char_traits<wchar_t>::eq(L'a', L'a'));
+    assert(!std::char_traits<wchar_t>::eq(L'a', L'A'));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp
new file mode 100644
index 0000000..6b523db
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool eq_int_type(int_type c1, int_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert( std::char_traits<wchar_t>::eq_int_type(L'a', L'a'));
+    assert(!std::char_traits<wchar_t>::eq_int_type(L'a', L'A'));
+    assert(!std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), L'A'));
+    assert( std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(),
+                                                   std::char_traits<wchar_t>::eof()));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
new file mode 100644
index 0000000..4975739
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static const char_type* find(const char_type* s, size_t n, const char_type& a);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(1)) == s1);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(2)) == s1+1);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(3)) == s1+2);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(4)) == 0);
+    assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(0)) == 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp
new file mode 100644
index 0000000..691e968
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static size_t length(const char_type* s);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::length(L"") == 0);
+    assert(std::char_traits<wchar_t>::length(L"a") == 1);
+    assert(std::char_traits<wchar_t>::length(L"aa") == 2);
+    assert(std::char_traits<wchar_t>::length(L"aaa") == 3);
+    assert(std::char_traits<wchar_t>::length(L"aaaa") == 4);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
new file mode 100644
index 0000000..147a579
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr bool lt(char_type c1, char_type c2);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t c = L'\0';
+    assert(!std::char_traits<wchar_t>::lt(L'a', L'a'));
+    assert( std::char_traits<wchar_t>::lt(L'A', L'a'));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp
new file mode 100644
index 0000000..f19fa93
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static char_type* move(char_type* s1, const char_type* s2, size_t n);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    wchar_t s1[] = {1, 2, 3};
+    assert(std::char_traits<wchar_t>::move(s1, s1+1, 2) == s1);
+    assert(s1[0] == wchar_t(2));
+    assert(s1[1] == wchar_t(3));
+    assert(s1[2] == wchar_t(3));
+    s1[2] = wchar_t(0);
+    assert(std::char_traits<wchar_t>::move(s1+1, s1, 2) == s1+1);
+    assert(s1[0] == wchar_t(2));
+    assert(s1[1] == wchar_t(2));
+    assert(s1[2] == wchar_t(3));
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp
new file mode 100644
index 0000000..ee44f31
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type not_eof(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::not_eof(L'a') == L'a');
+    assert(std::char_traits<wchar_t>::not_eof(L'A') == L'A');
+    assert(std::char_traits<wchar_t>::not_eof(0) == 0);
+    assert(std::char_traits<wchar_t>::not_eof(std::char_traits<wchar_t>::eof()) !=
+           std::char_traits<wchar_t>::eof());
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp
new file mode 100644
index 0000000..9b4c048
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr char_type to_char_type(int_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::to_char_type(L'a') == L'a');
+    assert(std::char_traits<wchar_t>::to_char_type(L'A') == L'A');
+    assert(std::char_traits<wchar_t>::to_char_type(0) == 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp
new file mode 100644
index 0000000..488b03e
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// static constexpr int_type to_int_type(char_type c);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::char_traits<wchar_t>::to_int_type(L'a') == L'a');
+    assert(std::char_traits<wchar_t>::to_int_type(L'A') == L'A');
+    assert(std::char_traits<wchar_t>::to_int_type(0) == 0);
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp
new file mode 100644
index 0000000..1259897
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// template<> struct char_traits<wchar_t>
+
+// typedef wchar_t   char_type;
+// typedef int       int_type;
+// typedef streamoff off_type;
+// typedef streampos pos_type;
+// typedef mbstate_t state_type;
+
+#include <string>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::char_traits<wchar_t>::char_type, wchar_t>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::int_type, std::wint_t>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::off_type, std::streamoff>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::pos_type, std::wstreampos>::value), "");
+    static_assert((std::is_same<std::char_traits<wchar_t>::state_type, std::mbstate_t>::value), "");
+}
diff --git a/final/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp b/final/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp b/final/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/char.traits/nothing_to_do.pass.cpp b/final/test/strings/char.traits/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/strings/char.traits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/string.classes/typedefs.pass.cpp b/final/test/strings/string.classes/typedefs.pass.cpp
new file mode 100644
index 0000000..11ee6c8
--- /dev/null
+++ b/final/test/strings/string.classes/typedefs.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// Test for the existence of:
+
+// basic_string typedef names
+// typedef basic_string<char> string;
+// typedef basic_string<char16_t> u16string;
+// typedef basic_string<char32_t> u32string;
+// typedef basic_string<wchar_t> wstring;
+
+#include <string>
+
+int main()
+{
+    typedef std::string test1;
+    typedef std::wstring test2;
+#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
+    typedef std::u16string test3;
+    typedef std::u32string test4;
+#endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
+}
diff --git a/final/test/strings/string.conversions/stod.pass.cpp b/final/test/strings/string.conversions/stod.pass.cpp
new file mode 100644
index 0000000..026d230
--- /dev/null
+++ b/final/test/strings/string.conversions/stod.pass.cpp
@@ -0,0 +1,166 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// double stod(const string& str, size_t *idx = 0);
+// double stod(const wstring& str, size_t *idx = 0);
+
+#include <string>
+#include <cmath>
+#include <cassert>
+
+int main()
+{
+    assert(std::stod("0") == 0);
+    assert(std::stod(L"0") == 0);
+    assert(std::stod("-0") == 0);
+    assert(std::stod(L"-0") == 0);
+    assert(std::stod("-10") == -10);
+    assert(std::stod(L"-10.5") == -10.5);
+    assert(std::stod(" 10") == 10);
+    assert(std::stod(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stod("10g", &idx) == 10);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stod(L"10g", &idx) == 10);
+    assert(idx == 2);
+    try
+    {
+        assert(std::stod("1.e60", &idx) == 1.e60);
+        assert(idx == 5);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    try
+    {
+        assert(std::stod(L"1.e60", &idx) == 1.e60);
+        assert(idx == 5);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::stod("1.e360", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        assert(std::stod(L"1.e360", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        assert(std::stod("INF", &idx) == INFINITY);
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::stod(L"INF", &idx) == INFINITY);
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::isnan(std::stod("NAN", &idx)));
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::isnan(std::stod(L"NAN", &idx)));
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        std::stod("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stod(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stod("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stod(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stod("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stod(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/stof.pass.cpp b/final/test/strings/string.conversions/stof.pass.cpp
new file mode 100644
index 0000000..65809cb
--- /dev/null
+++ b/final/test/strings/string.conversions/stof.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <string>
+
+// float stof(const string& str, size_t *idx = 0);
+// float stof(const wstring& str, size_t *idx = 0);
+
+#include <string>
+#include <cmath>
+#include <cassert>
+
+int main()
+{
+    assert(std::stof("0") == 0);
+    assert(std::stof(L"0") == 0);
+    assert(std::stof("-0") == 0);
+    assert(std::stof(L"-0") == 0);
+    assert(std::stof("-10") == -10);
+    assert(std::stof(L"-10.5") == -10.5);
+    assert(std::stof(" 10") == 10);
+    assert(std::stof(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stof("10g", &idx) == 10);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stof(L"10g", &idx) == 10);
+    assert(idx == 2);
+    idx = 0;
+    try
+    {
+        assert(std::stof("1.e60", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        assert(std::stof(L"1.e60", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::stof("1.e360", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        assert(std::stof(L"1.e360", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        assert(std::stof("INF", &idx) == INFINITY);
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::stof(L"INF", &idx) == INFINITY);
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::isnan(std::stof("NAN", &idx)));
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::isnan(std::stof(L"NAN", &idx)));
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        std::stof("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stof(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stof("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stof(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stof("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stof(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/stoi.pass.cpp b/final/test/strings/string.conversions/stoi.pass.cpp
new file mode 100644
index 0000000..c2fc210
--- /dev/null
+++ b/final/test/strings/string.conversions/stoi.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// int stoi(const string& str, size_t *idx = 0, int base = 10);
+// int stoi(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::stoi("0") == 0);
+    assert(std::stoi(L"0") == 0);
+    assert(std::stoi("-0") == 0);
+    assert(std::stoi(L"-0") == 0);
+    assert(std::stoi("-10") == -10);
+    assert(std::stoi(L"-10") == -10);
+    assert(std::stoi(" 10") == 10);
+    assert(std::stoi(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stoi("10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stoi(L"10g", &idx, 16) == 16);
+    assert(idx == 2);
+    if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max())
+    {
+        try
+        {
+            std::stoi("0x100000000", &idx, 16);
+            assert(false);
+        }
+        catch (const std::out_of_range&)
+        {
+        }
+        try
+        {
+            std::stoi(L"0x100000000", &idx, 16);
+            assert(false);
+        }
+        catch (const std::out_of_range&)
+        {
+        }
+    }
+    idx = 0;
+    try
+    {
+        std::stoi("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoi(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoi("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoi(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoi("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoi(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/stol.pass.cpp b/final/test/strings/string.conversions/stol.pass.cpp
new file mode 100644
index 0000000..d1cd75d
--- /dev/null
+++ b/final/test/strings/string.conversions/stol.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <string>
+
+// long stol(const string& str, size_t *idx = 0, int base = 10);
+// long stol(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::stol("0") == 0);
+    assert(std::stol(L"0") == 0);
+    assert(std::stol("-0") == 0);
+    assert(std::stol(L"-0") == 0);
+    assert(std::stol("-10") == -10);
+    assert(std::stol(L"-10") == -10);
+    assert(std::stol(" 10") == 10);
+    assert(std::stol(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stol("10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stol(L"10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    try
+    {
+        std::stol("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stol(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stol("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stol(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stol("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stol(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+//  LWG issue #2009
+    try
+    {
+        std::stol("9999999999999999999999999999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stol(L"9999999999999999999999999999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/stold.pass.cpp b/final/test/strings/string.conversions/stold.pass.cpp
new file mode 100644
index 0000000..93c59fe
--- /dev/null
+++ b/final/test/strings/string.conversions/stold.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// long double stold(const string& str, size_t *idx = 0);
+// long double stold(const wstring& str, size_t *idx = 0);
+
+#include <iostream>
+
+#include <string>
+#include <cmath>
+#include <cassert>
+
+int main()
+{
+    assert(std::stold("0") == 0);
+    assert(std::stold(L"0") == 0);
+    assert(std::stold("-0") == 0);
+    assert(std::stold(L"-0") == 0);
+    assert(std::stold("-10") == -10);
+    assert(std::stold(L"-10.5") == -10.5);
+    assert(std::stold(" 10") == 10);
+    assert(std::stold(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stold("10g", &idx) == 10);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stold(L"10g", &idx) == 10);
+    assert(idx == 2);
+    try
+    {
+        assert(std::stold("1.e60", &idx) == 1.e60L);
+        assert(idx == 5);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    try
+    {
+        assert(std::stold(L"1.e60", &idx) == 1.e60L);
+        assert(idx == 5);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::stold("1.e6000", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        assert(std::stold(L"1.e6000", &idx) == INFINITY);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        assert(std::stold("INF", &idx) == INFINITY);
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::stold(L"INF", &idx) == INFINITY);
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::isnan(std::stold("NAN", &idx)));
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        assert(std::isnan(std::stold(L"NAN", &idx)));
+        assert(idx == 3);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(false);
+    }
+    idx = 0;
+    try
+    {
+        std::stold("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stold(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stold("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stold(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stold("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stold(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/stoll.pass.cpp b/final/test/strings/string.conversions/stoll.pass.cpp
new file mode 100644
index 0000000..11f15e1
--- /dev/null
+++ b/final/test/strings/string.conversions/stoll.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <string>
+
+// long long stoll(const string& str, size_t *idx = 0, int base = 10);
+// long long stoll(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::stoll("0") == 0);
+    assert(std::stoll(L"0") == 0);
+    assert(std::stoll("-0") == 0);
+    assert(std::stoll(L"-0") == 0);
+    assert(std::stoll("-10") == -10);
+    assert(std::stoll(L"-10") == -10);
+    assert(std::stoll(" 10") == 10);
+    assert(std::stoll(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stoll("10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stoll(L"10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    try
+    {
+        std::stoll("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoll(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoll("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoll(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoll("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoll(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoll("99999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoll(L"99999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/stoul.pass.cpp b/final/test/strings/string.conversions/stoul.pass.cpp
new file mode 100644
index 0000000..fcd19e8
--- /dev/null
+++ b/final/test/strings/string.conversions/stoul.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <string>
+
+// unsigned long stoul(const string& str, size_t *idx = 0, int base = 10);
+// unsigned long stoul(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::stoul("0") == 0);
+    assert(std::stoul(L"0") == 0);
+    assert(std::stoul("-0") == 0);
+    assert(std::stoul(L"-0") == 0);
+    assert(std::stoul(" 10") == 10);
+    assert(std::stoul(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stoul("10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stoul(L"10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    try
+    {
+        std::stoul("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoul(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoul("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoul(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoul("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoul(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+//  LWG issue #2009
+    try
+    {
+        std::stoul("9999999999999999999999999999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoul(L"9999999999999999999999999999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/stoull.pass.cpp b/final/test/strings/string.conversions/stoull.pass.cpp
new file mode 100644
index 0000000..b1a2f9f
--- /dev/null
+++ b/final/test/strings/string.conversions/stoull.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <string>
+
+// unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);
+// unsigned long long stoull(const wstring& str, size_t *idx = 0, int base = 10);
+
+#include <string>
+#include <cassert>
+
+int main()
+{
+    assert(std::stoull("0") == 0);
+    assert(std::stoull(L"0") == 0);
+    assert(std::stoull("-0") == 0);
+    assert(std::stoull(L"-0") == 0);
+    assert(std::stoull(" 10") == 10);
+    assert(std::stoull(L" 10") == 10);
+    size_t idx = 0;
+    assert(std::stoull("10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    assert(std::stoull(L"10g", &idx, 16) == 16);
+    assert(idx == 2);
+    idx = 0;
+    try
+    {
+        std::stoull("", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    idx = 0;
+    try
+    {
+        std::stoull(L"", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoull("  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoull(L"  - 8", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoull("a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoull(L"a1", &idx);
+        assert(false);
+    }
+    catch (const std::invalid_argument&)
+    {
+        assert(idx == 0);
+    }
+//  LWG issue #2009
+    try
+    {
+        std::stoull("9999999999999999999999999999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+    try
+    {
+        std::stoull(L"9999999999999999999999999999999999999999999999999", &idx);
+        assert(false);
+    }
+    catch (const std::out_of_range&)
+    {
+        assert(idx == 0);
+    }
+}
diff --git a/final/test/strings/string.conversions/to_string.pass.cpp b/final/test/strings/string.conversions/to_string.pass.cpp
new file mode 100644
index 0000000..05e5e4b
--- /dev/null
+++ b/final/test/strings/string.conversions/to_string.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// string to_string(int val);
+// string to_string(unsigned val);
+// string to_string(long val);
+// string to_string(unsigned long val);
+// string to_string(long long val);
+// string to_string(unsigned long long val);
+// string to_string(float val);
+// string to_string(double val);
+// string to_string(long double val);
+
+#include <string>
+#include <cassert>
+#include <sstream>
+
+template <class T>
+void
+test_signed()
+{
+    {
+        std::string s = std::to_string(T(0));
+        assert(s.size() == 1);
+        assert(s[s.size()] == 0);
+        assert(s == "0");
+    }
+    {
+        std::string s = std::to_string(T(12345));
+        assert(s.size() == 5);
+        assert(s[s.size()] == 0);
+        assert(s == "12345");
+    }
+    {
+        std::string s = std::to_string(T(-12345));
+        assert(s.size() == 6);
+        assert(s[s.size()] == 0);
+        assert(s == "-12345");
+    }
+    {
+        std::string s = std::to_string(std::numeric_limits<T>::max());
+        assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+        std::istringstream is(s);
+        T t(0);
+        is >> t;
+        assert(t == std::numeric_limits<T>::max());
+    }
+    {
+        std::string s = std::to_string(std::numeric_limits<T>::min());
+        std::istringstream is(s);
+        T t(0);
+        is >> t;
+        assert(t == std::numeric_limits<T>::min());
+    }
+}
+
+template <class T>
+void
+test_unsigned()
+{
+    {
+        std::string s = std::to_string(T(0));
+        assert(s.size() == 1);
+        assert(s[s.size()] == 0);
+        assert(s == "0");
+    }
+    {
+        std::string s = std::to_string(T(12345));
+        assert(s.size() == 5);
+        assert(s[s.size()] == 0);
+        assert(s == "12345");
+    }
+    {
+        std::string s = std::to_string(std::numeric_limits<T>::max());
+        assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+        std::istringstream is(s);
+        T t(0);
+        is >> t;
+        assert(t == std::numeric_limits<T>::max());
+    }
+}
+
+template <class T>
+void
+test_float()
+{
+    {
+        std::string s = std::to_string(T(0));
+        assert(s.size() == 8);
+        assert(s[s.size()] == 0);
+        assert(s == "0.000000");
+    }
+    {
+        std::string s = std::to_string(T(12345));
+        assert(s.size() == 12);
+        assert(s[s.size()] == 0);
+        assert(s == "12345.000000");
+    }
+    {
+        std::string s = std::to_string(T(-12345));
+        assert(s.size() == 13);
+        assert(s[s.size()] == 0);
+        assert(s == "-12345.000000");
+    }
+}
+
+int main()
+{
+    test_signed<int>();
+    test_signed<long>();
+    test_signed<long long>();
+    test_unsigned<unsigned>();
+    test_unsigned<unsigned long>();
+    test_unsigned<unsigned long long>();
+    test_float<float>();
+    test_float<double>();
+    test_float<long double>();
+}
diff --git a/final/test/strings/string.conversions/to_wstring.pass.cpp b/final/test/strings/string.conversions/to_wstring.pass.cpp
new file mode 100644
index 0000000..281aa1a
--- /dev/null
+++ b/final/test/strings/string.conversions/to_wstring.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+// wstring to_wstring(int val);
+// wstring to_wstring(unsigned val);
+// wstring to_wstring(long val);
+// wstring to_wstring(unsigned long val);
+// wstring to_wstring(long long val);
+// wstring to_wstring(unsigned long long val);
+// wstring to_wstring(float val);
+// wstring to_wstring(double val);
+// wstring to_wstring(long double val);
+
+#include <string>
+#include <cassert>
+#include <sstream>
+
+template <class T>
+void
+test_signed()
+{
+    {
+        std::wstring s = std::to_wstring(T(0));
+        assert(s.size() == 1);
+        assert(s[s.size()] == 0);
+        assert(s == L"0");
+    }
+    {
+        std::wstring s = std::to_wstring(T(12345));
+        assert(s.size() == 5);
+        assert(s[s.size()] == 0);
+        assert(s == L"12345");
+    }
+    {
+        std::wstring s = std::to_wstring(T(-12345));
+        assert(s.size() == 6);
+        assert(s[s.size()] == 0);
+        assert(s == L"-12345");
+    }
+    {
+        std::wstring s = std::to_wstring(std::numeric_limits<T>::max());
+        assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+        std::wistringstream is(s);
+        T t(0);
+        is >> t;
+        assert(t == std::numeric_limits<T>::max());
+    }
+    {
+        std::wstring s = std::to_wstring(std::numeric_limits<T>::min());
+        std::wistringstream is(s);
+        T t(0);
+        is >> t;
+        assert(t == std::numeric_limits<T>::min());
+    }
+}
+
+template <class T>
+void
+test_unsigned()
+{
+    {
+        std::wstring s = std::to_wstring(T(0));
+        assert(s.size() == 1);
+        assert(s[s.size()] == 0);
+        assert(s == L"0");
+    }
+    {
+        std::wstring s = std::to_wstring(T(12345));
+        assert(s.size() == 5);
+        assert(s[s.size()] == 0);
+        assert(s == L"12345");
+    }
+    {
+        std::wstring s = std::to_wstring(std::numeric_limits<T>::max());
+        assert(s.size() == std::numeric_limits<T>::digits10 + 1);
+        std::wistringstream is(s);
+        T t(0);
+        is >> t;
+        assert(t == std::numeric_limits<T>::max());
+    }
+}
+
+template <class T>
+void
+test_float()
+{
+    {
+        std::wstring s = std::to_wstring(T(0));
+        assert(s.size() == 8);
+        assert(s[s.size()] == 0);
+        assert(s == L"0.000000");
+    }
+    {
+        std::wstring s = std::to_wstring(T(12345));
+        assert(s.size() == 12);
+        assert(s[s.size()] == 0);
+        assert(s == L"12345.000000");
+    }
+    {
+        std::wstring s = std::to_wstring(T(-12345));
+        assert(s.size() == 13);
+        assert(s[s.size()] == 0);
+        assert(s == L"-12345.000000");
+    }
+}
+
+int main()
+{
+    test_signed<int>();
+    test_signed<long>();
+    test_signed<long long>();
+    test_unsigned<unsigned>();
+    test_unsigned<unsigned long>();
+    test_unsigned<unsigned long long>();
+    test_float<float>();
+    test_float<double>();
+    test_float<long double>();
+}
diff --git a/final/test/strings/strings.general/nothing_to_do.pass.cpp b/final/test/strings/strings.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/strings/strings.general/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/strings/version.pass.cpp b/final/test/strings/version.pass.cpp
new file mode 100644
index 0000000..0c79c1a
--- /dev/null
+++ b/final/test/strings/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <string>
+
+#include <string>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/support/DefaultOnly.h b/final/test/support/DefaultOnly.h
new file mode 100644
index 0000000..a3d4303
--- /dev/null
+++ b/final/test/support/DefaultOnly.h
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 DEFAULTONLY_H
+#define DEFAULTONLY_H
+
+#include <cassert>
+
+class DefaultOnly
+{
+    int data_;
+
+    DefaultOnly(const DefaultOnly&);
+    DefaultOnly& operator=(const DefaultOnly&);
+public:
+    static int count;
+
+    DefaultOnly() : data_(-1) {++count;}
+    ~DefaultOnly() {data_ = 0; --count;}
+
+    friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
+        {return x.data_ == y.data_;}
+    friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
+        {return x.data_ < y.data_;}
+};
+
+int DefaultOnly::count = 0;
+
+#endif  // DEFAULTONLY_H
diff --git a/final/test/support/allocators.h b/final/test/support/allocators.h
new file mode 100644
index 0000000..5372c07
--- /dev/null
+++ b/final/test/support/allocators.h
@@ -0,0 +1,183 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 ALLOCATORS_H
+#define ALLOCATORS_H
+
+#include <type_traits>
+#include <utility>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class T>
+class A1
+{
+    int id_;
+public:
+    explicit A1(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool allocate_called;
+    static std::pair<T*, std::size_t> deallocate_called;
+
+    A1(const A1& a) : id_(a.id()) {copy_called = true;}
+    A1(A1&& a) : id_(a.id())      {move_called = true;}
+
+    template <class U>
+        A1(const A1<U>& a) : id_(a.id()) {copy_called = true;}
+    template <class U>
+        A1(A1<U>&& a) : id_(a.id()) {move_called = true;}
+
+    T* allocate(std::size_t n)
+    {
+        allocate_called = true;
+        return (T*)n;
+    }
+
+    void deallocate(T* p, std::size_t n)
+    {
+        deallocate_called = std::pair<T*, std::size_t>(p, n);
+    }
+
+    std::size_t max_size() const {return id_;}
+};
+
+template <class T> bool A1<T>::copy_called = false;
+template <class T> bool A1<T>::move_called = false;
+template <class T> bool A1<T>::allocate_called = false;
+template <class T> std::pair<T*, std::size_t> A1<T>::deallocate_called;
+
+template <class T, class U>
+inline
+bool operator==(const A1<T>& x, const A1<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A1<T>& x, const A1<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T>
+class A2
+{
+    int id_;
+public:
+    explicit A2(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    typedef unsigned size_type;
+    typedef int difference_type;
+
+    typedef std::true_type propagate_on_container_move_assignment;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool allocate_called;
+
+    A2(const A2& a) : id_(a.id()) {copy_called = true;}
+    A2(A2&& a) : id_(a.id())      {move_called = true;}
+
+    T* allocate(std::size_t n, const void* hint)
+    {
+        allocate_called = true;
+        return (T*)hint;
+    }
+};
+
+template <class T> bool A2<T>::copy_called = false;
+template <class T> bool A2<T>::move_called = false;
+template <class T> bool A2<T>::allocate_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A2<T>& x, const A2<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A2<T>& x, const A2<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T>
+class A3
+{
+    int id_;
+public:
+    explicit A3(int id = 0) : id_(id) {}
+
+    typedef T value_type;
+
+    typedef std::true_type propagate_on_container_copy_assignment;
+    typedef std::true_type propagate_on_container_swap;
+
+    int id() const {return id_;}
+
+    static bool copy_called;
+    static bool move_called;
+    static bool constructed;
+    static bool destroy_called;
+
+    A3(const A3& a) : id_(a.id()) {copy_called = true;}
+    A3(A3&& a) : id_(a.id())      {move_called = true;}
+
+    template <class U, class ...Args>
+    void construct(U* p, Args&& ...args)
+    {
+        ::new (p) U(std::forward<Args>(args)...);
+        constructed = true;
+    }
+
+    template <class U>
+    void destroy(U* p)
+    {
+        p->~U();
+        destroy_called = true;
+    }
+
+    A3 select_on_container_copy_construction() const {return A3(-1);}
+};
+
+template <class T> bool A3<T>::copy_called = false;
+template <class T> bool A3<T>::move_called = false;
+template <class T> bool A3<T>::constructed = false;
+template <class T> bool A3<T>::destroy_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A3<T>& x, const A3<U>& y)
+{
+    return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A3<T>& x, const A3<U>& y)
+{
+    return !(x == y);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif  // ALLOCATORS_H
diff --git a/final/test/support/asan_testing.h b/final/test/support/asan_testing.h
new file mode 100644
index 0000000..c8797bd
--- /dev/null
+++ b/final/test/support/asan_testing.h
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 ASAN_TESTING_H
+#define ASAN_TESTING_H
+
+#include <__config>
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" int __sanitizer_verify_contiguous_container
+     ( const void *beg, const void *mid, const void *end );
+     
+template <typename T, typename Alloc>
+bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
+{
+    if ( std::is_same<Alloc, std::allocator<T>>::value && c.data() != NULL)
+        return __sanitizer_verify_contiguous_container (
+            c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0;
+    return true;
+}
+
+#else
+template <typename T, typename Alloc>
+bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
+{
+    return true;
+}
+#endif
+ 
+
+#endif  // ASAN_TESTING_H
\ No newline at end of file
diff --git a/final/test/support/constexpr_char_traits.hpp b/final/test/support/constexpr_char_traits.hpp
new file mode 100644
index 0000000..a2a690e
--- /dev/null
+++ b/final/test/support/constexpr_char_traits.hpp
@@ -0,0 +1,138 @@
+// -*- C++ -*-
+//===-------_------------ constexpr_char_traits ---------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _CONSTEXPR_CHAR_TRAITS
+#define _CONSTEXPR_CHAR_TRAITS
+
+#include <__config>
+#include <string>
+
+
+template <class _CharT>
+struct constexpr_char_traits
+{
+    typedef _CharT    char_type;
+    typedef int       int_type;
+    typedef std::streamoff off_type;
+    typedef std::streampos pos_type;
+    typedef std::mbstate_t state_type;
+
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT
+        {__c1 = __c2;}
+
+    static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+
+    static _LIBCPP_CONSTEXPR  bool lt(char_type __c1, char_type __c2) _NOEXCEPT
+        {return __c1 < __c2;}
+
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 int              compare(const char_type* __s1, const char_type* __s2, size_t __n);
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 size_t           length(const char_type* __s);
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 char_type*       move(char_type* __s1, const char_type* __s2, size_t __n);
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 char_type*       copy(char_type* __s1, const char_type* __s2, size_t __n);
+    static _LIBCPP_CONSTEXPR_AFTER_CXX11 char_type*       assign(char_type* __s, size_t __n, char_type __a);
+
+    static _LIBCPP_CONSTEXPR int_type  not_eof(int_type __c) _NOEXCEPT
+        {return eq_int_type(__c, eof()) ? ~eof() : __c;}
+
+    static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
+        {return char_type(__c);}
+
+    static _LIBCPP_CONSTEXPR int_type  to_int_type(char_type __c) _NOEXCEPT
+        {return int_type(__c);}
+
+    static _LIBCPP_CONSTEXPR bool      eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
+        {return __c1 == __c2;}
+
+    static _LIBCPP_CONSTEXPR int_type  eof() _NOEXCEPT
+        {return int_type(EOF);}
+};
+
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 int
+constexpr_char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+{
+    for (; __n; --__n, ++__s1, ++__s2)
+    {
+        if (lt(*__s1, *__s2))
+            return -1;
+        if (lt(*__s2, *__s1))
+            return 1;
+    }
+    return 0;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 size_t
+constexpr_char_traits<_CharT>::length(const char_type* __s)
+{
+    size_t __len = 0;
+    for (; !eq(*__s, char_type(0)); ++__s)
+        ++__len;
+    return __len;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT*
+constexpr_char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
+{
+    for (; __n; --__n)
+    {
+        if (eq(*__s, __a))
+            return __s;
+        ++__s;
+    }
+    return 0;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _CharT*
+constexpr_char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    char_type* __r = __s1;
+    if (__s1 < __s2)
+    {
+        for (; __n; --__n, ++__s1, ++__s2)
+            assign(*__s1, *__s2);
+    }
+    else if (__s2 < __s1)
+    {
+        __s1 += __n;
+        __s2 += __n;
+        for (; __n; --__n)
+            assign(*--__s1, *--__s2);
+    }
+    return __r;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _CharT*
+constexpr_char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+{
+    _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+    char_type* __r = __s1;
+    for (; __n; --__n, ++__s1, ++__s2)
+        assign(*__s1, *__s2);
+    return __r;
+}
+
+template <class _CharT>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 _CharT*
+constexpr_char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
+{
+    char_type* __r = __s;
+    for (; __n; --__n, ++__s)
+        assign(*__s, __a);
+    return __r;
+}
+
+#endif // _CONSTEXPR_CHAR_TRAITS
\ No newline at end of file
diff --git a/final/test/support/counting_predicates.hpp b/final/test/support/counting_predicates.hpp
new file mode 100644
index 0000000..4e0f8fb
--- /dev/null
+++ b/final/test/support/counting_predicates.hpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 __COUNTING_PREDICATES_H
+#define __COUNTING_PREDICATES_H
+
+
+template <typename Predicate>
+struct unary_counting_predicate {
+public:
+	unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
+	~unary_counting_predicate() {}
+	
+	typedef typename Predicate::argument_type argument_type;
+	typedef bool result_type;
+	
+	bool operator () (const argument_type &a) const { ++count_; return p_(a); }
+	size_t count() const { return count_; }
+	void reset() { count_ = 0; }
+	
+private:
+	Predicate p_;
+	mutable size_t count_;
+	};
+
+
+template <typename Predicate, typename Arg1, typename Arg2=Arg1>
+struct binary_counting_predicate : public std::binary_function<Arg1, Arg2, bool> {
+public:
+
+	binary_counting_predicate ( Predicate p ) : p_(p), count_(0) {}
+	~binary_counting_predicate() {}
+	
+	bool operator () (const Arg1 &a1, const Arg2 &a2) const { ++count_; return p_(a1, a2); }
+	size_t count() const { return count_; }
+	void reset() { count_ = 0; }
+
+private:
+	Predicate p_;
+	mutable size_t count_;
+	};
+
+#endif // __COUNTING_PREDICATES_H
diff --git a/final/test/support/hexfloat.h b/final/test/support/hexfloat.h
new file mode 100644
index 0000000..7ef0937
--- /dev/null
+++ b/final/test/support/hexfloat.h
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Define a hexfloat literal emulator since we can't depend on being able to
+//   for hexfloat literals
+
+// 0x10.F5p-10 == hexfloat<double>(0x10, 0xF5, -10)
+
+#ifndef HEXFLOAT_H
+#define HEXFLOAT_H
+
+#include <algorithm>
+#include <cmath>
+#include <climits>
+
+template <class T>
+class hexfloat
+{
+    T value_;
+public:
+    hexfloat(long long m1, unsigned long long m0, int exp)
+    {
+        const std::size_t n = sizeof(unsigned long long) * CHAR_BIT;
+        int s = m1 < 0 ? -1 : 1;
+        value_ = std::ldexp(m1 + s * std::ldexp(T(m0), -static_cast<int>(n -
+                                                     std::__clz(m0)/4*4)), exp);
+    }
+
+    operator T() const {return value_;}
+};
+
+#endif
diff --git a/final/test/support/min_allocator.h b/final/test/support/min_allocator.h
new file mode 100644
index 0000000..f3f08ca
--- /dev/null
+++ b/final/test/support/min_allocator.h
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 MIN_ALLOCATOR_H
+#define MIN_ALLOCATOR_H
+
+#if __cplusplus >= 201103L
+
+#include <memory>
+
+template <class T> class min_pointer;
+template <class T> class min_pointer<const T>;
+template <> class min_pointer<void>;
+template <> class min_pointer<const void>;
+template <class T> class min_allocator;
+
+template <>
+class min_pointer<const void>
+{
+    const void* ptr_;
+public:
+    min_pointer() noexcept = default;
+    min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+    template <class T>
+    min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
+
+    explicit operator bool() const {return ptr_ != nullptr;}
+
+    friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+    friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+    template <class U> friend class min_pointer;
+};
+
+template <>
+class min_pointer<void>
+{
+    void* ptr_;
+public:
+    min_pointer() noexcept = default;
+    min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+    template <class T,
+              class = typename std::enable_if
+                       <
+                            !std::is_const<T>::value
+                       >::type
+             >
+    min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
+
+    explicit operator bool() const {return ptr_ != nullptr;}
+
+    friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+    friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+    template <class U> friend class min_pointer;
+};
+
+template <class T>
+class min_pointer
+{
+    T* ptr_;
+
+    explicit min_pointer(T* p) : ptr_(p) {}
+public:
+    min_pointer() noexcept = default;
+    min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+    explicit min_pointer(min_pointer<void> p) : ptr_(static_cast<T*>(p.ptr_)) {}
+
+    explicit operator bool() const {return ptr_ != nullptr;}
+    
+    typedef std::ptrdiff_t difference_type;
+    typedef T& reference;
+    typedef T* pointer;
+    typedef T value_type;
+    typedef std::random_access_iterator_tag iterator_category;
+
+    reference operator*() const {return *ptr_;}
+    pointer operator->() const {return ptr_;}
+
+    min_pointer& operator++() {++ptr_; return *this;}
+    min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
+
+    min_pointer& operator--() {--ptr_; return *this;}
+    min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
+
+    min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
+    min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
+
+    min_pointer operator+(difference_type n) const
+    {
+        min_pointer tmp(*this);
+        tmp += n;
+        return tmp;
+    }
+
+    friend min_pointer operator+(difference_type n, min_pointer x)
+    {
+        return x + n;
+    }
+
+    min_pointer operator-(difference_type n) const
+    {
+        min_pointer tmp(*this);
+        tmp -= n;
+        return tmp;
+    }
+
+    friend difference_type operator-(min_pointer x, min_pointer y)
+    {
+        return x.ptr_ - y.ptr_;
+    }
+
+    reference operator[](difference_type n) const {return ptr_[n];}
+
+    friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
+    friend bool operator> (min_pointer x, min_pointer y) {return y < x;}
+    friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
+    friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
+
+    static min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));}
+
+    friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+    friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+    template <class U> friend class min_pointer;
+    template <class U> friend class min_allocator;
+};
+
+template <class T>
+class min_pointer<const T>
+{
+    const T* ptr_;
+
+    explicit min_pointer(const T* p) : ptr_(p) {}
+public:
+    min_pointer() noexcept = default;
+    min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+    min_pointer(min_pointer<T> p) : ptr_(p.ptr_) {}
+    explicit min_pointer(min_pointer<const void> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
+
+    explicit operator bool() const {return ptr_ != nullptr;}
+
+    typedef std::ptrdiff_t difference_type;
+    typedef const T& reference;
+    typedef const T* pointer;
+    typedef const T value_type;
+    typedef std::random_access_iterator_tag iterator_category;
+
+    reference operator*() const {return *ptr_;}
+    pointer operator->() const {return ptr_;}
+
+    min_pointer& operator++() {++ptr_; return *this;}
+    min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
+
+    min_pointer& operator--() {--ptr_; return *this;}
+    min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
+
+    min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
+    min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
+
+    min_pointer operator+(difference_type n) const
+    {
+        min_pointer tmp(*this);
+        tmp += n;
+        return tmp;
+    }
+
+    friend min_pointer operator+(difference_type n, min_pointer x)
+    {
+        return x + n;
+    }
+
+    min_pointer operator-(difference_type n) const
+    {
+        min_pointer tmp(*this);
+        tmp -= n;
+        return tmp;
+    }
+
+    friend difference_type operator-(min_pointer x, min_pointer y)
+    {
+        return x.ptr_ - y.ptr_;
+    }
+
+    reference operator[](difference_type n) const {return ptr_[n];}
+
+    friend bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
+    friend bool operator> (min_pointer x, min_pointer y) {return y < x;}
+    friend bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
+    friend bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
+
+    static min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));}
+
+    friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
+    friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
+    template <class U> friend class min_pointer;
+};
+
+template <class T>
+inline
+bool
+operator==(min_pointer<T> x, std::nullptr_t)
+{
+    return !static_cast<bool>(x);
+}
+
+template <class T>
+inline
+bool
+operator==(std::nullptr_t, min_pointer<T> x)
+{
+    return !static_cast<bool>(x);
+}
+
+template <class T>
+inline
+bool
+operator!=(min_pointer<T> x, std::nullptr_t)
+{
+    return static_cast<bool>(x);
+}
+
+template <class T>
+inline
+bool
+operator!=(std::nullptr_t, min_pointer<T> x)
+{
+    return static_cast<bool>(x);
+}
+
+template <class T>
+class min_allocator
+{
+public:
+    typedef T value_type;
+    typedef min_pointer<T> pointer;
+
+    min_allocator() = default;
+    template <class U>
+    min_allocator(min_allocator<U>) {}
+
+    pointer allocate(std::ptrdiff_t n)
+    {
+        return pointer(static_cast<T*>(::operator new(n*sizeof(T))));
+    }
+
+    void deallocate(pointer p, std::ptrdiff_t)
+    {
+        return ::operator delete(p.ptr_);
+    }
+
+    friend bool operator==(min_allocator, min_allocator) {return true;}
+    friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);}
+};
+
+#endif  // __cplusplus >= 201103L
+
+#endif  // MIN_ALLOCATOR_H
diff --git a/final/test/support/nasty_containers.hpp b/final/test/support/nasty_containers.hpp
new file mode 100644
index 0000000..5a2e195
--- /dev/null
+++ b/final/test/support/nasty_containers.hpp
@@ -0,0 +1,282 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 NASTY_VECTOR_H
+#define NASTY_VECTOR_H
+
+#include <vector>
+#include <list>
+
+template <class T>
+class nasty_vector
+{
+public:
+    typedef typename std::vector<T>                           nested_container;
+    typedef typename nested_container::value_type             value_type;
+    typedef typename nested_container::reference              reference;
+    typedef typename nested_container::const_reference        const_reference;
+    typedef typename nested_container::iterator               iterator;
+    typedef typename nested_container::const_iterator         const_iterator;
+
+    typedef typename nested_container::size_type              size_type;
+    typedef typename nested_container::difference_type        difference_type;
+    typedef typename nested_container::pointer                pointer;
+    typedef typename nested_container::const_pointer          const_pointer;
+
+    typedef typename nested_container::reverse_iterator       reverse_iterator;
+    typedef typename nested_container::const_reverse_iterator const_reverse_iterator;
+
+    nasty_vector() : v_() {}
+    explicit nasty_vector(size_type n) : v_(n) {}
+    nasty_vector(size_type n, const value_type& value) : v_(n, value) {}
+    template <class InputIterator> nasty_vector(InputIterator first, InputIterator last) : v_(first, last) {}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    nasty_vector(std::initializer_list<value_type> il) : v_(il) {}
+#endif
+    ~nasty_vector() {}
+
+    template <class InputIterator>
+        void assign(InputIterator first, InputIterator last) { v_.assign(first, last); }
+    void assign(size_type n, const value_type& u) { v_.assign(n, u); }
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    void assign(std::initializer_list<value_type> il)  { v_.assign(il); }
+#endif
+
+    iterator               begin() _NOEXCEPT         { return v_.begin(); }
+    const_iterator         begin()   const _NOEXCEPT { return v_.begin(); }
+    iterator               end() _NOEXCEPT           { return v_.end(); }
+    const_iterator         end()     const _NOEXCEPT { return v_.end(); }
+
+    reverse_iterator       rbegin() _NOEXCEPT        { return v_.rbegin(); }
+    const_reverse_iterator rbegin()  const _NOEXCEPT { return v_.rbegin(); }
+    reverse_iterator       rend() _NOEXCEPT          { return v_.rend(); }
+    const_reverse_iterator rend()    const _NOEXCEPT { return v_.rend(); }
+
+    const_iterator         cbegin()  const _NOEXCEPT { return v_.cbegin(); }
+    const_iterator         cend()    const _NOEXCEPT { return v_.cend(); }
+    const_reverse_iterator crbegin() const _NOEXCEPT { return v_.crbegin(); }
+    const_reverse_iterator crend()   const _NOEXCEPT { return v_.crend(); }
+
+    size_type size() const _NOEXCEPT      { return v_.size(); }
+    size_type max_size() const _NOEXCEPT  { return v_.max_size(); }
+    size_type capacity() const _NOEXCEPT  { return v_.capacity(); }
+    bool empty() const _NOEXCEPT          { return v_.empty(); }
+    void reserve(size_type n)             { v_.reserve(n); };
+    void shrink_to_fit() _NOEXCEPT        { v_.shrink_to_fit(); }
+
+    reference       operator[](size_type n)       { return v_[n]; }
+    const_reference operator[](size_type n) const { return v_[n]; }
+    reference       at(size_type n)               { return v_.at(n); }
+    const_reference at(size_type n) const         { return v_.at(n); }
+
+    reference       front()       { return v_.front(); }
+    const_reference front() const { return v_.front(); }
+    reference       back()        { return v_.back(); }
+    const_reference back() const  { return v_.back(); }
+
+    value_type*       data() _NOEXCEPT       { return v_.data(); }
+    const value_type* data() const _NOEXCEPT { return v_.data(); }
+
+    void push_back(const value_type& x)     { v_.push_back(x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void push_back(value_type&& x)          { v_.push_back(std::forward<value_type&&>(x)); }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... Args>
+        void emplace_back(Args&&... args)   { v_.emplace_back(std::forward<Args>(args)...); }
+#endif
+#endif
+    void pop_back()                         { v_.pop_back(); }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... Args> iterator emplace(const_iterator pos, Args&&... args)
+    { return v_.emplace(pos, std::forward<Args>(args)...); }
+#endif
+#endif
+    
+    iterator insert(const_iterator pos, const value_type& x) { return v_.insert(pos, x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    iterator insert(const_iterator pos, value_type&& x)      { return v_.insert(pos, std::forward<value_type>(x)); }
+#endif
+    iterator insert(const_iterator pos, size_type n, const value_type& x) { return v_.insert(pos, n, x); }
+    template <class InputIterator>
+        iterator insert(const_iterator pos, InputIterator first, InputIterator last)
+    { return v_.insert(pos, first, last); }
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return v_.insert(pos, il); }
+#endif
+
+    iterator erase(const_iterator pos)                        { return v_.erase(pos); }
+    iterator erase(const_iterator first, const_iterator last) { return v_.erase(first, last); }
+
+    void clear() _NOEXCEPT { v_.clear(); }
+
+    void resize(size_type sz)                      { v_.resize(sz); }
+    void resize(size_type sz, const value_type& c) { v_.resize(sz, c); }
+
+    void swap(nasty_vector &nv) _NOEXCEPT_(std::__is_nothrow_swappable<nested_container>::value)
+    { v_.swap(nv.v_); }
+    
+    nasty_vector *operator &()             { return nullptr; }  // nasty
+    const nasty_vector *operator &() const { return nullptr; }  // nasty
+    
+    nested_container v_;
+};
+
+template <class T>
+bool operator==(const nasty_vector<T>& x, const nasty_vector<T>& y) { return x.v_ == y.v_; }
+
+template <class T>
+class nasty_list
+{
+public:
+
+    typedef typename std::list<T>                             nested_container;
+    typedef typename nested_container::value_type             value_type;
+    typedef typename nested_container::reference              reference;
+    typedef typename nested_container::const_reference        const_reference;
+    typedef typename nested_container::iterator               iterator;
+    typedef typename nested_container::const_iterator         const_iterator;
+
+    typedef typename nested_container::size_type              size_type;
+    typedef typename nested_container::difference_type        difference_type;
+    typedef typename nested_container::pointer                pointer;
+    typedef typename nested_container::const_pointer          const_pointer;
+
+    typedef typename nested_container::reverse_iterator       reverse_iterator;
+    typedef typename nested_container::const_reverse_iterator const_reverse_iterator;
+
+    nasty_list() : l_() {}
+    explicit nasty_list(size_type n)  : l_(n) {}
+    nasty_list(size_type n, const value_type& value)  : l_(n,value) {}
+    template <class Iter>
+        nasty_list(Iter first, Iter last)  : l_(first, last) {}
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    nasty_list(std::initializer_list<value_type> il) : l_(il) {}
+#endif
+
+    ~nasty_list() {}
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    nasty_list& operator=(std::initializer_list<value_type> il) { l_ = il; return *this; }
+#endif
+    template <class Iter>
+        void assign(Iter first, Iter last) { l_.assign(first, last); }
+    void assign(size_type n, const value_type& t) { l_.assign(n, t); }
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    void assign(std::initializer_list<value_type> il) { l_.assign(il); }
+#endif
+
+
+    iterator               begin() _NOEXCEPT         { return l_.begin(); }
+    const_iterator         begin()   const _NOEXCEPT { return l_.begin(); }
+    iterator               end() _NOEXCEPT           { return l_.end(); }
+    const_iterator         end()     const _NOEXCEPT { return l_.end(); }
+
+    reverse_iterator       rbegin() _NOEXCEPT        { return l_.rbegin(); }
+    const_reverse_iterator rbegin()  const _NOEXCEPT { return l_.rbegin(); }
+    reverse_iterator       rend() _NOEXCEPT          { return l_.rend(); }
+    const_reverse_iterator rend()    const _NOEXCEPT { return l_.rend(); }
+
+    const_iterator         cbegin()  const _NOEXCEPT { return l_.cbegin(); }
+    const_iterator         cend()    const _NOEXCEPT { return l_.cend(); }
+    const_reverse_iterator crbegin() const _NOEXCEPT { return l_.crbegin(); }
+    const_reverse_iterator crend()   const _NOEXCEPT { return l_.crend(); }
+
+    reference       front()       { return l_.front(); }
+    const_reference front() const { return l_.front(); }
+    reference       back()        { return l_.back(); }
+    const_reference back() const  { return l_.back(); }
+
+    size_type size() const _NOEXCEPT      { return l_.size(); }
+    size_type max_size() const _NOEXCEPT  { return l_.max_size(); }
+    bool empty() const _NOEXCEPT          { return l_.empty(); }
+
+    void push_front(const value_type& x)    { l_.push_front(x); }
+    void push_back(const value_type& x)     { l_.push_back(x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void push_back(value_type&& x)          { l_.push_back(std::forward<value_type&&>(x)); }
+    void push_front(value_type&& x)         { l_.push_back(std::forward<value_type&&>(x)); }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... Args>
+        void emplace_back(Args&&... args)   { l_.emplace_back(std::forward<Args>(args)...); }
+    template <class... Args>
+        void emplace_front(Args&&... args)  { l_.emplace_front(std::forward<Args>(args)...); }
+#endif
+#endif
+    void pop_front()                        { l_.pop_front(); }
+    void pop_back()                         { l_.pop_back(); }
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class... Args> iterator emplace(const_iterator pos, Args&&... args)
+    { return l_.emplace(pos, std::forward<Args>(args)...); }
+#endif
+#endif
+    
+    iterator insert(const_iterator pos, const value_type& x) { return l_.insert(pos, x); }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    iterator insert(const_iterator pos, value_type&& x)      { return l_.insert(pos, std::forward<value_type>(x)); }
+#endif
+    iterator insert(const_iterator pos, size_type n, const value_type& x) { return l_.insert(pos, n, x); }
+    template <class InputIterator>
+        iterator insert(const_iterator pos, InputIterator first, InputIterator last)
+    { return l_.insert(pos, first, last); }
+
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+    iterator insert(const_iterator pos, std::initializer_list<value_type> il) { return l_.insert(pos, il); }
+#endif
+
+    iterator erase(const_iterator pos)                      { return l_.erase(pos); }
+    iterator erase(const_iterator pos, const_iterator last) { return l_.erase(pos, last); }
+
+    void resize(size_type sz)                      { l_.resize(); }
+    void resize(size_type sz, const value_type& c) { l_.resize(c); }
+
+    void swap(nasty_list &nl) _NOEXCEPT_(std::__is_nothrow_swappable<nested_container>::value)
+    { l_.swap(nl.l_); }
+    
+    void clear() _NOEXCEPT { l_.clear(); }
+
+//     void splice(const_iterator position, list& x);
+//     void splice(const_iterator position, list&& x);
+//     void splice(const_iterator position, list& x, const_iterator i);
+//     void splice(const_iterator position, list&& x, const_iterator i);
+//     void splice(const_iterator position, list& x, const_iterator first,
+//                                                   const_iterator last);
+//     void splice(const_iterator position, list&& x, const_iterator first,
+//                                                   const_iterator last);
+// 
+//     void remove(const value_type& value);
+//     template <class Pred> void remove_if(Pred pred);
+//     void unique();
+//     template <class BinaryPredicate>
+//         void unique(BinaryPredicate binary_pred);
+//     void merge(list& x);
+//     void merge(list&& x);
+//     template <class Compare>
+//         void merge(list& x, Compare comp);
+//     template <class Compare>
+//         void merge(list&& x, Compare comp);
+//     void sort();
+//     template <class Compare>
+//         void sort(Compare comp);
+//     void reverse() noexcept;
+
+    nasty_list *operator &()             { return nullptr; }  // nasty
+    const nasty_list *operator &() const { return nullptr; }  // nasty
+
+    nested_container l_;
+};
+
+template <class T>
+bool operator==(const nasty_list<T>& x, const nasty_list<T>& y) { return x.l_ == y.l_; }
+
+#endif
diff --git a/final/test/support/nothing_to_do.pass.cpp b/final/test/support/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/support/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/support/platform_support.h b/final/test/support/platform_support.h
new file mode 100644
index 0000000..9ae2ae7
--- /dev/null
+++ b/final/test/support/platform_support.h
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Define a bunch of macros that can be used in the tests instead of
+//  implementation defined assumptions:
+//   - locale names
+//   - floating point number string output
+
+#ifndef PLATFORM_SUPPORT_H
+#define PLATFORM_SUPPORT_H
+
+// locale names
+#ifdef _WIN32
+// WARNING: Windows does not support UTF-8 codepages.
+// Locales are "converted" using http://docs.moodle.org/dev/Table_of_locales
+#define LOCALE_en_US_UTF_8     "English_United States.1252"
+#define LOCALE_cs_CZ_ISO8859_2 "Czech_Czech Republic.1250"
+#define LOCALE_fr_FR_UTF_8     "French_France.1252"
+#define LOCALE_fr_CA_ISO8859_1 "French_Canada.1252"
+#define LOCALE_ru_RU_UTF_8     "Russian_Russia.1251"
+#define LOCALE_zh_CN_UTF_8     "Chinese_China.936"
+#else
+#define LOCALE_en_US_UTF_8     "en_US.UTF-8"
+#define LOCALE_fr_FR_UTF_8     "fr_FR.UTF-8"
+#ifdef __linux__
+#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO-8859-1"
+#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO-8859-2"
+#else
+#define LOCALE_fr_CA_ISO8859_1 "fr_CA.ISO8859-1"
+#define LOCALE_cs_CZ_ISO8859_2 "cs_CZ.ISO8859-2"
+#endif
+#define LOCALE_ru_RU_UTF_8     "ru_RU.UTF-8"
+#define LOCALE_zh_CN_UTF_8     "zh_CN.UTF-8"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#include <io.h> // _mktemp
+#endif
+
+inline
+std::string
+get_temp_file_name()
+{
+   std::string s("temp.XXXXXX");
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+   _mktemp(&s[0]);
+#else
+   mktemp(&s[0]);
+#endif
+   return s;
+}
+
+#endif // PLATFORM_SUPPORT_H
diff --git a/final/test/support/private_constructor.hpp b/final/test/support/private_constructor.hpp
new file mode 100644
index 0000000..a9fcf68
--- /dev/null
+++ b/final/test/support/private_constructor.hpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 __PRIVATE_CONSTRUCTOR__H
+#define __PRIVATE_CONSTRUCTOR__H
+
+#include <iostream>
+
+struct PrivateConstructor {
+
+    PrivateConstructor static make ( int v ) { return PrivateConstructor(v); }
+    int get () const { return val; }
+private:
+    PrivateConstructor ( int v ) : val(v) {}
+    int val;
+    };
+
+bool operator < ( const PrivateConstructor &lhs, const PrivateConstructor &rhs ) { return lhs.get() < rhs.get(); }
+
+bool operator < ( const PrivateConstructor &lhs, int rhs ) { return lhs.get() < rhs; }
+bool operator < ( int lhs, const PrivateConstructor &rhs ) { return lhs < rhs.get(); }
+
+std::ostream & operator << ( std::ostream &os, const PrivateConstructor &foo ) { return os << foo.get (); }
+
+#endif
diff --git a/final/test/support/test_allocator.h b/final/test/support/test_allocator.h
new file mode 100644
index 0000000..683fac2
--- /dev/null
+++ b/final/test/support/test_allocator.h
@@ -0,0 +1,224 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 TEST_ALLOCATOR_H
+#define TEST_ALLOCATOR_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+#include <cassert>
+
+class test_alloc_base
+{
+protected:
+    static int time_to_throw;
+public:
+    static int throw_after;
+    static int count;
+    static int alloc_count;
+};
+
+int test_alloc_base::count = 0;
+int test_alloc_base::time_to_throw = 0;
+int test_alloc_base::alloc_count = 0;
+int test_alloc_base::throw_after = INT_MAX;
+
+template <class T>
+class test_allocator
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef T                                                          value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+    typedef typename std::add_lvalue_reference<value_type>::type       reference;
+    typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+    template <class U> struct rebind {typedef test_allocator<U> other;};
+
+    test_allocator() throw() : data_(0) {++count;}
+    explicit test_allocator(int i) throw() : data_(i) {++count;}
+    test_allocator(const test_allocator& a) throw()
+        : data_(a.data_) {++count;}
+    template <class U> test_allocator(const test_allocator<U>& a) throw()
+        : data_(a.data_) {++count;}
+    ~test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
+    pointer address(reference x) const {return &x;}
+    const_pointer address(const_reference x) const {return &x;}
+    pointer allocate(size_type n, const void* = 0)
+        {
+            assert(data_ >= 0);
+            if (time_to_throw >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                throw std::bad_alloc();
+#else
+                std::terminate();
+#endif
+            }
+            ++time_to_throw;
+            ++alloc_count;
+            return (pointer)std::malloc(n * sizeof(T));
+        }
+    void deallocate(pointer p, size_type n)
+        {assert(data_ >= 0); --alloc_count; std::free(p);}
+    size_type max_size() const throw()
+        {return UINT_MAX / sizeof(T);}
+    void construct(pointer p, const T& val)
+        {::new(p) T(val);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void construct(pointer p, T&& val)
+        {::new(p) T(std::move(val));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void destroy(pointer p) {p->~T();}
+
+    friend bool operator==(const test_allocator& x, const test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const test_allocator& x, const test_allocator& y)
+        {return !(x == y);}
+};
+
+template <class T>
+class non_default_test_allocator
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class non_default_test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef T                                                          value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+    typedef typename std::add_lvalue_reference<value_type>::type       reference;
+    typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+    template <class U> struct rebind {typedef non_default_test_allocator<U> other;};
+
+//    non_default_test_allocator() throw() : data_(0) {++count;}
+    explicit non_default_test_allocator(int i) throw() : data_(i) {++count;}
+    non_default_test_allocator(const non_default_test_allocator& a) throw()
+        : data_(a.data_) {++count;}
+    template <class U> non_default_test_allocator(const non_default_test_allocator<U>& a) throw()
+        : data_(a.data_) {++count;}
+    ~non_default_test_allocator() throw() {assert(data_ >= 0); --count; data_ = -1;}
+    pointer address(reference x) const {return &x;}
+    const_pointer address(const_reference x) const {return &x;}
+    pointer allocate(size_type n, const void* = 0)
+        {
+            assert(data_ >= 0);
+            if (time_to_throw >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                throw std::bad_alloc();
+#else
+                std::terminate();
+#endif
+            }
+            ++time_to_throw;
+            ++alloc_count;
+            return (pointer)std::malloc(n * sizeof(T));
+        }
+    void deallocate(pointer p, size_type n)
+        {assert(data_ >= 0); --alloc_count; std::free(p);}
+    size_type max_size() const throw()
+        {return UINT_MAX / sizeof(T);}
+    void construct(pointer p, const T& val)
+        {::new(p) T(val);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void construct(pointer p, T&& val)
+        {::new(p) T(std::move(val));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void destroy(pointer p) {p->~T();}
+
+    friend bool operator==(const non_default_test_allocator& x, const non_default_test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const non_default_test_allocator& x, const non_default_test_allocator& y)
+        {return !(x == y);}
+};
+
+template <>
+class test_allocator<void>
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef void                                                       value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+
+    template <class U> struct rebind {typedef test_allocator<U> other;};
+
+    test_allocator() throw() : data_(-1) {}
+    explicit test_allocator(int i) throw() : data_(i) {}
+    test_allocator(const test_allocator& a) throw()
+        : data_(a.data_) {}
+    template <class U> test_allocator(const test_allocator<U>& a) throw()
+        : data_(a.data_) {}
+    ~test_allocator() throw() {data_ = 0;}
+
+    friend bool operator==(const test_allocator& x, const test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const test_allocator& x, const test_allocator& y)
+        {return !(x == y);}
+};
+
+template <class T>
+class other_allocator
+{
+    int data_;
+
+    template <class U> friend class other_allocator;
+
+public:
+    typedef T value_type;
+
+    other_allocator() : data_(-1) {}
+    explicit other_allocator(int i) : data_(i) {}
+    template <class U> other_allocator(const other_allocator<U>& a)
+        : data_(a.data_) {}
+    T* allocate(std::size_t n)
+        {return (T*)std::malloc(n * sizeof(T));}
+    void deallocate(T* p, std::size_t n)
+        {std::free(p);}
+
+    other_allocator select_on_container_copy_construction() const
+        {return other_allocator(-2);}
+
+    friend bool operator==(const other_allocator& x, const other_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const other_allocator& x, const other_allocator& y)
+        {return !(x == y);}
+
+    typedef std::true_type propagate_on_container_copy_assignment;
+    typedef std::true_type propagate_on_container_move_assignment;
+    typedef std::true_type propagate_on_container_swap;
+
+#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    std::size_t max_size() const
+        {return UINT_MAX / sizeof(T);}
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+};
+
+#endif  // TEST_ALLOCATOR_H
diff --git a/final/test/support/test_iterators.h b/final/test/support/test_iterators.h
new file mode 100644
index 0000000..5bd6df7
--- /dev/null
+++ b/final/test/support/test_iterators.h
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 ITERATORS_H
+#define ITERATORS_H
+
+#include <iterator>
+
+template <class It>
+class output_iterator
+{
+    It it_;
+
+    template <class U> friend class output_iterator;
+public:
+    typedef          std::output_iterator_tag                  iterator_category;
+    typedef void                                               value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    output_iterator () {}
+    explicit output_iterator(It it) : it_(it) {}
+    template <class U>
+        output_iterator(const output_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+
+    output_iterator& operator++() {++it_; return *this;}
+    output_iterator operator++(int)
+        {output_iterator tmp(*this); ++(*this); return tmp;}
+};
+
+template <class It>
+class input_iterator
+{
+    It it_;
+
+    template <class U> friend class input_iterator;
+public:
+    typedef          std::input_iterator_tag                   iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    input_iterator() : it_() {}
+    explicit input_iterator(It it) : it_(it) {}
+    template <class U>
+        input_iterator(const input_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    input_iterator& operator++() {++it_; return *this;}
+    input_iterator operator++(int)
+        {input_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const input_iterator& x, const input_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const input_iterator& x, const input_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const input_iterator<T>& x, const input_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class forward_iterator
+{
+    It it_;
+
+    template <class U> friend class forward_iterator;
+public:
+    typedef          std::forward_iterator_tag                 iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    forward_iterator() : it_() {}
+    explicit forward_iterator(It it) : it_(it) {}
+    template <class U>
+        forward_iterator(const forward_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    forward_iterator& operator++() {++it_; return *this;}
+    forward_iterator operator++(int)
+        {forward_iterator tmp(*this); ++(*this); return tmp;}
+
+    friend bool operator==(const forward_iterator& x, const forward_iterator& y)
+        {return x.it_ == y.it_;}
+    friend bool operator!=(const forward_iterator& x, const forward_iterator& y)
+        {return !(x == y);}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const forward_iterator<T>& x, const forward_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class bidirectional_iterator
+{
+    It it_;
+
+    template <class U> friend class bidirectional_iterator;
+public:
+    typedef          std::bidirectional_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    bidirectional_iterator() : it_() {}
+    explicit bidirectional_iterator(It it) : it_(it) {}
+    template <class U>
+        bidirectional_iterator(const bidirectional_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    bidirectional_iterator& operator++() {++it_; return *this;}
+    bidirectional_iterator operator++(int)
+        {bidirectional_iterator tmp(*this); ++(*this); return tmp;}
+
+    bidirectional_iterator& operator--() {--it_; return *this;}
+    bidirectional_iterator operator--(int)
+        {bidirectional_iterator tmp(*this); --(*this); return tmp;}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const bidirectional_iterator<T>& x, const bidirectional_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class It>
+class random_access_iterator
+{
+    It it_;
+
+    template <class U> friend class random_access_iterator;
+public:
+    typedef          std::random_access_iterator_tag           iterator_category;
+    typedef typename std::iterator_traits<It>::value_type      value_type;
+    typedef typename std::iterator_traits<It>::difference_type difference_type;
+    typedef It                                                 pointer;
+    typedef typename std::iterator_traits<It>::reference       reference;
+
+    It base() const {return it_;}
+
+    random_access_iterator() : it_() {}
+    explicit random_access_iterator(It it) : it_(it) {}
+   template <class U>
+        random_access_iterator(const random_access_iterator<U>& u) :it_(u.it_) {}
+
+    reference operator*() const {return *it_;}
+    pointer operator->() const {return it_;}
+
+    random_access_iterator& operator++() {++it_; return *this;}
+    random_access_iterator operator++(int)
+        {random_access_iterator tmp(*this); ++(*this); return tmp;}
+
+    random_access_iterator& operator--() {--it_; return *this;}
+    random_access_iterator operator--(int)
+        {random_access_iterator tmp(*this); --(*this); return tmp;}
+
+    random_access_iterator& operator+=(difference_type n) {it_ += n; return *this;}
+    random_access_iterator operator+(difference_type n) const
+        {random_access_iterator tmp(*this); tmp += n; return tmp;}
+    friend random_access_iterator operator+(difference_type n, random_access_iterator x)
+        {x += n; return x;}
+    random_access_iterator& operator-=(difference_type n) {return *this += -n;}
+    random_access_iterator operator-(difference_type n) const
+        {random_access_iterator tmp(*this); tmp -= n; return tmp;}
+
+    reference operator[](difference_type n) const {return it_[n];}
+};
+
+template <class T, class U>
+inline
+bool
+operator==(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() == y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator!=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x == y);
+}
+
+template <class T, class U>
+inline
+bool
+operator<(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() < y.base();
+}
+
+template <class T, class U>
+inline
+bool
+operator<=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(y < x);
+}
+
+template <class T, class U>
+inline
+bool
+operator>(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return y < x;
+}
+
+template <class T, class U>
+inline
+bool
+operator>=(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return !(x < y);
+}
+
+template <class T, class U>
+inline
+typename std::iterator_traits<T>::difference_type
+operator-(const random_access_iterator<T>& x, const random_access_iterator<U>& y)
+{
+    return x.base() - y.base();
+}
+
+template <class Iter>
+inline Iter base(output_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(input_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(forward_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(bidirectional_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>
+inline Iter base(random_access_iterator<Iter> i) { return i.base(); }
+
+template <class Iter>    // everything else
+inline Iter base(Iter i) { return i; }
+
+#endif  // ITERATORS_H
diff --git a/final/test/testit b/final/test/testit
new file mode 100755
index 0000000..821292e
--- /dev/null
+++ b/final/test/testit
@@ -0,0 +1,180 @@
+#!/bin/sh
+# //===--------------------------- testit ---------------------------------===//
+# //
+# //                     The LLVM Compiler Infrastructure
+# //
+# // This file is distributed under the University of Illinois Open Source
+# // License. See LICENSE.TXT for details.
+# //
+# //===--------------------------------------------------------------------===//
+
+currentpath=`pwd`
+origpath=$currentpath
+currentdir=`basename $currentpath`
+while [ $currentdir != "test" ]; do
+	if [ $currentdir = "/" ]
+	then
+		echo "current directory must be in or under \"test\"."
+		exit 1
+	fi
+	cd ..
+	currentpath=`pwd`
+	currentdir=`basename $currentpath`
+done
+
+cd ..
+LIBCXX_ROOT=`pwd`
+cd $origpath
+
+if [ -z "$CC" ]
+then
+	if which xcrun >/dev/null
+	then
+		CC="xcrun clang++"
+	else
+		CC=clang++
+	fi
+fi
+
+if [ -z "$CXX_LANG" ]
+then
+    CXX_LANG=c++11
+fi
+if [ -z "$OPTIONS" ]
+then
+	OPTIONS="-std=${CXX_LANG} -stdlib=libc++"
+fi
+OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support"
+
+if [ -z "$HEADER_INCLUDE" ]
+then
+       HEADER_INCLUDE="-I$LIBCXX_ROOT/include"
+fi
+
+if [ -z "$SOURCE_LIB" ]
+then
+       SOURCE_LIB="-L$LIBCXX_ROOT/lib"
+fi
+
+case $TRIPLE in
+  *-*-mingw* | *-*-cygwin* | *-*-win*)
+	TEST_EXE=test.exe
+    ;;
+  *)
+    TEST_EXE=a.out
+    ;;
+esac
+
+case $(uname -s) in
+   NetBSD)
+     THREAD_FLAGS=-lpthread
+     ;;
+esac
+
+FAIL=0
+PASS=0
+UNIMPLEMENTED=0
+IMPLEMENTED_FAIL=0
+IMPLEMENTED_PASS=0
+
+afunc() {
+	fail=0
+	pass=0
+	if (ls ${TEST_PREFIX}*fail.cpp > /dev/null 2>&1)
+	then
+		for FILE in $(ls ${TEST_PREFIX}*fail.cpp); do
+			if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS -o ./$TEST_EXE > /dev/null 2>&1
+			then
+				rm ./$TEST_EXE
+				echo "$FILE should not compile"
+				fail=$(($fail+1))
+			else
+				pass=$(($pass+1))
+			fi
+		done
+	fi
+
+	if (ls ${TEST_PREFIX}*pass.cpp > /dev/null 2>&1)
+	then
+		for FILE in $(ls ${TEST_PREFIX}*pass.cpp); do
+            if [ "$VERBOSE" ]
+            then
+             	echo "Running test: " $FILE
+            fi
+			if $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS) -o ./$TEST_EXE
+			then
+				if ./$TEST_EXE
+				then
+					rm ./$TEST_EXE
+					pass=$(($pass+1))
+				else
+					echo "`pwd`/$FILE failed at run time"
+					echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
+					fail=$(($fail+1))
+					rm ./$TEST_EXE
+				fi
+			else
+				echo "`pwd`/$FILE failed to compile"
+				echo "Compile line was:" $CC $OPTIONS $HEADER_INCLUDE $SOURCE_LIB $FILE $LIBS $(test $1 = no || echo $THREAD_FLAGS)
+				fail=$(($fail+1))
+			fi
+		done
+	fi
+
+	if [ $fail -gt 0 ]
+	then
+		echo "failed $fail tests in `pwd`"
+		IMPLEMENTED_FAIL=$(($IMPLEMENTED_FAIL+1))
+	fi
+	if [ $pass -gt 0 ]
+	then
+		echo "passed $pass tests in `pwd`"
+		if [ $fail -eq 0 ]
+		then
+			IMPLEMENTED_PASS=$((IMPLEMENTED_PASS+1))
+		fi
+	fi
+	if [ $fail -eq 0 -a $pass -eq 0 ]
+	then
+		echo "not implemented:  `pwd`"
+		UNIMPLEMENTED=$(($UNIMPLEMENTED+1))
+	fi
+
+	FAIL=$(($FAIL+$fail))
+	PASS=$(($PASS+$pass))
+
+	for FILE in *
+	do
+		if [ -d "$FILE" ];
+		then
+			cd $FILE
+			if [ $FILE = thread -o $1 = yes ]; then
+				afunc yes
+			else
+				afunc no
+			fi
+			cd ..
+		fi
+	done
+}
+
+afunc no
+
+echo "****************************************************"
+echo "Results for `pwd`:"
+echo "using `$CC --version`"
+echo "with $OPTIONS $HEADER_INCLUDE $SOURCE_LIB"
+echo "----------------------------------------------------"
+echo "sections without tests   : $UNIMPLEMENTED"
+echo "sections with failures   : $IMPLEMENTED_FAIL"
+echo "sections without failures: $IMPLEMENTED_PASS"
+echo "                       +   ----"
+echo "total number of sections : $(($UNIMPLEMENTED+$IMPLEMENTED_FAIL+$IMPLEMENTED_PASS))"
+echo "----------------------------------------------------"
+echo "number of tests failed   : $FAIL"
+echo "number of tests passed   : $PASS"
+echo "                       +   ----"
+echo "total number of tests    : $(($FAIL+$PASS))"
+echo "****************************************************"
+
+exit $FAIL
diff --git a/final/test/thread/futures/futures.async/async.pass.cpp b/final/test/thread/futures/futures.async/async.pass.cpp
new file mode 100644
index 0000000..f67abe4
--- /dev/null
+++ b/final/test/thread/futures/futures.async/async.pass.cpp
@@ -0,0 +1,196 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// template <class F, class... Args>
+//     future<typename result_of<F(Args...)>::type>
+//     async(F&& f, Args&&... args);
+
+// template <class F, class... Args>
+//     future<typename result_of<F(Args...)>::type>
+//     async(launch policy, F&& f, Args&&... args);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+typedef std::chrono::high_resolution_clock Clock;
+typedef std::chrono::milliseconds ms;
+
+int f0()
+{
+    std::this_thread::sleep_for(ms(200));
+    return 3;
+}
+
+int i = 0;
+
+int& f1()
+{
+    std::this_thread::sleep_for(ms(200));
+    return i;
+}
+
+void f2()
+{
+    std::this_thread::sleep_for(ms(200));
+}
+
+std::unique_ptr<int> f3(int i)
+{
+    std::this_thread::sleep_for(ms(200));
+    return std::unique_ptr<int>(new int(i));
+}
+
+std::unique_ptr<int> f4(std::unique_ptr<int>&& p)
+{
+    std::this_thread::sleep_for(ms(200));
+    return std::move(p);
+}
+
+void f5(int i)
+{
+    std::this_thread::sleep_for(ms(200));
+    throw i;
+}
+
+int main()
+{
+    {
+        std::future<int> f = std::async(f0);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(f.get() == 3);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<int> f = std::async(std::launch::async, f0);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(f.get() == 3);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<int> f = std::async(std::launch::any, f0);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(f.get() == 3);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<int> f = std::async(std::launch::deferred, f0);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(f.get() == 3);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 > ms(100));
+    }
+
+    {
+        std::future<int&> f = std::async(f1);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(&f.get() == &i);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<int&> f = std::async(std::launch::async, f1);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(&f.get() == &i);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<int&> f = std::async(std::launch::any, f1);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(&f.get() == &i);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<int&> f = std::async(std::launch::deferred, f1);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(&f.get() == &i);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 > ms(100));
+    }
+
+    {
+        std::future<void> f = std::async(f2);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        f.get();
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<void> f = std::async(std::launch::async, f2);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        f.get();
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<void> f = std::async(std::launch::any, f2);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        f.get();
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+    {
+        std::future<void> f = std::async(std::launch::deferred, f2);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        f.get();
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 > ms(100));
+    }
+
+    {
+        std::future<std::unique_ptr<int>> f = std::async(f3, 3);
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(*f.get() == 3);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+
+    {
+        std::future<std::unique_ptr<int>> f =
+                               std::async(f4, std::unique_ptr<int>(new int(3)));
+        std::this_thread::sleep_for(ms(300));
+        Clock::time_point t0 = Clock::now();
+        assert(*f.get() == 3);
+        Clock::time_point t1 = Clock::now();
+        assert(t1-t0 < ms(100));
+    }
+
+    {
+        std::future<void> f = std::async(f5, 3);
+        std::this_thread::sleep_for(ms(300));
+        try { f.get(); assert (false); } catch ( int ex ) {}
+    }
+
+    {
+        std::future<void> f = std::async(std::launch::deferred, f5, 3);
+        std::this_thread::sleep_for(ms(300));
+        try { f.get(); assert (false); } catch ( int ex ) {}
+    }
+
+}
diff --git a/final/test/thread/futures/futures.errors/default_error_condition.pass.cpp b/final/test/thread/futures/futures.errors/default_error_condition.pass.cpp
new file mode 100644
index 0000000..35afe5a
--- /dev/null
+++ b/final/test/thread/futures/futures.errors/default_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// const error_category& future_category();
+
+// virtual error_condition default_error_condition(int ev) const;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::future_category();
+    std::error_condition e_cond = e_cat.default_error_condition(static_cast<int>(std::errc::not_a_directory));
+    assert(e_cond.category() == e_cat);
+    assert(e_cond.value() == static_cast<int>(std::errc::not_a_directory));
+}
diff --git a/final/test/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp b/final/test/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp
new file mode 100644
index 0000000..1f1cf40
--- /dev/null
+++ b/final/test/thread/futures/futures.errors/equivalent_error_code_int.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// const error_category& future_category();
+
+// virtual bool equivalent(const error_code& code, int condition) const;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::future_category();
+    assert(e_cat.equivalent(std::error_code(5, e_cat), 5));
+    assert(!e_cat.equivalent(std::error_code(5, e_cat), 6));
+}
diff --git a/final/test/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp b/final/test/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp
new file mode 100644
index 0000000..06fdce1
--- /dev/null
+++ b/final/test/thread/futures/futures.errors/equivalent_int_error_condition.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// const error_category& future_category();
+
+// virtual bool equivalent(int code, const error_condition& condition) const;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& e_cat = std::future_category();
+    std::error_condition e_cond = e_cat.default_error_condition(5);
+    assert(e_cat.equivalent(5, e_cond));
+    assert(!e_cat.equivalent(6, e_cond));
+}
diff --git a/final/test/thread/futures/futures.errors/future_category.pass.cpp b/final/test/thread/futures/futures.errors/future_category.pass.cpp
new file mode 100644
index 0000000..515946c
--- /dev/null
+++ b/final/test/thread/futures/futures.errors/future_category.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// const error_category& future_category();
+
+#include <future>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+    const std::error_category& ec = std::future_category();
+    assert(std::strcmp(ec.name(), "future") == 0);
+}
diff --git a/final/test/thread/futures/futures.errors/make_error_code.pass.cpp b/final/test/thread/futures/futures.errors/make_error_code.pass.cpp
new file mode 100644
index 0000000..f904c46
--- /dev/null
+++ b/final/test/thread/futures/futures.errors/make_error_code.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class error_code
+
+// error_code make_error_code(future_errc e);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec = make_error_code(std::future_errc::broken_promise);
+        assert(ec.value() == static_cast<int>(std::future_errc::broken_promise));
+        assert(ec.category() == std::future_category());
+    }
+}
diff --git a/final/test/thread/futures/futures.errors/make_error_condition.pass.cpp b/final/test/thread/futures/futures.errors/make_error_condition.pass.cpp
new file mode 100644
index 0000000..fd0f1c5
--- /dev/null
+++ b/final/test/thread/futures/futures.errors/make_error_condition.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class error_condition
+
+// error_condition make_error_condition(future_errc e);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        const std::error_condition ec1 =
+          std::make_error_condition(std::future_errc::future_already_retrieved);
+        assert(ec1.value() ==
+                  static_cast<int>(std::future_errc::future_already_retrieved));
+        assert(ec1.category() == std::future_category());
+    }
+}
diff --git a/final/test/thread/futures/futures.future_error/code.pass.cpp b/final/test/thread/futures/futures.future_error/code.pass.cpp
new file mode 100644
index 0000000..fdbfa4e
--- /dev/null
+++ b/final/test/thread/futures/futures.future_error/code.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future_error
+
+// const error_code& code() const throw();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        std::error_code ec = std::make_error_code(std::future_errc::broken_promise);
+        std::future_error f(ec);
+        assert(f.code() == ec);
+    }
+    {
+        std::error_code ec = std::make_error_code(std::future_errc::future_already_retrieved);
+        std::future_error f(ec);
+        assert(f.code() == ec);
+    }
+    {
+        std::error_code ec = std::make_error_code(std::future_errc::promise_already_satisfied);
+        std::future_error f(ec);
+        assert(f.code() == ec);
+    }
+    {
+        std::error_code ec = std::make_error_code(std::future_errc::no_state);
+        std::future_error f(ec);
+        assert(f.code() == ec);
+    }
+}
diff --git a/final/test/thread/futures/futures.future_error/types.pass.cpp b/final/test/thread/futures/futures.future_error/types.pass.cpp
new file mode 100644
index 0000000..af8e219
--- /dev/null
+++ b/final/test/thread/futures/futures.future_error/types.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future_error : public logic_error {...};
+
+#include <future>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_convertible<std::future_error*,
+                                       std::logic_error*>::value), "");
+}
diff --git a/final/test/thread/futures/futures.future_error/what.pass.cpp b/final/test/thread/futures/futures.future_error/what.pass.cpp
new file mode 100644
index 0000000..5e54350
--- /dev/null
+++ b/final/test/thread/futures/futures.future_error/what.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// LWG 2056 changed the values of future_errc, so if we're using new headers
+// with an old library we'll get incorrect messages.
+//
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+// XFAIL: with_system_lib=x86_64-apple-darwin13
+
+// <future>
+
+// class future_error
+
+// const char* what() const throw();
+
+#include <future>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+    {
+        std::future_error f(std::make_error_code(std::future_errc::broken_promise));
+        assert(std::strcmp(f.what(), "The associated promise has been destructed prior "
+                      "to the associated state becoming ready.") == 0);
+    }
+    {
+        std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved));
+        assert(std::strcmp(f.what(), "The future has already been retrieved from "
+                      "the promise or packaged_task.") == 0);
+    }
+    {
+        std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied));
+        assert(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
+    }
+    {
+        std::future_error f(std::make_error_code(std::future_errc::no_state));
+        assert(std::strcmp(f.what(), "Operation not permitted on an object without "
+                      "an associated state.") == 0);
+    }
+}
diff --git a/final/test/thread/futures/futures.overview/future_errc.pass.cpp b/final/test/thread/futures/futures.overview/future_errc.pass.cpp
new file mode 100644
index 0000000..7b3b70a
--- /dev/null
+++ b/final/test/thread/futures/futures.overview/future_errc.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// enum class future_errc
+// {
+//     future_already_retrieved = 1,
+//     promise_already_satisfied,
+//     no_state
+//     broken_promise,
+// };
+
+#include <future>
+
+int main()
+{
+    static_assert(static_cast<int>(std::future_errc::future_already_retrieved) == 1, "");
+    static_assert(static_cast<int>(std::future_errc::promise_already_satisfied) == 2, "");
+    static_assert(static_cast<int>(std::future_errc::no_state) == 3, "");
+    static_assert(static_cast<int>(std::future_errc::broken_promise) == 4, "");
+}
diff --git a/final/test/thread/futures/futures.overview/future_status.pass.cpp b/final/test/thread/futures/futures.overview/future_status.pass.cpp
new file mode 100644
index 0000000..0b6d32c
--- /dev/null
+++ b/final/test/thread/futures/futures.overview/future_status.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// enum class future_status
+// {
+//     ready,
+//     timeout,
+//     deferred
+// };
+
+#include <future>
+
+int main()
+{
+    static_assert(static_cast<int>(std::future_status::ready) == 0, "");
+    static_assert(static_cast<int>(std::future_status::timeout) == 1, "");
+    static_assert(static_cast<int>(std::future_status::deferred) == 2, "");
+}
diff --git a/final/test/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp b/final/test/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp
new file mode 100644
index 0000000..85b7993
--- /dev/null
+++ b/final/test/thread/futures/futures.overview/is_error_code_enum_future_errc.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// template <> struct is_error_code_enum<future_errc> : public true_type {};
+
+#include <future>
+
+int main()
+{
+    static_assert(std::is_error_code_enum<std::future_errc>::value, "");
+}
diff --git a/final/test/thread/futures/futures.overview/launch.pass.cpp b/final/test/thread/futures/futures.overview/launch.pass.cpp
new file mode 100644
index 0000000..5f4663c
--- /dev/null
+++ b/final/test/thread/futures/futures.overview/launch.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// enum class launch
+// {
+//     async = 1,
+//     deferred = 2,
+//     any = async | deferred
+// };
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
+    static_assert(static_cast<int>(std::launch::any) ==
+                 (static_cast<int>(std::launch::async) | static_cast<int>(std::launch::deferred)), "");
+#else
+    static_assert(std::launch::any == (std::launch::async | std::launch::deferred), "");
+    static_assert(std::launch(0) == (std::launch::async & std::launch::deferred), "");
+    static_assert(std::launch::any == (std::launch::async ^ std::launch::deferred), "");
+    static_assert(std::launch::deferred == ~std::launch::async, "");
+    std::launch x = std::launch::async;
+    x &= std::launch::deferred;
+    assert(x == std::launch(0));
+    x = std::launch::async;
+    x |= std::launch::deferred;
+    assert(x == std::launch::any);
+    x ^= std::launch::deferred;
+    assert(x == std::launch::async);
+#endif
+    static_assert(static_cast<int>(std::launch::async) == 1, "");
+    static_assert(static_cast<int>(std::launch::deferred) == 2, "");
+}
diff --git a/final/test/thread/futures/futures.promise/alloc_ctor.pass.cpp b/final/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
new file mode 100644
index 0000000..dca399f
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/alloc_ctor.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// template <class Allocator>
+//   promise(allocator_arg_t, const Allocator& a);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 1);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int&> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 1);
+        std::future<int&> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<void> p(std::allocator_arg, test_allocator<void>());
+        assert(test_alloc_base::count == 1);
+        std::future<void> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+}
diff --git a/final/test/thread/futures/futures.promise/copy_assign.fail.cpp b/final/test/thread/futures/futures.promise/copy_assign.fail.cpp
new file mode 100644
index 0000000..c082781
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/copy_assign.fail.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// promise& operator=(const promise& rhs) = delete;
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 2);
+        p = p0;
+        assert(test_alloc_base::count == 1);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int&> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 2);
+        p = p0;
+        assert(test_alloc_base::count == 1);
+        std::future<int&> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+        std::promise<void> p(std::allocator_arg, test_allocator<void>());
+        assert(test_alloc_base::count == 2);
+        p = p0;
+        assert(test_alloc_base::count == 1);
+        std::future<void> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+}
diff --git a/final/test/thread/futures/futures.promise/copy_ctor.fail.cpp b/final/test/thread/futures/futures.promise/copy_ctor.fail.cpp
new file mode 100644
index 0000000..36a3555
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/copy_ctor.fail.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// promise(const promise&) = delete;
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p(p0);
+        assert(test_alloc_base::count == 1);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int&> p(p0);
+        assert(test_alloc_base::count == 1);
+        std::future<int&> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+        std::promise<void> p(p0);
+        assert(test_alloc_base::count == 1);
+        std::future<void> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+}
diff --git a/final/test/thread/futures/futures.promise/default.pass.cpp b/final/test/thread/futures/futures.promise/default.pass.cpp
new file mode 100644
index 0000000..47aec02
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// promise();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        std::promise<int> p;
+        std::future<int> f = p.get_future();
+        assert(f.valid());
+    }
+    {
+        std::promise<int&> p;
+        std::future<int&> f = p.get_future();
+        assert(f.valid());
+    }
+    {
+        std::promise<void> p;
+        std::future<void> f = p.get_future();
+        assert(f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/dtor.pass.cpp b/final/test/thread/futures/futures.promise/dtor.pass.cpp
new file mode 100644
index 0000000..cd4fafb
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/dtor.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// ~promise();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        std::future<T> f;
+        {
+            std::promise<T> p;
+            f = p.get_future();
+            p.set_value(3);
+        }
+        assert(f.get() == 3);
+    }
+    {
+        typedef int T;
+        std::future<T> f;
+        {
+            std::promise<T> p;
+            f = p.get_future();
+        }
+        try
+        {
+            T i = f.get();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::broken_promise));
+        }
+    }
+
+    {
+        typedef int& T;
+        int i = 4;
+        std::future<T> f;
+        {
+            std::promise<T> p;
+            f = p.get_future();
+            p.set_value(i);
+        }
+        assert(&f.get() == &i);
+    }
+    {
+        typedef int& T;
+        std::future<T> f;
+        {
+            std::promise<T> p;
+            f = p.get_future();
+        }
+        try
+        {
+            T i = f.get();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::broken_promise));
+        }
+    }
+
+    {
+        typedef void T;
+        std::future<T> f;
+        {
+            std::promise<T> p;
+            f = p.get_future();
+            p.set_value();
+        }
+        f.get();
+        assert(true);
+    }
+    {
+        typedef void T;
+        std::future<T> f;
+        {
+            std::promise<T> p;
+            f = p.get_future();
+        }
+        try
+        {
+            f.get();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            // LWG 2056 changed the values of future_errc, so if we're using new
+            // headers with an old library the error codes won't line up.
+            //
+            // Note that this particular check only applies to promise<void>
+            // since the other specializations happen to be implemented in the
+            // header rather than the library.
+            assert(
+                e.code() == make_error_code(std::future_errc::broken_promise) ||
+                e.code() == std::error_code(0, std::future_category()));
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/get_future.pass.cpp b/final/test/thread/futures/futures.promise/get_future.pass.cpp
new file mode 100644
index 0000000..e7e78c7
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/get_future.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// future<R> get_future();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        std::promise<double> p;
+        std::future<double> f = p.get_future();
+        p.set_value(105.5);
+        assert(f.get() == 105.5);
+    }
+    {
+        std::promise<double> p;
+        std::future<double> f = p.get_future();
+        try
+        {
+            f = p.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() ==  make_error_code(std::future_errc::future_already_retrieved));
+        }
+    }
+    {
+        std::promise<double> p;
+        std::promise<double> p0 = std::move(p);
+        try
+        {
+            std::future<double> f = p.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() ==  make_error_code(std::future_errc::no_state));
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/move_assign.pass.cpp b/final/test/thread/futures/futures.promise/move_assign.pass.cpp
new file mode 100644
index 0000000..c378495
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/move_assign.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// promise& operator=(promise&& rhs);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 2);
+        p = std::move(p0);
+        assert(test_alloc_base::count == 1);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int&> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 2);
+        p = std::move(p0);
+        assert(test_alloc_base::count == 1);
+        std::future<int&> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+        std::promise<void> p(std::allocator_arg, test_allocator<void>());
+        assert(test_alloc_base::count == 2);
+        p = std::move(p0);
+        assert(test_alloc_base::count == 1);
+        std::future<void> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.promise/move_ctor.pass.cpp b/final/test/thread/futures/futures.promise/move_ctor.pass.cpp
new file mode 100644
index 0000000..4bd013a
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/move_ctor.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// promise(promise&& rhs);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p(std::move(p0));
+        assert(test_alloc_base::count == 1);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int&> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int&> p(std::move(p0));
+        assert(test_alloc_base::count == 1);
+        std::future<int&> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<void> p0(std::allocator_arg, test_allocator<void>());
+        std::promise<void> p(std::move(p0));
+        assert(test_alloc_base::count == 1);
+        std::future<void> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        try
+        {
+            f = p0.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.promise/set_exception.pass.cpp b/final/test/thread/futures/futures.promise/set_exception.pass.cpp
new file mode 100644
index 0000000..13c9aa9
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_exception.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void set_exception(exception_ptr p);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        p.set_exception(std::make_exception_ptr(3));
+        try
+        {
+            f.get();
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 3);
+        }
+        try
+        {
+            p.set_exception(std::make_exception_ptr(3));
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/final/test/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
new file mode 100644
index 0000000..7f9e418
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_exception_at_thread_exit(exception_ptr p);
+
+#include <future>
+#include <cassert>
+
+void func(std::promise<int> p)
+{
+    const int i = 5;
+    p.set_exception_at_thread_exit(std::make_exception_ptr(3));
+}
+
+int main()
+{
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func, std::move(p)).detach();
+        try
+        {
+            f.get();
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 3);
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/set_lvalue.pass.cpp b/final/test/thread/futures/futures.promise/set_lvalue.pass.cpp
new file mode 100644
index 0000000..4ee5fbb
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_lvalue.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise<R&>::set_value(R& r);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int& T;
+        int i = 3;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        p.set_value(i);
+        int& j = f.get();
+        assert(j == 3);
+        ++i;
+        assert(j == 4);
+        try
+        {
+            p.set_value(i);
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp b/final/test/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp
new file mode 100644
index 0000000..eef353a
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise<R&>::set_value_at_thread_exit(R& r);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+int i = 0;
+
+void func(std::promise<int&> p)
+{
+    p.set_value_at_thread_exit(i);
+    i = 4;
+}
+
+int main()
+{
+    {
+        std::promise<int&> p;
+        std::future<int&> f = p.get_future();
+        std::thread(func, std::move(p)).detach();
+        assert(f.get() == 4);
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/set_rvalue.pass.cpp b/final/test/thread/futures/futures.promise/set_rvalue.pass.cpp
new file mode 100644
index 0000000..3cbacea
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_rvalue.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value(R&& r);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct A
+{
+    A() {}
+    A(const A&) = delete;
+    A(A&&) {throw 9;}
+};
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::unique_ptr<int> T;
+        T i(new int(3));
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        p.set_value(std::move(i));
+        assert(*f.get() == 3);
+        try
+        {
+            p.set_value(std::move(i));
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+        }
+    }
+    {
+        typedef A T;
+        T i;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        try
+        {
+            p.set_value(std::move(i));
+            assert(false);
+        }
+        catch (int j)
+        {
+            assert(j == 9);
+        }
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp b/final/test/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp
new file mode 100644
index 0000000..1e3108c
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_rvalue_at_thread_exit.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value_at_thread_exit(R&& r);
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void func(std::promise<std::unique_ptr<int>> p)
+{
+    p.set_value_at_thread_exit(std::unique_ptr<int>(new int(5)));
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::promise<std::unique_ptr<int>> p;
+        std::future<std::unique_ptr<int>> f = p.get_future();
+        std::thread(func, std::move(p)).detach();
+        assert(*f.get() == 5);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp b/final/test/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp
new file mode 100644
index 0000000..bf8f21b
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value_at_thread_exit(const R& r);
+
+#include <future>
+#include <cassert>
+
+void func(std::promise<int> p)
+{
+    const int i = 5;
+    p.set_value_at_thread_exit(i);
+}
+
+int main()
+{
+    {
+        std::promise<int> p;
+        std::future<int> f = p.get_future();
+        std::thread(func, std::move(p)).detach();
+        assert(f.get() == 5);
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp b/final/test/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp
new file mode 100644
index 0000000..ee6f62f
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise<void>::set_value_at_thread_exit();
+
+#include <future>
+#include <memory>
+#include <cassert>
+
+int i = 0;
+
+void func(std::promise<void> p)
+{
+    p.set_value_at_thread_exit();
+    i = 1;
+}
+
+int main()
+{
+    {
+        std::promise<void> p;
+        std::future<void> f = p.get_future();
+        std::thread(func, std::move(p)).detach();
+        f.get();
+        assert(i == 1);
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/set_value_const.pass.cpp b/final/test/thread/futures/futures.promise/set_value_const.pass.cpp
new file mode 100644
index 0000000..94a9f92
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_value_const.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise::set_value(const R& r);
+
+#include <future>
+#include <cassert>
+
+struct A
+{
+    A() {}
+    A(const A&) {throw 10;}
+};
+
+int main()
+{
+    {
+        typedef int T;
+        T i = 3;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        p.set_value(i);
+        ++i;
+        assert(f.get() == 3);
+        --i;
+        try
+        {
+            p.set_value(i);
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+        }
+    }
+    {
+        typedef A T;
+        T i;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        try
+        {
+            p.set_value(i);
+            assert(false);
+        }
+        catch (int j)
+        {
+            assert(j == 10);
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/set_value_void.pass.cpp b/final/test/thread/futures/futures.promise/set_value_void.pass.cpp
new file mode 100644
index 0000000..c3b7e78
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/set_value_void.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void promise<void>::set_value();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        p.set_value();
+        f.get();
+        try
+        {
+            p.set_value();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.promise/swap.pass.cpp b/final/test/thread/futures/futures.promise/swap.pass.cpp
new file mode 100644
index 0000000..5e292b0
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/swap.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// void swap(promise& other);
+
+// template <class R> void swap(promise<R>& x, promise<R>& y);
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 2);
+        p.swap(p0);
+        assert(test_alloc_base::count == 2);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 2);
+        assert(f.valid());
+        f = p0.get_future();
+        assert(f.valid());
+        assert(test_alloc_base::count == 2);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p(std::allocator_arg, test_allocator<int>());
+        assert(test_alloc_base::count == 2);
+        swap(p, p0);
+        assert(test_alloc_base::count == 2);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 2);
+        assert(f.valid());
+        f = p0.get_future();
+        assert(f.valid());
+        assert(test_alloc_base::count == 2);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p;
+        assert(test_alloc_base::count == 1);
+        p.swap(p0);
+        assert(test_alloc_base::count == 1);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        f = p0.get_future();
+        assert(f.valid());
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        std::promise<int> p0(std::allocator_arg, test_allocator<int>());
+        std::promise<int> p;
+        assert(test_alloc_base::count == 1);
+        swap(p, p0);
+        assert(test_alloc_base::count == 1);
+        std::future<int> f = p.get_future();
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+        f = p0.get_future();
+        assert(f.valid());
+        assert(test_alloc_base::count == 1);
+    }
+    assert(test_alloc_base::count == 0);
+}
diff --git a/final/test/thread/futures/futures.promise/uses_allocator.pass.cpp b/final/test/thread/futures/futures.promise/uses_allocator.pass.cpp
new file mode 100644
index 0000000..1f30682
--- /dev/null
+++ b/final/test/thread/futures/futures.promise/uses_allocator.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class promise<R>
+
+// template <class R, class Alloc>
+//   struct uses_allocator<promise<R>, Alloc>
+//      : true_type { };
+
+#include <future>
+#include "../test_allocator.h"
+
+int main()
+{
+    static_assert((std::uses_allocator<std::promise<int>, test_allocator<int> >::value), "");
+    static_assert((std::uses_allocator<std::promise<int&>, test_allocator<int> >::value), "");
+    static_assert((std::uses_allocator<std::promise<void>, test_allocator<void> >::value), "");
+}
diff --git a/final/test/thread/futures/futures.shared_future/copy_assign.pass.cpp b/final/test/thread/futures/futures.shared_future/copy_assign.pass.cpp
new file mode 100644
index 0000000..e6b86d1
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/copy_assign.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future& operator=(const shared_future& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f;
+        f = f0;
+        assert(f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f;
+        f = f0;
+        assert(f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f;
+        f = f0;
+        assert(f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.shared_future/copy_ctor.pass.cpp b/final/test/thread/futures/futures.shared_future/copy_ctor.pass.cpp
new file mode 100644
index 0000000..445c189
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/copy_ctor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future(const shared_future& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f = f0;
+        assert(f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f = f0;
+        assert(f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f = f0;
+        assert(f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.shared_future/ctor_future.pass.cpp b/final/test/thread/futures/futures.shared_future/ctor_future.pass.cpp
new file mode 100644
index 0000000..207473e
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/ctor_future.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future(future<R>&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::future<T> f0;
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::future<T> f0;
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::future<T> f0;
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.shared_future/default.pass.cpp b/final/test/thread/futures/futures.shared_future/default.pass.cpp
new file mode 100644
index 0000000..dc056e8
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        std::shared_future<int> f;
+        assert(!f.valid());
+    }
+    {
+        std::shared_future<int&> f;
+        assert(!f.valid());
+    }
+    {
+        std::shared_future<void> f;
+        assert(!f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.shared_future/dtor.pass.cpp b/final/test/thread/futures/futures.shared_future/dtor.pass.cpp
new file mode 100644
index 0000000..a06a313
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/dtor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// ~shared_future();
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+    assert(test_alloc_base::count == 0);
+    {
+        typedef int T;
+        std::shared_future<T> f;
+        {
+            std::promise<T> p(std::allocator_arg, test_allocator<T>());
+            assert(test_alloc_base::count == 1);
+            f = p.get_future();
+            assert(test_alloc_base::count == 1);
+            assert(f.valid());
+        }
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        typedef int& T;
+        std::shared_future<T> f;
+        {
+            std::promise<T> p(std::allocator_arg, test_allocator<int>());
+            assert(test_alloc_base::count == 1);
+            f = p.get_future();
+            assert(test_alloc_base::count == 1);
+            assert(f.valid());
+        }
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        typedef void T;
+        std::shared_future<T> f;
+        {
+            std::promise<T> p(std::allocator_arg, test_allocator<T>());
+            assert(test_alloc_base::count == 1);
+            f = p.get_future();
+            assert(test_alloc_base::count == 1);
+            assert(f.valid());
+        }
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+}
diff --git a/final/test/thread/futures/futures.shared_future/get.pass.cpp b/final/test/thread/futures/futures.shared_future/get.pass.cpp
new file mode 100644
index 0000000..16723ea
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/get.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// const R& shared_future::get();
+// R& shared_future<R&>::get();
+// void shared_future<void>::get();
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value(3);
+}
+
+void func2(std::promise<int> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_exception(std::make_exception_ptr(3));
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func4(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_exception(std::make_exception_ptr(3.5));
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value();
+}
+
+void func6(std::promise<void> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_exception(std::make_exception_ptr('c'));
+}
+
+int main()
+{
+    {
+        typedef int T;
+        {
+            std::promise<T> p;
+            std::shared_future<T> f = p.get_future();
+            std::thread(func1, std::move(p)).detach();
+            assert(f.valid());
+            assert(f.get() == 3);
+            assert(f.valid());
+        }
+        {
+            std::promise<T> p;
+            std::shared_future<T> f = p.get_future();
+            std::thread(func2, std::move(p)).detach();
+            try
+            {
+                assert(f.valid());
+                assert(f.get() == 3);
+                assert(false);
+            }
+            catch (int i)
+            {
+                assert(i == 3);
+            }
+            assert(f.valid());
+        }
+    }
+    {
+        typedef int& T;
+        {
+            std::promise<T> p;
+            std::shared_future<T> f = p.get_future();
+            std::thread(func3, std::move(p)).detach();
+            assert(f.valid());
+            assert(f.get() == 5);
+            assert(f.valid());
+        }
+        {
+            std::promise<T> p;
+            std::shared_future<T> f = p.get_future();
+            std::thread(func4, std::move(p)).detach();
+            try
+            {
+                assert(f.valid());
+                assert(f.get() == 3);
+                assert(false);
+            }
+            catch (double i)
+            {
+                assert(i == 3.5);
+            }
+            assert(f.valid());
+        }
+    }
+    {
+        typedef void T;
+        {
+            std::promise<T> p;
+            std::shared_future<T> f = p.get_future();
+            std::thread(func5, std::move(p)).detach();
+            assert(f.valid());
+            f.get();
+            assert(f.valid());
+        }
+        {
+            std::promise<T> p;
+            std::shared_future<T> f = p.get_future();
+            std::thread(func6, std::move(p)).detach();
+            try
+            {
+                assert(f.valid());
+                f.get();
+                assert(false);
+            }
+            catch (char i)
+            {
+                assert(i == 'c');
+            }
+            assert(f.valid());
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.shared_future/move_assign.pass.cpp b/final/test/thread/futures/futures.shared_future/move_assign.pass.cpp
new file mode 100644
index 0000000..36e0168
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/move_assign.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future& operator=(shared_future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.shared_future/move_ctor.pass.cpp b/final/test/thread/futures/futures.shared_future/move_ctor.pass.cpp
new file mode 100644
index 0000000..35b8221
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/move_ctor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// shared_future(shared_future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::shared_future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::shared_future<T> f0;
+        std::shared_future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.shared_future/wait.pass.cpp b/final/test/thread/futures/futures.shared_future/wait.pass.cpp
new file mode 100644
index 0000000..b14d703
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/wait.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// void wait() const;
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value();
+}
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock Clock;
+    typedef std::chrono::duration<double, std::milli> ms;
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        assert(f.valid());
+        f.wait();
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func3, std::move(p)).detach();
+        assert(f.valid());
+        f.wait();
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func5, std::move(p)).detach();
+        assert(f.valid());
+        f.wait();
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+}
diff --git a/final/test/thread/futures/futures.shared_future/wait_for.pass.cpp b/final/test/thread/futures/futures.shared_future/wait_for.pass.cpp
new file mode 100644
index 0000000..ae678ff
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/wait_for.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// template <class Rep, class Period>
+//   future_status
+//   wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+
+#include <future>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value();
+}
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock Clock;
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func3, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func5, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+}
diff --git a/final/test/thread/futures/futures.shared_future/wait_until.pass.cpp b/final/test/thread/futures/futures.shared_future/wait_until.pass.cpp
new file mode 100644
index 0000000..1a0c9b3
--- /dev/null
+++ b/final/test/thread/futures/futures.shared_future/wait_until.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class shared_future<R>
+
+// template <class Clock, class Duration>
+//   future_status
+//   wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+
+#include <future>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value();
+}
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock Clock;
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func3, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::shared_future<T> f = p.get_future();
+        std::thread(func5, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+}
diff --git a/final/test/thread/futures/futures.state/nothing_to_do.pass.cpp b/final/test/thread/futures/futures.state/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..9a59227
--- /dev/null
+++ b/final/test/thread/futures/futures.state/nothing_to_do.pass.cpp
@@ -0,0 +1,13 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp b/final/test/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp
new file mode 100644
index 0000000..70ea0ad
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task& operator=(packaged_task&) = delete;
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p0(A(5));
+        std::packaged_task<double(int, char)> p;
+        p = p0;
+        assert(!p0.valid());
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p0;
+        std::packaged_task<double(int, char)> p;
+        p = p0;
+        assert(!p0.valid());
+        assert(!p.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp
new file mode 100644
index 0000000..a0f711a
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task& operator=(packaged_task&& other);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p0(A(5));
+        std::packaged_task<double(int, char)> p;
+        p = std::move(p0);
+        assert(!p0.valid());
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p0;
+        std::packaged_task<double(int, char)> p;
+        p = std::move(p0);
+        assert(!p0.valid());
+        assert(!p.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp b/final/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp
new file mode 100644
index 0000000..45048b7
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+// template <class F>
+//   packaged_task(F&& f);
+// These constructors shall not participate in overload resolution if 
+//    decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
+
+#include <future>
+#include <cassert>
+
+struct A {};
+typedef std::packaged_task<A(int, char)> PT;
+typedef volatile std::packaged_task<A(int, char)> VPT;
+
+
+int main()
+{
+    PT p { VPT{} };
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp b/final/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp
new file mode 100644
index 0000000..e81adfa
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+// template <class F, class Allocator>
+//   explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
+// These constructors shall not participate in overload resolution if 
+//    decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
+
+#include <future>
+#include <cassert>
+
+#include "../../test_allocator.h"
+
+struct A {};
+typedef std::packaged_task<A(int, char)> PT;
+typedef volatile std::packaged_task<A(int, char)> VPT;
+
+int main()
+{
+    PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}};
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp b/final/test/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp
new file mode 100644
index 0000000..9884c49
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task(packaged_task&) = delete;
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p0(A(5));
+        std::packaged_task<double(int, char)> p(p0);
+        assert(!p0.valid());
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p0;
+        std::packaged_task<double(int, char)> p(p0);
+        assert(!p0.valid());
+        assert(!p.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp
new file mode 100644
index 0000000..f53b26e
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task();
+
+#include <future>
+#include <cassert>
+
+struct A {};
+
+int main()
+{
+    std::packaged_task<A(int, char)> p;
+    assert(!p.valid());
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp
new file mode 100644
index 0000000..58e9982
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class F>
+//     explicit packaged_task(F&& f);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    static int n_moves;
+    static int n_copies;
+
+    explicit A(long i) : data_(i) {}
+    A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;}
+    A(const A& a) : data_(a.data_) {++n_copies;}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int A::n_moves = 0;
+int A::n_copies = 0;
+
+int func(int i) { return i; }
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+        assert(A::n_copies == 0);
+        assert(A::n_moves > 0);
+    }
+    A::n_copies = 0;
+    A::n_copies = 0;
+    {
+        A a(5);
+        std::packaged_task<double(int, char)> p(a);
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+        assert(A::n_copies > 0);
+        assert(A::n_moves > 0);
+    }
+    {
+        std::packaged_task<int(int)> p(&func);
+        assert(p.valid());
+        std::future<int> f = p.get_future();
+        p(4);
+        assert(f.get() == 4);
+    }
+    {
+        std::packaged_task<int(int)> p(func);
+        assert(p.valid());
+        std::future<int> f = p.get_future();
+        p(4);
+        assert(f.get() == 4);
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
new file mode 100644
index 0000000..e7070c5
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class F, class Allocator>
+//     explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
+
+#include <future>
+#include <cassert>
+
+#include "../../test_allocator.h"
+
+class A
+{
+    long data_;
+
+public:
+    static int n_moves;
+    static int n_copies;
+
+    explicit A(long i) : data_(i) {}
+    A(A&& a) : data_(a.data_) {++n_moves; a.data_ = -1;}
+    A(const A& a) : data_(a.data_) {++n_copies;}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int A::n_moves = 0;
+int A::n_copies = 0;
+
+int func(int i) { return i; }
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p(std::allocator_arg,
+                                                test_allocator<A>(), A(5));
+        assert(test_alloc_base::count > 0);
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+        assert(A::n_copies == 0);
+        assert(A::n_moves > 0);
+    }
+    assert(test_alloc_base::count == 0);
+    A::n_copies = 0;
+    A::n_moves  = 0;
+    {
+        A a(5);
+        std::packaged_task<double(int, char)> p(std::allocator_arg,
+                                                test_allocator<A>(), a);
+        assert(test_alloc_base::count > 0);
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+        assert(A::n_copies > 0);
+        assert(A::n_moves > 0);
+    }
+    assert(test_alloc_base::count == 0);
+    A::n_copies = 0;
+    A::n_moves  = 0;
+    {
+        A a(5);
+        std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), &func);
+        assert(test_alloc_base::count > 0);
+        assert(p.valid());
+        std::future<int> f = p.get_future();
+        p(4);
+        assert(f.get() == 4);
+    }
+    assert(test_alloc_base::count == 0);
+    A::n_copies = 0;
+    A::n_moves  = 0;
+    {
+        A a(5);
+        std::packaged_task<int(int)> p(std::allocator_arg, test_allocator<A>(), func);
+        assert(test_alloc_base::count > 0);
+        assert(p.valid());
+        std::future<int> f = p.get_future();
+        p(4);
+        assert(f.get() == 4);
+    }
+    assert(test_alloc_base::count == 0);
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp
new file mode 100644
index 0000000..c668a67
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// packaged_task(packaged_task&& other);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p0(A(5));
+        std::packaged_task<double(int, char)> p = std::move(p0);
+        assert(!p0.valid());
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p0;
+        std::packaged_task<double(int, char)> p = std::move(p0);
+        assert(!p0.valid());
+        assert(!p.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp
new file mode 100644
index 0000000..9b76934
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// ~packaged_task();
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+void func(std::packaged_task<double(int, char)> p)
+{
+}
+
+void func2(std::packaged_task<double(int, char)> p)
+{
+    p(3, 'a');
+}
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread(func, std::move(p)).detach();
+        try
+        {
+            double i = f.get();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::broken_promise));
+        }
+    }
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread(func2, std::move(p)).detach();
+        assert(f.get() == 105.0);
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp
new file mode 100644
index 0000000..d6efbf1
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// future<R> get_future();
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        try
+        {
+            f = p.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() ==  make_error_code(std::future_errc::future_already_retrieved));
+        }
+    }
+    {
+        std::packaged_task<double(int, char)> p;
+        try
+        {
+            std::future<double> f = p.get_future();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() ==  make_error_code(std::future_errc::no_state));
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp
new file mode 100644
index 0000000..accbd75
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void make_ready_at_thread_exit(ArgTypes... args);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const
+    {
+        if (j == 'z')
+            throw A(6);
+        return data_ + i + j;
+    }
+};
+
+void func0(std::packaged_task<double(int, char)> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.make_ready_at_thread_exit(3, 'a');
+}
+
+void func1(std::packaged_task<double(int, char)> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.make_ready_at_thread_exit(3, 'z');
+}
+
+void func2(std::packaged_task<double(int, char)> p)
+{
+    p.make_ready_at_thread_exit(3, 'a');
+    try
+    {
+        p.make_ready_at_thread_exit(3, 'c');
+    }
+    catch (const std::future_error& e)
+    {
+        assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+    }
+}
+
+void func3(std::packaged_task<double(int, char)> p)
+{
+    try
+    {
+        p.make_ready_at_thread_exit(3, 'a');
+    }
+    catch (const std::future_error& e)
+    {
+        assert(e.code() == make_error_code(std::future_errc::no_state));
+    }
+}
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread(func0, std::move(p)).detach();
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        try
+        {
+            f.get();
+            assert(false);
+        }
+        catch (const A& e)
+        {
+            assert(e(3, 'a') == 106);
+        }
+    }
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread(func2, std::move(p)).detach();
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p;
+        std::thread t(func3, std::move(p));
+        t.join();
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/operator.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/operator.pass.cpp
new file mode 100644
index 0000000..b77cf31
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/operator.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void operator()(ArgTypes... args);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const
+    {
+        if (j == 'z')
+            throw A(6);
+        return data_ + i + j;
+    }
+};
+
+void func0(std::packaged_task<double(int, char)> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p(3, 'a');
+}
+
+void func1(std::packaged_task<double(int, char)> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p(3, 'z');
+}
+
+void func2(std::packaged_task<double(int, char)> p)
+{
+    p(3, 'a');
+    try
+    {
+        p(3, 'c');
+    }
+    catch (const std::future_error& e)
+    {
+        assert(e.code() == make_error_code(std::future_errc::promise_already_satisfied));
+    }
+}
+
+void func3(std::packaged_task<double(int, char)> p)
+{
+    try
+    {
+        p(3, 'a');
+    }
+    catch (const std::future_error& e)
+    {
+        assert(e.code() == make_error_code(std::future_errc::no_state));
+    }
+}
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread(func0, std::move(p)).detach();
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        try
+        {
+            f.get();
+            assert(false);
+        }
+        catch (const A& e)
+        {
+            assert(e(3, 'a') == 106);
+        }
+    }
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        std::thread t(func2, std::move(p));
+        assert(f.get() == 105.0);
+        t.join();
+    }
+    {
+        std::packaged_task<double(int, char)> p;
+        std::thread t(func3, std::move(p));
+        t.join();
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/reset.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/reset.pass.cpp
new file mode 100644
index 0000000..3ca3d14
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/reset.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void reset();
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const
+    {
+        if (j == 'z')
+            throw A(6);
+        return data_ + i + j;
+    }
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p(A(5));
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+        p.reset();
+        p(4, 'a');
+        f = p.get_future();
+        assert(f.get() == 106.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p;
+        try
+        {
+            p.reset();
+            assert(false);
+        }
+        catch (const std::future_error& e)
+        {
+            assert(e.code() == make_error_code(std::future_errc::no_state));
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.members/swap.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.members/swap.pass.cpp
new file mode 100644
index 0000000..9f549aa
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.members/swap.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// void swap(packaged_task& other);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p0(A(5));
+        std::packaged_task<double(int, char)> p;
+        p.swap(p0);
+        assert(!p0.valid());
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p0;
+        std::packaged_task<double(int, char)> p;
+        p.swap(p0);
+        assert(!p0.valid());
+        assert(!p.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp
new file mode 100644
index 0000000..ef99f61
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class R, class... ArgTypes>
+//   void
+//   swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y);
+
+#include <future>
+#include <cassert>
+
+class A
+{
+    long data_;
+
+public:
+    explicit A(long i) : data_(i) {}
+
+    long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+    {
+        std::packaged_task<double(int, char)> p0(A(5));
+        std::packaged_task<double(int, char)> p;
+        swap(p, p0);
+        assert(!p0.valid());
+        assert(p.valid());
+        std::future<double> f = p.get_future();
+        p(3, 'a');
+        assert(f.get() == 105.0);
+    }
+    {
+        std::packaged_task<double(int, char)> p0;
+        std::packaged_task<double(int, char)> p;
+        swap(p, p0);
+        assert(!p0.valid());
+        assert(!p.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp b/final/test/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp
new file mode 100644
index 0000000..130390f
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// template <class Callable, class Alloc>
+//   struct uses_allocator<packaged_task<Callable>, Alloc>
+//      : true_type { };
+
+#include <future>
+#include "../../test_allocator.h"
+
+int main()
+{
+    static_assert((std::uses_allocator<std::packaged_task<double(int, char)>, test_allocator<int> >::value), "");
+}
diff --git a/final/test/thread/futures/futures.tas/types.pass.cpp b/final/test/thread/futures/futures.tas/types.pass.cpp
new file mode 100644
index 0000000..c66f359
--- /dev/null
+++ b/final/test/thread/futures/futures.tas/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// template<class R, class... ArgTypes>
+//     class packaged_task<R(ArgTypes...)>
+// {
+// public:
+//     typedef R result_type;
+
+#include <future>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    static_assert((std::is_same<std::packaged_task<A(int, char)>::result_type, A>::value), "");
+}
diff --git a/final/test/thread/futures/futures.unique_future/copy_assign.fail.cpp b/final/test/thread/futures/futures.unique_future/copy_assign.fail.cpp
new file mode 100644
index 0000000..ebdcbf9
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/copy_assign.fail.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// future& operator=(const future&) = delete;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::future<T> f0;
+        std::future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::future<T> f0;
+        std::future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::future<T> f0;
+        std::future<T> f;
+        f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.unique_future/copy_ctor.fail.cpp b/final/test/thread/futures/futures.unique_future/copy_ctor.fail.cpp
new file mode 100644
index 0000000..8d43294
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/copy_ctor.fail.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// future(const future&) = delete;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f = f0;
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::future<T> f0;
+        std::future<T> f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f = f0;
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::future<T> f0;
+        std::future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f = f0;
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::future<T> f0;
+        std::future<T> f = f0;
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.unique_future/default.pass.cpp b/final/test/thread/futures/futures.unique_future/default.pass.cpp
new file mode 100644
index 0000000..915f118
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// future();
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        std::future<int> f;
+        assert(!f.valid());
+    }
+    {
+        std::future<int&> f;
+        assert(!f.valid());
+    }
+    {
+        std::future<void> f;
+        assert(!f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.unique_future/dtor.pass.cpp b/final/test/thread/futures/futures.unique_future/dtor.pass.cpp
new file mode 100644
index 0000000..1bc141b
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/dtor.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// ~future();
+
+#include <future>
+#include <cassert>
+
+#include "../test_allocator.h"
+
+int main()
+{
+    assert(test_alloc_base::count == 0);
+    {
+        typedef int T;
+        std::future<T> f;
+        {
+            std::promise<T> p(std::allocator_arg, test_allocator<T>());
+            assert(test_alloc_base::count == 1);
+            f = p.get_future();
+            assert(test_alloc_base::count == 1);
+            assert(f.valid());
+        }
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        typedef int& T;
+        std::future<T> f;
+        {
+            std::promise<T> p(std::allocator_arg, test_allocator<int>());
+            assert(test_alloc_base::count == 1);
+            f = p.get_future();
+            assert(test_alloc_base::count == 1);
+            assert(f.valid());
+        }
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+    {
+        typedef void T;
+        std::future<T> f;
+        {
+            std::promise<T> p(std::allocator_arg, test_allocator<T>());
+            assert(test_alloc_base::count == 1);
+            f = p.get_future();
+            assert(test_alloc_base::count == 1);
+            assert(f.valid());
+        }
+        assert(test_alloc_base::count == 1);
+        assert(f.valid());
+    }
+    assert(test_alloc_base::count == 0);
+}
diff --git a/final/test/thread/futures/futures.unique_future/get.pass.cpp b/final/test/thread/futures/futures.unique_future/get.pass.cpp
new file mode 100644
index 0000000..1b0ee2b
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/get.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// R future::get();
+// R& future<R&>::get();
+// void future<void>::get();
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value(3);
+}
+
+void func2(std::promise<int> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_exception(std::make_exception_ptr(3));
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func4(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_exception(std::make_exception_ptr(3.5));
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value();
+}
+
+void func6(std::promise<void> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_exception(std::make_exception_ptr('c'));
+}
+
+int main()
+{
+    {
+        typedef int T;
+        {
+            std::promise<T> p;
+            std::future<T> f = p.get_future();
+            std::thread(func1, std::move(p)).detach();
+            assert(f.valid());
+            assert(f.get() == 3);
+            assert(!f.valid());
+        }
+        {
+            std::promise<T> p;
+            std::future<T> f = p.get_future();
+            std::thread(func2, std::move(p)).detach();
+            try
+            {
+                assert(f.valid());
+                assert(f.get() == 3);
+                assert(false);
+            }
+            catch (int i)
+            {
+                assert(i == 3);
+            }
+            assert(!f.valid());
+        }
+    }
+    {
+        typedef int& T;
+        {
+            std::promise<T> p;
+            std::future<T> f = p.get_future();
+            std::thread(func3, std::move(p)).detach();
+            assert(f.valid());
+            assert(f.get() == 5);
+            assert(!f.valid());
+        }
+        {
+            std::promise<T> p;
+            std::future<T> f = p.get_future();
+            std::thread(func4, std::move(p)).detach();
+            try
+            {
+                assert(f.valid());
+                assert(f.get() == 3);
+                assert(false);
+            }
+            catch (double i)
+            {
+                assert(i == 3.5);
+            }
+            assert(!f.valid());
+        }
+    }
+    {
+        typedef void T;
+        {
+            std::promise<T> p;
+            std::future<T> f = p.get_future();
+            std::thread(func5, std::move(p)).detach();
+            assert(f.valid());
+            f.get();
+            assert(!f.valid());
+        }
+        {
+            std::promise<T> p;
+            std::future<T> f = p.get_future();
+            std::thread(func6, std::move(p)).detach();
+            try
+            {
+                assert(f.valid());
+                f.get();
+                assert(false);
+            }
+            catch (char i)
+            {
+                assert(i == 'c');
+            }
+            assert(!f.valid());
+        }
+    }
+}
diff --git a/final/test/thread/futures/futures.unique_future/move_assign.pass.cpp b/final/test/thread/futures/futures.unique_future/move_assign.pass.cpp
new file mode 100644
index 0000000..79dcd7d
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/move_assign.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// future& operator=(future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::future<T> f0;
+        std::future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::future<T> f0;
+        std::future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::future<T> f0;
+        std::future<T> f;
+        f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.unique_future/move_ctor.pass.cpp b/final/test/thread/futures/futures.unique_future/move_ctor.pass.cpp
new file mode 100644
index 0000000..af23e4d
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/move_ctor.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// future(future&& rhs);
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::future<T> f0;
+        std::future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::future<T> f0;
+        std::future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::future<T> f0;
+        std::future<T> f = std::move(f0);
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/futures/futures.unique_future/share.pass.cpp b/final/test/thread/futures/futures.unique_future/share.pass.cpp
new file mode 100644
index 0000000..a19ce2e
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/share.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// shared_future<R> share() &&;
+
+#include <future>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0.share());
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int T;
+        std::future<T> f0;
+        std::shared_future<T> f = std::move(f0.share());
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0.share());
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef int& T;
+        std::future<T> f0;
+        std::shared_future<T> f = std::move(f0.share());
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f0 = p.get_future();
+        std::shared_future<T> f = std::move(f0.share());
+        assert(!f0.valid());
+        assert(f.valid());
+    }
+    {
+        typedef void T;
+        std::future<T> f0;
+        std::shared_future<T> f = std::move(f0.share());
+        assert(!f0.valid());
+        assert(!f.valid());
+    }
+}
diff --git a/final/test/thread/futures/futures.unique_future/wait.pass.cpp b/final/test/thread/futures/futures.unique_future/wait.pass.cpp
new file mode 100644
index 0000000..68c0d14
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/wait.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// void wait() const;
+
+#include <future>
+#include <cassert>
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    p.set_value();
+}
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock Clock;
+    typedef std::chrono::duration<double, std::milli> ms;
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        assert(f.valid());
+        f.wait();
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func3, std::move(p)).detach();
+        assert(f.valid());
+        f.wait();
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func5, std::move(p)).detach();
+        assert(f.valid());
+        f.wait();
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+}
diff --git a/final/test/thread/futures/futures.unique_future/wait_for.pass.cpp b/final/test/thread/futures/futures.unique_future/wait_for.pass.cpp
new file mode 100644
index 0000000..2a81a2c
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/wait_for.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// template <class Rep, class Period>
+//   future_status
+//   wait_for(const chrono::duration<Rep, Period>& rel_time) const;
+
+#include <future>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value();
+}
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock Clock;
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(50));
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func3, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(50));
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func5, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_for(ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(50));
+    }
+}
diff --git a/final/test/thread/futures/futures.unique_future/wait_until.pass.cpp b/final/test/thread/futures/futures.unique_future/wait_until.pass.cpp
new file mode 100644
index 0000000..8ac0bc8
--- /dev/null
+++ b/final/test/thread/futures/futures.unique_future/wait_until.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+// class future<R>
+
+// template <class Clock, class Duration>
+//   future_status
+//   wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
+
+#include <future>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+void func1(std::promise<int> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value(3);
+}
+
+int j = 0;
+
+void func3(std::promise<int&> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    j = 5;
+    p.set_value(j);
+}
+
+void func5(std::promise<void> p)
+{
+    std::this_thread::sleep_for(ms(500));
+    p.set_value();
+}
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock Clock;
+    {
+        typedef int T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func1, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef int& T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func3, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+    {
+        typedef void T;
+        std::promise<T> p;
+        std::future<T> f = p.get_future();
+        std::thread(func5, std::move(p)).detach();
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::timeout);
+        assert(f.valid());
+        assert(f.wait_until(Clock::now() + ms(300)) == std::future_status::ready);
+        assert(f.valid());
+        Clock::time_point t0 = Clock::now();
+        f.wait();
+        Clock::time_point t1 = Clock::now();
+        assert(f.valid());
+        assert(t1-t0 < ms(5));
+    }
+}
diff --git a/final/test/thread/futures/test_allocator.h b/final/test/thread/futures/test_allocator.h
new file mode 100644
index 0000000..ea70ada
--- /dev/null
+++ b/final/test/thread/futures/test_allocator.h
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 TEST_ALLOCATOR_H
+#define TEST_ALLOCATOR_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+class test_alloc_base
+{
+public:
+    static int count;
+public:
+    static int throw_after;
+};
+
+int test_alloc_base::count = 0;
+int test_alloc_base::throw_after = INT_MAX;
+
+template <class T>
+class test_allocator
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef T                                                          value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+    typedef typename std::add_lvalue_reference<value_type>::type       reference;
+    typedef typename std::add_lvalue_reference<const value_type>::type const_reference;
+
+    template <class U> struct rebind {typedef test_allocator<U> other;};
+
+    test_allocator() throw() : data_(-1) {}
+    explicit test_allocator(int i) throw() : data_(i) {}
+    test_allocator(const test_allocator& a) throw()
+        : data_(a.data_) {}
+    template <class U> test_allocator(const test_allocator<U>& a) throw()
+        : data_(a.data_) {}
+    ~test_allocator() throw() {data_ = 0;}
+    pointer address(reference x) const {return &x;}
+    const_pointer address(const_reference x) const {return &x;}
+    pointer allocate(size_type n, const void* = 0)
+        {
+            if (count >= throw_after) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+                throw std::bad_alloc();
+#else
+                std::terminate();
+#endif
+            }
+            ++count;
+            return (pointer)std::malloc(n * sizeof(T));
+        }
+    void deallocate(pointer p, size_type n)
+        {--count; std::free(p);}
+    size_type max_size() const throw()
+        {return UINT_MAX / sizeof(T);}
+    void construct(pointer p, const T& val)
+        {::new(p) T(val);}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void construct(pointer p, T&& val)
+        {::new(p) T(std::move(val));}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    void destroy(pointer p) {p->~T();}
+
+    friend bool operator==(const test_allocator& x, const test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const test_allocator& x, const test_allocator& y)
+        {return !(x == y);}
+};
+
+template <>
+class test_allocator<void>
+    : public test_alloc_base
+{
+    int data_;
+
+    template <class U> friend class test_allocator;
+public:
+
+    typedef unsigned                                                   size_type;
+    typedef int                                                        difference_type;
+    typedef void                                                       value_type;
+    typedef value_type*                                                pointer;
+    typedef const value_type*                                          const_pointer;
+
+    template <class U> struct rebind {typedef test_allocator<U> other;};
+
+    test_allocator() throw() : data_(-1) {}
+    explicit test_allocator(int i) throw() : data_(i) {}
+    test_allocator(const test_allocator& a) throw()
+        : data_(a.data_) {}
+    template <class U> test_allocator(const test_allocator<U>& a) throw()
+        : data_(a.data_) {}
+    ~test_allocator() throw() {data_ = 0;}
+
+    friend bool operator==(const test_allocator& x, const test_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const test_allocator& x, const test_allocator& y)
+        {return !(x == y);}
+};
+
+template <class T>
+class other_allocator
+{
+    int data_;
+
+    template <class U> friend class other_allocator;
+
+public:
+    typedef T value_type;
+
+    other_allocator() : data_(-1) {}
+    explicit other_allocator(int i) : data_(i) {}
+    template <class U> other_allocator(const other_allocator<U>& a)
+        : data_(a.data_) {}
+    T* allocate(std::size_t n)
+        {return (T*)std::malloc(n * sizeof(T));}
+    void deallocate(T* p, std::size_t n)
+        {std::free(p);}
+
+    other_allocator select_on_container_copy_construction() const
+        {return other_allocator(-2);}
+
+    friend bool operator==(const other_allocator& x, const other_allocator& y)
+        {return x.data_ == y.data_;}
+    friend bool operator!=(const other_allocator& x, const other_allocator& y)
+        {return !(x == y);}
+
+    typedef std::true_type propagate_on_container_copy_assignment;
+    typedef std::true_type propagate_on_container_move_assignment;
+    typedef std::true_type propagate_on_container_swap;
+
+#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    std::size_t max_size() const
+        {return UINT_MAX / sizeof(T);}
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+
+};
+
+#endif  // TEST_ALLOCATOR_H
diff --git a/final/test/thread/futures/version.pass.cpp b/final/test/thread/futures/version.pass.cpp
new file mode 100644
index 0000000..5ac4e0f
--- /dev/null
+++ b/final/test/thread/futures/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <future>
+
+#include <future>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/thread/macro.pass.cpp b/final/test/thread/macro.pass.cpp
new file mode 100644
index 0000000..243640d
--- /dev/null
+++ b/final/test/thread/macro.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// #define __STDCPP_THREADS__ __cplusplus
+
+#include <thread>
+
+int main()
+{
+#ifndef __STDCPP_THREADS__
+#error __STDCPP_THREADS__ is not defined
+#endif
+}
diff --git a/final/test/thread/thread.condition/cv_status.pass.cpp b/final/test/thread/thread.condition/cv_status.pass.cpp
new file mode 100644
index 0000000..d5e0947
--- /dev/null
+++ b/final/test/thread/thread.condition/cv_status.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// enum class cv_status { no_timeout, timeout };
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    assert(static_cast<int>(std::cv_status::no_timeout) == 0);
+    assert(static_cast<int>(std::cv_status::timeout)    == 1);
+}
diff --git a/final/test/thread/thread.condition/notify_all_at_thread_exit.pass.cpp b/final/test/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
new file mode 100644
index 0000000..e4f193a
--- /dev/null
+++ b/final/test/thread/thread.condition/notify_all_at_thread_exit.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// void
+//   notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::high_resolution_clock Clock;
+
+void func()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    std::notify_all_at_thread_exit(cv, std::move(lk));
+    std::this_thread::sleep_for(ms(300));
+}
+
+int main()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    std::thread(func).detach();
+    Clock::time_point t0 = Clock::now();
+    cv.wait(lk);
+    Clock::time_point t1 = Clock::now();
+    assert(t1-t0 > ms(250));
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/assign.fail.cpp b/final/test/thread/thread.condition/thread.condition.condvar/assign.fail.cpp
new file mode 100644
index 0000000..e88550c
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable& operator=(const condition_variable&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable cv0;
+    std::condition_variable cv1;
+    cv1 = cv0;
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/copy.fail.cpp b/final/test/thread/thread.condition/thread.condition.condvar/copy.fail.cpp
new file mode 100644
index 0000000..24d6ee0
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/copy.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable(const condition_variable&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable cv0;
+    std::condition_variable cv1(cv0);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/default.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/default.pass.cpp
new file mode 100644
index 0000000..a912413
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/default.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// condition_variable();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable cv;
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp
new file mode 100644
index 0000000..9828fbb
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/destructor.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// ~condition_variable();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable* cv;
+std::mutex m;
+typedef std::unique_lock<std::mutex> Lock;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+    Lock lk(m);
+    f_ready = true;
+    cv->notify_one();
+    delete cv;
+}
+
+void g()
+{
+    Lock lk(m);
+    g_ready = true;
+    cv->notify_one();
+    while (!f_ready)
+        cv->wait(lk);
+}
+
+int main()
+{
+    cv = new std::condition_variable;
+    std::thread th2(g);
+    Lock lk(m);
+    while (!g_ready)
+        cv->wait(lk);
+    lk.unlock();
+    std::thread th1(f);
+    th1.join();
+    th2.join();
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
new file mode 100644
index 0000000..52b73c0
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// typedef pthread_cond_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    static_assert((std::is_same<std::condition_variable::native_handle_type,
+                                pthread_cond_t*>::value), "");
+    std::condition_variable cv;
+    std::condition_variable::native_handle_type h = cv.native_handle();
+    assert(h != nullptr);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp
new file mode 100644
index 0000000..0b50e26
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/notify_all.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void notify_all();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_all();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        std::unique_lock<std::mutex>lk(mut);
+    }
+    t1.join();
+    t2.join();
+    assert(test1 == 2);
+    assert(test2 == 2);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
new file mode 100644
index 0000000..c112585
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void notify_one();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        std::unique_lock<std::mutex>lk(mut);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        std::unique_lock<std::mutex>lk(mut);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/wait.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/wait.pass.cpp
new file mode 100644
index 0000000..c4afc53
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/wait.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// void wait(unique_lock<mutex>& lock);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 != 0);
+}
+
+int main()
+{
+    std::unique_lock<std::mutex>lk(mut);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
new file mode 100644
index 0000000..038c946
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/wait_for.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Rep, class Period>
+//     cv_status
+//     wait_for(unique_lock<mutex>& lock,
+//              const chrono::duration<Rep, Period>& rel_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    while (test2 == 0 &&
+           cv.wait_for(lk, milliseconds(250)) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp
new file mode 100644
index 0000000..ef7a9b6
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/wait_for_pred.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Rep, class Period, class Predicate>
+//     bool
+//     wait_for(unique_lock<mutex>& lock,
+//              const chrono::duration<Rep, Period>& rel_time,
+//              Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp
new file mode 100644
index 0000000..22b82d2
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/wait_pred.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Predicate>
+//   void wait(unique_lock<mutex>& lock, Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <functional>
+#include <cassert>
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    cv.wait(lk, Pred(test2));
+    assert(test2 != 0);
+}
+
+int main()
+{
+    std::unique_lock<std::mutex>lk(mut);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp
new file mode 100644
index 0000000..476cec5
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/wait_until.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Clock, class Duration>
+//   cv_status
+//   wait_until(unique_lock<mutex>& lock,
+//              const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_steady =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                steady_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    while (test2 == 0 && cv.wait_until(lk, t) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp
new file mode 100644
index 0000000..b7a4b3a
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvar/wait_until_pred.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable;
+
+// template <class Clock, class Duration, class Predicate>
+//     bool
+//     wait_until(unique_lock<mutex>& lock,
+//                const chrono::time_point<Clock, Duration>& abs_time,
+//                Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_steady =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                steady_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable cv;
+std::mutex mut;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(mut);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    bool r = cv.wait_until(lk, t, Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+        assert(r);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+        assert(test2 == 0);
+        assert(!r);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        std::unique_lock<std::mutex>lk(mut);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp
new file mode 100644
index 0000000..0b8d8e9
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/assign.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any& operator=(const condition_variable_any&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable_any cv0;
+    std::condition_variable_any cv1;
+    cv1 = cv0;
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp
new file mode 100644
index 0000000..8490254
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/copy.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any(const condition_variable_any&) = delete;
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable_any cv0;
+    std::condition_variable_any cv1(cv0);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/default.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
new file mode 100644
index 0000000..853fc1a
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/default.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// condition_variable_any();
+
+#include <condition_variable>
+#include <cassert>
+
+int main()
+{
+    std::condition_variable_any cv;
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp
new file mode 100644
index 0000000..a14c568
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/destructor.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// ~condition_variable_any();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any* cv;
+std::mutex m;
+
+bool f_ready = false;
+bool g_ready = false;
+
+void f()
+{
+    m.lock();
+    f_ready = true;
+    cv->notify_one();
+    delete cv;
+    m.unlock();
+}
+
+void g()
+{
+    m.lock();
+    g_ready = true;
+    cv->notify_one();
+    while (!f_ready)
+        cv->wait(m);
+    m.unlock();
+}
+
+int main()
+{
+    cv = new std::condition_variable_any;
+    std::thread th2(g);
+    m.lock();
+    while (!g_ready)
+        cv->wait(m);
+    m.unlock();
+    std::thread th1(f);
+    th1.join();
+    th2.join();
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp
new file mode 100644
index 0000000..389d4bc
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/notify_all.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// void notify_all();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    L1 lk(m0);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        L1 lk(m0);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_all();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        L1 lk(m0);
+    }
+    t1.join();
+    t2.join();
+    assert(test1 == 2);
+    assert(test2 == 2);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp
new file mode 100644
index 0000000..8ad0ca3
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/notify_one.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// void notify_one();
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test0 = 0;
+int test1 = 0;
+int test2 = 0;
+
+void f1()
+{
+    L1 lk(m0);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 == 1);
+    test1 = 2;
+}
+
+void f2()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 == 1);
+    test2 = 2;
+}
+
+int main()
+{
+    std::thread t1(f1);
+    std::thread t2(f2);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    {
+        L1 lk(m0);
+        test1 = 1;
+        test2 = 1;
+    }
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        L1 lk(m0);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+    cv.notify_one();
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(100));
+        L1 lk(m0);
+    }
+    if (test1 == 2)
+    {
+        t1.join();
+        test1 = 0;
+    }
+    else if (test2 == 2)
+    {
+        t2.join();
+        test2 = 0;
+    }
+    else
+        assert(false);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
new file mode 100644
index 0000000..dd4879d
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp
@@ -0,0 +1,52 @@
+#include <thread>
+#include <condition_variable>
+#include <mutex>
+#include <chrono>
+#include <iostream>
+#include <cassert>
+
+void f1()
+{
+    std::exit(0);
+}
+
+struct Mutex
+{
+    unsigned state = 0;
+    Mutex() = default;
+    ~Mutex() = default;
+    Mutex(const Mutex&) = delete;
+    Mutex& operator=(const Mutex&) = delete;
+
+    void lock()
+    {
+    if (++state == 2)
+        throw 1;  // this throw should end up calling terminate()
+    }
+
+    void unlock() {}
+};
+
+Mutex mut;
+std::condition_variable_any cv;
+
+void
+signal_me()
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    cv.notify_one();
+}
+
+int
+main()
+{
+    std::set_terminate(f1);
+    try
+    {
+        std::thread(signal_me).detach();
+        mut.lock();
+        cv.wait(mut);
+    }
+    catch (...) {}
+    assert(false);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp
new file mode 100644
index 0000000..b611167
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock>
+//   void wait(Lock& lock);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    while (test2 == 0)
+        cv.wait(lk);
+    assert(test2 != 0);
+}
+
+int main()
+{
+    L1 lk(m0);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp
new file mode 100644
index 0000000..7eb4b33
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp
@@ -0,0 +1,52 @@
+#include <thread>
+#include <condition_variable>
+#include <mutex>
+#include <chrono>
+#include <iostream>
+#include <cassert>
+
+void f1()
+{
+    std::exit(0);
+}
+
+struct Mutex
+{
+    unsigned state = 0;
+    Mutex() = default;
+    ~Mutex() = default;
+    Mutex(const Mutex&) = delete;
+    Mutex& operator=(const Mutex&) = delete;
+
+    void lock()
+    {
+    if (++state == 2)
+        throw 1;  // this throw should end up calling terminate()
+    }
+
+    void unlock() {}
+};
+
+Mutex mut;
+std::condition_variable_any cv;
+
+void
+signal_me()
+{
+    std::this_thread::sleep_for(std::chrono::milliseconds(500));
+    cv.notify_one();
+}
+
+int
+main()
+{
+    std::set_terminate(f1);
+    try
+    {
+        std::thread(signal_me).detach();
+        mut.lock();
+        cv.wait_for(mut, std::chrono::milliseconds(250));
+    }
+    catch (...) {}
+    assert(false);
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
new file mode 100644
index 0000000..89759ac
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Rep, class Period>
+//   cv_status
+//   wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    while (test2 == 0 &&
+           cv.wait_for(lk, milliseconds(250)) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp
new file mode 100644
index 0000000..bc4b7c3
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait_for_pred.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Rep, class Period, class Predicate>
+//   bool
+//   wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time,
+//            Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds milliseconds;
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    bool r = cv.wait_for(lk, milliseconds(250), Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < milliseconds(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - milliseconds(250) < milliseconds(50));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp
new file mode 100644
index 0000000..9b4fab3
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait_pred.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Predicate>
+//   void wait(Lock& lock, Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <functional>
+#include <cassert>
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    cv.wait(lk, Pred(test2));
+    assert(test2 != 0);
+}
+
+int main()
+{
+    L1 lk(m0);
+    std::thread t(f);
+    assert(test1 == 0);
+    while (test1 == 0)
+        cv.wait(lk);
+    assert(test1 != 0);
+    test2 = 1;
+    lk.unlock();
+    cv.notify_one();
+    t.join();
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp
new file mode 100644
index 0000000..15bf809
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait_until.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Clock, class Duration>
+//   cv_status
+//   wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_steady =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                steady_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    while (test2 == 0 && cv.wait_until(lk, t) == std::cv_status::no_timeout)
+        ;
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+        assert(test2 == 0);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp b/final/test/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp
new file mode 100644
index 0000000..1490e11
--- /dev/null
+++ b/final/test/thread/thread.condition/thread.condition.condvarany/wait_until_pred.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+// class condition_variable_any;
+
+// template <class Lock, class Duration, class Predicate>
+//     bool
+//     wait_until(Lock& lock,
+//                const chrono::time_point<Clock, Duration>& abs_time,
+//                Predicate pred);
+
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+#include <chrono>
+#include <cassert>
+
+struct Clock
+{
+    typedef std::chrono::milliseconds duration;
+    typedef duration::rep             rep;
+    typedef duration::period          period;
+    typedef std::chrono::time_point<Clock> time_point;
+    static const bool is_steady =  true;
+
+    static time_point now()
+    {
+        using namespace std::chrono;
+        return time_point(duration_cast<duration>(
+                steady_clock::now().time_since_epoch()
+                                                 ));
+    }
+};
+
+class Pred
+{
+    int& i_;
+public:
+    explicit Pred(int& i) : i_(i) {}
+
+    bool operator()() {return i_ != 0;}
+};
+
+std::condition_variable_any cv;
+
+typedef std::timed_mutex L0;
+typedef std::unique_lock<L0> L1;
+
+L0 m0;
+
+int test1 = 0;
+int test2 = 0;
+
+int runs = 0;
+
+void f()
+{
+    L1 lk(m0);
+    assert(test2 == 0);
+    test1 = 1;
+    cv.notify_one();
+    Clock::time_point t0 = Clock::now();
+    Clock::time_point t = t0 + Clock::duration(250);
+    bool r = cv.wait_until(lk, t, Pred(test2));
+    Clock::time_point t1 = Clock::now();
+    if (runs == 0)
+    {
+        assert(t1 - t0 < Clock::duration(250));
+        assert(test2 != 0);
+        assert(r);
+    }
+    else
+    {
+        assert(t1 - t0 - Clock::duration(250) < Clock::duration(50));
+        assert(test2 == 0);
+        assert(!r);
+    }
+    ++runs;
+}
+
+int main()
+{
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        test2 = 1;
+        lk.unlock();
+        cv.notify_one();
+        t.join();
+    }
+    test1 = 0;
+    test2 = 0;
+    {
+        L1 lk(m0);
+        std::thread t(f);
+        assert(test1 == 0);
+        while (test1 == 0)
+            cv.wait(lk);
+        assert(test1 != 0);
+        lk.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.condition/version.pass.cpp b/final/test/thread/thread.condition/version.pass.cpp
new file mode 100644
index 0000000..517c93b
--- /dev/null
+++ b/final/test/thread/thread.condition/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <condition_variable>
+
+#include <condition_variable>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.general/nothing_to_do.pass.cpp b/final/test/thread/thread.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
new file mode 100644
index 0000000..14c79a1
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
@@ -0,0 +1,505 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class L1, class L2, class... L3>
+//   void lock(L1&, L2&, L3&...);
+
+#include <mutex>
+#include <cassert>
+
+class L0
+{
+    bool locked_;
+
+public:
+    L0() : locked_(false) {}
+
+    void lock()
+    {
+        locked_ = true;
+    }
+
+    bool try_lock()
+    {
+        locked_ = true;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L1
+{
+    bool locked_;
+
+public:
+    L1() : locked_(false) {}
+
+    void lock()
+    {
+        locked_ = true;
+    }
+
+    bool try_lock()
+    {
+        locked_ = false;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L2
+{
+    bool locked_;
+
+public:
+    L2() : locked_(false) {}
+
+    void lock()
+    {
+        throw 1;
+    }
+
+    bool try_lock()
+    {
+        throw 1;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+int main()
+{
+    {
+        L0 l0;
+        L0 l1;
+        std::lock(l0, l1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        std::lock(l0, l1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        std::lock(l0, l1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L1 l0;
+        L2 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        try
+        {
+            std::lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        std::lock(l0, l1, l2);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L0 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L1 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        std::lock(l0, l1, l2, l3);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L2 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L2 l2;
+        L0 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L0 l2;
+        L0 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        try
+        {
+            std::lock(l0, l1, l2, l3);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+            assert(!l3.locked());
+        }
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/final/test/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
new file mode 100644
index 0000000..bdb76c6
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
@@ -0,0 +1,514 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class L1, class L2, class... L3>
+//   int try_lock(L1&, L2&, L3&...);
+
+#include <mutex>
+#include <cassert>
+
+class L0
+{
+    bool locked_;
+
+public:
+    L0() : locked_(false) {}
+
+    bool try_lock()
+    {
+        locked_ = true;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L1
+{
+    bool locked_;
+
+public:
+    L1() : locked_(false) {}
+
+    bool try_lock()
+    {
+        locked_ = false;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+class L2
+{
+    bool locked_;
+
+public:
+    L2() : locked_(false) {}
+
+    bool try_lock()
+    {
+        throw 1;
+        return locked_;
+    }
+
+    void unlock() {locked_ = false;}
+
+    bool locked() const {return locked_;}
+};
+
+int main()
+{
+    {
+        L0 l0;
+        L0 l1;
+        assert(std::try_lock(l0, l1) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        assert(std::try_lock(l0, l1) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        assert(std::try_lock(l0, l1) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        try
+        {
+            std::try_lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        try
+        {
+            std::try_lock(l0, l1);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 2);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L1 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L1 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L2 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L0 l0;
+        L2 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L2 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L1 l0;
+        L2 l1;
+        L0 l2;
+        assert(std::try_lock(l0, l1, l2) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+    }
+    {
+        L2 l0;
+        L0 l1;
+        L1 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L2 l0;
+        L1 l1;
+        L0 l2;
+        try
+        {
+            std::try_lock(l0, l1, l2);
+            assert(false);
+        }
+        catch (int)
+        {
+            assert(!l0.locked());
+            assert(!l1.locked());
+            assert(!l2.locked());
+        }
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == -1);
+        assert(l0.locked());
+        assert(l1.locked());
+        assert(l2.locked());
+        assert(l3.locked());
+    }
+    {
+        L1 l0;
+        L0 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 0);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L1 l1;
+        L0 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 1);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L1 l2;
+        L0 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 2);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+    {
+        L0 l0;
+        L0 l1;
+        L0 l2;
+        L1 l3;
+        assert(std::try_lock(l0, l1, l2, l3) == 3);
+        assert(!l0.locked());
+        assert(!l1.locked());
+        assert(!l2.locked());
+        assert(!l3.locked());
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
new file mode 100644
index 0000000..6f68884
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    m.lock();
+    std::lock_guard<std::mutex> lg(m, std::adopt_lock);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp
new file mode 100644
index 0000000..53abb42
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/assign.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard& operator=(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1;
+    std::lock_guard<std::mutex> lg0(m0);
+    std::lock_guard<std::mutex> lg(m1);
+    lg = lg0;
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp
new file mode 100644
index 0000000..296ccda
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/copy.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// lock_guard(lock_guard const&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m;
+    std::lock_guard<std::mutex> lg0(m);
+    std::lock_guard<std::mutex> lg(lg0);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp
new file mode 100644
index 0000000..246eb93
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.fail.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::lock_guard<std::mutex> lg = m;
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(2500000));  // within 2.5ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
new file mode 100644
index 0000000..d47222d
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class lock_guard;
+
+// explicit lock_guard(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::lock_guard<std::mutex> lg(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp
new file mode 100644
index 0000000..20aa62e
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.guard/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex>
+// class lock_guard
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::lock_guard<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp
new file mode 100644
index 0000000..446807f
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_assign.fail.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock& operator=(shared_lock const&) = delete;
+
+#include <shared_mutex>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m0;
+std::shared_timed_mutex m1;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m0);
+    std::shared_lock<std::shared_timed_mutex> lk1(m1);
+    lk1 = lk0;
+#else
+#   error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp
new file mode 100644
index 0000000..370c1fa
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/copy_ctor.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(shared_lock const&) = delete;
+
+#include <shared_mutex>
+
+#if _LIBCPP_STD_VER > 11
+std::shared_timed_mutex m;
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m);
+    std::shared_lock<std::shared_timed_mutex> lk = lk0;
+#else
+#   error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp
new file mode 100644
index 0000000..2713680
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock();
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> ul;
+    assert(!ul.owns_lock());
+    assert(ul.mutex() == nullptr);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..73936b7
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock& operator=(shared_lock&& u);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m0;
+std::shared_timed_mutex m1;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m0);
+    std::shared_lock<std::shared_timed_mutex> lk1(m1);
+    lk1 = std::move(lk0);
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp
new file mode 100644
index 0000000..cf63861
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(shared_lock&& u);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+std::shared_timed_mutex m;
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0(m);
+    std::shared_lock<std::shared_timed_mutex> lk = std::move(lk0);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
new file mode 100644
index 0000000..01bfbfd
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// explicit shared_lock(mutex_type& m);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::shared_lock<std::shared_timed_mutex> ul(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void g()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::shared_lock<std::shared_timed_mutex> ul(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0;
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+    m.lock_shared();
+    for (auto& t : v)
+        t = std::thread(g);
+    std::thread q(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock_shared();
+    for (auto& t : v)
+        t.join();
+    q.join();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp
new file mode 100644
index 0000000..b4f6025
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, adopt_lock_t);
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m;
+    m.lock();
+    std::shared_lock<std::shared_timed_mutex> lk(m, std::adopt_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp
new file mode 100644
index 0000000..3a8b61a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, defer_lock_t);
+
+#include <shared_mutex>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m;
+    std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == false);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp
new file mode 100644
index 0000000..ffe329c
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//   shared_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp
new file mode 100644
index 0000000..baf08de
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+//   shared_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::shared_lock<std::shared_timed_mutex> lk(m, Clock::now() + ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
new file mode 100644
index 0000000..9d06d3f
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// shared_lock(mutex_type& m, try_to_lock_t);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    while (true)
+    {
+        std::shared_lock<std::shared_timed_mutex> lk(m, std::try_to_lock);
+        if (lk.owns_lock())
+            break;
+    }
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp
new file mode 100644
index 0000000..ecac479
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    std::shared_lock<std::shared_timed_mutex> lk(m, std::defer_lock);
+    time_point t0 = Clock::now();
+    lk.lock();
+    time_point t1 = Clock::now();
+    assert(lk.owns_lock() == true);
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(25));  // within 25ms
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    lk.release();
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
new file mode 100644
index 0000000..d65fbfa
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// bool try_lock();
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_called = false;
+
+struct mutex
+{
+    bool try_lock_shared()
+    {
+        try_lock_called = !try_lock_called;
+        return try_lock_called;
+    }
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock() == true);
+    assert(try_lock_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock() == false);
+    assert(try_lock_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
new file mode 100644
index 0000000..d076e52
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Rep, class Period>
+//   bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_for_called = false;
+
+typedef std::chrono::milliseconds ms;
+
+struct mutex
+{
+    template <class Rep, class Period>
+        bool try_lock_shared_for(const std::chrono::duration<Rep, Period>& rel_time)
+    {
+        assert(rel_time == ms(5));
+        try_lock_for_called = !try_lock_for_called;
+        return try_lock_for_called;
+    }
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_for(ms(5)) == true);
+    assert(try_lock_for_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_for(ms(5)) == false);
+    assert(try_lock_for_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
new file mode 100644
index 0000000..8efffc4
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Clock, class Duration>
+//   bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+    template <class Clock, class Duration>
+        bool try_lock_shared_until(const std::chrono::time_point<Clock, Duration>& abs_time)
+    {
+        typedef std::chrono::milliseconds ms;
+        assert(Clock::now() - abs_time < ms(5));
+        try_lock_until_called = !try_lock_until_called;
+        return try_lock_until_called;
+    }
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::chrono::steady_clock Clock;
+    std::shared_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_until(Clock::now()) == true);
+    assert(try_lock_until_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_until(Clock::now()) == false);
+    assert(try_lock_until_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp
new file mode 100644
index 0000000..9e4b3c8
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void unlock();
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+bool unlock_called = false;
+
+struct mutex
+{
+    void lock_shared() {}
+    void unlock_shared() {unlock_called = true;}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m);
+    lk.unlock();
+    assert(unlock_called == true);
+    assert(lk.owns_lock() == false);
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+    lk.release();
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp
new file mode 100644
index 0000000..6a7a39e
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// void swap(shared_lock& u) noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+    void lock_shared() {}
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk1(m);
+    std::shared_lock<mutex> lk2;
+    lk1.swap(lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+    static_assert(noexcept(lk1.swap(lk2)), "member swap must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..03bf5e8
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// template <class Mutex>
+//   void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+    void lock_shared() {}
+    void unlock_shared() {}
+};
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk1(m);
+    std::shared_lock<mutex> lk2;
+    swap(lk1, lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+    static_assert(noexcept(swap(lk1, lk2)), "non-member swap must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp
new file mode 100644
index 0000000..a836b35
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// mutex_type* release() noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+struct mutex
+{
+    static int lock_count;
+    static int unlock_count;
+    void lock_shared() {++lock_count;}
+    void unlock_shared() {++unlock_count;}
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<mutex> lk(m);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+    assert(lk.release() == &m);
+    assert(lk.mutex() == nullptr);
+    assert(lk.owns_lock() == false);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+    static_assert(noexcept(lk.release()), "release must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp
new file mode 100644
index 0000000..4b4f6c6
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// mutex_type *mutex() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0;
+    assert(lk0.mutex() == nullptr);
+    std::shared_lock<std::shared_timed_mutex> lk1(m);
+    assert(lk1.mutex() == &m);
+    lk1.unlock();
+    assert(lk1.mutex() == &m);
+    static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp
new file mode 100644
index 0000000..177a69e
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// explicit operator bool() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0;
+    assert(static_cast<bool>(lk0) == false);
+    std::shared_lock<std::shared_timed_mutex> lk1(m);
+    assert(static_cast<bool>(lk1) == true);
+    lk1.unlock();
+    assert(static_cast<bool>(lk1) == false);
+    static_assert(noexcept(static_cast<bool>(lk0)), "explicit operator bool() must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp
new file mode 100644
index 0000000..a10c588
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex> class shared_lock;
+
+// bool owns_lock() const noexcept;
+
+#include <shared_mutex>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_lock<std::shared_timed_mutex> lk0;
+    assert(lk0.owns_lock() == false);
+    std::shared_lock<std::shared_timed_mutex> lk1(m);
+    assert(lk1.owns_lock() == true);
+    lk1.unlock();
+    assert(lk1.owns_lock() == false);
+    static_assert(noexcept(lk0.owns_lock()), "owns_lock must be noexcept");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp
new file mode 100644
index 0000000..3537357
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// template <class Mutex>
+// class shared_lock
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <shared_mutex>
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::shared_lock<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp
new file mode 100644
index 0000000..4f47744
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_assign.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0(m0);
+    std::unique_lock<std::mutex> lk1(m1);
+    lk1 = lk0;
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp
new file mode 100644
index 0000000..4888fe9
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/copy_ctor.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock const&) = delete;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0(m);
+    std::unique_lock<std::mutex> lk = lk0;
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp
new file mode 100644
index 0000000..55038c7
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::unique_lock<std::mutex> ul;
+    assert(!ul.owns_lock());
+    assert(ul.mutex() == nullptr);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp
new file mode 100644
index 0000000..2eb1c3a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_assign.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock& operator=(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m0;
+std::mutex m1;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::unique_lock<std::mutex> lk0(m0);
+    std::unique_lock<std::mutex> lk1(m1);
+    lk1 = std::move(lk0);
+    assert(lk1.mutex() == &m0);
+    assert(lk1.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp
new file mode 100644
index 0000000..f36600c
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/move_ctor.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(unique_lock&& u);
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::unique_lock<std::mutex> lk0(m);
+    std::unique_lock<std::mutex> lk = std::move(lk0);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(lk0.mutex() == nullptr);
+    assert(lk0.owns_lock() == false);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
new file mode 100644
index 0000000..4b08aca
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit unique_lock(mutex_type& m);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    time_point t1;
+    {
+    std::unique_lock<std::mutex> ul(m);
+    t1 = Clock::now();
+    }
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp
new file mode 100644
index 0000000..ff8043b
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_adopt_lock.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, adopt_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::mutex m;
+    m.lock();
+    std::unique_lock<std::mutex> lk(m, std::adopt_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp
new file mode 100644
index 0000000..f475ec1
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_defer_lock.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, defer_lock_t);
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::mutex m;
+    std::unique_lock<std::mutex> lk(m, std::defer_lock);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == false);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp
new file mode 100644
index 0000000..8370c56
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_duration.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//   unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp
new file mode 100644
index 0000000..8faf88f
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_time_point.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+//   unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(300));
+    assert(lk.owns_lock() == true);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    std::unique_lock<std::timed_mutex> lk(m, Clock::now() + ms(250));
+    assert(lk.owns_lock() == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
new file mode 100644
index 0000000..b6c64f5
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.cons/mutex_try_to_lock.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// unique_lock(mutex_type& m, try_to_lock_t);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        assert(lk.owns_lock() == false);
+    }
+    while (true)
+    {
+        std::unique_lock<std::mutex> lk(m, std::try_to_lock);
+        if (lk.owns_lock())
+            break;
+    }
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
new file mode 100644
index 0000000..c101d89
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    std::unique_lock<std::mutex> lk(m, std::defer_lock);
+    time_point t0 = Clock::now();
+    lk.lock();
+    time_point t1 = Clock::now();
+    assert(lk.owns_lock() == true);
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(25));  // within 25ms
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    lk.release();
+    try
+    {
+        lk.lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
new file mode 100644
index 0000000..40d9489
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool try_lock();
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_called = false;
+
+struct mutex
+{
+    bool try_lock()
+    {
+        try_lock_called = !try_lock_called;
+        return try_lock_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock() == true);
+    assert(try_lock_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock() == false);
+    assert(try_lock_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
new file mode 100644
index 0000000..3e7d13a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Rep, class Period>
+//   bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_for_called = false;
+
+typedef std::chrono::milliseconds ms;
+
+struct mutex
+{
+    template <class Rep, class Period>
+        bool try_lock_for(const std::chrono::duration<Rep, Period>& rel_time)
+    {
+        assert(rel_time == ms(5));
+        try_lock_for_called = !try_lock_for_called;
+        return try_lock_for_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_for(ms(5)) == true);
+    assert(try_lock_for_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_for(ms(5)) == false);
+    assert(try_lock_for_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_for(ms(5));
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
new file mode 100644
index 0000000..2b435e0
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Clock, class Duration>
+//   bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <cassert>
+
+bool try_lock_until_called = false;
+
+struct mutex
+{
+    template <class Clock, class Duration>
+        bool try_lock_until(const std::chrono::time_point<Clock, Duration>& abs_time)
+    {
+        typedef std::chrono::milliseconds ms;
+        assert(Clock::now() - abs_time < ms(5));
+        try_lock_until_called = !try_lock_until_called;
+        return try_lock_until_called;
+    }
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    typedef std::chrono::steady_clock Clock;
+    std::unique_lock<mutex> lk(m, std::defer_lock);
+    assert(lk.try_lock_until(Clock::now()) == true);
+    assert(try_lock_until_called == true);
+    assert(lk.owns_lock() == true);
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EDEADLK);
+    }
+    lk.unlock();
+    assert(lk.try_lock_until(Clock::now()) == false);
+    assert(try_lock_until_called == false);
+    assert(lk.owns_lock() == false);
+    lk.release();
+    try
+    {
+        lk.try_lock_until(Clock::now());
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
new file mode 100644
index 0000000..1318c86
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void unlock();
+
+#include <mutex>
+#include <cassert>
+
+bool unlock_called = false;
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {unlock_called = true;}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m);
+    lk.unlock();
+    assert(unlock_called == true);
+    assert(lk.owns_lock() == false);
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+    lk.release();
+    try
+    {
+        lk.unlock();
+        assert(false);
+    }
+    catch (std::system_error& e)
+    {
+        assert(e.code().value() == EPERM);
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp
new file mode 100644
index 0000000..fd3931a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/member_swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// void swap(unique_lock& u);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk1(m);
+    std::unique_lock<mutex> lk2;
+    lk1.swap(lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp
new file mode 100644
index 0000000..d74247e
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/nonmember_swap.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// template <class Mutex>
+//   void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y);
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    void lock() {}
+    void unlock() {}
+};
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk1(m);
+    std::unique_lock<mutex> lk2;
+    swap(lk1, lk2);
+    assert(lk1.mutex() == nullptr);
+    assert(lk1.owns_lock() == false);
+    assert(lk2.mutex() == &m);
+    assert(lk2.owns_lock() == true);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp
new file mode 100644
index 0000000..4252de1
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.mod/release.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// mutex_type* release() noexcept;
+
+#include <mutex>
+#include <cassert>
+
+struct mutex
+{
+    static int lock_count;
+    static int unlock_count;
+    void lock() {++lock_count;}
+    void unlock() {++unlock_count;}
+};
+
+int mutex::lock_count = 0;
+int mutex::unlock_count = 0;
+
+mutex m;
+
+int main()
+{
+    std::unique_lock<mutex> lk(m);
+    assert(lk.mutex() == &m);
+    assert(lk.owns_lock() == true);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+    assert(lk.release() == &m);
+    assert(lk.mutex() == nullptr);
+    assert(lk.owns_lock() == false);
+    assert(mutex::lock_count == 1);
+    assert(mutex::unlock_count == 0);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp
new file mode 100644
index 0000000..78b0c6a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/mutex.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// mutex_type *mutex() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(lk0.mutex() == nullptr);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(lk1.mutex() == &m);
+    lk1.unlock();
+    assert(lk1.mutex() == &m);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp
new file mode 100644
index 0000000..0d2e362
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/op_bool.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// explicit operator bool() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(static_cast<bool>(lk0) == false);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(static_cast<bool>(lk1) == true);
+    lk1.unlock();
+    assert(static_cast<bool>(lk1) == false);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp
new file mode 100644
index 0000000..2e2db5d
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.obs/owns_lock.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex> class unique_lock;
+
+// bool owns_lock() const;
+
+#include <mutex>
+#include <cassert>
+
+std::mutex m;
+
+int main()
+{
+    std::unique_lock<std::mutex> lk0;
+    assert(lk0.owns_lock() == false);
+    std::unique_lock<std::mutex> lk1(m);
+    assert(lk1.owns_lock() == true);
+    lk1.unlock();
+    assert(lk1.owns_lock() == false);
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp
new file mode 100644
index 0000000..aba22a7
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/thread.lock.unique/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// template <class Mutex>
+// class unique_lock
+// {
+// public:
+//     typedef Mutex mutex_type;
+//     ...
+// };
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::unique_lock<std::mutex>::mutex_type,
+                   std::mutex>::value), "");
+}
diff --git a/final/test/thread/thread.mutex/thread.lock/types.pass.cpp b/final/test/thread/thread.mutex/thread.lock/types.pass.cpp
new file mode 100644
index 0000000..8a34bcb
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.lock/types.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct defer_lock_t {};
+// struct try_to_lock_t {};
+// struct adopt_lock_t {};
+//
+// constexpr defer_lock_t  defer_lock{};
+// constexpr try_to_lock_t try_to_lock{};
+// constexpr adopt_lock_t  adopt_lock{};
+
+#include <mutex>
+#include <type_traits>
+
+int main()
+{
+    typedef std::defer_lock_t T1;
+    typedef std::try_to_lock_t T2;
+    typedef std::adopt_lock_t T3;
+
+    T1 t1 = std::defer_lock;
+    T2 t2 = std::try_to_lock;
+    T3 t3 = std::adopt_lock;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp
new file mode 100644
index 0000000..7f6333a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/assign.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex& operator=(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1;
+    m1 = m0;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp
new file mode 100644
index 0000000..7e1a07a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex(const mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m0;
+    std::mutex m1(m0);
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
new file mode 100644
index 0000000..704d716
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::mutex m;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp
new file mode 100644
index 0000000..8fde818
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/lock.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
new file mode 100644
index 0000000..59c762a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::mutex m;
+    pthread_mutex_t* h = m.native_handle();
+    assert(h);
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp
new file mode 100644
index 0000000..6ef0160
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/try_lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp
new file mode 100644
index 0000000..61b5621
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/assign.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m0;
+    std::recursive_mutex m1;
+    m1 = m0;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp
new file mode 100644
index 0000000..0239c04
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex(const recursive_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m0;
+    std::recursive_mutex m1(m0);
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp
new file mode 100644
index 0000000..bc775ed
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// recursive_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_mutex m;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp
new file mode 100644
index 0000000..cd48151
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.lock();
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
new file mode 100644
index 0000000..fb95294
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// typedef pthread_mutex_t* native_handle_type;
+// native_handle_type native_handle();
+
+#include <mutex>
+#include <cassert>
+
+int main()
+{
+    std::recursive_mutex m;
+    pthread_mutex_t* h = m.native_handle();
+    assert(h);
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp
new file mode 100644
index 0000000..f63e0ef
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/try_lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp
new file mode 100644
index 0000000..528aaca
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/assign.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m0;
+    std::shared_timed_mutex m1;
+    m1 = m0;
+#else
+#   error
+#endif
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp
new file mode 100644
index 0000000..dbf0100
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/copy.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex(const shared_timed_mutex&) = delete;
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m0;
+    std::shared_timed_mutex m1(m0);
+#else
+#   error
+#endif
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
new file mode 100644
index 0000000..f45382d
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/default.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// shared_timed_mutex();
+
+#include <shared_mutex>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    std::shared_timed_mutex m;
+#endif
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp
new file mode 100644
index 0000000..153ce62
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// void lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp
new file mode 100644
index 0000000..724a7b0
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// void lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock_shared();
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void g()
+{
+    time_point t0 = Clock::now();
+    m.lock_shared();
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0;
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+    m.lock_shared();
+    for (auto& t : v)
+        t = std::thread(g);
+    std::thread q(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock_shared();
+    for (auto& t : v)
+        t.join();
+    q.join();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp
new file mode 100644
index 0000000..aa6f5fb
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// bool try_lock();
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp
new file mode 100644
index 0000000..e97b313
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp
new file mode 100644
index 0000000..a34633e
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// bool try_lock_shared();
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock_shared());
+    assert(!m.try_lock_shared());
+    assert(!m.try_lock_shared());
+    while(!m.try_lock_shared())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    m.lock();
+    std::vector<std::thread> v;
+    for (int i = 0; i < 5; ++i)
+        v.push_back(std::thread(f));
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    for (auto& t : v)
+        t.join();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp
new file mode 100644
index 0000000..528c69a
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp
new file mode 100644
index 0000000..a6238e3
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock_shared();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_shared_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f1));
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+    {
+        m.lock();
+        std::vector<std::thread> v;
+        for (int i = 0; i < 5; ++i)
+            v.push_back(std::thread(f2));
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        for (auto& t : v)
+            t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp
new file mode 100644
index 0000000..8670fbf
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <shared_mutex>
+
+// class shared_timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <shared_mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+std::shared_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
new file mode 100644
index 0000000..5800683
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/assign.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex& operator=(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m0;
+    std::timed_mutex m1;
+    m1 = m0;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
new file mode 100644
index 0000000..61ba31d
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex(const timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m0;
+    std::timed_mutex m1(m0);
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
new file mode 100644
index 0000000..5956540
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::timed_mutex m;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
new file mode 100644
index 0000000..a4b41ac
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/lock.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
new file mode 100644
index 0000000..d5a06bf
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
new file mode 100644
index 0000000..5e4d5f1
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_for.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
new file mode 100644
index 0000000..f19dec2
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.class/try_lock_until.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
new file mode 100644
index 0000000..ae84be8
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/assign.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m0;
+    std::recursive_timed_mutex m1;
+    m1 = m0;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
new file mode 100644
index 0000000..487d6a8
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m0;
+    std::recursive_timed_mutex m1(m0);
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
new file mode 100644
index 0000000..a4c5110
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/default.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// recursive_timed_mutex();
+
+#include <mutex>
+
+int main()
+{
+    std::recursive_timed_mutex m;
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
new file mode 100644
index 0000000..32bedb3
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/lock.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// void lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+#include <iostream>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    m.lock();
+    time_point t1 = Clock::now();
+    m.lock();
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
new file mode 100644
index 0000000..d56e8bc
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// bool try_lock();
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::system_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f()
+{
+    time_point t0 = Clock::now();
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    assert(!m.try_lock());
+    while(!m.try_lock())
+        ;
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(200));  // within 200ms
+}
+
+int main()
+{
+    m.lock();
+    std::thread t(f);
+    std::this_thread::sleep_for(ms(250));
+    m.unlock();
+    t.join();
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
new file mode 100644
index 0000000..972fc63
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_for.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Rep, class Period>
+//     bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(300)) == true);
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_for(ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ns(50000000));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
new file mode 100644
index 0000000..e5e9166
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.mutex.requirements/thread.timedmutex.requirements/thread.timedmutex.recursive/try_lock_until.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// class recursive_timed_mutex;
+
+// template <class Clock, class Duration>
+//     bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <mutex>
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+std::recursive_timed_mutex m;
+
+typedef std::chrono::steady_clock Clock;
+typedef Clock::time_point time_point;
+typedef Clock::duration duration;
+typedef std::chrono::milliseconds ms;
+typedef std::chrono::nanoseconds ns;
+
+void f1()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(300)) == true);
+    time_point t1 = Clock::now();
+    assert(m.try_lock());
+    m.unlock();
+    m.unlock();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+void f2()
+{
+    time_point t0 = Clock::now();
+    assert(m.try_lock_until(Clock::now() + ms(250)) == false);
+    time_point t1 = Clock::now();
+    ns d = t1 - t0 - ms(250);
+    assert(d < ms(50));  // within 50ms
+}
+
+int main()
+{
+    {
+        m.lock();
+        std::thread t(f1);
+        std::this_thread::sleep_for(ms(250));
+        m.unlock();
+        t.join();
+    }
+    {
+        m.lock();
+        std::thread t(f2);
+        std::this_thread::sleep_for(ms(300));
+        m.unlock();
+        t.join();
+    }
+}
diff --git a/final/test/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp b/final/test/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.once/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/final/test/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
new file mode 100644
index 0000000..b4f76b4
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// template<class Callable, class ...Args>
+//   void call_once(once_flag& flag, Callable func, Args&&... args);
+
+#include <mutex>
+#include <thread>
+#include <cassert>
+
+typedef std::chrono::milliseconds ms;
+
+std::once_flag flg0;
+
+int init0_called = 0;
+
+void init0()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init0_called;
+}
+
+void f0()
+{
+    std::call_once(flg0, init0);
+}
+
+std::once_flag flg3;
+
+int init3_called = 0;
+int init3_completed = 0;
+
+void init3()
+{
+    ++init3_called;
+    std::this_thread::sleep_for(ms(250));
+    if (init3_called == 1)
+        throw 1;
+    ++init3_completed;
+}
+
+void f3()
+{
+    try
+    {
+        std::call_once(flg3, init3);
+    }
+    catch (...)
+    {
+    }
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+struct init1
+{
+    static int called;
+
+    void operator()(int i) {called += i;}
+};
+
+int init1::called = 0;
+
+std::once_flag flg1;
+
+void f1()
+{
+    std::call_once(flg1, init1(), 1);
+}
+
+struct init2
+{
+    static int called;
+
+    void operator()(int i, int j) const {called += i + j;}
+};
+
+int init2::called = 0;
+
+std::once_flag flg2;
+
+void f2()
+{
+    std::call_once(flg2, init2(), 2, 3);
+    std::call_once(flg2, init2(), 4, 5);
+}
+
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+
+std::once_flag flg41;
+std::once_flag flg42;
+
+int init41_called = 0;
+int init42_called = 0;
+
+void init42();
+
+void init41()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init41_called;
+}
+
+void init42()
+{
+    std::this_thread::sleep_for(ms(250));
+    ++init42_called;
+}
+
+void f41()
+{
+    std::call_once(flg41, init41);
+    std::call_once(flg42, init42);
+}
+
+void f42()
+{
+    std::call_once(flg42, init42);
+    std::call_once(flg41, init41);
+}
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+public:
+    MoveOnly() {}
+    MoveOnly(MoveOnly&&) {}
+
+    void operator()(MoveOnly&&)
+    {
+    }
+};
+
+#endif
+
+int main()
+{
+    // check basic functionality
+    {
+        std::thread t0(f0);
+        std::thread t1(f0);
+        t0.join();
+        t1.join();
+        assert(init0_called == 1);
+    }
+    // check basic exception safety
+    {
+        std::thread t0(f3);
+        std::thread t1(f3);
+        t0.join();
+        t1.join();
+        assert(init3_called == 2);
+        assert(init3_completed == 1);
+    }
+    // check deadlock avoidance
+    {
+        std::thread t0(f41);
+        std::thread t1(f42);
+        t0.join();
+        t1.join();
+        assert(init41_called == 1);
+        assert(init42_called == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    // check functors with 1 arg
+    {
+        std::thread t0(f1);
+        std::thread t1(f1);
+        t0.join();
+        t1.join();
+        assert(init1::called == 1);
+    }
+    // check functors with 2 args
+    {
+        std::thread t0(f2);
+        std::thread t1(f2);
+        t0.join();
+        t1.join();
+        assert(init2::called == 5);
+    }
+    {
+        std::once_flag f;
+        std::call_once(f, MoveOnly(), MoveOnly());
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp b/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp
new file mode 100644
index 0000000..c471427
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/assign.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag& operator=(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::once_flag f;
+    std::once_flag f2;
+    f2 = f;
+}
diff --git a/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp b/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp
new file mode 100644
index 0000000..450ba83
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/copy.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// once_flag(const once_flag&) = delete;
+
+#include <mutex>
+
+int main()
+{
+    std::once_flag f;
+    std::once_flag f2(f);
+}
diff --git a/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp b/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
new file mode 100644
index 0000000..6995f06
--- /dev/null
+++ b/final/test/thread/thread.mutex/thread.once/thread.once.onceflag/default.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+// struct once_flag;
+
+// constexpr once_flag() noexcept;
+
+#include <mutex>
+
+int main()
+{
+    {
+    std::once_flag f;
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::once_flag f;
+    }
+#endif
+}
diff --git a/final/test/thread/thread.mutex/version.pass.cpp b/final/test/thread/thread.mutex/version.pass.cpp
new file mode 100644
index 0000000..81b52c7
--- /dev/null
+++ b/final/test/thread/thread.mutex/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <mutex>
+
+#include <mutex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/nothing_to_do.pass.cpp b/final/test/thread/thread.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.exception/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.lockable/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.basic/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.lockable/thread.req.lockable.timed/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.native/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.paramname/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp b/final/test/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/thread/thread.req/thread.req.timing/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp
new file mode 100644
index 0000000..9a7f8dc
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.algorithm/swap.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void swap(thread& x, thread& y);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        swap(t0, t1);
+        assert(t0.get_id() == id1);
+        assert(t1.get_id() == id0);
+        t1.join();
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp
new file mode 100644
index 0000000..7373886
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.assign/copy.fail.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0(G());
+        std::thread t1;
+        t1 = t0;
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
new file mode 100644
index 0000000..1a5f320
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.assign/move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread& operator=(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::set_terminate(f1);
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1;
+        t1 = std::move(t0);
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+    {
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1;
+        t0 = std::move(t1);
+        assert(false);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
new file mode 100644
index 0000000..e5568ba
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// template <class F, class ...Args> thread(F&& f, Args&&... args);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+unsigned throw_one = 0xFFFF;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_one == 0)
+        throw std::bad_alloc();
+    --throw_one;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+bool f_run = false;
+
+void f()
+{
+    f_run = true;
+}
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+public:
+    MoveOnly() {}
+    MoveOnly(MoveOnly&&) {}
+
+    void operator()(MoveOnly&&)
+    {
+    }
+};
+
+#endif
+
+int main()
+{
+    {
+        std::thread t(f);
+        t.join();
+        assert(f_run == true);
+    }
+    f_run = false;
+    {
+        try
+        {
+            throw_one = 0;
+            std::thread t(f);
+            assert(false);
+        }
+        catch (...)
+        {
+            throw_one = 0xFFFF;
+            assert(!f_run);
+        }
+    }
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t((G()));
+        t.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+    G::op_run = false;
+    {
+        try
+        {
+            throw_one = 0;
+            assert(G::n_alive == 0);
+            assert(!G::op_run);
+            std::thread t((G()));
+            assert(false);
+        }
+        catch (...)
+        {
+            throw_one = 0xFFFF;
+            assert(G::n_alive == 0);
+            assert(!G::op_run);
+        }
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t(G(), 5, 5.5);
+        t.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+    {
+        std::thread t = std::thread(MoveOnly(), MoveOnly());
+        t.join();
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp
new file mode 100644
index 0000000..a331add
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+//     template <class _Fp, class ..._Args,
+//         explicit thread(_Fp&& __f, _Args&&... __args);
+//  This constructor shall not participate in overload resolution 
+//       if decay<F>::type is the same type as std::thread.
+
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    volatile std::thread t1;
+    std::thread t2 ( t1, 1, 2.0 );
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp
new file mode 100644
index 0000000..f66474c
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/copy.fail.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread(const thread&) = delete;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1 = t0;
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp
new file mode 100644
index 0000000..cd9c2c4
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/default.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread t;
+    assert(t.get_id() == std::thread::id());
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp
new file mode 100644
index 0000000..17268ab
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.constr/move.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// thread(thread&& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+
+    void operator()(int i, double j)
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        assert(i == 5);
+        assert(j == 5.5);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t0(G(), 5, 5.5);
+        std::thread::id id = t0.get_id();
+        std::thread t1 = std::move(t0);
+        assert(t1.get_id() == id);
+        assert(t0.get_id() == std::thread::id());
+        t1.join();
+        assert(G::n_alive == 0);
+        assert(G::op_run);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
new file mode 100644
index 0000000..e068c04
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// ~thread();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+void f1()
+{
+    std::exit(0);
+}
+
+int main()
+{
+    std::set_terminate(f1);
+    {
+        assert(G::n_alive == 0);
+        assert(!G::op_run);
+        std::thread t((G()));
+        std::this_thread::sleep_for(std::chrono::milliseconds(250));
+    }
+    assert(false);
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp
new file mode 100644
index 0000000..b8727d0
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/assign.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// id& operator=(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    id1 = id0;
+    assert(id1 == id0);
+    id1 = std::this_thread::get_id();
+    assert(id1 != id0);
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp
new file mode 100644
index 0000000..6d17dfc
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/copy.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// id(const id&) = default;
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1 = id0;
+    assert(id1 == id0);
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp
new file mode 100644
index 0000000..b315473
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/default.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id;
+    assert(id == std::thread::id());
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
new file mode 100644
index 0000000..2ff273c
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/eq.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// bool operator==(thread::id x, thread::id y);
+// bool operator!=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    id1 = id0;
+    assert( (id1 == id0));
+    assert(!(id1 != id0));
+    id1 = std::this_thread::get_id();
+    assert(!(id1 == id0));
+    assert( (id1 != id0));
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp
new file mode 100644
index 0000000..099781f
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/lt.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// bool operator< (thread::id x, thread::id y);
+// bool operator<=(thread::id x, thread::id y);
+// bool operator> (thread::id x, thread::id y);
+// bool operator>=(thread::id x, thread::id y);
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0;
+    std::thread::id id1;
+    std::thread::id id2 = std::this_thread::get_id();
+    assert(!(id0 <  id1));
+    assert( (id0 <= id1));
+    assert(!(id0 >  id1));
+    assert( (id0 >= id1));
+    assert(!(id0 == id2));
+    if (id0 < id2) {
+      assert( (id0 <= id2));
+      assert(!(id0 >  id2));
+      assert(!(id0 >= id2));
+    } else {
+      assert(!(id0 <= id2));
+      assert( (id0 >  id2));
+      assert( (id0 >= id2));
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
new file mode 100644
index 0000000..54fc739
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread::id
+
+// template<class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& out, thread::id id);
+
+#include <thread>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id0 = std::this_thread::get_id();
+    std::ostringstream os;
+    os << id0;
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
new file mode 100644
index 0000000..d407dfc
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id1;
+    std::thread::id id2 = std::this_thread::get_id();
+    typedef std::hash<std::thread::id> H;
+    H h;
+    assert(h(id1) != h(id2));
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
new file mode 100644
index 0000000..dbb98b5
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void detach();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.detach();
+        assert(!t0.joinable());
+        std::this_thread::sleep_for(std::chrono::milliseconds(250));
+        assert(G::op_run);
+        assert(G::n_alive == 0);
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
new file mode 100644
index 0000000..6af4f3b
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/get_id.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// id get_id() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        assert(t0.get_id() != id1);
+        assert(t1.get_id() == std::thread::id());
+        t0.join();
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
new file mode 100644
index 0000000..32faef4
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/join.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void join();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
new file mode 100644
index 0000000..9c90eb7
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/joinable.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// bool joinable() const;
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        assert(t0.joinable());
+        t0.join();
+        assert(!t0.joinable());
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
new file mode 100644
index 0000000..1aae922
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// native_handle_type native_handle();
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        pthread_t pid = t0.native_handle();
+        assert(pid != 0);
+        t0.join();
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
new file mode 100644
index 0000000..820091e
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.member/swap.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// void swap(thread& t);
+
+#include <thread>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class G
+{
+    int alive_;
+public:
+    static int n_alive;
+    static bool op_run;
+
+    G() : alive_(1) {++n_alive;}
+    G(const G& g) : alive_(g.alive_) {++n_alive;}
+    ~G() {alive_ = 0; --n_alive;}
+
+    void operator()()
+    {
+        assert(alive_ == 1);
+        assert(n_alive >= 1);
+        op_run = true;
+    }
+};
+
+int G::n_alive = 0;
+bool G::op_run = false;
+
+int main()
+{
+    {
+        std::thread t0((G()));
+        std::thread::id id0 = t0.get_id();
+        std::thread t1;
+        std::thread::id id1 = t1.get_id();
+        t0.swap(t1);
+        assert(t0.get_id() == id1);
+        assert(t1.get_id() == id0);
+        t1.join();
+    }
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp
new file mode 100644
index 0000000..256edc2
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/thread.thread.static/hardware_concurrency.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+
+// unsigned hardware_concurrency();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    assert(std::thread::hardware_concurrency() > 0);
+}
diff --git a/final/test/thread/thread.threads/thread.thread.class/types.pass.cpp b/final/test/thread/thread.threads/thread.thread.class/types.pass.cpp
new file mode 100644
index 0000000..e5094f7
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.class/types.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// class thread
+// {
+// public:
+//     typedef pthread_t native_handle_type;
+//     ...
+// };
+
+#include <thread>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::thread::native_handle_type, pthread_t>::value), "");
+}
diff --git a/final/test/thread/thread.threads/thread.thread.this/get_id.pass.cpp b/final/test/thread/thread.threads/thread.thread.this/get_id.pass.cpp
new file mode 100644
index 0000000..ef6615b
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.this/get_id.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// thread::id this_thread::get_id();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::thread::id id = std::this_thread::get_id();
+    assert(id != std::thread::id());
+}
diff --git a/final/test/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp b/final/test/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
new file mode 100644
index 0000000..f66b962
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.this/sleep_for.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// template <class Rep, class Period>
+//   void sleep_for(const chrono::duration<Rep, Period>& rel_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+#include <signal.h>
+#include <sys/time.h>
+
+int main()
+{
+    int ec;
+    struct sigaction action;
+    action.sa_handler = [](int) {};
+    sigemptyset(&action.sa_mask);
+    action.sa_flags = 0;
+
+    ec = sigaction(SIGALRM, &action, nullptr);
+    assert(!ec);
+
+    struct itimerval it;
+    it.it_interval = { 0 };
+    it.it_value.tv_sec = 0;
+    it.it_value.tv_usec = 250000;
+    // This will result in a SIGALRM getting fired resulting in the nanosleep
+    // inside sleep_for getting EINTR.
+    ec = setitimer(ITIMER_REAL, &it, nullptr);
+    assert(!ec);
+
+    typedef std::chrono::system_clock Clock;
+    typedef Clock::time_point time_point;
+    typedef Clock::duration duration;
+    std::chrono::milliseconds ms(500);
+    time_point t0 = Clock::now();
+    std::this_thread::sleep_for(ms);
+    time_point t1 = Clock::now();
+    std::chrono::nanoseconds ns = (t1 - t0) - ms;
+    std::chrono::nanoseconds err = 5 * ms / 100;
+    // The time slept is within 5% of 500ms
+    assert(std::abs(ns.count()) < err.count());
+}
diff --git a/final/test/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp b/final/test/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp
new file mode 100644
index 0000000..2f3bb9a
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.this/sleep_until.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// template <class Clock, class Duration>
+//   void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
+
+#include <thread>
+#include <cstdlib>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef Clock::time_point time_point;
+    typedef Clock::duration duration;
+    std::chrono::milliseconds ms(500);
+    time_point t0 = Clock::now();
+    std::this_thread::sleep_until(t0 + ms);
+    time_point t1 = Clock::now();
+    std::chrono::nanoseconds ns = (t1 - t0) - ms;
+    std::chrono::nanoseconds err = 5 * ms / 100;
+    // The time slept is within 5% of 500ms
+    assert(std::abs(ns.count()) < err.count());
+}
diff --git a/final/test/thread/thread.threads/thread.thread.this/yield.pass.cpp b/final/test/thread/thread.threads/thread.thread.this/yield.pass.cpp
new file mode 100644
index 0000000..52f53a6
--- /dev/null
+++ b/final/test/thread/thread.threads/thread.thread.this/yield.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+// void this_thread::yield();
+
+#include <thread>
+#include <cassert>
+
+int main()
+{
+    std::this_thread::yield();
+}
diff --git a/final/test/thread/thread.threads/version.pass.cpp b/final/test/thread/thread.threads/version.pass.cpp
new file mode 100644
index 0000000..6d272c7
--- /dev/null
+++ b/final/test/thread/thread.threads/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <thread>
+
+#include <thread>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
new file mode 100644
index 0000000..a5663a2
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(OuterA2&& outerAlloc,
+//                            const InnerAllocs& ...innerAllocs);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A1<int> a3(3);
+        A a(a3);
+        assert(a.outer_allocator() == A1<int>(3));
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+    }
+    A1<int>::copy_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(3));
+        assert(a.outer_allocator() == A1<int>(3));
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+    }
+    A1<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A1<int> a4(4);
+        A a(a4, A2<int>(5));
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(4), A2<int>(5));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(5)));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    A1<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A1<int> a4(4);
+        A a(a4, A2<int>(5), A3<int>(6));
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+    }
+    A1<int>::copy_called = false;
+    A1<int>::move_called = false;
+    A2<int>::copy_called = false;
+    A2<int>::move_called = false;
+    A3<int>::copy_called = false;
+    A3<int>::move_called = false;
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(4), A2<int>(5), A3<int>(6));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a.outer_allocator() == A1<int>(4));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(5), A3<int>(6))));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp
new file mode 100644
index 0000000..9d40cf5
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_copy.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2,
+//                                                           InnerAllocs...>& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        B a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        B a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A2<int>::copy_called == true);
+        assert(A3<int>::copy_called == true);
+        assert(a2 == a1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp
new file mode 100644
index 0000000..02e9dff
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/converting_move.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA2>
+//   scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2,
+//                                                     InnerAllocs...>&& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        B a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        B a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == true);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<double>, A2<int>, A3<int>> B;
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        B a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = std::move(a1);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == true);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == true);
+        assert(A3<int>::copy_called == false);
+        assert(A3<int>::move_called == true);
+        assert(a2 == a1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..2105532
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor(const scoped_allocator_adaptor& other);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a1(A1<int>(4), A2<int>(5));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(a2 == a1);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A1<int>::copy_called = false;
+        A1<int>::move_called = false;
+        A2<int>::copy_called = false;
+        A2<int>::move_called = false;
+        A3<int>::copy_called = false;
+        A3<int>::move_called = false;
+        A a2 = a1;
+        assert(A1<int>::copy_called == true);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == true);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == true);
+        assert(A3<int>::move_called == false);
+        assert(a2 == a1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp
new file mode 100644
index 0000000..2a1d781
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.cnstr/default.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor();
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert(a.inner_allocator() == a);
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == false);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        assert(a.outer_allocator() == A1<int>());
+        assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
+        assert(A1<int>::copy_called == false);
+        assert(A1<int>::move_called == false);
+        assert(A2<int>::copy_called == false);
+        assert(A2<int>::move_called == false);
+        assert(A3<int>::copy_called == false);
+        assert(A3<int>::move_called == false);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp
new file mode 100644
index 0000000..727907e
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// pointer allocate(size_type n);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp
new file mode 100644
index 0000000..cae42de
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/allocate_size_hint.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// pointer allocate(size_type n, const_void_pointer hint);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)0) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)10) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        A1<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)20) == (int*)10);
+        assert(A1<int>::allocate_called == true);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)0) == (int*)0);
+        assert(A2<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>, A2<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)10) == (int*)10);
+        assert(A2<int>::allocate_called == true);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A2<int>, A2<int>, A3<int>> A;
+        A a;
+        A2<int>::allocate_called = false;
+        assert(a.allocate(10, (const void*)20) == (int*)20);
+        assert(A2<int>::allocate_called == true);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
new file mode 100644
index 0000000..f94b0e1
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/construct.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class T, class... Args> void construct(T* p, Args&&... args);
+
+#include <scoped_allocator>
+#include <cassert>
+#include <string>
+
+#include "allocators.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct B
+{
+    static bool constructed;
+
+    typedef A1<B> allocator_type;
+
+    explicit B(std::allocator_arg_t, const allocator_type& a, int i)
+    {
+        assert(a.id() == 5);
+        assert(i == 6);
+        constructed = true;
+    }
+};
+
+bool B::constructed = false;
+
+struct C
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<C>> allocator_type;
+
+    explicit C(std::allocator_arg_t, const allocator_type& a, int i)
+    {
+        assert(a.id() == 7);
+        assert(i == 8);
+        constructed = true;
+    }
+};
+
+bool C::constructed = false;
+
+struct D
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<D>> allocator_type;
+
+    explicit D(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 3);
+        constructed = true;
+    }
+};
+
+bool D::constructed = false;
+
+struct E
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A1<E>> allocator_type;
+
+    explicit E(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 50);
+        constructed = true;
+    }
+};
+
+bool E::constructed = false;
+
+struct F
+{
+    static bool constructed;
+
+    typedef std::scoped_allocator_adaptor<A2<F>> allocator_type;
+
+    explicit F(int i, int j)
+    {
+        assert(i == 1);
+        assert(j == 2);
+    }
+
+    explicit F(int i, int j, const allocator_type& a)
+    {
+        assert(i == 1);
+        assert(j == 2);
+        assert(a.id() == 50);
+        constructed = true;
+    }
+};
+
+bool F::constructed = false;
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<std::string>> A;
+        A a;
+        char buf[100];
+        typedef std::string S;
+        S* s = (S*)buf;
+        a.construct(s, 4, 'c');
+        assert(*s == "cccc");
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<B>> A;
+        A a(A1<B>(5));
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        a.construct(s, 6);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<C>> A;
+        A a(A1<int>(5), A2<C>(7));
+        char buf[100];
+        typedef C S;
+        S* s = (S*)buf;
+        a.construct(s, 8);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<D>> A;
+        A a(A1<int>(5), A2<D>(3));
+        char buf[100];
+        typedef D S;
+        S* s = (S*)buf;
+        a.construct(s, 1, 2);
+        assert(S::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<E>, A2<E>> K;
+        typedef std::scoped_allocator_adaptor<K, A1<E>> A;
+        A a(K(), A1<E>(50));
+        char buf[100];
+        typedef E S;
+        S* s = (S*)buf;
+        A3<E>::constructed = false;
+        a.construct(s, 1, 2);
+        assert(S::constructed);
+        assert(A3<E>::constructed);
+        s->~S();
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<F>, A2<F>> K;
+        typedef std::scoped_allocator_adaptor<K, A1<F>> A;
+        A a(K(), A1<F>(50));
+        char buf[100];
+        typedef F S;
+        S* s = (S*)buf;
+        A3<F>::constructed = false;
+        a.construct(s, 1, 2);
+        assert(!S::constructed);
+        assert(A3<F>::constructed);
+        s->~S();
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp
new file mode 100644
index 0000000..bf77f29
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/deallocate.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// void deallocate(pointer p, size_type n);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a;
+        a.deallocate((int*)10, 20);
+        assert((A1<int>::deallocate_called == std::pair<int*, std::size_t>((int*)10, 20)));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp
new file mode 100644
index 0000000..0ff3880
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/destroy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class T> void destroy(T* p);
+
+#include <scoped_allocator>
+#include <cassert>
+#include <string>
+
+#include "allocators.h"
+
+struct B
+{
+    static bool constructed;
+
+    B() {constructed = true;}
+    ~B() {constructed = false;}
+};
+
+bool B::constructed = false;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<B>> A;
+        A a;
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        assert(!S::constructed);
+        a.construct(s);
+        assert(S::constructed);
+        a.destroy(s);
+        assert(!S::constructed);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<B>, A1<B>> A;
+        A a;
+        char buf[100];
+        typedef B S;
+        S* s = (S*)buf;
+        assert(!S::constructed);
+        assert(!A3<S>::constructed);
+        assert(!A3<S>::destroy_called);
+        a.construct(s);
+        assert(S::constructed);
+        assert(A3<S>::constructed);
+        assert(!A3<S>::destroy_called);
+        a.destroy(s);
+        assert(!S::constructed);
+        assert(A3<S>::constructed);
+        assert(A3<S>::destroy_called);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp
new file mode 100644
index 0000000..0fb55b6
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/inner_allocator.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// inner_allocator_type& inner_allocator();
+// const inner_allocator_type& inner_allocator() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(5));
+        assert(a.inner_allocator() == a);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(5), A2<int>(6));
+        assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>(A2<int>(6)));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(5), A2<int>(6), A3<int>(8));
+        assert((a.inner_allocator() ==
+            std::scoped_allocator_adaptor<A2<int>, A3<int>>(A2<int>(6), A3<int>(8))));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp
new file mode 100644
index 0000000..a5275ee
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/max_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// size_type max_size() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        const A a(A1<int>(100));
+        assert(a.max_size() == 100);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        const A a(A1<int>(20), A2<int>());
+        assert(a.max_size() == 20);
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        const A a(A1<int>(200), A2<int>(), A3<int>());
+        assert(a.max_size() == 200);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp
new file mode 100644
index 0000000..2297612
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/outer_allocator.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// outer_allocator_type& outer_allocator();
+// const outer_allocator_type& outer_allocator() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a(A1<int>(5));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a(A1<int>(5), A2<int>(6));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a(A1<int>(5), A2<int>(6), A3<int>(8));
+        assert(a.outer_allocator() == A1<int>(5));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 0000000..f9f0ffa
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.members/select_on_container_copy_construction.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// scoped_allocator_adaptor select_on_container_copy_construction() const;
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        assert(a1.outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == 3);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A3<int>> A;
+        A a1(A3<int>(3));
+        assert(a1.outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == -1);
+    }
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(1), A2<int>(2), A3<int>(3));
+        assert(a1.outer_allocator().id() == 1);
+        assert(a1.inner_allocator().outer_allocator().id() == 2);
+        assert(a1.inner_allocator().inner_allocator().outer_allocator().id() == 3);
+        A a2 = std::allocator_traits<A>::select_on_container_copy_construction(a1);
+        assert(a2.outer_allocator().id() == 1);
+        assert(a2.inner_allocator().outer_allocator().id() == 2);
+        assert(a2.inner_allocator().inner_allocator().outer_allocator().id() == -1);
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp
new file mode 100644
index 0000000..537fb90
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <scoped_allocator>
+#include <cassert>
+
+#if __cplusplus >= 201103L
+// #include <memory>
+//
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc                        allocator_type;
+//     typedef typename allocator_type::value_type
+//                                          value_type;
+// 
+//     typedef Alloc::pointer | value_type* pointer;
+//     typedef Alloc::const_pointer
+//           | pointer_traits<pointer>::rebind<const value_type>
+//                                          const_pointer;
+//     typedef Alloc::void_pointer
+//           | pointer_traits<pointer>::rebind<void>
+//                                          void_pointer;
+//     typedef Alloc::const_void_pointer
+//           | pointer_traits<pointer>::rebind<const void>
+//                                          const_void_pointer;
+
+template <typename Alloc>
+void test_pointer()
+{
+     typename std::allocator_traits<Alloc>::pointer        vp;
+     typename std::allocator_traits<Alloc>::const_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+template <typename Alloc>
+void test_void_pointer()
+{
+     typename std::allocator_traits<Alloc>::void_pointer        vp;
+     typename std::allocator_traits<Alloc>::const_void_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+struct Foo { int x; };
+
+int main()
+{
+	test_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
+	test_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
+	test_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();
+
+	test_void_pointer<std::scoped_allocator_adaptor<std::allocator<char>>> ();
+	test_void_pointer<std::scoped_allocator_adaptor<std::allocator<int>>> ();
+	test_void_pointer<std::scoped_allocator_adaptor<std::allocator<Foo>>> ();	
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp
new file mode 100644
index 0000000..4303b95
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/inner_allocator_type.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below inner_allocator_type;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A1<int>>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A2<int>>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::inner_allocator_type,
+        std::scoped_allocator_adaptor<A2<int>, A3<int>>>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 0000000..ceb9413
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_copy_assignment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_copy_assignment;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_copy_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_copy_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_copy_assignment,
+        std::true_type>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 0000000..04da507
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_move_assignment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_move_assignment;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_move_assignment,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_move_assignment,
+        std::true_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_move_assignment,
+        std::true_type>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 0000000..4a66bbd
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/allocator.adaptor.types/propagate_on_container_swap.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// typedef see below propagate_on_container_swap;
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::propagate_on_container_swap,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>>::propagate_on_container_swap,
+        std::false_type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::propagate_on_container_swap,
+        std::true_type>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp b/final/test/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp
new file mode 100644
index 0000000..8d4cb6a
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/scoped.adaptor.operators/eq.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+//   class scoped_allocator_adaptor
+
+// template <class OuterA1, class OuterA2, class... InnerAllocs>
+//     bool
+//     operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+//                const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
+// 
+// template <class OuterA1, class OuterA2, class... InnerAllocs>
+//     bool
+//     operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
+//                const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b);
+
+#include <scoped_allocator>
+#include <cassert>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>> A;
+        A a1(A1<int>(3));
+        A a2 = a1;
+        assert(a2 == a1);
+        assert(!(a2 != a1));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
+        A a1(A1<int>(4), A2<int>(5));
+        A a2 = a1;
+        assert(a2 == a1);
+        assert(!(a2 != a1));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A a2 = a1;
+        assert(a2 == a1);
+        assert(!(a2 != a1));
+    }
+    {
+        typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
+        A a1(A1<int>(4), A2<int>(5), A3<int>(6));
+        A a2(A1<int>(4), A2<int>(5), A3<int>(5));
+        assert(a2 != a1);
+        assert(!(a2 == a1));
+    }
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/allocator.adaptor/types.pass.cpp b/final/test/utilities/allocator.adaptor/types.pass.cpp
new file mode 100644
index 0000000..7beff48
--- /dev/null
+++ b/final/test/utilities/allocator.adaptor/types.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class OuterAlloc, class... InnerAllocs>
+// class scoped_allocator_adaptor
+//     : public OuterAlloc
+// {
+// public:
+//     typedef OuterAlloc outer_allocator_type;
+//     typedef typename OuterTraits::size_type size_type;
+//     typedef typename OuterTraits::difference_type difference_type;
+//     typedef typename OuterTraits::pointer pointer;
+//     typedef typename OuterTraits::const_pointer const_pointer;
+//     typedef typename OuterTraits::void_pointer void_pointer;
+//     typedef typename OuterTraits::const_void_pointer const_void_pointer;
+// };
+
+#include <scoped_allocator>
+#include <type_traits>
+
+#include "allocators.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert((std::is_base_of<
+        A1<int>,
+        std::scoped_allocator_adaptor<A1<int>>
+        >::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::outer_allocator_type,
+        A1<int>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::size_type,
+        std::make_unsigned<std::ptrdiff_t>::type>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::difference_type,
+        std::ptrdiff_t>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::pointer,
+        int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::const_pointer,
+        const int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::void_pointer,
+        void*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A1<int>>::const_void_pointer,
+        const void*>::value), "");
+
+    static_assert((std::is_base_of<
+        A2<int>,
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>
+        >::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::outer_allocator_type,
+        A2<int>>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::size_type,
+        unsigned>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::difference_type,
+        int>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::pointer,
+        int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_pointer,
+        const int*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::void_pointer,
+        void*>::value), "");
+
+    static_assert((std::is_same<
+        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_void_pointer,
+        const void*>::value), "");
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/date.time/tested_elsewhere.pass.cpp b/final/test/utilities/date.time/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..e1d1c73
--- /dev/null
+++ b/final/test/utilities/date.time/tested_elsewhere.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <ctime>
+#include <type_traits>
+
+#ifndef NULL
+#error NULL not defined
+#endif
+
+#ifndef CLOCKS_PER_SEC
+#error CLOCKS_PER_SEC not defined
+#endif
+
+int main()
+{
+    std::clock_t c = 0;
+    std::size_t s = 0;
+    std::time_t t = 0;
+    std::tm tm = {0};
+    char str[3];
+    static_assert((std::is_same<decltype(std::clock()), std::clock_t>::value), "");
+    static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), "");
+    static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::time(&t)), std::time_t>::value), "");
+    static_assert((std::is_same<decltype(std::asctime(&tm)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::ctime(&t)), char*>::value), "");
+    static_assert((std::is_same<decltype(std::gmtime(&t)), std::tm*>::value), "");
+    static_assert((std::is_same<decltype(std::localtime(&t)), std::tm*>::value), "");
+    static_assert((std::is_same<decltype(std::strftime(str,s,"",&tm)), std::size_t>::value), "");
+}
diff --git a/final/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp b/final/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp
new file mode 100644
index 0000000..74298f2
--- /dev/null
+++ b/final/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// divides
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::divides<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(36, 4) == 9);
+#if _LIBCPP_STD_VER > 11
+    typedef std::divides<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 4) == 9);
+    assert(f2(36.0, 4) == 9);
+    assert(f2(18, 4.0) == 4.5); // exact in binary
+
+    constexpr int foo = std::divides<int> () (3, 2);
+    static_assert ( foo == 1, "" );
+
+    constexpr int bar = std::divides<> () (3.0, 2);
+    static_assert ( bar == 1, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp b/final/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp
new file mode 100644
index 0000000..9a496a8
--- /dev/null
+++ b/final/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// minus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::minus<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(3, 2) == 1);
+#if _LIBCPP_STD_VER > 11
+    typedef std::minus<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 1);
+    assert(f2(3.0, 2) == 1);
+    assert(f2(3, 2.5) == 0.5);
+
+    constexpr int foo = std::minus<int> () (3, 2);
+    static_assert ( foo == 1, "" );
+
+    constexpr int bar = std::minus<> () (3.0, 2);
+    static_assert ( bar == 1, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp b/final/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
new file mode 100644
index 0000000..3c17881
--- /dev/null
+++ b/final/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// modulus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::modulus<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(36, 8) == 4);
+#if _LIBCPP_STD_VER > 11
+    typedef std::modulus<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 8) == 4);
+    assert(f2(36L, 8) == 4);
+    assert(f2(36, 8L) == 4);
+
+    constexpr int foo = std::modulus<int> () (3, 2);
+    static_assert ( foo == 1, "" );
+
+    constexpr int bar = std::modulus<> () (3L, 2);
+    static_assert ( bar == 1, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp b/final/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
new file mode 100644
index 0000000..97287e6
--- /dev/null
+++ b/final/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// multiplies
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::multiplies<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(3, 2) == 6);
+#if _LIBCPP_STD_VER > 11
+    typedef std::multiplies<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 6);
+    assert(f2(3.0, 2) == 6);
+    assert(f2(3, 2.5) == 7.5); // exact in binary
+
+    constexpr int foo = std::multiplies<int> () (3, 2);
+    static_assert ( foo == 6, "" );
+
+    constexpr int bar = std::multiplies<> () (3.0, 2);
+    static_assert ( bar == 6, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp b/final/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp
new file mode 100644
index 0000000..3ffb705
--- /dev/null
+++ b/final/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::negate<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
+    assert(f(36) == -36);
+#if _LIBCPP_STD_VER > 11
+    typedef std::negate<> F2;
+    const F2 f2 = F2();
+    assert(f2(36) == -36);
+    assert(f2(36L) == -36);
+    assert(f2(36.0) == -36);
+
+    constexpr int foo = std::negate<int> () (3);
+    static_assert ( foo == -3, "" );
+
+    constexpr int bar = std::negate<> () (3.0);
+    static_assert ( bar == -3, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp b/final/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp
new file mode 100644
index 0000000..44001a0
--- /dev/null
+++ b/final/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// plus
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::plus<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(3, 2) == 5);
+#if _LIBCPP_STD_VER > 11
+    typedef std::plus<> F2;
+    const F2 f2 = F2();
+    assert(f2(3,2) == 5);
+    assert(f2(3.0, 2) == 5);
+    assert(f2(3, 2.5) == 5.5);
+    
+    constexpr int foo = std::plus<int> () (3, 2);
+    static_assert ( foo == 5, "" );
+
+    constexpr int bar = std::plus<> () (3.0, 2);
+    static_assert ( bar == 5, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/arithmetic.operations/transparent.pass.cpp b/final/test/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
new file mode 100644
index 0000000..72b4b4a
--- /dev/null
+++ b/final/test/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::plus<int>>::value, "" );
+    static_assert ( !is_transparent<std::plus<std::string>>::value, "" );
+    static_assert (  is_transparent<std::plus<void>>::value, "" );
+    static_assert (  is_transparent<std::plus<>>::value, "" );
+
+    static_assert ( !is_transparent<std::minus<int>>::value, "" );
+    static_assert ( !is_transparent<std::minus<std::string>>::value, "" );
+    static_assert (  is_transparent<std::minus<void>>::value, "" );
+    static_assert (  is_transparent<std::minus<>>::value, "" );
+
+    static_assert ( !is_transparent<std::multiplies<int>>::value, "" );
+    static_assert ( !is_transparent<std::multiplies<std::string>>::value, "" );
+    static_assert (  is_transparent<std::multiplies<void>>::value, "" );
+    static_assert (  is_transparent<std::multiplies<>>::value, "" );
+
+    static_assert ( !is_transparent<std::divides<int>>::value, "" );
+    static_assert ( !is_transparent<std::divides<std::string>>::value, "" );
+    static_assert (  is_transparent<std::divides<void>>::value, "" );
+    static_assert (  is_transparent<std::divides<>>::value, "" );
+
+    static_assert ( !is_transparent<std::modulus<int>>::value, "" );
+    static_assert ( !is_transparent<std::modulus<std::string>>::value, "" );
+    static_assert (  is_transparent<std::modulus<void>>::value, "" );
+    static_assert (  is_transparent<std::modulus<>>::value, "" );
+
+    static_assert ( !is_transparent<std::negate<int>>::value, "" );
+    static_assert ( !is_transparent<std::negate<std::string>>::value, "" );
+    static_assert (  is_transparent<std::negate<void>>::value, "" );
+    static_assert (  is_transparent<std::negate<>>::value, "" );
+    
+#endif
+
+    return 0;
+    }
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
new file mode 100644
index 0000000..6315598
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16385
+
+#include <functional>
+#include <cmath>
+#include <cassert>
+
+float _pow(float a, float b)
+{
+    return std::pow(a, b);
+}
+
+int main()
+{
+    std::function<float(float, float)> fnc = _pow;
+    auto task = std::bind(fnc, 2.f, 4.f);
+    auto task2(task);
+    assert(task() == 16);
+    assert(task2() == 16);
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
new file mode 100644
index 0000000..ab4dd59
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <functional>
+#include <cassert>
+
+template <class R, class F>
+void
+test(F f, R expected)
+{
+    assert(f() == expected);
+}
+
+template <class R, class F>
+void
+test_const(const F& f, R expected)
+{
+    assert(f() == expected);
+}
+
+int f() {return 1;}
+
+struct A_int_0
+{
+    int operator()() {return 4;}
+    int operator()() const {return 5;}
+};
+
+int main()
+{
+    test(std::bind(f), 1);
+    test(std::bind(&f), 1);
+    test(std::bind(A_int_0()), 4);
+    test_const(std::bind(A_int_0()), 5);
+
+    test(std::bind<int>(f), 1);
+    test(std::bind<int>(&f), 1);
+    test(std::bind<int>(A_int_0()), 4);
+    test_const(std::bind<int>(A_int_0()), 5);
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
new file mode 100644
index 0000000..1125844
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <stdio.h>
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {count += 2;}
+};
+
+void
+test_void_1()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    int i = 2;
+    std::bind(f_void_1, _1)(i);
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    {
+    int i = 2;
+    std::bind(f_void_1, i)();
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    int i = 3;
+    std::bind(fp, _1)(i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    {
+    void (*fp)(int) = f_void_1;
+    int i = 3;
+    std::bind(fp, i)();
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    int i = 4;
+    std::bind(a0, _1)(i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    {
+    A_void_1 a0;
+    int i = 4;
+    std::bind(a0, i)();
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    A_void_1 a;
+    std::bind(fp, _1)(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, _1)(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    A_void_1 a;
+    std::bind(fp, a)();
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, ap)();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    A_void_1 a;
+    std::bind(fp, _1)(a);
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, _1)(ap);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    A_void_1 a;
+    std::bind(fp, a)();
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::bind(fp, ap)();
+    assert(count == save_count+2);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    using namespace std::placeholders;
+    // function
+    {
+    int i = 2;
+    assert(std::bind(f_int_1, _1)(i) == 3);
+    assert(std::bind(f_int_1, i)() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    int i = 3;
+    assert(std::bind(fp, _1)(i) == 4);
+    assert(std::bind(fp, i)() == 4);
+    }
+    // functor
+    {
+    int i = 4;
+    assert(std::bind(A_int_1(), _1)(i) == 3);
+    assert(std::bind(A_int_1(), i)() == 3);
+    }
+    // member function pointer
+    {
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem1, _1)(a) == 3);
+    assert(std::bind(&A_int_1::mem1, a)() == 3);
+    A_int_1* ap = &a;
+    assert(std::bind(&A_int_1::mem1, _1)(ap) == 3);
+    assert(std::bind(&A_int_1::mem1, ap)() == 3);
+    }
+    // const member function pointer
+    {
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
+    assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
+    A_int_1* ap = &a;
+    assert(std::bind(&A_int_1::mem2, _1)(ap) == 4);
+    assert(std::bind(&A_int_1::mem2, ap)() == 4);
+    }
+    // member data pointer
+    {
+    A_int_1 a;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+    assert(std::bind(&A_int_1::data_, a)() == 5);
+    A_int_1* ap = &a;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+    std::bind(&A_int_1::data_, _1)(a) = 6;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 6);
+    assert(std::bind(&A_int_1::data_, _1)(ap) == 6);
+    std::bind(&A_int_1::data_, _1)(ap) = 7;
+    assert(std::bind(&A_int_1::data_, _1)(ap) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    int i = 2;
+    int j = 3;
+    std::bind(f_void_2, _1, _2)(i, j);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, i, _1)(j);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, i, j)();
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    int j = 3;
+    std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), j);
+    assert(count == save_count+3);
+    save_count = count;
+    std::bind(&A_void_2::mem1, _2, _1)(j, A_void_2());
+    assert(count == save_count+3);
+    save_count = count;
+    }
+}
+
+struct TFENode
+{
+    bool foo(unsigned long long) const
+    {
+        return true;
+    }
+};
+
+void
+test3()
+{
+    using namespace std;
+    using namespace std::placeholders;
+    const auto f = bind(&TFENode::foo, _1, 0UL);
+    const TFENode n = TFENode{};
+    bool b = f(n);
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
new file mode 100644
index 0000000..4913a51
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
@@ -0,0 +1,266 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <stdio.h>
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {count += 2;}
+};
+
+void
+test_void_1()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    std::bind(f_void_1, _1)(2);
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    {
+    std::bind(f_void_1, 2)();
+    assert(count == save_count + 2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    std::bind(fp, _1)(3);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    {
+    void (*fp)(int) = f_void_1;
+    std::bind(fp, 3)();
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    std::bind(a0, _1)(4);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    {
+    A_void_1 a0;
+    std::bind(a0, 4)();
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::bind(fp, _1)(A_void_1());
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, _1)(&a);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::bind(fp, A_void_1())();
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, &a)();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::bind(fp, _1)(A_void_1());
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, _1)(&a);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::bind(fp, A_void_1())();
+    assert(count == save_count+2);
+    save_count = count;
+    A_void_1 a;
+    std::bind(fp, &a)();
+    assert(count == save_count+2);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    using namespace std::placeholders;
+    // function
+    {
+    assert(std::bind(f_int_1, _1)(2) == 3);
+    assert(std::bind(f_int_1, 2)() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    assert(std::bind(fp, _1)(3) == 4);
+    assert(std::bind(fp, 3)() == 4);
+    }
+    // functor
+    {
+    assert(std::bind(A_int_1(), _1)(4) == 3);
+    assert(std::bind(A_int_1(), 4)() == 3);
+    }
+    // member function pointer
+    {
+    assert(std::bind(&A_int_1::mem1, _1)(A_int_1()) == 3);
+    assert(std::bind(&A_int_1::mem1, A_int_1())() == 3);
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem1, _1)(&a) == 3);
+    assert(std::bind(&A_int_1::mem1, &a)() == 3);
+    }
+    // const member function pointer
+    {
+    assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4);
+    assert(std::bind(&A_int_1::mem2, A_int_1())() == 4);
+    A_int_1 a;
+    assert(std::bind(&A_int_1::mem2, _1)(&a) == 4);
+    assert(std::bind(&A_int_1::mem2, &a)() == 4);
+    }
+    // member data pointer
+    {
+    assert(std::bind(&A_int_1::data_, _1)(A_int_1()) == 5);
+    assert(std::bind(&A_int_1::data_, A_int_1())() == 5);
+    A_int_1 a;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 5);
+    std::bind(&A_int_1::data_, _1)(a) = 6;
+    assert(std::bind(&A_int_1::data_, _1)(a) == 6);
+    assert(std::bind(&A_int_1::data_, _1)(&a) == 6);
+    std::bind(&A_int_1::data_, _1)(&a) = 7;
+    assert(std::bind(&A_int_1::data_, _1)(&a) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    using namespace std::placeholders;
+    int save_count = count;
+    // function
+    {
+    std::bind(f_void_2, _1, _2)(2, 3);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, 2, _1)(3);
+    assert(count == save_count+5);
+    save_count = count;
+    std::bind(f_void_2, 2, 3)();
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), 3);
+    assert(count == save_count+3);
+    save_count = count;
+    std::bind(&A_void_2::mem1, _2, _1)(3, A_void_2());
+    assert(count == save_count+3);
+    save_count = count;
+    }
+}
+
+int f_nested(int i)
+{
+    return i+1;
+}
+
+int g_nested(int i)
+{
+    return i*10;
+}
+
+void test_nested()
+{
+    using namespace std::placeholders;
+    assert(std::bind(f_nested, std::bind(g_nested, _1))(3) == 31);
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+    test_nested();
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
new file mode 100644
index 0000000..03447db
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+template <class F>
+void
+test(F f)
+{
+    int save_count = count;
+    f();
+    assert(count == save_count + 1);
+}
+
+template <class F>
+void
+test_const(const F& f)
+{
+    int save_count = count;
+    f();
+    assert(count == save_count + 2);
+}
+
+void f() {++count;}
+
+struct A_int_0
+{
+    void operator()() {++count;}
+    void operator()() const {count += 2;}
+};
+
+int main()
+{
+    test(std::bind(f));
+    test(std::bind(&f));
+    test(std::bind(A_int_0()));
+    test_const(std::bind(A_int_0()));
+
+    test(std::bind<void>(f));
+    test(std::bind<void>(&f));
+    test(std::bind<void>(A_int_0()));
+    test_const(std::bind<void>(A_int_0()));
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
new file mode 100644
index 0000000..12720f7
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
+//   unspecified bind(Fn, Types...);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16343
+
+#include <cmath>
+#include <functional>
+#include <cassert>
+
+struct power
+{
+  template <typename T>
+  T
+  operator()(T a, T b)
+  {
+    return std::pow(a, b);
+  }
+};
+
+struct plus_one
+{
+  template <typename T>
+  T
+  operator()(T a)
+  {
+    return a + 1;
+  }
+};
+
+int
+main()
+{
+    using std::placeholders::_1;
+
+    auto g = std::bind(power(), 2, _1);
+    assert(g(5) == 32);
+    assert(std::bind(plus_one(), g)(5) == 33);
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
new file mode 100644
index 0000000..7f8dd4a
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<class T> struct is_bind_expression
+
+#include <functional>
+
+template <bool Expected, class T>
+void
+test(const T&)
+{
+    static_assert(std::is_bind_expression<T>::value == Expected, "");
+}
+
+struct C {};
+
+int main()
+{
+    test<true>(std::bind(C()));
+    test<true>(std::bind(C(), std::placeholders::_2));
+    test<true>(std::bind<int>(C()));
+    test<false>(1);
+    test<false>(std::placeholders::_2);
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
new file mode 100644
index 0000000..6a52bd1
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// struct is_placeholder
+
+#include <functional>
+
+template <int Expected, class T>
+void
+test(const T&)
+{
+    static_assert(std::is_placeholder<T>::value == Expected, "");
+}
+
+struct C {};
+
+int main()
+{
+    test<1>(std::placeholders::_1);
+    test<2>(std::placeholders::_2);
+    test<3>(std::placeholders::_3);
+    test<4>(std::placeholders::_4);
+    test<5>(std::placeholders::_5);
+    test<6>(std::placeholders::_6);
+    test<7>(std::placeholders::_7);
+    test<8>(std::placeholders::_8);
+    test<9>(std::placeholders::_9);
+    test<10>(std::placeholders::_10);
+    test<0>(4);
+    test<0>(5.5);
+    test<0>('a');
+    test<0>(C());
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
new file mode 100644
index 0000000..fa791d4
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// placeholders
+
+#include <functional>
+
+template <class T>
+void
+test(const T& t)
+{
+    T t2;
+    T t3 = t;
+}
+
+int main()
+{
+    test(std::placeholders::_1);
+    test(std::placeholders::_2);
+    test(std::placeholders::_3);
+    test(std::placeholders::_4);
+    test(std::placeholders::_5);
+    test(std::placeholders::_6);
+    test(std::placeholders::_7);
+    test(std::placeholders::_8);
+    test(std::placeholders::_9);
+    test(std::placeholders::_10);
+}
diff --git a/final/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp b/final/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/function.objects/bind/nothing_to_do.pass.cpp b/final/test/utilities/function.objects/bind/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/function.objects/bind/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp b/final/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
new file mode 100644
index 0000000..6654478
--- /dev/null
+++ b/final/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_and
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::bit_and<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(0xEA95, 0xEA95) == 0xEA95);
+    assert(f(0xEA95, 0x58D3) == 0x4891);
+    assert(f(0x58D3, 0xEA95) == 0x4891);
+    assert(f(0x58D3, 0) == 0);
+    assert(f(0xFFFF, 0x58D3) == 0x58D3);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_and<> F2;
+    const F2 f2 = F2();
+    assert(f2(0xEA95, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+    assert(f2(0xEA95, 0x58D3) == 0x4891);
+    assert(f2(0xEA95L, 0x58D3) == 0x4891);
+    assert(f2(0xEA95, 0x58D3L) == 0x4891);
+
+    assert(f2(0x58D3, 0xEA95) == 0x4891);
+    assert(f2(0x58D3L, 0xEA95) == 0x4891);
+    assert(f2(0x58D3, 0xEA95L) == 0x4891);
+
+    assert(f2(0x58D3, 0) == 0);
+    assert(f2(0x58D3L, 0) == 0);
+    assert(f2(0x58D3, 0L) == 0);
+
+    assert(f2(0xFFFF, 0x58D3) == 0x58D3);
+    assert(f2(0xFFFFL, 0x58D3) == 0x58D3);
+    assert(f2(0xFFFF, 0x58D3L) == 0x58D3);
+
+    constexpr int foo = std::bit_and<int> () (0x58D3, 0xEA95);
+    static_assert ( foo == 0x4891, "" );
+
+    constexpr int bar = std::bit_and<> () (0x58D3L, 0xEA95);
+    static_assert ( bar == 0x4891, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp b/final/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
new file mode 100644
index 0000000..82efcbc
--- /dev/null
+++ b/final/test/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_not<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
+    assert((f(0xEA95) & 0xFFFF ) == 0x156A);
+    assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
+    assert((f(0)      & 0xFFFF ) == 0xFFFF);
+    assert((f(0xFFFF) & 0xFFFF ) == 0);
+
+    typedef std::bit_not<> F2;
+    const F2 f2 = F2();
+    assert((f2(0xEA95)  & 0xFFFF ) == 0x156A);
+    assert((f2(0xEA95L) & 0xFFFF ) == 0x156A);
+    assert((f2(0x58D3)  & 0xFFFF ) == 0xA72C);
+    assert((f2(0x58D3L) & 0xFFFF ) == 0xA72C);
+    assert((f2(0)       & 0xFFFF ) == 0xFFFF);
+    assert((f2(0L)      & 0xFFFF ) == 0xFFFF);
+    assert((f2(0xFFFF)  & 0xFFFF ) == 0);
+    assert((f2(0xFFFFL)  & 0xFFFF ) == 0);
+
+    constexpr int foo = std::bit_not<int> () (0xEA95) & 0xFFFF;
+    static_assert ( foo == 0x156A, "" );
+
+    constexpr int bar = std::bit_not<> () (0xEA95) & 0xFFFF;
+    static_assert ( bar == 0x156A, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp b/final/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
new file mode 100644
index 0000000..6ae3c3a
--- /dev/null
+++ b/final/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_or
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::bit_or<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(0xEA95, 0xEA95) == 0xEA95);
+    assert(f(0xEA95, 0x58D3) == 0xFAD7);
+    assert(f(0x58D3, 0xEA95) == 0xFAD7);
+    assert(f(0x58D3, 0) == 0x58D3);
+    assert(f(0xFFFF, 0x58D3) == 0xFFFF);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_or<> F2;
+    const F2 f2 = F2();
+    assert(f2(0xEA95, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95L, 0xEA95) == 0xEA95);
+    assert(f2(0xEA95, 0xEA95L) == 0xEA95);
+
+    assert(f2(0xEA95, 0x58D3) == 0xFAD7);
+    assert(f2(0xEA95L, 0x58D3) == 0xFAD7);
+    assert(f2(0xEA95, 0x58D3L) == 0xFAD7);
+
+    assert(f2(0x58D3, 0xEA95) == 0xFAD7);
+    assert(f2(0x58D3L, 0xEA95) == 0xFAD7);
+    assert(f2(0x58D3, 0xEA95L) == 0xFAD7);
+
+    assert(f2(0x58D3, 0) == 0x58D3);
+    assert(f2(0x58D3L, 0) == 0x58D3);
+    assert(f2(0x58D3, 0L) == 0x58D3);
+
+    assert(f2(0xFFFF, 0x58D3) == 0xFFFF);
+    assert(f2(0xFFFFL, 0x58D3) == 0xFFFF);
+    assert(f2(0xFFFF, 0x58D3L) == 0xFFFF);
+
+    constexpr int foo = std::bit_or<int> () (0x58D3, 0xEA95);
+    static_assert ( foo == 0xFAD7, "" );
+
+    constexpr int bar = std::bit_or<> () (0x58D3L, 0xEA95);
+    static_assert ( bar == 0xFAD7, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp b/final/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
new file mode 100644
index 0000000..e7bb5e4
--- /dev/null
+++ b/final/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// bit_xor
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::bit_xor<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), "");
+    assert(f(0xEA95, 0xEA95) == 0);
+    assert(f(0xEA95, 0x58D3) == 0xB246);
+    assert(f(0x58D3, 0xEA95) == 0xB246);
+    assert(f(0x58D3, 0) == 0x58D3);
+    assert(f(0xFFFF, 0x58D3) == 0xA72C);
+#if _LIBCPP_STD_VER > 11
+    typedef std::bit_xor<> F2;
+    const F2 f2 = F2();
+    assert(f(0xEA95, 0xEA95) == 0);
+    assert(f(0xEA95L, 0xEA95) == 0);
+    assert(f(0xEA95, 0xEA95L) == 0);
+
+    assert(f(0xEA95, 0x58D3) == 0xB246);
+    assert(f(0xEA95L, 0x58D3) == 0xB246);
+    assert(f(0xEA95, 0x58D3L) == 0xB246);
+
+    assert(f(0x58D3, 0xEA95) == 0xB246);
+    assert(f(0x58D3L, 0xEA95) == 0xB246);
+    assert(f(0x58D3, 0xEA95L) == 0xB246);
+
+    assert(f(0x58D3, 0) == 0x58D3);
+    assert(f(0x58D3L, 0) == 0x58D3);
+    assert(f(0x58D3, 0L) == 0x58D3);
+
+    assert(f(0xFFFF, 0x58D3) == 0xA72C);
+    assert(f(0xFFFFL, 0x58D3) == 0xA72C);
+    assert(f(0xFFFF, 0x58D3L) == 0xA72C);
+
+    constexpr int foo = std::bit_xor<int> () (0x58D3, 0xEA95);
+    static_assert ( foo == 0xB246, "" );
+
+    constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95);
+    static_assert ( bar == 0xB246, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/bitwise.operations/transparent.pass.cpp b/final/test/utilities/function.objects/bitwise.operations/transparent.pass.cpp
new file mode 100644
index 0000000..9f8e15d
--- /dev/null
+++ b/final/test/utilities/function.objects/bitwise.operations/transparent.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::bit_and<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_and<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_and<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_and<>>::value, "" );
+
+    static_assert ( !is_transparent<std::bit_or<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_or<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_or<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_or<>>::value, "" );
+
+    static_assert ( !is_transparent<std::bit_xor<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_xor<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_xor<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_xor<>>::value, "" );
+
+    static_assert ( !is_transparent<std::bit_not<int>>::value, "" );
+    static_assert ( !is_transparent<std::bit_not<std::string>>::value, "" );
+    static_assert (  is_transparent<std::bit_not<void>>::value, "" );
+    static_assert (  is_transparent<std::bit_not<>>::value, "" );
+    
+#endif
+
+    return 0;
+    }
diff --git a/final/test/utilities/function.objects/comparisons/equal_to.pass.cpp b/final/test/utilities/function.objects/comparisons/equal_to.pass.cpp
new file mode 100644
index 0000000..3d1c0b5
--- /dev/null
+++ b/final/test/utilities/function.objects/comparisons/equal_to.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::equal_to<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(!f(36, 6));
+#if _LIBCPP_STD_VER > 11
+    typedef std::equal_to<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 36));
+    assert(!f2(36, 6));
+    assert(f2(36, 36.0));
+    assert(f2(36.0, 36L));
+
+    constexpr bool foo = std::equal_to<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::equal_to<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/comparisons/greater.pass.cpp b/final/test/utilities/function.objects/comparisons/greater.pass.cpp
new file mode 100644
index 0000000..5a88f43
--- /dev/null
+++ b/final/test/utilities/function.objects/comparisons/greater.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::greater<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert(f(36, 6));
+    assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::greater<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert(f2(36, 6));
+    assert(!f2(6, 36));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(6, 36.0));
+    assert(!f2(6.0, 36));
+
+    constexpr bool foo = std::greater<int> () (36, 36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::greater<> () (36.0, 36);
+    static_assert ( !bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/comparisons/greater_equal.pass.cpp b/final/test/utilities/function.objects/comparisons/greater_equal.pass.cpp
new file mode 100644
index 0000000..22444c7
--- /dev/null
+++ b/final/test/utilities/function.objects/comparisons/greater_equal.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// greater_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::greater_equal<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(f(36, 6));
+    assert(!f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::greater_equal<> F2;
+    const F2 f2 = F2();
+    assert(f2(36, 36));
+    assert(f2(36, 6));
+    assert(!f2(6, 36));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(6, 36.0));
+    assert(!f2(6.0, 36));
+
+    constexpr bool foo = std::greater_equal<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::greater_equal<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/comparisons/less.pass.cpp b/final/test/utilities/function.objects/comparisons/less.pass.cpp
new file mode 100644
index 0000000..99cdd12
--- /dev/null
+++ b/final/test/utilities/function.objects/comparisons/less.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::less<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert(!f(36, 6));
+    assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::less<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert(!f2(36, 6));
+    assert( f2(6, 36));
+    assert(!f2(36, 6.0));
+    assert(!f2(36.0, 6));
+    assert( f2(6, 36.0));
+    assert( f2(6.0, 36));
+
+    constexpr bool foo = std::less<int> () (36, 36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::less<> () (36.0, 36);
+    static_assert ( !bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/comparisons/less_equal.pass.cpp b/final/test/utilities/function.objects/comparisons/less_equal.pass.cpp
new file mode 100644
index 0000000..116906e
--- /dev/null
+++ b/final/test/utilities/function.objects/comparisons/less_equal.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// less_equal
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::less_equal<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(!f(36, 6));
+    assert(f(6, 36));
+#if _LIBCPP_STD_VER > 11
+    typedef std::less_equal<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert(!f2(36, 6));
+    assert( f2(6, 36));
+    assert(!f2(36, 6.0));
+    assert(!f2(36.0, 6));
+    assert( f2(6, 36.0));
+    assert( f2(6.0, 36));
+
+    constexpr bool foo = std::less_equal<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::less_equal<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/final/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp
new file mode 100644
index 0000000..4b61bf8
--- /dev/null
+++ b/final/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not_equal_to
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::not_equal_to<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert(f(36, 6));
+#if _LIBCPP_STD_VER > 11
+    typedef std::not_equal_to<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36, 36));
+    assert( f2(36, 6));
+    assert( f2(36, 6.0));
+    assert( f2(36.0, 6));
+    assert(!f2(36.0, 36));
+    assert(!f2(36, 36.0));
+
+    constexpr bool foo = std::not_equal_to<int> () (36, 36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::not_equal_to<> () (36.0, 36);
+    static_assert ( !bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/comparisons/transparent.pass.cpp b/final/test/utilities/function.objects/comparisons/transparent.pass.cpp
new file mode 100644
index 0000000..41ce4bc
--- /dev/null
+++ b/final/test/utilities/function.objects/comparisons/transparent.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::less<int>>::value, "" );
+    static_assert ( !is_transparent<std::less<std::string>>::value, "" );
+    static_assert (  is_transparent<std::less<void>>::value, "" );
+    static_assert (  is_transparent<std::less<>>::value, "" );
+
+    static_assert ( !is_transparent<std::less_equal<int>>::value, "" );
+    static_assert ( !is_transparent<std::less_equal<std::string>>::value, "" );
+    static_assert (  is_transparent<std::less_equal<void>>::value, "" );
+    static_assert (  is_transparent<std::less_equal<>>::value, "" );
+
+    static_assert ( !is_transparent<std::equal_to<int>>::value, "" );
+    static_assert ( !is_transparent<std::equal_to<std::string>>::value, "" );
+    static_assert (  is_transparent<std::equal_to<void>>::value, "" );
+    static_assert (  is_transparent<std::equal_to<>>::value, "" );
+
+    static_assert ( !is_transparent<std::not_equal_to<int>>::value, "" );
+    static_assert ( !is_transparent<std::not_equal_to<std::string>>::value, "" );
+    static_assert (  is_transparent<std::not_equal_to<void>>::value, "" );
+    static_assert (  is_transparent<std::not_equal_to<>>::value, "" );
+
+    static_assert ( !is_transparent<std::greater<int>>::value, "" );
+    static_assert ( !is_transparent<std::greater<std::string>>::value, "" );
+    static_assert (  is_transparent<std::greater<void>>::value, "" );
+    static_assert (  is_transparent<std::greater<>>::value, "" );
+
+    static_assert ( !is_transparent<std::greater_equal<int>>::value, "" );
+    static_assert ( !is_transparent<std::greater_equal<std::string>>::value, "" );
+    static_assert (  is_transparent<std::greater_equal<void>>::value, "" );
+    static_assert (  is_transparent<std::greater_equal<>>::value, "" );
+
+#endif
+
+    return 0;
+    }
diff --git a/final/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp b/final/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/function.objects/func.memfn/member_data.fail.cpp b/final/test/utilities/function.objects/func.memfn/member_data.fail.cpp
new file mode 100644
index 0000000..5e748c9
--- /dev/null
+++ b/final/test/utilities/function.objects/func.memfn/member_data.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    double data_;
+};
+
+template <class F>
+void
+test(F f)
+{
+    {
+    A a;
+    f(a) = 5;
+    assert(a.data_ == 5);
+    A* ap = &a;
+    f(ap) = 6;
+    assert(a.data_ == 6);
+    const A* cap = ap;
+    assert(f(cap) == f(ap));
+    f(cap) = 7;
+    }
+}
+
+int main()
+{
+    test(std::mem_fn(&A::data_));
+}
diff --git a/final/test/utilities/function.objects/func.memfn/member_data.pass.cpp b/final/test/utilities/function.objects/func.memfn/member_data.pass.cpp
new file mode 100644
index 0000000..dff211c
--- /dev/null
+++ b/final/test/utilities/function.objects/func.memfn/member_data.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T> unspecified mem_fn(R T::* pm);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    double data_;
+};
+
+template <class F>
+void
+test(F f)
+{
+    {
+    A a;
+    f(a) = 5;
+    assert(a.data_ == 5);
+    A* ap = &a;
+    f(ap) = 6;
+    assert(a.data_ == 6);
+    const A* cap = ap;
+    assert(f(cap) == f(ap));
+    const F& cf = f;
+    assert(cf(ap) == f(ap));
+    }
+}
+
+int main()
+{
+    test(std::mem_fn(&A::data_));
+}
diff --git a/final/test/utilities/function.objects/func.memfn/member_function.pass.cpp b/final/test/utilities/function.objects/func.memfn/member_function.pass.cpp
new file mode 100644
index 0000000..4096bd8
--- /dev/null
+++ b/final/test/utilities/function.objects/func.memfn/member_function.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...));
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() {return 'a';}
+    char test1(int) {return 'b';}
+    char test2(int, double) {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}
diff --git a/final/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp b/final/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp
new file mode 100644
index 0000000..be22443
--- /dev/null
+++ b/final/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...) const);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() const {return 'a';}
+    char test1(int) const {return 'b';}
+    char test2(int, double) const {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    const A* cap = &a;
+    assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    const A* cap = &a;
+    assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    const A* cap = &a;
+    assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}
diff --git a/final/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp b/final/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
new file mode 100644
index 0000000..329ac16
--- /dev/null
+++ b/final/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...) const volatile);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() const volatile {return 'a';}
+    char test1(int) const volatile {return 'b';}
+    char test2(int, double) const volatile {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    const volatile A* cap = &a;
+    assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    const volatile A* cap = &a;
+    assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    const volatile A* cap = &a;
+    assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}
diff --git a/final/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp b/final/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
new file mode 100644
index 0000000..743ded9
--- /dev/null
+++ b/final/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, class T, CopyConstructible... Args>
+//   unspecified mem_fn(R (T::* pm)(Args...) volatile);
+
+#include <functional>
+#include <cassert>
+
+struct A
+{
+    char test0() volatile {return 'a';}
+    char test1(int) volatile {return 'b';}
+    char test2(int, double) volatile {return 'c';}
+};
+
+template <class F>
+void
+test0(F f)
+{
+    {
+    A a;
+    assert(f(a) == 'a');
+    A* ap = &a;
+    assert(f(ap) == 'a');
+    volatile A* cap = &a;
+    assert(f(cap) == 'a');
+    const F& cf = f;
+    assert(cf(ap) == 'a');
+    }
+}
+
+template <class F>
+void
+test1(F f)
+{
+    {
+    A a;
+    assert(f(a, 1) == 'b');
+    A* ap = &a;
+    assert(f(ap, 2) == 'b');
+    volatile A* cap = &a;
+    assert(f(cap, 2) == 'b');
+    const F& cf = f;
+    assert(cf(ap, 2) == 'b');
+    }
+}
+
+template <class F>
+void
+test2(F f)
+{
+    {
+    A a;
+    assert(f(a, 1, 2) == 'c');
+    A* ap = &a;
+    assert(f(ap, 2, 3.5) == 'c');
+    volatile A* cap = &a;
+    assert(f(cap, 2, 3.5) == 'c');
+    const F& cf = f;
+    assert(cf(ap, 2, 3.5) == 'c');
+    }
+}
+
+int main()
+{
+    test0(std::mem_fn(&A::test0));
+    test1(std::mem_fn(&A::test1));
+    test2(std::mem_fn(&A::test2));
+}
diff --git a/final/test/utilities/function.objects/func.require/binary_function.pass.cpp b/final/test/utilities/function.objects/func.require/binary_function.pass.cpp
new file mode 100644
index 0000000..fa7afb2
--- /dev/null
+++ b/final/test/utilities/function.objects/func.require/binary_function.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// binary_function
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    typedef std::binary_function<int, short, bool> bf;
+    static_assert((std::is_same<bf::first_argument_type, int>::value), "");
+    static_assert((std::is_same<bf::second_argument_type, short>::value), "");
+    static_assert((std::is_same<bf::result_type, bool>::value), "");
+}
diff --git a/final/test/utilities/function.objects/func.require/invoke.pass.cpp b/final/test/utilities/function.objects/func.require/invoke.pass.cpp
new file mode 100644
index 0000000..2568163
--- /dev/null
+++ b/final/test/utilities/function.objects/func.require/invoke.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// [func.require]
+
+// INVOKE
+#if __cplusplus < 201103L
+int main () {}      // no __invoke in C++03
+#else
+
+#include <type_traits>
+
+template <typename T, int N>
+struct Array
+{
+    typedef T type[N];
+};
+
+struct Type
+{
+    Array<char, 1>::type& f1();
+    Array<char, 2>::type& f2() const;
+    
+    Array<char, 1>::type& g1()        &;
+    Array<char, 2>::type& g2() const  &;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Array<char, 3>::type& g3()       &&;
+    Array<char, 4>::type& g4() const &&;
+#endif
+};
+
+int main()
+{
+    static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type        >())) == 1, "");
+    static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const  >())) == 2, "");
+    
+    static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type       &>())) == 1, "");
+    static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const &>())) == 2, "");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type      &&>())) == 3, "");
+    static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, "");
+#endif
+}
+#endif
diff --git a/final/test/utilities/function.objects/func.require/unary_function.pass.cpp b/final/test/utilities/function.objects/func.require/unary_function.pass.cpp
new file mode 100644
index 0000000..f14b2d3
--- /dev/null
+++ b/final/test/utilities/function.objects/func.require/unary_function.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// unary_function
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    typedef std::unary_function<int, bool> uf;
+    static_assert((std::is_same<uf::argument_type, int>::value), "");
+    static_assert((std::is_same<uf::result_type, bool>::value), "");
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
new file mode 100644
index 0000000..357a3b4
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Class bad_function_call
+
+// class bad_function_call
+//     : public exception
+// {
+// public:
+//   // 20.7.16.1.1, constructor:
+//   bad_function_call();
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_function_call>::value), "");
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
new file mode 100644
index 0000000..f5ab948
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// Class bad_function_call
+
+// bad_function_call();
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    std::bad_function_call ex;
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
new file mode 100644
index 0000000..44252b4
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp
@@ -0,0 +1,135 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template <MoveConstructible  R, MoveConstructible ... ArgTypes>
+//   void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    explicit A(int j)
+    {
+        ++count;
+        data_[0] = j;
+    }
+
+    A(const A& a)
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = a.data_[i];
+    }
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int id() const {return data_[0];}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+int h(int) {return 1;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = A(2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 1);
+    assert(f2.target<A>()->id() == 2);
+    swap(f1, f2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 2);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = g;
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    swap(f1, f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = A(1);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    swap(f1, f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = h;
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(*f2.target<int(*)(int)>() == h);
+    swap(f1, f2);
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == h);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp
new file mode 100644
index 0000000..829763f
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// explicit operator bool() const
+
+#include <functional>
+#include <cassert>
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f;
+    assert(!f);
+    f = g;
+    assert(f);
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
new file mode 100644
index 0000000..92f99cd
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(nullptr_t);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = (int (*)(int))0;
+    assert(!f);
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(const A*, int)> f = &A::foo;
+    assert(f);
+    assert(new_called == 0);
+    assert(f.target<int (A::*)(int) const>() != 0);
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
new file mode 100644
index 0000000..de16998
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F>
+//   requires CopyConstructible<F> && Callable<F, ArgTypes..>
+//         && Convertible<Callable<F, ArgTypes...>::result_type
+//   operator=(F f);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    f = (int (*)(int))0;
+    assert(!f);
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(const A*, int)> f;
+    f = &A::foo;
+    assert(f);
+    assert(new_called == 0);
+    assert(f.target<int (A::*)(int) const>() != 0);
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
new file mode 100644
index 0000000..c8f4178
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_incomplete.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F> function(F);
+
+// Allow incomplete argument types in the __is_callable check
+
+#include <functional>
+
+struct X{
+    typedef std::function<void(X&)> callback_type;
+    virtual ~X() {}
+private:
+    callback_type _cb;
+};
+
+int main()
+{
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
new file mode 100644
index 0000000..4feac30
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int>());
+    assert(!f);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
new file mode 100644
index 0000000..5990922
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> function(allocator_arg_t, const A&, F);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+class Foo {
+public:
+  void bar(int k) { }
+};
+
+int main()
+{
+    {
+    std::function<int(int)> f(std::allocator_arg, test_allocator<A>(), A());
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int(*)(int)>(), g);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int(*)(int)>(),
+                              (int (*)(int))0);
+    assert(!f);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(const A*, int)> f(std::allocator_arg,
+                                        test_allocator<int(A::*)(int)const>(),
+                                        &A::foo);
+    assert(f);
+    assert(f.target<int (A::*)(int) const>() != 0);
+    }
+    {
+    Foo f;
+    std::function<void(int)> fun = std::bind(&Foo::bar, &f, std::placeholders::_1);
+    fun(10);
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
new file mode 100644
index 0000000..f758a4d
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, const function&);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), f);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<int(*)(int)>(), f);
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    assert(new_called == 0);
+    non_default_test_allocator<std::function<int(int)>> al(1);
+    std::function<int(int)> f2(std::allocator_arg, al, g);
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<int>(), f);
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f2.target<A>() == 0);
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
new file mode 100644
index 0000000..956136b
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+    std::function<int(int)> f(std::allocator_arg, test_allocator<int>(), nullptr);
+    assert(!f);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
new file mode 100644
index 0000000..570c27e
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class A> function(allocator_arg_t, const A&, function&&);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), std::move(f));
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
new file mode 100644
index 0000000..cf7b963
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(const function& f);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2 = f;
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f2.target<A>() == 0);
+    }
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(!f);
+    std::function<long(int)> g = f;
+    assert(new_called == 0);
+    assert(g.target<long(*)(int)>() == 0);
+    assert(g.target<A>() == 0);
+    assert(!g);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2 = std::move(f);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
new file mode 100644
index 0000000..544ec43
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function& operator=(const function& f);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2;
+    f2 = f;
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2;
+    f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>());
+    assert(f2.target<A>() == 0);
+    }
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    std::function<int(int)> f2;
+    f2 = f;
+    assert(new_called == 0);
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f2.target<A>() == 0);
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    std::function<int(int)> f2;
+    f2 = std::move(f);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f2.target<A>());
+    assert(f2.target<int(*)(int)>() == 0);
+    assert(f.target<A>() == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
new file mode 100644
index 0000000..83d61b6
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// explicit function();
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::function<int(int)> f;
+    assert(!f);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
new file mode 100644
index 0000000..7099c45
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R()>
+
+// template<class F> function(F);
+
+#define _LIBCPP_HAS_NO_VARIADICS
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::function<void()> f(static_cast<void(*)()>(0));
+    assert(!f);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
new file mode 100644
index 0000000..f0d6402
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function(nullptr_t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::function<int(int)> f(nullptr);
+    assert(!f);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
new file mode 100644
index 0000000..12a2b6e
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// function& operator=(nullptr_t);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f.target<A>());
+    f = nullptr;
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(f.target<A>() == 0);
+    }
+    {
+    std::function<int(int)> f = g;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    f = nullptr;
+    assert(new_called == 0);
+    assert(f.target<int(*)(int)>() == 0);
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
new file mode 100644
index 0000000..6dcd285
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+// member data pointer:  cv qualifiers should transfer from argument to return type
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    A_int_1 a;
+    std::function<int& (const A_int_1*)> r2(fp);
+    const A_int_1* ap = &a;
+    assert(r2(ap) == 6);
+    r2(ap) = 7;
+    assert(r2(ap) == 7);
+    }
+}
+
+int main()
+{
+    test_int_1();
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
new file mode 100644
index 0000000..31b80c3
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp
@@ -0,0 +1,335 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {++count;}
+};
+
+void
+test_void_1()
+{
+    int save_count = count;
+    // function
+    {
+    std::function<void (int)> r1(f_void_1);
+    int i = 2;
+    r1(i);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    std::function<void (int)> r1(fp);
+    int i = 3;
+    r1(i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    std::function<void (int)> r1(a0);
+    int i = 4;
+    r1(i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::function<void (A_void_1)> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    std::function<void (A_void_1*)> r2 = fp;
+    r2(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::function<void (A_void_1)> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    std::function<void (A_void_1*)> r2(fp);
+    A_void_1* ap = &a;
+    r2(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // function
+    {
+    std::function<int (int)> r1(f_int_1);
+    int i = 2;
+    assert(r1(i) == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    std::function<int (int)> r1(fp);
+    int i = 3;
+    assert(r1(i) == 4);
+    }
+    // functor
+    {
+    A_int_1 a0;
+    std::function<int (int)> r1(a0);
+    int i = 4;
+    assert(r1(i) == 3);
+    }
+    // member function pointer
+    {
+    int (A_int_1::*fp)() = &A_int_1::mem1;
+    std::function<int (A_int_1)> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 3);
+    std::function<int (A_int_1*)> r2(fp);
+    A_int_1* ap = &a;
+    assert(r2(ap) == 3);
+    }
+    // const member function pointer
+    {
+    int (A_int_1::*fp)() const = &A_int_1::mem2;
+    std::function<int (A_int_1)> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 4);
+    std::function<int (A_int_1*)> r2(fp);
+    A_int_1* ap = &a;
+    assert(r2(ap) == 4);
+    }
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    std::function<int& (A_int_1&)> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 5);
+    r1(a) = 6;
+    assert(r1(a) == 6);
+    std::function<int& (A_int_1*)> r2(fp);
+    A_int_1* ap = &a;
+    assert(r2(ap) == 6);
+    r2(ap) = 7;
+    assert(r2(ap) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    int save_count = count;
+    // function
+    {
+    std::function<void (int, int)> r1(f_void_2);
+    int i = 2;
+    int j = 3;
+    r1(i, j);
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int, int) = f_void_2;
+    std::function<void (int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    r1(i, j);
+    assert(count == save_count+7);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_2 a0;
+    std::function<void (int, int)> r1(a0);
+    int i = 4;
+    int j = 5;
+    r1(i, j);
+    assert(count == save_count+9);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_2::*fp)(int) = &A_void_2::mem1;
+    std::function<void (A_void_2, int)> r1(fp);
+    A_void_2 a;
+    int i = 3;
+    r1(a, i);
+    assert(count == save_count+3);
+    save_count = count;
+    std::function<void (A_void_2*, int)> r2(fp);
+    A_void_2* ap = &a;
+    r2(ap, i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_2::*fp)(int) const = &A_void_2::mem2;
+    std::function<void (A_void_2, int)> r1(fp);
+    A_void_2 a;
+    int i = 4;
+    r1(a, i);
+    assert(count == save_count+4);
+    save_count = count;
+    std::function<void (A_void_2*, int)> r2(fp);
+    A_void_2* ap = &a;
+    r2(ap, i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+}
+
+// 2 arg, return int
+
+int f_int_2(int i, int j)
+{
+    return i+j;
+}
+
+struct A_int_2
+{
+    int operator()(int i, int j)
+    {
+        return i+j;
+    }
+
+    int mem1(int i) {return i+1;}
+    int mem2(int i) const {return i+2;}
+};
+
+void
+testint_2()
+{
+    // function
+    {
+    std::function<int (int, int)> r1(f_int_2);
+    int i = 2;
+    int j = 3;
+    assert(r1(i, j) == i+j);
+    }
+    // function pointer
+    {
+    int (*fp)(int, int) = f_int_2;
+    std::function<int (int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    assert(r1(i, j) == i+j);
+    }
+    // functor
+    {
+    A_int_2 a0;
+    std::function<int (int, int)> r1(a0);
+    int i = 4;
+    int j = 5;
+    assert(r1(i, j) == i+j);
+    }
+    // member function pointer
+    {
+    int(A_int_2::*fp)(int) = &A_int_2::mem1;
+    std::function<int (A_int_2, int)> r1(fp);
+    A_int_2 a;
+    int i = 3;
+    assert(r1(a, i) == i+1);
+    std::function<int (A_int_2*, int)> r2(fp);
+    A_int_2* ap = &a;
+    assert(r2(ap, i) == i+1);
+    }
+    // const member function pointer
+    {
+    int (A_int_2::*fp)(int) const = &A_int_2::mem2;
+    std::function<int (A_int_2, int)> r1(fp);
+    A_int_2 a;
+    int i = 4;
+    assert(r1(a, i) == i+2);
+    std::function<int (A_int_2*, int)> r2(fp);
+    A_int_2* ap = &a;
+    assert(r2(ap, i) == i+2);
+    }
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+    testint_2();
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
new file mode 100644
index 0000000..67b4ec2
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return int
+
+int count = 0;
+
+int f_int_0()
+{
+    return 3;
+}
+
+struct A_int_0
+{
+    int operator()() {return 4;}
+};
+
+void
+test_int_0()
+{
+    // function
+    {
+    std::function<int ()> r1(f_int_0);
+    assert(r1() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)() = f_int_0;
+    std::function<int ()> r1(fp);
+    assert(r1() == 3);
+    }
+    // functor
+    {
+    A_int_0 a0;
+    std::function<int ()> r1(a0);
+    assert(r1() == 4);
+    }
+}
+
+int main()
+{
+    test_int_0();
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
new file mode 100644
index 0000000..a820cb1
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// R operator()(ArgTypes... args) const
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+// 0 args, return void
+
+int count = 0;
+
+void f_void_0()
+{
+    ++count;
+}
+
+struct A_void_0
+{
+    void operator()() {++count;}
+};
+
+void
+test_void_0()
+{
+    int save_count = count;
+    // function
+    {
+    std::function<void ()> r1(f_void_0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)() = f_void_0;
+    std::function<void ()> r1(fp);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_0 a0;
+    std::function<void ()> r1(a0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+int main()
+{
+    test_void_0();
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp
new file mode 100644
index 0000000..e9ecfa5
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<class F, class A> void assign(F&&, const A&);
+
+#include <functional>
+#include <cassert>
+
+#include "test_allocator.h"
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::function<int(int)> f;
+    f.assign(A(), test_allocator<A>());
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
new file mode 100644
index 0000000..dc56574
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// void swap(function& other);
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    explicit A(int j)
+    {
+        ++count;
+        data_[0] = j;
+    }
+
+    A(const A& a)
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = a.data_[i];
+    }
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int id() const {return data_[0];}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+int h(int) {return 1;}
+
+int main()
+{
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = A(2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 1);
+    assert(f2.target<A>()->id() == 2);
+    f1.swap(f2);
+    assert(A::count == 2);
+    assert(new_called == 2);
+    assert(f1.target<A>()->id() == 2);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = A(1);
+    std::function<int(int)> f2 = g;
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    f1.swap(f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = A(1);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(f2.target<A>()->id() == 1);
+    f1.swap(f2);
+    assert(A::count == 1);
+    assert(new_called == 1);
+    assert(f1.target<A>()->id() == 1);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+    {
+    std::function<int(int)> f1 = g;
+    std::function<int(int)> f2 = h;
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == g);
+    assert(*f2.target<int(*)(int)>() == h);
+    f1.swap(f2);
+    assert(A::count == 0);
+    assert(new_called == 0);
+    assert(*f1.target<int(*)(int)>() == h);
+    assert(*f2.target<int(*)(int)>() == g);
+    }
+    assert(A::count == 0);
+    assert(new_called == 0);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp
new file mode 100644
index 0000000..5bca096
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+//   bool operator==(const function<R(ArgTypes...)>&, nullptr_t);
+//
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+//   bool operator==(nullptr_t, const function<R(ArgTypes...)>&);
+//
+// template <MoveConstructible R, MoveConstructible ... ArgTypes>
+//   bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
+//
+// template <MoveConstructible  R, MoveConstructible ... ArgTypes>
+//   bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
+
+#include <functional>
+#include <cassert>
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f;
+    assert(f == nullptr);
+    assert(nullptr == f);
+    f = g;
+    assert(f != nullptr);
+    assert(nullptr != f);
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
new file mode 100644
index 0000000..53476a2
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// template<typename T>
+//   requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
+//   T*
+//   target();
+// template<typename T>
+//   requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R>
+//   const T*
+//   target() const;
+
+#include <functional>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::function<int(int)> f = g;
+    assert(A::count == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    const std::function<int(int)> f = A();
+    assert(A::count == 1);
+    assert(f.target<A>());
+    assert(f.target<int(*)(int)>() == 0);
+    }
+    assert(A::count == 0);
+    {
+    const std::function<int(int)> f = g;
+    assert(A::count == 0);
+    assert(f.target<int(*)(int)>());
+    assert(f.target<A>() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
new file mode 100644
index 0000000..7605e3b
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// class function<R(ArgTypes...)>
+
+// const std::type_info& target_type() const;
+
+#include <functional>
+#include <typeinfo>
+#include <cassert>
+
+class A
+{
+    int data_[10];
+public:
+    static int count;
+
+    A()
+    {
+        ++count;
+        for (int i = 0; i < 10; ++i)
+            data_[i] = i;
+    }
+
+    A(const A&) {++count;}
+
+    ~A() {--count;}
+
+    int operator()(int i) const
+    {
+        for (int j = 0; j < 10; ++j)
+            i += data_[j];
+        return i;
+    }
+
+    int foo(int) const {return 1;}
+};
+
+int A::count = 0;
+
+int g(int) {return 0;}
+
+int main()
+{
+    {
+    std::function<int(int)> f = A();
+    assert(f.target_type() == typeid(A));
+    }
+    {
+    std::function<int(int)> f;
+    assert(f.target_type() == typeid(void));
+    }
+}
diff --git a/final/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp b/final/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
new file mode 100644
index 0000000..6c70db4
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template<Returnable R, CopyConstructible... ArgTypes>
+// class function<R(ArgTypes...)>
+//   : public unary_function<T1, R>      // iff sizeof...(ArgTypes) == 1 and
+//                                       // ArgTypes contains T1
+//   : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and
+//                                       // ArgTypes contains T1 and T2
+// {
+// public:
+//     typedef R result_type;
+//     ...
+// };
+
+#include <functional>
+#include <type_traits>
+
+int main()
+{
+    static_assert((!std::is_base_of<std::unary_function <int, int>,
+                                           std::function<int()> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, int>,
+                                           std::function<int()> >::value), "");
+    static_assert(( std::is_same<          std::function<int()>::result_type,
+                                                         int>::value), "");
+
+    static_assert(( std::is_base_of<std::unary_function <int, double>,
+                                           std::function<double(int)> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, double>,
+                                           std::function<double(int)> >::value), "");
+    static_assert(( std::is_same<          std::function<double(int)>::result_type,
+                                                         double>::value), "");
+
+    static_assert((!std::is_base_of<std::unary_function <int, double>,
+                                           std::function<double(int, char)> >::value), "");
+    static_assert(( std::is_base_of<std::binary_function<int, char, double>,
+                                           std::function<double(int, char)> >::value), "");
+    static_assert(( std::is_same<          std::function<double(int, char)>::result_type,
+                                                         double>::value), "");
+}
diff --git a/final/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp b/final/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/function.objects/logical.operations/logical_and.pass.cpp b/final/test/utilities/function.objects/logical.operations/logical_and.pass.cpp
new file mode 100644
index 0000000..c7b03cc
--- /dev/null
+++ b/final/test/utilities/function.objects/logical.operations/logical_and.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_and
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_and<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(!f(36, 0));
+    assert(!f(0, 36));
+    assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_and<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert( f2(36, 36L));
+    assert( f2(36L, 36));
+    assert(!f2(36, 0));
+    assert(!f2(0, 36));
+    assert( f2(36, 36L));
+    assert(!f2(36, 0L));
+    assert(!f2(0, 36L));
+    assert( f2(36L, 36));
+    assert(!f2(36L, 0));
+    assert(!f2(0L, 36));
+
+    constexpr bool foo = std::logical_and<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::logical_and<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/logical.operations/logical_not.pass.cpp b/final/test/utilities/function.objects/logical.operations/logical_not.pass.cpp
new file mode 100644
index 0000000..12b3543
--- /dev/null
+++ b/final/test/utilities/function.objects/logical.operations/logical_not.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_not
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_not<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
+    assert(!f(36));
+    assert(f(0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_not<> F2;
+    const F2 f2 = F2();
+    assert(!f2(36));
+    assert( f2(0));
+    assert(!f2(36L));
+    assert( f2(0L));
+
+    constexpr bool foo = std::logical_not<int> () (36);
+    static_assert ( !foo, "" );
+
+    constexpr bool bar = std::logical_not<> () (36);
+    static_assert ( !bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/logical.operations/logical_or.pass.cpp b/final/test/utilities/function.objects/logical.operations/logical_or.pass.cpp
new file mode 100644
index 0000000..8b5420d
--- /dev/null
+++ b/final/test/utilities/function.objects/logical.operations/logical_or.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// logical_or
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_or<int> F;
+    const F f = F();
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(f(36, 36));
+    assert(f(36, 0));
+    assert(f(0, 36));
+    assert(!f(0, 0));
+#if _LIBCPP_STD_VER > 11
+    typedef std::logical_or<> F2;
+    const F2 f2 = F2();
+    assert( f2(36, 36));
+    assert( f2(36, 36L));
+    assert( f2(36L, 36));
+    assert( f2(36, 0));
+    assert( f2(0, 36));
+    assert( f2(36, 0L));
+    assert( f2(0, 36L));
+    assert(!f2(0, 0));
+    assert(!f2(0, 0L));
+    assert(!f2(0L, 0));
+
+    constexpr bool foo = std::logical_or<int> () (36, 36);
+    static_assert ( foo, "" );
+
+    constexpr bool bar = std::logical_or<> () (36.0, 36);
+    static_assert ( bar, "" );
+#endif
+}
diff --git a/final/test/utilities/function.objects/logical.operations/transparent.pass.cpp b/final/test/utilities/function.objects/logical.operations/transparent.pass.cpp
new file mode 100644
index 0000000..6e3b7a2
--- /dev/null
+++ b/final/test/utilities/function.objects/logical.operations/transparent.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <functional>
+#include <string>
+
+template <class _Tp>
+struct is_transparent
+{
+private:
+    struct __two {char __lx; char __lxx;};
+    template <class _Up> static __two __test(...);
+    template <class _Up> static char __test(typename _Up::is_transparent* = 0);
+public:
+    static const bool value = sizeof(__test<_Tp>(0)) == 1;
+};
+
+
+int main () {
+#if _LIBCPP_STD_VER > 11
+
+    static_assert ( !is_transparent<std::logical_and<int>>::value, "" );
+    static_assert ( !is_transparent<std::logical_and<std::string>>::value, "" );
+    static_assert (  is_transparent<std::logical_and<void>>::value, "" );
+    static_assert (  is_transparent<std::logical_and<>>::value, "" );
+
+    static_assert ( !is_transparent<std::logical_or<int>>::value, "" );
+    static_assert ( !is_transparent<std::logical_or<std::string>>::value, "" );
+    static_assert (  is_transparent<std::logical_or<void>>::value, "" );
+    static_assert (  is_transparent<std::logical_or<>>::value, "" );
+
+    static_assert ( !is_transparent<std::logical_not<int>>::value, "" );
+    static_assert ( !is_transparent<std::logical_not<std::string>>::value, "" );
+    static_assert (  is_transparent<std::logical_not<void>>::value, "" );
+    static_assert (  is_transparent<std::logical_not<>>::value, "" );
+    
+#endif
+
+    return 0;
+    }
diff --git a/final/test/utilities/function.objects/negators/binary_negate.pass.cpp b/final/test/utilities/function.objects/negators/binary_negate.pass.cpp
new file mode 100644
index 0000000..e306708
--- /dev/null
+++ b/final/test/utilities/function.objects/negators/binary_negate.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// binary_negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::binary_negate<std::logical_and<int> > F;
+    const F f = F(std::logical_and<int>());
+    static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), "");
+    assert(!f(36, 36));
+    assert( f(36, 0));
+    assert( f(0, 36));
+    assert( f(0, 0));
+}
diff --git a/final/test/utilities/function.objects/negators/not1.pass.cpp b/final/test/utilities/function.objects/negators/not1.pass.cpp
new file mode 100644
index 0000000..f6ac7a4
--- /dev/null
+++ b/final/test/utilities/function.objects/negators/not1.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not1
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_not<int> F;
+    assert(std::not1(F())(36));
+    assert(!std::not1(F())(0));
+}
diff --git a/final/test/utilities/function.objects/negators/not2.pass.cpp b/final/test/utilities/function.objects/negators/not2.pass.cpp
new file mode 100644
index 0000000..7541753
--- /dev/null
+++ b/final/test/utilities/function.objects/negators/not2.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// not2
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    typedef std::logical_and<int> F;
+    assert(!std::not2(F())(36, 36));
+    assert( std::not2(F())(36, 0));
+    assert( std::not2(F())(0, 36));
+    assert( std::not2(F())(0, 0));
+}
diff --git a/final/test/utilities/function.objects/negators/unary_negate.pass.cpp b/final/test/utilities/function.objects/negators/unary_negate.pass.cpp
new file mode 100644
index 0000000..2aa4f0a
--- /dev/null
+++ b/final/test/utilities/function.objects/negators/unary_negate.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// unary_negate
+
+#include <functional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::unary_negate<std::logical_not<int> > F;
+    const F f = F(std::logical_not<int>());
+    static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
+    assert(f(36));
+    assert(!f(0));
+}
diff --git a/final/test/utilities/function.objects/refwrap/binary.pass.cpp b/final/test/utilities/function.objects/refwrap/binary.pass.cpp
new file mode 100644
index 0000000..579e81f
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/binary.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for deriving from binary_function
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+class functor2
+    : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+    typedef float result_type;
+};
+
+class functor4
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+};
+
+struct C
+{
+    typedef int argument_type;
+    typedef int result_type;
+};
+
+int main()
+{
+    static_assert((!std::is_base_of<std::binary_function<int, char, int>,
+                                    std::reference_wrapper<functor1> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<char, int, double>,
+                                   std::reference_wrapper<functor2> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<char, int, double>,
+                                   std::reference_wrapper<functor3> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<char, int, double>,
+                                   std::reference_wrapper<functor4> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, int>,
+                                    std::reference_wrapper<C> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float ()> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                   std::reference_wrapper<float (int)> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float (int, int)> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float(*)()> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<int, int, float>,
+                                   std::reference_wrapper<float(*)(int)> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<int, int, float>,
+                                    std::reference_wrapper<float(*)(int, int)> >::value), "");
+    static_assert((!std::is_base_of<std::binary_function<C*, int, float>,
+                                   std::reference_wrapper<float(C::*)()> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<C*, int, float>,
+                                   std::reference_wrapper<float(C::*)(int)> >::value), "");
+    static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
+                                   std::reference_wrapper<float(C::*)(int) const volatile> >::value), "");
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
new file mode 100644
index 0000000..df0b55a
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// operator T& () const;
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    T& r2 = r;
+    assert(&r2 == &t);
+}
+
+void f() {}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test(f);
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
new file mode 100644
index 0000000..122716a
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper& operator=(const reference_wrapper<T>& x);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    T t2 = t;
+    std::reference_wrapper<T> r2(t2);
+    r2 = r;
+    assert(&r2.get() == &t);
+}
+
+void f() {}
+void g() {}
+
+void
+test_function()
+{
+    std::reference_wrapper<void ()> r(f);
+    std::reference_wrapper<void ()> r2(g);
+    r2 = r;
+    assert(&r2.get() == &f);
+}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test_function();
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
new file mode 100644
index 0000000..721a442
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(const reference_wrapper<T>& x);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    std::reference_wrapper<T> r2 = r;
+    assert(&r2.get() == &t);
+}
+
+void f() {}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test(f);
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/final/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
new file mode 100644
index 0000000..ba46946
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(T&&) = delete;
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    std::reference_wrapper<const int> r(3);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
new file mode 100644
index 0000000..564a3f7
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// reference_wrapper(T& t);
+
+#include <functional>
+#include <cassert>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+template <class T>
+void
+test(T& t)
+{
+    std::reference_wrapper<T> r(t);
+    assert(&r.get() == &t);
+}
+
+void f() {}
+
+int main()
+{
+    void (*fp)() = f;
+    test(fp);
+    test(f);
+    functor1 f1;
+    test(f1);
+    int i = 0;
+    test(i);
+    const int j = 0;
+    test(j);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
new file mode 100644
index 0000000..f2ffd44
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<const T> cref(const T& t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    std::reference_wrapper<const int> r = std::cref(i);
+    assert(&r.get() == &i);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
new file mode 100644
index 0000000..7587526
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<const T> cref(reference_wrapper<T> t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    const int i = 0;
+    std::reference_wrapper<const int> r1 = std::cref(i);
+    std::reference_wrapper<const int> r2 = std::cref(r1);
+    assert(&r2.get() == &i);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
new file mode 100644
index 0000000..86a5696
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(T& t);
+
+// Don't allow binding to a temp
+
+#include <functional>
+
+struct A {};
+
+const A source() {return A();}
+
+int main()
+{
+    std::reference_wrapper<const A> r = std::ref(source());
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
new file mode 100644
index 0000000..39aa484
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(T& t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    std::reference_wrapper<int> r = std::ref(i);
+    assert(&r.get() == &i);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
new file mode 100644
index 0000000..1eb92aa
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <ObjectType T> reference_wrapper<T> ref(reference_wrapper<T>t);
+
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    std::reference_wrapper<int> r1 = std::ref(i);
+    std::reference_wrapper<int> r2 = std::ref(r1);
+    assert(&r2.get() == &i);
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
new file mode 100644
index 0000000..5515627
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// member data pointer:  cv qualifiers should transfer from argument to return type
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    std::reference_wrapper<int A_int_1::*> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 5);
+    r1(a) = 6;
+    assert(r1(a) == 6);
+    const A_int_1* ap = &a;
+    assert(r1(ap) == 6);
+    r1(ap) = 7;
+    assert(r1(ap) == 7);
+    }
+}
+
+int main()
+{
+    test_int_1();
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
new file mode 100644
index 0000000..a9edf00
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp
@@ -0,0 +1,329 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+int count = 0;
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+
+    void mem1() {++count;}
+    void mem2() const {++count;}
+};
+
+void
+test_void_1()
+{
+    int save_count = count;
+    // function
+    {
+    std::reference_wrapper<void (int)> r1(f_void_1);
+    int i = 2;
+    r1(i);
+    assert(count == save_count+2);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int) = f_void_1;
+    std::reference_wrapper<void (*)(int)> r1(fp);
+    int i = 3;
+    r1(i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_1 a0;
+    std::reference_wrapper<A_void_1> r1(a0);
+    int i = 4;
+    r1(i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_1::*fp)() = &A_void_1::mem1;
+    std::reference_wrapper<void (A_void_1::*)()> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    r1(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_1::*fp)() const = &A_void_1::mem2;
+    std::reference_wrapper<void (A_void_1::*)() const> r1(fp);
+    A_void_1 a;
+    r1(a);
+    assert(count == save_count+1);
+    save_count = count;
+    A_void_1* ap = &a;
+    r1(ap);
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+// 1 arg, return int
+
+int f_int_1(int i)
+{
+    return i + 1;
+}
+
+struct A_int_1
+{
+    A_int_1() : data_(5) {}
+    int operator()(int i)
+    {
+        return i - 1;
+    }
+
+    int mem1() {return 3;}
+    int mem2() const {return 4;}
+    int data_;
+};
+
+void
+test_int_1()
+{
+    // function
+    {
+    std::reference_wrapper<int (int)> r1(f_int_1);
+    int i = 2;
+    assert(r1(i) == 3);
+    }
+    // function pointer
+    {
+    int (*fp)(int) = f_int_1;
+    std::reference_wrapper<int (*)(int)> r1(fp);
+    int i = 3;
+    assert(r1(i) == 4);
+    }
+    // functor
+    {
+    A_int_1 a0;
+    std::reference_wrapper<A_int_1> r1(a0);
+    int i = 4;
+    assert(r1(i) == 3);
+    }
+    // member function pointer
+    {
+    int (A_int_1::*fp)() = &A_int_1::mem1;
+    std::reference_wrapper<int (A_int_1::*)()> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 3);
+    A_int_1* ap = &a;
+    assert(r1(ap) == 3);
+    }
+    // const member function pointer
+    {
+    int (A_int_1::*fp)() const = &A_int_1::mem2;
+    std::reference_wrapper<int (A_int_1::*)() const> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 4);
+    A_int_1* ap = &a;
+    assert(r1(ap) == 4);
+    }
+    // member data pointer
+    {
+    int A_int_1::*fp = &A_int_1::data_;
+    std::reference_wrapper<int A_int_1::*> r1(fp);
+    A_int_1 a;
+    assert(r1(a) == 5);
+    r1(a) = 6;
+    assert(r1(a) == 6);
+    A_int_1* ap = &a;
+    assert(r1(ap) == 6);
+    r1(ap) = 7;
+    assert(r1(ap) == 7);
+    }
+}
+
+// 2 arg, return void
+
+void f_void_2(int i, int j)
+{
+    count += i+j;
+}
+
+struct A_void_2
+{
+    void operator()(int i, int j)
+    {
+        count += i+j;
+    }
+
+    void mem1(int i) {count += i;}
+    void mem2(int i) const {count += i;}
+};
+
+void
+test_void_2()
+{
+    int save_count = count;
+    // function
+    {
+    std::reference_wrapper<void (int, int)> r1(f_void_2);
+    int i = 2;
+    int j = 3;
+    r1(i, j);
+    assert(count == save_count+5);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)(int, int) = f_void_2;
+    std::reference_wrapper<void (*)(int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    r1(i, j);
+    assert(count == save_count+7);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_2 a0;
+    std::reference_wrapper<A_void_2> r1(a0);
+    int i = 4;
+    int j = 5;
+    r1(i, j);
+    assert(count == save_count+9);
+    save_count = count;
+    }
+    // member function pointer
+    {
+    void (A_void_2::*fp)(int) = &A_void_2::mem1;
+    std::reference_wrapper<void (A_void_2::*)(int)> r1(fp);
+    A_void_2 a;
+    int i = 3;
+    r1(a, i);
+    assert(count == save_count+3);
+    save_count = count;
+    A_void_2* ap = &a;
+    r1(ap, i);
+    assert(count == save_count+3);
+    save_count = count;
+    }
+    // const member function pointer
+    {
+    void (A_void_2::*fp)(int) const = &A_void_2::mem2;
+    std::reference_wrapper<void (A_void_2::*)(int) const> r1(fp);
+    A_void_2 a;
+    int i = 4;
+    r1(a, i);
+    assert(count == save_count+4);
+    save_count = count;
+    A_void_2* ap = &a;
+    r1(ap, i);
+    assert(count == save_count+4);
+    save_count = count;
+    }
+}
+
+// 2 arg, return int
+
+int f_int_2(int i, int j)
+{
+    return i+j;
+}
+
+struct A_int_2
+{
+    int operator()(int i, int j)
+    {
+        return i+j;
+    }
+
+    int mem1(int i) {return i+1;}
+    int mem2(int i) const {return i+2;}
+};
+
+void
+testint_2()
+{
+    // function
+    {
+    std::reference_wrapper<int (int, int)> r1(f_int_2);
+    int i = 2;
+    int j = 3;
+    assert(r1(i, j) == i+j);
+    }
+    // function pointer
+    {
+    int (*fp)(int, int) = f_int_2;
+    std::reference_wrapper<int (*)(int, int)> r1(fp);
+    int i = 3;
+    int j = 4;
+    assert(r1(i, j) == i+j);
+    }
+    // functor
+    {
+    A_int_2 a0;
+    std::reference_wrapper<A_int_2> r1(a0);
+    int i = 4;
+    int j = 5;
+    assert(r1(i, j) == i+j);
+    }
+    // member function pointer
+    {
+    int(A_int_2::*fp)(int) = &A_int_2::mem1;
+    std::reference_wrapper<int (A_int_2::*)(int)> r1(fp);
+    A_int_2 a;
+    int i = 3;
+    assert(r1(a, i) == i+1);
+    A_int_2* ap = &a;
+    assert(r1(ap, i) == i+1);
+    }
+    // const member function pointer
+    {
+    int (A_int_2::*fp)(int) const = &A_int_2::mem2;
+    std::reference_wrapper<int (A_int_2::*)(int) const> r1(fp);
+    A_int_2 a;
+    int i = 4;
+    assert(r1(a, i) == i+2);
+    A_int_2* ap = &a;
+    assert(r1(ap, i) == i+2);
+    }
+}
+
+int main()
+{
+    test_void_1();
+    test_int_1();
+    test_void_2();
+    testint_2();
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
new file mode 100644
index 0000000..61357a7
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return int
+
+int count = 0;
+
+int f_int_0()
+{
+    return 3;
+}
+
+struct A_int_0
+{
+    int operator()() {return 4;}
+};
+
+void
+test_int_0()
+{
+    // function
+    {
+    std::reference_wrapper<int ()> r1(f_int_0);
+    assert(r1() == 3);
+    }
+    // function pointer
+    {
+    int (*fp)() = f_int_0;
+    std::reference_wrapper<int (*)()> r1(fp);
+    assert(r1() == 3);
+    }
+    // functor
+    {
+    A_int_0 a0;
+    std::reference_wrapper<A_int_0> r1(a0);
+    assert(r1() == 4);
+    }
+}
+
+// 1 arg, return void
+
+void f_void_1(int i)
+{
+    count += i;
+}
+
+struct A_void_1
+{
+    void operator()(int i)
+    {
+        count += i;
+    }
+};
+
+int main()
+{
+    test_int_0();
+}
diff --git a/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
new file mode 100644
index 0000000..8d70050
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// template <class... ArgTypes>
+//   requires Callable<T, ArgTypes&&...>
+//   Callable<T, ArgTypes&&...>::result_type
+//   operator()(ArgTypes&&... args) const;
+
+#include <functional>
+#include <cassert>
+
+// 0 args, return void
+
+int count = 0;
+
+void f_void_0()
+{
+    ++count;
+}
+
+struct A_void_0
+{
+    void operator()() {++count;}
+};
+
+void
+test_void_0()
+{
+    int save_count = count;
+    // function
+    {
+    std::reference_wrapper<void ()> r1(f_void_0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // function pointer
+    {
+    void (*fp)() = f_void_0;
+    std::reference_wrapper<void (*)()> r1(fp);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+    // functor
+    {
+    A_void_0 a0;
+    std::reference_wrapper<A_void_0> r1(a0);
+    r1();
+    assert(count == save_count+1);
+    save_count = count;
+    }
+}
+
+int main()
+{
+    test_void_0();
+}
diff --git a/final/test/utilities/function.objects/refwrap/type.pass.cpp b/final/test/utilities/function.objects/refwrap/type.pass.cpp
new file mode 100644
index 0000000..68e4067
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for member typedef type
+
+#include <functional>
+#include <type_traits>
+
+class C {};
+
+int main()
+{
+    static_assert((std::is_same<std::reference_wrapper<C>::type,
+                                                       C>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void ()>::type,
+                                                       void ()>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int* (double*)>::type,
+                                                       int* (double*)>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void(*)()>::type,
+                                                       void(*)()>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::type,
+                                                       int*(*)(double*)>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::type,
+                                                       int*(C::*)(double*)>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::type,
+                                                       int (C::*)(double*) const volatile>::value), "");
+}
diff --git a/final/test/utilities/function.objects/refwrap/unary.pass.cpp b/final/test/utilities/function.objects/refwrap/unary.pass.cpp
new file mode 100644
index 0000000..528a8f3
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/unary.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// check for deriving from unary_function
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+class functor2
+    : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+    typedef float result_type;
+};
+
+class functor4
+    : public std::unary_function<int, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+};
+
+struct C
+{
+    typedef int argument_type;
+    typedef int result_type;
+};
+
+int main()
+{
+    static_assert((std::is_base_of<std::unary_function<int, char>,
+                                   std::reference_wrapper<functor1> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<char, int>,
+                                    std::reference_wrapper<functor2> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, int>,
+                                   std::reference_wrapper<functor3> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, int>,
+                                   std::reference_wrapper<functor4> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, int>,
+                                    std::reference_wrapper<C> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, float>,
+                                    std::reference_wrapper<float(*)()> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, float>,
+                                   std::reference_wrapper<float (int)> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, float>,
+                                    std::reference_wrapper<float (int, int)> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<int, float>,
+                                   std::reference_wrapper<float(*)(int)> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<int, float>,
+                                    std::reference_wrapper<float(*)(int, int)> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<C*, float>,
+                                   std::reference_wrapper<float(C::*)()> >::value), "");
+    static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
+                                   std::reference_wrapper<float(C::*)() const volatile> >::value), "");
+    static_assert((!std::is_base_of<std::unary_function<C*, float>,
+                                   std::reference_wrapper<float(C::*)(int)> >::value), "");
+}
diff --git a/final/test/utilities/function.objects/refwrap/weak_result.pass.cpp b/final/test/utilities/function.objects/refwrap/weak_result.pass.cpp
new file mode 100644
index 0000000..609094d
--- /dev/null
+++ b/final/test/utilities/function.objects/refwrap/weak_result.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// reference_wrapper
+
+// has weak result type
+
+#include <functional>
+#include <type_traits>
+
+class functor1
+    : public std::unary_function<int, char>
+{
+};
+
+class functor2
+    : public std::binary_function<char, int, double>
+{
+};
+
+class functor3
+    : public std::unary_function<char, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+    typedef float result_type;
+};
+
+class functor4
+    : public std::unary_function<char, int>,
+      public std::binary_function<char, int, double>
+{
+public:
+};
+
+class C {};
+
+template <class T>
+struct has_result_type
+{
+private:
+    struct two {char _; char __;};
+    template <class U> static two test(...);
+    template <class U> static char test(typename U::result_type* = 0);
+public:
+    static const bool value = sizeof(test<T>(0)) == 1;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::reference_wrapper<functor1>::result_type,
+                                char>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<functor2>::result_type,
+                                double>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<functor3>::result_type,
+                                float>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void()>::result_type,
+                                void>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(double*)>::result_type,
+                                int*>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<void(*)()>::result_type,
+                                void>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::result_type,
+                                int*>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::result_type,
+                                int*>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::result_type,
+                                int>::value), "");
+    static_assert((std::is_same<std::reference_wrapper<C()>::result_type,
+                                C>::value), "");
+    static_assert(has_result_type<std::reference_wrapper<functor3> >::value, "");
+    static_assert(!has_result_type<std::reference_wrapper<functor4> >::value, "");
+    static_assert(!has_result_type<std::reference_wrapper<C> >::value, "");
+}
diff --git a/final/test/utilities/function.objects/unord.hash/enum.fail.cpp b/final/test/utilities/function.objects/unord.hash/enum.fail.cpp
new file mode 100644
index 0000000..9e44bfb
--- /dev/null
+++ b/final/test/utilities/function.objects/unord.hash/enum.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+//  Hashing a struct w/o a defined hash should fail.
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+
+struct X {};
+
+int main()
+{
+    X x;
+    size_t h = std::hash<X>{} ( x );
+}
diff --git a/final/test/utilities/function.objects/unord.hash/enum.pass.cpp b/final/test/utilities/function.objects/unord.hash/enum.pass.cpp
new file mode 100644
index 0000000..b5cd6f8
--- /dev/null
+++ b/final/test/utilities/function.objects/unord.hash/enum.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// make sure that we can hash enumeration values
+// Not very portable
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+enum class Colors { red, orange, yellow, green, blue, indigo, violet };
+enum class Cardinals { zero, one, two, three, five=5 };
+enum class LongColors : short { red, orange, yellow, green, blue, indigo, violet };
+enum class ShortColors : long { red, orange, yellow, green, blue, indigo, violet };
+enum class EightBitColors : uint8_t { red, orange, yellow, green, blue, indigo, violet };
+
+enum Fruits { apple, pear, grape, mango, cantaloupe };
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    typedef typename std::underlying_type<T>::type under_type;
+    
+    std::hash<T> h1;
+    std::hash<under_type> h2;
+    for (int i = 0; i <= 5; ++i)
+    {
+        T t(static_cast<T> (i));
+        if (sizeof(T) <= sizeof(std::size_t))
+            assert(h1(t) == h2(static_cast<under_type>(i)));
+    }
+}
+
+int main()
+{
+    test<Cardinals>();
+
+    test<Colors>();
+    test<ShortColors>();
+    test<LongColors>();
+    test<EightBitColors>();
+
+    test<Fruits>();
+}
+#else
+int main () {}
+#endif
diff --git a/final/test/utilities/function.objects/unord.hash/floating.pass.cpp b/final/test/utilities/function.objects/unord.hash/floating.pass.cpp
new file mode 100644
index 0000000..988950d
--- /dev/null
+++ b/final/test/utilities/function.objects/unord.hash/floating.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+#include <cmath>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    std::size_t t0 = h(0.);
+    std::size_t tn0 = h(-0.);
+    std::size_t tp1 = h(0.1);
+    std::size_t t1 = h(1);
+    std::size_t tn1 = h(-1);
+    std::size_t pinf = h(INFINITY);
+    std::size_t ninf = h(-INFINITY);
+    assert(t0 == tn0);
+    assert(t0 != tp1);
+    assert(t0 != t1);
+    assert(t0 != tn1);
+    assert(t0 != pinf);
+    assert(t0 != ninf);
+
+    assert(tp1 != t1);
+    assert(tp1 != tn1);
+    assert(tp1 != pinf);
+    assert(tp1 != ninf);
+
+    assert(t1 != tn1);
+    assert(t1 != pinf);
+    assert(t1 != ninf);
+
+    assert(tn1 != pinf);
+    assert(tn1 != ninf);
+
+    assert(pinf != ninf);
+}
+
+int main()
+{
+    test<float>();
+    test<double>();
+    test<long double>();
+}
diff --git a/final/test/utilities/function.objects/unord.hash/integral.pass.cpp b/final/test/utilities/function.objects/unord.hash/integral.pass.cpp
new file mode 100644
index 0000000..e5f7ca6
--- /dev/null
+++ b/final/test/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    for (int i = 0; i <= 5; ++i)
+    {
+        T t(i);
+        if (sizeof(T) <= sizeof(std::size_t))
+            assert(h(t) == t);
+    }
+}
+
+int main()
+{
+    test<bool>();
+    test<char>();
+    test<signed char>();
+    test<unsigned char>();
+    test<char16_t>();
+    test<char32_t>();
+    test<wchar_t>();
+    test<short>();
+    test<unsigned short>();
+    test<int>();
+    test<unsigned int>();
+    test<long>();
+    test<unsigned long>();
+    test<long long>();
+    test<unsigned long long>();
+}
diff --git a/final/test/utilities/function.objects/unord.hash/pointer.pass.cpp b/final/test/utilities/function.objects/unord.hash/pointer.pass.cpp
new file mode 100644
index 0000000..e4e0112
--- /dev/null
+++ b/final/test/utilities/function.objects/unord.hash/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <functional>
+#include <cassert>
+#include <type_traits>
+#include <limits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   std::hash<T> >::value), "");
+    std::hash<T> h;
+    typedef typename std::remove_pointer<T>::type type;
+    type i;
+    type j;
+    assert(h(&i) != h(&j));
+}
+
+int main()
+{
+    test<int*>();
+}
diff --git a/final/test/utilities/function.objects/version.pass.cpp b/final/test/utilities/function.objects/version.pass.cpp
new file mode 100644
index 0000000..99d731a
--- /dev/null
+++ b/final/test/utilities/function.objects/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+#include <functional>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/intseq/intseq.general/integer_seq.pass.cpp b/final/test/utilities/intseq/intseq.general/integer_seq.pass.cpp
new file mode 100644
index 0000000..8ca5a96
--- /dev/null
+++ b/final/test/utilities/intseq/intseq.general/integer_seq.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// class make_integer_sequence
+
+#include <tuple>
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+template <typename AtContainer, typename T, T... I>
+auto extract ( const AtContainer &t, const std::integer_sequence<T, I...> idx )
+-> decltype ( std::make_tuple ( std::get<I>(t)... ))
+{     return  std::make_tuple ( std::get<I>(t)... ); }
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+//  Make a couple of sequences
+    using int3    = std::make_integer_sequence<int, 3>;     // generates int:    0,1,2
+    using size7   = std::make_integer_sequence<size_t, 7>;  // generates size_t: 0,1,2,3,4,5,6
+    using size4   = std::make_index_sequence<4>;            // generates size_t: 0,1,2,3
+    using size2   = std::index_sequence_for<int, size_t>;   // generates size_t: 0,1
+    using intmix  = std::integer_sequence<int, 9, 8, 7, 2>; // generates int:    9,8,7,2
+    using sizemix = std::index_sequence<1, 1, 2, 3, 5>;     // generates size_t: 1,1,2,3,5
+    
+//  Make sure they're what we expect
+    static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );
+    static_assert ( int3::size () == 3, "int3 size wrong" );
+    
+    static_assert ( std::is_same<size7::value_type, size_t>::value, "size7 type wrong" );
+    static_assert ( size7::size () == 7, "size7 size wrong" );
+    
+    static_assert ( std::is_same<size4::value_type, size_t>::value, "size4 type wrong" );
+    static_assert ( size4::size () == 4, "size4 size wrong" );
+    
+    static_assert ( std::is_same<size2::value_type, size_t>::value, "size2 type wrong" );
+    static_assert ( size2::size () == 2, "size2 size wrong" );
+    
+    static_assert ( std::is_same<intmix::value_type, int>::value, "intmix type wrong" );
+    static_assert ( intmix::size () == 4, "intmix size wrong" );
+
+    static_assert ( std::is_same<sizemix::value_type, size_t>::value, "sizemix type wrong" );
+    static_assert ( sizemix::size () == 5, "sizemix size wrong" );
+
+    auto tup = std::make_tuple ( 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 );
+    
+//  Use them
+    auto t3 = extract ( tup, int3() );
+    static_assert ( std::tuple_size<decltype(t3)>::value == int3::size (), "t3 size wrong");
+    assert ( t3 == std::make_tuple ( 10, 11, 12 ));
+
+    auto t7 = extract ( tup, size7 ());
+    static_assert ( std::tuple_size<decltype(t7)>::value == size7::size (), "t7 size wrong");
+    assert ( t7 == std::make_tuple ( 10, 11, 12, 13, 14, 15, 16 ));
+
+    auto t4 = extract ( tup, size4 ());
+    static_assert ( std::tuple_size<decltype(t4)>::value == size4::size (), "t4 size wrong");
+    assert ( t4 == std::make_tuple ( 10, 11, 12, 13 ));
+
+    auto t2 = extract ( tup, size2 ());
+    static_assert ( std::tuple_size<decltype(t2)>::value == size2::size (), "t2 size wrong");
+    assert ( t2 == std::make_tuple ( 10, 11 ));
+
+    auto tintmix = extract ( tup, intmix ());
+    static_assert ( std::tuple_size<decltype(tintmix)>::value == intmix::size (), "tintmix size wrong");
+    assert ( tintmix == std::make_tuple ( 19, 18, 17, 12 ));
+
+    auto tsizemix = extract ( tup, sizemix ());
+    static_assert ( std::tuple_size<decltype(tsizemix)>::value == sizemix::size (), "tsizemix size wrong");
+    assert ( tsizemix == std::make_tuple ( 11, 11, 12, 13, 15 ));
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/intseq/intseq.intseq/integer_seq.fail.cpp b/final/test/utilities/intseq/intseq.intseq/integer_seq.fail.cpp
new file mode 100644
index 0000000..4b2d1ac
--- /dev/null
+++ b/final/test/utilities/intseq/intseq.intseq/integer_seq.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T... I>
+// struct integer_sequence
+// {
+//     typedef T type;
+// 
+//     static constexpr size_t size() noexcept;
+// };
+
+// This test is a conforming extension.  The extension turns undefined behavior
+//  into a compile-time error.
+
+#include <utility>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+//  Should fail to compile, since float is not an integral type
+    using floatmix = std::integer_sequence<float>;
+    floatmix::value_type I;
+
+#else
+
+X
+
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/intseq/intseq.intseq/integer_seq.pass.cpp b/final/test/utilities/intseq/intseq.intseq/integer_seq.pass.cpp
new file mode 100644
index 0000000..a795e90
--- /dev/null
+++ b/final/test/utilities/intseq/intseq.intseq/integer_seq.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T... I>
+// struct integer_sequence
+// {
+//     typedef T type;
+// 
+//     static constexpr size_t size() noexcept;
+// };
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+//  Make a few of sequences
+    using int3    = std::integer_sequence<int, 3, 2, 1>;
+    using size1   = std::integer_sequence<size_t, 7>;
+    using ushort2 = std::integer_sequence<unsigned short, 4, 6>;
+    using bool0   = std::integer_sequence<bool>;
+    
+//  Make sure they're what we expect
+    static_assert ( std::is_same<int3::value_type, int>::value, "int3 type wrong" );
+    static_assert ( int3::size() == 3, "int3 size wrong" );
+    
+    static_assert ( std::is_same<size1::value_type, size_t>::value, "size1 type wrong" );
+    static_assert ( size1::size() == 1, "size1 size wrong" );
+    
+    static_assert ( std::is_same<ushort2::value_type, unsigned short>::value, "ushort2 type wrong" );
+    static_assert ( ushort2::size() == 2, "ushort2 size wrong" );
+    
+    static_assert ( std::is_same<bool0::value_type, bool>::value, "bool0 type wrong" );
+    static_assert ( bool0::size() == 0, "bool0 size wrong" );
+    
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/intseq/intseq.make/make_integer_seq.fail.cpp b/final/test/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
new file mode 100644
index 0000000..2dd6c17
--- /dev/null
+++ b/final/test/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T N>
+//   using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    std::make_integer_sequence<int, -3>::value_type i;
+
+#else
+
+X
+
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/intseq/intseq.make/make_integer_seq.pass.cpp b/final/test/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
new file mode 100644
index 0000000..7e82b94
--- /dev/null
+++ b/final/test/utilities/intseq/intseq.make/make_integer_seq.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T, T N>
+//   using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
+
+#include <utility>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    static_assert(std::is_same<std::make_integer_sequence<int, 0>, std::integer_sequence<int>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<int, 1>, std::integer_sequence<int, 0>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<int, 2>, std::integer_sequence<int, 0, 1>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<int, 3>, std::integer_sequence<int, 0, 1, 2>>::value, "");
+
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 0>, std::integer_sequence<unsigned long long>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 1>, std::integer_sequence<unsigned long long, 0>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 2>, std::integer_sequence<unsigned long long, 0, 1>>::value, "");
+    static_assert(std::is_same<std::make_integer_sequence<unsigned long long, 3>, std::integer_sequence<unsigned long long, 0, 1, 2>>::value, "");
+
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/intseq/nothing_to_do.pass.cpp b/final/test/utilities/intseq/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/intseq/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp b/final/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp
new file mode 100644
index 0000000..636998a
--- /dev/null
+++ b/final/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// struct allocator_arg_t { };
+// const allocator_arg_t allocator_arg = allocator_arg_t();
+
+#include <memory>
+
+void test(std::allocator_arg_t) {}
+
+int main()
+{
+    test(std::allocator_arg);
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
new file mode 100644
index 0000000..490fdf5
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static pointer allocate(allocator_type& a, size_type n);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    value_type* allocate(std::size_t n)
+    {
+        assert(n == 10);
+        return (value_type*)0xDEADBEEF;
+    }
+};
+
+int main()
+{
+    A<int> a;
+    assert(std::allocator_traits<A<int> >::allocate(a, 10) == (int*)0xDEADBEEF);
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
new file mode 100644
index 0000000..079db35
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    value_type* allocate(std::size_t n)
+    {
+        assert(n == 10);
+        return (value_type*)0xDEADBEEF;
+    }
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    value_type* allocate(std::size_t n)
+    {
+        assert(n == 12);
+        return (value_type*)0xEEADBEEF;
+    }
+    value_type* allocate(std::size_t n, const void* p)
+    {
+        assert(n == 11);
+        assert(p == 0);
+        return (value_type*)0xFEADBEEF;
+    }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    A<int> a;
+    assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF);
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    B<int> b;
+    assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF);
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
new file mode 100644
index 0000000..6340197
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class Ptr, class... Args>
+//         static void construct(allocator_type& a, Ptr p, Args&&... args);
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+};
+
+int b_construct = 0;
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    template <class U, class ...Args>
+    void construct(U* p, Args&& ...args)
+    {
+        ++b_construct;
+        ::new ((void*)p) U(std::forward<Args>(args)...);
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+};
+
+struct A0
+{
+    static int count;
+    A0() {++count;}
+};
+
+int A0::count = 0;
+
+struct A1
+{
+    static int count;
+    A1(char c)
+    {
+        assert(c == 'c');
+        ++count;
+    }
+};
+
+int A1::count = 0;
+
+struct A2
+{
+    static int count;
+    A2(char c, int i)
+    {
+        assert(c == 'd');
+        assert(i == 5);
+        ++count;
+    }
+};
+
+int A2::count = 0;
+
+int main()
+{
+    {
+        A0::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        assert(A0::count == 0);
+        std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+        assert(A0::count == 1);
+    }
+    {
+        A1::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A1)>::type a1;
+        assert(A1::count == 0);
+        std::allocator_traits<A<int> >::construct(a, (A1*)&a1, 'c');
+        assert(A1::count == 1);
+    }
+    {
+        A2::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A2)>::type a2;
+        assert(A2::count == 0);
+        std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5);
+        assert(A2::count == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        A0::count = 0;
+        b_construct = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        assert(A0::count == 0);
+        assert(b_construct == 0);
+        std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+        assert(A0::count == 1);
+        assert(b_construct == 1);
+    }
+    {
+        A1::count = 0;
+        b_construct = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A1)>::type a1;
+        assert(A1::count == 0);
+        assert(b_construct == 0);
+        std::allocator_traits<B<int> >::construct(b, (A1*)&a1, 'c');
+        assert(A1::count == 1);
+        assert(b_construct == 1);
+    }
+    {
+        A2::count = 0;
+        b_construct = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A2)>::type a2;
+        assert(A2::count == 0);
+        assert(b_construct == 0);
+        std::allocator_traits<B<int> >::construct(b, (A2*)&a2, 'd', 5);
+        assert(A2::count == 1);
+        assert(b_construct == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
new file mode 100644
index 0000000..b137dc6
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static void deallocate(allocator_type& a, pointer p, size_type n);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int called = 0;
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    void deallocate(value_type* p, std::size_t n)
+    {
+        assert(p == (value_type*)0xDEADBEEF);
+        assert(n == 10);
+        ++called;
+    }
+};
+
+int main()
+{
+    A<int> a;
+    std::allocator_traits<A<int> >::deallocate(a, (int*)0xDEADBEEF, 10);
+    assert(called == 1);
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
new file mode 100644
index 0000000..54726c9
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class Ptr>
+//         static void destroy(allocator_type& a, Ptr p);
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+};
+
+int b_destroy = 0;
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    template <class U>
+    void destroy(U* p)
+    {
+        ++b_destroy;
+        p->~U();
+    }
+};
+
+struct A0
+{
+    static int count;
+    ~A0() {++count;}
+};
+
+int A0::count = 0;
+
+int main()
+{
+    {
+        A0::count = 0;
+        A<int> a;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        std::allocator_traits<A<int> >::construct(a, (A0*)&a0);
+        assert(A0::count == 0);
+        std::allocator_traits<A<int> >::destroy(a, (A0*)&a0);
+        assert(A0::count == 1);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        A0::count = 0;
+        b_destroy = 0;
+        B<int> b;
+        std::aligned_storage<sizeof(A0)>::type a0;
+        std::allocator_traits<B<int> >::construct(b, (A0*)&a0);
+        assert(A0::count == 0);
+        assert(b_destroy == 0);
+        std::allocator_traits<B<int> >::destroy(b, (A0*)&a0);
+        assert(A0::count == 1);
+        assert(b_destroy == 1);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
new file mode 100644
index 0000000..1fa7291
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static size_type max_size(const allocator_type& a) noexcept;
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    size_t max_size() const
+    {
+        return 100;
+    }
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        A<int> a;
+        assert(std::allocator_traits<A<int> >::max_size(a) ==
+               std::numeric_limits<std::size_t>::max());
+    }
+    {
+        const A<int> a = {};
+        assert(std::allocator_traits<A<int> >::max_size(a) ==
+               std::numeric_limits<std::size_t>::max());
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        B<int> b;
+        assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+    }
+    {
+        const B<int> b = {};
+        assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+    }
+#if __cplusplus >= 201103
+    {
+        std::allocator<int> a;
+        static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 0000000..29fe2be
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     static allocator_type
+//         select_on_container_copy_construction(const allocator_type& a);
+//     ...
+// };
+
+#include <memory>
+#include <new>
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    int id;
+    explicit A(int i = 0) : id(i) {}
+
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+
+    int id;
+    explicit B(int i = 0) : id(i) {}
+
+    B select_on_container_copy_construction() const
+    {
+        return B(100);
+    }
+};
+
+int main()
+{
+    {
+        A<int> a;
+        assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+    }
+    {
+        const A<int> a(0);
+        assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
+    }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+    {
+        B<int> b;
+        assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+    }
+    {
+        const B<int> b(0);
+        assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
+    }
+#endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
new file mode 100644
index 0000000..20348d2
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::const_pointer
+//           | pointer_traits<pointer>::rebind<const value_type>
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    typedef CPtr<T> pointer;
+    typedef CPtr<const T> const_pointer;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::const_pointer, Ptr<const char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::const_pointer, const char*>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::const_pointer, CPtr<const char> >::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
new file mode 100644
index 0000000..4b4045a
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::const_void_pointer
+//           | pointer_traits<pointer>::rebind<const void>
+//                                          const_void_pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    typedef CPtr<const void> const_void_pointer;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::const_void_pointer, Ptr<const void> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::const_void_pointer, const void*>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::const_void_pointer, CPtr<const void> >::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
new file mode 100644
index 0000000..085c911
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::difference_type
+//           | pointer_traits<pointer>::difference_type         difference_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef short difference_type;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    struct pointer {};
+    struct const_pointer {};
+    struct void_pointer {};
+    struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+    typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::difference_type, short>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::difference_type, signed char>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
new file mode 100644
index 0000000..60ba094
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::pointer | value_type* pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::pointer, Ptr<char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::pointer, char*>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 0000000..604e890
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::propagate_on_container_copy_assignment
+//           | false_type                   propagate_on_container_copy_assignment;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef std::true_type propagate_on_container_copy_assignment;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_copy_assignment, std::true_type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_copy_assignment, std::false_type>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 0000000..1d2b186
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::propagate_on_container_move_assignment
+//           | false_type                   propagate_on_container_move_assignment;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef std::true_type propagate_on_container_move_assignment;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_move_assignment, std::true_type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_move_assignment, std::false_type>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 0000000..6730d1a
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::propagate_on_container_swap
+//           | false_type                   propagate_on_container_swap;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef std::true_type propagate_on_container_swap;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_swap, std::true_type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_swap, std::false_type>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
new file mode 100644
index 0000000..50611b9
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class T> using rebind_alloc  = Alloc::rebind<U>::other | Alloc<T, Args...>;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+    typedef T value_type;
+
+    template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>, ReboundA<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>, ReboundB<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>, C<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>, D<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>, E<double> >::value), "");
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>::other, ReboundA<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>::other, ReboundB<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>::other, C<double> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>::other, D<double, char> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>::other, E<double> >::value), "");
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
new file mode 100644
index 0000000..e9c175f
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::size_type | size_t    size_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef unsigned short size_type;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    struct pointer {};
+    struct const_pointer {};
+    struct void_pointer {};
+    struct const_void_pointer {};
+};
+
+namespace std
+{
+
+template <>
+struct pointer_traits<C<char>::pointer>
+{
+    typedef signed char difference_type;
+};
+
+}
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::size_type,
+                   std::make_unsigned<std::ptrdiff_t>::type>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::size_type,
+                   unsigned char>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
new file mode 100644
index 0000000..74cd347
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc::void_pointer
+//           | pointer_traits<pointer>::rebind<void>
+//                                          void_pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct Ptr {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+    typedef Ptr<T> pointer;
+};
+
+template <class T>
+struct B
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct CPtr {};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+    typedef CPtr<void> void_pointer;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::void_pointer, Ptr<void> >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<char> >::void_pointer, void*>::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::void_pointer, CPtr<void> >::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/allocator_type.pass.cpp b/final/test/utilities/memory/allocator.traits/allocator_type.pass.cpp
new file mode 100644
index 0000000..fe35ae4
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/allocator_type.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc allocator_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::allocator_type, A<char> >::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/final/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp
new file mode 100644
index 0000000..87da9a0
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+template <class T, class U>
+struct ReboundB {};
+
+template <class T, class U>
+struct B
+{
+    typedef T value_type;
+
+    template <class V> struct rebind {typedef ReboundB<V, U> other;};
+};
+
+template <class T>
+struct C
+{
+    typedef T value_type;
+};
+
+template <class T, class U>
+struct D
+{
+    typedef T value_type;
+};
+
+template <class T>
+struct E
+{
+    typedef T value_type;
+
+    template <class U> struct rebind {typedef ReboundA<U> otter;};
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");
+    static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/final/test/utilities/memory/allocator.traits/value_type.pass.cpp b/final/test/utilities/memory/allocator.traits/value_type.pass.cpp
new file mode 100644
index 0000000..d0c3d2c
--- /dev/null
+++ b/final/test/utilities/memory/allocator.traits/value_type.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef typename Alloc::value_type value_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+    typedef T value_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::allocator_traits<A<char> >::value_type, char>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp b/final/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp b/final/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
new file mode 100644
index 0000000..0477d99
--- /dev/null
+++ b/final/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T, class Alloc> struct uses_allocator;
+
+#include <memory>
+#include <vector>
+
+struct A
+{
+};
+
+struct B
+{
+    typedef int allocator_type;
+};
+
+int main()
+{
+    static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
+    static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
+    static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
+    static_assert(( std::uses_allocator<B, double>::value), "");
+}
diff --git a/final/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp b/final/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp b/final/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..a718063
--- /dev/null
+++ b/final/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp
@@ -0,0 +1,14 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdlib> and <cstring> are already tested elsewhere
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp b/final/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
new file mode 100644
index 0000000..8ce49b9
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+
+// template <class T1, class T2>
+//   bool
+//   operator==(const allocator<T1>&, const allocator<T2>&) throw();
+//
+// template <class T1, class T2>
+//   bool
+//   operator!=(const allocator<T1>&, const allocator<T2>&) throw();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::allocator<int> a1;
+    std::allocator<int> a2;
+    assert(a1 == a2);
+    assert(!(a1 != a2));
+}
diff --git a/final/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp b/final/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp
new file mode 100644
index 0000000..04534f2
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer address(reference x) const;
+// const_pointer address(const_reference x) const;
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+void test_address()
+{
+    T* tp = new T();
+    const T* ctp = tp;
+    const std::allocator<T> a;
+    assert(a.address(*tp) == tp);
+    assert(a.address(*ctp) == tp);
+    delete tp;
+}
+
+struct A
+{
+    void operator&() const {}
+};
+
+int main()
+{
+    test_address<int>();
+    test_address<A>();
+}
diff --git a/final/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/final/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
new file mode 100644
index 0000000..f881805
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// pointer allocate(size_type n, allocator<void>::const_pointer hint=0);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    assert(s == 3 * sizeof(int));
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    int data;
+    A() {++A_constructed;}
+    A(const A&) {++A_constructed;}
+    ~A() {--A_constructed;}
+};
+
+int main()
+{
+    std::allocator<A> a;
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+    A* ap = a.allocate(3);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+    a.deallocate(ap, 3);
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+
+    A* ap2 = a.allocate(3, (const void*)5);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+    a.deallocate(ap2, 3);
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+}
diff --git a/final/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/final/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
new file mode 100644
index 0000000..7e1500b
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// template <class... Args> void construct(pointer p, Args&&... args);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_called = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_called;
+    assert(s == 3 * sizeof(int));
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    --new_called;
+    std::free(p);
+}
+
+int A_constructed = 0;
+
+struct A
+{
+    int data;
+    A() {++A_constructed;}
+
+    A(const A&) {++A_constructed;}
+
+    explicit A(int) {++A_constructed;}
+    A(int, int*) {++A_constructed;}
+
+    ~A() {--A_constructed;}
+};
+
+int move_only_constructed = 0;
+
+class move_only
+{
+    int data;
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&&) {++move_only_constructed;}
+    move_only& operator=(move_only&&) {return *this;}
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {++move_only_constructed;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    move_only() {++move_only_constructed;}
+    ~move_only() {--move_only_constructed;}
+};
+
+int main()
+{
+    {
+    std::allocator<A> a;
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+
+    A* ap = a.allocate(3);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap, A());
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap, 5);
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.construct(ap, 5, (int*)0);
+    assert(new_called == 1);
+    assert(A_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(A_constructed == 0);
+
+    a.deallocate(ap, 3);
+    assert(new_called == 0);
+    assert(A_constructed == 0);
+    }
+    {
+    std::allocator<move_only> a;
+    assert(new_called == 0);
+    assert(move_only_constructed == 0);
+
+    move_only* ap = a.allocate(3);
+    assert(new_called == 1);
+    assert(move_only_constructed == 0);
+
+    a.construct(ap);
+    assert(new_called == 1);
+    assert(move_only_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(move_only_constructed == 0);
+
+    a.construct(ap, move_only());
+    assert(new_called == 1);
+    assert(move_only_constructed == 1);
+
+    a.destroy(ap);
+    assert(new_called == 1);
+    assert(move_only_constructed == 0);
+
+    a.deallocate(ap, 3);
+    assert(new_called == 0);
+    assert(move_only_constructed == 0);
+    }
+}
diff --git a/final/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp b/final/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
new file mode 100644
index 0000000..6ec9339
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// allocator:
+// size_type max_size() const throw();
+
+#include <memory>
+#include <limits>
+#include <cstddef>
+#include <cassert>
+
+int new_called = 0;
+
+int main()
+{
+    const std::allocator<int> a;
+    std::size_t M = a.max_size() * sizeof(int);
+    assert(M > 0xFFFF && M <= std::numeric_limits<std::size_t>::max());
+}
diff --git a/final/test/utilities/memory/default.allocator/allocator_pointers.pass.cpp b/final/test/utilities/memory/default.allocator/allocator_pointers.pass.cpp
new file mode 100644
index 0000000..b894e45
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator_pointers.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+#include <cassert>
+
+#if __cplusplus >= 201103L
+// #include <memory>
+//
+// template <class Alloc>
+// struct allocator_traits
+// {
+//     typedef Alloc                        allocator_type;
+//     typedef typename allocator_type::value_type
+//                                          value_type;
+// 
+//     typedef Alloc::pointer | value_type* pointer;
+//     typedef Alloc::const_pointer
+//           | pointer_traits<pointer>::rebind<const value_type>
+//                                          const_pointer;
+//     typedef Alloc::void_pointer
+//           | pointer_traits<pointer>::rebind<void>
+//                                          void_pointer;
+//     typedef Alloc::const_void_pointer
+//           | pointer_traits<pointer>::rebind<const void>
+//                                          const_void_pointer;
+
+template <typename Alloc>
+void test_pointer()
+{
+     typename std::allocator_traits<Alloc>::pointer        vp;
+     typename std::allocator_traits<Alloc>::const_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+template <typename Alloc>
+void test_void_pointer()
+{
+     typename std::allocator_traits<Alloc>::void_pointer        vp;
+     typename std::allocator_traits<Alloc>::const_void_pointer cvp;
+     
+     static_assert(std::is_same<bool, decltype( vp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype( vp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp ==  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp !=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >=  vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <   vp)>::value, "");
+     static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <=  vp)>::value, "");
+
+     static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <  cvp)>::value, "");
+     static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, "");
+}
+
+struct Foo { int x; };
+
+int main()
+{
+	test_pointer<std::allocator<char>> ();
+	test_pointer<std::allocator<int>> ();
+	test_pointer<std::allocator<Foo>> ();	
+
+	test_void_pointer<std::allocator<char>> ();
+	test_void_pointer<std::allocator<int>> ();
+	test_void_pointer<std::allocator<Foo>> ();	
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/utilities/memory/default.allocator/allocator_types.pass.cpp b/final/test/utilities/memory/default.allocator/allocator_types.pass.cpp
new file mode 100644
index 0000000..b0282d7
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator_types.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// check nested types:
+
+// template <class T>
+// class allocator
+// {
+// public:
+//     typedef size_t                                size_type;
+//     typedef ptrdiff_t                             difference_type;
+//     typedef T*                                    pointer;
+//     typedef const T*                              const_pointer;
+//     typedef typename add_lvalue_reference<T>::type       reference;
+//     typedef typename add_lvalue_reference<const T>::type const_reference;
+//     typedef T                                     value_type;
+//
+//     template <class U> struct rebind {typedef allocator<U> other;};
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+#include <cstddef>
+
+int main()
+{
+    static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
+    static_assert((std::is_same<std::allocator<char>::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::allocator<char>::pointer, char*>::value), "");
+    static_assert((std::is_same<std::allocator<char>::const_pointer, const char*>::value), "");
+    static_assert((std::is_same<std::allocator<char>::value_type, char>::value), "");
+    static_assert((std::is_same<std::allocator<char>::reference, char&>::value), "");
+    static_assert((std::is_same<std::allocator<char>::const_reference, const char&>::value), "");
+    static_assert((std::is_same<std::allocator<char>::rebind<int>::other,
+                                std::allocator<int> >::value), "");
+    std::allocator<char> a;
+    std::allocator<char> a2 = a;
+    a2 = a;
+    std::allocator<int> a3 = a2;
+}
diff --git a/final/test/utilities/memory/default.allocator/allocator_void.pass.cpp b/final/test/utilities/memory/default.allocator/allocator_void.pass.cpp
new file mode 100644
index 0000000..cc1dbeb
--- /dev/null
+++ b/final/test/utilities/memory/default.allocator/allocator_void.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <>
+// class allocator<void>
+// {
+// public:
+//     typedef void*                                 pointer;
+//     typedef const void*                           const_pointer;
+//     typedef void                                  value_type;
+//
+//     template <class _Up> struct rebind {typedef allocator<_Up> other;};
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::allocator<void>::pointer, void*>::value), "");
+    static_assert((std::is_same<std::allocator<void>::const_pointer, const void*>::value), "");
+    static_assert((std::is_same<std::allocator<void>::value_type, void>::value), "");
+    static_assert((std::is_same<std::allocator<void>::rebind<int>::other,
+                                std::allocator<int> >::value), "");
+    std::allocator<void> a;
+    std::allocator<void> a2 = a;
+    a2 = a;
+}
diff --git a/final/test/utilities/memory/pointer.traits/difference_type.pass.cpp b/final/test/utilities/memory/pointer.traits/difference_type.pass.cpp
new file mode 100644
index 0000000..483c325
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/difference_type.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     typedef ptrdiff_t difference_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<double*>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/final/test/utilities/memory/pointer.traits/element_type.pass.cpp b/final/test/utilities/memory/pointer.traits/element_type.pass.cpp
new file mode 100644
index 0000000..44694fc
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/element_type.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     typedef T element_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<const short*>::element_type, const short>::value), "");
+}
diff --git a/final/test/utilities/memory/pointer.traits/pointer.pass.cpp b/final/test/utilities/memory/pointer.traits/pointer.pass.cpp
new file mode 100644
index 0000000..66e90cf
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/pointer.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     typedef Ptr pointer;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+    typedef short element_type;
+    typedef char difference_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<A>::pointer, A>::value), "");
+    static_assert((std::is_same<std::pointer_traits<int*>::pointer, int*>::value), "");
+}
diff --git a/final/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp b/final/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
new file mode 100644
index 0000000..e0e38fb
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     static pointer pointer_to(<details>);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+private:
+    struct nat {};
+public:
+    typedef T element_type;
+    element_type* t_;
+
+    A(element_type* t) : t_(t) {}
+
+    static A pointer_to(typename std::conditional<std::is_void<element_type>::value,
+                                           nat, element_type>::type& et)
+        {return A(&et);}
+};
+
+int main()
+{
+    {
+        int i = 0;
+        A<int> a = std::pointer_traits<A<int> >::pointer_to(i);
+        assert(a.t_ = &i);
+    }
+    {
+        (std::pointer_traits<A<void> >::element_type)0;
+    }
+}
diff --git a/final/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp b/final/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
new file mode 100644
index 0000000..4efe613
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     typedef <details> difference_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+    typedef short element_type;
+    typedef char difference_type;
+};
+
+struct B
+{
+    typedef short element_type;
+};
+
+template <class T>
+struct C {};
+
+template <class T>
+struct D
+{
+    typedef char difference_type;
+};
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<A>::difference_type, char>::value), "");
+    static_assert((std::is_same<std::pointer_traits<B>::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<double> >::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<int> >::difference_type, char>::value), "");
+}
diff --git a/final/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp b/final/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
new file mode 100644
index 0000000..0ee1e8c
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     typedef <details> element_type;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+    typedef char element_type;
+};
+
+template <class T>
+struct B
+{
+    typedef char element_type;
+};
+
+template <class T>
+struct C
+{
+};
+
+template <class T, class U>
+struct D
+{
+};
+
+int main()
+{
+    static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), "");
+    static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), "");
+}
diff --git a/final/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp b/final/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
new file mode 100644
index 0000000..4a1455c
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Ptr>
+// struct pointer_traits
+// {
+//     template <class U> using rebind = <details>;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+};
+
+template <class T> struct B1 {};
+
+template <class T>
+struct B
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class U> using rebind = B1<U>;
+#else
+    template <class U> struct rebind {typedef B1<U> other;};
+#endif
+};
+
+template <class T, class U>
+struct C
+{
+};
+
+template <class T, class U> struct D1 {};
+
+template <class T, class U>
+struct D
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    template <class V> using rebind = D1<V, U>;
+#else
+    template <class V> struct rebind {typedef D1<V, U> other;};
+#endif
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), "");
+#else  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), "");
+    static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), "");
+#endif  // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/final/test/utilities/memory/pointer.traits/pointer_to.pass.cpp b/final/test/utilities/memory/pointer.traits/pointer_to.pass.cpp
new file mode 100644
index 0000000..764a7ba
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/pointer_to.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     static pointer pointer_to(<details>);
+//     ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+        int i = 0;
+        int* a = std::pointer_traits<int*>::pointer_to(i);
+        assert(a = &i);
+    }
+    {
+        (std::pointer_traits<void*>::element_type)0;
+    }
+}
diff --git a/final/test/utilities/memory/pointer.traits/rebind.pass.cpp b/final/test/utilities/memory/pointer.traits/rebind.pass.cpp
new file mode 100644
index 0000000..8716c05
--- /dev/null
+++ b/final/test/utilities/memory/pointer.traits/rebind.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct pointer_traits<T*>
+// {
+//     template <class U> using rebind = U*;
+//     ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), "");
+#else
+    static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), "");
+#endif
+}
diff --git a/final/test/utilities/memory/ptr.align/align.pass.cpp b/final/test/utilities/memory/ptr.align/align.pass.cpp
new file mode 100644
index 0000000..e4e2e0a
--- /dev/null
+++ b/final/test/utilities/memory/ptr.align/align.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+
+// void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int i = 0;
+    const unsigned N = 20;
+    char buf[N];
+    void* r;
+    void* p = &buf[0];
+    std::size_t s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[0]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[1];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-3);
+
+    p = &buf[2];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-2);
+
+    p = &buf[3];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-1);
+
+    p = &buf[4];
+    s = N;
+    r = std::align(4, 10, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[0];
+    s = N;
+    r = std::align(4, N, p, s);
+    assert(p == &buf[0]);
+    assert(r == p);
+    assert(s == N);
+
+    p = &buf[1];
+    s = N-1;
+    r = std::align(4, N-4, p, s);
+    assert(p == &buf[4]);
+    assert(r == p);
+    assert(s == N-4);
+
+    p = &buf[1];
+    s = N-1;
+    r = std::align(4, N-3, p, s);
+    assert(p == &buf[1]);
+    assert(r == nullptr);
+    assert(s == N-1);
+
+    p = &buf[0];
+    s = N;
+    r = std::align(1, N+1, p, s);
+    assert(p == &buf[0]);
+    assert(r == nullptr);
+    assert(s == N);
+}
diff --git a/final/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp b/final/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp b/final/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
new file mode 100644
index 0000000..e07bec4
--- /dev/null
+++ b/final/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <ObjectType T> T* addressof(T& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    void operator&() const {}
+};
+
+struct nothing {
+    operator char&()
+    {
+        static char c;
+        return c;
+    }
+};
+
+int main()
+{
+    {
+    int i;
+    double d;
+    assert(std::addressof(i) == &i);
+    assert(std::addressof(d) == &d);
+    A* tp = new A;
+    const A* ctp = tp;
+    assert(std::addressof(*tp) == tp);
+    assert(std::addressof(*ctp) == tp);
+    delete tp;
+    }
+    {
+    union
+    {
+        nothing n;
+        int i;
+    };
+    assert(std::addressof(n) == (void*)std::addressof(i));
+    }
+}
diff --git a/final/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/final/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
new file mode 100644
index 0000000..7de7ecc
--- /dev/null
+++ b/final/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class InputIterator, class ForwardIterator>
+//   ForwardIterator
+//   uninitialized_copy(InputIterator first, InputIterator last,
+//                      ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    B b[N];
+    try
+    {
+        std::uninitialized_copy(b, b+N, bp);
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    std::uninitialized_copy(b, b+2, bp);
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}
diff --git a/final/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/final/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
new file mode 100644
index 0000000..79afa4f
--- /dev/null
+++ b/final/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class InputIterator, class Size, class ForwardIterator>
+//   ForwardIterator
+//   uninitialized_copy_n(InputIterator first, Size n,
+//                        ForwardIterator result);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    B b[N];
+    try
+    {
+        std::uninitialized_copy_n(b, 5, bp);
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    std::uninitialized_copy_n(b, 2, bp);
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}
diff --git a/final/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/final/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
new file mode 100644
index 0000000..8fc6b81
--- /dev/null
+++ b/final/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class ForwardIterator, class Size, class T>
+//   ForwardIterator
+//   uninitialized_fill_n(ForwardIterator first, Size n, const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    try
+    {
+        std::uninitialized_fill_n(bp, 5, B());
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    B* r = std::uninitialized_fill_n(bp, 2, B());
+    assert(r == bp + 2);
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}
diff --git a/final/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/final/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
new file mode 100644
index 0000000..c34fdc7
--- /dev/null
+++ b/final/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class ForwardIterator, class T>
+//   void
+//   uninitialized_fill(ForwardIterator first, ForwardIterator last,
+//                      const T& x);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count_;
+    int data_;
+    explicit B() : data_(1) {}
+    B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;}
+    ~B() {data_ = 0;}
+};
+
+int B::count_ = 0;
+
+int main()
+{
+    const int N = 5;
+    char pool[sizeof(B)*N] = {0};
+    B* bp = (B*)pool;
+    try
+    {
+        std::uninitialized_fill(bp, bp+N, B());
+        assert(false);
+    }
+    catch (...)
+    {
+        for (int i = 0; i < N; ++i)
+            assert(bp[i].data_ == 0);
+    }
+    B::count_ = 0;
+    std::uninitialized_fill(bp, bp+2, B());
+    for (int i = 0; i < 2; ++i)
+        assert(bp[i].data_ == 1);
+}
diff --git a/final/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp b/final/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
new file mode 100644
index 0000000..f77d6c7
--- /dev/null
+++ b/final/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// raw_storage_iterator
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+int A_constructed = 0;
+
+struct A
+{
+    int data_;
+public:
+    explicit A(int i) : data_(i) {++A_constructed;}
+
+    A(const A& a) : data_(a.data_)  {++A_constructed;}
+    ~A() {--A_constructed; data_ = 0;}
+
+    bool operator==(int i) const {return data_ == i;}
+};
+
+int main()
+{
+    typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type
+            Storage;
+    Storage buffer;
+    std::raw_storage_iterator<A*, A> it((A*)&buffer);
+    assert(A_constructed == 0);
+    for (int i = 0; i < 3; ++i)
+    {
+        *it++ = A(i+1);
+        A* ap = (A*)&buffer + i;
+        assert(*ap == i+1);
+        assert(A_constructed == i+1);
+    }
+}
diff --git a/final/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp b/final/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
new file mode 100644
index 0000000..c1575bd
--- /dev/null
+++ b/final/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+//   pair<T*, ptrdiff_t>
+//   get_temporary_buffer(ptrdiff_t n);
+//
+// template <class T>
+//   void
+//   return_temporary_buffer(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::pair<int*, std::ptrdiff_t> ip = std::get_temporary_buffer<int>(5);
+    assert(ip.first);
+    assert(ip.second == 5);
+    std::return_temporary_buffer(ip.first);
+}
diff --git a/final/test/utilities/memory/unique.ptr/deleter.h b/final/test/utilities/memory/unique.ptr/deleter.h
new file mode 100644
index 0000000..04b6de7
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/deleter.h
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Example move-only deleter
+
+#ifndef DELETER_H
+#define DELETER_H
+
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(0) {}
+    explicit Deleter(int s) : state_(s) {}
+    ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class Deleter<T[]>
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(0) {}
+    explicit Deleter(int s) : state_(s) {}
+    ~Deleter() {assert(state_ >= 0); state_ = -1;}
+
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(Deleter<T>& x, Deleter<T>& y)
+{
+    Deleter<T> t(std::move(x));
+    x = std::move(y);
+    y = std::move(t);
+}
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+public:
+
+    CDeleter() : state_(0) {}
+    explicit CDeleter(int s) : state_(s) {}
+    ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+    template <class U>
+        CDeleter(const CDeleter<U>& d)
+            : state_(d.state()) {}
+
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+template <class T>
+class CDeleter<T[]>
+{
+    int state_;
+
+public:
+
+    CDeleter() : state_(0) {}
+    explicit CDeleter(int s) : state_(s) {}
+    ~CDeleter() {assert(state_ >= 0); state_ = -1;}
+
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete [] p;}
+};
+
+template <class T>
+void
+swap(CDeleter<T>& x, CDeleter<T>& y)
+{
+    CDeleter<T> t(std::move(x));
+    x = std::move(y);
+    y = std::move(t);
+}
+
+#endif  // DELETER_H
diff --git a/final/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/final/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp
new file mode 100644
index 0000000..b2fb58f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+#include <string>
+#include <cassert>
+
+//    The only way to create an unique_ptr<T[]> is to default construct them.
+
+class foo {
+public:
+    foo () : val_(3) {}
+    int get () const { return val_; }
+private:
+    int val_;
+    };
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    auto p1 = std::make_unique<int[]>(5);
+    for ( int i = 0; i < 5; ++i )
+        assert ( p1[i] == 0 );
+    }
+    
+    {
+    auto p2 = std::make_unique<std::string[]>(5);
+    for ( int i = 0; i < 5; ++i )
+        assert ( p2[i].size () == 0 );
+    }
+    
+    {
+    auto p3 = std::make_unique<foo[]>(7);
+    for ( int i = 0; i < 7; ++i )
+        assert ( p3[i].get () == 3 );
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp
new file mode 100644
index 0000000..0098791
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up1 = std::make_unique<std::string[]>("error"); // doesn't compile - no bound
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp
new file mode 100644
index 0000000..cc94e9a
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up2 = std::make_unique<int[]>(10, 20, 30, 40);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp
new file mode 100644
index 0000000..cfdc2e1
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up3 = std::make_unique<int[5]>();    // this is deleted
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp
new file mode 100644
index 0000000..26eb59b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    auto up4 = std::make_unique<int[5]>(11, 22, 33, 44, 55); // deleted 
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp
new file mode 100644
index 0000000..7326ed2
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <memory>
+#include <string>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    std::unique_ptr<int> p1 = std::make_unique<int>(1);
+    assert ( *p1 == 1 );
+    p1 = std::make_unique<int> ();
+    assert ( *p1 == 0 );
+    }
+    
+    {
+    std::unique_ptr<std::string> p2 = std::make_unique<std::string> ( "Meow!" );
+    assert ( *p2 == "Meow!" );
+    p2 = std::make_unique<std::string> ();
+    assert ( *p2 == "" );
+    p2 = std::make_unique<std::string> ( 6, 'z' );
+    assert ( *p2 == "zzzzzz" );
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
new file mode 100644
index 0000000..9bf794c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    std::default_delete<B> d2;
+    std::default_delete<A> d1 = d2;
+    A* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d1(p);
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
new file mode 100644
index 0000000..f686e9f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    std::default_delete<A> d;
+    A* p = new A;
+    assert(A::count == 1);
+    d(p);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
new file mode 100644
index 0000000..255e5cd
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+    std::default_delete<A> d;
+    A* p = 0;
+    d(p);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp
new file mode 100644
index 0000000..5d1cf1f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete's operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::default_delete<const void> d;
+    const void* p = 0;
+    d(p);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
new file mode 100644
index 0000000..41209d9
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> does not have a working converting constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct B
+    : public A
+{
+};
+
+int main()
+{
+    std::default_delete<B[]> d2;
+    std::default_delete<A[]> d1 = d2;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
new file mode 100644
index 0000000..7a40976
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]> has a working default constructor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    std::default_delete<A[]> d;
+    A* p = new A[3];
+    assert(A::count == 3);
+    d(p);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
new file mode 100644
index 0000000..528b10e
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// default_delete
+
+// Test that default_delete<T[]>'s operator() requires a complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+    std::default_delete<A[]> d;
+    A* p = 0;
+    d(p);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
new file mode 100644
index 0000000..57724ae
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    std::unique_ptr<A> s2;
+    s2 = s;
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
new file mode 100644
index 0000000..2426dd3
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s1(new A[3]);
+    A* p = s1.get();
+    assert(A::count == 3);
+    std::unique_ptr<A[]> s2(new A[2]);
+    assert(A::count == 5);
+    s2 = std::move(s1);
+    assert(A::count == 3);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A[], Deleter<A[]> > s1(new A[4], Deleter<A[]>(5));
+    A* p = s1.get();
+    assert(A::count == 4);
+    std::unique_ptr<A[], Deleter<A[]> > s2(new A[5]);
+    assert(A::count == 9);
+    s2 = std::move(s1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(A::count == 4);
+    assert(s2.get_deleter().state() == 5);
+    assert(s1.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    CDeleter<A[]> d1(5);
+    std::unique_ptr<A[], CDeleter<A[]>&> s1(new A[6], d1);
+    A* p = s1.get();
+    assert(A::count == 6);
+    CDeleter<A[]> d2(6);
+    std::unique_ptr<A[], CDeleter<A[]>&> s2(new A[3], d2);
+    assert(A::count == 9);
+    s2 = std::move(s1);
+    assert(A::count == 6);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(d1.state() == 5);
+    assert(d2.state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
new file mode 100644
index 0000000..bfaac88
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A[]> s(new A[3]);
+    std::unique_ptr<A[]> s2;
+    s2 = s;
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
new file mode 100644
index 0000000..aa4fdb8
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
new file mode 100644
index 0000000..e0d7c89
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
new file mode 100644
index 0000000..a0ea40b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
new file mode 100644
index 0000000..b460923
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    boost::unique_ptr<B[], Deleter<B> > s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[], Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
new file mode 100644
index 0000000..e18be7b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
new file mode 100644
index 0000000..8d2e074
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const boost::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[]> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
new file mode 100644
index 0000000..3ba514c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const boost::unique_ptr<B[], Deleter<B> > s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[], Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
new file mode 100644
index 0000000..f4c45bc
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    const boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
new file mode 100644
index 0000000..5e238bd
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    boost::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[]> s2(new A);
+    assert(A::count == 2);
+    s2 = boost::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
new file mode 100644
index 0000000..d084d38
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    boost::unique_ptr<B[], Deleter<B> > s(new B);
+    A* p = s.get();
+    boost::unique_ptr<A[], Deleter<A> > s2(new A);
+    assert(A::count == 2);
+    s2 = (boost::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
new file mode 100644
index 0000000..972c559
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    boost::unique_ptr<B[], Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    boost::unique_ptr<A[], Deleter<A>&> s2(new A, da);
+    s2 = boost::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
new file mode 100644
index 0000000..e2d7956
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 1);
+    s2 = 0;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
new file mode 100644
index 0000000..6d752b9
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(0) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {++state_;}
+};
+
+int main()
+{
+    Deleter d;
+    assert(d.state() == 0);
+    {
+    std::unique_ptr<int[], Deleter&> p(0, d);
+    assert(p.get() == 0);
+    assert(&p.get_deleter() == &d);
+    }
+    assert(d.state() == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
new file mode 100644
index 0000000..30ecdde
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s2(new A[3]);
+    assert(A::count == 3);
+    s2 = nullptr;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
new file mode 100644
index 0000000..e7ad6ad
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+    struct pointer {};
+};
+
+int main()
+{
+    {
+    typedef std::unique_ptr<int[]> P;
+    static_assert((std::is_same<P::pointer, int*>::value), "");
+    }
+    {
+    typedef std::unique_ptr<int[], Deleter> P;
+    static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
new file mode 100644
index 0000000..a706c40
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require default Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+
+    Deleter() {}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) {}
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter> p;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
new file mode 100644
index 0000000..0cc5438
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int[]> p;
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int[], Deleter> p;
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
new file mode 100644
index 0000000..82b8494
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter&> p;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
new file mode 100644
index 0000000..3ded41c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test default unique_ptr<T[]> ctor
+
+// default unique_ptr<T[]> ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+    std::unique_ptr<A[], D> a_;
+    B();
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+    {
+    B<> s;
+    assert(s.get() == 0);
+    }
+    check(0);
+    {
+    B<Deleter> s;
+    assert(s.get() == 0);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::B() {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
new file mode 100644
index 0000000..74d24fd
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+    std::unique_ptr<int[], void (*)(void*)> p;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
new file mode 100644
index 0000000..bc49a0e
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
new file mode 100644
index 0000000..fc00c7d
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+    int state_;
+
+    NCDeleter(NCDeleter&);
+    NCDeleter& operator=(NCDeleter&);
+public:
+
+    NCDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 3);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A[], Deleter<A[]> > s(new A[3], Deleter<A[]>(5));
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 3);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    NCDeleter d;
+    std::unique_ptr<A[], NCDeleter&> s(new A[3], d);
+    A* p = s.get();
+    std::unique_ptr<A[], NCDeleter&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 3);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
new file mode 100644
index 0000000..8e44c78
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A[]> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
new file mode 100644
index 0000000..ef821a9
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class NCDeleter
+{
+    int state_;
+
+    NCDeleter(NCDeleter&);
+    NCDeleter& operator=(NCDeleter&);
+public:
+
+    NCDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+std::unique_ptr<A[]>
+source1()
+{
+    return std::unique_ptr<A[]>(new A[3]);
+}
+
+void sink1(std::unique_ptr<A[]> p)
+{
+}
+
+std::unique_ptr<A[], Deleter<A[]> >
+source2()
+{
+    return std::unique_ptr<A[], Deleter<A[]> >(new A[3]);
+}
+
+void sink2(std::unique_ptr<A[], Deleter<A[]> > p)
+{
+}
+
+std::unique_ptr<A[], NCDeleter&>
+source3()
+{
+    static NCDeleter d;
+    return std::unique_ptr<A[], NCDeleter&>(new A[3], d);
+}
+
+void sink3(std::unique_ptr<A[], NCDeleter&> p)
+{
+}
+
+int main()
+{
+    sink1(source1());
+    sink2(source2());
+    sink3(source3());
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
new file mode 100644
index 0000000..c952cf2
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Can't copy from lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A[], Deleter> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
new file mode 100644
index 0000000..0d091ff
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+// test move ctor.  Can't copy from const lvalue
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A[], Deleter> s(new A[3]);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
new file mode 100644
index 0000000..d175fbf
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
new file mode 100644
index 0000000..1838511
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
new file mode 100644
index 0000000..36ad75d
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
new file mode 100644
index 0000000..3a19bde
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
new file mode 100644
index 0000000..bda2a70
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
new file mode 100644
index 0000000..fba8951
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
new file mode 100644
index 0000000..24c6469
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
new file mode 100644
index 0000000..486d908
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
new file mode 100644
index 0000000..e4cbef5
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
new file mode 100644
index 0000000..73423d1
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
new file mode 100644
index 0000000..cfc097b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
new file mode 100644
index 0000000..fdb0882
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
new file mode 100644
index 0000000..d9ef8e9
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
new file mode 100644
index 0000000..b4577a1
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
new file mode 100644
index 0000000..9325d07
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
new file mode 100644
index 0000000..b090e59
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[]> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[]> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
new file mode 100644
index 0000000..b2af3c7
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B[], Deleter<B[]> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
new file mode 100644
index 0000000..d1c0e8a
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
new file mode 100644
index 0000000..9a8c175
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int[]> p(nullptr);
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int[], Deleter> p(nullptr);
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
new file mode 100644
index 0000000..4c31611
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require default Deleter ctor
+
+#include <memory>
+
+class Deleter
+{
+
+    Deleter() {}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) {}
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter> p(new int);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
new file mode 100644
index 0000000..dab42f2
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should only require default Deleter ctor
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[]> s(p);
+    assert(s.get() == p);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[], Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
new file mode 100644
index 0000000..af7f27f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+#include <memory>
+
+// unique_ptr<T[]>(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int[], Deleter&> p(new int);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
new file mode 100644
index 0000000..1afb1c3
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor shouldn't require complete type
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A[]> >
+struct B
+{
+    std::unique_ptr<A[], D> a_;
+    explicit B(A*);
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+    {
+    A* p = get();
+    check(3);
+    B<> s(p);
+    assert(s.get() == p);
+    }
+    check(0);
+    {
+    A* p = get();
+    check(3);
+    B<Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A[3];}
+
+void Deleter::operator()(A* p) {delete [] p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
new file mode 100644
index 0000000..31f7ce3
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr<T[]>(pointer) ctor
+
+// unique_ptr<T[]>(pointer) ctor should require non-pointer Deleter
+
+#include <memory>
+
+int main()
+{
+    std::unique_ptr<int[], void (*)(void*)> p(new int);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
new file mode 100644
index 0000000..591144f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+// unique_ptr(pointer) ctor should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    B* p = new B[3];
+    std::unique_ptr<A[]> s(p);
+    }
+    {
+    B* p = new B[3];
+    std::unique_ptr<A[], Deleter> s(p);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 0000000..2d62bcc
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 0000000..914076b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    Deleter d;
+    std::unique_ptr<A[], Deleter> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 0000000..a6f535f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    Deleter d;
+    std::unique_ptr<A[], Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 6);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 0000000..b635d50
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    std::unique_ptr<A[], const Deleter&> s(p, Deleter());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 0000000..a4c917c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr<T[], const D&>(pointer, d) does not requires CopyConstructible deleter
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete [] p;}
+};
+
+int main()
+{
+    {
+    A* p = new A[3];
+    assert(A::count == 3);
+    Deleter d;
+    std::unique_ptr<A[], const Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
new file mode 100644
index 0000000..0e03a7d
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+// unique_ptr(pointer, deleter) should not work with derived pointers
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete [] p;}
+};
+
+int main()
+{
+    B* p = new B[3];
+    std::unique_ptr<A[], Deleter> s(p, Deleter());
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
new file mode 100644
index 0000000..d79a4e3
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test release
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::unique_ptr<int[]> p(new int[3]);
+    int* i = p.get();
+    int* j = p.release();
+    assert(p.get() == 0);
+    assert(i == j);
+    delete [] j;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
new file mode 100644
index 0000000..8233ca0
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> p(new A[3]);
+    assert(A::count == 3);
+    A* i = p.get();
+    p.reset();
+    assert(A::count == 0);
+    assert(p.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A[]> p(new A[4]);
+    assert(A::count == 4);
+    A* i = p.get();
+    p.reset(new A[5]);
+    assert(A::count == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
new file mode 100644
index 0000000..bca6cb2
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A[]> p(new A);
+    assert(A::count == 1);
+    assert(B::count == 0);
+    A* i = p.get();
+    p.reset(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    std::unique_ptr<A[]> p(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    A* i = p.get();
+    p.reset(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
new file mode 100644
index 0000000..e9754cc
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    int state_;
+    static int count;
+    A() : state_(0) {++count;}
+    explicit A(int i) : state_(i) {++count;}
+    A(const A& a) : state_(a.state_) {++count;}
+    A& operator=(const A& a) {state_ = a.state_; return *this;}
+    ~A() {--count;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* p1 = new A[3];
+    std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1));
+    A* p2 = new A[3];
+    std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2));
+    assert(s1.get() == p1);
+    assert(s1.get_deleter().state() == 1);
+    assert(s2.get() == p2);
+    assert(s2.get_deleter().state() == 2);
+    s1.swap(s2);
+    assert(s1.get() == p2);
+    assert(s1.get_deleter().state() == 2);
+    assert(s2.get() == p1);
+    assert(s2.get_deleter().state() == 1);
+    assert(A::count == 6);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
new file mode 100644
index 0000000..46ba139
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::unique_ptr<int[]> p(new int(3));
+    assert(*p == 3);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
new file mode 100644
index 0000000..9ec9b95
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+    std::unique_ptr<int[]> p(new int [3]);
+    if (p)
+        ;
+    else
+        assert(false);
+    if (!p)
+        assert(false);
+    }
+    {
+    std::unique_ptr<int[]> p;
+    if (!p)
+        ;
+    else
+        assert(false);
+    if (p)
+        assert(false);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
new file mode 100644
index 0000000..2ae0659
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int* p = new int[3];
+    std::unique_ptr<int[]> s(p);
+    assert(s.get() == p);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
new file mode 100644
index 0000000..4496740
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+    void operator()(void*) {}
+
+    int test() {return 5;}
+    int test() const {return 6;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int[], Deleter> p;
+    assert(p.get_deleter().test() == 5);
+    }
+    {
+    const std::unique_ptr<int[], Deleter> p;
+    assert(p.get_deleter().test() == 6);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
new file mode 100644
index 0000000..519eae6
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+    int state_;
+    static int next_;
+public:
+    A() : state_(++next_) {}
+    int get() const {return state_;}
+
+    friend bool operator==(const A& x, int y)
+        {return x.state_ == y;}
+
+    A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+    std::unique_ptr<A[]> p(new A[3]);
+    assert(p[0] == 1);
+    assert(p[1] == 2);
+    assert(p[2] == 3);
+    p[0] = 3;
+    p[1] = 2;
+    p[2] = 1;
+    assert(p[0] == 3);
+    assert(p[1] == 2);
+    assert(p[2] == 1);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
new file mode 100644
index 0000000..1c90ba7
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    int i_;
+
+    A() : i_(7) {}
+};
+
+int main()
+{
+    std::unique_ptr<A[]> p(new A);
+    assert(p->i_ == 7);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
new file mode 100644
index 0000000..8721062
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr::pointer type
+
+#include <memory>
+#include <type_traits>
+
+struct Deleter
+{
+    struct pointer {};
+};
+
+int main()
+{
+    {
+    typedef std::unique_ptr<int> P;
+    static_assert((std::is_same<P::pointer, int*>::value), "");
+    }
+    {
+    typedef std::unique_ptr<int, Deleter> P;
+    static_assert((std::is_same<P::pointer, Deleter::pointer>::value), "");
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
new file mode 100644
index 0000000..57724ae
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    std::unique_ptr<A> s2;
+    s2 = s;
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
new file mode 100644
index 0000000..6641a58
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+// test move assignment.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s1(new A);
+    A* p = s1.get();
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s1);
+    assert(A::count == 1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5));
+    A* p = s1.get();
+    std::unique_ptr<A, Deleter<A> > s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(A::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s1.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    CDeleter<A> d1(5);
+    std::unique_ptr<A, CDeleter<A>&> s1(new A, d1);
+    A* p = s1.get();
+    CDeleter<A> d2(6);
+    std::unique_ptr<A, CDeleter<A>&> s2(new A, d2);
+    s2 = std::move(s1);
+    assert(s2.get() == p);
+    assert(s1.get() == 0);
+    assert(A::count == 1);
+    assert(d1.state() == 5);
+    assert(d2.state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
new file mode 100644
index 0000000..5046fd8
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A> s(new A);
+    std::unique_ptr<A> s2;
+    s2 = s;
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
new file mode 100644
index 0000000..aa4fdb8
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
new file mode 100644
index 0000000..e0d7c89
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
new file mode 100644
index 0000000..8940dbe
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
new file mode 100644
index 0000000..64d7b6b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
new file mode 100644
index 0000000..1ab0779
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// Can't assign from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
new file mode 100644
index 0000000..ff59ad4
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(new A);
+    assert(A::count == 2);
+    s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
new file mode 100644
index 0000000..e06b9d0
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    std::unique_ptr<B, Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
new file mode 100644
index 0000000..d726a83
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// test converting move assignment with reference deleters
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    CDeleter<B> db(5);
+    std::unique_ptr<B, CDeleter<B>&> s(new B, db);
+    A* p = s.get();
+    CDeleter<A> da(6);
+    std::unique_ptr<A, CDeleter<A>&> s2(new A, da);
+    s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s.get_deleter().state() == 5);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
new file mode 100644
index 0000000..ab33785
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+#include <memory>
+#include <cassert>
+
+// Can't assign from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
new file mode 100644
index 0000000..50c553e
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2;
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
new file mode 100644
index 0000000..541e10b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Can't assign from const lvalue
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    Deleter<B> db(5);
+    const std::unique_ptr<B, Deleter<B>&> s(new B, db);
+    A* p = s.get();
+    Deleter<A> da(6);
+    std::unique_ptr<A, Deleter<A>&> s2(new A, da);
+    s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
new file mode 100644
index 0000000..f7e128b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move assignment
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<A[], Deleter> s;
+    std::unique_ptr<A, Deleter> s2;
+    s2 = std::move(s);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
new file mode 100644
index 0000000..e2d7956
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 1);
+    s2 = 0;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
new file mode 100644
index 0000000..fb15849
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move assignment
+
+#include <memory>
+#include <cassert>
+
+// test assignment from null
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s2(new A);
+    assert(A::count == 1);
+    s2 = nullptr;
+    assert(A::count == 0);
+    assert(s2.get() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
new file mode 100644
index 0000000..a23f029
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up(std::move(ap));
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up;
+    up = std::move(ap);
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
new file mode 100644
index 0000000..1f317c7
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+//    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up(ap);
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A> up;
+    up = ap;
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
new file mode 100644
index 0000000..2dd5ea3
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// template <class U> explicit unique_ptr(auto_ptr<U>&);
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct Deleter
+{
+    template <class T>
+        void operator()(T*) {}
+};
+
+int main()
+{
+    {
+    B* p = new B;
+    std::auto_ptr<B> ap(p);
+    std::unique_ptr<A, Deleter> up(ap);
+    assert(up.get() == p);
+    assert(ap.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
new file mode 100644
index 0000000..2ffe1be
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require default Deleter ctor
+class Deleter
+{
+
+    Deleter() {}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) {}
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter> p;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
new file mode 100644
index 0000000..e63db5c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int> p;
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int, Deleter> p;
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
new file mode 100644
index 0000000..6907501
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter&> p;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
new file mode 100644
index 0000000..e9af7e2
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test default unique_ptr ctor
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+    std::unique_ptr<A, D> a_;
+    B() {}
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+int main()
+{
+    {
+    B<> s;
+    assert(s.get() == 0);
+    }
+    check(0);
+    {
+    B<Deleter> s;
+    assert(s.get() == 0);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::~B() {}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
new file mode 100644
index 0000000..78f6e73
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr default ctor
+
+#include <memory>
+
+// default unique_ptr ctor should require non-pointer Deleter
+
+int main()
+{
+    std::unique_ptr<int, void (*)(void*)> p;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
new file mode 100644
index 0000000..68ad589
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
new file mode 100644
index 0000000..65b1694
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A, Deleter<A> > s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    {
+    CDeleter d;
+    std::unique_ptr<A, CDeleter&> s(new A, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
new file mode 100644
index 0000000..897b889
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
new file mode 100644
index 0000000..4b997df
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+std::unique_ptr<A>
+source1()
+{
+    return std::unique_ptr<A>(new A);
+}
+
+void sink1(std::unique_ptr<A> p)
+{
+}
+
+std::unique_ptr<A, Deleter<A> >
+source2()
+{
+    return std::unique_ptr<A, Deleter<A> >(new A);
+}
+
+void sink2(std::unique_ptr<A, Deleter<A> > p)
+{
+}
+
+std::unique_ptr<A, CDeleter&>
+source3()
+{
+    static CDeleter d;
+    return std::unique_ptr<A, CDeleter&>(new A, d);
+}
+
+void sink3(std::unique_ptr<A, CDeleter&> p)
+{
+}
+
+int main()
+{
+    sink1(source1());
+    sink2(source2());
+    sink3(source3());
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
new file mode 100644
index 0000000..7fb1a0a
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
new file mode 100644
index 0000000..671e343
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr move ctor
+
+#include <memory>
+#include <cassert>
+
+// test move ctor.  Can't copy from const lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter> s(new A);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
new file mode 100644
index 0000000..5cd1b18
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// Can't construct from lvalue
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
new file mode 100644
index 0000000..42917b1
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
new file mode 100644
index 0000000..8f12592
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
new file mode 100644
index 0000000..f72efb9
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
new file mode 100644
index 0000000..c9076af
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
new file mode 100644
index 0000000..7463c38
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2(std::move(s));
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
new file mode 100644
index 0000000..7487e2d
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
new file mode 100644
index 0000000..18443a4
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
new file mode 100644
index 0000000..630fcb7
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    std::unique_ptr<B, Deleter<B> > s(new B);
+    std::unique_ptr<A, Deleter<A> > s2 = s;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
new file mode 100644
index 0000000..a8a9c76
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5));
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
new file mode 100644
index 0000000..04bf0f9
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
new file mode 100644
index 0000000..84cef78
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
new file mode 100644
index 0000000..da15c5c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
new file mode 100644
index 0000000..f809310
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    CDeleter<B> b(5);
+    std::unique_ptr<B, CDeleter<B>&> s(new B, b);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A> > s2 = std::move(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
new file mode 100644
index 0000000..4d47bfd
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
new file mode 100644
index 0000000..d568798
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2(s);
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
new file mode 100644
index 0000000..50647b9
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<B> s(new B);
+    A* p = s.get();
+    std::unique_ptr<A> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
new file mode 100644
index 0000000..0ca3d8c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Implicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    const std::unique_ptr<B, Deleter<B> > s(new B);
+    A* p = s.get();
+    std::unique_ptr<A, Deleter<A> > s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(s2.get_deleter().state() == 5);
+    assert(s.get_deleter().state() == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
new file mode 100644
index 0000000..e1eff8d
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+#include <memory>
+#include <cassert>
+
+// test converting move ctor.  Should only require a MoveConstructible deleter, or if
+//    deleter is a reference, not even that.
+// Explicit version
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+template <class T>
+class CDeleter
+{
+    int state_;
+
+    CDeleter(CDeleter&);
+    CDeleter& operator=(CDeleter&);
+public:
+
+    CDeleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    CDeleter<A> d;
+    const std::unique_ptr<B, CDeleter<A>&> s(new B, d);
+    A* p = s.get();
+    std::unique_ptr<A, CDeleter<A>&> s2 = s;
+    assert(s2.get() == p);
+    assert(s.get() == 0);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    d.set_state(6);
+    assert(s2.get_deleter().state() == d.state());
+    assert(s.get_deleter().state() ==  d.state());
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
new file mode 100644
index 0000000..cf03a2b
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr converting move ctor
+
+// Do not convert from an array unique_ptr
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+};
+
+struct Deleter
+{
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<A[], Deleter> s;
+    std::unique_ptr<A, Deleter> s2(std::move(s));
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
new file mode 100644
index 0000000..67a48a3
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// unique_ptr(nullptr_t);
+
+#include <memory>
+#include <cassert>
+
+// default unique_ptr ctor should only require default Deleter ctor
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int> p(nullptr);
+    assert(p.get() == 0);
+    }
+    {
+    std::unique_ptr<int, Deleter> p(nullptr);
+    assert(p.get() == 0);
+    assert(p.get_deleter().state() == 5);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
new file mode 100644
index 0000000..1af04b2
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require default Deleter ctor
+class Deleter
+{
+
+    Deleter() {}
+
+public:
+
+    Deleter(Deleter&) {}
+    Deleter& operator=(Deleter&) {}
+
+    void operator()(void*) const {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter> p(new int);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
new file mode 100644
index 0000000..e5fff77
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should only require default Deleter ctor
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A> s(p);
+    assert(s.get() == p);
+    }
+    assert(A::count == 0);
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A, Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
new file mode 100644
index 0000000..9b7dd8c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-reference Deleter ctor
+class Deleter
+{
+public:
+
+    void operator()(void*) {}
+};
+
+int main()
+{
+    std::unique_ptr<int, Deleter&> p(new int);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
new file mode 100644
index 0000000..a226e87
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor shouldn't require complete type
+
+struct A;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p);
+};
+
+void check(int i);
+
+template <class D = std::default_delete<A> >
+struct B
+{
+    std::unique_ptr<A, D> a_;
+    explicit B(A*);
+    ~B();
+
+    A* get() const {return a_.get();}
+    D& get_deleter() {return a_.get_deleter();}
+};
+
+A* get();
+
+int main()
+{
+    {
+    A* p = get();
+    check(1);
+    B<> s(p);
+    assert(s.get() == p);
+    }
+    check(0);
+    {
+    A* p = get();
+    check(1);
+    B<Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    check(0);
+}
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+A* get() {return new A;}
+
+void Deleter::operator()(A* p) {delete p;}
+
+void check(int i)
+{
+    assert(A::count == i);
+}
+
+template <class D>
+B<D>::B(A* a) : a_(a) {}
+
+template <class D>
+B<D>::~B() {}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
new file mode 100644
index 0000000..a917d87
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+
+// unique_ptr(pointer) ctor should require non-pointer Deleter
+
+int main()
+{
+    std::unique_ptr<int, void (*)(void*)> p(new int);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
new file mode 100644
index 0000000..42fc094
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer) ctor should work with derived pointers
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    B* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    std::unique_ptr<A> s(p);
+    assert(s.get() == p);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    B* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    std::unique_ptr<A, Deleter> s(p);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
new file mode 100644
index 0000000..130f91d
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+template <class T>
+class Deleter
+{
+    int state_;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
+    Deleter& operator=(Deleter&& r)
+    {
+        state_ = r.state_;
+        r.state_ = 0;
+        return *this;
+    }
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
+    Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
+    Deleter& operator=(std::__rv<Deleter> r)
+    {
+        state_ = r->state_;
+        r->state_ = 0;
+        return *this;
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    Deleter() : state_(5) {}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U>&& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {d.set_state(0);}
+
+private:
+    template <class U>
+        Deleter(const Deleter<U>& d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    template <class U>
+        Deleter(Deleter<U> d,
+            typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
+            : state_(d.state()) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+public:
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
new file mode 100644
index 0000000..421bec5
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, d) requires CopyConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    Deleter d;
+    std::unique_ptr<A, Deleter> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
new file mode 100644
index 0000000..bce79db
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    Deleter d;
+    std::unique_ptr<A, Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    d.set_state(6);
+    assert(s.get_deleter().state() == 6);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
new file mode 100644
index 0000000..7cacd1f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, D()) should not compile
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    std::unique_ptr<A, const Deleter&> s(p, Deleter());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
new file mode 100644
index 0000000..a7750fc
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr<T, const D&>(pointer, d) does not requires CopyConstructible deleter
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+class Deleter
+{
+    int state_;
+
+    Deleter(const Deleter&);
+    Deleter& operator=(const Deleter&);
+public:
+
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+    void set_state(int s) {state_ = s;}
+
+    void operator()(A* p) const {delete p;}
+};
+
+int main()
+{
+    {
+    A* p = new A;
+    assert(A::count == 1);
+    Deleter d;
+    std::unique_ptr<A, const Deleter&> s(p, d);
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
new file mode 100644
index 0000000..1a83258
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with derived pointers
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+class Deleter
+{
+    int state_;
+
+public:
+    Deleter() : state_(5) {}
+
+    int state() const {return state_;}
+
+    void operator()(A* p) {delete p;}
+};
+
+int main()
+{
+    {
+    B* p = new B;
+    assert(A::count == 1);
+    assert(B::count == 1);
+    std::unique_ptr<A, Deleter> s(p, Deleter());
+    assert(s.get() == p);
+    assert(s.get_deleter().state() == 5);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
new file mode 100644
index 0000000..ed68052
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test unique_ptr(pointer, deleter) ctor
+
+#include <memory>
+#include <cassert>
+
+// unique_ptr(pointer, deleter) should work with function pointers
+// unique_ptr<void> should work
+
+bool my_free_called = false;
+
+void my_free(void*)
+{
+    my_free_called = true;
+}
+
+int main()
+{
+    {
+    int i = 0;
+    std::unique_ptr<void, void (*)(void*)> s(&i, my_free);
+    assert(s.get() == &i);
+    assert(s.get_deleter() == my_free);
+    assert(!my_free_called);
+    }
+    assert(my_free_called);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
new file mode 100644
index 0000000..064f38c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// The deleter is not called if get() == 0
+
+#include <memory>
+#include <cassert>
+
+class Deleter
+{
+    int state_;
+
+    Deleter(Deleter&);
+    Deleter& operator=(Deleter&);
+
+public:
+    Deleter() : state_(0) {}
+
+    int state() const {return state_;}
+
+    void operator()(void*) {++state_;}
+};
+
+int main()
+{
+    Deleter d;
+    assert(d.state() == 0);
+    {
+    std::unique_ptr<int, Deleter&> p(0, d);
+    assert(p.get() == 0);
+    assert(&p.get_deleter() == &d);
+    }
+    assert(d.state() == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
new file mode 100644
index 0000000..dadd4ec
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test release
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::unique_ptr<int> p(new int(3));
+    int* i = p.get();
+    int* j = p.release();
+    assert(p.get() == 0);
+    assert(i == j);
+    delete j;
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp
new file mode 100644
index 0000000..4041fbb
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> p(new A);
+    assert(A::count == 1);
+    A* i = p.get();
+    p.reset();
+    assert(A::count == 0);
+    assert(p.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A> p(new A);
+    assert(A::count == 1);
+    A* i = p.get();
+    p.reset(new A);
+    assert(A::count == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
new file mode 100644
index 0000000..6acc3d7
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> p(new A);
+    assert(A::count == 1);
+    assert(B::count == 0);
+    A* i = p.get();
+    p.reset(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+    {
+    std::unique_ptr<A> p(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    A* i = p.get();
+    p.reset(new B);
+    assert(A::count == 1);
+    assert(B::count == 1);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp
new file mode 100644
index 0000000..58b05ef
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test reset against resetting self
+
+#include <memory>
+
+struct A
+{
+    std::unique_ptr<A> ptr_;
+
+    A() : ptr_(this) {}
+    void reset() {ptr_.reset();}
+};
+
+int main()
+{
+    (new A)->reset();
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp
new file mode 100644
index 0000000..d0a03be
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../../deleter.h"
+
+struct A
+{
+    int state_;
+    static int count;
+    explicit A(int i) : state_(i) {++count;}
+    A(const A& a) : state_(a.state_) {++count;}
+    A& operator=(const A& a) {state_ = a.state_; return *this;}
+    ~A() {--count;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* p1 = new A(1);
+    std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1));
+    A* p2 = new A(2);
+    std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2));
+    assert(s1.get() == p1);
+    assert(*s1 == A(1));
+    assert(s1.get_deleter().state() == 1);
+    assert(s2.get() == p2);
+    assert(*s2 == A(2));
+    assert(s2.get_deleter().state() == 2);
+    s1.swap(s2);
+    assert(s1.get() == p2);
+    assert(*s1 == A(2));
+    assert(s1.get_deleter().state() == 2);
+    assert(s2.get() == p1);
+    assert(*s2 == A(1));
+    assert(s2.get_deleter().state() == 1);
+    assert(A::count == 2);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
new file mode 100644
index 0000000..9d0cfca
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::unique_ptr<int> p(new int(3));
+    assert(*p == 3);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
new file mode 100644
index 0000000..d5c7445
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op*()
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+    std::unique_ptr<int> p(new int(3));
+    if (p)
+        ;
+    else
+        assert(false);
+    if (!p)
+        assert(false);
+    }
+    {
+    std::unique_ptr<int> p;
+    if (!p)
+        ;
+    else
+        assert(false);
+    if (p)
+        assert(false);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
new file mode 100644
index 0000000..24fa6be
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int* p = new int;
+    std::unique_ptr<int> s(p);
+    assert(s.get() == p);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
new file mode 100644
index 0000000..5ed8a22
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test get_deleter()
+
+#include <memory>
+#include <cassert>
+
+struct Deleter
+{
+    void operator()(void*) {}
+
+    int test() {return 5;}
+    int test() const {return 6;}
+};
+
+int main()
+{
+    {
+    std::unique_ptr<int, Deleter> p;
+    assert(p.get_deleter().test() == 5);
+    }
+    {
+    const std::unique_ptr<int, Deleter> p;
+    assert(p.get_deleter().test() == 6);
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
new file mode 100644
index 0000000..21e829c
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op[](size_t)
+
+#include <memory>
+#include <cassert>
+
+class A
+{
+    int state_;
+    static int next_;
+public:
+    A() : state_(++next_) {}
+    int get() const {return state_;}
+
+    friend bool operator==(const A& x, int y)
+        {return x.state_ == y;}
+
+    A& operator=(int i) {state_ = i; return *this;}
+};
+
+int A::next_ = 0;
+
+int main()
+{
+    std::unique_ptr<A> p(new A[3]);
+    assert(p[0] == 1);
+    assert(p[1] == 2);
+    assert(p[2] == 3);
+    p[0] = 3;
+    p[1] = 2;
+    p[2] = 1;
+    assert(p[0] == 3);
+    assert(p[1] == 2);
+    assert(p[2] == 1);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
new file mode 100644
index 0000000..47de8f6
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// test op->()
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    int i_;
+
+    A() : i_(7) {}
+};
+
+int main()
+{
+    std::unique_ptr<A> p(new A);
+    assert(p->i_ == 7);
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
new file mode 100644
index 0000000..22ae217
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class T, class D>
+//     bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+//     bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+//     bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+//     bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+//     bool operator<(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+//     bool operator<(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+//     bool operator<=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+//     bool operator<=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+//     bool operator>(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+//     bool operator>(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+// template <class T, class D>
+//     bool operator>=(const unique_ptr<T, D>& x, nullptr_t) noexcept;
+// template <class T, class D>
+//     bool operator>=(nullptr_t, const unique_ptr<T, D>& y) noexcept;
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+    const std::unique_ptr<int> p1(new int(1));
+    assert(!(p1 == nullptr));
+    assert(!(nullptr == p1));
+    assert(!(p1 < nullptr));
+    assert( (nullptr < p1));
+    assert(!(p1 <= nullptr));
+    assert( (nullptr <= p1));
+    assert( (p1 > nullptr));
+    assert(!(nullptr > p1));
+    assert( (p1 >= nullptr));
+    assert(!(nullptr >= p1));
+
+    const std::unique_ptr<int> p2;
+    assert( (p2 == nullptr));
+    assert( (nullptr == p2));
+    assert(!(p2 < nullptr));
+    assert(!(nullptr < p2));
+    assert( (p2 <= nullptr));
+    assert( (nullptr <= p2));
+    assert(!(p2 > nullptr));
+    assert(!(nullptr > p2));
+    assert( (p2 >= nullptr));
+    assert( (nullptr >= p2));
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
new file mode 100644
index 0000000..3788654
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// template <class T1, class D1, class T2, class D2>
+//   bool
+//   operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+//   bool
+//   operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter<A> > p1(new A);
+    const std::unique_ptr<A, Deleter<A> > p2(new A);
+    assert(!(p1 == p2));
+    assert(p1 != p2);
+    }
+    {
+    const std::unique_ptr<A, Deleter<A> > p1(new A);
+    const std::unique_ptr<B, Deleter<B> > p2(new B);
+    assert(!(p1 == p2));
+    assert(p1 != p2);
+    }
+    {
+    const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+    const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
+    assert(!(p1 == p2));
+    assert(p1 != p2);
+    }
+    {
+    const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+    const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
+    assert(!(p1 == p2));
+    assert(p1 != p2);
+    }
+    {
+    const std::unique_ptr<A, Deleter<A> > p1;
+    const std::unique_ptr<A, Deleter<A> > p2;
+    assert(p1 == p2);
+    assert(!(p1 != p2));
+    }
+    {
+    const std::unique_ptr<A, Deleter<A> > p1;
+    const std::unique_ptr<B, Deleter<B> > p2;
+    assert(p1 == p2);
+    assert(!(p1 != p2));
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
new file mode 100644
index 0000000..80653cf
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// template <class T1, class D1, class T2, class D2>
+//   bool
+//   operator< (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+//   bool
+//   operator> (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+//   bool
+//   operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+// template <class T1, class D1, class T2, class D2>
+//   bool
+//   operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    static int count;
+    A() {++count;}
+    A(const A&) {++count;}
+    virtual ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct B
+    : public A
+{
+    static int count;
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+int main()
+{
+    {
+    const std::unique_ptr<A, Deleter<A> > p1(new A);
+    const std::unique_ptr<A, Deleter<A> > p2(new A);
+    assert((p1 < p2) == !(p1 > p2));
+    assert((p1 < p2) == (p1 <= p2));
+    assert((p1 < p2) == !(p1 >= p2));
+    }
+    {
+    const std::unique_ptr<A, Deleter<A> > p1(new A);
+    const std::unique_ptr<B, Deleter<B> > p2(new B);
+    assert((p1 < p2) == !(p1 > p2));
+    assert((p1 < p2) == (p1 <= p2));
+    assert((p1 < p2) == !(p1 >= p2));
+    }
+    {
+    const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+    const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
+    assert((p1 < p2) == !(p1 > p2));
+    assert((p1 < p2) == (p1 <= p2));
+    assert((p1 < p2) == !(p1 >= p2));
+    }
+    {
+    const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
+    const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
+    assert((p1 < p2) == !(p1 > p2));
+    assert((p1 < p2) == (p1 <= p2));
+    assert((p1 < p2) == !(p1 >= p2));
+    }
+    {
+    const std::unique_ptr<A, Deleter<A> > p1;
+    const std::unique_ptr<A, Deleter<A> > p2;
+    assert((p1 < p2) == (p1 > p2));
+    assert((p1 < p2) == !(p1 <= p2));
+    assert((p1 < p2) == !(p1 >= p2));
+    }
+    {
+    const std::unique_ptr<A, Deleter<A> > p1;
+    const std::unique_ptr<B, Deleter<B> > p2;
+    assert((p1 < p2) == (p1 > p2));
+    assert((p1 < p2) == !(p1 <= p2));
+    assert((p1 < p2) == !(p1 >= p2));
+    }
+}
diff --git a/final/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/final/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
new file mode 100644
index 0000000..44b746f
--- /dev/null
+++ b/final/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// unique_ptr
+
+// Test swap
+
+#include <memory>
+#include <cassert>
+
+#include "../deleter.h"
+
+struct A
+{
+    int state_;
+    static int count;
+    A() : state_(0) {++count;}
+    explicit A(int i) : state_(i) {++count;}
+    A(const A& a) : state_(a.state_) {++count;}
+    A& operator=(const A& a) {state_ = a.state_; return *this;}
+    ~A() {--count;}
+
+    friend bool operator==(const A& x, const A& y)
+        {return x.state_ == y.state_;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* p1 = new A(1);
+    std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1));
+    A* p2 = new A(2);
+    std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2));
+    assert(s1.get() == p1);
+    assert(*s1 == A(1));
+    assert(s1.get_deleter().state() == 1);
+    assert(s2.get() == p2);
+    assert(*s2 == A(2));
+    assert(s2.get_deleter().state() == 2);
+    swap(s1, s2);
+    assert(s1.get() == p2);
+    assert(*s1 == A(2));
+    assert(s1.get_deleter().state() == 2);
+    assert(s2.get() == p1);
+    assert(*s2 == A(1));
+    assert(s2.get_deleter().state() == 1);
+    assert(A::count == 2);
+    }
+    assert(A::count == 0);
+    {
+    A* p1 = new A[3];
+    std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1));
+    A* p2 = new A[3];
+    std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2));
+    assert(s1.get() == p1);
+    assert(s1.get_deleter().state() == 1);
+    assert(s2.get() == p2);
+    assert(s2.get_deleter().state() == 2);
+    swap(s1, s2);
+    assert(s1.get() == p2);
+    assert(s1.get_deleter().state() == 2);
+    assert(s2.get() == p1);
+    assert(s2.get_deleter().state() == 1);
+    assert(A::count == 6);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp b/final/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
new file mode 100644
index 0000000..bbf4be2
--- /dev/null
+++ b/final/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// void declare_no_pointers(char* p, size_t n);
+// void undeclare_no_pointers(char* p, size_t n);
+
+#include <memory>
+
+int main()
+{
+    char* p = new char[10];
+    std::declare_no_pointers(p, 10);
+    std::undeclare_no_pointers(p, 10);
+    delete [] p;
+}
diff --git a/final/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp b/final/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
new file mode 100644
index 0000000..3f0bcea
--- /dev/null
+++ b/final/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// void declare_reachable(void* p);
+// template <class T> T* undeclare_reachable(T* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int* p = new int;
+    std::declare_reachable(p);
+    assert(std::undeclare_reachable(p) == p);
+    delete p;
+}
diff --git a/final/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp b/final/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
new file mode 100644
index 0000000..1f27b45
--- /dev/null
+++ b/final/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// pointer_safety get_pointer_safety();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::pointer_safety r = std::get_pointer_safety();
+    assert(r == std::pointer_safety::relaxed ||
+           r == std::pointer_safety::preferred ||
+           r == std::pointer_safety::strict);
+}
diff --git a/final/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp b/final/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
new file mode 100644
index 0000000..58686d6
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// template<class T>
+// class enable_shared_from_this
+// {
+// protected:
+//     enable_shared_from_this();
+//     enable_shared_from_this(enable_shared_from_this const&);
+//     enable_shared_from_this& operator=(enable_shared_from_this const&);
+//     ~enable_shared_from_this();
+// public:
+//     shared_ptr<T> shared_from_this();
+//     shared_ptr<T const> shared_from_this() const;
+// };
+
+#include <memory>
+#include <cassert>
+
+struct T
+    : public std::enable_shared_from_this<T>
+{
+};
+
+struct Y : T {};
+
+struct Z : Y {};
+
+int main()
+{
+    {
+    std::shared_ptr<Y> p(new Z);
+    std::shared_ptr<T> q = p->shared_from_this();
+    assert(p == q);
+    assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
+    }
+    {
+    std::shared_ptr<Y> p = std::make_shared<Z>();
+    std::shared_ptr<T> q = p->shared_from_this();
+    assert(p == q);
+    assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp
new file mode 100644
index 0000000..990cb58
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T>
+// struct hash<shared_ptr<T>>
+// {
+//     typedef shared_ptr<T>    argument_type;
+//     typedef size_t           result_type;
+//     size_t operator()(const shared_ptr<T>& p) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int* ptr = new int;
+    std::shared_ptr<int> p(ptr);
+    std::hash<std::shared_ptr<int> > f;
+    std::size_t h = f(p);
+    assert(h == std::hash<int*>()(ptr));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
new file mode 100644
index 0000000..5cd4ab1
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T, class D>
+// struct hash<unique_ptr<T, D>>
+// {
+//     typedef unique_ptr<T, D> argument_type;
+//     typedef size_t           result_type;
+//     size_t operator()(const unique_ptr<T, D>& p) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    int* ptr = new int;
+    std::unique_ptr<int> p(ptr);
+    std::hash<std::unique_ptr<int> > f;
+    std::size_t h = f(p);
+    assert(h == std::hash<int*>()(ptr));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp
new file mode 100644
index 0000000..0c80324
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong(shared_ptr<T>* p, shared_ptr<T>* v,
+//                                shared_ptr<T> w);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v(new int(3));
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_strong(&p, &v, w);
+        assert(b == false);
+        assert(*p == 4);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v = p;
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_strong(&p, &v, w);
+        assert(b == true);
+        assert(*p == 2);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp
new file mode 100644
index 0000000..9f93ae8
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+//                                         shared_ptr<T> w, memory_order success,
+//                                         memory_order failure);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v(new int(3));
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w,
+                                                              std::memory_order_seq_cst,
+                                                              std::memory_order_seq_cst);
+        assert(b == false);
+        assert(*p == 4);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v = p;
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w,
+                                                              std::memory_order_seq_cst,
+                                                              std::memory_order_seq_cst);
+        assert(b == true);
+        assert(*p == 2);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp
new file mode 100644
index 0000000..1c274d1
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v,
+//                              shared_ptr<T> w);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v(new int(3));
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_weak(&p, &v, w);
+        assert(b == false);
+        assert(*p == 4);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v = p;
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_weak(&p, &v, w);
+        assert(b == true);
+        assert(*p == 2);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp
new file mode 100644
index 0000000..7741223
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// bool
+// atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
+//                                       shared_ptr<T> w, memory_order success,
+//                                       memory_order failure);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v(new int(3));
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w,
+                                                            std::memory_order_seq_cst,
+                                                            std::memory_order_seq_cst);
+        assert(b == false);
+        assert(*p == 4);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> v = p;
+        std::shared_ptr<int> w(new int(2));
+        bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w,
+                                                            std::memory_order_seq_cst,
+                                                            std::memory_order_seq_cst);
+        assert(b == true);
+        assert(*p == 2);
+        assert(*v == 4);
+        assert(*w == 2);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp
new file mode 100644
index 0000000..6e6f635
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> r(new int(3));
+        r = std::atomic_exchange(&p, r);
+        assert(*p == 3);
+        assert(*r == 4);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp
new file mode 100644
index 0000000..f6a2085
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p(new int(4));
+        std::shared_ptr<int> r(new int(3));
+        r = std::atomic_exchange_explicit(&p, r, std::memory_order_seq_cst);
+        assert(*p == 3);
+        assert(*r == 4);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp
new file mode 100644
index 0000000..0420734
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T>
+// bool
+// atomic_is_lock_free(const shared_ptr<T>* p);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        const std::shared_ptr<int> p(new int(3));
+        assert(std::atomic_is_lock_free(&p) == false);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp
new file mode 100644
index 0000000..49fd1b6
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_load(const shared_ptr<T>* p)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p(new int(3));
+        std::shared_ptr<int> q = std::atomic_load(&p);
+        assert(*q == *p);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp
new file mode 100644
index 0000000..94d0615
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// shared_ptr<T>
+// atomic_load_explicit(const shared_ptr<T>* p, memory_order mo)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        const std::shared_ptr<int> p(new int(3));
+        std::shared_ptr<int> q = std::atomic_load_explicit(&p, std::memory_order_relaxed);
+        assert(*q == *p);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp
new file mode 100644
index 0000000..83ee45f
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// void
+// atomic_store(shared_ptr<T>* p, shared_ptr<T> r)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p;
+        std::shared_ptr<int> r(new int(3));
+        std::atomic_store(&p, r);
+        assert(*p == *r);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp
new file mode 100644
index 0000000..2b3bb8b
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+// void
+// atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if __has_feature(cxx_atomic)
+    {
+        std::shared_ptr<int> p;
+        std::shared_ptr<int> r(new int(3));
+        std::atomic_store_explicit(&p, r, std::memory_order_seq_cst);
+        assert(*p == *r);
+    }
+#endif
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
new file mode 100644
index 0000000..7af7468
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// Example move-only deleter
+
+#ifndef DELETER_H
+#define DELETER_H
+
+#include <type_traits>
+#include <cassert>
+
+struct test_deleter_base
+{
+    static int count;
+    static int dealloc_count;
+};
+
+int test_deleter_base::count = 0;
+int test_deleter_base::dealloc_count = 0;
+
+template <class T>
+class test_deleter
+    : public test_deleter_base
+{
+    int state_;
+
+public:
+
+    test_deleter() : state_(0) {++count;}
+    explicit test_deleter(int s) : state_(s) {++count;}
+    test_deleter(const test_deleter& d)
+        : state_(d.state_) {++count;}
+    ~test_deleter() {assert(state_ >= 0); --count; state_ = -1;}
+
+    int state() const {return state_;}
+    void set_state(int i) {state_ = i;}
+
+    void operator()(T* p) {assert(state_ >= 0); ++dealloc_count; delete p;}
+};
+
+template <class T>
+void
+swap(test_deleter<T>& x, test_deleter<T>& y)
+{
+    test_deleter<T> t(std::move(x));
+    x = std::move(y);
+    y = std::move(t);
+}
+
+#endif  // DELETER_H
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp
new file mode 100644
index 0000000..8175312
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class shared_ptr
+// {
+// public:
+//     typedef T element_type;
+//     ...
+// };
+
+#include <memory>
+
+struct A;  // purposefully incomplete
+
+int main()
+{
+    static_assert((std::is_same<std::shared_ptr<A>::element_type, A>::value), "");
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
new file mode 100644
index 0000000..a6c6249
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class D, class T> D* get_deleter(const shared_ptr<T>& p);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        {
+            A* ptr = new A;
+            std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+            test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+            assert(test_deleter<A>::count == 1);
+            assert(test_deleter<A>::dealloc_count == 0);
+            assert(d);
+            assert(d->state() == 3);
+        }
+        assert(A::count == 0);
+        assert(test_deleter<A>::count == 0);
+        assert(test_deleter<A>::dealloc_count == 1);
+    }
+    test_deleter<A>::dealloc_count = 0;
+    {
+        {
+            std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+            test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+            assert(test_deleter<A>::count == 1);
+            assert(test_deleter<A>::dealloc_count == 0);
+            assert(d);
+            assert(d->state() == 3);
+        }
+        assert(A::count == 0);
+        assert(test_deleter<A>::count == 0);
+        assert(test_deleter<A>::dealloc_count == 1);
+    }
+    test_deleter<A>::dealloc_count = 0;
+    {
+        std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+        std::default_delete<A>* d = std::get_deleter<std::default_delete<A> >(p);
+        assert(d == 0);
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
new file mode 100644
index 0000000..21cdf4a
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::auto_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::auto_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::auto_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::auto_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
new file mode 100644
index 0000000..5d27a88
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr& operator=(const shared_ptr& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB(new A);
+            pB = pA;
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 2);
+            assert(pA.use_count() == 2);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        const std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB(new A);
+            pB = pA;
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        const std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB;
+            pB = pA;
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 2);
+            assert(pA.use_count() == 2);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        const std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB;
+            pB = pA;
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..abd3d37
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = pA;
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 2);
+            assert(pA.use_count() == 2);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        const std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = pA;
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        const std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = pA;
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 2);
+            assert(pA.use_count() == 2);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        const std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = pA;
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == pB.get());
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 0000000..93956bc
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
new file mode 100644
index 0000000..4194890
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr& operator=(shared_ptr&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB(new A);
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB(new A);
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB;
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<A> pB;
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+#endif // _LIBCXX_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
new file mode 100644
index 0000000..742d8c1
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::unique_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::unique_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB(new B);
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::unique_ptr<A> pA(new A);
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::unique_ptr<A> pA;
+        A* ptrA = pA.get();
+        {
+            std::shared_ptr<B> pB;
+            pB = std::move(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 1);
+            assert(pA.get() == 0);
+            assert(pB.get() == ptrA);
+        }
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp
new file mode 100644
index 0000000..7d771d0
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<const A> pA(new A);
+        std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA);
+        assert(pB.get() == pA.get());
+        assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+    }
+    {
+        const std::shared_ptr<const A> pA;
+        std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA);
+        assert(pB.get() == pA.get());
+        assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
new file mode 100644
index 0000000..4f88a5c
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<B> pB(new A);
+        std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB);
+        assert(pA.get() == pB.get());
+        assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+    }
+    {
+        const std::shared_ptr<B> pB(new B);
+        std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB);
+        assert(pA.get() == 0);
+        assert(pA.use_count() == 0);
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
new file mode 100644
index 0000000..98fa138
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<A> pA(new A);
+        std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA);
+        assert(pB.get() == pA.get());
+        assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+    }
+    {
+        const std::shared_ptr<B> pA(new A);
+        std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA);
+        assert(pB.get() == pA.get());
+        assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+    }
+    {
+        const std::shared_ptr<A> pA;
+        std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA);
+        assert(pB.get() == pA.get());
+        assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+    }
+    {
+        const std::shared_ptr<B> pA;
+        std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA);
+        assert(pB.get() == pA.get());
+        assert(!pB.owner_before(pA) && !pA.owner_before(pB));
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
new file mode 100644
index 0000000..f40cbc3
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class T>
+//     bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+//     bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+//     bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+//     bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+//     bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+//     bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+//     bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+//     bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+//     bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+//     bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept;
+// template <class T>
+//     bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept;
+// template <class T>
+//     bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept;
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+    const std::shared_ptr<int> p1(new int(1));
+    assert(!(p1 == nullptr));
+    assert(!(nullptr == p1));
+    assert(!(p1 < nullptr));
+    assert( (nullptr < p1));
+    assert(!(p1 <= nullptr));
+    assert( (nullptr <= p1));
+    assert( (p1 > nullptr));
+    assert(!(nullptr > p1));
+    assert( (p1 >= nullptr));
+    assert(!(nullptr >= p1));
+
+    const std::shared_ptr<int> p2;
+    assert( (p2 == nullptr));
+    assert( (nullptr == p2));
+    assert(!(p2 < nullptr));
+    assert(!(nullptr < p2));
+    assert( (p2 <= nullptr));
+    assert( (nullptr <= p2));
+    assert(!(p2 > nullptr));
+    assert(!(nullptr > p2));
+    assert( (p2 >= nullptr));
+    assert( (nullptr >= p2));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp
new file mode 100644
index 0000000..c4cd169
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b);
+// template<class T, class U> bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+    int* ptr1(new int);
+    int* ptr2(new int);
+    const std::shared_ptr<int> p1(ptr1);
+    const std::shared_ptr<int> p2(ptr2);
+    const std::shared_ptr<int> p3(ptr2, do_nothing);
+    assert(p1 != p2);
+    assert(p2 == p3);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp
new file mode 100644
index 0000000..5a90a9a
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+void do_nothing(int*) {}
+
+int main()
+{
+    int* ptr1(new int);
+    int* ptr2(new int);
+    const std::shared_ptr<int> p1(ptr1);
+    const std::shared_ptr<int> p2(ptr2);
+    const std::shared_ptr<int> p3(ptr2, do_nothing);
+    assert((p1 < p2) == (ptr1 < ptr2));
+    assert(!(p2 < p3) && !(p3 < p2));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
new file mode 100644
index 0000000..27046cf
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y> explicit shared_ptr(auto_ptr<Y>&& r);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next)
+        throw std::bad_alloc();
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::auto_ptr<A> ptr(new A);
+    A* raw_ptr = ptr.get();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    std::shared_ptr<B> p(std::move(ptr));
+#else
+    std::shared_ptr<B> p(ptr);
+#endif
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(p.use_count() == 1);
+    assert(p.get() == raw_ptr);
+    assert(ptr.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::auto_ptr<A> ptr(new A);
+    A* raw_ptr = ptr.get();
+    throw_next = true;
+    try
+    {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        std::shared_ptr<B> p(std::move(ptr));
+#else
+        std::shared_ptr<B> p(ptr);
+#endif
+        assert(false);
+    }
+    catch (...)
+    {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(ptr.get() == raw_ptr);
+#else
+        // Without rvalue references, ptr got copied into
+        // the shared_ptr destructor and the copy was
+        // destroyed during unwinding.
+        assert(A::count == 0);
+        assert(B::count == 0);
+#endif
+    }
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp
new file mode 100644
index 0000000..9af5d7e
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr();
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::shared_ptr<int> p;
+    assert(p.use_count() == 0);
+    assert(p.get() == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp
new file mode 100644
index 0000000..3a9b3a9
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr(nullptr_t)
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    std::shared_ptr<int> p(nullptr);
+    assert(p.use_count() == 0);
+    assert(p.get() == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
new file mode 100644
index 0000000..7d4dc38
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class D> shared_ptr(nullptr_t, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+    assert(A::count == 0);
+    assert(p.use_count() == 1);
+    assert(p.get() == 0);
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+    assert(test_deleter<A>::count == 1);
+    assert(test_deleter<A>::dealloc_count == 0);
+    assert(d);
+    assert(d->state() == 3);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 1);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
new file mode 100644
index 0000000..7966e00
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5));
+    assert(A::count == 0);
+    assert(p.use_count() == 1);
+    assert(p.get() == 0);
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+    assert(test_deleter<A>::count == 1);
+    assert(test_deleter<A>::dealloc_count == 0);
+    assert(d);
+    assert(d->state() == 3);
+    assert(test_allocator<A>::count == 1);
+    assert(test_allocator<A>::alloc_count == 1);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 1);
+    assert(test_allocator<A>::count == 0);
+    assert(test_allocator<A>::alloc_count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
new file mode 100644
index 0000000..ab2c73e
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    try
+    {
+        test_allocator<A>::throw_after = 0;
+        std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5));
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(A::count == 0);
+        assert(test_deleter<A>::count == 0);
+        assert(test_deleter<A>::dealloc_count == 1);
+        assert(test_allocator<A>::count == 0);
+        assert(test_allocator<A>::alloc_count == 0);
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
new file mode 100644
index 0000000..e8365ae
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class D> shared_ptr(nullptr_t, D d);
+
+#include <memory>
+#include <cassert>
+#include <new>
+#include <cstdlib>
+#include "../test_deleter.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next)
+        throw std::bad_alloc();
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+int main()
+{
+    throw_next = true;
+    try
+    {
+        std::shared_ptr<A> p(nullptr, test_deleter<A>(3));
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(A::count == 0);
+        assert(test_deleter<A>::count == 0);
+        assert(test_deleter<A>::dealloc_count == 1);
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
new file mode 100644
index 0000000..c9cffa1
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y> explicit shared_ptr(Y* p);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* ptr = new A;
+    std::shared_ptr<A> p(ptr);
+    assert(A::count == 1);
+    assert(p.use_count() == 1);
+    assert(p.get() == ptr);
+    }
+    assert(A::count == 0);
+    {
+    A* ptr = new A;
+    std::shared_ptr<void> p(ptr);
+    assert(A::count == 1);
+    assert(p.use_count() == 1);
+    assert(p.get() == ptr);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
new file mode 100644
index 0000000..43eedee
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> shared_ptr(Y* p, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* ptr = new A;
+    std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+    assert(A::count == 1);
+    assert(p.use_count() == 1);
+    assert(p.get() == ptr);
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+    assert(test_deleter<A>::count == 1);
+    assert(test_deleter<A>::dealloc_count == 0);
+    assert(d);
+    assert(d->state() == 3);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 1);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
new file mode 100644
index 0000000..23d3f10
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    A* ptr = new A;
+    std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5));
+    assert(A::count == 1);
+    assert(p.use_count() == 1);
+    assert(p.get() == ptr);
+    test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+    assert(test_deleter<A>::count == 1);
+    assert(test_deleter<A>::dealloc_count == 0);
+    assert(d);
+    assert(d->state() == 3);
+    assert(test_allocator<A>::count == 1);
+    assert(test_allocator<A>::alloc_count == 1);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 1);
+    assert(test_allocator<A>::count == 0);
+    assert(test_allocator<A>::alloc_count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
new file mode 100644
index 0000000..4220993
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    A* ptr = new A;
+    try
+    {
+        test_allocator<A>::throw_after = 0;
+        std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5));
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(A::count == 0);
+        assert(test_deleter<A>::count == 0);
+        assert(test_deleter<A>::dealloc_count == 1);
+        assert(test_allocator<A>::count == 0);
+        assert(test_allocator<A>::alloc_count == 0);
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
new file mode 100644
index 0000000..79aaa58
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> shared_ptr(Y* p, D d);
+
+#include <memory>
+#include <cassert>
+#include <new>
+#include <cstdlib>
+#include "../test_deleter.h"
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next)
+        throw std::bad_alloc();
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+int main()
+{
+    A* ptr = new A;
+    throw_next = true;
+    try
+    {
+        std::shared_ptr<A> p(ptr, test_deleter<A>(3));
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(A::count == 0);
+        assert(test_deleter<A>::count == 0);
+        assert(test_deleter<A>::dealloc_count == 1);
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
new file mode 100644
index 0000000..d50d91c
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class Y> explicit shared_ptr(Y* p);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next)
+        throw std::bad_alloc();
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+int main()
+{
+    {
+    A* ptr = new A;
+    throw_next = true;
+    assert(A::count == 1);
+    try
+    {
+        std::shared_ptr<A> p(ptr);
+        assert(false);
+    }
+    catch (std::bad_alloc&)
+    {
+        assert(A::count == 0);
+    }
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
new file mode 100644
index 0000000..e1dcdfc
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr(const shared_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<A> pA(new A);
+        assert(pA.use_count() == 1);
+        assert(A::count == 1);
+        {
+            std::shared_ptr<A> pA2(pA);
+            assert(A::count == 1);
+            assert(pA.use_count() == 2);
+            assert(pA2.use_count() == 2);
+            assert(pA2.get() == pA.get());
+        }
+        assert(pA.use_count() == 1);
+        assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        assert(pA.use_count() == 0);
+        assert(A::count == 0);
+        {
+            std::shared_ptr<A> pA2(pA);
+            assert(A::count == 0);
+            assert(pA.use_count() == 0);
+            assert(pA2.use_count() == 0);
+            assert(pA2.get() == pA.get());
+        }
+        assert(pA.use_count() == 0);
+        assert(A::count == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..8b5ffdc
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+    static int count;
+
+    C() {++count;}
+    C(const C&) {++count;}
+    virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+    static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), "");
+    static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), "");
+    static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), "");
+    {
+        const std::shared_ptr<A> pA(new A);
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+        {
+            std::shared_ptr<B> pB(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 2);
+            assert(pA.use_count() == 2);
+            assert(pA.get() == pB.get());
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+        {
+            std::shared_ptr<B> pB(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == pB.get());
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
new file mode 100644
index 0000000..f041d94
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(shared_ptr<Y>&& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+    static int count;
+
+    C() {++count;}
+    C(const C&) {++count;}
+    virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+    static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), "");
+    static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), "");
+    static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), "");
+    {
+        std::shared_ptr<A> pA(new A);
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+        {
+            B* p = pA.get();
+            std::shared_ptr<B> pB(std::move(pA));
+            assert(B::count == 1);
+            assert(A::count == 1);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(pB.use_count() == 2);
+            assert(pA.use_count() == 2);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(p == pB.get());
+        }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+        {
+            std::shared_ptr<B> pB(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+            assert(pA.get() == pB.get());
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp
new file mode 100644
index 0000000..fb5262f
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<A> pA(new A);
+        assert(pA.use_count() == 1);
+        {
+            B b;
+            std::shared_ptr<B> pB(pA, &b);
+            assert(A::count == 1);
+            assert(B::count == 1);
+            assert(pA.use_count() == 2);
+            assert(pB.use_count() == 2);
+            assert(pB.get() == &b);
+        }
+        assert(pA.use_count() == 1);
+        assert(A::count == 1);
+        assert(B::count == 0);
+    }
+    assert(A::count == 0);
+    assert(B::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
new file mode 100644
index 0000000..b89178e
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// shared_ptr(shared_ptr&& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<A> pA(new A);
+        assert(pA.use_count() == 1);
+        assert(A::count == 1);
+        {
+            A* p = pA.get();
+            std::shared_ptr<A> pA2(std::move(pA));
+            assert(A::count == 1);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(pA.use_count() == 0);
+            assert(pA2.use_count() == 1);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(pA.use_count() == 2);
+            assert(pA2.use_count() == 2);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+            assert(pA2.get() == p);
+        }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        assert(pA.use_count() == 0);
+        assert(A::count == 0);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        assert(pA.use_count() == 1);
+        assert(A::count == 1);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    }
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        assert(pA.use_count() == 0);
+        assert(A::count == 0);
+        {
+            std::shared_ptr<A> pA2(std::move(pA));
+            assert(A::count == 0);
+            assert(pA.use_count() == 0);
+            assert(pA2.use_count() == 0);
+            assert(pA2.get() == pA.get());
+        }
+        assert(pA.use_count() == 0);
+        assert(A::count == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
new file mode 100644
index 0000000..b841833
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Y, class D> explicit shared_ptr(unique_ptr<Y, D>&&r);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+bool throw_next = false;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    if (throw_next)
+        throw std::bad_alloc();
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    std::unique_ptr<A> ptr(new A);
+    A* raw_ptr = ptr.get();
+    std::shared_ptr<B> p(std::move(ptr));
+    assert(A::count == 1);
+    assert(B::count == 1);
+    assert(p.use_count() == 1);
+    assert(p.get() == raw_ptr);
+    assert(ptr.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+    std::unique_ptr<A> ptr(new A);
+    A* raw_ptr = ptr.get();
+    throw_next = true;
+    try
+    {
+        std::shared_ptr<B> p(std::move(ptr));
+        assert(false);
+    }
+    catch (...)
+    {
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(ptr.get() == raw_ptr);
+#else
+        assert(A::count == 0);
+        assert(B::count == 0);
+        assert(ptr.get() == 0);
+#endif
+    }
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
new file mode 100644
index 0000000..a9d8aff
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::weak_ptr<A> wp;
+        try
+        {
+            std::shared_ptr<A> sp(wp);
+            assert(false);
+        }
+        catch (std::bad_weak_ptr&)
+        {
+        }
+        assert(A::count == 0);
+    }
+    {
+        std::shared_ptr<A> sp0(new A);
+        std::weak_ptr<A> wp(sp0);
+        std::shared_ptr<A> sp(wp);
+        assert(sp.use_count() == 2);
+        assert(sp.get() == sp0.get());
+        assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> sp0(new A);
+        std::weak_ptr<A> wp(sp0);
+        sp0.reset();
+        try
+        {
+            std::shared_ptr<A> sp(wp);
+            assert(false);
+        }
+        catch (std::bad_weak_ptr&)
+        {
+        }
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
new file mode 100644
index 0000000..e019837
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class A, class... Args>
+//    shared_ptr<T> allocate_shared(const A& a, Args&&... args);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+#include "test_allocator.h"
+
+int new_count = 0;
+
+struct A
+{
+    static int count;
+
+    A(int i, char c) : int_(i), char_(c) {++count;}
+    A(const A& a)
+        : int_(a.int_), char_(a.char_)
+        {++count;}
+    ~A() {--count;}
+
+    int get_int() const {return int_;}
+    char get_char() const {return char_;}
+private:
+    int int_;
+    char char_;
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+    int i = 67;
+    char c = 'e';
+    std::shared_ptr<A> p = std::allocate_shared<A>(test_allocator<A>(54), i, c);
+    assert(test_allocator<A>::alloc_count == 1);
+    assert(A::count == 1);
+    assert(p->get_int() == 67);
+    assert(p->get_char() == 'e');
+    }
+    assert(A::count == 0);
+    assert(test_allocator<A>::alloc_count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
new file mode 100644
index 0000000..eda148c
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
+
+#include <memory>
+#include <new>
+#include <cstdlib>
+#include <cassert>
+
+int new_count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+    ++new_count;
+    return std::malloc(s);
+}
+
+void  operator delete(void* p) throw()
+{
+    std::free(p);
+}
+
+struct A
+{
+    static int count;
+
+    A(int i, char c) : int_(i), char_(c) {++count;}
+    A(const A& a)
+        : int_(a.int_), char_(a.char_)
+        {++count;}
+    ~A() {--count;}
+
+    int get_int() const {return int_;}
+    char get_char() const {return char_;}
+private:
+    int int_;
+    char char_;
+};
+
+int A::count = 0;
+
+int main()
+{
+    int nc = new_count;
+    {
+    int i = 67;
+    char c = 'e';
+    std::shared_ptr<A> p = std::make_shared<A>(i, c);
+    assert(new_count == nc+1);
+    assert(A::count == 1);
+    assert(p->get_int() == 67);
+    assert(p->get_char() == 'e');
+    }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    nc = new_count;
+    {
+    char c = 'e';
+    std::shared_ptr<A> p = std::make_shared<A>(67, c);
+    assert(new_count == nc+1);
+    assert(A::count == 1);
+    assert(p->get_int() == 67);
+    assert(p->get_char() == 'e');
+    }
+#endif
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp
new file mode 100644
index 0000000..b627ac1
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class CharT, class Traits, class Y>
+//   basic_ostream<CharT, Traits>&
+//   operator<<(basic_ostream<CharT, Traits>& os, shared_ptr<Y> const& p);
+
+#include <memory>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::shared_ptr<int> p(new int(3));
+    std::ostringstream os;
+    assert(os.str().empty());
+    os << p;
+    assert(!os.str().empty());
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
new file mode 100644
index 0000000..7bffc06
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// void reset();
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<B> p(new B);
+        p.reset();
+        assert(A::count == 0);
+        assert(B::count == 0);
+        assert(p.use_count() == 0);
+        assert(p.get() == 0);
+    }
+    assert(A::count == 0);
+    {
+        std::shared_ptr<B> p;
+        p.reset();
+        assert(A::count == 0);
+        assert(B::count == 0);
+        assert(p.use_count() == 0);
+        assert(p.get() == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
new file mode 100644
index 0000000..85a64d0
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y> void reset(Y* p);
+
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<B> p(new B);
+        A* ptr = new A;
+        p.reset(ptr);
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(p.use_count() == 1);
+        assert(p.get() == ptr);
+    }
+    assert(A::count == 0);
+    {
+        std::shared_ptr<B> p;
+        A* ptr = new A;
+        p.reset(ptr);
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(p.use_count() == 1);
+        assert(p.get() == ptr);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
new file mode 100644
index 0000000..33965df
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D> void reset(Y* p, D d);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<B> p(new B);
+        A* ptr = new A;
+        p.reset(ptr, test_deleter<A>(3));
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(p.use_count() == 1);
+        assert(p.get() == ptr);
+        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+        assert(test_deleter<A>::count == 1);
+        assert(test_deleter<A>::dealloc_count == 0);
+        assert(d);
+        assert(d->state() == 3);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 1);
+    {
+        std::shared_ptr<B> p;
+        A* ptr = new A;
+        p.reset(ptr, test_deleter<A>(3));
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(p.use_count() == 1);
+        assert(p.get() == ptr);
+        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+        assert(test_deleter<A>::count == 1);
+        assert(test_deleter<A>::dealloc_count == 1);
+        assert(d);
+        assert(d->state() == 3);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 2);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
new file mode 100644
index 0000000..09070e2
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class Y, class D, class A> void reset(Y* p, D d, A a);
+
+#include <memory>
+#include <cassert>
+#include "../test_deleter.h"
+#include "test_allocator.h"
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<B> p(new B);
+        A* ptr = new A;
+        p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4));
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(p.use_count() == 1);
+        assert(p.get() == ptr);
+        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+        assert(test_deleter<A>::count == 1);
+        assert(test_deleter<A>::dealloc_count == 0);
+        assert(d);
+        assert(d->state() == 3);
+        assert(test_allocator<A>::count == 1);
+        assert(test_allocator<A>::alloc_count == 1);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 1);
+    assert(test_allocator<A>::count == 0);
+    assert(test_allocator<A>::alloc_count == 0);
+    {
+        std::shared_ptr<B> p;
+        A* ptr = new A;
+        p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4));
+        assert(A::count == 1);
+        assert(B::count == 1);
+        assert(p.use_count() == 1);
+        assert(p.get() == ptr);
+        test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p);
+        assert(test_deleter<A>::count == 1);
+        assert(test_deleter<A>::dealloc_count == 1);
+        assert(d);
+        assert(d->state() == 3);
+        assert(test_allocator<A>::count == 1);
+        assert(test_allocator<A>::alloc_count == 1);
+    }
+    assert(A::count == 0);
+    assert(test_deleter<A>::count == 0);
+    assert(test_deleter<A>::dealloc_count == 2);
+    assert(test_allocator<A>::count == 0);
+    assert(test_allocator<A>::alloc_count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
new file mode 100644
index 0000000..6d28a50
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// void swap(shared_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        A* ptr1 = new A;
+        A* ptr2 = new A;
+        std::shared_ptr<A> p1(ptr1);
+        {
+            std::shared_ptr<A> p2(ptr2);
+            p1.swap(p2);
+            assert(p1.use_count() == 1);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 1);
+            assert(p2.get() == ptr1);
+            assert(A::count == 2);
+        }
+        assert(p1.use_count() == 1);
+        assert(p1.get() == ptr2);
+        assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+        A* ptr1 = new A;
+        A* ptr2 = 0;
+        std::shared_ptr<A> p1(ptr1);
+        {
+            std::shared_ptr<A> p2;
+            p1.swap(p2);
+            assert(p1.use_count() == 0);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 1);
+            assert(p2.get() == ptr1);
+            assert(A::count == 1);
+        }
+        assert(p1.use_count() == 0);
+        assert(p1.get() == ptr2);
+        assert(A::count == 0);
+    }
+    assert(A::count == 0);
+    {
+        A* ptr1 = 0;
+        A* ptr2 = new A;
+        std::shared_ptr<A> p1;
+        {
+            std::shared_ptr<A> p2(ptr2);
+            p1.swap(p2);
+            assert(p1.use_count() == 1);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 0);
+            assert(p2.get() == ptr1);
+            assert(A::count == 1);
+        }
+        assert(p1.use_count() == 1);
+        assert(p1.get() == ptr2);
+        assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+        A* ptr1 = 0;
+        A* ptr2 = 0;
+        std::shared_ptr<A> p1;
+        {
+            std::shared_ptr<A> p2;
+            p1.swap(p2);
+            assert(p1.use_count() == 0);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 0);
+            assert(p2.get() == ptr1);
+            assert(A::count == 0);
+        }
+        assert(p1.use_count() == 0);
+        assert(p1.get() == ptr2);
+        assert(A::count == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp
new file mode 100644
index 0000000..0028168
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// T* operator->() const;
+
+#include <memory>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<std::pair<int, int> > p(new std::pair<int, int>(3, 4));
+    assert(p->first == 3);
+    assert(p->second == 4);
+    p->first = 5;
+    p->second = 6;
+    assert(p->first == 5);
+    assert(p->second == 6);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp
new file mode 100644
index 0000000..378cd05
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// T& operator*() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p(new int(32));
+    assert(*p == 32);
+    *p = 3;
+    assert(*p == 3);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
new file mode 100644
index 0000000..1b79d49
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// explicit operator bool() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::shared_ptr<int> p(new int(32));
+    assert(p);
+    }
+    {
+    const std::shared_ptr<int> p;
+    assert(!p);
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 0000000..3acd2f8
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class U> bool owner_before(shared_ptr<U> const& b) const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p1(new int);
+    const std::shared_ptr<int> p2 = p1;
+    const std::shared_ptr<int> p3(new int);
+    assert(!p1.owner_before(p2));
+    assert(!p2.owner_before(p1));
+    assert(p1.owner_before(p3) || p3.owner_before(p1));
+    assert(p3.owner_before(p1) == p3.owner_before(p2));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 0000000..33447ba
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template <class U> bool owner_before(weak_ptr<U> const& b) const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p1(new int);
+    const std::shared_ptr<int> p2 = p1;
+    const std::shared_ptr<int> p3(new int);
+    const std::weak_ptr<int> w1(p1);
+    const std::weak_ptr<int> w2(p2);
+    const std::weak_ptr<int> w3(p3);
+    assert(!p1.owner_before(w2));
+    assert(!p2.owner_before(w1));
+    assert(p1.owner_before(w3) || p3.owner_before(w1));
+    assert(p3.owner_before(w1) == p3.owner_before(w2));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp
new file mode 100644
index 0000000..50ff692
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// bool unique() const;
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p(new int(32));
+    assert(p.unique());
+    {
+    std::shared_ptr<int> p2 = p;
+    assert(!p.unique());
+    }
+    assert(p.unique());
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
new file mode 100644
index 0000000..b40e470
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// shared_ptr
+
+// template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        A* ptr1 = new A;
+        A* ptr2 = new A;
+        std::shared_ptr<A> p1(ptr1);
+        {
+            std::shared_ptr<A> p2(ptr2);
+            swap(p1, p2);
+            assert(p1.use_count() == 1);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 1);
+            assert(p2.get() == ptr1);
+            assert(A::count == 2);
+        }
+        assert(p1.use_count() == 1);
+        assert(p1.get() == ptr2);
+        assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+        A* ptr1 = new A;
+        A* ptr2 = 0;
+        std::shared_ptr<A> p1(ptr1);
+        {
+            std::shared_ptr<A> p2;
+            swap(p1, p2);
+            assert(p1.use_count() == 0);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 1);
+            assert(p2.get() == ptr1);
+            assert(A::count == 1);
+        }
+        assert(p1.use_count() == 0);
+        assert(p1.get() == ptr2);
+        assert(A::count == 0);
+    }
+    assert(A::count == 0);
+    {
+        A* ptr1 = 0;
+        A* ptr2 = new A;
+        std::shared_ptr<A> p1;
+        {
+            std::shared_ptr<A> p2(ptr2);
+            swap(p1, p2);
+            assert(p1.use_count() == 1);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 0);
+            assert(p2.get() == ptr1);
+            assert(A::count == 1);
+        }
+        assert(p1.use_count() == 1);
+        assert(p1.get() == ptr2);
+        assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+        A* ptr1 = 0;
+        A* ptr2 = 0;
+        std::shared_ptr<A> p1;
+        {
+            std::shared_ptr<A> p2;
+            swap(p1, p2);
+            assert(p1.use_count() == 0);
+            assert(p1.get() == ptr2);
+            assert(p2.use_count() == 0);
+            assert(p2.get() == ptr1);
+            assert(A::count == 0);
+        }
+        assert(p1.use_count() == 0);
+        assert(p1.get() == ptr2);
+        assert(A::count == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp
new file mode 100644
index 0000000..45748d7
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class weak_ptr
+// {
+// public:
+//     typedef T element_type;
+//     ...
+// };
+
+#include <memory>
+
+struct A;  // purposefully incomplete
+
+int main()
+{
+    static_assert((std::is_same<std::weak_ptr<A>::element_type, A>::value), "");
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
new file mode 100644
index 0000000..db2ed3b
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T> struct owner_less;
+//
+// template <class T>
+// struct owner_less<shared_ptr<T> >
+//     : binary_function<shared_ptr<T>, shared_ptr<T>, bool>
+// {
+//     typedef bool result_type;
+//     bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const;
+//     bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+//     bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+// };
+//
+// template <class T>
+// struct owner_less<weak_ptr<T> >
+//     : binary_function<weak_ptr<T>, weak_ptr<T>, bool>
+// {
+//     typedef bool result_type;
+//     bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const;
+//     bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
+//     bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p1(new int);
+    const std::shared_ptr<int> p2 = p1;
+    const std::shared_ptr<int> p3(new int);
+    const std::weak_ptr<int> w1(p1);
+    const std::weak_ptr<int> w2(p2);
+    const std::weak_ptr<int> w3(p3);
+
+    {
+    typedef std::owner_less<std::shared_ptr<int> > CS;
+    CS cs;
+
+    assert(!cs(p1, p2));
+    assert(!cs(p2, p1));
+    assert(cs(p1 ,p3) || cs(p3, p1));
+    assert(cs(p3, p1) == cs(p3, p2));
+
+    assert(!cs(p1, w2));
+    assert(!cs(p2, w1));
+    assert(cs(p1, w3) || cs(p3, w1));
+    assert(cs(p3, w1) == cs(p3, w2));
+    }
+    {
+    typedef std::owner_less<std::weak_ptr<int> > CS;
+    CS cs;
+
+    assert(!cs(w1, w2));
+    assert(!cs(w2, w1));
+    assert(cs(w1, w3) || cs(w3, w1));
+    assert(cs(w3, w1) == cs(w3, w2));
+
+    assert(!cs(w1, p2));
+    assert(!cs(w2, p1));
+    assert(cs(w1, p3) || cs(w3, p1));
+    assert(cs(w3, p1) == cs(w3, p2));
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..6b32079
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<A> pA(new A);
+        {
+            std::weak_ptr<B> pB;
+            pB = pA;
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 1);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
new file mode 100644
index 0000000..e5713f3
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// weak_ptr& operator=(const weak_ptr& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<A> ps(new A);
+        const std::weak_ptr<A> pA(ps);
+        {
+            std::weak_ptr<A> pB;
+            pB = pA;
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 1);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+
+    {
+        const std::shared_ptr<A> ps(new A);
+        std::weak_ptr<A> pA(ps);
+        {
+            std::weak_ptr<A> pB;
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+        }
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
new file mode 100644
index 0000000..5a03d92
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr& operator=(const weak_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        const std::shared_ptr<A> ps(new A);
+        const std::weak_ptr<A> pA(ps);
+        {
+            std::weak_ptr<B> pB;
+            pB = pA;
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 1);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+
+    {
+        const std::shared_ptr<A> ps(new A);
+        std::weak_ptr<A> pA(ps);
+        {
+            std::weak_ptr<B> pB;
+            pB = std::move(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+        }
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp
new file mode 100644
index 0000000..28358db
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template<class T> class weak_ptr
+
+// weak_ptr();
+
+#include <memory>
+#include <cassert>
+
+struct A;
+
+int main()
+{
+    std::weak_ptr<A> p;
+    assert(p.use_count() == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
new file mode 100644
index 0000000..d70adb9
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr(const shared_ptr<Y>& r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+    static int count;
+
+    C() {++count;}
+    C(const C&) {++count;}
+    virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+int main()
+{
+    static_assert(( std::is_convertible<std::shared_ptr<A>, std::weak_ptr<B> >::value), "");
+    static_assert((!std::is_convertible<std::weak_ptr<B>, std::shared_ptr<A> >::value), "");
+    static_assert((!std::is_convertible<std::shared_ptr<A>, std::weak_ptr<C> >::value), "");
+    {
+        const std::shared_ptr<A> pA(new A);
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+        {
+            std::weak_ptr<B> pB(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 1);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> pA;
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+        {
+            std::weak_ptr<B> pB(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
new file mode 100644
index 0000000..1fdf883
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// weak_ptr(const weak_ptr& r);
+// weak_ptr(weak_ptr &&r)
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+    static int count;
+
+    C() {++count;}
+    C(const C&) {++count;}
+    virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+template <class T>
+std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); }
+
+template <class T>
+void sink (std::weak_ptr<T> &&) {}
+
+int main()
+{
+    {
+        const std::shared_ptr<A> ps(new A);
+        const std::weak_ptr<A> pA(ps);
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+        {
+            std::weak_ptr<A> pB(pA);
+            assert(B::count == 1);
+            assert(A::count == 1);
+            assert(pB.use_count() == 1);
+            assert(pA.use_count() == 1);
+        }
+        assert(pA.use_count() == 1);
+        assert(B::count == 1);
+        assert(A::count == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::weak_ptr<A> pA;
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+        {
+            std::weak_ptr<A> pB(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+
+    {
+        std::shared_ptr<A> ps(new A);
+        std::weak_ptr<A> pA = source(ps);
+        assert(pA.use_count() == 1);
+        assert(A::count == 1);
+        sink(std::move(pA)); // kill off the weak pointer
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
new file mode 100644
index 0000000..70ad11b
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class Y> weak_ptr(const weak_ptr<Y>& r);
+// template<class Y> weak_ptr(weak_ptr<Y> &&r);
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+
+struct B
+{
+    static int count;
+
+    B() {++count;}
+    B(const B&) {++count;}
+    virtual ~B() {--count;}
+};
+
+int B::count = 0;
+
+struct A
+    : public B
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+struct C
+{
+    static int count;
+
+    C() {++count;}
+    C(const C&) {++count;}
+    virtual ~C() {--count;}
+};
+
+int C::count = 0;
+
+template <class T>
+std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); }
+
+template <class T>
+void sink (std::weak_ptr<T> &&) {}
+
+int main()
+{
+    static_assert(( std::is_convertible<std::weak_ptr<A>, std::weak_ptr<B> >::value), "");
+    static_assert((!std::is_convertible<std::weak_ptr<B>, std::weak_ptr<A> >::value), "");
+    static_assert((!std::is_convertible<std::weak_ptr<A>, std::weak_ptr<C> >::value), "");
+    {
+        const std::weak_ptr<A> pA(std::shared_ptr<A>(new A));
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+        {
+            std::weak_ptr<B> pB(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+    {
+        std::weak_ptr<A> pA;
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+        {
+            std::weak_ptr<B> pB(pA);
+            assert(B::count == 0);
+            assert(A::count == 0);
+            assert(pB.use_count() == 0);
+            assert(pA.use_count() == 0);
+        }
+        assert(pA.use_count() == 0);
+        assert(B::count == 0);
+        assert(A::count == 0);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+
+    {
+        std::shared_ptr<A> ps(new A);
+        std::weak_ptr<A> pA = source(ps);
+        std::weak_ptr<B> pB(std::move(pA));
+        assert(pB.use_count() == 1);
+    }
+    assert(B::count == 0);
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
new file mode 100644
index 0000000..fa496d4
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// void swap(weak_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::shared_ptr<A> p1(new A);
+        std::weak_ptr<A> w1(p1);
+        assert(w1.use_count() == 1);
+        w1.reset();
+        assert(w1.use_count() == 0);
+        assert(p1.use_count() == 1);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
new file mode 100644
index 0000000..4001efb
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// void swap(weak_ptr& r);
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        A* ptr1 = new A;
+        A* ptr2 = new A;
+        std::shared_ptr<A> p1(ptr1);
+        std::weak_ptr<A> w1(p1);
+        {
+            std::shared_ptr<A> p2(ptr2);
+            std::weak_ptr<A> w2(p2);
+            w1.swap(w2);
+            assert(w1.use_count() == 1);
+            assert(w1.lock().get() == ptr2);
+            assert(w2.use_count() == 1);
+            assert(w2.lock().get() == ptr1);
+            assert(A::count == 2);
+        }
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
new file mode 100644
index 0000000..d61ac51
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// bool expired() const;
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::weak_ptr<A> wp;
+        assert(wp.use_count() == 0);
+        assert(wp.expired() == (wp.use_count() == 0));
+    }
+    {
+        std::shared_ptr<A> sp0(new A);
+        std::weak_ptr<A> wp(sp0);
+        assert(wp.use_count() == 1);
+        assert(wp.expired() == (wp.use_count() == 0));
+        sp0.reset();
+        assert(wp.use_count() == 0);
+        assert(wp.expired() == (wp.use_count() == 0));
+    }
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp
new file mode 100644
index 0000000..956884b
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// shared_ptr<T> lock() const;
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        std::weak_ptr<A> wp;
+        std::shared_ptr<A> sp = wp.lock();
+        assert(sp.use_count() == 0);
+        assert(sp.get() == 0);
+        assert(A::count == 0);
+    }
+    {
+        std::shared_ptr<A> sp0(new A);
+        std::weak_ptr<A> wp(sp0);
+        std::shared_ptr<A> sp = wp.lock();
+        assert(sp.use_count() == 2);
+        assert(sp.get() == sp0.get());
+        assert(A::count == 1);
+    }
+    assert(A::count == 0);
+    {
+        std::shared_ptr<A> sp0(new A);
+        std::weak_ptr<A> wp(sp0);
+        sp0.reset();
+        std::shared_ptr<A> sp = wp.lock();
+        assert(sp.use_count() == 0);
+        assert(sp.get() == 0);
+        assert(A::count == 0);
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp
new file mode 100644
index 0000000..ccffc2a
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class T> class weak_ptr;
+//
+// not less than comparable
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p1(new int);
+    const std::shared_ptr<int> p2(new int);
+    const std::weak_ptr<int> w1(p1);
+    const std::weak_ptr<int> w2(p2);
+
+    bool b = w1 < w2;
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp
new file mode 100644
index 0000000..4aa49cf
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class U> bool owner_before(const shared_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p1(new int);
+    const std::shared_ptr<int> p2 = p1;
+    const std::shared_ptr<int> p3(new int);
+    const std::weak_ptr<int> w1(p1);
+    const std::weak_ptr<int> w2(p2);
+    const std::weak_ptr<int> w3(p3);
+    assert(!w1.owner_before(p2));
+    assert(!w2.owner_before(p1));
+    assert(w1.owner_before(p3) || w3.owner_before(p1));
+    assert(w3.owner_before(p1) == w3.owner_before(p2));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
new file mode 100644
index 0000000..9fe2b6e
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class U> bool owner_before(const weak_ptr<U>& b);
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    const std::shared_ptr<int> p1(new int);
+    const std::shared_ptr<int> p2 = p1;
+    const std::shared_ptr<int> p3(new int);
+    const std::weak_ptr<int> w1(p1);
+    const std::weak_ptr<int> w2(p2);
+    const std::weak_ptr<int> w3(p3);
+    assert(!w1.owner_before(w2));
+    assert(!w2.owner_before(w1));
+    assert(w1.owner_before(w3) || w3.owner_before(w1));
+    assert(w3.owner_before(w1) == w3.owner_before(w2));
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
new file mode 100644
index 0000000..e13d5ae
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// weak_ptr
+
+// template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b)
+
+#include <memory>
+#include <cassert>
+
+struct A
+{
+    static int count;
+
+    A() {++count;}
+    A(const A&) {++count;}
+    ~A() {--count;}
+};
+
+int A::count = 0;
+
+int main()
+{
+    {
+        A* ptr1 = new A;
+        A* ptr2 = new A;
+        std::shared_ptr<A> p1(ptr1);
+        std::weak_ptr<A> w1(p1);
+        {
+            std::shared_ptr<A> p2(ptr2);
+            std::weak_ptr<A> w2(p2);
+            swap(w1, w2);
+            assert(w1.use_count() == 1);
+            assert(w1.lock().get() == ptr2);
+            assert(w2.use_count() == 1);
+            assert(w2.lock().get() == ptr1);
+            assert(A::count == 2);
+        }
+    }
+    assert(A::count == 0);
+}
diff --git a/final/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp b/final/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp
new file mode 100644
index 0000000..cb895cd
--- /dev/null
+++ b/final/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// class bad_weak_ptr
+//     : public std::exception
+// {
+// public:
+//     bad_weak_ptr();
+// };
+
+#include <memory>
+#include <type_traits>
+#include <cassert>
+#include <cstring>
+
+int main()
+{
+    static_assert((std::is_base_of<std::exception, std::bad_weak_ptr>::value), "");
+    std::bad_weak_ptr e;
+    std::bad_weak_ptr e2 = e;
+    e2 = e;
+    assert(std::strcmp(e.what(), "bad_weak_ptr") == 0);
+}
diff --git a/final/test/utilities/memory/version.pass.cpp b/final/test/utilities/memory/version.pass.cpp
new file mode 100644
index 0000000..790c08a
--- /dev/null
+++ b/final/test/utilities/memory/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+#include <memory>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/meta/meta.hel/integral_constant.pass.cpp b/final/test/utilities/meta/meta.hel/integral_constant.pass.cpp
new file mode 100644
index 0000000..1ad1adc
--- /dev/null
+++ b/final/test/utilities/meta/meta.hel/integral_constant.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// integral_constant
+
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+    typedef std::integral_constant<int, 5> _5;
+    static_assert(_5::value == 5, "");
+    static_assert((std::is_same<_5::value_type, int>::value), "");
+    static_assert((std::is_same<_5::type, _5>::value), "");
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    static_assert((_5() == 5), "");
+#else
+    assert(_5() == 5);
+#endif
+
+#if _LIBCPP_STD_VER > 11
+    static_assert ( _5{}() == 5, "" );
+    static_assert ( std::true_type{}(), "" );
+#endif
+
+    static_assert(std::false_type::value == false, "");
+    static_assert((std::is_same<std::false_type::value_type, bool>::value), "");
+    static_assert((std::is_same<std::false_type::type, std::false_type>::value), "");
+
+    static_assert(std::true_type::value == true, "");
+    static_assert((std::is_same<std::true_type::value_type, bool>::value), "");
+    static_assert((std::is_same<std::true_type::type, std::true_type>::value), "");
+
+    std::false_type f1;
+    std::false_type f2 = f1;
+
+    std::true_type t1;
+    std::true_type t2 = t1;
+}
diff --git a/final/test/utilities/meta/meta.rel/is_base_of.pass.cpp b/final/test/utilities/meta/meta.rel/is_base_of.pass.cpp
new file mode 100644
index 0000000..0f90ae5
--- /dev/null
+++ b/final/test/utilities/meta/meta.rel/is_base_of.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_base_of
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_base_of()
+{
+    static_assert((std::is_base_of<T, U>::value), "");
+    static_assert((std::is_base_of<const T, U>::value), "");
+    static_assert((std::is_base_of<T, const U>::value), "");
+    static_assert((std::is_base_of<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_base_of()
+{
+    static_assert((!std::is_base_of<T, U>::value), "");
+}
+
+struct B {};
+struct B1 : B {};
+struct B2 : B {};
+struct D : private B1, private B2 {};
+
+int main()
+{
+    test_is_base_of<B, D>();
+    test_is_base_of<B1, D>();
+    test_is_base_of<B2, D>();
+    test_is_base_of<B, B1>();
+    test_is_base_of<B, B2>();
+    test_is_base_of<B, B>();
+
+    test_is_not_base_of<D, B>();
+    test_is_not_base_of<B&, D&>();
+    test_is_not_base_of<B[3], D[3]>();
+    test_is_not_base_of<int, int>();
+}
diff --git a/final/test/utilities/meta/meta.rel/is_convertible.pass.cpp b/final/test/utilities/meta/meta.rel/is_convertible.pass.cpp
new file mode 100644
index 0000000..718e0ff
--- /dev/null
+++ b/final/test/utilities/meta/meta.rel/is_convertible.pass.cpp
@@ -0,0 +1,189 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_convertible
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_convertible()
+{
+    static_assert((std::is_convertible<T, U>::value), "");
+    static_assert((std::is_convertible<const T, U>::value), "");
+    static_assert((std::is_convertible<T, const U>::value), "");
+    static_assert((std::is_convertible<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_convertible()
+{
+    static_assert((!std::is_convertible<T, U>::value), "");
+    static_assert((!std::is_convertible<const T, U>::value), "");
+    static_assert((!std::is_convertible<T, const U>::value), "");
+    static_assert((!std::is_convertible<const T, const U>::value), "");
+}
+
+typedef void Function();
+typedef char Array[1];
+
+class NonCopyable {
+  NonCopyable(NonCopyable&);
+};
+
+int main()
+{
+    // void
+    test_is_convertible<void,void> ();
+    test_is_not_convertible<void,Function> ();
+    test_is_not_convertible<void,Function&> ();
+    test_is_not_convertible<void,Function*> ();
+    test_is_not_convertible<void,Array> ();
+    test_is_not_convertible<void,Array&> ();
+    test_is_not_convertible<void,char> ();
+    test_is_not_convertible<void,char&> ();
+    test_is_not_convertible<void,char*> ();
+
+    // Function
+    test_is_not_convertible<Function, void> ();
+    test_is_not_convertible<Function, Function> ();
+    test_is_convertible<Function, Function&> ();
+    test_is_convertible<Function, Function*> ();
+    test_is_not_convertible<Function, Array> ();
+    test_is_not_convertible<Function, Array&> ();
+    test_is_not_convertible<Function, char> ();
+    test_is_not_convertible<Function, char&> ();
+    test_is_not_convertible<Function, char*> ();
+
+    // Function&
+    test_is_not_convertible<Function&, void> ();
+    test_is_not_convertible<Function&, Function> ();
+    test_is_convertible<Function&, Function&> ();
+
+    test_is_convertible<Function&, Function*> ();
+    test_is_not_convertible<Function&, Array> ();
+    test_is_not_convertible<Function&, Array&> ();
+    test_is_not_convertible<Function&, char> ();
+    test_is_not_convertible<Function&, char&> ();
+    test_is_not_convertible<Function&, char*> ();
+
+    // Function*
+    test_is_not_convertible<Function*, void> ();
+    test_is_not_convertible<Function*, Function> ();
+    test_is_not_convertible<Function*, Function&> ();
+    test_is_convertible<Function*, Function*> ();
+
+    test_is_not_convertible<Function*, Array> ();
+    test_is_not_convertible<Function*, Array&> ();
+    test_is_not_convertible<Function*, char> ();
+    test_is_not_convertible<Function*, char&> ();
+    test_is_not_convertible<Function*, char*> ();
+
+    // Array
+    test_is_not_convertible<Array, void> ();
+    test_is_not_convertible<Array, Function> ();
+    test_is_not_convertible<Array, Function&> ();
+    test_is_not_convertible<Array, Function*> ();
+    test_is_not_convertible<Array, Array> ();
+
+    static_assert((!std::is_convertible<Array, Array&>::value), "");
+    static_assert(( std::is_convertible<Array, const Array&>::value), "");
+    static_assert((!std::is_convertible<const Array, Array&>::value), "");
+    static_assert(( std::is_convertible<const Array, const Array&>::value), "");
+
+    test_is_not_convertible<Array, char> ();
+    test_is_not_convertible<Array, char&> ();
+
+    static_assert(( std::is_convertible<Array, char*>::value), "");
+    static_assert(( std::is_convertible<Array, const char*>::value), "");
+    static_assert((!std::is_convertible<const Array, char*>::value), "");
+    static_assert(( std::is_convertible<const Array, const char*>::value), "");
+
+    // Array&
+    test_is_not_convertible<Array&, void> ();
+    test_is_not_convertible<Array&, Function> ();
+    test_is_not_convertible<Array&, Function&> ();
+    test_is_not_convertible<Array&, Function*> ();
+    test_is_not_convertible<Array&, Array> ();
+
+    static_assert(( std::is_convertible<Array&, Array&>::value), "");
+    static_assert(( std::is_convertible<Array&, const Array&>::value), "");
+    static_assert((!std::is_convertible<const Array&, Array&>::value), "");
+    static_assert(( std::is_convertible<const Array&, const Array&>::value), "");
+
+    test_is_not_convertible<Array&, char> ();
+    test_is_not_convertible<Array&, char&> ();
+
+    static_assert(( std::is_convertible<Array&, char*>::value), "");
+    static_assert(( std::is_convertible<Array&, const char*>::value), "");
+    static_assert((!std::is_convertible<const Array&, char*>::value), "");
+    static_assert(( std::is_convertible<const Array&, const char*>::value), "");
+
+    // char
+    test_is_not_convertible<char, void> ();
+    test_is_not_convertible<char, Function> ();
+    test_is_not_convertible<char, Function&> ();
+    test_is_not_convertible<char, Function*> ();
+    test_is_not_convertible<char, Array> ();
+    test_is_not_convertible<char, Array&> ();
+
+    test_is_convertible<char, char> ();
+    
+    static_assert((!std::is_convertible<char, char&>::value), "");
+    static_assert(( std::is_convertible<char, const char&>::value), "");
+    static_assert((!std::is_convertible<const char, char&>::value), "");
+    static_assert(( std::is_convertible<const char, const char&>::value), "");
+
+    test_is_not_convertible<char, char*> ();
+
+    // char&
+    test_is_not_convertible<char&, void> ();
+    test_is_not_convertible<char&, Function> ();
+    test_is_not_convertible<char&, Function&> ();
+    test_is_not_convertible<char&, Function*> ();
+    test_is_not_convertible<char&, Array> ();
+    test_is_not_convertible<char&, Array&> ();
+
+    test_is_convertible<char&, char> ();
+    
+    static_assert(( std::is_convertible<char&, char&>::value), "");
+    static_assert(( std::is_convertible<char&, const char&>::value), "");
+    static_assert((!std::is_convertible<const char&, char&>::value), "");
+    static_assert(( std::is_convertible<const char&, const char&>::value), "");
+
+    test_is_not_convertible<char&, char*> ();
+
+    // char*
+    test_is_not_convertible<char*, void> ();
+    test_is_not_convertible<char*, Function> ();
+    test_is_not_convertible<char*, Function&> ();
+    test_is_not_convertible<char*, Function*> ();
+    test_is_not_convertible<char*, Array> ();
+    test_is_not_convertible<char*, Array&> ();
+
+    test_is_not_convertible<char*, char> ();
+    test_is_not_convertible<char*, char&> ();
+    
+    static_assert(( std::is_convertible<char*, char*>::value), "");
+    static_assert(( std::is_convertible<char*, const char*>::value), "");
+    static_assert((!std::is_convertible<const char*, char*>::value), "");
+    static_assert(( std::is_convertible<const char*, const char*>::value), "");
+
+    // NonCopyable
+    static_assert((std::is_convertible<NonCopyable&, NonCopyable&>::value), "");
+    static_assert((std::is_convertible<NonCopyable&, const NonCopyable&>::value), "");
+    static_assert((std::is_convertible<NonCopyable&, const volatile NonCopyable&>::value), "");
+    static_assert((std::is_convertible<NonCopyable&, volatile NonCopyable&>::value), "");
+    static_assert((std::is_convertible<const NonCopyable&, const NonCopyable&>::value), "");
+    static_assert((std::is_convertible<const NonCopyable&, const volatile NonCopyable&>::value), "");
+    static_assert((std::is_convertible<volatile NonCopyable&, const volatile NonCopyable&>::value), "");
+    static_assert((std::is_convertible<const volatile NonCopyable&, const volatile NonCopyable&>::value), "");
+    static_assert((!std::is_convertible<const NonCopyable&, NonCopyable&>::value), "");
+}
diff --git a/final/test/utilities/meta/meta.rel/is_same.pass.cpp b/final/test/utilities/meta/meta.rel/is_same.pass.cpp
new file mode 100644
index 0000000..7250d6c
--- /dev/null
+++ b/final/test/utilities/meta/meta.rel/is_same.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_same
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_same()
+{
+    static_assert((std::is_same<T, U>::value), "");
+    static_assert((!std::is_same<const T, U>::value), "");
+    static_assert((!std::is_same<T, const U>::value), "");
+    static_assert((std::is_same<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_same_ref()
+{
+    static_assert((std::is_same<T, U>::value), "");
+    static_assert((std::is_same<const T, U>::value), "");
+    static_assert((std::is_same<T, const U>::value), "");
+    static_assert((std::is_same<const T, const U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_same()
+{
+    static_assert((!std::is_same<T, U>::value), "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    test_is_same<int, int>();
+    test_is_same<void, void>();
+    test_is_same<Class, Class>();
+    test_is_same<int*, int*>();
+    test_is_same_ref<int&, int&>();
+
+    test_is_not_same<int, void>();
+    test_is_not_same<void, Class>();
+    test_is_not_same<Class, int*>();
+    test_is_not_same<int*, int&>();
+    test_is_not_same<int&, int>();
+}
diff --git a/final/test/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp b/final/test/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/meta/meta.rqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp
new file mode 100644
index 0000000..28bbede
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.arr/remove_all_extents.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_all_extents
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+template <class T, class U>
+void test_remove_all_extents()
+{
+    static_assert((std::is_same<typename std::remove_all_extents<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::remove_all_extents_t<T>,     U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_remove_all_extents<int, int> ();
+    test_remove_all_extents<const Enum, const Enum> ();
+    test_remove_all_extents<int[], int> ();
+    test_remove_all_extents<const int[], const int> ();
+    test_remove_all_extents<int[3], int> ();
+    test_remove_all_extents<const int[3], const int> ();
+    test_remove_all_extents<int[][3], int> ();
+    test_remove_all_extents<const int[][3], const int> ();
+    test_remove_all_extents<int[2][3], int> ();
+    test_remove_all_extents<const int[2][3], const int> ();
+    test_remove_all_extents<int[1][2][3], int> ();
+    test_remove_all_extents<const int[1][2][3], const int> ();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp
new file mode 100644
index 0000000..c688c26
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.arr/remove_extent.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_extent
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+template <class T, class U>
+void test_remove_extent()
+{
+    static_assert((std::is_same<typename std::remove_extent<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::remove_extent_t<T>,     U>::value), "");
+#endif
+}
+
+
+int main()
+{
+    test_remove_extent<int, int> ();
+    test_remove_extent<const Enum, const Enum> ();
+    test_remove_extent<int[], int> ();
+    test_remove_extent<const int[], const int> ();
+    test_remove_extent<int[3], int> ();
+    test_remove_extent<const int[3], const int> ();
+    test_remove_extent<int[][3], int[3]> ();
+    test_remove_extent<const int[][3], const int[3]> ();
+    test_remove_extent<int[2][3], int[3]> ();
+    test_remove_extent<const int[2][3], const int[3]> ();
+    test_remove_extent<int[1][2][3], int[2][3]> ();
+    test_remove_extent<const int[1][2][3], const int[2][3]> ();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp
new file mode 100644
index 0000000..19b1fb4
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.cv/add_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_const
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_const_imp()
+{
+    static_assert((std::is_same<typename std::add_const<T>::type, const U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::add_const_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_add_const()
+{
+    test_add_const_imp<T, const T>();
+    test_add_const_imp<const T, const T>();
+    test_add_const_imp<volatile T, volatile const T>();
+    test_add_const_imp<const volatile T, const volatile T>();
+}
+
+int main()
+{
+    test_add_const<void>();
+    test_add_const<int>();
+    test_add_const<int[3]>();
+    test_add_const<int&>();
+    test_add_const<const int&>();
+    test_add_const<int*>();
+    test_add_const<const int*>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp
new file mode 100644
index 0000000..4905e51
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.cv/add_cv.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_cv
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_cv_imp()
+{
+    static_assert((std::is_same<typename std::add_cv<T>::type, const volatile U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::add_cv_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_add_cv()
+{
+    test_add_cv_imp<T, const volatile T>();
+    test_add_cv_imp<const T, const volatile T>();
+    test_add_cv_imp<volatile T, volatile const T>();
+    test_add_cv_imp<const volatile T, const volatile T>();
+}
+
+int main()
+{
+    test_add_cv<void>();
+    test_add_cv<int>();
+    test_add_cv<int[3]>();
+    test_add_cv<int&>();
+    test_add_cv<const int&>();
+    test_add_cv<int*>();
+    test_add_cv<const int*>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp
new file mode 100644
index 0000000..7a12c44
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.cv/add_volatile.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_volatile
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_volatile_imp()
+{
+    static_assert((std::is_same<typename std::add_volatile<T>::type, volatile U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::add_volatile_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_add_volatile()
+{
+    test_add_volatile_imp<T, volatile T>();
+    test_add_volatile_imp<const T, const volatile T>();
+    test_add_volatile_imp<volatile T, volatile T>();
+    test_add_volatile_imp<const volatile T, const volatile T>();
+}
+
+int main()
+{
+    test_add_volatile<void>();
+    test_add_volatile<int>();
+    test_add_volatile<int[3]>();
+    test_add_volatile<int&>();
+    test_add_volatile<const int&>();
+    test_add_volatile<int*>();
+    test_add_volatile<const int*>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp
new file mode 100644
index 0000000..cd2faf7
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_const.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_const
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_const_imp()
+{
+    static_assert((std::is_same<typename std::remove_const<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::remove_const_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_remove_const()
+{
+    test_remove_const_imp<T, T>();
+    test_remove_const_imp<const T, T>();
+    test_remove_const_imp<volatile T, volatile T>();
+    test_remove_const_imp<const volatile T, volatile T>();
+}
+
+int main()
+{
+    test_remove_const<void>();
+    test_remove_const<int>();
+    test_remove_const<int[3]>();
+    test_remove_const<int&>();
+    test_remove_const<const int&>();
+    test_remove_const<int*>();
+    test_remove_const<const int*>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp
new file mode 100644
index 0000000..3f6405c
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_cv.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_cv
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_cv_imp()
+{
+    static_assert((std::is_same<typename std::remove_cv<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::remove_cv_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_remove_cv()
+{
+    test_remove_cv_imp<T, T>();
+    test_remove_cv_imp<const T, T>();
+    test_remove_cv_imp<volatile T, T>();
+    test_remove_cv_imp<const volatile T, T>();
+}
+
+int main()
+{
+    test_remove_cv<void>();
+    test_remove_cv<int>();
+    test_remove_cv<int[3]>();
+    test_remove_cv<int&>();
+    test_remove_cv<const int&>();
+    test_remove_cv<int*>();
+    test_remove_cv<const int*>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp
new file mode 100644
index 0000000..6258a90
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.cv/remove_volatile.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_volatile
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_volatile_imp()
+{
+    static_assert((std::is_same<typename std::remove_volatile<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::remove_volatile_t<T>, U>::value), "");
+#endif
+}
+
+template <class T>
+void test_remove_volatile()
+{
+    test_remove_volatile_imp<T, T>();
+    test_remove_volatile_imp<const T, const T>();
+    test_remove_volatile_imp<volatile T, T>();
+    test_remove_volatile_imp<const volatile T, const T>();
+}
+
+int main()
+{
+    test_remove_volatile<void>();
+    test_remove_volatile<int>();
+    test_remove_volatile<int[3]>();
+    test_remove_volatile<int&>();
+    test_remove_volatile<const int&>();
+    test_remove_volatile<int*>();
+    test_remove_volatile<volatile int*>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
new file mode 100644
index 0000000..c87e99c
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// aligned_storage
+
+#include <type_traits>
+
+int main()
+{
+    {
+    typedef std::aligned_storage<10, 1 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<10, 1>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 1, "");
+    static_assert(sizeof(T1) == 10, "");
+    }
+    {
+    typedef std::aligned_storage<10, 2 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<10, 2>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 2, "");
+    static_assert(sizeof(T1) == 10, "");
+    }
+    {
+    typedef std::aligned_storage<10, 4 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<10, 4>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 12, "");
+    }
+    {
+    typedef std::aligned_storage<10, 8 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<10, 8>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 8, "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+    {
+    typedef std::aligned_storage<10, 16 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<10, 16>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 16, "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+    {
+    typedef std::aligned_storage<10, 32 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<10, 32>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 32, "");
+    static_assert(sizeof(T1) == 32, "");
+    }
+    {
+    typedef std::aligned_storage<20, 32 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<20, 32>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 32, "");
+    static_assert(sizeof(T1) == 32, "");
+    }
+    {
+    typedef std::aligned_storage<40, 32 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<40, 32>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 32, "");
+    static_assert(sizeof(T1) == 64, "");
+    }
+    {
+    typedef std::aligned_storage<12, 16 >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<12, 16>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 16, "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+    {
+    typedef std::aligned_storage<1>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<1>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 1, "");
+    static_assert(sizeof(T1) == 1, "");
+    }
+    {
+    typedef std::aligned_storage<2>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<2>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 2, "");
+    static_assert(sizeof(T1) == 2, "");
+    }
+    {
+    typedef std::aligned_storage<3>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<3>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 2, "");
+    static_assert(sizeof(T1) == 4, "");
+    }
+    {
+    typedef std::aligned_storage<4>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<4>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 4, "");
+    }
+    {
+    typedef std::aligned_storage<5>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<5>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 8, "");
+    }
+    {
+    typedef std::aligned_storage<7>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<7>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 8, "");
+    }
+    {
+    typedef std::aligned_storage<8>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<8>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 8, "");
+    static_assert(sizeof(T1) == 8, "");
+    }
+    {
+    typedef std::aligned_storage<9>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<9>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 8, "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+    {
+    typedef std::aligned_storage<15>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<15>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 8, "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+    // Use alignof(std::max_align_t) below to find the max alignment instead of
+    // hardcoding it, because it's different on different platforms.
+    // (For example 8 on arm and 16 on x86.)
+#if __cplusplus < 201103L
+#define alignof __alignof__
+#endif
+    {
+    typedef std::aligned_storage<16>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<16>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
+                  "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+    {
+    typedef std::aligned_storage<17>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<17>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == alignof(std::max_align_t),
+                  "");
+    static_assert(sizeof(T1) == 16 + alignof(std::max_align_t), "");
+    }
+    {
+    typedef std::aligned_storage<10>::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_storage_t<10>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 8, "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp
new file mode 100644
index 0000000..ae849ca
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// aligned_union<size_t Len, class ...Types>
+
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+    typedef std::aligned_union<10, char >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<10, char>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 1, "");
+    static_assert(sizeof(T1) == 10, "");
+    }
+    {
+    typedef std::aligned_union<10, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<10, short>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 2, "");
+    static_assert(sizeof(T1) == 10, "");
+    }
+    {
+    typedef std::aligned_union<10, int >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<10, int>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 12, "");
+    }
+    {
+    typedef std::aligned_union<10, double >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<10, double>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 8, "");
+    static_assert(sizeof(T1) == 16, "");
+    }
+    {
+    typedef std::aligned_union<10, short, char >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<10, short, char>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 2, "");
+    static_assert(sizeof(T1) == 10, "");
+    }
+    {
+    typedef std::aligned_union<10, char, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<10, char, short>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 2, "");
+    static_assert(sizeof(T1) == 10, "");
+    }
+    {
+    typedef std::aligned_union<2, int, char, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<2, int, char, short>, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 4, "");
+    }
+    {
+    typedef std::aligned_union<2, char, int, short >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<2, char, int, short >, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 4, "");
+    }
+    {
+    typedef std::aligned_union<2, char, short, int >::type T1;
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_same<std::aligned_union_t<2, char, short, int >, T1>::value, "" );
+#endif
+    static_assert(std::alignment_of<T1>::value == 4, "");
+    static_assert(sizeof(T1) == 4, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
new file mode 100644
index 0000000..91bf7e7
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// common_type
+
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::common_type<int>::type, int>::value), "");
+    static_assert((std::is_same<std::common_type<char>::type, char>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::common_type_t<int>,   int>::value), "");
+    static_assert((std::is_same<std::common_type_t<char>, char>::value), "");
+#endif
+
+    static_assert((std::is_same<std::common_type<               int>::type, int>::value), "");
+    static_assert((std::is_same<std::common_type<const          int>::type, int>::value), "");
+    static_assert((std::is_same<std::common_type<      volatile int>::type, int>::value), "");
+    static_assert((std::is_same<std::common_type<const volatile int>::type, int>::value), "");
+
+    static_assert((std::is_same<std::common_type<int,           int>::type, int>::value), "");
+    static_assert((std::is_same<std::common_type<int,     const int>::type, int>::value), "");
+    
+    static_assert((std::is_same<std::common_type<long,       const int>::type, long>::value), "");
+    static_assert((std::is_same<std::common_type<const long,       int>::type, long>::value), "");
+    static_assert((std::is_same<std::common_type<long,    volatile int>::type, long>::value), "");
+    static_assert((std::is_same<std::common_type<volatile long,    int>::type, long>::value), "");
+    static_assert((std::is_same<std::common_type<const long, const int>::type, long>::value), "");
+
+    static_assert((std::is_same<std::common_type<double, char>::type, double>::value), "");
+    static_assert((std::is_same<std::common_type<short, char>::type, int>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::common_type_t<double, char>, double>::value), "");
+    static_assert((std::is_same<std::common_type_t<short, char>, int>::value), "");
+#endif
+
+    static_assert((std::is_same<std::common_type<double, char, long long>::type, double>::value), "");
+    static_assert((std::is_same<std::common_type<unsigned, char, long long>::type, long long>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::common_type_t<double, char, long long>, double>::value), "");
+    static_assert((std::is_same<std::common_type_t<unsigned, char, long long>, long long>::value), "");
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp
new file mode 100644
index 0000000..ac11e3a
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/conditional.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// conditional
+
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::conditional<true, char, int>::type, char>::value), "");
+    static_assert((std::is_same<std::conditional<false, char, int>::type, int>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::conditional_t<true, char, int>, char>::value), "");
+    static_assert((std::is_same<std::conditional_t<false, char, int>, int>::value), "");
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp
new file mode 100644
index 0000000..bd8ae0e
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/decay.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// decay
+
+#include <type_traits>
+
+template <class T, class U>
+void test_decay()
+{
+    static_assert((std::is_same<typename std::decay<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::decay_t<T>,     U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_decay<void, void>();
+    test_decay<int, int>();
+    test_decay<const volatile int, int>();
+    test_decay<int*, int*>();
+    test_decay<int[3], int*>();
+    test_decay<const int[3], const int*>();
+    test_decay<void(), void (*)()>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp
new file mode 100644
index 0000000..1ab0767
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enable_if
+
+#include <type_traits>
+
+int main()
+{
+    typedef std::enable_if<false>::type A;
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp
new file mode 100644
index 0000000..eb72b0f
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enable_if
+
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::enable_if<true>::type, void>::value), "");
+    static_assert((std::is_same<std::enable_if<true, int>::type, int>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::enable_if_t<true>, void>::value), "");
+    static_assert((std::is_same<std::enable_if_t<true, int>, int>::value), "");
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp
new file mode 100644
index 0000000..8ce8945
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/enable_if2.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enable_if
+
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::enable_if_t<false> A;
+#else
+    static_assert ( false, "" );
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
new file mode 100644
index 0000000..bf44c34
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// result_of<Fn(ArgTypes...)>
+
+#include <type_traits>
+#include <memory>
+
+typedef bool (&PF1)();
+typedef short (*PF2)(long);
+
+struct S
+{
+    operator PF2() const;
+    double operator()(char, int&);
+    void calc(long) const;
+    char data_;
+};
+
+typedef void (S::*PMS)(long) const;
+typedef char S::*PMD;
+
+struct wat
+{
+    wat& operator*() { return *this; }
+    void foo();
+};
+
+struct F {};
+
+template <class T, class U>
+void test_result_of_imp()
+{
+    static_assert((std::is_same<typename std::result_of<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::result_of_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_result_of_imp<S(int), short> ();
+    test_result_of_imp<S&(unsigned char, int&), double> ();
+    test_result_of_imp<PF1(), bool> ();
+    test_result_of_imp<PMS(std::unique_ptr<S>, int), void> ();
+    test_result_of_imp<PMS(S, int), void> ();
+    test_result_of_imp<PMS(const S&, int), void> ();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_result_of_imp<PMD(S), char&&> ();
+#endif
+    test_result_of_imp<PMD(const S*), const char&> ();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_result_of_imp<int (F::* (F       &)) ()       &, int> ();
+    test_result_of_imp<int (F::* (F       &)) () const &, int> ();
+    test_result_of_imp<int (F::* (F const &)) () const &, int> ();
+    test_result_of_imp<int (F::* (F      &&)) ()      &&, int> ();
+    test_result_of_imp<int (F::* (F      &&)) () const&&, int> ();
+    test_result_of_imp<int (F::* (F const&&)) () const&&, int> ();
+#endif
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    using type1 = std::result_of<decltype(&wat::foo)(wat)>::type;
+#endif
+#if _LIBCPP_STD_VER > 11
+    using type2 = std::result_of_t<decltype(&wat::foo)(wat)>;
+#endif
+
+
+
+    static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!");
+    static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!");
+    static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!");
+    static_assert((std::is_same<std::result_of<PMS(std::unique_ptr<S>, int)>::type, void>::value), "Error!");
+    static_assert((std::is_same<std::result_of<PMS(S, int)>::type, void>::value), "Error!");
+    static_assert((std::is_same<std::result_of<PMS(const S&, int)>::type, void>::value), "Error!");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert((std::is_same<std::result_of<PMD(S)>::type, char&&>::value), "Error!");
+#endif
+    static_assert((std::is_same<std::result_of<PMD(const S*)>::type, const char&>::value), "Error!");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert((std::is_same<std::result_of<int (F::* (F       &)) ()       &>::type, int>::value), "Error!");
+    static_assert((std::is_same<std::result_of<int (F::* (F       &)) () const &>::type, int>::value), "Error!");
+    static_assert((std::is_same<std::result_of<int (F::* (F const &)) () const &>::type, int>::value), "Error!");
+    static_assert((std::is_same<std::result_of<int (F::* (F      &&)) ()      &&>::type, int>::value), "Error!");
+    static_assert((std::is_same<std::result_of<int (F::* (F      &&)) () const&&>::type, int>::value), "Error!");
+    static_assert((std::is_same<std::result_of<int (F::* (F const&&)) () const&&>::type, int>::value), "Error!");
+#endif
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+    using type = std::result_of<decltype(&wat::foo)(wat)>::type;
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
new file mode 100644
index 0000000..728062b
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.other/underlying_type.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// underlying_type
+
+#include <type_traits>
+#include <climits>
+
+enum E { V = INT_MIN };
+enum F { W = UINT_MAX };
+
+int main()
+{
+    static_assert((std::is_same<std::underlying_type<E>::type, int>::value),
+                  "E has the wrong underlying type");
+    static_assert((std::is_same<std::underlying_type<F>::type, unsigned>::value),
+                  "F has the wrong underlying type");
+
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::underlying_type_t<E>, int>::value), "");
+    static_assert((std::is_same<std::underlying_type_t<F>, unsigned>::value), "");
+#endif
+
+#if __has_feature(cxx_strong_enums)
+    enum G : char { };
+
+    static_assert((std::is_same<std::underlying_type<G>::type, char>::value),
+                  "G has the wrong underlying type");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::underlying_type_t<G>, char>::value), "");
+#endif
+#endif // __has_feature(cxx_strong_enums)
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp
new file mode 100644
index 0000000..76d0f12
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.ptr/add_pointer.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_pointer
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_pointer()
+{
+    static_assert((std::is_same<typename std::add_pointer<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::add_pointer_t<T>,     U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_add_pointer<void, void*>();
+    test_add_pointer<int, int*>();
+    test_add_pointer<int[3], int(*)[3]>();
+    test_add_pointer<int&, int*>();
+    test_add_pointer<const int&, const int*>();
+    test_add_pointer<int*, int**>();
+    test_add_pointer<const int*, const int**>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp
new file mode 100644
index 0000000..9cecd39
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.ptr/remove_pointer.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_pointer
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_pointer()
+{
+    static_assert((std::is_same<typename std::remove_pointer<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::remove_pointer_t<T>,     U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_remove_pointer<void, void>();
+    test_remove_pointer<int, int>();
+    test_remove_pointer<int[3], int[3]>();
+    test_remove_pointer<int*, int>();
+    test_remove_pointer<const int*, const int>();
+    test_remove_pointer<int**, int*>();
+    test_remove_pointer<int** const, int*>();
+    test_remove_pointer<int*const * , int* const>();
+    test_remove_pointer<const int** , const int*>();
+
+    test_remove_pointer<int&, int&>();
+    test_remove_pointer<const int&, const int&>();
+    test_remove_pointer<int(&)[3], int(&)[3]>();
+    test_remove_pointer<int(*)[3], int[3]>();
+    test_remove_pointer<int*&, int*&>();
+    test_remove_pointer<const int*&, const int*&>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
new file mode 100644
index 0000000..8150ce0
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_lvalue_reference
+
+#include <type_traits>
+
+template <class T, class U>
+void test_add_lvalue_reference()
+{
+    static_assert((std::is_same<typename std::add_lvalue_reference<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::add_lvalue_reference_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_add_lvalue_reference<void, void>();
+    test_add_lvalue_reference<int, int&>();
+    test_add_lvalue_reference<int[3], int(&)[3]>();
+    test_add_lvalue_reference<int&, int&>();
+    test_add_lvalue_reference<const int&, const int&>();
+    test_add_lvalue_reference<int*, int*&>();
+    test_add_lvalue_reference<const int*, const int*&>();
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp
new file mode 100644
index 0000000..e8f08fd
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.ref/add_rvalue_ref.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// add_rvalue_reference
+
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class T, class U>
+void test_add_rvalue_reference()
+{
+    static_assert((std::is_same<typename std::add_rvalue_reference<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::add_rvalue_reference_t<T>, U>::value), "");
+#endif
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_add_rvalue_reference<void, void>();
+    test_add_rvalue_reference<int, int&&>();
+    test_add_rvalue_reference<int[3], int(&&)[3]>();
+    test_add_rvalue_reference<int&, int&>();
+    test_add_rvalue_reference<const int&, const int&>();
+    test_add_rvalue_reference<int*, int*&&>();
+    test_add_rvalue_reference<const int*, const int*&&>();
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp
new file mode 100644
index 0000000..f9ebc37
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.ref/remove_ref.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// remove_reference
+
+#include <type_traits>
+
+template <class T, class U>
+void test_remove_reference()
+{
+    static_assert((std::is_same<typename std::remove_reference<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::remove_reference_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_remove_reference<void, void>();
+    test_remove_reference<int, int>();
+    test_remove_reference<int[3], int[3]>();
+    test_remove_reference<int*, int*>();
+    test_remove_reference<const int*, const int*>();
+
+    test_remove_reference<int&, int>();
+    test_remove_reference<const int&, const int>();
+    test_remove_reference<int(&)[3], int[3]>();
+    test_remove_reference<int*&, int*>();
+    test_remove_reference<const int*&, const int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_remove_reference<int&&, int>();
+    test_remove_reference<const int&&, const int>();
+    test_remove_reference<int(&&)[3], int[3]>();
+    test_remove_reference<int*&&, int*>();
+    test_remove_reference<const int*&&, const int*>();
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
new file mode 100644
index 0000000..7de3b0d
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.sign/make_signed.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// make_signed
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+enum BigEnum
+{
+    bigzero,
+    big = 0xFFFFFFFFFFFFFFFFULL
+};
+
+#if !defined(_LIBCPP_HAS_NO_INT128) && !defined(_LIBCPP_HAS_NO_STRONG_ENUMS)
+enum HugeEnum : __uint128_t
+{
+    hugezero
+};
+#endif
+
+template <class T, class U>
+void test_make_signed()
+{
+    static_assert((std::is_same<typename std::make_signed<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::make_signed_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_make_signed< signed char, signed char >();
+    test_make_signed< unsigned char, signed char >();
+    test_make_signed< char, signed char >();
+    test_make_signed< short, signed short >();
+    test_make_signed< unsigned short, signed short >();
+    test_make_signed< int, signed int >();
+    test_make_signed< unsigned int, signed int >();
+    test_make_signed< long, signed long >();
+    test_make_signed< unsigned long, long >();
+    test_make_signed< long long, signed long long >();
+    test_make_signed< unsigned long long, signed long long >();
+    test_make_signed< wchar_t, std::conditional<sizeof(wchar_t) == 4, int, short>::type >();
+    test_make_signed< const wchar_t, std::conditional<sizeof(wchar_t) == 4, const int, const short>::type >();
+    test_make_signed< const Enum, const int >();
+    test_make_signed< BigEnum, std::conditional<sizeof(long) == 4, long long, long>::type >();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test_make_signed< __int128_t, __int128_t >();
+    test_make_signed< __uint128_t, __int128_t >();
+# ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
+    test_make_signed< HugeEnum, __int128_t >();
+# endif
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp b/final/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
new file mode 100644
index 0000000..a13485a
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/meta.trans.sign/make_unsigned.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// make_unsigned
+
+#include <type_traits>
+
+enum Enum {zero, one_};
+
+enum BigEnum
+{
+    bigzero,
+    big = 0xFFFFFFFFFFFFFFFFULL
+};
+
+#if !defined(_LIBCPP_HAS_NO_INT128) && !defined(_LIBCPP_HAS_NO_STRONG_ENUMS)
+enum HugeEnum : __int128_t
+{
+    hugezero
+};
+#endif
+
+template <class T, class U>
+void test_make_unsigned()
+{
+    static_assert((std::is_same<typename std::make_unsigned<T>::type, U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<std::make_unsigned_t<T>, U>::value), "");
+#endif
+}
+
+int main()
+{
+    test_make_unsigned<signed char, unsigned char> ();
+    test_make_unsigned<unsigned char, unsigned char> ();
+    test_make_unsigned<char, unsigned char> ();
+    test_make_unsigned<short, unsigned short> ();
+    test_make_unsigned<unsigned short, unsigned short> ();
+    test_make_unsigned<int, unsigned int> ();
+    test_make_unsigned<unsigned int, unsigned int> ();
+    test_make_unsigned<long, unsigned long> ();
+    test_make_unsigned<unsigned long, unsigned long> ();
+    test_make_unsigned<long long, unsigned long long> ();
+    test_make_unsigned<unsigned long long, unsigned long long> ();
+    test_make_unsigned<wchar_t, std::conditional<sizeof(wchar_t) == 4, unsigned int, unsigned short>::type> ();
+    test_make_unsigned<const wchar_t, std::conditional<sizeof(wchar_t) == 4, const unsigned int, const unsigned short>::type> ();
+    test_make_unsigned<const Enum, const unsigned int> ();
+    test_make_unsigned<BigEnum,
+                   std::conditional<sizeof(long) == 4, unsigned long long, unsigned long>::type> ();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test_make_unsigned<__int128_t, __uint128_t>();
+    test_make_unsigned<__uint128_t, __uint128_t>();
+# ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
+    test_make_unsigned<HugeEnum, __uint128_t>();
+# endif
+#endif
+}
diff --git a/final/test/utilities/meta/meta.trans/nothing_to_do.pass.cpp b/final/test/utilities/meta/meta.trans/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/meta/meta.trans/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp b/final/test/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/meta/meta.type.synop/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp b/final/test/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
new file mode 100644
index 0000000..01a2f65
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// alignment_of
+
+#include <type_traits>
+#include <cstdint>
+
+template <class T, unsigned A>
+void test_alignment_of()
+{
+    static_assert( std::alignment_of<T>::value == A, "");
+    static_assert( std::alignment_of<const T>::value == A, "");
+    static_assert( std::alignment_of<volatile T>::value == A, "");
+    static_assert( std::alignment_of<const volatile T>::value == A, "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    test_alignment_of<int&, 4>();
+    test_alignment_of<Class, 1>();
+    test_alignment_of<int*, sizeof(intptr_t)>();
+    test_alignment_of<const int*, sizeof(intptr_t)>();
+    test_alignment_of<char[3], 1>();
+    test_alignment_of<int, 4>();
+    test_alignment_of<double, 8>();
+#if (defined(__ppc__) && !defined(__ppc64__))
+    test_alignment_of<bool, 4>();	// 32-bit PPC has four byte bool
+#else
+    test_alignment_of<bool, 1>();
+#endif
+    test_alignment_of<unsigned, 4>();
+}
diff --git a/final/test/utilities/meta/meta.unary.prop.query/extent.pass.cpp b/final/test/utilities/meta/meta.unary.prop.query/extent.pass.cpp
new file mode 100644
index 0000000..a99dc69
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary.prop.query/extent.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// extent
+
+#include <type_traits>
+
+template <class T, unsigned A>
+void test_extent()
+{
+    static_assert((std::extent<T>::value == A), "");
+    static_assert((std::extent<const T>::value == A), "");
+    static_assert((std::extent<volatile T>::value == A), "");
+    static_assert((std::extent<const volatile T>::value == A), "");
+}
+
+template <class T, unsigned A>
+void test_extent1()
+{
+    static_assert((std::extent<T, 1>::value == A), "");
+    static_assert((std::extent<const T, 1>::value == A), "");
+    static_assert((std::extent<volatile T, 1>::value == A), "");
+    static_assert((std::extent<const volatile T, 1>::value == A), "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    test_extent<void, 0>();
+    test_extent<int&, 0>();
+    test_extent<Class, 0>();
+    test_extent<int*, 0>();
+    test_extent<const int*, 0>();
+    test_extent<int, 0>();
+    test_extent<double, 0>();
+    test_extent<bool, 0>();
+    test_extent<unsigned, 0>();
+
+    test_extent<int[2], 2>();
+    test_extent<int[2][4], 2>();
+    test_extent<int[][4], 0>();
+
+    test_extent1<int, 0>();
+    test_extent1<int[2], 0>();
+    test_extent1<int[2][4], 4>();
+    test_extent1<int[][4], 4>();
+}
diff --git a/final/test/utilities/meta/meta.unary.prop.query/rank.pass.cpp b/final/test/utilities/meta/meta.unary.prop.query/rank.pass.cpp
new file mode 100644
index 0000000..06f66a9
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary.prop.query/rank.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// rank
+
+#include <type_traits>
+
+template <class T, unsigned A>
+void test_rank()
+{
+    static_assert( std::rank<T>::value == A, "");
+    static_assert( std::rank<const T>::value == A, "");
+    static_assert( std::rank<volatile T>::value == A, "");
+    static_assert( std::rank<const volatile T>::value == A, "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    test_rank<void, 0>();
+    test_rank<int&, 0>();
+    test_rank<Class, 0>();
+    test_rank<int*, 0>();
+    test_rank<const int*, 0>();
+    test_rank<int, 0>();
+    test_rank<double, 0>();
+    test_rank<bool, 0>();
+    test_rank<unsigned, 0>();
+
+    test_rank<char[3], 1>();
+    test_rank<char[][3], 2>();
+    test_rank<char[][4][3], 3>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp
new file mode 100644
index 0000000..f4dd356
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/array.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// array
+
+#include <type_traits>
+
+template <class T>
+void test_array_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert( std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_array()
+{
+    test_array_imp<T>();
+    test_array_imp<const T>();
+    test_array_imp<volatile T>();
+    test_array_imp<const volatile T>();
+}
+
+typedef char array[3];
+typedef const char const_array[3];
+typedef char incomplete_array[];
+
+int main()
+{
+    test_array<array>();
+    test_array<const_array>();
+    test_array<incomplete_array>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp
new file mode 100644
index 0000000..0de0048
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/class.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// class
+
+#include <type_traits>
+
+template <class T>
+void test_class_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert( std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_class()
+{
+    test_class_imp<T>();
+    test_class_imp<const T>();
+    test_class_imp<volatile T>();
+    test_class_imp<const volatile T>();
+}
+
+class Class
+{
+    int _;
+    double __;
+};
+
+int main()
+{
+    test_class<Class>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp
new file mode 100644
index 0000000..7c9c78f
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/enum.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enum
+
+#include <type_traits>
+
+template <class T>
+void test_enum_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert( std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_enum()
+{
+    test_enum_imp<T>();
+    test_enum_imp<const T>();
+    test_enum_imp<volatile T>();
+    test_enum_imp<const volatile T>();
+}
+
+enum Enum {zero, one};
+
+int main()
+{
+    test_enum<Enum>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp
new file mode 100644
index 0000000..2866449
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/floating_point.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// floating_point
+
+#include <type_traits>
+
+template <class T>
+void test_floating_point_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert( std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_floating_point()
+{
+    test_floating_point_imp<T>();
+    test_floating_point_imp<const T>();
+    test_floating_point_imp<volatile T>();
+    test_floating_point_imp<const volatile T>();
+}
+
+int main()
+{
+    test_floating_point<float>();
+    test_floating_point<double>();
+    test_floating_point<long double>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
new file mode 100644
index 0000000..82757f5
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// function
+
+#include <type_traits>
+
+template <class T>
+void test_function_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert( std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_function()
+{
+    test_function_imp<T>();
+    test_function_imp<const T>();
+    test_function_imp<volatile T>();
+    test_function_imp<const volatile T>();
+}
+
+int main()
+{
+    test_function<void ()>();
+    test_function<void (int)>();
+    test_function<int (double)>();
+    test_function<int (double, char)>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp
new file mode 100644
index 0000000..f68ed3e
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/integral.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// integral
+
+#include <type_traits>
+
+template <class T>
+void test_integral_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert( std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_integral()
+{
+    test_integral_imp<T>();
+    test_integral_imp<const T>();
+    test_integral_imp<volatile T>();
+    test_integral_imp<const volatile T>();
+}
+
+int main()
+{
+    test_integral<bool>();
+    test_integral<char>();
+    test_integral<signed char>();
+    test_integral<unsigned char>();
+    test_integral<wchar_t>();
+    test_integral<short>();
+    test_integral<unsigned short>();
+    test_integral<int>();
+    test_integral<unsigned int>();
+    test_integral<long>();
+    test_integral<unsigned long>();
+    test_integral<long long>();
+    test_integral<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test_integral<__int128_t>();
+    test_integral<__uint128_t>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp
new file mode 100644
index 0000000..3b6ccad
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/lvalue_ref.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// lvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_lvalue_ref()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert( std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+int main()
+{
+    test_lvalue_ref<int&>();
+    test_lvalue_ref<const int&>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
new file mode 100644
index 0000000..c563870
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_function_pointer
+
+#include <type_traits>
+
+template <class T>
+void test_member_function_pointer_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert( std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_member_function_pointer()
+{
+    test_member_function_pointer_imp<T>();
+    test_member_function_pointer_imp<const T>();
+    test_member_function_pointer_imp<volatile T>();
+    test_member_function_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+    test_member_function_pointer<void (Class::*)()>();
+    test_member_function_pointer<void (Class::*)(int)>();
+    test_member_function_pointer<void (Class::*)(int, char)>();
+
+    test_member_function_pointer<void (Class::*)() const>();
+    test_member_function_pointer<void (Class::*)(int) const>();
+    test_member_function_pointer<void (Class::*)(int, char) const>();
+
+    test_member_function_pointer<void (Class::*)() volatile>();
+    test_member_function_pointer<void (Class::*)(int) volatile>();
+    test_member_function_pointer<void (Class::*)(int, char) volatile>();
+
+#if __cplusplus >= 201103L
+// reference qualifiers on functions are a C++11 extension
+    test_member_function_pointer<void (Class::*)() &&>();
+    test_member_function_pointer<void (Class::*)(int) &&>();
+    test_member_function_pointer<void (Class::*)(int, char) &&>();
+
+    test_member_function_pointer<void (Class::*)() &>();
+    test_member_function_pointer<void (Class::*)(int) &>();
+    test_member_function_pointer<void (Class::*)(int, char) &>();
+
+    test_member_function_pointer<void (Class::*)() volatile &&>();
+    test_member_function_pointer<void (Class::*)(int) volatile &&>();
+    test_member_function_pointer<void (Class::*)(int, char) volatile &&>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp
new file mode 100644
index 0000000..4e6699c
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/member_object_pointer.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_object_pointer
+
+#include <type_traits>
+
+template <class T>
+void test_member_object_pointer_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert( std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_member_object_pointer()
+{
+    test_member_object_pointer_imp<T>();
+    test_member_object_pointer_imp<const T>();
+    test_member_object_pointer_imp<volatile T>();
+    test_member_object_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+    test_member_object_pointer<int Class::*>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp
new file mode 100644
index 0000000..d619701
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// nullptr_t
+//	is_null_pointer
+
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+template <class T>
+void test_nullptr_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+    static_assert( std::is_null_pointer<T>::value, "");
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_nullptr()
+{
+    test_nullptr_imp<T>();
+    test_nullptr_imp<const T>();
+    test_nullptr_imp<volatile T>();
+    test_nullptr_imp<const volatile T>();
+}
+
+int main()
+{
+    test_nullptr<std::nullptr_t>();
+}
+#else
+int main() {}
+#endif
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp
new file mode 100644
index 0000000..7073c10
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/pointer.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// pointer
+
+#include <type_traits>
+
+template <class T>
+void test_pointer_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert( std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_pointer()
+{
+    test_pointer_imp<T>();
+    test_pointer_imp<const T>();
+    test_pointer_imp<volatile T>();
+    test_pointer_imp<const volatile T>();
+}
+
+int main()
+{
+    test_pointer<void*>();
+    test_pointer<int*>();
+    test_pointer<const int*>();
+    test_pointer<void (*)(int)>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp
new file mode 100644
index 0000000..7964424
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/rvalue_ref.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// rvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_rvalue_ref()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert( std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_rvalue_ref<int&&>();
+    test_rvalue_ref<const int&&>();
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp
new file mode 100644
index 0000000..6cabb71
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/union.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// union
+
+#include <type_traits>
+
+template <class T>
+void test_union_imp()
+{
+    static_assert(!std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert( std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_union()
+{
+    test_union_imp<T>();
+    test_union_imp<const T>();
+    test_union_imp<volatile T>();
+    test_union_imp<const volatile T>();
+}
+
+union Union
+{
+    int _;
+    double __;
+};
+
+int main()
+{
+    test_union<Union>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp
new file mode 100644
index 0000000..f20bcf8
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.cat/void.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// void
+
+#include <type_traits>
+
+template <class T>
+void test_void_imp()
+{
+    static_assert( std::is_void<T>::value, "");
+#if _LIBCPP_STD_VER > 11
+    static_assert(!std::is_null_pointer<T>::value, "");
+#endif
+    static_assert(!std::is_integral<T>::value, "");
+    static_assert(!std::is_floating_point<T>::value, "");
+    static_assert(!std::is_array<T>::value, "");
+    static_assert(!std::is_pointer<T>::value, "");
+    static_assert(!std::is_lvalue_reference<T>::value, "");
+    static_assert(!std::is_rvalue_reference<T>::value, "");
+    static_assert(!std::is_member_object_pointer<T>::value, "");
+    static_assert(!std::is_member_function_pointer<T>::value, "");
+    static_assert(!std::is_enum<T>::value, "");
+    static_assert(!std::is_union<T>::value, "");
+    static_assert(!std::is_class<T>::value, "");
+    static_assert(!std::is_function<T>::value, "");
+}
+
+template <class T>
+void test_void()
+{
+    test_void_imp<T>();
+    test_void_imp<const T>();
+    test_void_imp<volatile T>();
+    test_void_imp<const volatile T>();
+}
+
+int main()
+{
+    test_void<void>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp
new file mode 100644
index 0000000..3476d5c
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/array.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// array
+
+#include <type_traits>
+
+template <class T>
+void test_array_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert(!std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_array()
+{
+    test_array_imp<T>();
+    test_array_imp<const T>();
+    test_array_imp<volatile T>();
+    test_array_imp<const volatile T>();
+}
+
+typedef char array[3];
+typedef const char const_array[3];
+typedef char incomplete_array[];
+
+int main()
+{
+    test_array<array>();
+    test_array<const_array>();
+    test_array<incomplete_array>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp
new file mode 100644
index 0000000..a77a101
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/class.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// class
+
+#include <type_traits>
+
+template <class T>
+void test_class_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert(!std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_class()
+{
+    test_class_imp<T>();
+    test_class_imp<const T>();
+    test_class_imp<volatile T>();
+    test_class_imp<const volatile T>();
+}
+
+class Class
+{
+    int _;
+    double __;
+};
+
+int main()
+{
+    test_class<Class>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp
new file mode 100644
index 0000000..dc9e487
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/enum.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// enum
+
+#include <type_traits>
+
+template <class T>
+void test_enum_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert( std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_enum()
+{
+    test_enum_imp<T>();
+    test_enum_imp<const T>();
+    test_enum_imp<volatile T>();
+    test_enum_imp<const volatile T>();
+}
+
+enum Enum {zero, one};
+
+int main()
+{
+    test_enum<Enum>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp
new file mode 100644
index 0000000..3560b45
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/floating_point.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// floating_point
+
+#include <type_traits>
+
+template <class T>
+void test_floating_point_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert( std::is_arithmetic<T>::value, "");
+    static_assert( std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert( std::is_scalar<T>::value, "");
+    static_assert(!std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_floating_point()
+{
+    test_floating_point_imp<T>();
+    test_floating_point_imp<const T>();
+    test_floating_point_imp<volatile T>();
+    test_floating_point_imp<const volatile T>();
+}
+
+int main()
+{
+    test_floating_point<float>();
+    test_floating_point<double>();
+    test_floating_point<long double>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp
new file mode 100644
index 0000000..fc8a1e5
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/function.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// function
+
+#include <type_traits>
+
+template <class T>
+void test_function_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert(!std::is_object<T>::value, "");
+    static_assert(!std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_function()
+{
+    test_function_imp<T>();
+    test_function_imp<const T>();
+    test_function_imp<volatile T>();
+    test_function_imp<const volatile T>();
+}
+
+int main()
+{
+    test_function<void ()>();
+    test_function<void (int)>();
+    test_function<int (double)>();
+    test_function<int (double, char)>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp
new file mode 100644
index 0000000..0bc9458
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/integral.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// integral
+
+#include <type_traits>
+
+template <class T>
+void test_integral_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert( std::is_arithmetic<T>::value, "");
+    static_assert( std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert( std::is_scalar<T>::value, "");
+    static_assert(!std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_integral()
+{
+    test_integral_imp<T>();
+    test_integral_imp<const T>();
+    test_integral_imp<volatile T>();
+    test_integral_imp<const volatile T>();
+}
+
+int main()
+{
+    test_integral<bool>();
+    test_integral<char>();
+    test_integral<signed char>();
+    test_integral<unsigned char>();
+    test_integral<wchar_t>();
+    test_integral<short>();
+    test_integral<unsigned short>();
+    test_integral<int>();
+    test_integral<unsigned int>();
+    test_integral<long>();
+    test_integral<unsigned long>();
+    test_integral<long long>();
+    test_integral<unsigned long long>();
+#ifndef _LIBCPP_HAS_NO_INT128
+    test_integral<__int128_t>();
+    test_integral<__uint128_t>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp
new file mode 100644
index 0000000..dd81283
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/lvalue_ref.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// lvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_lvalue_ref()
+{
+    static_assert( std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert(!std::is_object<T>::value, "");
+    static_assert(!std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+int main()
+{
+    test_lvalue_ref<int&>();
+    test_lvalue_ref<const int&>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp
new file mode 100644
index 0000000..0df2117
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/member_function_pointer.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_function_pointer
+
+#include <type_traits>
+
+template <class T>
+void test_member_function_pointer_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert( std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert( std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_member_function_pointer()
+{
+    test_member_function_pointer_imp<T>();
+    test_member_function_pointer_imp<const T>();
+    test_member_function_pointer_imp<volatile T>();
+    test_member_function_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+    test_member_function_pointer<void (Class::*)()>();
+    test_member_function_pointer<void (Class::*)(int)>();
+    test_member_function_pointer<void (Class::*)(int, char)>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp
new file mode 100644
index 0000000..a0dea4a
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/member_object_pointer.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// member_object_pointer
+
+#include <type_traits>
+
+template <class T>
+void test_member_object_pointer_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert( std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert( std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_member_object_pointer()
+{
+    test_member_object_pointer_imp<T>();
+    test_member_object_pointer_imp<const T>();
+    test_member_object_pointer_imp<volatile T>();
+    test_member_object_pointer_imp<const volatile T>();
+}
+
+class Class
+{
+};
+
+int main()
+{
+    test_member_object_pointer<int Class::*>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp
new file mode 100644
index 0000000..de23da8
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/pointer.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// pointer
+
+#include <type_traits>
+
+template <class T>
+void test_pointer_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert( std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_pointer()
+{
+    test_pointer_imp<T>();
+    test_pointer_imp<const T>();
+    test_pointer_imp<volatile T>();
+    test_pointer_imp<const volatile T>();
+}
+
+int main()
+{
+    test_pointer<void*>();
+    test_pointer<int*>();
+    test_pointer<const int*>();
+    test_pointer<void (*)(int)>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp
new file mode 100644
index 0000000..7563c2f
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/rvalue_ref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// rvalue_ref
+
+#include <type_traits>
+
+template <class T>
+void test_rvalue_ref()
+{
+    static_assert( std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert(!std::is_object<T>::value, "");
+    static_assert(!std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_rvalue_ref<int&&>();
+    test_rvalue_ref<const int&&>();
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp
new file mode 100644
index 0000000..05db74c
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/union.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// union
+
+#include <type_traits>
+
+template <class T>
+void test_union_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert(!std::is_fundamental<T>::value, "");
+    static_assert( std::is_object<T>::value, "");
+    static_assert(!std::is_scalar<T>::value, "");
+    static_assert( std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_union()
+{
+    test_union_imp<T>();
+    test_union_imp<const T>();
+    test_union_imp<volatile T>();
+    test_union_imp<const volatile T>();
+}
+
+union Union
+{
+    int _;
+    double __;
+};
+
+int main()
+{
+    test_union<Union>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp
new file mode 100644
index 0000000..59569fe
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.comp/void.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// void
+
+#include <type_traits>
+
+template <class T>
+void test_void_imp()
+{
+    static_assert(!std::is_reference<T>::value, "");
+    static_assert(!std::is_arithmetic<T>::value, "");
+    static_assert( std::is_fundamental<T>::value, "");
+    static_assert(!std::is_object<T>::value, "");
+    static_assert(!std::is_scalar<T>::value, "");
+    static_assert(!std::is_compound<T>::value, "");
+    static_assert(!std::is_member_pointer<T>::value, "");
+}
+
+template <class T>
+void test_void()
+{
+    test_void_imp<T>();
+    test_void_imp<const T>();
+    test_void_imp<volatile T>();
+    test_void_imp<const volatile T>();
+}
+
+int main()
+{
+    test_void<void>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
new file mode 100644
index 0000000..de27b98
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/__has_operator_addressof.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// extension
+
+// template <typename _Tp> struct __has_operator_addressof
+
+
+#include <type_traits>
+
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+
+struct A
+{
+};
+
+struct B
+{
+    constexpr B* operator&() const;
+};
+
+struct D;
+
+struct C
+{
+    template <class U>
+    D operator,(U&&);
+};
+
+struct E
+{
+    constexpr C operator&() const;
+};
+
+#endif  // _LIBCPP_HAS_NO_CONSTEXPR
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    static_assert(std::__has_operator_addressof<int>::value == false, "");
+    static_assert(std::__has_operator_addressof<A>::value == false, "");
+    static_assert(std::__has_operator_addressof<B>::value == true, "");
+    static_assert(std::__has_operator_addressof<E>::value == true, "");
+#endif  // _LIBCPP_HAS_NO_CONSTEXPR
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
new file mode 100644
index 0000000..92fd336
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_virtual_destructor
+
+#include <type_traits>
+
+template <class T>
+void test_has_virtual_destructor()
+{
+    static_assert( std::has_virtual_destructor<T>::value, "");
+    static_assert( std::has_virtual_destructor<const T>::value, "");
+    static_assert( std::has_virtual_destructor<volatile T>::value, "");
+    static_assert( std::has_virtual_destructor<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_virtual_destructor()
+{
+    static_assert(!std::has_virtual_destructor<T>::value, "");
+    static_assert(!std::has_virtual_destructor<const T>::value, "");
+    static_assert(!std::has_virtual_destructor<volatile T>::value, "");
+    static_assert(!std::has_virtual_destructor<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    ~A();
+};
+
+int main()
+{
+    test_has_not_virtual_destructor<void>();
+    test_has_not_virtual_destructor<A>();
+    test_has_not_virtual_destructor<int&>();
+    test_has_not_virtual_destructor<Union>();
+    test_has_not_virtual_destructor<Empty>();
+    test_has_not_virtual_destructor<int>();
+    test_has_not_virtual_destructor<double>();
+    test_has_not_virtual_destructor<int*>();
+    test_has_not_virtual_destructor<const int*>();
+    test_has_not_virtual_destructor<char[3]>();
+    test_has_not_virtual_destructor<char[3]>();
+    test_has_not_virtual_destructor<bit_zero>();
+
+    test_has_virtual_destructor<Abstract>();
+    test_has_virtual_destructor<NotEmpty>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
new file mode 100644
index 0000000..cba575f
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_abstract
+
+#include <type_traits>
+
+template <class T>
+void test_is_abstract()
+{
+    static_assert( std::is_abstract<T>::value, "");
+    static_assert( std::is_abstract<const T>::value, "");
+    static_assert( std::is_abstract<volatile T>::value, "");
+    static_assert( std::is_abstract<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_abstract()
+{
+    static_assert(!std::is_abstract<T>::value, "");
+    static_assert(!std::is_abstract<const T>::value, "");
+    static_assert(!std::is_abstract<volatile T>::value, "");
+    static_assert(!std::is_abstract<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual ~Abstract() = 0;
+};
+
+int main()
+{
+    test_is_not_abstract<void>();
+    test_is_not_abstract<int&>();
+    test_is_not_abstract<int>();
+    test_is_not_abstract<double>();
+    test_is_not_abstract<int*>();
+    test_is_not_abstract<const int*>();
+    test_is_not_abstract<char[3]>();
+    test_is_not_abstract<char[3]>();
+    test_is_not_abstract<Union>();
+    test_is_not_abstract<Empty>();
+    test_is_not_abstract<bit_zero>();
+    test_is_not_abstract<NotEmpty>();
+
+    test_is_abstract<Abstract>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
new file mode 100644
index 0000000..b46a4d6
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_assignable
+
+#include <type_traits>
+
+struct A
+{
+};
+
+struct B
+{
+    void operator=(A);
+};
+
+template <class T, class U>
+void test_is_assignable()
+{
+    static_assert(( std::is_assignable<T, U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_assignable()
+{
+    static_assert((!std::is_assignable<T, U>::value), "");
+}
+
+struct D;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+struct C
+{
+    template <class U>
+    D operator,(U&&);
+};
+
+struct E
+{
+    C operator=(int);
+};
+#endif
+
+int main()
+{
+    test_is_assignable<int&, int&> ();
+    test_is_assignable<int&, int> ();
+    test_is_assignable<int&, double> ();
+    test_is_assignable<B, A> ();
+    test_is_assignable<void*&, void*> ();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_is_assignable<E, int> ();
+
+    test_is_not_assignable<int, int&> ();
+    test_is_not_assignable<int, int> ();
+#endif
+    test_is_not_assignable<A, B> ();
+    test_is_not_assignable<void, const void> ();
+    test_is_not_assignable<const void, const void> ();
+    test_is_not_assignable<int(), int> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
new file mode 100644
index 0000000..3285765
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_const
+
+#include <type_traits>
+
+template <class T>
+void test_is_const()
+{
+    static_assert(!std::is_const<T>::value, "");
+    static_assert( std::is_const<const T>::value, "");
+    static_assert(!std::is_const<volatile T>::value, "");
+    static_assert( std::is_const<const volatile T>::value, "");
+}
+
+int main()
+{
+    test_is_const<void>();
+    test_is_const<int>();
+    test_is_const<double>();
+    test_is_const<int*>();
+    test_is_const<const int*>();
+    test_is_const<char[3]>();
+    test_is_const<char[3]>();
+
+    static_assert(!std::is_const<int&>::value, "");
+    static_assert(!std::is_const<const int&>::value, "");
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
new file mode 100644
index 0000000..2b8f7ef
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// template <class T, class... Args>
+//   struct is_constructible;
+
+#include <type_traits>
+
+struct A
+{
+    explicit A(int);
+    A(int, double);
+#if __has_feature(cxx_access_control_sfinae) 
+private:
+#endif
+    A(char);
+};
+
+class Abstract
+{
+    virtual void foo() = 0;
+};
+
+class AbstractDestructor
+{
+    virtual ~AbstractDestructor() = 0;
+};
+
+template <class T>
+void test_is_constructible()
+{
+    static_assert( (std::is_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_constructible()
+{
+    static_assert( (std::is_constructible<T, A0>::value), "");
+}
+
+template <class T, class A0, class A1>
+void test_is_constructible()
+{
+    static_assert( (std::is_constructible<T, A0, A1>::value), "");
+}
+
+template <class T>
+void test_is_not_constructible()
+{
+    static_assert((!std::is_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_not_constructible()
+{
+    static_assert((!std::is_constructible<T, A0>::value), "");
+}
+
+int main()
+{
+    test_is_constructible<int> ();
+    test_is_constructible<int, const int> ();
+    test_is_constructible<A, int> ();
+    test_is_constructible<A, int, double> ();
+    test_is_constructible<int&, int&> ();
+
+    test_is_not_constructible<A> ();
+#if __has_feature(cxx_access_control_sfinae) 
+    test_is_not_constructible<A, char> ();
+#else
+    test_is_constructible<A, char> ();
+#endif
+    test_is_not_constructible<A, void> ();
+    test_is_not_constructible<void> ();
+    test_is_not_constructible<int&> ();
+    test_is_not_constructible<Abstract> ();
+    test_is_not_constructible<AbstractDestructor> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp
new file mode 100644
index 0000000..bde44de
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_copy_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_is_copy_assignable()
+{
+    static_assert(( std::is_copy_assignable<T>::value), "");
+}
+
+template <class T>
+void test_is_not_copy_assignable()
+{
+    static_assert((!std::is_copy_assignable<T>::value), "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    A();
+};
+
+class B
+{
+    B& operator=(const B&);
+};
+
+int main()
+{
+    test_is_copy_assignable<int> ();
+    test_is_copy_assignable<int&> ();
+    test_is_copy_assignable<A> ();
+    test_is_copy_assignable<bit_zero> ();
+    test_is_copy_assignable<Union> ();
+    test_is_copy_assignable<NotEmpty> ();
+    test_is_copy_assignable<Empty> ();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_is_not_copy_assignable<const int> ();
+    test_is_not_copy_assignable<int[]> ();
+    test_is_not_copy_assignable<int[3]> ();
+#endif
+#if __has_feature(cxx_access_control_sfinae) 
+    test_is_not_copy_assignable<B> ();
+#endif
+    test_is_not_copy_assignable<void> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp
new file mode 100644
index 0000000..837d0b0
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_copy_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_copy_constructible()
+{
+    static_assert( std::is_copy_constructible<T>::value, "");
+}
+
+template <class T>
+void test_is_not_copy_constructible()
+{
+    static_assert(!std::is_copy_constructible<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+public:
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A(const A&);
+};
+
+class B
+{
+    B(const B&);
+};
+
+int main()
+{
+    test_is_copy_constructible<A>();
+    test_is_copy_constructible<int&>();
+    test_is_copy_constructible<Union>();
+    test_is_copy_constructible<Empty>();
+    test_is_copy_constructible<int>();
+    test_is_copy_constructible<double>();
+    test_is_copy_constructible<int*>();
+    test_is_copy_constructible<const int*>();
+    test_is_copy_constructible<NotEmpty>();
+    test_is_copy_constructible<bit_zero>();
+
+    test_is_not_copy_constructible<char[3]>();
+    test_is_not_copy_constructible<char[]>();
+    test_is_not_copy_constructible<void>();
+    test_is_not_copy_constructible<Abstract>();
+#if __has_feature(cxx_access_control_sfinae) 
+    test_is_not_copy_constructible<B>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
new file mode 100644
index 0000000..379226a
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_default_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_default_constructible()
+{
+    static_assert( std::is_default_constructible<T>::value, "");
+    static_assert( std::is_default_constructible<const T>::value, "");
+    static_assert( std::is_default_constructible<volatile T>::value, "");
+    static_assert( std::is_default_constructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_default_constructible()
+{
+    static_assert(!std::is_default_constructible<T>::value, "");
+    static_assert(!std::is_default_constructible<const T>::value, "");
+    static_assert(!std::is_default_constructible<volatile T>::value, "");
+    static_assert(!std::is_default_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+public:
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A();
+};
+
+class B
+{
+    B();
+};
+
+int main()
+{
+    test_is_default_constructible<A>();
+    test_is_default_constructible<Union>();
+    test_is_default_constructible<Empty>();
+    test_is_default_constructible<int>();
+    test_is_default_constructible<double>();
+    test_is_default_constructible<int*>();
+    test_is_default_constructible<const int*>();
+    test_is_default_constructible<char[3]>();
+    test_is_default_constructible<NotEmpty>();
+    test_is_default_constructible<bit_zero>();
+
+    test_is_not_default_constructible<void>();
+    test_is_not_default_constructible<int&>();
+    test_is_not_default_constructible<char[]>();
+    test_is_not_default_constructible<Abstract>();
+#if __has_feature(cxx_access_control_sfinae) 
+    test_is_not_default_constructible<B>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp
new file mode 100644
index 0000000..807745e
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_destructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_destructible()
+{
+    static_assert( std::is_destructible<T>::value, "");
+    static_assert( std::is_destructible<const T>::value, "");
+    static_assert( std::is_destructible<volatile T>::value, "");
+    static_assert( std::is_destructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_destructible()
+{
+    static_assert(!std::is_destructible<T>::value, "");
+    static_assert(!std::is_destructible<const T>::value, "");
+    static_assert(!std::is_destructible<volatile T>::value, "");
+    static_assert(!std::is_destructible<const volatile T>::value, "");
+}
+
+class Empty {};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    ~A();
+};
+
+typedef void (Function) ();
+
+struct PublicAbstract                    { public:    virtual void foo() = 0; };
+struct ProtectedAbstract                 { protected: virtual void foo() = 0; };
+struct PrivateAbstract                   { private:   virtual void foo() = 0; };
+
+struct PublicDestructor                  { public:    ~PublicDestructor() {}};
+struct ProtectedDestructor               { protected: ~ProtectedDestructor() {}};
+struct PrivateDestructor                 { private:   ~PrivateDestructor() {}};
+
+struct VirtualPublicDestructor           { public:    virtual ~VirtualPublicDestructor() {}};
+struct VirtualProtectedDestructor        { protected: virtual ~VirtualProtectedDestructor() {}};
+struct VirtualPrivateDestructor          { private:   virtual ~VirtualPrivateDestructor() {}};
+
+struct PurePublicDestructor              { public:    virtual ~PurePublicDestructor() = 0; };
+struct PureProtectedDestructor           { protected: virtual ~PureProtectedDestructor() = 0; };
+struct PurePrivateDestructor             { private:   virtual ~PurePrivateDestructor() = 0; };
+
+struct DeletedPublicDestructor           { public:    ~DeletedPublicDestructor() = delete; };
+struct DeletedProtectedDestructor        { protected: ~DeletedProtectedDestructor() = delete; };
+struct DeletedPrivateDestructor          { private:   ~DeletedPrivateDestructor() = delete; };
+
+struct DeletedVirtualPublicDestructor    { public:    virtual ~DeletedVirtualPublicDestructor() = delete; };
+struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; };
+struct DeletedVirtualPrivateDestructor   { private:   virtual ~DeletedVirtualPrivateDestructor() = delete; };
+
+
+int main()
+{
+    test_is_destructible<A>();
+    test_is_destructible<int&>();
+    test_is_destructible<Union>();
+    test_is_destructible<Empty>();
+    test_is_destructible<int>();
+    test_is_destructible<double>();
+    test_is_destructible<int*>();
+    test_is_destructible<const int*>();
+    test_is_destructible<char[3]>();
+    test_is_destructible<bit_zero>();
+    test_is_destructible<int[3]>();
+    test_is_destructible<ProtectedAbstract>();
+    test_is_destructible<PublicAbstract>();
+    test_is_destructible<PrivateAbstract>();
+    test_is_destructible<PublicDestructor>();
+    test_is_destructible<VirtualPublicDestructor>();
+    test_is_destructible<PurePublicDestructor>();
+
+    test_is_not_destructible<int[]>();
+    test_is_not_destructible<void>();
+
+    test_is_not_destructible<ProtectedDestructor>();
+    test_is_not_destructible<PrivateDestructor>();
+    test_is_not_destructible<VirtualProtectedDestructor>();
+    test_is_not_destructible<VirtualPrivateDestructor>();
+    test_is_not_destructible<PureProtectedDestructor>();
+    test_is_not_destructible<PurePrivateDestructor>();
+    test_is_not_destructible<DeletedPublicDestructor>();
+    test_is_not_destructible<DeletedProtectedDestructor>();
+    test_is_not_destructible<DeletedPrivateDestructor>();
+
+//     test_is_not_destructible<DeletedVirtualPublicDestructor>(); // currently fails due to clang bug #20268
+    test_is_not_destructible<DeletedVirtualProtectedDestructor>();
+    test_is_not_destructible<DeletedVirtualPrivateDestructor>();
+
+#if __has_feature(cxx_access_control_sfinae) 
+    test_is_not_destructible<NotEmpty>();
+#endif
+    test_is_not_destructible<Function>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
new file mode 100644
index 0000000..584d2cc
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_empty
+
+#include <type_traits>
+
+template <class T>
+void test_is_empty()
+{
+    static_assert( std::is_empty<T>::value, "");
+    static_assert( std::is_empty<const T>::value, "");
+    static_assert( std::is_empty<volatile T>::value, "");
+    static_assert( std::is_empty<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_empty()
+{
+    static_assert(!std::is_empty<T>::value, "");
+    static_assert(!std::is_empty<const T>::value, "");
+    static_assert(!std::is_empty<volatile T>::value, "");
+    static_assert(!std::is_empty<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+int main()
+{
+    test_is_not_empty<void>();
+    test_is_not_empty<int&>();
+    test_is_not_empty<int>();
+    test_is_not_empty<double>();
+    test_is_not_empty<int*>();
+    test_is_not_empty<const int*>();
+    test_is_not_empty<char[3]>();
+    test_is_not_empty<char[3]>();
+    test_is_not_empty<Union>();
+    test_is_not_empty<NotEmpty>();
+
+    test_is_empty<Empty>();
+    test_is_empty<bit_zero>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
new file mode 100644
index 0000000..cf32196
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_final
+
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+struct P final { };
+union U1 { };
+union U2 final { };
+
+template <class T>
+void test_is_final()
+{
+    static_assert( std::is_final<T>::value, "");
+    static_assert( std::is_final<const T>::value, "");
+    static_assert( std::is_final<volatile T>::value, "");
+    static_assert( std::is_final<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_final()
+{
+    static_assert(!std::is_final<T>::value, "");
+    static_assert(!std::is_final<const T>::value, "");
+    static_assert(!std::is_final<volatile T>::value, "");
+    static_assert(!std::is_final<const volatile T>::value, "");
+}
+
+int main ()
+{
+    test_is_not_final<int>();
+    test_is_not_final<int*>();
+    test_is_final    <P>(); 
+    test_is_not_final<P*>();    
+    test_is_not_final<U1>();
+    test_is_not_final<U1*>();
+    test_is_final    <U2>();    
+    test_is_not_final<U2*>();   
+}
+#else
+int main () {}
+#endif
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
new file mode 100644
index 0000000..ce781cd
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_literal_type
+
+#include <type_traits>
+
+template <class T>
+void test_is_literal_type()
+{
+    static_assert( std::is_literal_type<T>::value, "");
+}
+
+template <class T>
+void test_is_not_literal_type()
+{
+    static_assert(!std::is_literal_type<T>::value, "");
+}
+
+struct A
+{
+};
+
+struct B
+{
+    B();
+};
+
+int main()
+{
+    test_is_literal_type<int> ();
+    test_is_literal_type<const int> ();
+    test_is_literal_type<int&> ();
+    test_is_literal_type<volatile int&> ();
+    test_is_literal_type<A> ();
+
+    test_is_not_literal_type<B> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
new file mode 100644
index 0000000..892ffd7
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_move_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_is_move_assignable()
+{
+    static_assert( std::is_move_assignable<T>::value, "");
+}
+
+template <class T>
+void test_is_not_move_assignable()
+{
+    static_assert(!std::is_move_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    A();
+};
+
+int main()
+{
+    test_is_move_assignable<int> ();
+    test_is_move_assignable<A> ();
+    test_is_move_assignable<bit_zero> ();
+    test_is_move_assignable<Union> ();
+    test_is_move_assignable<NotEmpty> ();
+    test_is_move_assignable<Empty> ();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_is_not_move_assignable<const int> ();
+    test_is_not_move_assignable<int[]> ();
+    test_is_not_move_assignable<int[3]> ();
+    test_is_not_move_assignable<int[3]> ();
+#endif
+    test_is_not_move_assignable<void> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp
new file mode 100644
index 0000000..7409eba
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_move_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_move_constructible()
+{
+    static_assert( std::is_move_constructible<T>::value, "");
+}
+
+template <class T>
+void test_is_not_move_constructible()
+{
+    static_assert(!std::is_move_constructible<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+public:
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A(const A&);
+};
+
+struct B
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    B(B&&);
+#endif
+};
+
+int main()
+{
+    test_is_not_move_constructible<char[3]>();
+    test_is_not_move_constructible<char[]>();
+    test_is_not_move_constructible<void>();
+    test_is_not_move_constructible<Abstract>();
+
+    test_is_move_constructible<A>();
+    test_is_move_constructible<int&>();
+    test_is_move_constructible<Union>();
+    test_is_move_constructible<Empty>();
+    test_is_move_constructible<int>();
+    test_is_move_constructible<double>();
+    test_is_move_constructible<int*>();
+    test_is_move_constructible<const int*>();
+    test_is_move_constructible<NotEmpty>();
+    test_is_move_constructible<bit_zero>();
+    test_is_move_constructible<B>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp
new file mode 100644
index 0000000..3bd2b3b
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_assignable
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_nothrow_assignable()
+{
+    static_assert(( std::is_nothrow_assignable<T, U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_nothrow_assignable()
+{
+    static_assert((!std::is_nothrow_assignable<T, U>::value), "");
+}
+
+struct A
+{
+};
+
+struct B
+{
+    void operator=(A);
+};
+
+int main()
+{
+    test_is_nothrow_assignable<int&, int&> ();
+    test_is_nothrow_assignable<int&, int> ();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test_is_nothrow_assignable<int&, double> ();
+#endif
+
+    test_is_not_nothrow_assignable<int, int&> ();
+    test_is_not_nothrow_assignable<int, int> ();
+    test_is_not_nothrow_assignable<B, A> ();
+    test_is_not_nothrow_assignable<A, B> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
new file mode 100644
index 0000000..8978ec9
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// template <class T, class... Args>
+//   struct is_nothrow_constructible;
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_constructible()
+{
+    static_assert(( std::is_nothrow_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_nothrow_constructible()
+{
+    static_assert(( std::is_nothrow_constructible<T, A0>::value), "");
+}
+
+template <class T>
+void test_is_not_nothrow_constructible()
+{
+    static_assert((!std::is_nothrow_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_not_nothrow_constructible()
+{
+    static_assert((!std::is_nothrow_constructible<T, A0>::value), "");
+}
+
+template <class T, class A0, class A1>
+void test_is_not_nothrow_constructible()
+{
+    static_assert((!std::is_nothrow_constructible<T, A0, A1>::value), "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A(const A&);
+};
+
+int main()
+{
+    test_is_nothrow_constructible<int> ();
+    test_is_nothrow_constructible<int, const int&> ();
+    test_is_nothrow_constructible<Empty> ();
+    test_is_nothrow_constructible<Empty, const Empty&> ();
+
+    test_is_not_nothrow_constructible<A, int> ();
+    test_is_not_nothrow_constructible<A, int, double> ();
+    test_is_not_nothrow_constructible<A> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp
new file mode 100644
index 0000000..d843803
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_copy_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_has_nothrow_assign()
+{
+    static_assert( std::is_nothrow_copy_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_assign()
+{
+    static_assert(!std::is_nothrow_copy_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+struct NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    A& operator=(const A&);
+};
+
+int main()
+{
+    test_has_nothrow_assign<int&>();
+    test_has_nothrow_assign<Union>();
+    test_has_nothrow_assign<Empty>();
+    test_has_nothrow_assign<int>();
+    test_has_nothrow_assign<double>();
+    test_has_nothrow_assign<int*>();
+    test_has_nothrow_assign<const int*>();
+    test_has_nothrow_assign<NotEmpty>();
+    test_has_nothrow_assign<bit_zero>();
+
+    test_has_not_nothrow_assign<const int>();
+    test_has_not_nothrow_assign<void>();
+    test_has_not_nothrow_assign<A>();
+
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp
new file mode 100644
index 0000000..99fce65
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_copy_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_copy_constructible()
+{
+    static_assert( std::is_nothrow_copy_constructible<T>::value, "");
+    static_assert( std::is_nothrow_copy_constructible<const T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_copy_constructor()
+{
+    static_assert(!std::is_nothrow_copy_constructible<T>::value, "");
+    static_assert(!std::is_nothrow_copy_constructible<const T>::value, "");
+    static_assert(!std::is_nothrow_copy_constructible<volatile T>::value, "");
+    static_assert(!std::is_nothrow_copy_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    A(const A&);
+};
+
+int main()
+{
+    test_has_not_nothrow_copy_constructor<void>();
+    test_has_not_nothrow_copy_constructor<A>();
+
+    test_is_nothrow_copy_constructible<int&>();
+    test_is_nothrow_copy_constructible<Union>();
+    test_is_nothrow_copy_constructible<Empty>();
+    test_is_nothrow_copy_constructible<int>();
+    test_is_nothrow_copy_constructible<double>();
+    test_is_nothrow_copy_constructible<int*>();
+    test_is_nothrow_copy_constructible<const int*>();
+    test_is_nothrow_copy_constructible<bit_zero>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp
new file mode 100644
index 0000000..1550dff
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_default_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_default_constructible()
+{
+    static_assert( std::is_nothrow_default_constructible<T>::value, "");
+    static_assert( std::is_nothrow_default_constructible<const T>::value, "");
+    static_assert( std::is_nothrow_default_constructible<volatile T>::value, "");
+    static_assert( std::is_nothrow_default_constructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_default_constructor()
+{
+    static_assert(!std::is_nothrow_default_constructible<T>::value, "");
+    static_assert(!std::is_nothrow_default_constructible<const T>::value, "");
+    static_assert(!std::is_nothrow_default_constructible<volatile T>::value, "");
+    static_assert(!std::is_nothrow_default_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    A();
+};
+
+int main()
+{
+    test_has_not_nothrow_default_constructor<void>();
+    test_has_not_nothrow_default_constructor<int&>();
+    test_has_not_nothrow_default_constructor<A>();
+
+    test_is_nothrow_default_constructible<Union>();
+    test_is_nothrow_default_constructible<Empty>();
+    test_is_nothrow_default_constructible<int>();
+    test_is_nothrow_default_constructible<double>();
+    test_is_nothrow_default_constructible<int*>();
+    test_is_nothrow_default_constructible<const int*>();
+    test_is_nothrow_default_constructible<char[3]>();
+    test_is_nothrow_default_constructible<bit_zero>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
new file mode 100644
index 0000000..7871732
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_nothrow_destructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_destructible()
+{
+    static_assert( std::is_nothrow_destructible<T>::value, "");
+    static_assert( std::is_nothrow_destructible<const T>::value, "");
+    static_assert( std::is_nothrow_destructible<volatile T>::value, "");
+    static_assert( std::is_nothrow_destructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_destructor()
+{
+    static_assert(!std::is_nothrow_destructible<T>::value, "");
+    static_assert(!std::is_nothrow_destructible<const T>::value, "");
+    static_assert(!std::is_nothrow_destructible<volatile T>::value, "");
+    static_assert(!std::is_nothrow_destructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual void foo() = 0;
+};
+
+class AbstractDestructor
+{
+    virtual ~AbstractDestructor() = 0;
+};
+
+struct A
+{
+    ~A();
+};
+
+int main()
+{
+    test_has_not_nothrow_destructor<void>();
+    test_has_not_nothrow_destructor<AbstractDestructor>();
+    test_has_not_nothrow_destructor<NotEmpty>();
+
+#if __has_feature(cxx_noexcept)
+    test_is_nothrow_destructible<A>();
+#endif
+    test_is_nothrow_destructible<int&>();
+#if  __has_feature(cxx_unrestricted_unions) 
+    test_is_nothrow_destructible<Union>();
+#endif
+#if __has_feature(cxx_access_control_sfinae)
+    test_is_nothrow_destructible<Empty>();
+#endif
+    test_is_nothrow_destructible<int>();
+    test_is_nothrow_destructible<double>();
+    test_is_nothrow_destructible<int*>();
+    test_is_nothrow_destructible<const int*>();
+    test_is_nothrow_destructible<char[3]>();
+    test_is_nothrow_destructible<char[3]>();
+    test_is_nothrow_destructible<Abstract>();
+#if __has_feature(cxx_noexcept)
+    test_is_nothrow_destructible<bit_zero>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp
new file mode 100644
index 0000000..fe51e43
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_nothrow_move_assign
+
+#include <type_traits>
+
+template <class T>
+void test_has_nothrow_assign()
+{
+    static_assert( std::is_nothrow_move_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_assign()
+{
+    static_assert(!std::is_nothrow_move_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+struct NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    A& operator=(const A&);
+};
+
+int main()
+{
+    test_has_nothrow_assign<int&>();
+    test_has_nothrow_assign<Union>();
+    test_has_nothrow_assign<Empty>();
+    test_has_nothrow_assign<int>();
+    test_has_nothrow_assign<double>();
+    test_has_nothrow_assign<int*>();
+    test_has_nothrow_assign<const int*>();
+    test_has_nothrow_assign<NotEmpty>();
+    test_has_nothrow_assign<bit_zero>();
+
+    test_has_not_nothrow_assign<void>();
+    test_has_not_nothrow_assign<A>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp
new file mode 100644
index 0000000..f5a42af
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// has_nothrow_move_constructor
+
+#include <type_traits>
+
+template <class T>
+void test_is_nothrow_move_constructible()
+{
+    static_assert( std::is_nothrow_move_constructible<T>::value, "");
+    static_assert( std::is_nothrow_move_constructible<const T>::value, "");
+}
+
+template <class T>
+void test_has_not_nothrow_move_constructor()
+{
+    static_assert(!std::is_nothrow_move_constructible<T>::value, "");
+    static_assert(!std::is_nothrow_move_constructible<const T>::value, "");
+    static_assert(!std::is_nothrow_move_constructible<volatile T>::value, "");
+    static_assert(!std::is_nothrow_move_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+struct A
+{
+    A(const A&);
+};
+
+int main()
+{
+    test_has_not_nothrow_move_constructor<void>();
+    test_has_not_nothrow_move_constructor<A>();
+
+    test_is_nothrow_move_constructible<int&>();
+    test_is_nothrow_move_constructible<Union>();
+    test_is_nothrow_move_constructible<Empty>();
+    test_is_nothrow_move_constructible<int>();
+    test_is_nothrow_move_constructible<double>();
+    test_is_nothrow_move_constructible<int*>();
+    test_is_nothrow_move_constructible<const int*>();
+    test_is_nothrow_move_constructible<bit_zero>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
new file mode 100644
index 0000000..a97685c
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_pod
+
+#include <type_traits>
+
+template <class T>
+void test_is_pod()
+{
+    static_assert( std::is_pod<T>::value, "");
+    static_assert( std::is_pod<const T>::value, "");
+    static_assert( std::is_pod<volatile T>::value, "");
+    static_assert( std::is_pod<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_pod()
+{
+    static_assert(!std::is_pod<T>::value, "");
+    static_assert(!std::is_pod<const T>::value, "");
+    static_assert(!std::is_pod<volatile T>::value, "");
+    static_assert(!std::is_pod<const volatile T>::value, "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    test_is_not_pod<void>();
+    test_is_not_pod<int&>();
+    test_is_not_pod<Class>();
+
+    test_is_pod<int>();
+    test_is_pod<double>();
+    test_is_pod<int*>();
+    test_is_pod<const int*>();
+    test_is_pod<char[3]>();
+    test_is_pod<char[3]>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
new file mode 100644
index 0000000..8f5547e
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_polymorphic
+
+#include <type_traits>
+
+template <class T>
+void test_is_polymorphic()
+{
+    static_assert( std::is_polymorphic<T>::value, "");
+    static_assert( std::is_polymorphic<const T>::value, "");
+    static_assert( std::is_polymorphic<volatile T>::value, "");
+    static_assert( std::is_polymorphic<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_polymorphic()
+{
+    static_assert(!std::is_polymorphic<T>::value, "");
+    static_assert(!std::is_polymorphic<const T>::value, "");
+    static_assert(!std::is_polymorphic<volatile T>::value, "");
+    static_assert(!std::is_polymorphic<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual ~Abstract() = 0;
+};
+
+#if __has_feature(cxx_attributes) 
+class Final final {
+};
+#else
+class Final {
+};
+#endif
+
+int main()
+{
+    test_is_not_polymorphic<void>();
+    test_is_not_polymorphic<int&>();
+    test_is_not_polymorphic<int>();
+    test_is_not_polymorphic<double>();
+    test_is_not_polymorphic<int*>();
+    test_is_not_polymorphic<const int*>();
+    test_is_not_polymorphic<char[3]>();
+    test_is_not_polymorphic<char[3]>();
+    test_is_not_polymorphic<Union>();
+    test_is_not_polymorphic<Empty>();
+    test_is_not_polymorphic<bit_zero>();
+    test_is_not_polymorphic<Final>();
+    test_is_not_polymorphic<NotEmpty&>();
+    test_is_not_polymorphic<Abstract&>();
+
+    test_is_polymorphic<NotEmpty>();
+    test_is_polymorphic<Abstract>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
new file mode 100644
index 0000000..7de6566
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_signed
+
+#include <type_traits>
+
+template <class T>
+void test_is_signed()
+{
+    static_assert( std::is_signed<T>::value, "");
+    static_assert( std::is_signed<const T>::value, "");
+    static_assert( std::is_signed<volatile T>::value, "");
+    static_assert( std::is_signed<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_signed()
+{
+    static_assert(!std::is_signed<T>::value, "");
+    static_assert(!std::is_signed<const T>::value, "");
+    static_assert(!std::is_signed<volatile T>::value, "");
+    static_assert(!std::is_signed<const volatile T>::value, "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    test_is_not_signed<void>();
+    test_is_not_signed<int&>();
+    test_is_not_signed<Class>();
+    test_is_not_signed<int*>();
+    test_is_not_signed<const int*>();
+    test_is_not_signed<char[3]>();
+    test_is_not_signed<char[3]>();
+    test_is_not_signed<bool>();
+    test_is_not_signed<unsigned>();
+
+    test_is_signed<int>();
+    test_is_signed<double>();
+
+#ifndef _LIBCPP_HAS_NO_INT128
+    test_is_signed<__int128_t>();
+    test_is_not_signed<__uint128_t>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
new file mode 100644
index 0000000..668c4cd
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_standard_layout
+
+#include <type_traits>
+
+template <class T>
+void test_is_standard_layout()
+{
+    static_assert( std::is_standard_layout<T>::value, "");
+    static_assert( std::is_standard_layout<const T>::value, "");
+    static_assert( std::is_standard_layout<volatile T>::value, "");
+    static_assert( std::is_standard_layout<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_standard_layout()
+{
+    static_assert(!std::is_standard_layout<T>::value, "");
+    static_assert(!std::is_standard_layout<const T>::value, "");
+    static_assert(!std::is_standard_layout<volatile T>::value, "");
+    static_assert(!std::is_standard_layout<const volatile T>::value, "");
+}
+
+template <class T1, class T2>
+struct pair
+{
+    T1 first;
+    T2 second;
+};
+
+int main()
+{
+    test_is_standard_layout<int> ();
+    test_is_standard_layout<int[3]> ();
+    test_is_standard_layout<pair<int, double> > ();
+
+    test_is_not_standard_layout<int&> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
new file mode 100644
index 0000000..af38699
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivial
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivial()
+{
+    static_assert( std::is_trivial<T>::value, "");
+    static_assert( std::is_trivial<const T>::value, "");
+    static_assert( std::is_trivial<volatile T>::value, "");
+    static_assert( std::is_trivial<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_trivial()
+{
+    static_assert(!std::is_trivial<T>::value, "");
+    static_assert(!std::is_trivial<const T>::value, "");
+    static_assert(!std::is_trivial<volatile T>::value, "");
+    static_assert(!std::is_trivial<const volatile T>::value, "");
+}
+
+struct A {};
+
+class B
+{
+public:
+    B();
+};
+
+int main()
+{
+    test_is_trivial<int> ();
+    test_is_trivial<A> ();
+
+    test_is_not_trivial<int&> ();
+    test_is_not_trivial<volatile int&> ();
+    test_is_not_trivial<B> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
new file mode 100644
index 0000000..d658823
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivialially_copyable.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_copyable
+
+#include <type_traits>
+#include <cassert>
+
+template <class T>
+void test_is_trivially_copyable()
+{
+    static_assert( std::is_trivially_copyable<T>::value, "");
+    static_assert( std::is_trivially_copyable<const T>::value, "");
+    static_assert(!std::is_trivially_copyable<volatile T>::value, "");
+    static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_trivially_copyable()
+{
+    static_assert(!std::is_trivially_copyable<T>::value, "");
+    static_assert(!std::is_trivially_copyable<const T>::value, "");
+    static_assert(!std::is_trivially_copyable<volatile T>::value, "");
+    static_assert(!std::is_trivially_copyable<const volatile T>::value, "");
+}
+
+struct A
+{
+    int i_;
+};
+
+struct B
+{
+    int i_;
+    ~B() {assert(i_ == 0);}
+};
+
+class C
+{
+public:
+    C();
+};
+
+int main()
+{
+    test_is_trivially_copyable<int> ();
+    test_is_trivially_copyable<const int> ();
+    test_is_trivially_copyable<A> ();
+    test_is_trivially_copyable<const A> ();
+    test_is_trivially_copyable<C> ();
+
+    test_is_not_trivially_copyable<int&> ();
+    test_is_not_trivially_copyable<const A&> ();
+    test_is_not_trivially_copyable<B> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp
new file mode 100644
index 0000000..984824a
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_assignable
+
+#include <type_traits>
+
+template <class T, class U>
+void test_is_trivially_assignable()
+{
+    static_assert(( std::is_trivially_assignable<T, U>::value), "");
+}
+
+template <class T, class U>
+void test_is_not_trivially_assignable()
+{
+    static_assert((!std::is_trivially_assignable<T, U>::value), "");
+}
+
+struct A
+{
+};
+
+struct B
+{
+    void operator=(A);
+};
+
+int main()
+{
+    test_is_trivially_assignable<int&, int&> ();
+    test_is_trivially_assignable<int&, int> ();
+    test_is_trivially_assignable<int&, double> ();
+
+    test_is_not_trivially_assignable<int, int&> ();
+    test_is_not_trivially_assignable<int, int> ();
+    test_is_not_trivially_assignable<B, A> ();
+    test_is_not_trivially_assignable<A, B> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp
new file mode 100644
index 0000000..4171d4d
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// template <class T, class... Args>
+//   struct is_trivially_constructible;
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_constructible()
+{
+    static_assert(( std::is_trivially_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_trivially_constructible()
+{
+    static_assert(( std::is_trivially_constructible<T, A0>::value), "");
+}
+
+template <class T>
+void test_is_not_trivially_constructible()
+{
+    static_assert((!std::is_trivially_constructible<T>::value), "");
+}
+
+template <class T, class A0>
+void test_is_not_trivially_constructible()
+{
+    static_assert((!std::is_trivially_constructible<T, A0>::value), "");
+}
+
+template <class T, class A0, class A1>
+void test_is_not_trivially_constructible()
+{
+    static_assert((!std::is_trivially_constructible<T, A0, A1>::value), "");
+}
+
+struct A
+{
+    explicit A(int);
+    A(int, double);
+};
+
+int main()
+{
+    test_is_trivially_constructible<int> ();
+    test_is_trivially_constructible<int, const int&> ();
+
+    test_is_not_trivially_constructible<A, int> ();
+    test_is_not_trivially_constructible<A, int, double> ();
+    test_is_not_trivially_constructible<A> ();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp
new file mode 100644
index 0000000..7d72565
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_copy_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_has_trivially_copy_assignable()
+{
+    static_assert( std::is_trivially_copy_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivially_copy_assignable()
+{
+    static_assert(!std::is_trivially_copy_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A& operator=(const A&);
+};
+
+int main()
+{
+    test_has_trivially_copy_assignable<int&>();
+    test_has_trivially_copy_assignable<Union>();
+    test_has_trivially_copy_assignable<Empty>();
+    test_has_trivially_copy_assignable<int>();
+    test_has_trivially_copy_assignable<double>();
+    test_has_trivially_copy_assignable<int*>();
+    test_has_trivially_copy_assignable<const int*>();
+    test_has_trivially_copy_assignable<bit_zero>();
+
+    test_has_not_trivially_copy_assignable<void>();
+    test_has_not_trivially_copy_assignable<A>();
+    test_has_not_trivially_copy_assignable<NotEmpty>();
+    test_has_not_trivially_copy_assignable<Abstract>();
+    test_has_not_trivially_copy_assignable<const Empty>();
+
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
new file mode 100644
index 0000000..6bd78ec
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_copy_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_copy_constructible()
+{
+    static_assert( std::is_trivially_copy_constructible<T>::value, "");
+    static_assert( std::is_trivially_copy_constructible<const T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_copy_constructor()
+{
+    static_assert(!std::is_trivially_copy_constructible<T>::value, "");
+    static_assert(!std::is_trivially_copy_constructible<const T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+public:
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A(const A&);
+};
+
+int main()
+{
+    test_has_not_trivial_copy_constructor<void>();
+    test_has_not_trivial_copy_constructor<A>();
+    test_has_not_trivial_copy_constructor<Abstract>();
+    test_has_not_trivial_copy_constructor<NotEmpty>();
+
+    test_is_trivially_copy_constructible<int&>();
+    test_is_trivially_copy_constructible<Union>();
+    test_is_trivially_copy_constructible<Empty>();
+    test_is_trivially_copy_constructible<int>();
+    test_is_trivially_copy_constructible<double>();
+    test_is_trivially_copy_constructible<int*>();
+    test_is_trivially_copy_constructible<const int*>();
+    test_is_trivially_copy_constructible<bit_zero>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp
new file mode 100644
index 0000000..1f63401
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_default_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_default_constructible()
+{
+    static_assert( std::is_trivially_default_constructible<T>::value, "");
+    static_assert( std::is_trivially_default_constructible<const T>::value, "");
+    static_assert( std::is_trivially_default_constructible<volatile T>::value, "");
+    static_assert( std::is_trivially_default_constructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_default_constructor()
+{
+    static_assert(!std::is_trivially_default_constructible<T>::value, "");
+    static_assert(!std::is_trivially_default_constructible<const T>::value, "");
+    static_assert(!std::is_trivially_default_constructible<volatile T>::value, "");
+    static_assert(!std::is_trivially_default_constructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A();
+};
+
+int main()
+{
+    test_has_not_trivial_default_constructor<void>();
+    test_has_not_trivial_default_constructor<int&>();
+    test_has_not_trivial_default_constructor<A>();
+    test_has_not_trivial_default_constructor<Abstract>();
+    test_has_not_trivial_default_constructor<NotEmpty>();
+
+    test_is_trivially_default_constructible<Union>();
+    test_is_trivially_default_constructible<Empty>();
+    test_is_trivially_default_constructible<int>();
+    test_is_trivially_default_constructible<double>();
+    test_is_trivially_default_constructible<int*>();
+    test_is_trivially_default_constructible<const int*>();
+    test_is_trivially_default_constructible<char[3]>();
+    test_is_trivially_default_constructible<bit_zero>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
new file mode 100644
index 0000000..1b34885
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_destructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_destructible()
+{
+    static_assert( std::is_trivially_destructible<T>::value, "");
+    static_assert( std::is_trivially_destructible<const T>::value, "");
+    static_assert( std::is_trivially_destructible<volatile T>::value, "");
+    static_assert( std::is_trivially_destructible<const volatile T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_destructor()
+{
+    static_assert(!std::is_trivially_destructible<T>::value, "");
+    static_assert(!std::is_trivially_destructible<const T>::value, "");
+    static_assert(!std::is_trivially_destructible<volatile T>::value, "");
+    static_assert(!std::is_trivially_destructible<const volatile T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual void foo() = 0;
+};
+
+class AbstractDestructor
+{
+    virtual ~AbstractDestructor() = 0;
+};
+
+struct A
+{
+    ~A();
+};
+
+int main()
+{
+    test_has_not_trivial_destructor<void>();
+    test_has_not_trivial_destructor<A>();
+    test_has_not_trivial_destructor<AbstractDestructor>();
+    test_has_not_trivial_destructor<NotEmpty>();
+
+    test_is_trivially_destructible<Abstract>();
+    test_is_trivially_destructible<int&>();
+    test_is_trivially_destructible<Union>();
+    test_is_trivially_destructible<Empty>();
+    test_is_trivially_destructible<int>();
+    test_is_trivially_destructible<double>();
+    test_is_trivially_destructible<int*>();
+    test_is_trivially_destructible<const int*>();
+    test_is_trivially_destructible<char[3]>();
+    test_is_trivially_destructible<char[3]>();
+    test_is_trivially_destructible<bit_zero>();
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp
new file mode 100644
index 0000000..c3fc7ac
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_move_assignable
+
+#include <type_traits>
+
+template <class T>
+void test_has_trivial_assign()
+{
+    static_assert( std::is_trivially_move_assignable<T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_assign()
+{
+    static_assert(!std::is_trivially_move_assignable<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A& operator=(const A&);
+};
+
+int main()
+{
+    test_has_trivial_assign<int&>();
+    test_has_trivial_assign<Union>();
+    test_has_trivial_assign<Empty>();
+    test_has_trivial_assign<int>();
+    test_has_trivial_assign<double>();
+    test_has_trivial_assign<int*>();
+    test_has_trivial_assign<const int*>();
+    test_has_trivial_assign<bit_zero>();
+
+    test_has_not_trivial_assign<void>();
+    test_has_not_trivial_assign<A>();
+    test_has_not_trivial_assign<NotEmpty>();
+    test_has_not_trivial_assign<Abstract>();
+    test_has_not_trivial_assign<const Empty>();
+
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
new file mode 100644
index 0000000..54cb5e8
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_trivially_move_constructible
+
+#include <type_traits>
+
+template <class T>
+void test_is_trivially_move_constructible()
+{
+    static_assert( std::is_trivially_move_constructible<T>::value, "");
+}
+
+template <class T>
+void test_has_not_trivial_move_constructor()
+{
+    static_assert(!std::is_trivially_move_constructible<T>::value, "");
+}
+
+class Empty
+{
+};
+
+class NotEmpty
+{
+public:
+    virtual ~NotEmpty();
+};
+
+union Union {};
+
+struct bit_zero
+{
+    int :  0;
+};
+
+class Abstract
+{
+public:
+    virtual ~Abstract() = 0;
+};
+
+struct A
+{
+    A(const A&);
+};
+
+#if __has_feature(cxx_defaulted_functions)
+
+struct MoveOnly1
+{
+    MoveOnly1(MoveOnly1&&);
+};
+
+struct MoveOnly2
+{
+    MoveOnly2(MoveOnly2&&) = default;
+};
+
+#endif
+
+int main()
+{
+    test_has_not_trivial_move_constructor<void>();
+    test_has_not_trivial_move_constructor<A>();
+    test_has_not_trivial_move_constructor<Abstract>();
+    test_has_not_trivial_move_constructor<NotEmpty>();
+
+    test_is_trivially_move_constructible<Union>();
+    test_is_trivially_move_constructible<Empty>();
+    test_is_trivially_move_constructible<int>();
+    test_is_trivially_move_constructible<double>();
+    test_is_trivially_move_constructible<int*>();
+    test_is_trivially_move_constructible<const int*>();
+    test_is_trivially_move_constructible<bit_zero>();
+
+#if __has_feature(cxx_defaulted_functions)
+    static_assert(!std::is_trivially_move_constructible<MoveOnly1>::value, "");
+    static_assert( std::is_trivially_move_constructible<MoveOnly2>::value, "");
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
new file mode 100644
index 0000000..2cd4945
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_unsigned
+
+#include <type_traits>
+
+template <class T>
+void test_is_unsigned()
+{
+    static_assert( std::is_unsigned<T>::value, "");
+    static_assert( std::is_unsigned<const T>::value, "");
+    static_assert( std::is_unsigned<volatile T>::value, "");
+    static_assert( std::is_unsigned<const volatile T>::value, "");
+}
+
+template <class T>
+void test_is_not_unsigned()
+{
+    static_assert(!std::is_unsigned<T>::value, "");
+    static_assert(!std::is_unsigned<const T>::value, "");
+    static_assert(!std::is_unsigned<volatile T>::value, "");
+    static_assert(!std::is_unsigned<const volatile T>::value, "");
+}
+
+class Class
+{
+public:
+    ~Class();
+};
+
+int main()
+{
+    test_is_not_unsigned<void>();
+    test_is_not_unsigned<int&>();
+    test_is_not_unsigned<Class>();
+    test_is_not_unsigned<int*>();
+    test_is_not_unsigned<const int*>();
+    test_is_not_unsigned<char[3]>();
+    test_is_not_unsigned<char[3]>();
+    test_is_not_unsigned<int>();
+    test_is_not_unsigned<double>();
+
+    test_is_unsigned<bool>();
+    test_is_unsigned<unsigned>();
+
+#ifndef _LIBCPP_HAS_NO_INT128
+    test_is_unsigned<__uint128_t>();
+    test_is_not_unsigned<__int128_t>();
+#endif
+}
diff --git a/final/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
new file mode 100644
index 0000000..8e1fca4
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// type_traits
+
+// is_volatile
+
+#include <type_traits>
+
+template <class T>
+void test_is_volatile()
+{
+    static_assert(!std::is_volatile<T>::value, "");
+    static_assert(!std::is_volatile<const T>::value, "");
+    static_assert( std::is_volatile<volatile T>::value, "");
+    static_assert( std::is_volatile<const volatile T>::value, "");
+}
+
+int main()
+{
+    test_is_volatile<void>();
+    test_is_volatile<int>();
+    test_is_volatile<double>();
+    test_is_volatile<int*>();
+    test_is_volatile<const int*>();
+    test_is_volatile<char[3]>();
+    test_is_volatile<char[3]>();
+
+    static_assert(!std::is_volatile<int&>::value, "");
+    static_assert(!std::is_volatile<volatile int&>::value, "");
+}
diff --git a/final/test/utilities/meta/meta.unary/nothing_to_do.pass.cpp b/final/test/utilities/meta/meta.unary/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/meta/meta.unary/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/meta/version.pass.cpp b/final/test/utilities/meta/version.pass.cpp
new file mode 100644
index 0000000..3a1033b
--- /dev/null
+++ b/final/test/utilities/meta/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <type_traits>
+
+#include <type_traits>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/nothing_to_do.pass.cpp b/final/test/utilities/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp b/final/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp
new file mode 100644
index 0000000..eacf34c
--- /dev/null
+++ b/final/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access;
+// explicit bad_optional_access(const char* what_arg);
+
+#include <experimental/optional>
+#include <string>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::bad_optional_access;
+
+    const char* s = "message";
+    bad_optional_access e(s);
+    assert(std::strcmp(e.what(), s) == 0);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp b/final/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp
new file mode 100644
index 0000000..bb78ca4
--- /dev/null
+++ b/final/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access;
+// bad_optional_access& operator=(const bad_optional_access&);
+
+#include <experimental/optional>
+#include <string>
+#include <cstring>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::bad_optional_access;
+
+    static_assert(std::is_nothrow_copy_assignable<bad_optional_access>::value, "");
+    const std::string s1("one message");
+    const std::string s2("another message");
+    bad_optional_access e1(s1);
+    bad_optional_access e2(s2);
+    assert(std::strcmp(e1.what(), e2.what()) != 0);
+    e1 = e2;
+    assert(std::strcmp(e1.what(), e2.what()) == 0);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp b/final/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp
new file mode 100644
index 0000000..30ef533
--- /dev/null
+++ b/final/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access;
+// bad_optional_access(const bad_optional_access&);
+
+#include <experimental/optional>
+#include <string>
+#include <cstring>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::bad_optional_access;
+
+    static_assert(std::is_nothrow_copy_constructible<bad_optional_access>::value, "");
+    const std::string s("another message");
+    bad_optional_access e1(s);
+    bad_optional_access e2 = e1;
+    assert(std::strcmp(e1.what(), e2.what()) == 0);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.bad_optional_access/default.pass.cpp b/final/test/utilities/optional/optional.bad_optional_access/default.pass.cpp
new file mode 100644
index 0000000..606be40
--- /dev/null
+++ b/final/test/utilities/optional/optional.bad_optional_access/default.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access is not default constructible
+
+#include <experimental/optional>
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::bad_optional_access;
+
+    static_assert(!std::is_default_constructible<bad_optional_access>::value, "");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp b/final/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp
new file mode 100644
index 0000000..c13d660
--- /dev/null
+++ b/final/test/utilities/optional/optional.bad_optional_access/derive.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access : public logic_error 
+
+#include <experimental/optional>
+#include <type_traits>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::bad_optional_access;
+
+    static_assert(std::is_base_of<std::logic_error, bad_optional_access>::value, "");
+    static_assert(std::is_convertible<bad_optional_access*, std::logic_error*>::value, "");
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.bad_optional_access/string.pass.cpp b/final/test/utilities/optional/optional.bad_optional_access/string.pass.cpp
new file mode 100644
index 0000000..d0b3fb5
--- /dev/null
+++ b/final/test/utilities/optional/optional.bad_optional_access/string.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// class bad_optional_access;
+// explicit bad_optional_access(const string& what_arg);
+
+#include <experimental/optional>
+#include <string>
+#include <cstring>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::bad_optional_access;
+
+    const std::string s("message");
+    bad_optional_access e(s);
+    assert(std::strcmp(e.what(), s.c_str()) == 0);
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.comp_with_t/equal.pass.cpp b/final/test/utilities/optional/optional.comp_with_t/equal.pass.cpp
new file mode 100644
index 0000000..2380739
--- /dev/null
+++ b/final/test/utilities/optional/optional.comp_with_t/equal.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator==(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator==(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+    { return lhs.i_ == rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef X T;
+    typedef optional<T> O;
+    
+    constexpr T val(2);
+    constexpr O o1;     // disengaged
+    constexpr O o2{1};  // engaged
+    constexpr O o3{val};  // engaged
+
+    static_assert ( !(o1 == T(1)), "" );
+    static_assert (   o2 == T(1),  "" );
+    static_assert ( !(o3 == T(1)), "" );
+    static_assert (   o3 == T(2) , "" );
+    static_assert (   o3 == val, "" );
+        
+    static_assert ( !(T(1) == o1), "" );
+    static_assert (   T(1) == o2,  "" );
+    static_assert ( !(T(1) == o3), "" );
+    static_assert (   T(2) == o3 , "" );
+    static_assert ( val == o3 , "" );
+    }
+#endif
+}
diff --git a/final/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp b/final/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp
new file mode 100644
index 0000000..8085376
--- /dev/null
+++ b/final/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator<(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator<(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    {
+    typedef X T;
+    typedef optional<T> O;
+    
+    constexpr T val(2);
+    constexpr O o1;     // disengaged
+    constexpr O o2{1};  // engaged
+    constexpr O o3{val};  // engaged
+
+    static_assert (   o1 < T(1) , "" );
+    static_assert ( !(o2 < T(1)), "" );
+    static_assert ( !(o3 < T(1)), "" );
+    static_assert (   o2 < T(2) , "" );
+    static_assert (   o2 < T(val), "" );
+    static_assert (   o3 < T(3) , "" );
+
+    static_assert (  !(T(1) < o1), "" );
+    static_assert (  !(T(1) < o2), "" );
+    static_assert (    T(1) < o3 , "" );
+    static_assert (  !(T(2) < o2), "" );
+    static_assert (!(T(val) < o2), "" );
+    static_assert (  !(T(3) < o3), "" );
+    }
+#endif
+}
diff --git a/final/test/utilities/optional/optional.defs/tested_elsewhere.pass.cpp b/final/test/utilities/optional/optional.defs/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/optional/optional.defs/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/optional/optional.general/nothing_to_do.pass.cpp b/final/test/utilities/optional/optional.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/optional/optional.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/optional/optional.hash/hash.pass.cpp b/final/test/utilities/optional/optional.hash/hash.pass.cpp
new file mode 100644
index 0000000..ca23d78
--- /dev/null
+++ b/final/test/utilities/optional/optional.hash/hash.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> struct hash<optional<T>>;
+
+#include <experimental/optional>
+#include <string>
+#include <memory>
+#include <cassert>
+
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+	using std::experimental::optional;
+
+    {
+        typedef int T;
+        optional<T> opt;
+        assert(std::hash<optional<T>>{}(opt) == 0);
+        opt = 2;
+        assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
+    }
+    {
+        typedef std::string T;
+        optional<T> opt;
+        assert(std::hash<optional<T>>{}(opt) == 0);
+        opt = std::string("123");
+        assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
+    }
+    {
+        typedef std::unique_ptr<int> T;
+        optional<T> opt;
+        assert(std::hash<optional<T>>{}(opt) == 0);
+        opt = std::unique_ptr<int>(new int(3));
+        assert(std::hash<optional<T>>{}(opt) == std::hash<T>{}(*opt));
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.inplace/in_place_t.pass.cpp b/final/test/utilities/optional/optional.inplace/in_place_t.pass.cpp
new file mode 100644
index 0000000..360b9d9
--- /dev/null
+++ b/final/test/utilities/optional/optional.inplace/in_place_t.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// struct in_place_t{};
+// constexpr in_place_t in_place{};
+
+#include <experimental/optional>
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+constexpr
+int
+test(const in_place_t&)
+{
+    return 3;
+}
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    static_assert((std::is_class<in_place_t>::value), "");
+    static_assert((std::is_empty<in_place_t>::value), "");
+    
+    static_assert(test(in_place) == 3, "");
+#endif
+}
diff --git a/final/test/utilities/optional/optional.nullops/eqaul.pass.cpp b/final/test/utilities/optional/optional.nullops/eqaul.pass.cpp
new file mode 100644
index 0000000..d137d30
--- /dev/null
+++ b/final/test/utilities/optional/optional.nullops/eqaul.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+	using std::experimental::optional;
+	using std::experimental::nullopt_t;
+	using std::experimental::nullopt;
+    
+    {
+    typedef int T;
+    typedef optional<T> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2{1};  // engaged
+
+    static_assert (   nullopt == o1 , "" );
+    static_assert ( !(nullopt == o2), "" );
+    static_assert (   o1 == nullopt , "" );
+    static_assert ( !(o2 == nullopt), "" );
+
+    static_assert (noexcept(nullopt == o1), "");
+    static_assert (noexcept(o1 == nullopt), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/optional/optional.nullops/less_than.pass.cpp b/final/test/utilities/optional/optional.nullops/less_than.pass.cpp
new file mode 100644
index 0000000..51c8e49
--- /dev/null
+++ b/final/test/utilities/optional/optional.nullops/less_than.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+
+// <optional>
+
+// template <class T> constexpr bool operator<(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator<(nullopt_t, const optional<T>& x) noexcept;
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+	using std::experimental::optional;
+	using std::experimental::nullopt_t;
+	using std::experimental::nullopt;
+
+    {
+    typedef int T;
+    typedef optional<T> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2{1};  // engaged
+
+    static_assert ( !(nullopt < o1), "" );
+    static_assert (   nullopt < o2 , "" );
+    static_assert ( !(o1 < nullopt), "" );
+    static_assert ( !(o2 < nullopt), "" );
+
+    static_assert (noexcept(nullopt < o1), "");
+    static_assert (noexcept(o1 < nullopt), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp b/final/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
new file mode 100644
index 0000000..de1e83b
--- /dev/null
+++ b/final/test/utilities/optional/optional.nullopt/nullopt_t.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// struct nullopt_t{see below};
+// constexpr nullopt_t nullopt(unspecified);
+
+#include <experimental/optional>
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
+constexpr
+int
+test(const nullopt_t&)
+{
+    return 3;
+}
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_class<nullopt_t>::value), "");
+    static_assert((std::is_empty<nullopt_t>::value), "");
+    static_assert((std::is_literal_type<nullopt_t>::value), "");
+    static_assert((!std::is_default_constructible<nullopt_t>::value), "");
+    
+    static_assert(test(nullopt) == 3, "");
+#endif
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp
new file mode 100644
index 0000000..e256a09
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.assign/assign_value.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U> optional<T>& operator=(U&& v);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+#include <memory>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    static_assert(std::is_assignable<optional<int>, int>::value, "");
+    static_assert(std::is_assignable<optional<int>, int&>::value, "");
+    static_assert(std::is_assignable<optional<int>&, int>::value, "");
+    static_assert(std::is_assignable<optional<int>&, int&>::value, "");
+    static_assert(std::is_assignable<optional<int>&, const int&>::value, "");
+    static_assert(!std::is_assignable<const optional<int>&, const int&>::value, "");
+    static_assert(!std::is_assignable<optional<int>, X>::value, "");
+    {
+        optional<int> opt;
+        opt = 1;
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == 1);
+    }
+    {
+        optional<int> opt;
+        const int i = 2;
+        opt = i;
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == i);
+    }
+    {
+        optional<int> opt(3);
+        const int i = 2;
+        opt = i;
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == i);
+    }
+    {
+        optional<std::unique_ptr<int>> opt;
+        opt = std::unique_ptr<int>(new int(3));
+        assert(static_cast<bool>(opt) == true);
+        assert(**opt == 3);
+    }
+    {
+        optional<std::unique_ptr<int>> opt(std::unique_ptr<int>(new int(2)));
+        opt = std::unique_ptr<int>(new int(3));
+        assert(static_cast<bool>(opt) == true);
+        assert(**opt == 3);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
new file mode 100644
index 0000000..81c3b4e
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.assign/copy.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional<T>& operator=(const optional<T>& rhs);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    static bool throw_now;
+
+    X() = default;
+    X(const X&)
+    {
+        if (throw_now)
+            throw 6;
+    }
+};
+
+bool X::throw_now = false;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<int> opt;
+        constexpr optional<int> opt2;
+        opt = opt2;
+        static_assert(static_cast<bool>(opt2) == false, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+    }
+    {
+        optional<int> opt;
+        constexpr optional<int> opt2(2);
+        opt = opt2;
+        static_assert(static_cast<bool>(opt2) == true, "");
+        static_assert(*opt2 == 2, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+        assert(*opt == *opt2);
+    }
+    {
+        optional<int> opt(3);
+        constexpr optional<int> opt2;
+        opt = opt2;
+        static_assert(static_cast<bool>(opt2) == false, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+    }
+    {
+        optional<int> opt(3);
+        constexpr optional<int> opt2(2);
+        opt = opt2;
+        static_assert(static_cast<bool>(opt2) == true, "");
+        static_assert(*opt2 == 2, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+        assert(*opt == *opt2);
+    }
+    {
+        optional<X> opt;
+        optional<X> opt2(X{});
+        assert(static_cast<bool>(opt2) == true);
+        try
+        {
+            X::throw_now = true;
+            opt = opt2;
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+            assert(static_cast<bool>(opt) == false);
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
new file mode 100644
index 0000000..c4361ea
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
@@ -0,0 +1,148 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class... Args> void optional<T>::emplace(Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+#include <memory>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+    int i_;
+    int j_ = 0;
+public:
+    X() : i_(0) {}
+    X(int i) : i_(i) {}
+    X(int i, int j) : i_(i), j_(j) {}
+
+    friend bool operator==(const X& x, const X& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Y
+{
+public:
+    static bool dtor_called;
+    Y() = default;
+    ~Y() {dtor_called = true;}
+};
+
+bool Y::dtor_called = false;
+
+class Z
+{
+public:
+    static bool dtor_called;
+    Z() = default;
+    Z(int) {throw 6;}
+    ~Z() {dtor_called = true;}
+};
+
+bool Z::dtor_called = false;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<int> opt;
+        opt.emplace();
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == 0);
+    }
+    {
+        optional<int> opt;
+        opt.emplace(1);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == 1);
+    }
+    {
+        optional<int> opt(2);
+        opt.emplace();
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == 0);
+    }
+    {
+        optional<int> opt(2);
+        opt.emplace(1);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == 1);
+    }
+    {
+        optional<X> opt;
+        opt.emplace();
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X());
+    }
+    {
+        optional<X> opt;
+        opt.emplace(1);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X(1));
+    }
+    {
+        optional<X> opt;
+        opt.emplace(1, 2);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X(1, 2));
+    }
+    {
+        optional<X> opt(X{3});
+        opt.emplace();
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X());
+    }
+    {
+        optional<X> opt(X{3});
+        opt.emplace(1);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X(1));
+    }
+    {
+        optional<X> opt(X{3});
+        opt.emplace(1, 2);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X(1, 2));
+    }
+    {
+        Y y;
+        {
+            optional<Y> opt(y);
+            assert(Y::dtor_called == false);
+            opt.emplace();
+            assert(Y::dtor_called == true);
+        }
+    }
+    {
+        Z z;
+        optional<Z> opt(z);
+        try
+        {
+            assert(static_cast<bool>(opt) == true);
+            assert(Z::dtor_called == false);
+            opt.emplace(1);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+            assert(static_cast<bool>(opt) == false);
+            assert(Z::dtor_called == true);
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
new file mode 100644
index 0000000..8d20be3
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U, class... Args>
+//   void optional<T>::emplace(initializer_list<U> il, Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+#include <vector>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+    int i_;
+    int j_ = 0;
+public:
+    static bool dtor_called;
+    constexpr X() : i_(0) {}
+    constexpr X(int i) : i_(i) {}
+    constexpr X(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {}
+    ~X() {dtor_called = true;}
+
+    friend constexpr bool operator==(const X& x, const X& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+bool X::dtor_called = false;
+
+class Y
+{
+    int i_;
+    int j_ = 0;
+public:
+    constexpr Y() : i_(0) {}
+    constexpr Y(int i) : i_(i) {}
+    constexpr Y(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {}
+
+    friend constexpr bool operator==(const Y& x, const Y& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Z
+{
+    int i_;
+    int j_ = 0;
+public:
+    static bool dtor_called;
+    constexpr Z() : i_(0) {}
+    constexpr Z(int i) : i_(i) {}
+    constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
+        {throw 6;}
+    ~Z() {dtor_called = true;}
+
+    friend constexpr bool operator==(const Z& x, const Z& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+bool Z::dtor_called = false;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        X x;
+        {
+            optional<X> opt(x);
+            assert(X::dtor_called == false);
+            opt.emplace({1, 2});
+            assert(X::dtor_called == true);
+            assert(*opt == X({1, 2}));
+        }
+    }
+    {
+        optional<std::vector<int>> opt;
+        opt.emplace({1, 2, 3}, std::allocator<int>());
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == std::vector<int>({1, 2, 3}));
+    }
+    {
+        optional<Y> opt;
+        opt.emplace({1, 2});
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == Y({1, 2}));
+    }
+    {
+        Z z;
+        optional<Z> opt(z);
+        try
+        {
+            assert(static_cast<bool>(opt) == true);
+            assert(Z::dtor_called == false);
+            opt.emplace({1, 2});
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+            assert(static_cast<bool>(opt) == false);
+            assert(Z::dtor_called == true);
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
new file mode 100644
index 0000000..d27313d
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional<T>& operator=(optional<T>&& rhs)
+//     noexcept(is_nothrow_move_assignable<T>::value &&
+//              is_nothrow_move_constructible<T>::value);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    static bool throw_now;
+
+    X() = default;
+    X(X&&)
+    {
+        if (throw_now)
+            throw 6;
+    }
+    X& operator=(X&&) noexcept
+    {
+        return *this;
+    }
+};
+
+struct Y {};
+
+bool X::throw_now = false;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        static_assert(std::is_nothrow_move_assignable<optional<int>>::value, "");
+        optional<int> opt;
+        constexpr optional<int> opt2;
+        opt = std::move(opt2);
+        static_assert(static_cast<bool>(opt2) == false, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+    }
+    {
+        optional<int> opt;
+        constexpr optional<int> opt2(2);
+        opt = std::move(opt2);
+        static_assert(static_cast<bool>(opt2) == true, "");
+        static_assert(*opt2 == 2, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+        assert(*opt == *opt2);
+    }
+    {
+        optional<int> opt(3);
+        constexpr optional<int> opt2;
+        opt = std::move(opt2);
+        static_assert(static_cast<bool>(opt2) == false, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+    }
+    {
+        optional<int> opt(3);
+        constexpr optional<int> opt2(2);
+        opt = std::move(opt2);
+        static_assert(static_cast<bool>(opt2) == true, "");
+        static_assert(*opt2 == 2, "");
+        assert(static_cast<bool>(opt) == static_cast<bool>(opt2));
+        assert(*opt == *opt2);
+    }
+    {
+        static_assert(!std::is_nothrow_move_assignable<optional<X>>::value, "");
+        optional<X> opt;
+        optional<X> opt2(X{});
+        assert(static_cast<bool>(opt2) == true);
+        try
+        {
+            X::throw_now = true;
+            opt = std::move(opt2);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+            assert(static_cast<bool>(opt) == false);
+        }
+    }
+    {
+        static_assert(std::is_nothrow_move_assignable<optional<Y>>::value, "");
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp
new file mode 100644
index 0000000..7f39744
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.assign/nullopt_t.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional<T>& operator=(nullopt_t) noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
+struct X
+{
+    static bool dtor_called;
+    ~X() {dtor_called = true;}
+};
+
+bool X::dtor_called = false;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<int> opt;
+        static_assert(noexcept(opt = nullopt) == true, "");
+        opt = nullopt;
+        assert(static_cast<bool>(opt) == false);
+    }
+    {
+        optional<int> opt(3);
+        opt = nullopt;
+        assert(static_cast<bool>(opt) == false);
+    }
+    {
+        optional<X> opt;
+        static_assert(noexcept(opt = nullopt) == true, "");
+        assert(X::dtor_called == false);
+        opt = nullopt;
+        assert(X::dtor_called == false);
+        assert(static_cast<bool>(opt) == false);
+    }
+    {
+        X x;
+        {
+            optional<X> opt(x);
+            assert(X::dtor_called == false);
+            opt = nullopt;
+            assert(X::dtor_called == true);
+            assert(static_cast<bool>(opt) == false);
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp
new file mode 100644
index 0000000..071f594
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/const_T.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional(const T& v);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+    int i_;
+public:
+    X(int i) : i_(i) {}
+
+    friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+    int i_;
+public:
+    constexpr Y(int i) : i_(i) {}
+
+    friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+class Z
+{
+    int i_;
+public:
+    Z(int i) : i_(i) {}
+    Z(const Z&) {throw 6;}
+};
+
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        constexpr T t(5);
+        constexpr optional<T> opt(t);
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == 5, "");
+
+        struct test_constexpr_ctor
+            : public optional<T>
+        {
+            constexpr test_constexpr_ctor(const T&) {}
+        };
+
+    }
+    {
+        typedef double T;
+        constexpr T t(3);
+        constexpr optional<T> opt(t);
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == 3, "");
+
+        struct test_constexpr_ctor
+            : public optional<T>
+        {
+            constexpr test_constexpr_ctor(const T&) {}
+        };
+
+    }
+    {
+        typedef X T;
+        const T t(3);
+        optional<T> opt(t);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == 3);
+    }
+    {
+        typedef Y T;
+        constexpr T t(3);
+        constexpr optional<T> opt(t);
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == 3, "");
+
+        struct test_constexpr_ctor
+            : public optional<T>
+        {
+            constexpr test_constexpr_ctor(const T&) {}
+        };
+
+    }
+    {
+        typedef Z T;
+        try
+        {
+            const T t(3);
+            optional<T> opt(t);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
new file mode 100644
index 0000000..8726f95
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -0,0 +1,124 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional(const optional<T>& rhs);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class T>
+void
+test(const optional<T>& rhs, bool is_going_to_throw = false)
+{
+    bool rhs_engaged = static_cast<bool>(rhs);
+    try
+    {
+        optional<T> lhs = rhs;
+        assert(is_going_to_throw == false);
+        assert(static_cast<bool>(lhs) == rhs_engaged);
+        if (rhs_engaged)
+            assert(*lhs == *rhs);
+    }
+    catch (int i)
+    {
+        assert(i == 6);
+    }
+}
+
+class X
+{
+    int i_;
+public:
+    X(int i) : i_(i) {}
+    X(const X& x) : i_(x.i_) {}
+    ~X() {i_ = 0;}
+    friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+    int i_;
+public:
+    Y(int i) : i_(i) {}
+    Y(const Y& x) : i_(x.i_) {}
+
+    friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+int count = 0;
+
+class Z
+{
+    int i_;
+public:
+    Z(int i) : i_(i) {}
+    Z(const Z&)
+    {
+        if (++count == 2)
+            throw 6;
+    }
+
+    friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+};
+
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef int T;
+        optional<T> rhs(3);
+        test(rhs);
+    }
+    {
+        typedef X T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef X T;
+        optional<T> rhs(X(3));
+        test(rhs);
+    }
+    {
+        typedef Y T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef Y T;
+        optional<T> rhs(Y(3));
+        test(rhs);
+    }
+    {
+        typedef Z T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef Z T;
+        optional<T> rhs(Z(3));
+        test(rhs, true);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp
new file mode 100644
index 0000000..6a1763d
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/default.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional() noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class Opt>
+void
+test_constexpr()
+{
+    static_assert(std::is_nothrow_default_constructible<Opt>::value, "");
+    constexpr Opt opt;
+    static_assert(static_cast<bool>(opt) == false, "");
+
+    struct test_constexpr_ctor
+        : public Opt
+    {
+        constexpr test_constexpr_ctor() {}
+    };
+
+}
+
+template <class Opt>
+void
+test()
+{
+    static_assert(std::is_nothrow_default_constructible<Opt>::value, "");
+    Opt opt;
+    assert(static_cast<bool>(opt) == false);
+
+    struct test_constexpr_ctor
+        : public Opt
+    {
+        constexpr test_constexpr_ctor() {}
+    };
+}
+
+struct X
+{
+    X();
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    test_constexpr<optional<int>>();
+    test_constexpr<optional<int*>>();
+    test<optional<X>>();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
new file mode 100644
index 0000000..412c993
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class... Args>
+//   constexpr explicit optional(in_place_t, Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+class X
+{
+    int i_;
+    int j_ = 0;
+public:
+    X() : i_(0) {}
+    X(int i) : i_(i) {}
+    X(int i, int j) : i_(i), j_(j) {}
+
+    ~X() {}
+
+    friend bool operator==(const X& x, const X& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Y
+{
+    int i_;
+    int j_ = 0;
+public:
+    constexpr Y() : i_(0) {}
+    constexpr Y(int i) : i_(i) {}
+    constexpr Y(int i, int j) : i_(i), j_(j) {}
+
+    friend constexpr bool operator==(const Y& x, const Y& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Z
+{
+    int i_;
+public:
+    Z(int i) : i_(i) {throw 6;}
+};
+
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        constexpr optional<int> opt(in_place, 5);
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == 5, "");
+
+        struct test_constexpr_ctor
+            : public optional<int>
+        {
+            constexpr test_constexpr_ctor(in_place_t, int i) 
+                : optional<int>(in_place, i) {}
+        };
+
+    }
+    {
+        const optional<X> opt(in_place);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X());
+    }
+    {
+        const optional<X> opt(in_place, 5);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X(5));
+    }
+    {
+        const optional<X> opt(in_place, 5, 4);
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == X(5, 4));
+    }
+    {
+        constexpr optional<Y> opt(in_place);
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == Y(), "");
+
+        struct test_constexpr_ctor
+            : public optional<Y>
+        {
+            constexpr test_constexpr_ctor(in_place_t) 
+                : optional<Y>(in_place) {}
+        };
+
+    }
+    {
+        constexpr optional<Y> opt(in_place, 5);
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == Y(5), "");
+
+        struct test_constexpr_ctor
+            : public optional<Y>
+        {
+            constexpr test_constexpr_ctor(in_place_t, int i) 
+                : optional<Y>(in_place, i) {}
+        };
+
+    }
+    {
+        constexpr optional<Y> opt(in_place, 5, 4);
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == Y(5, 4), "");
+
+        struct test_constexpr_ctor
+            : public optional<Y>
+        {
+            constexpr test_constexpr_ctor(in_place_t, int i, int j) 
+                : optional<Y>(in_place, i, j) {}
+        };
+
+    }
+    {
+        try
+        {
+            const optional<Z> opt(in_place, 1);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
new file mode 100644
index 0000000..98cb929
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U, class... Args>
+//     constexpr
+//     explicit optional(in_place_t, initializer_list<U> il, Args&&... args);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <vector>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+class X
+{
+    int i_;
+    int j_ = 0;
+public:
+    X() : i_(0) {}
+    X(int i) : i_(i) {}
+    X(int i, int j) : i_(i), j_(j) {}
+
+    ~X() {}
+
+    friend bool operator==(const X& x, const X& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Y
+{
+    int i_;
+    int j_ = 0;
+public:
+    constexpr Y() : i_(0) {}
+    constexpr Y(int i) : i_(i) {}
+    constexpr Y(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1]) {}
+
+    friend constexpr bool operator==(const Y& x, const Y& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+class Z
+{
+    int i_;
+    int j_ = 0;
+public:
+    constexpr Z() : i_(0) {}
+    constexpr Z(int i) : i_(i) {}
+    constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
+        {throw 6;}
+
+    friend constexpr bool operator==(const Z& x, const Z& y)
+        {return x.i_ == y.i_ && x.j_ == y.j_;}
+};
+
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        static_assert(!std::is_constructible<X, std::initializer_list<int>&>::value, "");
+        static_assert(!std::is_constructible<optional<X>, std::initializer_list<int>&>::value, "");
+    }
+    {
+        optional<std::vector<int>> opt(in_place, {3, 1});
+        assert(static_cast<bool>(opt) == true);
+        assert((*opt == std::vector<int>{3, 1}));
+        assert(opt->size() == 2);
+    }
+    {
+        optional<std::vector<int>> opt(in_place, {3, 1}, std::allocator<int>());
+        assert(static_cast<bool>(opt) == true);
+        assert((*opt == std::vector<int>{3, 1}));
+        assert(opt->size() == 2);
+    }
+    {
+        static_assert(std::is_constructible<optional<Y>, std::initializer_list<int>&>::value, "");
+        constexpr optional<Y> opt(in_place, {3, 1});
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == Y{3, 1}, "");
+
+        struct test_constexpr_ctor
+            : public optional<Y>
+        {
+            constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i) 
+                : optional<Y>(in_place, i) {}
+        };
+
+    }
+    {
+        static_assert(std::is_constructible<optional<Z>, std::initializer_list<int>&>::value, "");
+        try
+        {
+            optional<Z> opt(in_place, {3, 1});
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+        }
+
+        struct test_constexpr_ctor
+            : public optional<Z>
+        {
+            constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i) 
+                : optional<Z>(in_place, i) {}
+        };
+
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
new file mode 100644
index 0000000..b320c95
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -0,0 +1,124 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// optional(optional<T>&& rhs) noexcept(is_nothrow_move_constructible<T>::value);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class T>
+void
+test(optional<T>& rhs, bool is_going_to_throw = false)
+{
+    static_assert(std::is_nothrow_move_constructible<optional<T>>::value ==
+                  std::is_nothrow_move_constructible<T>::value, "");
+    bool rhs_engaged = static_cast<bool>(rhs);
+    try
+    {
+        optional<T> lhs = std::move(rhs);
+        assert(is_going_to_throw == false);
+        assert(static_cast<bool>(lhs) == rhs_engaged);
+    }
+    catch (int i)
+    {
+        assert(i == 6);
+    }
+}
+
+class X
+{
+    int i_;
+public:
+    X(int i) : i_(i) {}
+    X(X&& x) : i_(x.i_) {x.i_ = 0;}
+    ~X() {i_ = 0;}
+    friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+    int i_;
+public:
+    Y(int i) : i_(i) {}
+    Y(Y&& x) noexcept : i_(x.i_) {x.i_ = 0;}
+
+    friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+int count = 0;
+
+class Z
+{
+    int i_;
+public:
+    Z(int i) : i_(i) {}
+    Z(Z&&)
+    {
+        if (++count == 2)
+            throw 6;
+    }
+
+    friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+};
+
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef int T;
+        optional<T> rhs(3);
+        test(rhs);
+    }
+    {
+        typedef X T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef X T;
+        optional<T> rhs(X(3));
+        test(rhs);
+    }
+    {
+        typedef Y T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef Y T;
+        optional<T> rhs(Y(3));
+        test(rhs);
+    }
+    {
+        typedef Z T;
+        optional<T> rhs;
+        test(rhs);
+    }
+    {
+        typedef Z T;
+        optional<T> rhs(Z(3));
+        test(rhs, true);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
new file mode 100644
index 0000000..c307a2e
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/nullopt_t.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional(nullopt_t) noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::nullopt_t;
+using std::experimental::nullopt;
+
+template <class Opt>
+void
+test_constexpr()
+{
+    static_assert(noexcept(Opt(nullopt)), "");
+    constexpr Opt opt(nullopt);
+    static_assert(static_cast<bool>(opt) == false, "");
+
+    struct test_constexpr_ctor
+        : public Opt
+    {
+        constexpr test_constexpr_ctor() {}
+    };
+}
+
+template <class Opt>
+void
+test()
+{
+    static_assert(noexcept(Opt(nullopt)), "");
+    Opt opt(nullopt);
+    assert(static_cast<bool>(opt) == false);
+
+    struct test_constexpr_ctor
+        : public Opt
+    {
+        constexpr test_constexpr_ctor() {}
+    };
+}
+
+struct X
+{
+    X();
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    test_constexpr<optional<int>>();
+    test_constexpr<optional<int*>>();
+    test<optional<X>>();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
new file mode 100644
index 0000000..ac52a42
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr optional(T&& v);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+    int i_;
+public:
+    X(int i) : i_(i) {}
+    X(X&& x) : i_(x.i_) {}
+
+    friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+class Y
+{
+    int i_;
+public:
+    constexpr Y(int i) : i_(i) {}
+    constexpr Y(Y&& x) : i_(x.i_) {}
+
+    friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+};
+
+class Z
+{
+    int i_;
+public:
+    Z(int i) : i_(i) {}
+    Z(Z&&) {throw 6;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        constexpr optional<T> opt(T(5));
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == 5, "");
+
+        struct test_constexpr_ctor
+            : public optional<T>
+        {
+            constexpr test_constexpr_ctor(T&&) {}
+        };
+    }
+    {
+        typedef double T;
+        constexpr optional<T> opt(T(3));
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == 3, "");
+
+        struct test_constexpr_ctor
+            : public optional<T>
+        {
+            constexpr test_constexpr_ctor(T&&) {}
+        };
+    }
+    {
+        typedef X T;
+        optional<T> opt(T(3));
+        assert(static_cast<bool>(opt) == true);
+        assert(*opt == 3);
+    }
+    {
+        typedef Y T;
+        constexpr optional<T> opt(T(3));
+        static_assert(static_cast<bool>(opt) == true, "");
+        static_assert(*opt == 3, "");
+
+        struct test_constexpr_ctor
+            : public optional<T>
+        {
+            constexpr test_constexpr_ctor(T&&) {}
+        };
+    }
+    {
+        typedef Z T;
+        try
+        {
+            optional<T> opt(T(3));
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp
new file mode 100644
index 0000000..2697799
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// ~optional();
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+public:
+    static bool dtor_called;
+    X() = default;
+    ~X() {dtor_called = true;}
+};
+
+bool X::dtor_called = false;
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef int T;
+        static_assert(std::is_trivially_destructible<T>::value, "");
+        static_assert(std::is_trivially_destructible<optional<T>>::value, "");
+    }
+    {
+        typedef double T;
+        static_assert(std::is_trivially_destructible<T>::value, "");
+        static_assert(std::is_trivially_destructible<optional<T>>::value, "");
+    }
+    {
+        typedef X T;
+        static_assert(!std::is_trivially_destructible<T>::value, "");
+        static_assert(!std::is_trivially_destructible<optional<T>>::value, "");
+        {
+            X x;
+            optional<X> opt{x};
+            assert(X::dtor_called == false);
+        }
+        assert(X::dtor_called == true);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp
new file mode 100644
index 0000000..a372437
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/bool.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr explicit optional<T>::operator bool() const noexcept;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+
+    {
+        constexpr optional<int> opt;
+        static_assert(!opt, "");
+    }
+    {
+        constexpr optional<int> opt(0);
+        static_assert(opt, "");
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
new file mode 100644
index 0000000..98e5dac
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/dereference.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T& optional<T>::operator*();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    constexpr int test() const {return 3;}
+    int test() {return 4;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<X> opt(X{});
+        assert((*opt).test() == 4);
+    }
+#ifdef _LIBCPP_DEBUG
+    {
+        optional<X> opt;
+        assert((*opt).test() == 3);
+        assert(false);
+    }
+#endif  // _LIBCPP_DEBUG
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
new file mode 100644
index 0000000..c72a578
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/dereference_const.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T& optional<T>::operator*() const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    constexpr int test() const {return 3;}
+};
+
+struct Y
+{
+    int test() const {return 2;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        constexpr optional<X> opt(X{});
+        static_assert((*opt).test() == 3, "");
+    }
+    {
+        constexpr optional<Y> opt(Y{});
+        assert((*opt).test() == 2);
+    }
+#ifdef _LIBCPP_DEBUG
+    {
+        const optional<X> opt;
+        assert((*opt).test() == 3);
+        assert(false);
+    }
+#endif  // _LIBCPP_DEBUG
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp
new file mode 100644
index 0000000..0fb5aa2
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/op_arrow.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T* optional<T>::operator->();
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int test() const {return 2;}
+    int test() {return 3;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<X> opt(X{});
+        assert(opt->test() == 3);
+    }
+#ifdef _LIBCPP_DEBUG
+    {
+        optional<X> opt;
+        assert(opt->test() == 3);
+        assert(false);
+    }
+#endif  // _LIBCPP_DEBUG
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp
new file mode 100644
index 0000000..e813dd9
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/op_arrow_const.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T* optional<T>::operator->() const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    constexpr int test() const {return 3;}
+};
+
+struct Y
+{
+    int test() const {return 2;}
+};
+
+struct Z
+{
+    const Z* operator&() const {return this;}
+    constexpr int test() const {return 1;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        constexpr optional<X> opt(X{});
+        static_assert(opt->test() == 3, "");
+    }
+    {
+        constexpr optional<Y> opt(Y{});
+        assert(opt->test() == 2);
+    }
+    {
+        constexpr optional<Z> opt(Z{});
+        assert(opt->test() == 1);
+    }
+#ifdef _LIBCPP_DEBUG
+    {
+        const optional<X> opt;
+        assert(opt->test() == 3);
+        assert(false);
+    }
+#endif  // _LIBCPP_DEBUG
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp
new file mode 100644
index 0000000..e91805e
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/value.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T& optional<T>::value();
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::bad_optional_access;
+
+struct X
+{
+    X() = default;
+    X(const X&) = delete;
+    constexpr int test() const {return 3;}
+    int test() {return 4;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<X> opt;
+        opt.emplace();
+        assert(opt.value().test() == 4);
+    }
+    {
+        optional<X> opt;
+        try
+        {
+            opt.value();
+            assert(false);
+        }
+        catch (const bad_optional_access&)
+        {
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp
new file mode 100644
index 0000000..f0f8af6
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/value_const.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T& optional<T>::value() const;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    constexpr int test() const {return 3;}
+    int test() {return 4;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        constexpr optional<X> opt;
+        static_assert(opt.value().test() == 3, "");
+    }
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp
new file mode 100644
index 0000000..39bf687
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/value_const.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// constexpr const T& optional<T>::value() const;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+using std::experimental::bad_optional_access;
+
+struct X
+{
+    X() = default;
+    X(const X&) = delete;
+   constexpr int test() const {return 3;}
+    int test() {return 4;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        constexpr optional<X> opt(in_place);
+        static_assert(opt.value().test() == 3, "");
+    }
+    {
+        const optional<X> opt(in_place);
+        assert(opt.value().test() == 3);
+    }
+    {
+        const optional<X> opt;
+        try
+        {
+            opt.value();
+            assert(false);
+        }
+        catch (const bad_optional_access&)
+        {
+        }
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
new file mode 100644
index 0000000..6118c44
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/value_or.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U> T optional<T>::value_or(U&& v) &&;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+using std::experimental::in_place_t;
+using std::experimental::in_place;
+
+struct Y
+{
+    int i_;
+
+    Y(int i) : i_(i) {}
+};
+
+struct X
+{
+    int i_;
+
+    X(int i) : i_(i) {}
+    X(X&& x) : i_(x.i_) {x.i_ = 0;}
+    X(const Y& y) : i_(y.i_) {}
+    X(Y&& y) : i_(y.i_+1) {}
+    friend constexpr bool operator==(const X& x, const X& y)
+        {return x.i_ == y.i_;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<X> opt(in_place, 2);
+        Y y(3);
+        assert(std::move(opt).value_or(y) == 2);
+        assert(*opt == 0);
+    }
+    {
+        optional<X> opt(in_place, 2);
+        assert(std::move(opt).value_or(Y(3)) == 2);
+        assert(*opt == 0);
+    }
+    {
+        optional<X> opt;
+        Y y(3);
+        assert(std::move(opt).value_or(y) == 3);
+        assert(!opt);
+    }
+    {
+        optional<X> opt;
+        assert(std::move(opt).value_or(Y(3)) == 4);
+        assert(!opt);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp
new file mode 100644
index 0000000..d51f18a
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.observe/value_or_const.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class U> constexpr T optional<T>::value_or(U&& v) const&;
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct Y
+{
+    int i_;
+
+    constexpr Y(int i) : i_(i) {}
+};
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+    constexpr X(const Y& y) : i_(y.i_) {}
+    constexpr X(Y&& y) : i_(y.i_+1) {}
+    friend constexpr bool operator==(const X& x, const X& y)
+        {return x.i_ == y.i_;}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        constexpr optional<X> opt(2);
+        constexpr Y y(3);
+        static_assert(opt.value_or(y) == 2, "");
+    }
+    {
+        constexpr optional<X> opt(2);
+        static_assert(opt.value_or(Y(3)) == 2, "");
+    }
+    {
+        constexpr optional<X> opt;
+        constexpr Y y(3);
+        static_assert(opt.value_or(y) == 3, "");
+    }
+    {
+        constexpr optional<X> opt;
+        static_assert(opt.value_or(Y(3)) == 4, "");
+    }
+    {
+        const optional<X> opt(2);
+        const Y y(3);
+        assert(opt.value_or(y) == 2);
+    }
+    {
+        const optional<X> opt(2);
+        assert(opt.value_or(Y(3)) == 2);
+    }
+    {
+        const optional<X> opt;
+        const Y y(3);
+        assert(opt.value_or(y) == 3);
+    }
+    {
+        const optional<X> opt;
+        assert(opt.value_or(Y(3)) == 4);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp b/final/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp
new file mode 100644
index 0000000..e0ecfde
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional.object.swap/swap.pass.cpp
@@ -0,0 +1,306 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// void swap(optional&)
+//     noexcept(is_nothrow_move_constructible<T>::value &&
+//              noexcept(swap(declval<T&>(), declval<T&>())));
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+    int i_;
+public:
+    static unsigned dtor_called;
+    X(int i) : i_(i) {}
+    X(X&& x) = default;
+    X& operator=(X&&) = default;
+    ~X() {++dtor_called;}
+
+    friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+unsigned X::dtor_called = 0;
+
+class Y
+{
+    int i_;
+public:
+    static unsigned dtor_called;
+    Y(int i) : i_(i) {}
+    Y(Y&&) = default;
+    ~Y() {++dtor_called;}
+
+    friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+    friend void swap(Y& x, Y& y) {std::swap(x.i_, y.i_);}
+};
+
+unsigned Y::dtor_called = 0;
+
+class Z
+{
+    int i_;
+public:
+    Z(int i) : i_(i) {}
+    Z(Z&&) {throw 7;}
+
+    friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+    friend void swap(Z& x, Z& y) {throw 6;}
+};
+
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<int> opt1;
+        optional<int> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        opt1.swap(opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<int> opt1(1);
+        optional<int> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        opt1.swap(opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<int> opt1;
+        optional<int> opt2(2);
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        opt1.swap(opt2);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<int> opt1(1);
+        optional<int> opt2(2);
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        opt1.swap(opt2);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<X> opt1;
+        optional<X> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        opt1.swap(opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        assert(X::dtor_called == 0);
+    }
+    {
+        optional<X> opt1(1);
+        optional<X> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        X::dtor_called = 0;
+        opt1.swap(opt2);
+        assert(X::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<X> opt1;
+        optional<X> opt2(2);
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        X::dtor_called = 0;
+        opt1.swap(opt2);
+        assert(X::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<X> opt1(1);
+        optional<X> opt2(2);
+        static_assert(noexcept(opt1.swap(opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        X::dtor_called = 0;
+        opt1.swap(opt2);
+        assert(X::dtor_called == 1);  // from inside std::swap
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<Y> opt1;
+        optional<Y> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        opt1.swap(opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        assert(Y::dtor_called == 0);
+    }
+    {
+        optional<Y> opt1(1);
+        optional<Y> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        Y::dtor_called = 0;
+        opt1.swap(opt2);
+        assert(Y::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<Y> opt1;
+        optional<Y> opt2(2);
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        Y::dtor_called = 0;
+        opt1.swap(opt2);
+        assert(Y::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<Y> opt1(1);
+        optional<Y> opt2(2);
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        Y::dtor_called = 0;
+        opt1.swap(opt2);
+        assert(Y::dtor_called == 0);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<Z> opt1;
+        optional<Z> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        opt1.swap(opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<Z> opt1;
+        opt1.emplace(1);
+        optional<Z> opt2;
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        try
+        {
+            opt1.swap(opt2);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 7);
+        }
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<Z> opt1;
+        optional<Z> opt2;
+        opt2.emplace(2);
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        try
+        {
+            opt1.swap(opt2);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 7);
+        }
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+    }
+    {
+        optional<Z> opt1;
+        opt1.emplace(1);
+        optional<Z> opt2;
+        opt2.emplace(2);
+        static_assert(noexcept(opt1.swap(opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        try
+        {
+            opt1.swap(opt2);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+        }
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional_const_void.fail.cpp b/final/test/utilities/optional/optional.object/optional_const_void.fail.cpp
new file mode 100644
index 0000000..ccbcf2e
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional_const_void.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+	using std::experimental::optional;
+
+    optional<const void> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp b/final/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp
new file mode 100644
index 0000000..61470af
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional_not_destructible.fail.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+private:
+    ~X() {}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    optional<X> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp b/final/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp
new file mode 100644
index 0000000..eaee020
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional_not_noexcept_destructible.fail.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    ~X() noexcept(false) {}
+};
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    optional<X> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/optional_void.fail.cpp b/final/test/utilities/optional/optional.object/optional_void.fail.cpp
new file mode 100644
index 0000000..f911e9a
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/optional_void.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// T shall be an object type and shall satisfy the requirements of Destructible
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+
+    optional<void> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.object/types.pass.cpp b/final/test/utilities/optional/optional.object/types.pass.cpp
new file mode 100644
index 0000000..8b9ad2e
--- /dev/null
+++ b/final/test/utilities/optional/optional.object/types.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T>
+// class optional
+// {
+// public:
+//     typedef T value_type;
+//     ...
+
+#include <experimental/optional>
+#include <type_traits>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+template <class Opt, class T>
+void
+test()
+{
+    static_assert(std::is_same<typename Opt::value_type, T>::value, "");
+}
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    test<optional<int>, int>();
+    test<optional<const int>, const int>();
+    test<optional<double>, double>();
+    test<optional<const double>, const double>();
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.relops/equal.pass.cpp b/final/test/utilities/optional/optional.relops/equal.pass.cpp
new file mode 100644
index 0000000..03b9d3f
--- /dev/null
+++ b/final/test/utilities/optional/optional.relops/equal.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator==(const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+    { return lhs.i_ == rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef X T;
+    typedef optional<T> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2;     // disengaged
+    constexpr O o3{1};  // engaged
+    constexpr O o4{2};  // engaged
+    constexpr O o5{1};  // engaged
+
+    static_assert (   o1 == o1 , "" );
+    static_assert (   o1 == o2 , "" );
+    static_assert ( !(o1 == o3), "" );
+    static_assert ( !(o1 == o4), "" );
+    static_assert ( !(o1 == o5), "" );
+
+    static_assert (   o2 == o1 , "" );
+    static_assert (   o2 == o2 , "" );
+    static_assert ( !(o2 == o3), "" );
+    static_assert ( !(o2 == o4), "" );
+    static_assert ( !(o2 == o5), "" );
+
+    static_assert ( !(o3 == o1), "" );
+    static_assert ( !(o3 == o2), "" );
+    static_assert (   o3 == o3 , "" );
+    static_assert ( !(o3 == o4), "" );
+    static_assert (   o3 == o5 , "" );
+
+    static_assert ( !(o4 == o1), "" );
+    static_assert ( !(o4 == o2), "" );
+    static_assert ( !(o4 == o3), "" );
+    static_assert (   o4 == o4 , "" );
+    static_assert ( !(o4 == o5), "" );
+
+    static_assert ( !(o5 == o1), "" );
+    static_assert ( !(o5 == o2), "" );
+    static_assert (   o5 == o3 , "" );
+    static_assert ( !(o5 == o4), "" );
+    static_assert (   o5 == o5 , "" );
+
+    }
+#endif
+}
diff --git a/final/test/utilities/optional/optional.relops/less_than.pass.cpp b/final/test/utilities/optional/optional.relops/less_than.pass.cpp
new file mode 100644
index 0000000..8d70e92
--- /dev/null
+++ b/final/test/utilities/optional/optional.relops/less_than.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator< (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef optional<X> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2;     // disengaged
+    constexpr O o3{1};  // engaged
+    constexpr O o4{2};  // engaged
+    constexpr O o5{1};  // engaged
+    
+    static_assert ( !(o1 < o1), "" );
+    static_assert ( !(o1 < o2), "" );
+    static_assert (   o1 < o3 , "" );
+    static_assert (   o1 < o4 , "" );
+    static_assert (   o1 < o5 , "" );
+
+    static_assert ( !(o2 < o1), "" );
+    static_assert ( !(o2 < o2), "" );
+    static_assert (   o2 < o3 , "" );
+    static_assert (   o2 < o4 , "" );
+    static_assert (   o2 < o5 , "" );
+
+    static_assert ( !(o3 < o1), "" );
+    static_assert ( !(o3 < o2), "" );
+    static_assert ( !(o3 < o3), "" );
+    static_assert (   o3 < o4 , "" );
+    static_assert ( !(o3 < o5), "" );
+
+    static_assert ( !(o4 < o1), "" );
+    static_assert ( !(o4 < o2), "" );
+    static_assert ( !(o4 < o3), "" );
+    static_assert ( !(o4 < o4), "" );
+    static_assert ( !(o4 < o5), "" );
+
+    static_assert ( !(o5 < o1), "" );
+    static_assert ( !(o5 < o2), "" );
+    static_assert ( !(o5 < o3), "" );
+    static_assert (   o5 < o4 , "" );
+    static_assert ( !(o5 < o5), "" );
+    }
+#endif
+}
diff --git a/final/test/utilities/optional/optional.specalg/make_optional.pass.cpp b/final/test/utilities/optional/optional.specalg/make_optional.pass.cpp
new file mode 100644
index 0000000..cc95e61
--- /dev/null
+++ b/final/test/utilities/optional/optional.specalg/make_optional.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T>
+//   constexpr
+//   optional<typename decay<T>::type>
+//   make_optional(T&& v);
+
+#include <experimental/optional>
+#include <string>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+    using std::experimental::make_optional;
+
+    {
+        optional<int> opt = make_optional(2);
+        assert(*opt == 2);
+    }
+    {
+        std::string s("123");
+        optional<std::string> opt = make_optional(s);
+        assert(*opt == s);
+    }
+    {
+        std::string s("123");
+        optional<std::string> opt = make_optional(std::move(s));
+        assert(*opt == "123");
+        assert(s.empty());
+    }
+    {
+        std::unique_ptr<int> s(new int(3));
+        optional<std::unique_ptr<int>> opt = make_optional(std::move(s));
+        assert(**opt == 3);
+        assert(s == nullptr);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.specalg/swap.pass.cpp b/final/test/utilities/optional/optional.specalg/swap.pass.cpp
new file mode 100644
index 0000000..e31d217
--- /dev/null
+++ b/final/test/utilities/optional/optional.specalg/swap.pass.cpp
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> void swap(optional<T>& x, optional<T>& y)
+//     noexcept(noexcept(x.swap(y)));
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+class X
+{
+    int i_;
+public:
+    static unsigned dtor_called;
+    X(int i) : i_(i) {}
+    X(X&& x) = default;
+    X& operator=(X&&) = default;
+    ~X() {++dtor_called;}
+
+    friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
+};
+
+unsigned X::dtor_called = 0;
+
+class Y
+{
+    int i_;
+public:
+    static unsigned dtor_called;
+    Y(int i) : i_(i) {}
+    Y(Y&&) = default;
+    ~Y() {++dtor_called;}
+
+    friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
+    friend void swap(Y& x, Y& y) {std::swap(x.i_, y.i_);}
+};
+
+unsigned Y::dtor_called = 0;
+
+class Z
+{
+    int i_;
+public:
+    Z(int i) : i_(i) {}
+    Z(Z&&) {throw 7;}
+
+    friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
+    friend void swap(Z& x, Z& y) {throw 6;}
+};
+
+
+#endif  // _LIBCPP_STD_VER > 11
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+        optional<int> opt1;
+        optional<int> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        swap(opt1, opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<int> opt1(1);
+        optional<int> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        swap(opt1, opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<int> opt1;
+        optional<int> opt2(2);
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        swap(opt1, opt2);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<int> opt1(1);
+        optional<int> opt2(2);
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        swap(opt1, opt2);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<X> opt1;
+        optional<X> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        swap(opt1, opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        assert(X::dtor_called == 0);
+    }
+    {
+        optional<X> opt1(1);
+        optional<X> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        X::dtor_called = 0;
+        swap(opt1, opt2);
+        assert(X::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<X> opt1;
+        optional<X> opt2(2);
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        X::dtor_called = 0;
+        swap(opt1, opt2);
+        assert(X::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<X> opt1(1);
+        optional<X> opt2(2);
+        static_assert(noexcept(swap(opt1, opt2)) == true, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        X::dtor_called = 0;
+        swap(opt1, opt2);
+        assert(X::dtor_called == 1);  // from inside std::swap
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<Y> opt1;
+        optional<Y> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        swap(opt1, opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        assert(Y::dtor_called == 0);
+    }
+    {
+        optional<Y> opt1(1);
+        optional<Y> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        Y::dtor_called = 0;
+        swap(opt1, opt2);
+        assert(Y::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<Y> opt1;
+        optional<Y> opt2(2);
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        Y::dtor_called = 0;
+        swap(opt1, opt2);
+        assert(Y::dtor_called == 1);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<Y> opt1(1);
+        optional<Y> opt2(2);
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        Y::dtor_called = 0;
+        swap(opt1, opt2);
+        assert(Y::dtor_called == 0);
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 2);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 1);
+    }
+    {
+        optional<Z> opt1;
+        optional<Z> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+        swap(opt1, opt2);
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<Z> opt1;
+        opt1.emplace(1);
+        optional<Z> opt2;
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+        try
+        {
+            swap(opt1, opt2);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 7);
+        }
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == false);
+    }
+    {
+        optional<Z> opt1;
+        optional<Z> opt2;
+        opt2.emplace(2);
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        try
+        {
+            swap(opt1, opt2);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 7);
+        }
+        assert(static_cast<bool>(opt1) == false);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+    }
+    {
+        optional<Z> opt1;
+        opt1.emplace(1);
+        optional<Z> opt2;
+        opt2.emplace(2);
+        static_assert(noexcept(swap(opt1, opt2)) == false, "");
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+        try
+        {
+            swap(opt1, opt2);
+            assert(false);
+        }
+        catch (int i)
+        {
+            assert(i == 6);
+        }
+        assert(static_cast<bool>(opt1) == true);
+        assert(*opt1 == 1);
+        assert(static_cast<bool>(opt2) == true);
+        assert(*opt2 == 2);
+    }
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp b/final/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp
new file mode 100644
index 0000000..60836ae
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_const_in_place_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) in_place_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+    using std::experimental::in_place_t;
+    using std::experimental::in_place;
+
+    optional<const in_place_t> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp b/final/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp
new file mode 100644
index 0000000..9a4ba1a
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_const_lvalue_ref.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for a
+// reference type is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+
+    optional<const int&> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp b/final/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp
new file mode 100644
index 0000000..f6220bd
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_const_nullopt_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) null_opt_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+    using std::experimental::nullopt_t;
+    using std::experimental::nullopt;
+
+    optional<const nullopt_t> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp b/final/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
new file mode 100644
index 0000000..12f291f
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) in_place_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+    using std::experimental::in_place_t;
+    using std::experimental::in_place;
+
+    optional<in_place_t> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp b/final/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp
new file mode 100644
index 0000000..7e6697f
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_includes_initializer_list.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// #include <initializer_list>
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+
+    std::initializer_list<int> list;
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp b/final/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp
new file mode 100644
index 0000000..850df34
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_lvalue_ref.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for a
+// reference type is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+
+    optional<int&> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp b/final/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp
new file mode 100644
index 0000000..20955ac
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_nullopt_t.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for
+// (possibly cv-qualified) null_opt_t is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+    using std::experimental::nullopt_t;
+    using std::experimental::nullopt;
+
+    optional<nullopt_t> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp b/final/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp
new file mode 100644
index 0000000..d773e99
--- /dev/null
+++ b/final/test/utilities/optional/optional.syn/optional_rvalue_ref.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// A program that necessitates the instantiation of template optional for a
+// reference type is ill-formed.
+
+#include <experimental/optional>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    using std::experimental::optional;
+
+    optional<int&&> opt;
+#else
+#error
+#endif  // _LIBCPP_STD_VER > 11
+}
diff --git a/final/test/utilities/optional/version.pass.cpp b/final/test/utilities/optional/version.pass.cpp
new file mode 100644
index 0000000..585b7a2
--- /dev/null
+++ b/final/test/utilities/optional/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+#include <experimental/optional>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp
new file mode 100644
index 0000000..e4ced32
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_add.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_add
+
+#include <ratio>
+
+int main()
+{
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp
new file mode 100644
index 0000000..a537f02
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_add.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_add
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 2 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 3 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<-1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, -2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<-1, 1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, -1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<56987354, 467584654> R1;
+    typedef std::ratio<544668, 22145> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 127970191639601LL && R::den == 5177331081415LL, "");
+    }
+    {
+    typedef std::ratio<0> R1;
+    typedef std::ratio<0> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 0 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<1> R1;
+    typedef std::ratio<0> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<0> R1;
+    typedef std::ratio<1> R2;
+    typedef std::ratio_add<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 1, "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp
new file mode 100644
index 0000000..bdbcda3
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_divide.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_divide
+
+#include <ratio>
+
+int main()
+{
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<1, 2> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp
new file mode 100644
index 0000000..49b55e7
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_divide.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_divide
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<-1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, -2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<-1, 1> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, -1> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<56987354, 467584654> R1;
+    typedef std::ratio<544668, 22145> R2;
+    typedef std::ratio_divide<R1, R2>::type R;
+    static_assert(R::num == 630992477165LL && R::den == 127339199162436LL, "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp
new file mode 100644
index 0000000..81acc14
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_multiply.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_multiply
+
+#include <ratio>
+
+int main()
+{
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<2, 1> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp
new file mode 100644
index 0000000..ccf15e0
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_multiply.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_multiply
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<-1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, -2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<-1, 1> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, -1> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<56987354, 467584654> R1;
+    typedef std::ratio<544668, 22145> R2;
+    typedef std::ratio_multiply<R1, R2>::type R;
+    static_assert(R::num == 15519594064236LL && R::den == 5177331081415LL, "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp
new file mode 100644
index 0000000..b883143
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_subtract.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_subtract
+
+#include <ratio>
+
+int main()
+{
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+}
diff --git a/final/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp b/final/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp
new file mode 100644
index 0000000..33efd90
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.arithmetic/ratio_subtract.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_subtract
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == 0 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<-1, 2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == -3 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, -2> R1;
+    typedef std::ratio<1, 1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == -3 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<-1, 1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == 3 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<1, 2> R1;
+    typedef std::ratio<1, -1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == 3 && R::den == 2, "");
+    }
+    {
+    typedef std::ratio<56987354, 467584654> R1;
+    typedef std::ratio<544668, 22145> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == -126708206685271LL && R::den == 5177331081415LL, "");
+    }
+    {
+    typedef std::ratio<0> R1;
+    typedef std::ratio<0> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == 0 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<1> R1;
+    typedef std::ratio<0> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == 1 && R::den == 1, "");
+    }
+    {
+    typedef std::ratio<0> R1;
+    typedef std::ratio<1> R2;
+    typedef std::ratio_subtract<R1, R2>::type R;
+    static_assert(R::num == -1 && R::den == 1, "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp b/final/test/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
new file mode 100644
index 0000000..78027f7
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_equal
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    static_assert((std::ratio_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((std::ratio_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, -1> R2;
+    static_assert((!std::ratio_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((!std::ratio_equal<R1, R2>::value), "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp b/final/test/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
new file mode 100644
index 0000000..9182a9e
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_greater
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    static_assert((!std::ratio_greater<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_greater<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_greater<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((!std::ratio_greater<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, -1> R2;
+    static_assert((std::ratio_greater<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_greater<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_greater<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((std::ratio_greater<R1, R2>::value), "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp b/final/test/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
new file mode 100644
index 0000000..a1f5a18
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_greater_equal
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, -1> R2;
+    static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_greater_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((std::ratio_greater_equal<R1, R2>::value), "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.comparison/ratio_less.pass.cpp b/final/test/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
new file mode 100644
index 0000000..db53ab0
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.comparison/ratio_less.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_less
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, -1> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2;
+    static_assert((std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2;
+    static_assert((std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2;
+    static_assert((std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<641981, 1339063> R1;
+    typedef std::ratio<1291640, 2694141LL> R2;
+    static_assert((!std::ratio_less<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1291640, 2694141LL> R1;
+    typedef std::ratio<641981, 1339063> R2;
+    static_assert((std::ratio_less<R1, R2>::value), "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp b/final/test/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
new file mode 100644
index 0000000..5b148f0
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_less_equal
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    static_assert((std::ratio_less_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_less_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_less_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((std::ratio_less_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, -1> R2;
+    static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_less_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((!std::ratio_less_equal<R1, R2>::value), "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp b/final/test/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
new file mode 100644
index 0000000..ebf9307
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio_not_equal
+
+#include <ratio>
+
+int main()
+{
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, 1> R2;
+    static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((!std::ratio_not_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 1> R1;
+    typedef std::ratio<1, -1> R2;
+    static_assert((std::ratio_not_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_not_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1;
+    typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2;
+    static_assert((std::ratio_not_equal<R1, R2>::value), "");
+    }
+    {
+    typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1;
+    typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2;
+    static_assert((std::ratio_not_equal<R1, R2>::value), "");
+    }
+}
diff --git a/final/test/utilities/ratio/ratio.ratio/ratio.pass.cpp b/final/test/utilities/ratio/ratio.ratio/ratio.pass.cpp
new file mode 100644
index 0000000..f942c96
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.ratio/ratio.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio:  The static data members num and den shall have thcommon
+//    divisor of the absolute values of N and D:
+
+#include <ratio>
+
+template <long long N, long long D, long long eN, long long eD>
+void test()
+{
+    static_assert((std::ratio<N, D>::num == eN), "");
+    static_assert((std::ratio<N, D>::den == eD), "");
+}
+
+int main()
+{
+    test<1, 1, 1, 1>();
+    test<1, 10, 1, 10>();
+    test<10, 10, 1, 1>();
+    test<10, 1, 10, 1>();
+    test<12, 4, 3, 1>();
+    test<12, -4, -3, 1>();
+    test<-12, 4, -3, 1>();
+    test<-12, -4, 3, 1>();
+    test<4, 12, 1, 3>();
+    test<4, -12, -1, 3>();
+    test<-4, 12, -1, 3>();
+    test<-4, -12, 1, 3>();
+    test<222, 333, 2, 3>();
+    test<222, -333, -2, 3>();
+    test<-222, 333, -2, 3>();
+    test<-222, -333, 2, 3>();
+    test<0x7FFFFFFFFFFFFFFFLL, 127, 72624976668147841LL, 1>();
+    test<-0x7FFFFFFFFFFFFFFFLL, 127, -72624976668147841LL, 1>();
+    test<0x7FFFFFFFFFFFFFFFLL, -127, -72624976668147841LL, 1>();
+    test<-0x7FFFFFFFFFFFFFFFLL, -127, 72624976668147841LL, 1>();
+}
diff --git a/final/test/utilities/ratio/ratio.ratio/ratio1.fail.cpp b/final/test/utilities/ratio/ratio.ratio/ratio1.fail.cpp
new file mode 100644
index 0000000..e6dbf71
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.ratio/ratio1.fail.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio:  The template argument D shall not be zero
+
+#include <ratio>
+#include <cstdint>
+
+int main()
+{
+    const std::intmax_t t1 = std::ratio<1, 0>::num;
+}
diff --git a/final/test/utilities/ratio/ratio.ratio/ratio2.fail.cpp b/final/test/utilities/ratio/ratio.ratio/ratio2.fail.cpp
new file mode 100644
index 0000000..753e79a
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.ratio/ratio2.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio:  the absolute values of the template arguments N and D
+//               shall be representable by type intmax_t.
+
+#include <ratio>
+#include <cstdint>
+
+int main()
+{
+    const std::intmax_t t1 = std::ratio<0x8000000000000000ULL, 1>::num;
+}
diff --git a/final/test/utilities/ratio/ratio.ratio/ratio3.fail.cpp b/final/test/utilities/ratio/ratio.ratio/ratio3.fail.cpp
new file mode 100644
index 0000000..f4b4ab9
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.ratio/ratio3.fail.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio:  the absolute values of the template arguments N and D
+//               shall be representable by type intmax_t.
+
+#include <ratio>
+#include <cstdint>
+
+int main()
+{
+    const std::intmax_t t1 = std::ratio<1, 0x8000000000000000ULL>::num;
+}
diff --git a/final/test/utilities/ratio/ratio.si/nothing_to_do.pass.cpp b/final/test/utilities/ratio/ratio.si/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/ratio/ratio.si/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/ratio/typedefs.pass.cpp b/final/test/utilities/ratio/typedefs.pass.cpp
new file mode 100644
index 0000000..5ab4c74
--- /dev/null
+++ b/final/test/utilities/ratio/typedefs.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test ratio typedef's
+
+#include <ratio>
+
+int main()
+{
+    static_assert(std::atto::num == 1 && std::atto::den == 1000000000000000000ULL, "");
+    static_assert(std::femto::num == 1 && std::femto::den == 1000000000000000ULL, "");
+    static_assert(std::pico::num == 1 && std::pico::den == 1000000000000ULL, "");
+    static_assert(std::nano::num == 1 && std::nano::den == 1000000000ULL, "");
+    static_assert(std::micro::num == 1 && std::micro::den == 1000000ULL, "");
+    static_assert(std::milli::num == 1 && std::milli::den == 1000ULL, "");
+    static_assert(std::centi::num == 1 && std::centi::den == 100ULL, "");
+    static_assert(std::deci::num == 1 && std::deci::den == 10ULL, "");
+    static_assert(std::deca::num == 10ULL && std::deca::den == 1, "");
+    static_assert(std::hecto::num == 100ULL && std::hecto::den == 1, "");
+    static_assert(std::kilo::num == 1000ULL && std::kilo::den == 1, "");
+    static_assert(std::mega::num == 1000000ULL && std::mega::den == 1, "");
+    static_assert(std::giga::num == 1000000000ULL && std::giga::den == 1, "");
+    static_assert(std::tera::num == 1000000000000ULL && std::tera::den == 1, "");
+    static_assert(std::peta::num == 1000000000000000ULL && std::peta::den == 1, "");
+    static_assert(std::exa::num == 1000000000000000000ULL && std::exa::den == 1, "");
+}
diff --git a/final/test/utilities/ratio/version.pass.cpp b/final/test/utilities/ratio/version.pass.cpp
new file mode 100644
index 0000000..26c455f
--- /dev/null
+++ b/final/test/utilities/ratio/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <ratio>
+
+#include <ratio>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp b/final/test/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
new file mode 100644
index 0000000..7fe78ba
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// template <class charT>
+//     explicit bitset(const charT* str,
+//                     typename basic_string<charT>::size_type n = basic_string<charT>::npos,
+//                     charT zero = charT('0'), charT one = charT('1'));
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_char_pointer_ctor()
+{
+    {
+    try
+    {
+        std::bitset<N> v("xxx1010101010xxxx");
+        assert(false);
+    }
+    catch (std::invalid_argument&)
+    {
+    }
+    }
+
+    {
+    const char str[] ="1010101010";
+    std::bitset<N> v(str);
+    std::size_t M = std::min<std::size_t>(N, 10);
+    for (std::size_t i = 0; i < M; ++i)
+        assert(v[i] == (str[M - 1 - i] == '1'));
+    for (std::size_t i = 10; i < N; ++i)
+        assert(v[i] == false);
+    }
+}
+
+int main()
+{
+    test_char_pointer_ctor<0>();
+    test_char_pointer_ctor<1>();
+    test_char_pointer_ctor<31>();
+    test_char_pointer_ctor<32>();
+    test_char_pointer_ctor<33>();
+    test_char_pointer_ctor<63>();
+    test_char_pointer_ctor<64>();
+    test_char_pointer_ctor<65>();
+    test_char_pointer_ctor<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.cons/default.pass.cpp b/final/test/utilities/template.bitset/bitset.cons/default.pass.cpp
new file mode 100644
index 0000000..bd5ca7e
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.cons/default.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test default ctor
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_default_ctor()
+{
+    {
+    _LIBCPP_CONSTEXPR std::bitset<N> v1;
+    assert(v1.size() == N);
+    for (std::size_t i = 0; i < N; ++i)
+        assert(v1[i] == false);
+    }
+}
+
+int main()
+{
+    test_default_ctor<0>();
+    test_default_ctor<1>();
+    test_default_ctor<31>();
+    test_default_ctor<32>();
+    test_default_ctor<33>();
+    test_default_ctor<63>();
+    test_default_ctor<64>();
+    test_default_ctor<65>();
+    test_default_ctor<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp b/final/test/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
new file mode 100644
index 0000000..bcee50c
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset(string, pos, n, zero, one);
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_string_ctor()
+{
+    {
+    try
+    {
+        std::string str("xxx1010101010xxxx");
+        std::bitset<N> v(str, str.size()+1, 10);
+        assert(false);
+    }
+    catch (std::out_of_range&)
+    {
+    }
+    }
+
+    {
+    try
+    {
+        std::string str("xxx1010101010xxxx");
+        std::bitset<N> v(str, 2, 10);
+        assert(false);
+    }
+    catch (std::invalid_argument&)
+    {
+    }
+    }
+
+    {
+    std::string str("xxx1010101010xxxx");
+    std::bitset<N> v(str, 3, 10);
+    std::size_t M = std::min<std::size_t>(N, 10);
+    for (std::size_t i = 0; i < M; ++i)
+        assert(v[i] == (str[3 + M - 1 - i] == '1'));
+    for (std::size_t i = 10; i < N; ++i)
+        assert(v[i] == false);
+    }
+
+    {
+    try
+    {
+        std::string str("xxxbababababaxxxx");
+        std::bitset<N> v(str, 2, 10, 'a', 'b');
+        assert(false);
+    }
+    catch (std::invalid_argument&)
+    {
+    }
+    }
+
+    {
+    std::string str("xxxbababababaxxxx");
+    std::bitset<N> v(str, 3, 10, 'a', 'b');
+    std::size_t M = std::min<std::size_t>(N, 10);
+    for (std::size_t i = 0; i < M; ++i)
+        assert(v[i] == (str[3 + M - 1 - i] == 'b'));
+    for (std::size_t i = 10; i < N; ++i)
+        assert(v[i] == false);
+    }
+}
+
+int main()
+{
+    test_string_ctor<0>();
+    test_string_ctor<1>();
+    test_string_ctor<31>();
+    test_string_ctor<32>();
+    test_string_ctor<33>();
+    test_string_ctor<63>();
+    test_string_ctor<64>();
+    test_string_ctor<65>();
+    test_string_ctor<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp b/final/test/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
new file mode 100644
index 0000000..023fedc
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset(unsigned long long val);
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_val_ctor()
+{
+    {
+    _LIBCPP_CONSTEXPR std::bitset<N> v(0xAAAAAAAAAAAAAAAAULL);
+    assert(v.size() == N);
+    unsigned M = std::min<std::size_t>(N, 64);
+    for (std::size_t i = 0; i < M; ++i)
+        assert(v[i] == (i & 1));
+    for (std::size_t i = M; i < N; ++i)
+        assert(v[i] == false);
+    }
+}
+
+int main()
+{
+    test_val_ctor<0>();
+    test_val_ctor<1>();
+    test_val_ctor<31>();
+    test_val_ctor<32>();
+    test_val_ctor<33>();
+    test_val_ctor<63>();
+    test_val_ctor<64>();
+    test_val_ctor<65>();
+    test_val_ctor<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.hash/bitset.pass.cpp b/final/test/utilities/template.bitset/bitset.hash/bitset.pass.cpp
new file mode 100644
index 0000000..b1b24f9
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.hash/bitset.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+//     : public unary_function<T, size_t>
+// {
+//     size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <bitset>
+#include <cassert>
+#include <type_traits>
+
+template <std::size_t N>
+void
+test()
+{
+    typedef std::bitset<N> T;
+    typedef std::hash<T> H;
+    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+                                   H>::value), "");
+    H h;
+    T bs(static_cast<unsigned long long>(N));
+    assert(h(bs) == N);
+}
+
+int main()
+{
+    test<0>();
+    test<10>();
+    test<100>();
+    test<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/all.pass.cpp b/final/test/utilities/template.bitset/bitset.members/all.pass.cpp
new file mode 100644
index 0000000..5387b73
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/all.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool all() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_all()
+{
+    std::bitset<N> v;
+    v.reset();
+    assert(v.all() == (N == 0));
+    v.set();
+    assert(v.all() == true);
+    if (N > 1)
+    {
+        v[N/2] = false;
+        assert(v.all() == false);
+    }
+}
+
+int main()
+{
+    test_all<0>();
+    test_all<1>();
+    test_all<31>();
+    test_all<32>();
+    test_all<33>();
+    test_all<63>();
+    test_all<64>();
+    test_all<65>();
+    test_all<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/any.pass.cpp b/final/test/utilities/template.bitset/bitset.members/any.pass.cpp
new file mode 100644
index 0000000..aa6384a
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/any.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool any() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_any()
+{
+    std::bitset<N> v;
+    v.reset();
+    assert(v.any() == false);
+    v.set();
+    assert(v.any() == (N != 0));
+    if (N > 1)
+    {
+        v[N/2] = false;
+        assert(v.any() == true);
+        v.reset();
+        v[N/2] = true;
+        assert(v.any() == true);
+    }
+}
+
+int main()
+{
+    test_any<0>();
+    test_any<1>();
+    test_any<31>();
+    test_any<32>();
+    test_any<33>();
+    test_any<63>();
+    test_any<64>();
+    test_any<65>();
+    test_any<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/count.pass.cpp b/final/test/utilities/template.bitset/bitset.members/count.pass.cpp
new file mode 100644
index 0000000..fb9ce64
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/count.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test size_t count() const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_count()
+{
+    const std::bitset<N> v = make_bitset<N>();
+    std::size_t c1 = v.count();
+    std::size_t c2 = 0;
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            ++c2;
+    assert(c1 == c2);
+}
+
+int main()
+{
+    test_count<0>();
+    test_count<1>();
+    test_count<31>();
+    test_count<32>();
+    test_count<33>();
+    test_count<63>();
+    test_count<64>();
+    test_count<65>();
+    test_count<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp b/final/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp
new file mode 100644
index 0000000..6c4f5c6
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/flip_all.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& flip();
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_flip_all()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = v1;
+    v2.flip();
+    for (std::size_t i = 0; i < N; ++i)
+        assert(v2[i] == ~v1[i]);
+}
+
+int main()
+{
+    test_flip_all<0>();
+    test_flip_all<1>();
+    test_flip_all<31>();
+    test_flip_all<32>();
+    test_flip_all<33>();
+    test_flip_all<63>();
+    test_flip_all<64>();
+    test_flip_all<65>();
+    test_flip_all<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/final/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp
new file mode 100644
index 0000000..3e09b20
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/flip_one.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& flip(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_flip_one()
+{
+    std::bitset<N> v = make_bitset<N>();
+    try
+    {
+        v.flip(50);
+        bool b = v[50];
+        if (50 >= v.size())
+            assert(false);
+        assert(v[50] == b);
+        v.flip(50);
+        assert(v[50] != b);
+        v.flip(50);
+        assert(v[50] == b);
+    }
+    catch (std::out_of_range&)
+    {
+    }
+}
+
+int main()
+{
+    test_flip_one<0>();
+    test_flip_one<1>();
+    test_flip_one<31>();
+    test_flip_one<32>();
+    test_flip_one<33>();
+    test_flip_one<63>();
+    test_flip_one<64>();
+    test_flip_one<65>();
+    test_flip_one<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/index.pass.cpp b/final/test/utilities/template.bitset/bitset.members/index.pass.cpp
new file mode 100644
index 0000000..b96aaa5
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/index.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>::reference operator[](size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_index_const()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    if (N > 0)
+    {
+        assert(v1[N/2] == v1.test(N/2));
+        typename std::bitset<N>::reference r = v1[N/2];
+        assert(r == v1.test(N/2));
+        typename std::bitset<N>::reference r2 = v1[N/2];
+        r = r2;
+        assert(r == v1.test(N/2));
+        r = false;
+        assert(r == false);
+        assert(v1.test(N/2) == false);
+        r = true;
+        assert(r == true);
+        assert(v1.test(N/2) == true);
+        bool b = ~r;
+        assert(r == true);
+        assert(v1.test(N/2) == true);
+        assert(b == false);
+        r.flip();
+        assert(r == false);
+        assert(v1.test(N/2) == false);
+    }
+}
+
+int main()
+{
+    test_index_const<0>();
+    test_index_const<1>();
+    test_index_const<31>();
+    test_index_const<32>();
+    test_index_const<33>();
+    test_index_const<63>();
+    test_index_const<64>();
+    test_index_const<65>();
+    test_index_const<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/index_const.pass.cpp b/final/test/utilities/template.bitset/bitset.members/index_const.pass.cpp
new file mode 100644
index 0000000..e3c28c6
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/index_const.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test constexpr bool operator[](size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_index_const()
+{
+    const std::bitset<N> v1 = make_bitset<N>();
+    if (N > 0)
+    {
+        assert(v1[N/2] == v1.test(N/2));
+    }
+}
+
+int main()
+{
+    test_index_const<0>();
+    test_index_const<1>();
+    test_index_const<31>();
+    test_index_const<32>();
+    test_index_const<33>();
+    test_index_const<63>();
+    test_index_const<64>();
+    test_index_const<65>();
+    test_index_const<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp b/final/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp
new file mode 100644
index 0000000..7fe9fa7
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/left_shift.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator<<(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_left_shift()
+{
+    for (std::size_t s = 0; s <= N+1; ++s)
+    {
+        std::bitset<N> v1 = make_bitset<N>();
+        std::bitset<N> v2 = v1;
+        assert((v1 <<= s) == (v2 << s));
+    }
+}
+
+int main()
+{
+    test_left_shift<0>();
+    test_left_shift<1>();
+    test_left_shift<31>();
+    test_left_shift<32>();
+    test_left_shift<33>();
+    test_left_shift<63>();
+    test_left_shift<64>();
+    test_left_shift<65>();
+    test_left_shift<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp b/final/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
new file mode 100644
index 0000000..bed3e28
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/left_shift_eq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator<<=(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_left_shift()
+{
+    for (std::size_t s = 0; s <= N+1; ++s)
+    {
+        std::bitset<N> v1 = make_bitset<N>();
+        std::bitset<N> v2 = v1;
+        v1 <<= s;
+        for (std::size_t i = 0; i < N; ++i)
+            if (i < s)
+                assert(v1[i] == 0);
+            else
+                assert(v1[i] == v2[i-s]);
+    }
+}
+
+int main()
+{
+    test_left_shift<0>();
+    test_left_shift<1>();
+    test_left_shift<31>();
+    test_left_shift<32>();
+    test_left_shift<33>();
+    test_left_shift<63>();
+    test_left_shift<64>();
+    test_left_shift<65>();
+    test_left_shift<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/none.pass.cpp b/final/test/utilities/template.bitset/bitset.members/none.pass.cpp
new file mode 100644
index 0000000..b65c636
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/none.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bool none() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_none()
+{
+    std::bitset<N> v;
+    v.reset();
+    assert(v.none() == true);
+    v.set();
+    assert(v.none() == (N == 0));
+    if (N > 1)
+    {
+        v[N/2] = false;
+        assert(v.none() == false);
+        v.reset();
+        v[N/2] = true;
+        assert(v.none() == false);
+    }
+}
+
+int main()
+{
+    test_none<0>();
+    test_none<1>();
+    test_none<31>();
+    test_none<32>();
+    test_none<33>();
+    test_none<63>();
+    test_none<64>();
+    test_none<65>();
+    test_none<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/not_all.pass.cpp b/final/test/utilities/template.bitset/bitset.members/not_all.pass.cpp
new file mode 100644
index 0000000..2f8f711
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/not_all.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator~() const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_not_all()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = ~v1;
+    for (std::size_t i = 0; i < N; ++i)
+        assert(v2[i] == ~v1[i]);
+}
+
+int main()
+{
+    test_not_all<0>();
+    test_not_all<1>();
+    test_not_all<31>();
+    test_not_all<32>();
+    test_not_all<33>();
+    test_not_all<63>();
+    test_not_all<64>();
+    test_not_all<65>();
+    test_not_all<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp b/final/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
new file mode 100644
index 0000000..b599ec3
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/op_and_eq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator&=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_op_and_eq()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = make_bitset<N>();
+    std::bitset<N> v3 = v1;
+    v1 &= v2;
+    for (std::size_t i = 0; i < N; ++i)
+        assert(v1[i] == (v3[i] && v2[i]));
+}
+
+int main()
+{
+    test_op_and_eq<0>();
+    test_op_and_eq<1>();
+    test_op_and_eq<31>();
+    test_op_and_eq<32>();
+    test_op_and_eq<33>();
+    test_op_and_eq<63>();
+    test_op_and_eq<64>();
+    test_op_and_eq<65>();
+    test_op_and_eq<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp b/final/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
new file mode 100644
index 0000000..5f6cf3d
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/op_eq_eq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// bool operator==(const bitset<N>& rhs) const;
+// bool operator!=(const bitset<N>& rhs) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_equality()
+{
+    const std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = v1;
+    assert(v1 == v2);
+    if (N > 0)
+    {
+        v2[N/2].flip();
+        assert(v1 != v2);
+    }
+}
+
+int main()
+{
+    test_equality<0>();
+    test_equality<1>();
+    test_equality<31>();
+    test_equality<32>();
+    test_equality<33>();
+    test_equality<63>();
+    test_equality<64>();
+    test_equality<65>();
+    test_equality<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp b/final/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
new file mode 100644
index 0000000..6e63879
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/op_or_eq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator|=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_op_or_eq()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = make_bitset<N>();
+    std::bitset<N> v3 = v1;
+    v1 |= v2;
+    for (std::size_t i = 0; i < N; ++i)
+        assert(v1[i] == (v3[i] || v2[i]));
+}
+
+int main()
+{
+    test_op_or_eq<0>();
+    test_op_or_eq<1>();
+    test_op_or_eq<31>();
+    test_op_or_eq<32>();
+    test_op_or_eq<33>();
+    test_op_or_eq<63>();
+    test_op_or_eq<64>();
+    test_op_or_eq<65>();
+    test_op_or_eq<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp b/final/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
new file mode 100644
index 0000000..e68a641
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/op_xor_eq.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator^=(const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_op_xor_eq()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = make_bitset<N>();
+    std::bitset<N> v3 = v1;
+    v1 ^= v2;
+    for (std::size_t i = 0; i < N; ++i)
+        assert(v1[i] == (v3[i] != v2[i]));
+}
+
+int main()
+{
+    test_op_xor_eq<0>();
+    test_op_xor_eq<1>();
+    test_op_xor_eq<31>();
+    test_op_xor_eq<32>();
+    test_op_xor_eq<33>();
+    test_op_xor_eq<63>();
+    test_op_xor_eq<64>();
+    test_op_xor_eq<65>();
+    test_op_xor_eq<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp b/final/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp
new file mode 100644
index 0000000..ee44d92
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/reset_all.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& reset();
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_reset_all()
+{
+    std::bitset<N> v;
+    v.set();
+    v.reset();
+    for (std::size_t i = 0; i < N; ++i)
+        assert(!v[i]);
+}
+
+int main()
+{
+    test_reset_all<0>();
+    test_reset_all<1>();
+    test_reset_all<31>();
+    test_reset_all<32>();
+    test_reset_all<33>();
+    test_reset_all<63>();
+    test_reset_all<64>();
+    test_reset_all<65>();
+    test_reset_all<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/final/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp
new file mode 100644
index 0000000..ebaa9e7
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/reset_one.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& reset(size_t pos);
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_reset_one()
+{
+    std::bitset<N> v;
+    try
+    {
+        v.set();
+        v.reset(50);
+        if (50 >= v.size())
+            assert(false);
+        for (unsigned i = 0; i < v.size(); ++i)
+            if (i == 50)
+                assert(!v[i]);
+            else
+                assert(v[i]);
+    }
+    catch (std::out_of_range&)
+    {
+    }
+}
+
+int main()
+{
+    test_reset_one<0>();
+    test_reset_one<1>();
+    test_reset_one<31>();
+    test_reset_one<32>();
+    test_reset_one<33>();
+    test_reset_one<63>();
+    test_reset_one<64>();
+    test_reset_one<65>();
+    test_reset_one<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp b/final/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp
new file mode 100644
index 0000000..87fcc28
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/right_shift.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator>>(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_right_shift()
+{
+    for (std::size_t s = 0; s <= N+1; ++s)
+    {
+        std::bitset<N> v1 = make_bitset<N>();
+        std::bitset<N> v2 = v1;
+        assert((v1 >>= s) == (v2 >> s));
+    }
+}
+
+int main()
+{
+    test_right_shift<0>();
+    test_right_shift<1>();
+    test_right_shift<31>();
+    test_right_shift<32>();
+    test_right_shift<33>();
+    test_right_shift<63>();
+    test_right_shift<64>();
+    test_right_shift<65>();
+    test_right_shift<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp b/final/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
new file mode 100644
index 0000000..1dd89c1
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/right_shift_eq.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& operator<<=(size_t pos);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_right_shift()
+{
+    for (std::size_t s = 0; s <= N+1; ++s)
+    {
+        std::bitset<N> v1 = make_bitset<N>();
+        std::bitset<N> v2 = v1;
+        v1 >>= s;
+        for (std::size_t i = 0; i < N; ++i)
+            if (i + s < N)
+                assert(v1[i] == v2[i + s]);
+            else
+                assert(v1[i] == 0);
+    }
+}
+
+int main()
+{
+    test_right_shift<0>();
+    test_right_shift<1>();
+    test_right_shift<31>();
+    test_right_shift<32>();
+    test_right_shift<33>();
+    test_right_shift<63>();
+    test_right_shift<64>();
+    test_right_shift<65>();
+    test_right_shift<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/set_all.pass.cpp b/final/test/utilities/template.bitset/bitset.members/set_all.pass.cpp
new file mode 100644
index 0000000..56454a8
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/set_all.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& set();
+
+#include <bitset>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+void test_set_all()
+{
+    std::bitset<N> v;
+    v.set();
+    for (std::size_t i = 0; i < N; ++i)
+        assert(v[i]);
+}
+
+int main()
+{
+    test_set_all<0>();
+    test_set_all<1>();
+    test_set_all<31>();
+    test_set_all<32>();
+    test_set_all<33>();
+    test_set_all<63>();
+    test_set_all<64>();
+    test_set_all<65>();
+    test_set_all<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/set_one.pass.cpp b/final/test/utilities/template.bitset/bitset.members/set_one.pass.cpp
new file mode 100644
index 0000000..116eaf3
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/set_one.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N>& set(size_t pos, bool val = true);
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_set_one()
+{
+    std::bitset<N> v;
+    try
+    {
+        v.set(50);
+        if (50 >= v.size())
+            assert(false);
+        assert(v[50]);
+    }
+    catch (std::out_of_range&)
+    {
+    }
+    try
+    {
+        v.set(50, false);
+        if (50 >= v.size())
+            assert(false);
+        assert(!v[50]);
+    }
+    catch (std::out_of_range&)
+    {
+    }
+}
+
+int main()
+{
+    test_set_one<0>();
+    test_set_one<1>();
+    test_set_one<31>();
+    test_set_one<32>();
+    test_set_one<33>();
+    test_set_one<63>();
+    test_set_one<64>();
+    test_set_one<65>();
+    test_set_one<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/size.pass.cpp b/final/test/utilities/template.bitset/bitset.members/size.pass.cpp
new file mode 100644
index 0000000..822e0a0
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/size.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test size_t count() const;
+
+#include <bitset>
+#include <cassert>
+
+template <std::size_t N>
+void test_size()
+{
+    const std::bitset<N> v;
+    assert(v.size() == N);
+}
+
+int main()
+{
+    test_size<0>();
+    test_size<1>();
+    test_size<31>();
+    test_size<32>();
+    test_size<33>();
+    test_size<63>();
+    test_size<64>();
+    test_size<65>();
+    test_size<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/test.pass.cpp b/final/test/utilities/template.bitset/bitset.members/test.pass.cpp
new file mode 100644
index 0000000..5102b46
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/test.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test constexpr bool test(size_t pos) const;
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_test()
+{
+    const std::bitset<N> v1 = make_bitset<N>();
+    try
+    {
+        bool b = v1.test(50);
+        if (50 >= v1.size())
+            assert(false);
+        assert(b == v1[50]);
+    }
+    catch (std::out_of_range&)
+    {
+    }
+}
+
+int main()
+{
+    test_test<0>();
+    test_test<1>();
+    test_test<31>();
+    test_test<32>();
+    test_test<33>();
+    test_test<63>();
+    test_test<64>();
+    test_test<65>();
+    test_test<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/to_string.pass.cpp b/final/test/utilities/template.bitset/bitset.members/to_string.pass.cpp
new file mode 100644
index 0000000..b657940
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/to_string.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// 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>
+// basic_string<charT, traits, allocator<charT> > to_string() const;
+//
+// template <class charT>
+// basic_string<charT, char_traits<charT>, allocator<charT> > to_string() const;
+//
+// basic_string<char, char_traits<char>, allocator<char> > to_string() const;
+
+#include <bitset>
+#include <string>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_to_string()
+{
+{
+    std::bitset<N> v = make_bitset<N>();
+    {
+    std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >();
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >();
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::string s = v.template to_string<char>();
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::string s = v.to_string();
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+}
+{
+    std::bitset<N> v = make_bitset<N>();
+    {
+    std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::string s = v.template to_string<char>('0');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::string s = v.to_string('0');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+}
+{
+    std::bitset<N> v = make_bitset<N>();
+    {
+    std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >('0', '1');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::wstring s = v.template to_string<wchar_t, std::char_traits<wchar_t> >('0', '1');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::string s = v.template to_string<char>('0', '1');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+    {
+    std::string s = v.to_string('0', '1');
+    for (std::size_t i = 0; i < N; ++i)
+        if (v[i])
+            assert(s[N - 1 - i] == '1');
+        else
+            assert(s[N - 1 - i] == '0');
+    }
+}
+}
+
+int main()
+{
+    test_to_string<0>();
+    test_to_string<1>();
+    test_to_string<31>();
+    test_to_string<32>();
+    test_to_string<33>();
+    test_to_string<63>();
+    test_to_string<64>();
+    test_to_string<65>();
+    test_to_string<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp b/final/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
new file mode 100644
index 0000000..27d8480
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/to_ullong.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test unsigned long long to_ullong() const;
+
+#include <bitset>
+#include <algorithm>
+#include <climits>
+#include <cassert>
+
+template <std::size_t N>
+void test_to_ullong()
+{
+    const std::size_t M = sizeof(unsigned long long) * CHAR_BIT < N ? sizeof(unsigned long long) * CHAR_BIT : N;
+    const std::size_t X = M == 0 ? sizeof(unsigned long long) * CHAR_BIT - 1 : sizeof(unsigned long long) * CHAR_BIT - M;
+    const unsigned long long max = M == 0 ? 0 : (unsigned long long)(-1) >> X;
+    unsigned long long tests[] = {0,
+                           std::min<unsigned long long>(1, max),
+                           std::min<unsigned long long>(2, max),
+                           std::min<unsigned long long>(3, max),
+                           std::min(max, max-3),
+                           std::min(max, max-2),
+                           std::min(max, max-1),
+                           max};
+    for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+        unsigned long long j = tests[i];
+        std::bitset<N> v(j);
+        assert(j == v.to_ullong());
+    }
+}
+
+int main()
+{
+    test_to_ullong<0>();
+    test_to_ullong<1>();
+    test_to_ullong<31>();
+    test_to_ullong<32>();
+    test_to_ullong<33>();
+    test_to_ullong<63>();
+    test_to_ullong<64>();
+    test_to_ullong<65>();
+    test_to_ullong<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp b/final/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
new file mode 100644
index 0000000..3ad1aba
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.members/to_ulong.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test unsigned long to_ulong() const;
+
+#include <bitset>
+#include <algorithm>
+#include <limits>
+#include <climits>
+#include <cassert>
+
+template <std::size_t N>
+void test_to_ulong()
+{
+    const std::size_t M = sizeof(unsigned long) * CHAR_BIT < N ? sizeof(unsigned long) * CHAR_BIT : N;
+    const std::size_t X = M == 0 ? sizeof(unsigned long) * CHAR_BIT - 1 : sizeof(unsigned long) * CHAR_BIT - M;
+    const std::size_t max = M == 0 ? 0 : std::size_t(std::numeric_limits<unsigned long>::max()) >> X;
+    std::size_t tests[] = {0,
+                           std::min<std::size_t>(1, max),
+                           std::min<std::size_t>(2, max),
+                           std::min<std::size_t>(3, max),
+                           std::min(max, max-3),
+                           std::min(max, max-2),
+                           std::min(max, max-1),
+                           max};
+    for (std::size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i)
+    {
+        std::size_t j = tests[i];
+        std::bitset<N> v(j);
+        assert(j == v.to_ulong());
+    }
+}
+
+int main()
+{
+    test_to_ulong<0>();
+    test_to_ulong<1>();
+    test_to_ulong<31>();
+    test_to_ulong<32>();
+    test_to_ulong<33>();
+    test_to_ulong<63>();
+    test_to_ulong<64>();
+    test_to_ulong<65>();
+    test_to_ulong<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.operators/op_and.pass.cpp b/final/test/utilities/template.bitset/bitset.operators/op_and.pass.cpp
new file mode 100644
index 0000000..751cee6
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.operators/op_and.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_op_and()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = make_bitset<N>();
+    std::bitset<N> v3 = v1;
+    assert((v1 & v2) == (v3 &= v2));;
+}
+
+int main()
+{
+    test_op_and<0>();
+    test_op_and<1>();
+    test_op_and<31>();
+    test_op_and<32>();
+    test_op_and<33>();
+    test_op_and<63>();
+    test_op_and<64>();
+    test_op_and<65>();
+    test_op_and<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.operators/op_not.pass.cpp b/final/test/utilities/template.bitset/bitset.operators/op_not.pass.cpp
new file mode 100644
index 0000000..fda5e5c
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.operators/op_not.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_op_not()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = make_bitset<N>();
+    std::bitset<N> v3 = v1;
+    assert((v1 ^ v2) == (v3 ^= v2));;
+}
+
+int main()
+{
+    test_op_not<0>();
+    test_op_not<1>();
+    test_op_not<31>();
+    test_op_not<32>();
+    test_op_not<33>();
+    test_op_not<63>();
+    test_op_not<64>();
+    test_op_not<65>();
+    test_op_not<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.operators/op_or.pass.cpp b/final/test/utilities/template.bitset/bitset.operators/op_or.pass.cpp
new file mode 100644
index 0000000..067f868
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.operators/op_or.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs);
+
+#include <bitset>
+#include <cstdlib>
+#include <cassert>
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+template <std::size_t N>
+std::bitset<N>
+make_bitset()
+{
+    std::bitset<N> v;
+    for (std::size_t i = 0; i < N; ++i)
+        v[i] = static_cast<bool>(std::rand() & 1);
+    return v;
+}
+
+template <std::size_t N>
+void test_op_or()
+{
+    std::bitset<N> v1 = make_bitset<N>();
+    std::bitset<N> v2 = make_bitset<N>();
+    std::bitset<N> v3 = v1;
+    assert((v1 | v2) == (v3 |= v2));;
+}
+
+int main()
+{
+    test_op_or<0>();
+    test_op_or<1>();
+    test_op_or<31>();
+    test_op_or<32>();
+    test_op_or<33>();
+    test_op_or<63>();
+    test_op_or<64>();
+    test_op_or<65>();
+    test_op_or<1000>();
+}
diff --git a/final/test/utilities/template.bitset/bitset.operators/stream_in.pass.cpp b/final/test/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
new file mode 100644
index 0000000..4c8afe3
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.operators/stream_in.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// template <class charT, class traits, size_t N>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
+
+#include <bitset>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::istringstream in("01011010");
+    std::bitset<8> b;
+    in >> b;
+    assert(b.to_ulong() == 0x5A);
+}
diff --git a/final/test/utilities/template.bitset/bitset.operators/stream_out.pass.cpp b/final/test/utilities/template.bitset/bitset.operators/stream_out.pass.cpp
new file mode 100644
index 0000000..05efe27
--- /dev/null
+++ b/final/test/utilities/template.bitset/bitset.operators/stream_out.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test:
+
+// template <class charT, class traits, size_t N>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
+
+#include <bitset>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+    std::ostringstream os;
+    std::bitset<8> b(0x5A);
+    os << b;
+    assert(os.str() == "01011010");
+}
diff --git a/final/test/utilities/template.bitset/includes.pass.cpp b/final/test/utilities/template.bitset/includes.pass.cpp
new file mode 100644
index 0000000..2e3c281
--- /dev/null
+++ b/final/test/utilities/template.bitset/includes.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test that <bitset> includes <cstddef>, <string>, <stdexcept> and <iosfwd>
+
+#include <bitset>
+
+#ifndef _LIBCPP_CSTDDEF
+#error <cstddef> has not been included
+#endif
+
+#ifndef _LIBCPP_STRING
+#error <string> has not been included
+#endif
+
+#ifndef _LIBCPP_STDEXCEPT
+#error <stdexcept> has not been included
+#endif
+
+#ifndef _LIBCPP_IOSFWD
+#error <iosfwd> has not been included
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/template.bitset/version.pass.cpp b/final/test/utilities/template.bitset/version.pass.cpp
new file mode 100644
index 0000000..5ae984c
--- /dev/null
+++ b/final/test/utilities/template.bitset/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <bitset>
+
+#include <bitset>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/time/clock.h b/final/test/utilities/time/clock.h
new file mode 100644
index 0000000..c72470c
--- /dev/null
+++ b/final/test/utilities/time/clock.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 CLOCK_H
+#define CLOCK_H
+
+#include <chrono>
+
+class Clock
+{
+    typedef std::chrono::nanoseconds                 duration;
+    typedef duration::rep                            rep;
+    typedef duration::period                         period;
+    typedef std::chrono::time_point<Clock, duration> time_point;
+    static const bool is_steady =                    false;
+
+    static time_point now();
+};
+
+#endif  // CLOCK_H
diff --git a/final/test/utilities/time/hours.pass.cpp b/final/test/utilities/time/hours.pass.cpp
new file mode 100644
index 0000000..e4c39f7
--- /dev/null
+++ b/final/test/utilities/time/hours.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 23 bits, ratio<3600>> hours;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::hours D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 22, "");
+    static_assert((std::is_same<Period, std::ratio<3600> >::value), "");
+}
diff --git a/final/test/utilities/time/microseconds.pass.cpp b/final/test/utilities/time/microseconds.pass.cpp
new file mode 100644
index 0000000..1fe6b10
--- /dev/null
+++ b/final/test/utilities/time/microseconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 55 bits, micro> microseconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::microseconds D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 54, "");
+    static_assert((std::is_same<Period, std::micro>::value), "");
+}
diff --git a/final/test/utilities/time/milliseconds.pass.cpp b/final/test/utilities/time/milliseconds.pass.cpp
new file mode 100644
index 0000000..75df301
--- /dev/null
+++ b/final/test/utilities/time/milliseconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 45 bits, milli> milliseconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::milliseconds D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 44, "");
+    static_assert((std::is_same<Period, std::milli>::value), "");
+}
diff --git a/final/test/utilities/time/minutes.pass.cpp b/final/test/utilities/time/minutes.pass.cpp
new file mode 100644
index 0000000..1421486
--- /dev/null
+++ b/final/test/utilities/time/minutes.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 29 bits, ratio< 60>> minutes;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::minutes D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 28, "");
+    static_assert((std::is_same<Period, std::ratio<60> >::value), "");
+}
diff --git a/final/test/utilities/time/nanoseconds.pass.cpp b/final/test/utilities/time/nanoseconds.pass.cpp
new file mode 100644
index 0000000..d422803
--- /dev/null
+++ b/final/test/utilities/time/nanoseconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 64 bits, nano> nanoseconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::nanoseconds D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 63, "");
+    static_assert((std::is_same<Period, std::nano>::value), "");
+}
diff --git a/final/test/utilities/time/rep.h b/final/test/utilities/time/rep.h
new file mode 100644
index 0000000..2ec3514
--- /dev/null
+++ b/final/test/utilities/time/rep.h
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 REP_H
+#define REP_H
+
+class Rep
+{
+    int data_;
+public:
+    _LIBCPP_CONSTEXPR Rep() : data_(-1) {}
+    explicit _LIBCPP_CONSTEXPR Rep(int i) : data_(i) {}
+
+    bool _LIBCPP_CONSTEXPR operator==(int i) const {return data_ == i;}
+    bool _LIBCPP_CONSTEXPR operator==(const Rep& r) const {return data_ == r.data_;}
+
+    Rep& operator*=(Rep x) {data_ *= x.data_; return *this;}
+    Rep& operator/=(Rep x) {data_ /= x.data_; return *this;}
+};
+
+#endif  // REP_H
diff --git a/final/test/utilities/time/seconds.pass.cpp b/final/test/utilities/time/seconds.pass.cpp
new file mode 100644
index 0000000..231d596
--- /dev/null
+++ b/final/test/utilities/time/seconds.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// typedef duration<signed integral type of at least 35 bits > seconds;
+
+#include <chrono>
+#include <type_traits>
+#include <limits>
+
+int main()
+{
+    typedef std::chrono::seconds D;
+    typedef D::rep Rep;
+    typedef D::period Period;
+    static_assert(std::is_signed<Rep>::value, "");
+    static_assert(std::is_integral<Rep>::value, "");
+    static_assert(std::numeric_limits<Rep>::digits >= 34, "");
+    static_assert((std::is_same<Period, std::ratio<1> >::value), "");
+}
diff --git a/final/test/utilities/time/time.clock.req/nothing_to_do.pass.cpp b/final/test/utilities/time/time.clock.req/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/time/time.clock.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/time/time.clock/nothing_to_do.pass.cpp b/final/test/utilities/time/time.clock/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/time/time.clock/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp b/final/test/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
new file mode 100644
index 0000000..848534d
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <chrono>
+
+// high_resolution_clock
+
+// check clock invariants
+
+#include <chrono>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock C;
+    static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
+    static_assert((std::is_same<C::period, C::duration::period>::value), "");
+    static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
+    static_assert(C::is_steady || !C::is_steady, "");
+    test(std::chrono::high_resolution_clock::is_steady);
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.hires/now.pass.cpp b/final/test/utilities/time/time.clock/time.clock.hires/now.pass.cpp
new file mode 100644
index 0000000..0bcd99d
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.hires/now.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// high_resolution_clock
+
+// static time_point now();
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::high_resolution_clock C;
+    C::time_point t1 = C::now();
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp b/final/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
new file mode 100644
index 0000000..bec6787
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <chrono>
+
+// steady_clock
+
+// check clock invariants
+
+#include <chrono>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+    typedef std::chrono::steady_clock C;
+    static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
+    static_assert((std::is_same<C::period, C::duration::period>::value), "");
+    static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
+    static_assert(C::is_steady, "");
+    test(std::chrono::steady_clock::is_steady);
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp b/final/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp
new file mode 100644
index 0000000..0c6ebe6
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.steady/now.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// steady_clock
+
+// static time_point now();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::steady_clock C;
+    C::time_point t1 = C::now();
+    C::time_point t2 = C::now();
+    assert(t2 >= t1);
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.system/consistency.pass.cpp b/final/test/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
new file mode 100644
index 0000000..d9d6b04
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 test uses new symbols that were not defined in the libc++ shipped on
+// darwin11 and darwin12:
+// XFAIL: with_system_lib=x86_64-apple-darwin11
+// XFAIL: with_system_lib=x86_64-apple-darwin12
+
+// <chrono>
+
+// system_clock
+
+// check clock invariants
+
+#include <chrono>
+
+template <class _Tp>
+void test(const _Tp &) {}
+
+int main()
+{
+    typedef std::chrono::system_clock C;
+    static_assert((std::is_same<C::rep, C::duration::rep>::value), "");
+    static_assert((std::is_same<C::period, C::duration::period>::value), "");
+    static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
+    static_assert((std::is_same<C::time_point::clock, C>::value), "");
+    static_assert((C::is_steady || !C::is_steady), "");
+    test(std::chrono::system_clock::is_steady);
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp b/final/test/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp
new file mode 100644
index 0000000..9b12a66
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.system/from_time_t.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// static time_point from_time_t(time_t t);
+
+#include <chrono>
+#include <ctime>
+
+int main()
+{
+    typedef std::chrono::system_clock C;
+    C::time_point t1 = C::from_time_t(C::to_time_t(C::now()));
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.system/now.pass.cpp b/final/test/utilities/time/time.clock/time.clock.system/now.pass.cpp
new file mode 100644
index 0000000..60530fd
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.system/now.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// static time_point now();
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::system_clock C;
+    C::time_point t1 = C::now();
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp b/final/test/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp
new file mode 100644
index 0000000..b6a440e
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.system/rep_signed.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// rep should be signed
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    assert(std::chrono::system_clock::duration::min() <
+           std::chrono::system_clock::duration::zero());
+}
diff --git a/final/test/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp b/final/test/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp
new file mode 100644
index 0000000..2a82d53
--- /dev/null
+++ b/final/test/utilities/time/time.clock/time.clock.system/to_time_t.pass.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// system_clock
+
+// time_t to_time_t(const time_point& t);
+
+#include <chrono>
+#include <ctime>
+
+int main()
+{
+    typedef std::chrono::system_clock C;
+    std::time_t t1 = C::to_time_t(C::now());
+}
diff --git a/final/test/utilities/time/time.duration/default_ratio.pass.cpp b/final/test/utilities/time/time.duration/default_ratio.pass.cpp
new file mode 100644
index 0000000..a34e278
--- /dev/null
+++ b/final/test/utilities/time/time.duration/default_ratio.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Test default template arg:
+
+// template <class Rep, class Period = ratio<1>>
+// class duration;
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::chrono::duration<int, std::ratio<1> >,
+                   std::chrono::duration<int> >::value), "");
+}
diff --git a/final/test/utilities/time/time.duration/duration.fail.cpp b/final/test/utilities/time/time.duration/duration.fail.cpp
new file mode 100644
index 0000000..053616b
--- /dev/null
+++ b/final/test/utilities/time/time.duration/duration.fail.cpp
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// If a program instantiates duration with a duration type for the template
+// argument Rep a diagnostic is required.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::duration<std::chrono::milliseconds> D;
+    D d;
+}
diff --git a/final/test/utilities/time/time.duration/positive_num.fail.cpp b/final/test/utilities/time/time.duration/positive_num.fail.cpp
new file mode 100644
index 0000000..e9096fd
--- /dev/null
+++ b/final/test/utilities/time/time.duration/positive_num.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Period::num shall be positive, diagnostic required.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::duration<int, std::ratio<5, -1> > D;
+    D d;
+}
diff --git a/final/test/utilities/time/time.duration/ratio.fail.cpp b/final/test/utilities/time/time.duration/ratio.fail.cpp
new file mode 100644
index 0000000..4ce0aaa
--- /dev/null
+++ b/final/test/utilities/time/time.duration/ratio.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Period shall be a specialization of ratio, diagnostic required.
+
+#include <chrono>
+
+template <int N, int D = 1>
+class Ratio
+{
+public:
+    static const int num = N;
+    static const int den = D;
+};
+
+int main()
+{
+    typedef std::chrono::duration<int, Ratio<1> > D;
+    D d;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
new file mode 100644
index 0000000..8a8f4b1
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_++.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator++();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::hours h(3);
+    std::chrono::hours& href = ++h;
+    assert(&href == &h);
+    assert(h.count() == 4);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
new file mode 100644
index 0000000..cf50282
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_++int.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator++(int);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::hours h(3);
+    std::chrono::hours h2 = h++;
+    assert(h.count() == 4);
+    assert(h2.count() == 3);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
new file mode 100644
index 0000000..c0f1014
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_+.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator+() const;
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::chrono::minutes m(3);
+    std::chrono::minutes m2 = +m;
+    assert(m.count() == m2.count());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::minutes m(3);
+    constexpr std::chrono::minutes m2 = +m;
+    static_assert(m.count() == m2.count(), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
new file mode 100644
index 0000000..8d8cf45
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_+=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator+=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::seconds s(3);
+    s += std::chrono::seconds(2);
+    assert(s.count() == 5);
+    s += std::chrono::minutes(2);
+    assert(s.count() == 125);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
new file mode 100644
index 0000000..0aadfbc
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_--.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator--();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::hours h(3);
+    std::chrono::hours& href = --h;
+    assert(&href == &h);
+    assert(h.count() == 2);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
new file mode 100644
index 0000000..7fc6a1d
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_--int.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator--(int);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::hours h(3);
+    std::chrono::hours h2 = h--;
+    assert(h.count() == 2);
+    assert(h2.count() == 3);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
new file mode 100644
index 0000000..00da6f6
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_-.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration operator-() const;
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    const std::chrono::minutes m(3);
+    std::chrono::minutes m2 = -m;
+    assert(m2.count() == -m.count());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::minutes m(3);
+    constexpr std::chrono::minutes m2 = -m;
+    static_assert(m2.count() == -m.count(), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
new file mode 100644
index 0000000..a0a7aed
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_-=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator-=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::seconds s(3);
+    s -= std::chrono::seconds(2);
+    assert(s.count() == 1);
+    s -= std::chrono::minutes(2);
+    assert(s.count() == -119);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
new file mode 100644
index 0000000..09786bc
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_divide=.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator/=(const rep& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::nanoseconds ns(15);
+    ns /= 5;
+    assert(ns.count() == 3);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
new file mode 100644
index 0000000..8a4a2b4
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=duration.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator%=(const duration& rhs)
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::microseconds us(11);
+    std::chrono::microseconds us2(3);
+    us %= us2;
+    assert(us.count() == 2);
+    us %= std::chrono::milliseconds(3);
+    assert(us.count() == 2);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
new file mode 100644
index 0000000..8758e17
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_mod=rep.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator%=(const rep& rhs)
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::microseconds us(11);
+    us %= 3;
+    assert(us.count() == 2);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
new file mode 100644
index 0000000..b97534a
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.arithmetic/op_times=.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration& operator*=(const rep& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::nanoseconds ns(3);
+    ns *= 5;
+    assert(ns.count() == 15);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
new file mode 100644
index 0000000..1c87fcd
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cast/duration_cast.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class ToDuration, class Rep, class Period>
+//   constexpr
+//   ToDuration
+//   duration_cast(const duration<Rep, Period>& d);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class ToDuration, class FromDuration>
+void
+test(const FromDuration& f, const ToDuration& d)
+{
+    {
+    typedef decltype(std::chrono::duration_cast<ToDuration>(f)) R;
+    static_assert((std::is_same<R, ToDuration>::value), "");
+    assert(std::chrono::duration_cast<ToDuration>(f) == d);
+    }
+}
+
+int main()
+{
+    test(std::chrono::milliseconds(7265000), std::chrono::hours(2));
+    test(std::chrono::milliseconds(7265000), std::chrono::minutes(121));
+    test(std::chrono::milliseconds(7265000), std::chrono::seconds(7265));
+    test(std::chrono::milliseconds(7265000), std::chrono::milliseconds(7265000));
+    test(std::chrono::milliseconds(7265000), std::chrono::microseconds(7265000000LL));
+    test(std::chrono::milliseconds(7265000), std::chrono::nanoseconds(7265000000000LL));
+    test(std::chrono::milliseconds(7265000),
+         std::chrono::duration<double, std::ratio<3600> >(7265./3600));
+    test(std::chrono::duration<int, std::ratio<2, 3> >(9),
+         std::chrono::duration<int, std::ratio<3, 5> >(10));
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::hours h = std::chrono::duration_cast<std::chrono::hours>(std::chrono::milliseconds(7265000));
+    static_assert(h.count() == 2, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp b/final/test/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp
new file mode 100644
index 0000000..13dd8f4
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cast/toduration.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class ToDuration, class Rep, class Period>
+//   ToDuration
+//   duration_cast(const duration<Rep, Period>& d);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+    std::chrono::duration_cast<int>(std::chrono::milliseconds(3));
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp b/final/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
new file mode 100644
index 0000000..2d0dd94
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.comparisons/op_equal.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   bool
+//   operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   bool
+//   operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::seconds s2(3);
+    assert(s1 == s2);
+    assert(!(s1 != s2));
+    }
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::seconds s2(4);
+    assert(!(s1 == s2));
+    assert(s1 != s2);
+    }
+    {
+    std::chrono::milliseconds s1(3);
+    std::chrono::microseconds s2(3000);
+    assert(s1 == s2);
+    assert(!(s1 != s2));
+    }
+    {
+    std::chrono::milliseconds s1(3);
+    std::chrono::microseconds s2(4000);
+    assert(!(s1 == s2));
+    assert(s1 != s2);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+    assert(s1 == s2);
+    assert(!(s1 != s2));
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+    std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+    assert(!(s1 == s2));
+    assert(s1 != s2);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+    assert(s1 == s2);
+    assert(!(s1 != s2));
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::seconds s2(3);
+    static_assert(s1 == s2, "");
+    static_assert(!(s1 != s2), "");
+    }
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::seconds s2(4);
+    static_assert(!(s1 == s2), "");
+    static_assert(s1 != s2, "");
+    }
+    {
+    constexpr std::chrono::milliseconds s1(3);
+    constexpr std::chrono::microseconds s2(3000);
+    static_assert(s1 == s2, "");
+    static_assert(!(s1 != s2), "");
+    }
+    {
+    constexpr std::chrono::milliseconds s1(3);
+    constexpr std::chrono::microseconds s2(4000);
+    static_assert(!(s1 == s2), "");
+    static_assert(s1 != s2, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+    static_assert(s1 == s2, "");
+    static_assert(!(s1 != s2), "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+    static_assert(!(s1 == s2), "");
+    static_assert(s1 != s2, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+    static_assert(s1 == s2, "");
+    static_assert(!(s1 != s2), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp b/final/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
new file mode 100644
index 0000000..9d87557
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.comparisons/op_less.pass.cpp
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   bool
+//   operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   bool
+//   operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   bool
+//   operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   bool
+//   operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::seconds s2(3);
+    assert(!(s1 < s2));
+    assert(!(s1 > s2));
+    assert( (s1 <= s2));
+    assert( (s1 >= s2));
+    }
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::seconds s2(4);
+    assert( (s1 < s2));
+    assert(!(s1 > s2));
+    assert( (s1 <= s2));
+    assert(!(s1 >= s2));
+    }
+    {
+    std::chrono::milliseconds s1(3);
+    std::chrono::microseconds s2(3000);
+    assert(!(s1 < s2));
+    assert(!(s1 > s2));
+    assert( (s1 <= s2));
+    assert( (s1 >= s2));
+    }
+    {
+    std::chrono::milliseconds s1(3);
+    std::chrono::microseconds s2(4000);
+    assert( (s1 < s2));
+    assert(!(s1 > s2));
+    assert( (s1 <= s2));
+    assert(!(s1 >= s2));
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+    assert(!(s1 < s2));
+    assert(!(s1 > s2));
+    assert( (s1 <= s2));
+    assert( (s1 >= s2));
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+    std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+    assert(!(s1 < s2));
+    assert( (s1 > s2));
+    assert(!(s1 <= s2));
+    assert( (s1 >= s2));
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+    assert(!(s1 < s2));
+    assert(!(s1 > s2));
+    assert( (s1 <= s2));
+    assert( (s1 >= s2));
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::seconds s2(3);
+    static_assert(!(s1 < s2), "");
+    static_assert(!(s1 > s2), "");
+    static_assert( (s1 <= s2), "");
+    static_assert( (s1 >= s2), "");
+    }
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::seconds s2(4);
+    static_assert( (s1 < s2), "");
+    static_assert(!(s1 > s2), "");
+    static_assert( (s1 <= s2), "");
+    static_assert(!(s1 >= s2), "");
+    }
+    {
+    constexpr std::chrono::milliseconds s1(3);
+    constexpr std::chrono::microseconds s2(3000);
+    static_assert(!(s1 < s2), "");
+    static_assert(!(s1 > s2), "");
+    static_assert( (s1 <= s2), "");
+    static_assert( (s1 >= s2), "");
+    }
+    {
+    constexpr std::chrono::milliseconds s1(3);
+    constexpr std::chrono::microseconds s2(4000);
+    static_assert( (s1 < s2), "");
+    static_assert(!(s1 > s2), "");
+    static_assert( (s1 <= s2), "");
+    static_assert(!(s1 >= s2), "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
+    static_assert(!(s1 < s2), "");
+    static_assert(!(s1 > s2), "");
+    static_assert( (s1 <= s2), "");
+    static_assert( (s1 >= s2), "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
+    static_assert(!(s1 < s2), "");
+    static_assert( (s1 > s2), "");
+    static_assert(!(s1 <= s2), "");
+    static_assert( (s1 >= s2), "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
+    constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
+    static_assert(!(s1 < s2), "");
+    static_assert(!(s1 > s2), "");
+    static_assert( (s1 <= s2), "");
+    static_assert( (s1 >= s2), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
new file mode 100644
index 0000000..152227d
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/convert_exact.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+//   duration(const duration<Rep2, Period2>& d);
+
+// exact conversions allowed for integral reps
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::milliseconds ms(1);
+    std::chrono::microseconds us = ms;
+    assert(us.count() == 1000);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::milliseconds ms(1);
+    constexpr std::chrono::microseconds us = ms;
+    static_assert(us.count() == 1000, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp b/final/test/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp
new file mode 100644
index 0000000..04c0825
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/convert_float_to_int.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+//   duration(const duration<Rep2, Period2>& d);
+
+//  conversions from floating point to integral durations disallowed
+
+#include <chrono>
+
+int main()
+{
+    std::chrono::duration<double> d;
+    std::chrono::duration<int> i = d;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp b/final/test/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp
new file mode 100644
index 0000000..e82e25e
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/convert_inexact.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+//   duration(const duration<Rep2, Period2>& d);
+
+// inexact conversions disallowed for integral reps
+
+#include <chrono>
+
+int main()
+{
+    std::chrono::microseconds us(1);
+    std::chrono::milliseconds ms = us;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
new file mode 100644
index 0000000..519b2b1
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/convert_inexact.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+//   duration(const duration<Rep2, Period2>& d);
+
+// inexact conversions allowed for floating point reps
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::duration<double, std::micro> us(1);
+    std::chrono::duration<double, std::milli> ms = us;
+    assert(ms.count() == 1./1000);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::duration<double, std::micro> us(1);
+    constexpr std::chrono::duration<double, std::milli> ms = us;
+    static_assert(ms.count() == 1./1000, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
new file mode 100644
index 0000000..59fefe2
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/convert_int_to_float.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+//   duration(const duration<Rep2, Period2>& d);
+
+//  conversions from integral to floating point durations allowed
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::duration<int> i(3);
+    std::chrono::duration<double, std::milli> d = i;
+    assert(d.count() == 3000);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::duration<int> i(3);
+    constexpr std::chrono::duration<double, std::milli> d = i;
+    static_assert(d.count() == 3000, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
new file mode 100644
index 0000000..74b65d6
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/convert_overflow.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2, class Period2>
+//   duration(const duration<Rep2, Period2>& d);
+
+// overflow should SFINAE instead of error out, LWG 2094
+
+#include <chrono>
+#include <cassert>
+
+bool called = false;
+
+void f(std::chrono::milliseconds);
+void f(std::chrono::seconds)
+{
+    called = true;
+}
+
+int main()
+{
+    {
+    std::chrono::duration<int, std::exa> r(1);
+    f(r);
+    assert(called);
+    }
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp
new file mode 100644
index 0000000..c529909
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/default.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// duration() = default;
+
+// Rep must be default initialized, not initialized with 0
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void
+test()
+{
+    D d;
+    assert(d.count() == typename D::rep());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    constexpr D d2 = D();
+    static_assert(d2.count() == typename D::rep(), "");
+#endif
+}
+
+int main()
+{
+    test<std::chrono::duration<Rep> >();
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
new file mode 100644
index 0000000..20f8161
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/rep.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+//   explicit duration(const Rep2& r);
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D, class R>
+void
+test(R r)
+{
+    D d(r);
+    assert(d.count() == r);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    constexpr D d2(R(2));
+    static_assert(d2.count() == 2, "");
+#endif
+}
+
+int main()
+{
+    test<std::chrono::duration<int> >(5);
+    test<std::chrono::duration<int, std::ratio<3, 2> > >(5);
+    test<std::chrono::duration<Rep, std::ratio<3, 2> > >(Rep(3));
+    test<std::chrono::duration<double, std::ratio<2, 3> > >(5.5);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp b/final/test/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp
new file mode 100644
index 0000000..9f071ca
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/rep01.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+//   explicit duration(const Rep2& r);
+
+// test for explicit
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<int> d = 1;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp b/final/test/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp
new file mode 100644
index 0000000..37f32e7
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/rep02.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+//   explicit duration(const Rep2& r);
+
+// Rep2 shall be implicitly convertible to rep
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<Rep> d(1);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp b/final/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
new file mode 100644
index 0000000..b3ba9f7
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/rep02.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+//   explicit duration(const Rep2& r);
+
+// construct double with int
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    std::chrono::duration<double> d(5);
+    assert(d.count() == 5);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    constexpr std::chrono::duration<double> d2(5);
+    static_assert(d2.count() == 5, "");
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp b/final/test/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp
new file mode 100644
index 0000000..4ace54b
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.cons/rep03.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep2>
+//   explicit duration(const Rep2& r);
+
+// treat_as_floating_point<Rep2>::value shall be false
+
+#include <chrono>
+
+int main()
+{
+    std::chrono::duration<int> d(1.);
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.literals/literals.pass.cpp b/final/test/utilities/time/time.duration/time.duration.literals/literals.pass.cpp
new file mode 100644
index 0000000..48324ae
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.literals/literals.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals::chrono_literals;
+
+//    Make sure the types are right
+    static_assert ( std::is_same<decltype( 3h   ), std::chrono::hours>::value, "" );
+    static_assert ( std::is_same<decltype( 3min ), std::chrono::minutes>::value, "" );
+    static_assert ( std::is_same<decltype( 3s   ), std::chrono::seconds>::value, "" );
+    static_assert ( std::is_same<decltype( 3ms  ), std::chrono::milliseconds>::value, "" );
+    static_assert ( std::is_same<decltype( 3us  ), std::chrono::microseconds>::value, "" );
+    static_assert ( std::is_same<decltype( 3ns  ), std::chrono::nanoseconds>::value, "" );
+    
+    std::chrono::hours h = 4h;
+    assert ( h == std::chrono::hours(4));
+    auto h2 = 4.0h;
+    assert ( h == h2 );
+    
+    std::chrono::minutes min = 36min;
+    assert ( min == std::chrono::minutes(36));
+    auto min2 = 36.0min;
+    assert ( min == min2 );
+
+    std::chrono::seconds s = 24s;
+    assert ( s == std::chrono::seconds(24));
+    auto s2 = 24.0s;
+    assert ( s == s2 );
+
+    std::chrono::milliseconds ms = 247ms;
+    assert ( ms == std::chrono::milliseconds(247));
+    auto ms2 = 247.0ms;
+    assert ( ms == ms2 );
+
+    std::chrono::microseconds us = 867us;
+    assert ( us == std::chrono::microseconds(867));
+    auto us2 = 867.0us;
+    assert ( us == us2 );
+
+    std::chrono::nanoseconds ns = 645ns;
+    assert ( ns == std::chrono::nanoseconds(645));
+    auto ns2 = 645.ns;
+    assert ( ns == ns2 );
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp b/final/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp
new file mode 100644
index 0000000..46aaa30
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.literals/literals1.fail.cpp
@@ -0,0 +1,21 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    std::chrono::hours h  = 4h;  // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
+
diff --git a/final/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp b/final/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp
new file mode 100644
index 0000000..574f9bc
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.literals/literals1.pass.cpp
@@ -0,0 +1,48 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::chrono;
+
+    hours h = 4h;
+    assert ( h == hours(4));
+    auto h2 = 4.0h;
+    assert ( h == h2 );
+    
+    minutes min = 36min;
+    assert ( min == minutes(36));
+    auto min2 = 36.0min;
+    assert ( min == min2 );
+
+    seconds s = 24s;
+    assert ( s == seconds(24));
+    auto s2 = 24.0s;
+    assert ( s == s2 );
+
+    milliseconds ms = 247ms;
+    assert ( ms == milliseconds(247));
+    auto ms2 = 247.0ms;
+    assert ( ms == ms2 );
+
+    microseconds us = 867us;
+    assert ( us == microseconds(867));
+    auto us2 = 867.0us;
+    assert ( us == us2 );
+
+    nanoseconds ns = 645ns;
+    assert ( ns == nanoseconds(645));
+    auto ns2 = 645.ns;
+    assert ( ns == ns2 );
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp b/final/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp
new file mode 100644
index 0000000..17358e5
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.literals/literals2.fail.cpp
@@ -0,0 +1,22 @@
+// -*- 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.
+//
+//===----------------------------------------------------------------------===//
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using std::chrono::hours;
+
+    hours foo  =  4h;  // should fail w/conversion operator not found
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp b/final/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp
new file mode 100644
index 0000000..e37bc6e
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.literals/literals2.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11 
+    using namespace std::literals;
+
+    std::chrono::hours h = 4h;
+    assert ( h == std::chrono::hours(4));
+    auto h2 = 4.0h;
+    assert ( h == h2 );
+    
+    std::chrono::minutes min = 36min;
+    assert ( min == std::chrono::minutes(36));
+    auto min2 = 36.0min;
+    assert ( min == min2 );
+
+    std::chrono::seconds s = 24s;
+    assert ( s == std::chrono::seconds(24));
+    auto s2 = 24.0s;
+    assert ( s == s2 );
+
+    std::chrono::milliseconds ms = 247ms;
+    assert ( ms == std::chrono::milliseconds(247));
+    auto ms2 = 247.0ms;
+    assert ( ms == ms2 );
+
+    std::chrono::microseconds us = 867us;
+    assert ( us == std::chrono::microseconds(867));
+    auto us2 = 867.0us;
+    assert ( us == us2 );
+
+    std::chrono::nanoseconds ns = 645ns;
+    assert ( ns == std::chrono::nanoseconds(645));
+    auto ns2 = 645.ns;
+    assert ( ns == ns2 );
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
new file mode 100644
index 0000000..6585351
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_+.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+//   operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::seconds s2(5);
+    std::chrono::seconds r = s1 + s2;
+    assert(r.count() == 8);
+    }
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::microseconds s2(5);
+    std::chrono::microseconds r = s1 + s2;
+    assert(r.count() == 3000005);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+    std::chrono::duration<int, std::ratio<1, 15> > r = s1 + s2;
+    assert(r.count() == 75);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+    std::chrono::duration<double, std::ratio<1, 15> > r = s1 + s2;
+    assert(r.count() == 75);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::seconds s2(5);
+    constexpr std::chrono::seconds r = s1 + s2;
+    static_assert(r.count() == 8, "");
+    }
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::microseconds s2(5);
+    constexpr std::chrono::microseconds r = s1 + s2;
+    static_assert(r.count() == 3000005, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+    constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 + s2;
+    static_assert(r.count() == 75, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+    constexpr std::chrono::duration<double, std::ratio<1, 15> > r = s1 + s2;
+    static_assert(r.count() == 75, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
new file mode 100644
index 0000000..fac58b9
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_-.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+//   operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::seconds s2(5);
+    std::chrono::seconds r = s1 - s2;
+    assert(r.count() == -2);
+    }
+    {
+    std::chrono::seconds s1(3);
+    std::chrono::microseconds s2(5);
+    std::chrono::microseconds r = s1 - s2;
+    assert(r.count() == 2999995);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+    std::chrono::duration<int, std::ratio<1, 15> > r = s1 - s2;
+    assert(r.count() == -15);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+    std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
+    assert(r.count() == -15);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::seconds s2(5);
+    constexpr std::chrono::seconds r = s1 - s2;
+    static_assert(r.count() == -2, "");
+    }
+    {
+    constexpr std::chrono::seconds s1(3);
+    constexpr std::chrono::microseconds s2(5);
+    constexpr std::chrono::microseconds r = s1 - s2;
+    static_assert(r.count() == 2999995, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+    constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 - s2;
+    static_assert(r.count() == -15, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
+    constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+    constexpr std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
+    static_assert(r.count() == -15, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
new file mode 100644
index 0000000..6b24676
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_duration.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   typename common_type<Rep1, Rep2>::type
+//   operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::nanoseconds ns1(15);
+    std::chrono::nanoseconds ns2(5);
+    assert(ns1 / ns2 == 3);
+    }
+    {
+    std::chrono::microseconds us1(15);
+    std::chrono::nanoseconds ns2(5);
+    assert(us1 / ns2 == 3000);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+    std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+    assert(s1 / s2 == 6);
+    }
+    {
+    std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+    std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+    assert(s1 / s2 == 20./3);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::nanoseconds ns1(15);
+    constexpr std::chrono::nanoseconds ns2(5);
+    static_assert(ns1 / ns2 == 3, "");
+    }
+    {
+    constexpr std::chrono::microseconds us1(15);
+    constexpr std::chrono::nanoseconds ns2(5);
+    static_assert(us1 / ns2 == 3000, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
+    static_assert(s1 / s2 == 6, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(30);
+    constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
+    static_assert(s1 / s2 == 20./3, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp
new file mode 100644
index 0000000..db72577
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator/(const duration<Rep1, Period>& d, const Rep2& s);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<Rep> d(Rep(15));
+    d = d / 5;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
new file mode 100644
index 0000000..3036cde
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_divide_rep.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   constexpr
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator/(const duration<Rep1, Period>& d, const Rep2& s);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::nanoseconds ns(15);
+    ns = ns / 5;
+    assert(ns.count() == 3);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::nanoseconds ns(15);
+    constexpr std::chrono::nanoseconds ns2 = ns / 5;
+    static_assert(ns2.count() == 3, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
new file mode 100644
index 0000000..e69f320
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_duration.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+//   constexpr
+//   typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
+//   operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::nanoseconds ns1(15);
+    std::chrono::nanoseconds ns2(6);
+    std::chrono::nanoseconds r = ns1 % ns2;
+    assert(r.count() == 3);
+    }
+    {
+    std::chrono::microseconds us1(15);
+    std::chrono::nanoseconds ns2(28);
+    std::chrono::nanoseconds r = us1 % ns2;
+    assert(r.count() == 20);
+    }
+    {
+    std::chrono::duration<int, std::ratio<3, 5> > s1(6);
+    std::chrono::duration<int, std::ratio<2, 3> > s2(3);
+    std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
+    assert(r.count() == 24);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::nanoseconds ns1(15);
+    constexpr std::chrono::nanoseconds ns2(6);
+    constexpr std::chrono::nanoseconds r = ns1 % ns2;
+    static_assert(r.count() == 3, "");
+    }
+    {
+    constexpr std::chrono::microseconds us1(15);
+    constexpr std::chrono::nanoseconds ns2(28);
+    constexpr std::chrono::nanoseconds r = us1 % ns2;
+    static_assert(r.count() == 20, "");
+    }
+    {
+    constexpr std::chrono::duration<int, std::ratio<3, 5> > s1(6);
+    constexpr std::chrono::duration<int, std::ratio<2, 3> > s2(3);
+    constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
+    static_assert(r.count() == 24, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp
new file mode 100644
index 0000000..16e511d
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator%(const duration<Rep1, Period>& d, const Rep2& s)
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<Rep> d(Rep(15));
+    d = d % 5;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp
new file mode 100644
index 0000000..1acbe34
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_mod_rep.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   constexpr
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator%(const duration<Rep1, Period>& d, const Rep2& s)
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::nanoseconds ns(15);
+    ns = ns % 6;
+    assert(ns.count() == 3);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::nanoseconds ns(15);
+    constexpr std::chrono::nanoseconds ns2 = ns % 6;
+    static_assert(ns2.count() == 3, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp
new file mode 100644
index 0000000..190e74b
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   constexpr
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2>
+//   constexpr
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    {
+    std::chrono::nanoseconds ns(3);
+    ns = ns * 5;
+    assert(ns.count() == 15);
+    ns = 6 * ns;
+    assert(ns.count() == 90);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    constexpr std::chrono::nanoseconds ns(3);
+    constexpr std::chrono::nanoseconds ns2 = ns * 5;
+    static_assert(ns2.count() == 15, "");
+    constexpr std::chrono::nanoseconds ns3 = 6 * ns;
+    static_assert(ns3.count() == 18, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp
new file mode 100644
index 0000000..d816050
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep1.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2>
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<Rep> d;
+    d = d * 5;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp b/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp
new file mode 100644
index 0000000..e224ba9
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.nonmember/op_times_rep2.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// template <class Rep1, class Period, class Rep2>
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator*(const duration<Rep1, Period>& d, const Rep2& s);
+
+// template <class Rep1, class Period, class Rep2>
+//   duration<typename common_type<Rep1, Rep2>::type, Period>
+//   operator*(const Rep1& s, const duration<Rep2, Period>& d);
+
+#include <chrono>
+
+#include "../../rep.h"
+
+int main()
+{
+    std::chrono::duration<Rep> d;
+    d = 5 * d;
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp b/final/test/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.observer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.special/max.pass.cpp b/final/test/utilities/time/time.duration/time.duration.special/max.pass.cpp
new file mode 100644
index 0000000..405461e
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.special/max.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration max();
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+    {
+    typedef typename D::rep Rep;
+    Rep max_rep = std::chrono::duration_values<Rep>::max();
+    assert(D::max().count() == max_rep);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    typedef typename D::rep Rep;
+    constexpr Rep max_rep = std::chrono::duration_values<Rep>::max();
+    static_assert(D::max().count() == max_rep, "");
+    }
+#endif
+}
+
+int main()
+{
+    test<std::chrono::duration<int> >();
+    test<std::chrono::duration<Rep> >();
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.special/min.pass.cpp b/final/test/utilities/time/time.duration/time.duration.special/min.pass.cpp
new file mode 100644
index 0000000..44cd64e
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.special/min.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration min();
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+    {
+    typedef typename D::rep Rep;
+    Rep min_rep = std::chrono::duration_values<Rep>::min();
+    assert(D::min().count() == min_rep);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    typedef typename D::rep Rep;
+    constexpr Rep min_rep = std::chrono::duration_values<Rep>::min();
+    static_assert(D::min().count() == min_rep, "");
+    }
+#endif
+}
+
+int main()
+{
+    test<std::chrono::duration<int> >();
+    test<std::chrono::duration<Rep> >();
+}
diff --git a/final/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp b/final/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp
new file mode 100644
index 0000000..18350fe
--- /dev/null
+++ b/final/test/utilities/time/time.duration/time.duration.special/zero.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// static constexpr duration zero();
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+template <class D>
+void test()
+{
+    {
+    typedef typename D::rep Rep;
+    Rep zero_rep = std::chrono::duration_values<Rep>::zero();
+    assert(D::zero().count() == zero_rep);
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+    typedef typename D::rep Rep;
+    constexpr Rep zero_rep = std::chrono::duration_values<Rep>::zero();
+    static_assert(D::zero().count() == zero_rep, "");
+    }
+#endif
+}
+
+int main()
+{
+    test<std::chrono::duration<int> >();
+    test<std::chrono::duration<Rep> >();
+}
diff --git a/final/test/utilities/time/time.duration/types.pass.cpp b/final/test/utilities/time/time.duration/types.pass.cpp
new file mode 100644
index 0000000..8eaffe7
--- /dev/null
+++ b/final/test/utilities/time/time.duration/types.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration
+
+// Test nested types
+
+// typedef Rep rep;
+// typedef Period period;
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+    typedef std::chrono::duration<long, std::ratio<3, 2> > D;
+    static_assert((std::is_same<D::rep, long>::value), "");
+    static_assert((std::is_same<D::period, std::ratio<3, 2> >::value), "");
+}
diff --git a/final/test/utilities/time/time.point/default_duration.pass.cpp b/final/test/utilities/time/time.point/default_duration.pass.cpp
new file mode 100644
index 0000000..dfdf225
--- /dev/null
+++ b/final/test/utilities/time/time.point/default_duration.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Test default template arg:
+
+// template <class Clock, class Duration = typename Clock::duration>
+//   class time_point;
+
+#include <chrono>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_same<std::chrono::system_clock::duration,
+                   std::chrono::time_point<std::chrono::system_clock>::duration>::value), "");
+}
diff --git a/final/test/utilities/time/time.point/duration.fail.cpp b/final/test/utilities/time/time.point/duration.fail.cpp
new file mode 100644
index 0000000..ee48bcb
--- /dev/null
+++ b/final/test/utilities/time/time.point/duration.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// Duration shall be an instance of duration.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::time_point<std::chrono::system_clock, int> T;
+    T t;
+}
diff --git a/final/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp b/final/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
new file mode 100644
index 0000000..ffe855c
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.arithmetic/op_+=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator+=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    std::chrono::time_point<Clock, Duration> t(Duration(3));
+    t += Duration(2);
+    assert(t.time_since_epoch() == Duration(5));
+}
diff --git a/final/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp b/final/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
new file mode 100644
index 0000000..acad1cf
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.arithmetic/op_-=.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point& operator-=(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    std::chrono::time_point<Clock, Duration> t(Duration(3));
+    t -= Duration(2);
+    assert(t.time_since_epoch() == Duration(1));
+}
diff --git a/final/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp b/final/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
new file mode 100644
index 0000000..7d7e82a
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.cast/time_point_cast.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration>
+//   time_point<Clock, ToDuration>
+//   time_point_cast(const time_point<Clock, Duration>& t);
+
+#include <chrono>
+#include <type_traits>
+#include <cassert>
+
+template <class FromDuration, class ToDuration>
+void
+test(const FromDuration& df, const ToDuration& d)
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
+    typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+    {
+    FromTimePoint f(df);
+    ToTimePoint t(d);
+    typedef decltype(std::chrono::time_point_cast<ToDuration>(f)) R;
+    static_assert((std::is_same<R, ToTimePoint>::value), "");
+    assert(std::chrono::time_point_cast<ToDuration>(f) == t);
+    }
+}
+
+#if _LIBCPP_STD_VER > 11
+
+template<class FromDuration, long long From, class ToDuration, long long To>
+void test_constexpr ()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::time_point<Clock, FromDuration> FromTimePoint;
+    typedef std::chrono::time_point<Clock, ToDuration> ToTimePoint;
+    {
+    constexpr FromTimePoint f{FromDuration{From}};
+    constexpr ToTimePoint   t{ToDuration{To}};
+    static_assert(std::chrono::time_point_cast<ToDuration>(f) == t, "");
+    }
+
+}
+
+#endif
+
+int main()
+{
+    test(std::chrono::milliseconds(7265000), std::chrono::hours(2));
+    test(std::chrono::milliseconds(7265000), std::chrono::minutes(121));
+    test(std::chrono::milliseconds(7265000), std::chrono::seconds(7265));
+    test(std::chrono::milliseconds(7265000), std::chrono::milliseconds(7265000));
+    test(std::chrono::milliseconds(7265000), std::chrono::microseconds(7265000000LL));
+    test(std::chrono::milliseconds(7265000), std::chrono::nanoseconds(7265000000000LL));
+    test(std::chrono::milliseconds(7265000),
+         std::chrono::duration<double, std::ratio<3600> >(7265./3600));
+    test(std::chrono::duration<int, std::ratio<2, 3> >(9),
+         std::chrono::duration<int, std::ratio<3, 5> >(10));
+#if _LIBCPP_STD_VER > 11
+    {
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::hours,    2> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::minutes,121> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::seconds,7265> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::milliseconds,7265000> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::microseconds,7265000000LL> ();
+    test_constexpr<std::chrono::milliseconds, 7265000, std::chrono::nanoseconds,7265000000000LL> ();
+    typedef std::chrono::duration<int, std::ratio<3, 5>> T1;
+    test_constexpr<std::chrono::duration<int, std::ratio<2, 3>>, 9, T1, 10> ();
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp b/final/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp
new file mode 100644
index 0000000..de1e5bb
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.cast/toduration.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class ToDuration, class Clock, class Duration>
+//   time_point<Clock, ToDuration>
+//   time_point_cast(const time_point<Clock, Duration>& t);
+
+// ToDuration shall be an instantiation of duration.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::time_point<Clock, std::chrono::milliseconds> FromTimePoint;
+    typedef std::chrono::time_point<Clock, std::chrono::minutes> ToTimePoint;
+    std::chrono::time_point_cast<ToTimePoint>(FromTimePoint(std::chrono::milliseconds(3)));
+}
diff --git a/final/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp b/final/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
new file mode 100644
index 0000000..f5ff119
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.comparisons/op_equal.fail.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+    typedef std::chrono::system_clock Clock1;
+    typedef Clock                     Clock2;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock1, Duration1> T1;
+    typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    t1 == t2;
+}
diff --git a/final/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp b/final/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
new file mode 100644
index 0000000..fbd3a13
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.comparisons/op_equal.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock, Duration1> T1;
+    typedef std::chrono::time_point<Clock, Duration2> T2;
+
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(3));
+    assert( (t1 == t2));
+    assert(!(t1 != t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(4));
+    assert(!(t1 == t2));
+    assert( (t1 != t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    assert( (t1 == t2));
+    assert(!(t1 != t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3001));
+    assert(!(t1 == t2));
+    assert( (t1 != t2));
+    }
+    
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(3));
+    static_assert( (t1 == t2), "");
+    static_assert(!(t1 != t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(4));
+    static_assert(!(t1 == t2), "");
+    static_assert( (t1 != t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3000));
+    static_assert( (t1 == t2), "");
+    static_assert(!(t1 != t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3001));
+    static_assert(!(t1 == t2), "");
+    static_assert( (t1 != t2), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp b/final/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp
new file mode 100644
index 0000000..f9745cb
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.comparisons/op_less.fail.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// time_points with different clocks should not compare
+
+#include <chrono>
+
+#include "../../clock.h"
+
+int main()
+{
+    typedef std::chrono::system_clock Clock1;
+    typedef Clock                     Clock2;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock1, Duration1> T1;
+    typedef std::chrono::time_point<Clock2, Duration2> T2;
+
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    t1 < t2;
+}
diff --git a/final/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp b/final/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
new file mode 100644
index 0000000..9d94400
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.comparisons/op_less.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+// template <class Clock, class Duration1, class Duration2>
+//   bool
+//   operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    typedef std::chrono::time_point<Clock, Duration1> T1;
+    typedef std::chrono::time_point<Clock, Duration2> T2;
+
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(3));
+    assert(!(t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert( (t1 >= t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T1 t2(Duration1(4));
+    assert( (t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert(!(t1 >= t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3000));
+    assert(!(t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert( (t1 >= t2));
+    }
+    {
+    T1 t1(Duration1(3));
+    T2 t2(Duration2(3001));
+    assert( (t1 <  t2));
+    assert(!(t1 >  t2));
+    assert( (t1 <= t2));
+    assert(!(t1 >= t2));
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(3));
+    static_assert(!(t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert( (t1 >= t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T1 t2(Duration1(4));
+    static_assert( (t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert(!(t1 >= t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3000));
+    static_assert(!(t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert( (t1 >= t2), "");
+    }
+    {
+    constexpr T1 t1(Duration1(3));
+    constexpr T2 t2(Duration2(3001));
+    static_assert( (t1 <  t2), "");
+    static_assert(!(t1 >  t2), "");
+    static_assert( (t1 <= t2), "");
+    static_assert(!(t1 >= t2), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.cons/convert.fail.cpp b/final/test/utilities/time/time.point/time.point.cons/convert.fail.cpp
new file mode 100644
index 0000000..565aa6c
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.cons/convert.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2>
+//   time_point(const time_point<clock, Duration2>& t);
+
+// Duration2 shall be implicitly convertible to duration.
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    {
+    std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+    std::chrono::time_point<Clock, Duration1> t1 = t2;
+    }
+}
diff --git a/final/test/utilities/time/time.point/time.point.cons/convert.pass.cpp b/final/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
new file mode 100644
index 0000000..6cd7dcb
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.cons/convert.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Duration2>
+//   time_point(const time_point<clock, Duration2>& t);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::microseconds Duration1;
+    typedef std::chrono::milliseconds Duration2;
+    {
+    std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+    std::chrono::time_point<Clock, Duration1> t1 = t2;
+    assert(t1.time_since_epoch() == Duration1(3000));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(3));
+    constexpr std::chrono::time_point<Clock, Duration1> t1 = t2;
+    static_assert(t1.time_since_epoch() == Duration1(3000), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.cons/default.pass.cpp b/final/test/utilities/time/time.point/time.point.cons/default.pass.cpp
new file mode 100644
index 0000000..01f0bc1
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.cons/default.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// time_point();
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::duration<Rep, std::milli> Duration;
+    {
+    std::chrono::time_point<Clock, Duration> t;
+    assert(t.time_since_epoch() == Duration::zero());
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration> t;
+    static_assert(t.time_since_epoch() == Duration::zero(), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.cons/duration.fail.cpp b/final/test/utilities/time/time.point/time.point.cons/duration.fail.cpp
new file mode 100644
index 0000000..810007e
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.cons/duration.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+// test for explicit
+
+#include <chrono>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    std::chrono::time_point<Clock, Duration> t = Duration(3);
+}
diff --git a/final/test/utilities/time/time.point/time.point.cons/duration.pass.cpp b/final/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
new file mode 100644
index 0000000..9d53d86
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.cons/duration.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// explicit time_point(const duration& d);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    {
+    std::chrono::time_point<Clock, Duration> t(Duration(3));
+    assert(t.time_since_epoch() == Duration(3));
+    }
+    {
+    std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
+    assert(t.time_since_epoch() == Duration(3000));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration> t(Duration(3));
+    static_assert(t.time_since_epoch() == Duration(3), "");
+    }
+    {
+    constexpr std::chrono::time_point<Clock, Duration> t(std::chrono::seconds(3));
+    static_assert(t.time_since_epoch() == Duration(3000), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp b/final/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
new file mode 100644
index 0000000..7a8fa6d
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.nonmember/op_+.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2>
+//   time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+//   operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+// template <class Rep1, class Period1, class Clock, class Duration2>
+//   time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
+//   operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    {
+    std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+    assert(t2.time_since_epoch() == Duration2(3005));
+    t2 = Duration2(6) + t1;
+    assert(t2.time_since_epoch() == Duration2(3006));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 + Duration2(5);
+    static_assert(t2.time_since_epoch() == Duration2(3005), "");
+    constexpr std::chrono::time_point<Clock, Duration2> t3 = Duration2(6) + t1;
+    static_assert(t3.time_since_epoch() == Duration2(3006), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp b/final/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
new file mode 100644
index 0000000..342d27b
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.nonmember/op_-duration.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Rep2, class Period2>
+//   time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
+//   operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    {
+    std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+    assert(t2.time_since_epoch() == Duration2(2995));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    constexpr std::chrono::time_point<Clock, Duration2> t2 = t1 - Duration2(5);
+    static_assert(t2.time_since_epoch() == Duration2(2995), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp b/final/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
new file mode 100644
index 0000000..5267f07
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.nonmember/op_-time_point.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// template <class Clock, class Duration1, class Duration2>
+//   typename common_type<Duration1, Duration2>::type
+//   operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration1;
+    typedef std::chrono::microseconds Duration2;
+    {
+    std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+    assert((t1 - t2) == Duration2(2995));
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+    constexpr std::chrono::time_point<Clock, Duration1> t1(Duration1(3));
+    constexpr std::chrono::time_point<Clock, Duration2> t2(Duration2(5));
+    static_assert((t1 - t2) == Duration2(2995), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp b/final/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.observer/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/time/time.point/time.point.special/max.pass.cpp b/final/test/utilities/time/time.point/time.point.special/max.pass.cpp
new file mode 100644
index 0000000..6bba6fc
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.special/max.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point max();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    typedef std::chrono::time_point<Clock, Duration> TP;
+    assert(TP::max() == TP(Duration::max()));
+}
diff --git a/final/test/utilities/time/time.point/time.point.special/min.pass.cpp b/final/test/utilities/time/time.point/time.point.special/min.pass.cpp
new file mode 100644
index 0000000..b1d955c
--- /dev/null
+++ b/final/test/utilities/time/time.point/time.point.special/min.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// time_point
+
+// static constexpr time_point min();
+
+#include <chrono>
+#include <cassert>
+
+int main()
+{
+    typedef std::chrono::system_clock Clock;
+    typedef std::chrono::milliseconds Duration;
+    typedef std::chrono::time_point<Clock, Duration> TP;
+    assert(TP::min() == TP(Duration::min()));
+}
diff --git a/final/test/utilities/time/time.traits/nothing_to_do.pass.cpp b/final/test/utilities/time/time.traits/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/time/time.traits/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp b/final/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
new file mode 100644
index 0000000..89dc1dc
--- /dev/null
+++ b/final/test/utilities/time/time.traits/time.traits.duration_values/max.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::max
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    assert(std::chrono::duration_values<int>::max() ==
+           std::numeric_limits<int>::max());
+    assert(std::chrono::duration_values<double>::max() ==
+           std::numeric_limits<double>::max());
+    assert(std::chrono::duration_values<Rep>::max() ==
+           std::numeric_limits<Rep>::max());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    static_assert(std::chrono::duration_values<int>::max() ==
+           std::numeric_limits<int>::max(), "");
+    static_assert(std::chrono::duration_values<double>::max() ==
+           std::numeric_limits<double>::max(), "");
+    static_assert(std::chrono::duration_values<Rep>::max() ==
+           std::numeric_limits<Rep>::max(), "");
+#endif
+}
diff --git a/final/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp b/final/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
new file mode 100644
index 0000000..69812bb
--- /dev/null
+++ b/final/test/utilities/time/time.traits/time.traits.duration_values/min.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::min
+
+#include <chrono>
+#include <limits>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    assert(std::chrono::duration_values<int>::min() ==
+           std::numeric_limits<int>::lowest());
+    assert(std::chrono::duration_values<double>::min() ==
+           std::numeric_limits<double>::lowest());
+    assert(std::chrono::duration_values<Rep>::min() ==
+           std::numeric_limits<Rep>::lowest());
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    static_assert(std::chrono::duration_values<int>::min() ==
+           std::numeric_limits<int>::lowest(), "");
+    static_assert(std::chrono::duration_values<double>::min() ==
+           std::numeric_limits<double>::lowest(), "");
+    static_assert(std::chrono::duration_values<Rep>::min() ==
+           std::numeric_limits<Rep>::lowest(), "");
+#endif
+}
diff --git a/final/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp b/final/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
new file mode 100644
index 0000000..234b4bc
--- /dev/null
+++ b/final/test/utilities/time/time.traits/time.traits.duration_values/zero.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// duration_values::zero
+
+#include <chrono>
+#include <cassert>
+
+#include "../../rep.h"
+
+int main()
+{
+    assert(std::chrono::duration_values<int>::zero() == 0);
+    assert(std::chrono::duration_values<Rep>::zero() == 0);
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    static_assert(std::chrono::duration_values<int>::zero() == 0, "");
+    static_assert(std::chrono::duration_values<Rep>::zero() == 0, "");
+#endif
+}
diff --git a/final/test/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp b/final/test/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
new file mode 100644
index 0000000..c32350f
--- /dev/null
+++ b/final/test/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// treat_as_floating_point
+
+#include <chrono>
+#include <type_traits>
+
+template <class T>
+void
+test()
+{
+    static_assert((std::is_base_of<std::is_floating_point<T>,
+                                   std::chrono::treat_as_floating_point<T> >::value), "");
+}
+
+struct A {};
+
+int main()
+{
+    test<int>();
+    test<unsigned>();
+    test<char>();
+    test<bool>();
+    test<float>();
+    test<double>();
+    test<long double>();
+    test<A>();
+}
diff --git a/final/test/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp b/final/test/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
new file mode 100644
index 0000000..f942844
--- /dev/null
+++ b/final/test/utilities/time/time.traits/time.traits.specializations/duration.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// template <class Rep1, class Period1, class Rep2, class Period2>
+// struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
+// {
+//     typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type;
+// };
+
+#include <chrono>
+
+template <class D1, class D2, class De>
+void
+test()
+{
+    typedef typename std::common_type<D1, D2>::type Dc;
+    static_assert((std::is_same<Dc, De>::value), "");
+}
+
+int main()
+{
+    test<std::chrono::duration<int, std::ratio<1, 100> >,
+         std::chrono::duration<long, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<long, std::ratio<1, 100> >,
+         std::chrono::duration<int, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<char, std::ratio<1, 30> >,
+         std::chrono::duration<short, std::ratio<1, 1000> >,
+         std::chrono::duration<int, std::ratio<1, 3000> > >();
+    test<std::chrono::duration<double, std::ratio<21, 1> >,
+         std::chrono::duration<short, std::ratio<15, 1> >,
+         std::chrono::duration<double, std::ratio<3, 1> > >();
+}
diff --git a/final/test/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp b/final/test/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
new file mode 100644
index 0000000..a0786b4
--- /dev/null
+++ b/final/test/utilities/time/time.traits/time.traits.specializations/time_point.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+// template <class Clock, class Duration1, class Duration2>
+// struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>
+// {
+//     typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type;
+// };
+
+#include <chrono>
+
+template <class D1, class D2, class De>
+void
+test()
+{
+    typedef std::chrono::system_clock C;
+    typedef std::chrono::time_point<C, D1> T1;
+    typedef std::chrono::time_point<C, D2> T2;
+    typedef std::chrono::time_point<C, De> Te;
+    typedef typename std::common_type<T1, T2>::type Tc;
+    static_assert((std::is_same<Tc, Te>::value), "");
+}
+
+int main()
+{
+    test<std::chrono::duration<int, std::ratio<1, 100> >,
+         std::chrono::duration<long, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<long, std::ratio<1, 100> >,
+         std::chrono::duration<int, std::ratio<1, 1000> >,
+         std::chrono::duration<long, std::ratio<1, 1000> > >();
+    test<std::chrono::duration<char, std::ratio<1, 30> >,
+         std::chrono::duration<short, std::ratio<1, 1000> >,
+         std::chrono::duration<int, std::ratio<1, 3000> > >();
+    test<std::chrono::duration<double, std::ratio<21, 1> >,
+         std::chrono::duration<short, std::ratio<15, 1> >,
+         std::chrono::duration<double, std::ratio<3, 1> > >();
+}
diff --git a/final/test/utilities/time/version.pass.cpp b/final/test/utilities/time/version.pass.cpp
new file mode 100644
index 0000000..bfa3f6d
--- /dev/null
+++ b/final/test/utilities/time/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <chrono>
+
+#include <chrono>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp b/final/test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp b/final/test/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp
new file mode 100644
index 0000000..2862762
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.general/tuple.smartptr.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+//
+//  Tuples of smart pointers; based on bug #18350
+//  auto_ptr doesn't have a copy constructor that takes a const &, but tuple does.
+
+#include <tuple>
+#include <memory>
+
+int main () {
+    {
+    std::tuple<std::unique_ptr<char>> up;
+    std::tuple<std::shared_ptr<char>> sp;
+    std::tuple<std::weak_ptr  <char>> wp;
+//     std::tuple<std::auto_ptr  <char>> ap;
+    }
+    {
+    std::tuple<std::unique_ptr<char[]>> up;
+    std::tuple<std::shared_ptr<char[]>> sp;
+    std::tuple<std::weak_ptr  <char[]>> wp;
+//     std::tuple<std::auto_ptr  <char[]>> ap;
+    }
+    {
+    std::tuple<std::unique_ptr<char[5]>> up;
+    std::tuple<std::shared_ptr<char[5]>> sp;
+    std::tuple<std::weak_ptr  <char[5]>> wp;
+//     std::tuple<std::auto_ptr  <char[5]>> ap;
+    }
+}
\ No newline at end of file
diff --git a/final/test/utilities/tuple/tuple.tuple/MoveOnly.h b/final/test/utilities/tuple/tuple.tuple/MoveOnly.h
new file mode 100644
index 0000000..e4d9f64
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/MoveOnly.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 MOVEONLY_H
+#define MOVEONLY_H
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <cstddef>
+#include <functional>
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+    MoveOnly& operator=(const MoveOnly&);
+
+    int data_;
+public:
+    MoveOnly(int data = 1) : data_(data) {}
+    MoveOnly(MoveOnly&& x)
+        : data_(x.data_) {x.data_ = 0;}
+    MoveOnly& operator=(MoveOnly&& x)
+        {data_ = x.data_; x.data_ = 0; return *this;}
+
+    int get() const {return data_;}
+
+    bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
+    bool operator< (const MoveOnly& x) const {return data_ <  x.data_;}
+};
+
+namespace std {
+
+template <>
+struct hash<MoveOnly>
+    : public std::unary_function<MoveOnly, std::size_t>
+{
+    std::size_t operator()(const MoveOnly& x) const {return x.get();}
+};
+
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif  // MOVEONLY_H
diff --git a/final/test/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp b/final/test/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp
new file mode 100644
index 0000000..df5fdff
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/TupleFunction.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 is for bugs 18853 and 19118
+
+#if __cplusplus >= 201103L
+
+#include <tuple>
+#include <functional>
+
+struct X
+{
+    X() {}
+
+    template <class T>
+    X(T);
+
+    void operator()() {}
+};
+
+int
+main()
+{
+    X x;
+    std::function<void()> f(x);
+}
+#else
+int main () {}
+#endif
diff --git a/final/test/utilities/tuple/tuple.tuple/alloc_first.h b/final/test/utilities/tuple/tuple.tuple/alloc_first.h
new file mode 100644
index 0000000..237a289
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/alloc_first.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 ALLOC_FIRST_H
+#define ALLOC_FIRST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_first
+{
+    static bool allocator_constructed;
+
+    typedef A1<int> allocator_type;
+
+    int data_;
+
+    alloc_first() : data_(0) {}
+    alloc_first(int d) : data_(d) {}
+    alloc_first(std::allocator_arg_t, const A1<int>& a)
+        : data_(0)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_first(std::allocator_arg_t, const A1<int>& a, int d)
+        : data_(d)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_first(std::allocator_arg_t, const A1<int>& a, const alloc_first& d)
+        : data_(d.data_)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    ~alloc_first() {data_ = -1;}
+
+    friend bool operator==(const alloc_first& x, const alloc_first& y)
+        {return x.data_ == y.data_;}
+    friend bool operator< (const alloc_first& x, const alloc_first& y)
+        {return x.data_ < y.data_;}
+};
+
+bool alloc_first::allocator_constructed = false;
+
+#endif  // ALLOC_FIRST_H
diff --git a/final/test/utilities/tuple/tuple.tuple/alloc_last.h b/final/test/utilities/tuple/tuple.tuple/alloc_last.h
new file mode 100644
index 0000000..71a9b9e
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/alloc_last.h
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 ALLOC_LAST_H
+#define ALLOC_LAST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_last
+{
+    static bool allocator_constructed;
+
+    typedef A1<int> allocator_type;
+
+    int data_;
+
+    alloc_last() : data_(0) {}
+    alloc_last(int d) : data_(d) {}
+    alloc_last(const A1<int>& a)
+        : data_(0)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_last(int d, const A1<int>& a)
+        : data_(d)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    alloc_last(const alloc_last& d, const A1<int>& a)
+        : data_(d.data_)
+    {
+        assert(a.id() == 5);
+        allocator_constructed = true;
+    }
+
+    ~alloc_last() {data_ = -1;}
+
+    friend bool operator==(const alloc_last& x, const alloc_last& y)
+        {return x.data_ == y.data_;}
+    friend bool operator< (const alloc_last& x, const alloc_last& y)
+        {return x.data_ < y.data_;}
+};
+
+bool alloc_last::allocator_constructed = false;
+
+#endif  // ALLOC_LAST_H
diff --git a/final/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp b/final/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp
new file mode 100644
index 0000000..ddf558c
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// This is not a portable test
+
+#include <tuple>
+
+struct A {};
+
+struct B {};
+
+int main()
+{
+    {
+        typedef std::tuple<int, A> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<A, int> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<A, int, B> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<A, B, int> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+    {
+        typedef std::tuple<int, A, B> T;
+        static_assert((sizeof(T) == sizeof(int)), "");
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
new file mode 100644
index 0000000..677bd04
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+//   tuple& operator=(const pair<U1, U2>& u);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<double, char> T0;
+        typedef std::tuple<int, short> T1;
+        T0 t0(2.5, 'a');
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == short('a'));
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
new file mode 100644
index 0000000..a084859
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   tuple& operator=(const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i = 0) : id_(i) {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i = 0) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1;
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        D d2(2);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d2);
+        T1 t1(1.5, 'b', d);
+        t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
new file mode 100644
index 0000000..670ca04
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   tuple& operator=(tuple<UTypes...>&& u);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i= 0) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        D d2(2);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d2);
+        T1 t1(1.5, 'b', d);
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+    {
+        typedef std::tuple<double, char, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1)->id_ == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
new file mode 100644
index 0000000..525dfe6
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(2));
+        T t;
+        t = t0;
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
new file mode 100644
index 0000000..f19043c
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t;
+        t = t0;
+    }
+    {
+        typedef std::tuple<int> T;
+        T t0(2);
+        T t;
+        t = t0;
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<int, char> T;
+        T t0(2, 'a');
+        T t;
+        t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+    }
+    {
+        typedef std::tuple<int, char, std::string> T;
+        const T t0(2, 'a', "some text");
+        T t;
+        t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+        assert(std::get<2>(t) == "some text");
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
new file mode 100644
index 0000000..302c1f9
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(tuple&& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t;
+        t = std::move(t0);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t;
+        t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t;
+        t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t;
+        t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
new file mode 100644
index 0000000..fe0163c
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+//   tuple& operator=(pair<U1, U2>&& u);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i = 0) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::pair<double, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+        T1 t1;
+        t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
new file mode 100644
index 0000000..c2c00f2
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   explicit tuple(UTypes&&... u);
+
+/*
+    This is testing an extension whereby only Types having an explicit conversion
+    from UTypes are bound by the explicit tuple constructor.
+*/
+
+#include <tuple>
+#include <cassert>
+
+class MoveOnly
+{
+    MoveOnly(const MoveOnly&);
+    MoveOnly& operator=(const MoveOnly&);
+
+    int data_;
+public:
+    explicit MoveOnly(int data = 1) : data_(data) {}
+    MoveOnly(MoveOnly&& x)
+        : data_(x.data_) {x.data_ = 0;}
+    MoveOnly& operator=(MoveOnly&& x)
+        {data_ = x.data_; x.data_ = 0; return *this;}
+
+    int get() const {return data_;}
+
+    bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
+    bool operator< (const MoveOnly& x) const {return data_ <  x.data_;}
+};
+
+int main()
+{
+    {
+        std::tuple<MoveOnly> t = 1;
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
new file mode 100644
index 0000000..d6fbdae
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+//   explicit tuple(UTypes&&... u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+#if _LIBCPP_STD_VER > 11
+
+struct Empty {};
+struct A
+{
+    int id_;
+    explicit constexpr A(int i) : id_(i) {}
+};
+
+#endif
+
+int main()
+{
+    {
+        std::tuple<MoveOnly> t(MoveOnly(0));
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t(MoveOnly(0), MoveOnly(1));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+                                                   MoveOnly(1),
+                                                   MoveOnly(2));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+    // extensions
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+                                                   MoveOnly(1));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == MoveOnly());
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == MoveOnly());
+        assert(std::get<2>(t) == MoveOnly());
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        constexpr std::tuple<Empty> t0{Empty()};
+    }
+    {
+        constexpr std::tuple<A, A> t(3, 2);
+        static_assert(std::get<0>(t).id_ == 3, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
new file mode 100644
index 0000000..606c609
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a);
+
+#include <tuple>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        std::tuple<> t(std::allocator_arg, A1<int>());
+    }
+    {
+        std::tuple<int> t(std::allocator_arg, A1<int>());
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<DefaultOnly> t(std::allocator_arg, A1<int>());
+        assert(std::get<0>(t) == DefaultOnly());
+    }
+    {
+        assert(!alloc_first::allocator_constructed);
+        std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == alloc_first());
+    }
+    {
+        assert(!alloc_last::allocator_constructed);
+        std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == alloc_last());
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        std::tuple<DefaultOnly, alloc_first> t(std::allocator_arg, A1<int>(5));
+        assert(std::get<0>(t) == DefaultOnly());
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first());
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+                                                           A1<int>(5));
+        assert(std::get<0>(t) == DefaultOnly());
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first());
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last());
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+                                                           A2<int>(5));
+        assert(std::get<0>(t) == DefaultOnly());
+        assert(!alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first());
+        assert(!alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last());
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
new file mode 100644
index 0000000..667c4dd
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+//   tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        std::tuple<MoveOnly> t(std::allocator_arg, A1<int>(), MoveOnly(0));
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+                                         MoveOnly(0), MoveOnly(1));
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+                                                   MoveOnly(0),
+                                                   1, 2);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+                                                   A1<int>(5), 1, 2, 3);
+        assert(std::get<0>(t) == 1);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(2));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last(3));
+    }
+    // extensions
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+                                                   0, 1);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == MoveOnly());
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+                                                   0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == MoveOnly());
+        assert(std::get<2>(t) == MoveOnly());
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
new file mode 100644
index 0000000..5f6a586
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a, const Types&...);
+
+#include <tuple>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
+        assert(std::get<0>(t) == 3);
+    }
+    {
+        assert(!alloc_first::allocator_constructed);
+        std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5), alloc_first(3));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == alloc_first(3));
+    }
+    {
+        assert(!alloc_last::allocator_constructed);
+        std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5), alloc_last(3));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == alloc_last(3));
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        std::tuple<int, alloc_first> t(std::allocator_arg, A1<int>(5),
+                                       10, alloc_first(15));
+        assert(std::get<0>(t) == 10);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(15));
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+                                                   A1<int>(5), 1, alloc_first(2),
+                                                   alloc_last(3));
+        assert(std::get<0>(t) == 1);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(2));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last(3));
+    }
+    {
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+                                                   A2<int>(5), 1, alloc_first(2),
+                                                   alloc_last(3));
+        assert(std::get<0>(t) == 1);
+        assert(!alloc_first::allocator_constructed);
+        assert(std::get<1>(t) == alloc_first(2));
+        assert(!alloc_last::allocator_constructed);
+        assert(std::get<2>(t) == alloc_last(3));
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
new file mode 100644
index 0000000..0b210e5
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+//   tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::pair<double, int> T0;
+        typedef std::tuple<int, double> T1;
+        T0 t0(2, 3);
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+    {
+        typedef std::pair<int, int> T0;
+        typedef std::tuple<alloc_first, double> T1;
+        T0 t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+    {
+        typedef std::pair<int, int> T0;
+        typedef std::tuple<alloc_first, alloc_last> T1;
+        T0 t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
new file mode 100644
index 0000000..fd127ca
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+//   tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
+
+#include <tuple>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1(std::allocator_arg, A1<int>(), t0);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<int> T0;
+        typedef std::tuple<alloc_first> T1;
+        T0 t0(2);
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<int, int> T0;
+        typedef std::tuple<alloc_first, alloc_last> T1;
+        T0 t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == 3);
+    }
+    {
+        typedef std::tuple<double, int, int> T0;
+        typedef std::tuple<int, alloc_first, alloc_last> T1;
+        T0 t0(1.5, 2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 1);
+        assert(std::get<1>(t1) == 2);
+        assert(std::get<2>(t1) == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
new file mode 100644
index 0000000..b420588
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+//   tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<int> T0;
+        typedef std::tuple<alloc_first> T1;
+        T0 t0(2);
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<std::unique_ptr<D>> T0;
+        typedef std::tuple<std::unique_ptr<B>> T1;
+        T0 t0(std::unique_ptr<D>(new D(3)));
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(std::get<0>(t1)->id_ == 3);
+    }
+    {
+        typedef std::tuple<int, std::unique_ptr<D>> T0;
+        typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+        T0 t0(2, std::unique_ptr<D>(new D(3)));
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+    {
+        typedef std::tuple<int, int, std::unique_ptr<D>> T0;
+        typedef std::tuple<alloc_last, alloc_first, std::unique_ptr<B>> T1;
+        T0 t0(1, 2, std::unique_ptr<D>(new D(3)));
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t1) == 1);
+        assert(std::get<1>(t1) == 2);
+        assert(std::get<2>(t1)->id_ == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
new file mode 100644
index 0000000..568ed97
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a, const tuple&);
+
+#include <tuple>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t(std::allocator_arg, A1<int>(), t0);
+    }
+    {
+        typedef std::tuple<int> T;
+        T t0(2);
+        T t(std::allocator_arg, A1<int>(), t0);
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<alloc_first> T;
+        T t0(2);
+        alloc_first::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<alloc_last> T;
+        T t0(2);
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<alloc_first, alloc_last> T;
+        T t0(2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 3);
+    }
+    {
+        typedef std::tuple<int, alloc_first, alloc_last> T;
+        T t0(1, 2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), t0);
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 2);
+        assert(std::get<2>(t) == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
new file mode 100644
index 0000000..575a994
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+//   tuple(allocator_arg_t, const Alloc& a, tuple&&);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t(std::allocator_arg, A1<int>(), std::move(t0));
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t(std::allocator_arg, A1<int>(), std::move(t0));
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        typedef std::tuple<alloc_first> T;
+        T t0(1);
+        alloc_first::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+    }
+    {
+        typedef std::tuple<alloc_last> T;
+        T t0(1);
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, alloc_first> T;
+        T t0(0 ,1);
+        alloc_first::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, alloc_first, alloc_last> T;
+        T t0(1, 2, 3);
+        alloc_first::allocator_constructed = false;
+        alloc_last::allocator_constructed = false;
+        T t(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(alloc_last::allocator_constructed);
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 2);
+        assert(std::get<2>(t) == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
new file mode 100644
index 0000000..31c605e
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+//   tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+#include "allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::pair<int, std::unique_ptr<D>> T0;
+        typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+        T0 t0(2, std::unique_ptr<D>(new D(3)));
+        alloc_first::allocator_constructed = false;
+        T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+        assert(alloc_first::allocator_constructed);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp
new file mode 100644
index 0000000..e8a78d1
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::tuple<int*> t = 0;
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
new file mode 100644
index 0000000..04cb3d5
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::tuple<int> t(2);
+        assert(std::get<0>(t) == 2);
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        constexpr std::tuple<int> t(2);
+        static_assert(std::get<0>(t) == 2, "");
+    }
+    {
+        constexpr std::tuple<int> t;
+        static_assert(std::get<0>(t) == 0, "");
+    }
+#endif
+    {
+        std::tuple<int, char*> t(2, 0);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        constexpr std::tuple<int, char*> t(2, nullptr);
+        static_assert(std::get<0>(t) == 2, "");
+        static_assert(std::get<1>(t) == nullptr, "");
+    }
+#endif
+    {
+        std::tuple<int, char*> t(2, nullptr);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+    }
+    {
+        std::tuple<int, char*, std::string> t(2, nullptr, "text");
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "text");
+    }
+    // extensions
+    {
+        std::tuple<int, char*, std::string> t(2);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+    }
+    {
+        std::tuple<int, char*, std::string> t(2, nullptr);
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+    }
+    {
+        std::tuple<int, char*, std::string, double> t(2, nullptr, "text");
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "text");
+        assert(std::get<3>(t) == 0.0);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
new file mode 100644
index 0000000..4b3359e
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        std::tuple<int, char*, std::string, double&> t(2, nullptr, "text");
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
new file mode 100644
index 0000000..d40196b
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(const pair<U1, U2>& u);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<double, char> T0;
+        typedef std::tuple<int, short> T1;
+        T0 t0(2.5, 'a');
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == short('a'));
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef std::pair<double, char> P0;
+        typedef std::tuple<int, short> T1;
+        constexpr P0 p0(2.5, 'a');
+        constexpr T1 t1 = p0;
+        static_assert(std::get<0>(t1) != std::get<0>(p0), "");
+        static_assert(std::get<1>(t1) == std::get<1>(p0), "");
+        static_assert(std::get<0>(t1) == 2, "");
+        static_assert(std::get<1>(t1) == short('a'), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
new file mode 100644
index 0000000..bcdb9d9
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+#if _LIBCPP_STD_VER > 11 
+
+struct A
+{
+    int id_;
+
+    constexpr A(int i) : id_(i) {}
+    friend constexpr bool operator==(const A& x, const A& y) {return x.id_ == y.id_;}
+};
+
+struct C
+{
+    int id_;
+
+    constexpr explicit C(int i) : id_(i) {}
+    friend constexpr bool operator==(const C& x, const C& y) {return x.id_ == y.id_;}
+};
+
+#endif
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<A> T1;
+        constexpr T0 t0(2.5);
+        constexpr T1 t1 = t0;
+        static_assert(std::get<0>(t1) == 2, "");
+    }
+    {
+        typedef std::tuple<int> T0;
+        typedef std::tuple<C> T1;
+        constexpr T0 t0(2);
+        constexpr T1 t1{t0};
+        static_assert(std::get<0>(t1) == C(2), "");
+    }
+#endif
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1 = t0;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d);
+        T1 t1 = t0;
+        d.id_ = 2;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+    {
+        typedef std::tuple<double, char, int> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', 3);
+        T1 t1(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
new file mode 100644
index 0000000..ff19c2e
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(tuple<UTypes...>&& u);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::tuple<double> T0;
+        typedef std::tuple<int> T1;
+        T0 t0(2.5);
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+    }
+    {
+        typedef std::tuple<double, char> T0;
+        typedef std::tuple<int, int> T1;
+        T0 t0(2.5, 'a');
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+    }
+    {
+        typedef std::tuple<double, char, D> T0;
+        typedef std::tuple<int, int, B> T1;
+        T0 t0(2.5, 'a', D(3));
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 3);
+    }
+    {
+        D d(3);
+        typedef std::tuple<double, char, D&> T0;
+        typedef std::tuple<int, int, B&> T1;
+        T0 t0(2.5, 'a', d);
+        T1 t1 = std::move(t0);
+        d.id_ = 2;
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1).id_ == 2);
+    }
+    {
+        typedef std::tuple<double, char, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1) == int('a'));
+        assert(std::get<2>(t1)->id_ == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
new file mode 100644
index 0000000..8b8ec0c
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(2));
+        T t = t0;
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
new file mode 100644
index 0000000..fd953f8
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct Empty {};
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t = t0;
+    }
+    {
+        typedef std::tuple<int> T;
+        T t0(2);
+        T t = t0;
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<int, char> T;
+        T t0(2, 'a');
+        T t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+    }
+    {
+        typedef std::tuple<int, char, std::string> T;
+        const T t0(2, 'a', "some text");
+        T t = t0;
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 'a');
+        assert(std::get<2>(t) == "some text");
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef std::tuple<int> T;
+        constexpr T t0(2);
+        constexpr T t = t0;
+        static_assert(std::get<0>(t) == 2, "");
+    }
+    {
+        typedef std::tuple<Empty> T;
+        constexpr T t0;
+        constexpr T t = t0;
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
new file mode 100644
index 0000000..b72b77e
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// constexpr tuple();
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+#include "DefaultOnly.h"
+
+int main()
+{
+    {
+        std::tuple<> t;
+    }
+    {
+        std::tuple<int> t;
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        std::tuple<int, char*> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+    }
+    {
+        std::tuple<int, char*, std::string> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+    }
+    {
+        std::tuple<int, char*, std::string, DefaultOnly> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+        assert(std::get<2>(t) == "");
+        assert(std::get<3>(t) == DefaultOnly());
+    }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+        constexpr std::tuple<> t;
+    }
+    {
+        constexpr std::tuple<int> t;
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        constexpr std::tuple<int, char*> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
new file mode 100644
index 0000000..41e4b66
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(tuple&& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t = std::move(t0);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t = std::move(t0);
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 1);
+        assert(std::get<2>(t) == 2);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
new file mode 100644
index 0000000..05d7845
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(pair<U1, U2>&& u);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+    int id_;
+
+    explicit B(int i) : id_(i) {}
+
+    virtual ~B() {}
+};
+
+struct D
+    : B
+{
+    explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+    {
+        typedef std::pair<double, std::unique_ptr<D>> T0;
+        typedef std::tuple<int, std::unique_ptr<B>> T1;
+        T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+        T1 t1 = std::move(t0);
+        assert(std::get<0>(t1) == 2);
+        assert(std::get<1>(t1)->id_ == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp
new file mode 100644
index 0000000..5e84ff8
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template<class... Types>
+//     tuple<Types&&...> forward_as_tuple(Types&&... t);
+
+#include <tuple>
+#include <cassert>
+
+template <class Tuple>
+void
+test0(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 0, "");
+}
+
+template <class Tuple>
+void
+test1a(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 1, "");
+    static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, int&&>::value, "");
+    assert(std::get<0>(t) == 1);
+}
+
+template <class Tuple>
+void
+test1b(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 1, "");
+    static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, int&>::value, "");
+    assert(std::get<0>(t) == 2);
+}
+
+template <class Tuple>
+void
+test2a(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 2, "");
+    static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, double&>::value, "");
+    static_assert(std::is_same<typename std::tuple_element<1, Tuple>::type, char&>::value, "");
+    assert(std::get<0>(t) == 2.5);
+    assert(std::get<1>(t) == 'a');
+}
+
+#if _LIBCPP_STD_VER > 11
+template <class Tuple>
+constexpr int 
+test3(const Tuple& t)
+{
+    return std::tuple_size<Tuple>::value;
+}
+#endif
+
+int main()
+{
+    {
+        test0(std::forward_as_tuple());
+    }
+    {
+        test1a(std::forward_as_tuple(1));
+    }
+    {
+        int i = 2;
+        test1b(std::forward_as_tuple(i));
+    }
+    {
+        double i = 2.5;
+        char c = 'a';
+        test2a(std::forward_as_tuple(i, c));
+#if _LIBCPP_STD_VER > 11
+        static_assert ( test3 (std::forward_as_tuple(i, c)) == 2, "" );
+#endif
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
new file mode 100644
index 0000000..5b33d1a
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+//   tuple<VTypes...> make_tuple(Types&&... t);
+
+#include <tuple>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+    {
+        int i = 0;
+        float j = 0;
+        std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i),
+                                                          std::ref(j));
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 0);
+        assert(std::get<2>(t) == 0);
+        i = 2;
+        j = 3.5;
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 2);
+        assert(std::get<2>(t) == 3.5);
+        std::get<1>(t) = 0;
+        std::get<2>(t) = 0;
+        assert(i == 0);
+        assert(j == 0);
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        constexpr auto t1 = std::make_tuple(0, 1, 3.14);
+        constexpr int i1 = std::get<1>(t1);
+        constexpr double d1 = std::get<2>(t1);
+        static_assert (i1 == 1, "" );
+        static_assert (d1 == 3.14, "" );
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
new file mode 100644
index 0000000..e6ebf95
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+//   tuple<Types&...> tie(Types&... t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        int i = 0;
+        std::string s;
+        std::tie(i, std::ignore, s) = std::make_tuple(42, 3.14, "C++");
+        assert(i == 42);
+        assert(s == "C++");
+    }
+#if _LIBCPP_STD_VER > 11
+    {
+        static constexpr int i = 42;
+        static constexpr double f = 1.1;
+        constexpr std::tuple<const int &, const double &> t = std::tie(i, f);
+        static_assert ( std::get<0>(t) == 42, "" );
+        static_assert ( std::get<1>(t) == 1.1, "" );
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
new file mode 100644
index 0000000..b47842d
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
@@ -0,0 +1,216 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls);
+
+#include <tuple>
+#include <utility>
+#include <array>
+#include <string>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        std::tuple<> t = std::tuple_cat();
+    }
+    {
+        std::tuple<> t1;
+        std::tuple<> t2 = std::tuple_cat(t1);
+    }
+    {
+        std::tuple<> t = std::tuple_cat(std::tuple<>());
+    }
+    {
+        std::tuple<> t = std::tuple_cat(std::array<int, 0>());
+    }
+    {
+        std::tuple<int> t1(1);
+        std::tuple<int> t = std::tuple_cat(t1);
+        assert(std::get<0>(t) == 1);
+    }
+
+#if _LIBCPP_STD_VER > 11 
+    {
+        constexpr std::tuple<> t = std::tuple_cat();
+    }
+    {
+        constexpr std::tuple<> t1;
+        constexpr std::tuple<> t2 = std::tuple_cat(t1);
+    }
+    {
+        constexpr std::tuple<> t = std::tuple_cat(std::tuple<>());
+    }
+    {
+        constexpr std::tuple<> t = std::tuple_cat(std::array<int, 0>());
+    }
+    {
+        constexpr std::tuple<int> t1(1);
+        constexpr std::tuple<int> t = std::tuple_cat(t1);
+        static_assert(std::get<0>(t) == 1, "");
+    }
+    {
+        constexpr std::tuple<int> t1(1);
+        constexpr std::tuple<int, int> t = std::tuple_cat(t1, t1);
+        static_assert(std::get<0>(t) == 1, "");
+        static_assert(std::get<1>(t) == 1, "");
+    }
+#endif
+    {
+        std::tuple<int, MoveOnly> t =
+                                std::tuple_cat(std::tuple<int, MoveOnly>(1, 2));
+        assert(std::get<0>(t) == 1);
+        assert(std::get<1>(t) == 2);
+    }
+    {
+        std::tuple<int, int, int> t = std::tuple_cat(std::array<int, 3>());
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == 0);
+        assert(std::get<2>(t) == 0);
+    }
+    {
+        std::tuple<int, MoveOnly> t = std::tuple_cat(std::pair<int, MoveOnly>(2, 1));
+        assert(std::get<0>(t) == 2);
+        assert(std::get<1>(t) == 1);
+    }
+
+    {
+        std::tuple<> t1;
+        std::tuple<> t2;
+        std::tuple<> t3 = std::tuple_cat(t1, t2);
+    }
+    {
+        std::tuple<> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int> t3 = std::tuple_cat(t1, t2);
+        assert(std::get<0>(t3) == 2);
+    }
+    {
+        std::tuple<> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int> t3 = std::tuple_cat(t2, t1);
+        assert(std::get<0>(t3) == 2);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int*, int> t3 = std::tuple_cat(t1, t2);
+        assert(std::get<0>(t3) == nullptr);
+        assert(std::get<1>(t3) == 2);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int> t2(2);
+        std::tuple<int, int*> t3 = std::tuple_cat(t2, t1);
+        assert(std::get<0>(t3) == 2);
+        assert(std::get<1>(t3) == nullptr);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int*, int, double> t3 = std::tuple_cat(t1, t2);
+        assert(std::get<0>(t3) == nullptr);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == 3.5);
+    }
+    {
+        std::tuple<int*> t1;
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int, double, int*> t3 = std::tuple_cat(t2, t1);
+        assert(std::get<0>(t3) == 2);
+        assert(std::get<1>(t3) == 3.5);
+        assert(std::get<2>(t3) == nullptr);
+    }
+    {
+        std::tuple<int*, MoveOnly> t1(nullptr, 1);
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int*, MoveOnly, int, double> t3 =
+                                              std::tuple_cat(std::move(t1), t2);
+        assert(std::get<0>(t3) == nullptr);
+        assert(std::get<1>(t3) == 1);
+        assert(std::get<2>(t3) == 2);
+        assert(std::get<3>(t3) == 3.5);
+    }
+    {
+        std::tuple<int*, MoveOnly> t1(nullptr, 1);
+        std::tuple<int, double> t2(2, 3.5);
+        std::tuple<int, double, int*, MoveOnly> t3 =
+                                              std::tuple_cat(t2, std::move(t1));
+        assert(std::get<0>(t3) == 2);
+        assert(std::get<1>(t3) == 3.5);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 1);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+        std::tuple<int*, MoveOnly> t2(nullptr, 4);
+        std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+                                   std::tuple_cat(std::move(t1), std::move(t2));
+        assert(std::get<0>(t3) == 1);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 4);
+    }
+
+    {
+        std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+        std::tuple<int*, MoveOnly> t2(nullptr, 4);
+        std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+                                   std::tuple_cat(std::tuple<>(),
+                                                  std::move(t1),
+                                                  std::move(t2));
+        assert(std::get<0>(t3) == 1);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 4);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+        std::tuple<int*, MoveOnly> t2(nullptr, 4);
+        std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+                                   std::tuple_cat(std::move(t1),
+                                                  std::tuple<>(),
+                                                  std::move(t2));
+        assert(std::get<0>(t3) == 1);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 4);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+        std::tuple<int*, MoveOnly> t2(nullptr, 4);
+        std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+                                   std::tuple_cat(std::move(t1),
+                                                  std::move(t2),
+                                                  std::tuple<>());
+        assert(std::get<0>(t3) == 1);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 4);
+    }
+    {
+        std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+        std::tuple<int*, MoveOnly> t2(nullptr, 4);
+        std::tuple<MoveOnly, MoveOnly, int*, MoveOnly, int> t3 =
+                                   std::tuple_cat(std::move(t1),
+                                                  std::move(t2),
+                                                  std::tuple<int>(5));
+        assert(std::get<0>(t3) == 1);
+        assert(std::get<1>(t3) == 2);
+        assert(std::get<2>(t3) == nullptr);
+        assert(std::get<3>(t3) == 4);
+        assert(std::get<4>(t3) == 5);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
new file mode 100644
index 0000000..d6e8811
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+//   typename tuple_element<I, tuple<Types...> >::type const&
+//   get(const tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<double&, std::string, int> T;
+        double d = 1.5;
+        const T t(d, "high", 5);
+        assert(std::get<0>(t) == 1.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        std::get<0>(t) = 2.5;
+        assert(std::get<0>(t) == 2.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        assert(d == 2.5);
+
+        std::get<1>(t) = "four";
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
new file mode 100644
index 0000000..0ba898d
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+//   typename tuple_element<I, tuple<Types...> >::type const&
+//   get(const tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct Empty {};
+
+int main()
+{
+    {
+        typedef std::tuple<int> T;
+        const T t(3);
+        assert(std::get<0>(t) == 3);
+    }
+    {
+        typedef std::tuple<std::string, int> T;
+        const T t("high", 5);
+        assert(std::get<0>(t) == "high");
+        assert(std::get<1>(t) == 5);
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef std::tuple<double, int> T;
+        constexpr T t(2.718, 5);
+        static_assert(std::get<0>(t) == 2.718, "");
+        static_assert(std::get<1>(t) == 5, "");
+    }
+    {
+        typedef std::tuple<Empty> T;
+        constexpr T t{Empty()};
+        constexpr Empty e = std::get<0>(t);
+    }
+#endif
+    {
+        typedef std::tuple<double&, std::string, int> T;
+        double d = 1.5;
+        const T t(d, "high", 5);
+        assert(std::get<0>(t) == 1.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        std::get<0>(t) = 2.5;
+        assert(std::get<0>(t) == 2.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        assert(d == 2.5);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
new file mode 100644
index 0000000..3b98b5e
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+//   typename tuple_element<I, tuple<Types...> >::type&
+//   get(tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+#if __cplusplus > 201103L
+
+struct Empty {};
+
+struct S {
+   std::tuple<int, Empty> a;
+   int k;
+   Empty e;
+   constexpr S() : a{1,Empty{}}, k(std::get<0>(a)), e(std::get<1>(a)) {}
+   };
+
+constexpr std::tuple<int, int> getP () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+    {
+        typedef std::tuple<int> T;
+        T t(3);
+        assert(std::get<0>(t) == 3);
+        std::get<0>(t) = 2;
+        assert(std::get<0>(t) == 2);
+    }
+    {
+        typedef std::tuple<std::string, int> T;
+        T t("high", 5);
+        assert(std::get<0>(t) == "high");
+        assert(std::get<1>(t) == 5);
+        std::get<0>(t) = "four";
+        std::get<1>(t) = 4;
+        assert(std::get<0>(t) == "four");
+        assert(std::get<1>(t) == 4);
+    }
+    {
+        typedef std::tuple<double&, std::string, int> T;
+        double d = 1.5;
+        T t(d, "high", 5);
+        assert(std::get<0>(t) == 1.5);
+        assert(std::get<1>(t) == "high");
+        assert(std::get<2>(t) == 5);
+        std::get<0>(t) = 2.5;
+        std::get<1>(t) = "four";
+        std::get<2>(t) = 4;
+        assert(std::get<0>(t) == 2.5);
+        assert(std::get<1>(t) == "four");
+        assert(std::get<2>(t) == 4);
+        assert(d == 2.5);
+    }
+#if _LIBCPP_STD_VER > 11 
+    { // get on an rvalue tuple
+        static_assert ( std::get<0> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 0, "" );
+        static_assert ( std::get<1> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 1, "" );
+        static_assert ( std::get<2> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 2, "" );
+        static_assert ( std::get<3> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 3, "" );
+        static_assert(S().k == 1, "");
+        static_assert(std::get<1>(getP()) == 4, "");
+    }
+#endif
+
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp
new file mode 100644
index 0000000..5a97710
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/get_rv.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+//   typename tuple_element<I, tuple<Types...> >::type&&
+//   get(tuple<Types...>&& t);
+
+#include <tuple>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<std::unique_ptr<int> > T;
+        T t(std::unique_ptr<int>(new int(3)));
+        std::unique_ptr<int> p = std::get<0>(std::move(t));
+        assert(*p == 3);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
new file mode 100644
index 0000000..5cc33e1
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::complex<float> cf;
+    {
+    auto t1 = std::tuple<int, std::string, cf> { 42, "Hi", { 1,2 }};
+    assert ( std::get<int>(t1) == 42 ); // find at the beginning 
+    assert ( std::get<std::string>(t1) == "Hi" ); // find in the middle
+    assert ( std::get<cf>(t1).real() == 1 ); // find at the end
+    assert ( std::get<cf>(t1).imag() == 2 );
+    }
+    
+    {
+    auto t2 = std::tuple<int, std::string, int, cf> { 42, "Hi", 23, { 1,2 }};
+//  get<int> would fail!
+    assert ( std::get<std::string>(t2) == "Hi" );
+    assert (( std::get<cf>(t2) == cf{ 1,2 } ));
+    }
+    
+    {
+    constexpr std::tuple<int, const int, double, double> p5 { 1, 2, 3.4, 5.6 };
+    static_assert ( std::get<int>(p5) == 1, "" );
+    static_assert ( std::get<const int>(p5) == 2, "" );
+    }
+
+    {
+    const std::tuple<int, const int, double, double> p5 { 1, 2, 3.4, 5.6 };
+    const int &i1 = std::get<int>(p5);
+    const int &i2 = std::get<const int>(p5);
+    assert ( i1 == 1 );
+    assert ( i2 == 2 );
+    }
+
+    {
+    typedef std::unique_ptr<int> upint;
+    std::tuple<upint> t(upint(new int(4)));
+    upint p = std::get<upint>(std::move(t)); // get rvalue
+    assert(*p == 4);
+    assert(std::get<0>(t) == nullptr); // has been moved from
+    }
+
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
new file mode 100644
index 0000000..ec63a39
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type1.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::complex<float> cf;
+    auto t1 = std::make_tuple<int, std::string> ( 42, "Hi" );
+    assert ( std::get<cf>(t1) == cf {1,2} );    // no such type
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
new file mode 100644
index 0000000..fde7c69
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::complex<float> cf;
+    auto t1 = std::make_tuple<int, int, std::string, cf> ( 42, 21, "Hi", { 1,2 } );
+    assert ( std::get<int>(t1) == 42 ); // two ints here
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
new file mode 100644
index 0000000..f188171
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type3.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <tuple>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::complex<float> cf;
+    auto t1 = std::make_tuple<double, int, std::string, cf, int> ( 42, 21, "Hi", { 1,2 } );
+    assert ( std::get<int>(t1) == 42 ); // two ints here (one at the end)
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
new file mode 100644
index 0000000..b6d5773
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type4.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <tuple>
+#include <string>
+#include <memory>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::unique_ptr<int> upint;
+    std::tuple<upint> t(upint(new int(4)));
+    upint p = std::get<upint>(t);
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
new file mode 100644
index 0000000..f3f8f2b
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// class tuple_element<I, tuple<Types...> >
+// {
+// public:
+//     typedef Ti type;
+// };
+
+#include <tuple>
+#include <type_traits>
+
+template <class T, std::size_t N, class U>
+void test()
+{
+    static_assert((std::is_same<typename std::tuple_element<N, T>::type, U>::value), "");
+    static_assert((std::is_same<typename std::tuple_element<N, const T>::type, const U>::value), "");
+    static_assert((std::is_same<typename std::tuple_element<N, volatile T>::type, volatile U>::value), "");
+    static_assert((std::is_same<typename std::tuple_element<N, const volatile T>::type, const volatile U>::value), "");
+#if _LIBCPP_STD_VER > 11
+    static_assert((std::is_same<typename std::tuple_element_t<N, T>, U>::value), "");
+    static_assert((std::is_same<typename std::tuple_element_t<N, const T>, const U>::value), "");
+    static_assert((std::is_same<typename std::tuple_element_t<N, volatile T>, volatile U>::value), "");
+    static_assert((std::is_same<typename std::tuple_element_t<N, const volatile T>, const volatile U>::value), "");
+#endif
+}
+
+int main()
+{
+    test<std::tuple<int>, 0, int>();
+    test<std::tuple<char, int>, 0, char>();
+    test<std::tuple<char, int>, 1, int>();
+    test<std::tuple<int*, char, int>, 0, int*>();
+    test<std::tuple<int*, char, int>, 1, char>();
+    test<std::tuple<int*, char, int>, 2, int>();
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
new file mode 100644
index 0000000..6db5823
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+//   class tuple_size<tuple<Types...>>
+//     : public integral_constant<size_t, sizeof...(Types)> { };
+
+#include <tuple>
+#include <type_traits>
+
+template <class T, std::size_t N>
+void test()
+{
+    static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+                                   std::tuple_size<T> >::value), "");
+    static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+                                   std::tuple_size<const T> >::value), "");
+    static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+                                   std::tuple_size<volatile T> >::value), "");
+    static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
+                                   std::tuple_size<const volatile T> >::value), "");
+}
+
+int main()
+{
+    test<std::tuple<>, 0>();
+    test<std::tuple<int>, 1>();
+    test<std::tuple<char, int>, 2>();
+    test<std::tuple<char, char*, int>, 3>();
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
new file mode 100644
index 0000000..e05cd61
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<> T1;
+        typedef std::tuple<> T2;
+        const T1 t1;
+        const T2 t2;
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<int> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1.1);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<int> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1);
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, char(2));
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, char(3));
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1.1, char(2));
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<int, double> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1.1, char(3));
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 3);
+        assert(t1 == t2);
+        assert(!(t1 != t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 2, 3);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 3, 3);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 4);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 3, 2);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 2, 2);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 3, 3);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 3, 2);
+        assert(!(t1 == t2));
+        assert(t1 != t2);
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        constexpr T1 t1(1, 2, 3);
+        constexpr T2 t2(1.1, 3, 2);
+        static_assert(!(t1 == t2), "");
+        static_assert(t1 != t2, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
new file mode 100644
index 0000000..f09a105
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
@@ -0,0 +1,208 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+//   bool
+//   operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::tuple<> T1;
+        typedef std::tuple<> T2;
+        const T1 t1;
+        const T2 t2;
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1);
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(0.9);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char> T1;
+        typedef std::tuple<double> T2;
+        const T1 t1(1);
+        const T2 t2(1.1);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, 2);
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(0.9, 2);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1.1, 2);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, 1);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int> T1;
+        typedef std::tuple<double, char> T2;
+        const T1 t1(1, 2);
+        const T2 t2(1, 3);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 3);
+        assert(!(t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(0.9, 2, 3);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1.1, 2, 3);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 1, 3);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 3, 3);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 2);
+        assert(!(t1 <  t2));
+        assert(!(t1 <= t2));
+        assert( (t1 >  t2));
+        assert( (t1 >= t2));
+    }
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        const T1 t1(1, 2, 3);
+        const T2 t2(1, 2, 4);
+        assert( (t1 <  t2));
+        assert( (t1 <= t2));
+        assert(!(t1 >  t2));
+        assert(!(t1 >= t2));
+    }
+#if _LIBCPP_STD_VER > 11 
+    {
+        typedef std::tuple<char, int, double> T1;
+        typedef std::tuple<double, char, int> T2;
+        constexpr T1 t1(1, 2, 3);
+        constexpr T2 t2(1, 2, 4);
+        static_assert( (t1 <  t2), "");
+        static_assert( (t1 <= t2), "");
+        static_assert(!(t1 >  t2), "");
+        static_assert(!(t1 >= t2), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
new file mode 100644
index 0000000..415e964
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+//   void swap(tuple<Types...>& x, tuple<Types...>& y);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t1;
+        swap(t0, t1);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t1(MoveOnly(1));
+        swap(t0, t1);
+        assert(std::get<0>(t0) == 1);
+        assert(std::get<0>(t1) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t1(MoveOnly(2), MoveOnly(3));
+        swap(t0, t1);
+        assert(std::get<0>(t0) == 2);
+        assert(std::get<1>(t0) == 3);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+        swap(t0, t1);
+        assert(std::get<0>(t0) == 3);
+        assert(std::get<1>(t0) == 4);
+        assert(std::get<2>(t0) == 5);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+        assert(std::get<2>(t1) == 2);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
new file mode 100644
index 0000000..c7c96f8
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// void swap(tuple& rhs);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        T t0;
+        T t1;
+        t0.swap(t1);
+    }
+    {
+        typedef std::tuple<MoveOnly> T;
+        T t0(MoveOnly(0));
+        T t1(MoveOnly(1));
+        t0.swap(t1);
+        assert(std::get<0>(t0) == 1);
+        assert(std::get<0>(t1) == 0);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1));
+        T t1(MoveOnly(2), MoveOnly(3));
+        t0.swap(t1);
+        assert(std::get<0>(t0) == 2);
+        assert(std::get<1>(t0) == 3);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+    }
+    {
+        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+        T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+        t0.swap(t1);
+        assert(std::get<0>(t0) == 3);
+        assert(std::get<1>(t0) == 4);
+        assert(std::get<2>(t0) == 5);
+        assert(std::get<0>(t1) == 0);
+        assert(std::get<1>(t1) == 1);
+        assert(std::get<2>(t1) == 2);
+    }
+}
diff --git a/final/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp b/final/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp
new file mode 100644
index 0000000..c81835c
--- /dev/null
+++ b/final/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types, class Alloc>
+//   struct uses_allocator<tuple<Types...>, Alloc> : true_type { };
+
+#include <tuple>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+    {
+        typedef std::tuple<> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+    {
+        typedef std::tuple<int> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+    {
+        typedef std::tuple<char, int> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+    {
+        typedef std::tuple<double&, char, int> T;
+        static_assert((std::is_base_of<std::true_type,
+                                       std::uses_allocator<T, A>>::value), "");
+    }
+}
diff --git a/final/test/utilities/tuple/version.pass.cpp b/final/test/utilities/tuple/version.pass.cpp
new file mode 100644
index 0000000..2fdbb5d
--- /dev/null
+++ b/final/test/utilities/tuple/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+#include <tuple>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/type.index/type.index.hash/hash.pass.cpp b/final/test/utilities/type.index/type.index.hash/hash.pass.cpp
new file mode 100644
index 0000000..259f313
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.hash/hash.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// template <>
+// struct hash<type_index>
+//     : public unary_function<type_index, size_t>
+// {
+//     size_t operator()(type_index index) const;
+// };
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+    assert(std::hash<std::type_index>()(t1) == t1.hash_code());
+}
diff --git a/final/test/utilities/type.index/type.index.members/ctor.pass.cpp b/final/test/utilities/type.index/type.index.members/ctor.pass.cpp
new file mode 100644
index 0000000..2904e4a
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.members/ctor.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index(const type_info& rhs);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+}
diff --git a/final/test/utilities/type.index/type.index.members/eq.pass.cpp b/final/test/utilities/type.index/type.index.members/eq.pass.cpp
new file mode 100644
index 0000000..b6bbd1d
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.members/eq.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// bool operator==(const type_index& rhs) const;
+// bool operator!=(const type_index& rhs) const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+    std::type_index t2 = typeid(int);
+    std::type_index t3 = typeid(long);
+    assert(t1 == t2);
+    assert(t1 != t3);
+}
diff --git a/final/test/utilities/type.index/type.index.members/hash_code.pass.cpp b/final/test/utilities/type.index/type.index.members/hash_code.pass.cpp
new file mode 100644
index 0000000..b4f3168
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.members/hash_code.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// size_t hash_code() const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& ti = typeid(int);
+    std::type_index t1 = typeid(int);
+    assert(t1.hash_code() == ti.hash_code());
+}
diff --git a/final/test/utilities/type.index/type.index.members/lt.pass.cpp b/final/test/utilities/type.index/type.index.members/lt.pass.cpp
new file mode 100644
index 0000000..c099d1c
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.members/lt.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// bool operator< (const type_index& rhs) const;
+// bool operator<=(const type_index& rhs) const;
+// bool operator> (const type_index& rhs) const;
+// bool operator>=(const type_index& rhs) const;
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1 = typeid(int);
+    std::type_index t2 = typeid(int);
+    std::type_index t3 = typeid(long);
+    assert(!(t1 <  t2));
+    assert( (t1 <= t2));
+    assert(!(t1 >  t2));
+    assert( (t1 >= t2));
+    if (t1 < t3)
+    {
+        assert( (t1 <  t3));
+        assert( (t1 <= t3));
+        assert(!(t1 >  t3));
+        assert(!(t1 >= t3));
+    }
+    else
+    {
+        assert(!(t1 <  t3));
+        assert(!(t1 <= t3));
+        assert( (t1 >  t3));
+        assert( (t1 >= t3));
+    }
+}
diff --git a/final/test/utilities/type.index/type.index.members/name.pass.cpp b/final/test/utilities/type.index/type.index.members/name.pass.cpp
new file mode 100644
index 0000000..44ee215
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.members/name.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// const char* name() const;
+
+#include <typeindex>
+#include <string>
+#include <cassert>
+
+int main()
+{
+    const std::type_info& ti = typeid(int);
+    std::type_index t1 = typeid(int);
+    assert(std::string(t1.name()) == ti.name());
+}
diff --git a/final/test/utilities/type.index/type.index.overview/copy_assign.pass.cpp b/final/test/utilities/type.index/type.index.overview/copy_assign.pass.cpp
new file mode 100644
index 0000000..234e26b
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.overview/copy_assign.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index& operator=(const type_index& ti);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1(typeid(int));
+    std::type_index t2(typeid(double));
+    assert(t2 != t1);
+    t2 = t1;
+    assert(t2 == t1);
+}
diff --git a/final/test/utilities/type.index/type.index.overview/copy_ctor.pass.cpp b/final/test/utilities/type.index/type.index.overview/copy_ctor.pass.cpp
new file mode 100644
index 0000000..499c4b6
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.overview/copy_ctor.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// class type_index
+
+// type_index(const type_index& ti);
+
+#include <typeindex>
+#include <cassert>
+
+int main()
+{
+    std::type_index t1(typeid(int));
+    std::type_index t2 = t1;
+    assert(t2 == t1);
+}
diff --git a/final/test/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp b/final/test/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
new file mode 100644
index 0000000..b855d12
--- /dev/null
+++ b/final/test/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+// struct hash<type_index>
+//     : public unary_function<type_index, size_t>
+// {
+//     size_t operator()(type_index index) const;
+// };
+
+#include <typeindex>
+#include <type_traits>
+
+int main()
+{
+    static_assert((std::is_base_of<std::unary_function<std::type_index, std::size_t>,
+                                   std::hash<std::type_index> >::value), "");
+}
diff --git a/final/test/utilities/type.index/version.pass.cpp b/final/test/utilities/type.index/version.pass.cpp
new file mode 100644
index 0000000..26f4620
--- /dev/null
+++ b/final/test/utilities/type.index/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <typeindex>
+
+#include <typeindex>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/test/utilities/utilities.general/nothing_to_do.pass.cpp b/final/test/utilities/utilities.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utilities.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp b/final/test/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility.requirements/allocator.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp b/final/test/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility.requirements/hash.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility.requirements/nothing_to_do.pass.cpp b/final/test/utilities/utility.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp b/final/test/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility.requirements/nullablepointer.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp b/final/test/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility.requirements/swappable.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp b/final/test/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility.requirements/utility.arg.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility/declval/declval.pass.cpp b/final/test/utilities/utility/declval/declval.pass.cpp
new file mode 100644
index 0000000..81f4df8
--- /dev/null
+++ b/final/test/utilities/utility/declval/declval.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
+
+#include <utility>
+#include <type_traits>
+
+class A
+{
+    A(const A&);
+    A& operator=(const A&);
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert((std::is_same<decltype(std::declval<A>()), A&&>::value), "");
+#else
+    static_assert((std::is_same<decltype(std::declval<A>()), A>::value), "");
+#endif
+}
diff --git a/final/test/utilities/utility/exchange/exchange.pass.cpp b/final/test/utilities/utility/exchange/exchange.pass.cpp
new file mode 100644
index 0000000..620b414
--- /dev/null
+++ b/final/test/utilities/utility/exchange/exchange.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// utilities
+
+// exchange
+
+#include <utility>
+#include <cassert>
+#include <string>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    int v = 12;
+    assert ( std::exchange ( v, 23 ) == 12 );
+    assert ( v == 23 );
+    assert ( std::exchange ( v, 67.2 ) == 23 );
+    assert ( v == 67 );
+
+    assert ((std::exchange<int, float> ( v, {} )) == 67 );
+    assert ( v == 0 );
+    
+    }
+
+    {
+    bool b = false;
+    assert ( !std::exchange ( b, true ));
+    assert ( b );
+    }
+
+    {
+    const std::string s1 ( "Hi Mom!" );
+    const std::string s2 ( "Yo Dad!" );
+    std::string s3 = s1; // Mom
+    assert ( std::exchange ( s3, s2 ) == s1 );
+    assert ( s3 == s2 );
+    assert ( std::exchange ( s3, "Hi Mom!" ) == s2 );
+    assert ( s3 == s1 );
+
+    s3 = s2; // Dad
+    assert ( std::exchange ( s3, {} ) == s2 );
+    assert ( s3.size () == 0 );
+    
+    s3 = s2; // Dad
+    assert ( std::exchange ( s3, "" ) == s2 );
+    assert ( s3.size () == 0 );
+    }
+
+#endif
+}
diff --git a/final/test/utilities/utility/forward/forward.pass.cpp b/final/test/utilities/utility/forward/forward.pass.cpp
new file mode 100644
index 0000000..357b36f
--- /dev/null
+++ b/final/test/utilities/utility/forward/forward.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+#include <cassert>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+typedef char one;
+struct two {one _[2];};
+struct four {one _[4];};
+struct eight {one _[8];};
+
+one test(A&);
+two test(const A&);
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+four test(A&&);
+eight test(const A&&);
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    A a;
+    const A ca = A();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
+    static_assert(sizeof(test(std::forward<A>(a))) == 4, "");
+    static_assert(sizeof(test(std::forward<A>(source()))) == 4, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
+//    static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(a))) == 8, "");
+    static_assert(sizeof(test(std::forward<const A>(source()))) == 8, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
+//    static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(ca))) == 8, "");
+    static_assert(sizeof(test(std::forward<const A>(csource()))) == 8, "");
+
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    static_assert(sizeof(test(std::forward<A&>(a))) == 1, "");
+    static_assert(sizeof(test(std::forward<A>(a))) == 1, "");
+//    static_assert(sizeof(test(std::forward<A>(source()))) == 2, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(a))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A&>(source()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(a))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(source()))) == 2, "");
+
+    static_assert(sizeof(test(std::forward<const A&>(ca))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A&>(csource()))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(ca))) == 2, "");
+    static_assert(sizeof(test(std::forward<const A>(csource()))) == 2, "");
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#if _LIBCPP_STD_VER > 11
+    constexpr int i1 = std::move(23);
+    static_assert(i1 == 23, "" );
+    constexpr int i2 = std::forward<int>(42);
+    static_assert(i2 == 42, "" );
+#endif
+}
diff --git a/final/test/utilities/utility/forward/forward1.fail.cpp b/final/test/utilities/utility/forward/forward1.fail.cpp
new file mode 100644
index 0000000..43884d5
--- /dev/null
+++ b/final/test/utilities/utility/forward/forward1.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    std::forward<A&>(source());  // error
+}
diff --git a/final/test/utilities/utility/forward/forward2.fail.cpp b/final/test/utilities/utility/forward/forward2.fail.cpp
new file mode 100644
index 0000000..9ff0723
--- /dev/null
+++ b/final/test/utilities/utility/forward/forward2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    const A ca = A();
+    std::forward<A&>(ca);  // error
+}
diff --git a/final/test/utilities/utility/forward/forward3.fail.cpp b/final/test/utilities/utility/forward/forward3.fail.cpp
new file mode 100644
index 0000000..7e1e9b3
--- /dev/null
+++ b/final/test/utilities/utility/forward/forward3.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    std::forward<A&>(csource());  // error
+}
diff --git a/final/test/utilities/utility/forward/forward4.fail.cpp b/final/test/utilities/utility/forward/forward4.fail.cpp
new file mode 100644
index 0000000..276506f
--- /dev/null
+++ b/final/test/utilities/utility/forward/forward4.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    const A ca = A();
+    std::forward<A>(ca);  // error
+}
diff --git a/final/test/utilities/utility/forward/forward5.fail.cpp b/final/test/utilities/utility/forward/forward5.fail.cpp
new file mode 100644
index 0000000..86c2b56
--- /dev/null
+++ b/final/test/utilities/utility/forward/forward5.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+int main()
+{
+    const A ca = A();
+    std::forward<A>(csource());  // error
+}
diff --git a/final/test/utilities/utility/forward/forward6.fail.cpp b/final/test/utilities/utility/forward/forward6.fail.cpp
new file mode 100644
index 0000000..1f4b37d
--- /dev/null
+++ b/final/test/utilities/utility/forward/forward6.fail.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test forward
+
+#include <utility>
+
+struct A
+{
+};
+
+int main()
+{
+    A a;
+    std::forward(a);  // error
+}
diff --git a/final/test/utilities/utility/forward/move_copy.pass.cpp b/final/test/utilities/utility/forward/move_copy.pass.cpp
new file mode 100644
index 0000000..461a876
--- /dev/null
+++ b/final/test/utilities/utility/forward/move_copy.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+int copy_ctor = 0;
+int move_ctor = 0;
+
+class A
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else
+#endif
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    A(const A&) {++copy_ctor;}
+    A& operator=(const A&);
+
+    A(A&&) {++move_ctor;}
+    A& operator=(A&&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    A(const A&) {++copy_ctor;}
+    A& operator=(A&);
+
+    operator std::__rv<A> () {return std::__rv<A>(*this);}
+    A(std::__rv<A>) {++move_ctor;}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    A() {}
+};
+
+A source() {return A();}
+const A csource() {return A();}
+
+void test(A) {}
+
+int main()
+{
+    A a;
+    const A ca = A();
+
+    assert(copy_ctor == 0);
+    assert(move_ctor == 0);
+
+    A a2 = a;
+    assert(copy_ctor == 1);
+    assert(move_ctor == 0);
+
+    A a3 = std::move(a);
+    assert(copy_ctor == 1);
+    assert(move_ctor == 1);
+
+    A a4 = ca;
+    assert(copy_ctor == 2);
+    assert(move_ctor == 1);
+
+    A a5 = std::move(ca);
+    assert(copy_ctor == 3);
+    assert(move_ctor == 1);
+}
diff --git a/final/test/utilities/utility/forward/move_if_noexcept.pass.cpp b/final/test/utilities/utility/forward/move_if_noexcept.pass.cpp
new file mode 100644
index 0000000..f94ff2a
--- /dev/null
+++ b/final/test/utilities/utility/forward/move_if_noexcept.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T>
+//     typename conditional
+//     <
+//         !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
+//         const T&,
+//         T&&
+//     >::type
+//     move_if_noexcept(T& x);
+
+#include <utility>
+
+class A
+{
+    A(const A&);
+    A& operator=(const A&);
+public:
+
+    A() {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    A(A&&) {}
+#endif
+};
+
+struct legacy
+{
+    legacy() {}
+    legacy(const legacy&);
+};
+
+int main()
+{
+    int i = 0;
+    const int ci = 0;
+
+    legacy l;
+    A a;
+    const A ca;
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(a)), A&&>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A>::value), "");
+    static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A>::value), "");
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
+
+#if _LIBCPP_STD_VER > 11
+    constexpr int i1 = 23;
+    constexpr int i2 = std::move_if_noexcept(i1);
+    static_assert(i2 == 23, "" );
+#endif
+
+}
diff --git a/final/test/utilities/utility/forward/move_only.pass.cpp b/final/test/utilities/utility/forward/move_only.pass.cpp
new file mode 100644
index 0000000..0588c11
--- /dev/null
+++ b/final/test/utilities/utility/forward/move_only.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {return *this;}
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only mo;
+
+    test(std::move(mo));
+    test(source());
+}
diff --git a/final/test/utilities/utility/forward/move_only1.fail.cpp b/final/test/utilities/utility/forward/move_only1.fail.cpp
new file mode 100644
index 0000000..5e7623a
--- /dev/null
+++ b/final/test/utilities/utility/forward/move_only1.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(a);
+}
diff --git a/final/test/utilities/utility/forward/move_only2.fail.cpp b/final/test/utilities/utility/forward/move_only2.fail.cpp
new file mode 100644
index 0000000..2043f3d
--- /dev/null
+++ b/final/test/utilities/utility/forward/move_only2.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(ca);
+}
diff --git a/final/test/utilities/utility/forward/move_only3.fail.cpp b/final/test/utilities/utility/forward/move_only3.fail.cpp
new file mode 100644
index 0000000..84c83ae
--- /dev/null
+++ b/final/test/utilities/utility/forward/move_only3.fail.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(std::move(ca));
+}
diff --git a/final/test/utilities/utility/forward/move_only4.fail.cpp b/final/test/utilities/utility/forward/move_only4.fail.cpp
new file mode 100644
index 0000000..5eeca89
--- /dev/null
+++ b/final/test/utilities/utility/forward/move_only4.fail.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test move
+
+#include <utility>
+#include <cassert>
+
+#include <typeinfo>
+#include <stdio.h>
+
+class move_only
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(const move_only&);
+    move_only& operator=(const move_only&);
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&);
+    move_only& operator=(move_only&);
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+public:
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    move_only(move_only&&) {}
+    move_only& operator=(move_only&&) {}
+#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
+    move_only(std::__rv<move_only>) {}
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+    move_only() {}
+};
+
+move_only source() {return move_only();}
+const move_only csource() {return move_only();}
+
+void test(move_only) {}
+
+int main()
+{
+    move_only a;
+    const move_only ca = move_only();
+
+    test(csource());
+}
diff --git a/final/test/utilities/utility/operators/rel_ops.pass.cpp b/final/test/utilities/utility/operators/rel_ops.pass.cpp
new file mode 100644
index 0000000..26e7665
--- /dev/null
+++ b/final/test/utilities/utility/operators/rel_ops.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// test rel_ops
+
+#include <utility>
+#include <cassert>
+
+struct A
+{
+    int data_;
+
+    explicit A(int data = -1) : data_(data) {}
+};
+
+inline
+bool
+operator == (const A& x, const A& y)
+{
+    return x.data_ == y.data_;
+}
+
+inline
+bool
+operator < (const A& x, const A& y)
+{
+    return x.data_ < y.data_;
+}
+
+int main()
+{
+    using namespace std::rel_ops;
+    A a1(1);
+    A a2(2);
+    assert(a1 == a1);
+    assert(a1 != a2);
+    assert(a1 < a2);
+    assert(a2 > a1);
+    assert(a1 <= a1);
+    assert(a1 <= a2);
+    assert(a2 >= a2);
+    assert(a2 >= a1);
+}
diff --git a/final/test/utilities/utility/pairs/nothing_to_do.pass.cpp b/final/test/utilities/utility/pairs/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility/pairs/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/get_const.fail.cpp b/final/test/utilities/utility/pairs/pair.astuple/get_const.fail.cpp
new file mode 100644
index 0000000..dbe1c26
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/get_const.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+//     const typename tuple_element<I, std::pair<T1, T2> >::type&
+//     get(const pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        const P p(3, 4);
+        assert(std::get<0>(p) == 3);
+        assert(std::get<1>(p) == 4);
+        std::get<0>(p) = 5;
+    }
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp b/final/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
new file mode 100644
index 0000000..fcda366
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/get_const.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+//     const typename tuple_element<I, std::pair<T1, T2> >::type&
+//     get(const pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        const P p(3, 4);
+        assert(std::get<0>(p) == 3);
+        assert(std::get<1>(p) == 4);
+    }
+
+#if __cplusplus > 201103L
+    {
+        typedef std::pair<int, short> P;
+        constexpr P p1(3, 4);
+        static_assert(std::get<0>(p1) == 3, "");
+        static_assert(std::get<1>(p1) == 4, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp b/final/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
new file mode 100644
index 0000000..6d61c47
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+//     typename tuple_element<I, std::pair<T1, T2> >::type&
+//     get(pair<T1, T2>&);
+
+#include <utility>
+#include <cassert>
+
+#if __cplusplus > 201103L
+struct S {
+   std::pair<int, int> a;
+   int k;
+   constexpr S() : a{1,2}, k(std::get<0>(a)) {}
+   };
+
+constexpr std::pair<int, int> getP () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        P p(3, 4);
+        assert(std::get<0>(p) == 3);
+        assert(std::get<1>(p) == 4);
+        std::get<0>(p) = 5;
+        std::get<1>(p) = 6;
+        assert(std::get<0>(p) == 5);
+        assert(std::get<1>(p) == 6);
+    }
+
+#if __cplusplus > 201103L
+    {
+        static_assert(S().k == 1, "");
+        static_assert(std::get<1>(getP()) == 4, "");
+    }
+#endif
+
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp b/final/test/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp
new file mode 100644
index 0000000..aa5ca53
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<size_t I, class T1, class T2>
+//     typename tuple_element<I, std::pair<T1, T2> >::type&&
+//     get(pair<T1, T2>&&);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<std::unique_ptr<int>, short> P;
+        P p(std::unique_ptr<int>(new int(3)), 4);
+        std::unique_ptr<int> ptr = std::get<0>(std::move(p));
+        assert(*ptr == 3);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
new file mode 100644
index 0000000..176d583
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <utility>
+#include <string>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::complex<float> cf;
+    {
+    auto t1 = std::make_pair<int, cf> ( 42, { 1,2 } );
+    assert ( std::get<int>(t1) == 42 );
+    assert ( std::get<cf>(t1).real() == 1 );
+    assert ( std::get<cf>(t1).imag() == 2 );
+    }
+    
+    {
+    const std::pair<int, const int> p1 { 1, 2 };
+    const int &i1 = std::get<int>(p1);
+    const int &i2 = std::get<const int>(p1);
+    assert ( i1 == 1 );
+    assert ( i2 == 2 );
+    }
+
+    {
+    typedef std::unique_ptr<int> upint;
+    std::pair<upint, int> t(upint(new int(4)), 42);
+    upint p = std::get<0>(std::move(t)); // get rvalue
+    assert(*p == 4);
+    assert(std::get<0>(t) == nullptr); // has been moved from
+    }
+
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp
new file mode 100644
index 0000000..1c01ed7
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type1.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <utility>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::complex<float> cf;
+    auto t1 = std::make_pair<int, double> ( 42, 3.4 );
+    assert ( std::get<cf>(t1) == cf {1,2} );    // no such type
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp
new file mode 100644
index 0000000..f9e3942
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type2.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <utility>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::complex<float> cf;
+    auto t1 = std::make_pair<int, int> ( 42, 43 );
+    assert ( std::get<int>(t1) == 42 ); // two ints
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp
new file mode 100644
index 0000000..4843473
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/pairs.by.type3.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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 <utility>
+#include <complex>
+
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    typedef std::unique_ptr<int> upint;
+    std::pair<upint, int> t(upint(new int(4)), 23);
+    upint p = std::get<upint>(t);
+#else
+#error
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp b/final/test/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
new file mode 100644
index 0000000..9a303ba
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// tuple_element<I, pair<T1, T2> >::type
+
+#include <utility>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        static_assert((std::is_same<std::tuple_element<0, P1>::type, int>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, P1>::type, short>::value), "");
+    }
+    {
+        typedef std::pair<int*, char> P1;
+        static_assert((std::is_same<std::tuple_element<0, P1>::type, int*>::value), "");
+        static_assert((std::is_same<std::tuple_element<1, P1>::type, char>::value), "");
+    }
+}
diff --git a/final/test/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp b/final/test/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
new file mode 100644
index 0000000..2be694e
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.astuple/tuple_size.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// tuple_size<pair<T1, T2> >::value
+
+#include <utility>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        static_assert((std::tuple_size<P1>::value == 2), "");
+    }
+}
diff --git a/final/test/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp b/final/test/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
new file mode 100644
index 0000000..90476bc
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pair.piecewise/piecewise_construct.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// struct piecewise_construct_t { };
+// constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+
+#include <utility>
+#include <tuple>
+#include <cassert>
+
+class A
+{
+    int i_;
+    char c_;
+public:
+    A(int i, char c) : i_(i), c_(c) {}
+    int get_i() const {return i_;}
+    char get_c() const {return c_;}
+};
+
+class B
+{
+    double d_;
+    unsigned u1_;
+    unsigned u2_;
+public:
+    B(double d, unsigned u1, unsigned u2) : d_(d), u1_(u1), u2_(u2) {}
+    double get_d() const {return d_;}
+    unsigned get_u1() const {return u1_;}
+    unsigned get_u2() const {return u2_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    std::pair<A, B> p(std::piecewise_construct,
+                      std::make_tuple(4, 'a'),
+                      std::make_tuple(3.5, 6u, 2u));
+    assert(p.first.get_i() == 4);
+    assert(p.first.get_c() == 'a');
+    assert(p.second.get_d() == 3.5);
+    assert(p.second.get_u1() == 6u);
+    assert(p.second.get_u2() == 2u);
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp b/final/test/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000..b58f5c5
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/U_V.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
new file mode 100644
index 0000000..8c7dee2
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair(U&& x, V&& y);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<std::unique_ptr<int>, short*> P;
+        P p(std::unique_ptr<int>(new int(3)), nullptr);
+        assert(*p.first == 3);
+        assert(p.second == nullptr);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
new file mode 100644
index 0000000..fdef596
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair& operator=(const pair<U, V>& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        typedef std::pair<double, long> P2;
+        P1 p1(3, 4);
+        P2 p2;
+        p2 = p1;
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp
new file mode 100644
index 0000000..a753ee5
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/assign_rv_pair.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair& operator=(pair&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<std::unique_ptr<int>, short> P;
+        P p1(std::unique_ptr<int>(new int(3)), 4);
+        P p2;
+        p2 = std::move(p1);
+        assert(*p2.first == 3);
+        assert(p2.second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
new file mode 100644
index 0000000..a200390
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair& operator=(pair<U, V>&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct Base
+{
+    virtual ~Base() {}
+};
+
+struct Derived
+    : public Base
+{
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<std::unique_ptr<Derived>, short> P1;
+        typedef std::pair<std::unique_ptr<Base>, long> P2;
+        P1 p1(std::unique_ptr<Derived>(), 4);
+        P2 p2;
+        p2 = std::move(p1);
+        assert(p2.first == nullptr);
+        assert(p2.second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
new file mode 100644
index 0000000..2041b39
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair(const T1& x, const T2& y);
+
+#include <utility>
+#include <cassert>
+
+class A
+{
+    int data_;
+public:
+    A(int data) : data_(data) {}
+
+    bool operator==(const A& a) const {return data_ == a.data_;}
+};
+
+#if _LIBCPP_STD_VER > 11
+class AC
+{
+    int data_;
+public:
+    constexpr AC(int data) : data_(data) {}
+
+    constexpr bool operator==(const AC& a) const {return data_ == a.data_;}
+};
+#endif
+
+int main()
+{
+    {
+        typedef std::pair<float, short*> P;
+        P p(3.5f, 0);
+        assert(p.first == 3.5f);
+        assert(p.second == nullptr);
+    }
+    {
+        typedef std::pair<A, int> P;
+        P p(1, 2);
+        assert(p.first == A(1));
+        assert(p.second == 2);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<float, short*> P;
+        constexpr P p(3.5f, 0);
+        static_assert(p.first == 3.5f, "");
+        static_assert(p.second == nullptr, "");
+    }
+    {
+        typedef std::pair<AC, int> P;
+        constexpr P p(1, 2);
+        static_assert(p.first == AC(1), "");
+        static_assert(p.second == 2, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
new file mode 100644
index 0000000..286cce4
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> pair(const pair<U, V>& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        typedef std::pair<double, long> P2;
+        P1 p1(3, 4);
+        P2 p2 = p1;
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, short> P1;
+        typedef std::pair<double, long> P2;
+        constexpr P1 p1(3, 4);
+        constexpr P2 p2 = p1;
+        static_assert(p2.first == 3, "");
+        static_assert(p2.second == 4, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
new file mode 100644
index 0000000..4b54f71
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair(const pair&) = default;
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1(3, 4);
+        P1 p2 = p1;
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+
+    static_assert((std::is_trivially_copy_constructible<std::pair<int, int> >::value), "");
+
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, short> P1;
+        constexpr P1 p1(3, 4);
+        constexpr P1 p2 = p1;
+        static_assert(p2.first == 3, "");
+        static_assert(p2.second == 4, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/default.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/default.pass.cpp
new file mode 100644
index 0000000..bb6661f
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/default.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// constexpr pair();
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+    typedef std::pair<float, short*> P;
+    P p;
+    assert(p.first == 0.0f);
+    assert(p.second == nullptr);
+    }
+    
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef std::pair<float, short*> P;
+    constexpr P p;
+    static_assert(p.first == 0.0f, "");
+    static_assert(p.second == nullptr, "");
+    }
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
new file mode 100644
index 0000000..42a2666
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class... Args1, class... Args2>
+//     pair(piecewise_construct_t, tuple<Args1...> first_args,
+//                                 tuple<Args2...> second_args);
+
+#include <utility>
+#include <tuple>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+    {
+        typedef std::pair<int, int*> P1;
+        typedef std::pair<int*, int> P2;
+        typedef std::pair<P1, P2> P3;
+        P3 p3(std::piecewise_construct, std::tuple<int, int*>(3, nullptr),
+                                        std::tuple<int*, int>(nullptr, 4));
+        assert(p3.first == P1(3, nullptr));
+        assert(p3.second == P2(nullptr, 4));
+    }
+#endif  // _LIBCPP_HAS_NO_VARIADICS
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
new file mode 100644
index 0000000..5fb6c98
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> pair(pair<U, V>&& p);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct Base
+{
+    virtual ~Base() {}
+};
+
+struct Derived
+    : public Base
+{
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<std::unique_ptr<Derived>, short> P1;
+        typedef std::pair<std::unique_ptr<Base>, long> P2;
+        P1 p1(std::unique_ptr<Derived>(), 4);
+        P2 p2 = std::move(p1);
+        assert(p2.first == nullptr);
+        assert(p2.second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/swap.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/swap.pass.cpp
new file mode 100644
index 0000000..a912df0
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/swap.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// void swap(pair& p);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1(3, 4);
+        P1 p2(5, 6);
+        p1.swap(p2);
+        assert(p1.first == 5);
+        assert(p1.second == 6);
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/final/test/utilities/utility/pairs/pairs.pair/types.pass.cpp b/final/test/utilities/utility/pairs/pairs.pair/types.pass.cpp
new file mode 100644
index 0000000..c16bd71
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.pair/types.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2>
+// struct pair
+// {
+//     typedef T1 first_type;
+//     typedef T2 second_type;
+
+#include <utility>
+#include <type_traits>
+
+int main()
+{
+    typedef std::pair<float, short*> P;
+    static_assert((std::is_same<P::first_type, float>::value), "");
+    static_assert((std::is_same<P::second_type, short*>::value), "");
+}
diff --git a/final/test/utilities/utility/pairs/pairs.spec/comparison.pass.cpp b/final/test/utilities/utility/pairs/pairs.spec/comparison.pass.cpp
new file mode 100644
index 0000000..9ba8532
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.spec/comparison.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
+// template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 4);
+        P p2(3, 4);
+        assert( (p1 == p2));
+        assert(!(p1 != p2));
+        assert(!(p1 <  p2));
+        assert( (p1 <= p2));
+        assert(!(p1 >  p2));
+        assert( (p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(2, 4);
+        P p2(3, 4);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert( (p1 <  p2));
+        assert( (p1 <= p2));
+        assert(!(p1 >  p2));
+        assert(!(p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 2);
+        P p2(3, 4);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert( (p1 <  p2));
+        assert( (p1 <= p2));
+        assert(!(p1 >  p2));
+        assert(!(p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 4);
+        P p2(2, 4);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert(!(p1 <  p2));
+        assert(!(p1 <= p2));
+        assert( (p1 >  p2));
+        assert( (p1 >= p2));
+    }
+    {
+        typedef std::pair<int, short> P;
+        P p1(3, 4);
+        P p2(3, 2);
+        assert(!(p1 == p2));
+        assert( (p1 != p2));
+        assert(!(p1 <  p2));
+        assert(!(p1 <= p2));
+        assert( (p1 >  p2));
+        assert( (p1 >= p2));
+    }
+
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, short> P;
+        constexpr P p1(3, 4);
+        constexpr P p2(3, 2);
+        static_assert(!(p1 == p2), "");
+        static_assert( (p1 != p2), "");
+        static_assert(!(p1 <  p2), "");
+        static_assert(!(p1 <= p2), "");
+        static_assert( (p1 >  p2), "");
+        static_assert( (p1 >= p2), "");
+    }
+#endif
+}
diff --git a/final/test/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp b/final/test/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
new file mode 100644
index 0000000..48e0973
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
+
+#include <utility>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1 = std::make_pair(3, 4);
+        assert(p1.first == 3);
+        assert(p1.second == 4);
+    }
+    
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    {
+        typedef std::pair<std::unique_ptr<int>, short> P1;
+        P1 p1 = std::make_pair(std::unique_ptr<int>(new int(3)), 4);
+        assert(*p1.first == 3);
+        assert(p1.second == 4);
+    }
+    {
+        typedef std::pair<std::unique_ptr<int>, short> P1;
+        P1 p1 = std::make_pair(nullptr, 4);
+        assert(p1.first == nullptr);
+        assert(p1.second == 4);
+    }
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#if _LIBCPP_STD_VER > 11
+    {
+        typedef std::pair<int, short> P1;
+        constexpr P1 p1 = std::make_pair(3, 4);
+        static_assert(p1.first == 3, "");
+        static_assert(p1.second == 4, "");
+    }
+#endif
+
+}
diff --git a/final/test/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp b/final/test/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp
new file mode 100644
index 0000000..d9d8f27
--- /dev/null
+++ b/final/test/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y);
+
+#include <utility>
+#include <cassert>
+
+int main()
+{
+    {
+        typedef std::pair<int, short> P1;
+        P1 p1(3, 4);
+        P1 p2(5, 6);
+        swap(p1, p2);
+        assert(p1.first == 5);
+        assert(p1.second == 6);
+        assert(p2.first == 3);
+        assert(p2.second == 4);
+    }
+}
diff --git a/final/test/utilities/utility/utility.swap/swap.pass.cpp b/final/test/utilities/utility/utility.swap/swap.pass.cpp
new file mode 100644
index 0000000..8606611
--- /dev/null
+++ b/final/test/utilities/utility/utility.swap/swap.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<class T>
+//   requires MoveAssignable<T> && MoveConstructible<T>
+//   void
+//   swap(T& a, T& b);
+
+#include <utility>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+void
+test()
+{
+    int i = 1;
+    int j = 2;
+    std::swap(i, j);
+    assert(i == 2);
+    assert(j == 1);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test1()
+{
+    std::unique_ptr<int> i(new int(1));
+    std::unique_ptr<int> j(new int(2));
+    std::swap(i, j);
+    assert(*i == 2);
+    assert(*j == 1);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test1();
+#endif
+}
diff --git a/final/test/utilities/utility/utility.swap/swap_array.pass.cpp b/final/test/utilities/utility/utility.swap/swap_array.pass.cpp
new file mode 100644
index 0000000..b1209c3
--- /dev/null
+++ b/final/test/utilities/utility/utility.swap/swap_array.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+// template<ValueType T, size_t N>
+//   requires Swappable<T>
+//   void
+//   swap(T (&a)[N], T (&b)[N]);
+
+#include <utility>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+void
+test()
+{
+    int i[3] = {1, 2, 3};
+    int j[3] = {4, 5, 6};
+    std::swap(i, j);
+    assert(i[0] == 4);
+    assert(i[1] == 5);
+    assert(i[2] == 6);
+    assert(j[0] == 1);
+    assert(j[1] == 2);
+    assert(j[2] == 3);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+void
+test1()
+{
+    std::unique_ptr<int> i[3];
+    for (int k = 0; k < 3; ++k)
+        i[k].reset(new int(k+1));
+    std::unique_ptr<int> j[3];
+    for (int k = 0; k < 3; ++k)
+        j[k].reset(new int(k+4));
+    std::swap(i, j);
+    assert(*i[0] == 4);
+    assert(*i[1] == 5);
+    assert(*i[2] == 6);
+    assert(*j[0] == 1);
+    assert(*j[1] == 2);
+    assert(*j[2] == 3);
+}
+
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+    test();
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+    test1();
+#endif
+}
diff --git a/final/test/utilities/utility/version.pass.cpp b/final/test/utilities/utility/version.pass.cpp
new file mode 100644
index 0000000..77d145d
--- /dev/null
+++ b/final/test/utilities/utility/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// <utility>
+
+#include <utility>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/final/www/atomic_design.html b/final/www/atomic_design.html
new file mode 100644
index 0000000..2314841
--- /dev/null
+++ b/final/www/atomic_design.html
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>&lt;atomic&gt; design</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>&lt;atomic&gt; design</h1>
+  <!--*********************************************************************-->
+
+<p>
+There are currently 3 designs under consideration.  They differ in where most
+of the implementation work is done.  The functionality exposed to the customer
+should be identical (and conforming) for all three designs.
+</p>
+
+<ol type="A">
+<li>
+<a href="atomic_design_a.html">Minimal work for the library</a>
+</li>
+<li>
+<a href="atomic_design_b.html">Something in between</a>
+</li>
+<li>
+<a href="atomic_design_c.html">Minimal work for the front end</a>
+</li>
+</ol>
+
+<p>
+With any design, the (back end) compiler writer should note:
+</p>
+
+<blockquote>
+<p>
+The decision to implement lock-free operations on any given type (or not) is an
+ABI-binding decision.  One can not change from treating a type as not lock free,
+to lock free (or vice-versa) without breaking your ABI.
+</p>
+
+<p>
+Example:
+</p>
+
+<blockquote><pre>
+TU1.cc
+-----------
+extern atomic&lt;long long&gt; A;
+int foo() { return A.compare_exchange_strong(w, x); }
+
+TU2.cc
+-----------
+extern atomic&lt;long long&gt; A;
+void bar() { return A.compare_exchange_strong(y, z); }
+</pre></blockquote>
+</blockquote>
+
+<p>
+If only <em>one</em> of these calls to <tt>compare_exchange_strong</tt> is
+implemented with mutex-locked code, then that mutex-locked code will not be
+executed mutually exclusively of the one implemented in a lock-free manner.
+</p>
+
+</div>
+</body>
+</html>
diff --git a/final/www/atomic_design_a.html b/final/www/atomic_design_a.html
new file mode 100644
index 0000000..b329fd1
--- /dev/null
+++ b/final/www/atomic_design_a.html
@@ -0,0 +1,309 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>&lt;atomic&gt; design</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>&lt;atomic&gt; design</h1>
+  <!--*********************************************************************-->
+
+<p>
+The compiler supplies all of the intrinsics as described below.  This list of
+intrinsics roughly parallels the requirements of the C and C++ atomics
+proposals.  The C and C++ library implementations simply drop through to these
+intrinsics.  Anything the platform does not support in hardware, the compiler
+arranges for a (compiler-rt) library call to be made which will do the job with
+a mutex, and in this case ignoring the memory ordering parameter (effectively
+implementing <tt>memory_order_seq_cst</tt>).
+</p>
+
+<p>
+Ultimate efficiency is preferred over run time error checking.  Undefined
+behavior is acceptable when the inputs do not conform as defined below.
+</p>
+
+<blockquote><pre>
+<font color="#C80000">// In every intrinsic signature below, type* atomic_obj may be a pointer to a</font>
+<font color="#C80000">//    volatile-qualified type.</font>
+<font color="#C80000">// Memory ordering values map to the following meanings:</font>
+<font color="#C80000">//   memory_order_relaxed == 0</font>
+<font color="#C80000">//   memory_order_consume == 1</font>
+<font color="#C80000">//   memory_order_acquire == 2</font>
+<font color="#C80000">//   memory_order_release == 3</font>
+<font color="#C80000">//   memory_order_acq_rel == 4</font>
+<font color="#C80000">//   memory_order_seq_cst == 5</font>
+
+<font color="#C80000">// type must be trivially copyable</font>
+<font color="#C80000">// type represents a "type argument"</font>
+bool __atomic_is_lock_free(type);
+
+<font color="#C80000">// type must be trivially copyable</font>
+<font color="#C80000">// Behavior is defined for mem_ord = 0, 1, 2, 5</font>
+type __atomic_load(const type* atomic_obj, int mem_ord);
+
+<font color="#C80000">// type must be trivially copyable</font>
+<font color="#C80000">// Behavior is defined for mem_ord = 0, 3, 5</font>
+void __atomic_store(type* atomic_obj, type desired, int mem_ord);
+
+<font color="#C80000">// type must be trivially copyable</font>
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+type __atomic_exchange(type* atomic_obj, type desired, int mem_ord);
+
+<font color="#C80000">// type must be trivially copyable</font>
+<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
+<font color="#C80000">//   mem_failure &lt;= mem_success</font>
+<font color="#C80000">//   mem_failure != 3</font>
+<font color="#C80000">//   mem_failure != 4</font>
+bool __atomic_compare_exchange_strong(type* atomic_obj,
+                                      type* expected, type desired,
+                                      int mem_success, int mem_failure);
+
+<font color="#C80000">// type must be trivially copyable</font>
+<font color="#C80000">// Behavior is defined for mem_success = [0 ... 5],</font>
+<font color="#C80000">//   mem_failure &lt;= mem_success</font>
+<font color="#C80000">//   mem_failure != 3</font>
+<font color="#C80000">//   mem_failure != 4</font>
+bool __atomic_compare_exchange_weak(type* atomic_obj,
+                                    type* expected, type desired,
+                                    int mem_success, int mem_failure);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+type __atomic_fetch_add(type* atomic_obj, type operand, int mem_ord);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+type __atomic_fetch_sub(type* atomic_obj, type operand, int mem_ord);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+type __atomic_fetch_and(type* atomic_obj, type operand, int mem_ord);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+type __atomic_fetch_or(type* atomic_obj, type operand, int mem_ord);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+type __atomic_fetch_xor(type* atomic_obj, type operand, int mem_ord);
+
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+void* __atomic_fetch_add(void** atomic_obj, ptrdiff_t operand, int mem_ord);
+void* __atomic_fetch_sub(void** atomic_obj, ptrdiff_t operand, int mem_ord);
+
+<font color="#C80000">// Behavior is defined for mem_ord = [0 ... 5]</font>
+void __atomic_thread_fence(int mem_ord);
+void __atomic_signal_fence(int mem_ord);
+</pre></blockquote>
+
+<p>
+If desired the intrinsics taking a single <tt>mem_ord</tt> parameter can default
+this argument to 5.
+</p>
+
+<p>
+If desired the intrinsics taking two ordering parameters can default
+<tt>mem_success</tt> to 5, and <tt>mem_failure</tt> to
+<tt>translate_memory_order(mem_success)</tt> where
+<tt>translate_memory_order(mem_success)</tt> is defined as:
+</p>
+
+<blockquote><pre>
+int
+translate_memory_order(int o)
+{
+    switch (o)
+    {
+    case 4:
+        return 2;
+    case 3:
+        return 0;
+    }
+    return o;
+}
+</pre></blockquote>
+
+<p>
+Below are representative C++ implementations of all of the operations.  Their
+purpose is to document the desired semantics of each operation, assuming
+<tt>memory_order_seq_cst</tt>.  This is essentially the code that will be called
+if the front end calls out to compiler-rt.
+</p>
+
+<blockquote><pre>
+template &lt;class T&gt;
+T
+__atomic_load(T const volatile* obj)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    return *obj;
+}
+
+template &lt;class T&gt;
+void
+__atomic_store(T volatile* obj, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    *obj = desr;
+}
+
+template &lt;class T&gt;
+T
+__atomic_exchange(T volatile* obj, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj = desr;
+    return r;
+}
+
+template &lt;class T&gt;
+bool
+__atomic_compare_exchange_strong(T volatile* obj, T* exp, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    if (std::memcmp(const_cast&lt;T*&gt;(obj), exp, sizeof(T)) == 0) <font color="#C80000">// if (*obj == *exp)</font>
+    {
+        std::memcpy(const_cast&lt;T*&gt;(obj), &amp;desr, sizeof(T)); <font color="#C80000">// *obj = desr;</font>
+        return true;
+    }
+    std::memcpy(exp, const_cast&lt;T*&gt;(obj), sizeof(T)); <font color="#C80000">// *exp = *obj;</font>
+    return false;
+}
+
+<font color="#C80000">// May spuriously return false (even if *obj == *exp)</font>
+template &lt;class T&gt;
+bool
+__atomic_compare_exchange_weak(T volatile* obj, T* exp, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    if (std::memcmp(const_cast&lt;T*&gt;(obj), exp, sizeof(T)) == 0) <font color="#C80000">// if (*obj == *exp)</font>
+    {
+        std::memcpy(const_cast&lt;T*&gt;(obj), &amp;desr, sizeof(T)); <font color="#C80000">// *obj = desr;</font>
+        return true;
+    }
+    std::memcpy(exp, const_cast&lt;T*&gt;(obj), sizeof(T)); <font color="#C80000">// *exp = *obj;</font>
+    return false;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_add(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj += operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_sub(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj -= operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_and(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj &amp;= operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_or(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj |= operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_xor(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj ^= operand;
+    return r;
+}
+
+void*
+__atomic_fetch_add(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    void* r = *obj;
+    (char*&amp;)(*obj) += operand;
+    return r;
+}
+
+void*
+__atomic_fetch_sub(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    void* r = *obj;
+    (char*&amp;)(*obj) -= operand;
+    return r;
+}
+
+void __atomic_thread_fence()
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+}
+
+void __atomic_signal_fence()
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+}
+</pre></blockquote>
+
+
+</div>
+</body>
+</html>
diff --git a/final/www/atomic_design_b.html b/final/www/atomic_design_b.html
new file mode 100644
index 0000000..b738445
--- /dev/null
+++ b/final/www/atomic_design_b.html
@@ -0,0 +1,250 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>&lt;atomic&gt; design</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>&lt;atomic&gt; design</h1>
+  <!--*********************************************************************-->
+
+<p>
+This is a variation of design A which puts the burden on the library to arrange
+for the correct manipulation of the run time memory ordering arguments, and only
+calls the compiler for well-defined memory orderings.  I think of this design as
+the worst of A and C, instead of the best of A and C.  But I offer it as an
+option in the spirit of completeness.
+</p>
+
+<blockquote><pre>
+<font color="#C80000">// type must be trivially copyable</font>
+bool __atomic_is_lock_free(const type* atomic_obj);
+
+<font color="#C80000">// type must be trivially copyable</font>
+type __atomic_load_relaxed(const volatile type* atomic_obj);
+type __atomic_load_consume(const volatile type* atomic_obj);
+type __atomic_load_acquire(const volatile type* atomic_obj);
+type __atomic_load_seq_cst(const volatile type* atomic_obj);
+
+<font color="#C80000">// type must be trivially copyable</font>
+type __atomic_store_relaxed(volatile type* atomic_obj, type desired);
+type __atomic_store_release(volatile type* atomic_obj, type desired);
+type __atomic_store_seq_cst(volatile type* atomic_obj, type desired);
+
+<font color="#C80000">// type must be trivially copyable</font>
+type __atomic_exchange_relaxed(volatile type* atomic_obj, type desired);
+type __atomic_exchange_consume(volatile type* atomic_obj, type desired);
+type __atomic_exchange_acquire(volatile type* atomic_obj, type desired);
+type __atomic_exchange_release(volatile type* atomic_obj, type desired);
+type __atomic_exchange_acq_rel(volatile type* atomic_obj, type desired);
+type __atomic_exchange_seq_cst(volatile type* atomic_obj, type desired);
+
+<font color="#C80000">// type must be trivially copyable</font>
+bool __atomic_compare_exchange_strong_relaxed_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_consume_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_consume_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acquire_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acquire_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acquire_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_release_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_release_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_release_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acq_rel_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acq_rel_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_acq_rel_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_relaxed(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_consume(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_acquire(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+bool __atomic_compare_exchange_strong_seq_cst_seq_cst(volatile type* atomic_obj,
+                                                      type* expected,
+                                                      type desired);
+
+<font color="#C80000">// type must be trivially copyable</font>
+bool __atomic_compare_exchange_weak_relaxed_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_consume_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_consume_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acquire_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acquire_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acquire_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_release_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_release_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_release_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acq_rel_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acq_rel_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_acq_rel_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_relaxed(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_consume(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_acquire(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+bool __atomic_compare_exchange_weak_seq_cst_seq_cst(volatile type* atomic_obj,
+                                                    type* expected,
+                                                    type desired);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+type __atomic_fetch_add_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_add_seq_cst(volatile type* atomic_obj, type operand);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+type __atomic_fetch_sub_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_sub_seq_cst(volatile type* atomic_obj, type operand);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+type __atomic_fetch_and_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_and_seq_cst(volatile type* atomic_obj, type operand);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+type __atomic_fetch_or_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_or_seq_cst(volatile type* atomic_obj, type operand);
+
+<font color="#C80000">// type is one of: char, signed char, unsigned char, short, unsigned short, int,</font>
+<font color="#C80000">//      unsigned int, long, unsigned long, long long, unsigned long long,</font>
+<font color="#C80000">//      char16_t, char32_t, wchar_t</font>
+type __atomic_fetch_xor_relaxed(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_consume(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_acquire(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_release(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_acq_rel(volatile type* atomic_obj, type operand);
+type __atomic_fetch_xor_seq_cst(volatile type* atomic_obj, type operand);
+
+void* __atomic_fetch_add_relaxed(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_consume(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_acquire(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_release(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_add_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand);
+
+void* __atomic_fetch_sub_relaxed(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_consume(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_acquire(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_release(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand);
+void* __atomic_fetch_sub_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand);
+
+void __atomic_thread_fence_relaxed();
+void __atomic_thread_fence_consume();
+void __atomic_thread_fence_acquire();
+void __atomic_thread_fence_release();
+void __atomic_thread_fence_acq_rel();
+void __atomic_thread_fence_seq_cst();
+
+void __atomic_signal_fence_relaxed();
+void __atomic_signal_fence_consume();
+void __atomic_signal_fence_acquire();
+void __atomic_signal_fence_release();
+void __atomic_signal_fence_acq_rel();
+void __atomic_signal_fence_seq_cst();
+</pre></blockquote>
+
+</div>
+</body>
+</html>
diff --git a/final/www/atomic_design_c.html b/final/www/atomic_design_c.html
new file mode 100644
index 0000000..f574d4d
--- /dev/null
+++ b/final/www/atomic_design_c.html
@@ -0,0 +1,458 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>&lt;atomic&gt; design</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>&lt;atomic&gt; design</h1>
+  <!--*********************************************************************-->
+
+<p>
+The <tt>&lt;atomic&gt;</tt> header is one of the most closely coupled headers to
+the compiler.  Ideally when you invoke any function from
+<tt>&lt;atomic&gt;</tt>, it should result in highly optimized assembly being
+inserted directly into your application ...  assembly that is not otherwise
+representable by higher level C or C++ expressions.  The design of the libc++
+<tt>&lt;atomic&gt;</tt> header started with this goal in mind.  A secondary, but
+still very important goal is that the compiler should have to do minimal work to
+facilitate the implementation of <tt>&lt;atomic&gt;</tt>.  Without this second
+goal, then practically speaking, the libc++ <tt>&lt;atomic&gt;</tt> header would
+be doomed to be a barely supported, second class citizen on almost every
+platform.
+</p>
+
+<p>Goals:</p>
+
+<blockquote><ul>
+<li>Optimal code generation for atomic operations</li>
+<li>Minimal effort for the compiler to achieve goal 1 on any given platform</li>
+<li>Conformance to the C++0X draft standard</li>
+</ul></blockquote>
+
+<p>
+The purpose of this document is to inform compiler writers what they need to do
+to enable a high performance libc++ <tt>&lt;atomic&gt;</tt> with minimal effort.
+</p>
+
+<h2>The minimal work that must be done for a conforming <tt>&lt;atomic&gt;</tt></h2>
+
+<p>
+The only "atomic" operations that must actually be lock free in
+<tt>&lt;atomic&gt;</tt> are represented by the following compiler intrinsics:
+</p>
+
+<blockquote><pre>
+__atomic_flag__
+__atomic_exchange_seq_cst(__atomic_flag__ volatile* obj, __atomic_flag__ desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    __atomic_flag__ result = *obj;
+    *obj = desr;
+    return result;
+}
+
+void
+__atomic_store_seq_cst(__atomic_flag__ volatile* obj, __atomic_flag__ desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    *obj = desr;
+}
+</pre></blockquote>
+
+<p>
+Where:
+</p>
+
+<blockquote><ul>
+<li>
+If <tt>__has_feature(__atomic_flag)</tt> evaluates to 1 in the preprocessor then
+the compiler must define <tt>__atomic_flag__</tt> (e.g. as a typedef to
+<tt>int</tt>).
+</li>
+<li>
+If <tt>__has_feature(__atomic_flag)</tt> evaluates to 0 in the preprocessor then
+the library defines <tt>__atomic_flag__</tt> as a typedef to <tt>bool</tt>.
+</li>
+<li>
+<p>
+To communicate that the above intrinsics are available, the compiler must
+arrange for <tt>__has_feature</tt> to return 1 when fed the intrinsic name
+appended with an '_' and the mangled type name of <tt>__atomic_flag__</tt>.
+</p>
+<p>
+For example if <tt>__atomic_flag__</tt> is <tt>unsigned int</tt>:
+</p>
+<blockquote><pre>
+__has_feature(__atomic_flag) == 1
+__has_feature(__atomic_exchange_seq_cst_j) == 1
+__has_feature(__atomic_store_seq_cst_j) == 1
+
+typedef unsigned int __atomic_flag__; 
+
+unsigned int __atomic_exchange_seq_cst(unsigned int volatile*, unsigned int)
+{
+   // ...
+}
+
+void __atomic_store_seq_cst(unsigned int volatile*, unsigned int)
+{
+   // ...
+}
+</pre></blockquote>
+</li>
+</ul></blockquote>
+
+<p>
+That's it!  Compiler writers do the above and you've got a fully conforming
+(though sub-par performance) <tt>&lt;atomic&gt;</tt> header!
+</p>
+
+<h2>Recommended work for a higher performance <tt>&lt;atomic&gt;</tt></h2>
+
+<p>
+It would be good if the above intrinsics worked with all integral types plus
+<tt>void*</tt>.  Because this may not be possible to do in a lock-free manner for
+all integral types on all platforms, a compiler must communicate each type that
+an intrinsic works with.  For example if <tt>__atomic_exchange_seq_cst</tt> works
+for all types except for <tt>long long</tt> and <tt>unsigned long long</tt>
+then:
+</p>
+
+<blockquote><pre>
+__has_feature(__atomic_exchange_seq_cst_b) == 1  // bool
+__has_feature(__atomic_exchange_seq_cst_c) == 1  // char
+__has_feature(__atomic_exchange_seq_cst_a) == 1  // signed char
+__has_feature(__atomic_exchange_seq_cst_h) == 1  // unsigned char
+__has_feature(__atomic_exchange_seq_cst_Ds) == 1 // char16_t
+__has_feature(__atomic_exchange_seq_cst_Di) == 1 // char32_t
+__has_feature(__atomic_exchange_seq_cst_w) == 1  // wchar_t
+__has_feature(__atomic_exchange_seq_cst_s) == 1  // short
+__has_feature(__atomic_exchange_seq_cst_t) == 1  // unsigned short
+__has_feature(__atomic_exchange_seq_cst_i) == 1  // int
+__has_feature(__atomic_exchange_seq_cst_j) == 1  // unsigned int
+__has_feature(__atomic_exchange_seq_cst_l) == 1  // long
+__has_feature(__atomic_exchange_seq_cst_m) == 1  // unsigned long
+__has_feature(__atomic_exchange_seq_cst_Pv) == 1 // void*
+</pre></blockquote>
+
+<p>
+Note that only the <tt>__has_feature</tt> flag is decorated with the argument
+type.  The name of the compiler intrinsic is not decorated, but instead works
+like a C++ overloaded function.
+</p>
+
+<p>
+Additionally there are other intrinsics besides
+<tt>__atomic_exchange_seq_cst</tt> and <tt>__atomic_store_seq_cst</tt>.  They
+are optional.  But if the compiler can generate faster code than provided by the
+library, then clients will benefit from the compiler writer's expertise and
+knowledge of the targeted platform.
+</p>
+
+<p>
+Below is the complete list of <i>sequentially consistent</i> intrinsics, and
+their library implementations.  Template syntax is used to indicate the desired
+overloading for integral and void* types.  The template does not represent a
+requirement that the intrinsic operate on <em>any</em> type!
+</p>
+
+<blockquote><pre>
+T is one of:  bool, char, signed char, unsigned char, short, unsigned short,
+              int, unsigned int, long, unsigned long,
+              long long, unsigned long long, char16_t, char32_t, wchar_t, void*
+
+template &lt;class T&gt;
+T
+__atomic_load_seq_cst(T const volatile* obj)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    return *obj;
+}
+
+template &lt;class T&gt;
+void
+__atomic_store_seq_cst(T volatile* obj, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    *obj = desr;
+}
+
+template &lt;class T&gt;
+T
+__atomic_exchange_seq_cst(T volatile* obj, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj = desr;
+    return r;
+}
+
+template &lt;class T&gt;
+bool
+__atomic_compare_exchange_strong_seq_cst_seq_cst(T volatile* obj, T* exp, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    if (std::memcmp(const_cast&lt;T*&gt;(obj), exp, sizeof(T)) == 0)
+    {
+        std::memcpy(const_cast&lt;T*&gt;(obj), &amp;desr, sizeof(T));
+        return true;
+    }
+    std::memcpy(exp, const_cast&lt;T*&gt;(obj), sizeof(T));
+    return false;
+}
+
+template &lt;class T&gt;
+bool
+__atomic_compare_exchange_weak_seq_cst_seq_cst(T volatile* obj, T* exp, T desr)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    if (std::memcmp(const_cast&lt;T*&gt;(obj), exp, sizeof(T)) == 0)
+    {
+        std::memcpy(const_cast&lt;T*&gt;(obj), &amp;desr, sizeof(T));
+        return true;
+    }
+    std::memcpy(exp, const_cast&lt;T*&gt;(obj), sizeof(T));
+    return false;
+}
+
+T is one of:  char, signed char, unsigned char, short, unsigned short,
+              int, unsigned int, long, unsigned long,
+              long long, unsigned long long, char16_t, char32_t, wchar_t
+
+template &lt;class T&gt;
+T
+__atomic_fetch_add_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj += operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_sub_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj -= operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_and_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj &amp;= operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_or_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj |= operand;
+    return r;
+}
+
+template &lt;class T&gt;
+T
+__atomic_fetch_xor_seq_cst(T volatile* obj, T operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    T r = *obj;
+    *obj ^= operand;
+    return r;
+}
+
+void*
+__atomic_fetch_add_seq_cst(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    void* r = *obj;
+    (char*&amp;)(*obj) += operand;
+    return r;
+}
+
+void*
+__atomic_fetch_sub_seq_cst(void* volatile* obj, ptrdiff_t operand)
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+    void* r = *obj;
+    (char*&amp;)(*obj) -= operand;
+    return r;
+}
+
+void __atomic_thread_fence_seq_cst()
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+}
+
+void __atomic_signal_fence_seq_cst()
+{
+    unique_lock&lt;mutex&gt; _(some_mutex);
+}
+</pre></blockquote>
+
+<p>
+One should consult the (currently draft)
+<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3126.pdf">C++ standard</a>
+for the details of the definitions for these operations.  For example
+<tt>__atomic_compare_exchange_weak_seq_cst_seq_cst</tt> is allowed to fail
+spuriously while <tt>__atomic_compare_exchange_strong_seq_cst_seq_cst</tt> is
+not.
+</p>
+
+<p>
+If on your platform the lock-free definition of
+<tt>__atomic_compare_exchange_weak_seq_cst_seq_cst</tt> would be the same as
+<tt>__atomic_compare_exchange_strong_seq_cst_seq_cst</tt>, you may omit the
+<tt>__atomic_compare_exchange_weak_seq_cst_seq_cst</tt> intrinsic without a
+performance cost.  The library will prefer your implementation of
+<tt>__atomic_compare_exchange_strong_seq_cst_seq_cst</tt> over its own
+definition for implementing
+<tt>__atomic_compare_exchange_weak_seq_cst_seq_cst</tt>.  That is, the library
+will arrange for <tt>__atomic_compare_exchange_weak_seq_cst_seq_cst</tt> to call
+<tt>__atomic_compare_exchange_strong_seq_cst_seq_cst</tt> if you supply an
+intrinsic for the strong version but not the weak.
+</p>
+
+<h2>Taking advantage of weaker memory synchronization</h2>
+
+<p>
+So far all of the intrinsics presented require a <em>sequentially
+consistent</em> memory ordering.  That is, no loads or stores can move across
+the operation (just as if the library had locked that internal mutex).  But
+<tt>&lt;atomic&gt;</tt> supports weaker memory ordering operations.  In all,
+there are six memory orderings (listed here from strongest to weakest):
+</p>
+
+<blockquote><pre>
+memory_order_seq_cst
+memory_order_acq_rel
+memory_order_release
+memory_order_acquire
+memory_order_consume
+memory_order_relaxed
+</pre></blockquote>
+
+<p>
+(See the
+<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3126.pdf">C++ standard</a>
+for the detailed definitions of each of these orderings).
+</p>
+
+<p>
+On some platforms, the compiler vendor can offer some or even all of the above
+intrinsics at one or more weaker levels of memory synchronization.  This might
+lead for example to not issuing an <tt>mfence</tt> instruction on the x86.
+</p>
+
+<p>
+If the compiler does not offer any given operation, at any given memory ordering
+level, the library will automatically attempt to call the next highest memory
+ordering operation.  This continues up to <tt>seq_cst</tt>, and if that doesn't
+exist, then the library takes over and does the job with a <tt>mutex</tt>.  This
+is a compile-time search &amp; selection operation.  At run time, the
+application will only see the few inlined assembly instructions for the selected
+intrinsic.
+</p>
+
+<p>
+Each intrinsic is appended with the 7-letter name of the memory ordering it
+addresses.  For example a <tt>load</tt> with <tt>relaxed</tt> ordering is
+defined by:
+</p>
+
+<blockquote><pre>
+T __atomic_load_relaxed(const volatile T* obj);
+</pre></blockquote>
+
+<p>
+And announced with:
+</p>
+
+<blockquote><pre>
+__has_feature(__atomic_load_relaxed_b) == 1  // bool
+__has_feature(__atomic_load_relaxed_c) == 1  // char
+__has_feature(__atomic_load_relaxed_a) == 1  // signed char
+...
+</pre></blockquote>
+
+<p>
+The <tt>__atomic_compare_exchange_strong(weak)</tt> intrinsics are parameterized
+on two memory orderings.  The first ordering applies when the operation returns
+<tt>true</tt> and the second ordering applies when the operation returns
+<tt>false</tt>.
+</p>
+
+<p>
+Not every memory ordering is appropriate for every operation.  <tt>exchange</tt>
+and the <tt>fetch_<i>op</i></tt> operations support all 6.  But <tt>load</tt>
+only supports <tt>relaxed</tt>, <tt>consume</tt>, <tt>acquire</tt> and <tt>seq_cst</tt>.
+<tt>store</tt>
+only supports <tt>relaxed</tt>, <tt>release</tt>, and <tt>seq_cst</tt>.  The
+<tt>compare_exchange</tt> operations support the following 16 combinations out
+of the possible 36:
+</p>
+
+<blockquote><pre>
+relaxed_relaxed
+consume_relaxed
+consume_consume
+acquire_relaxed
+acquire_consume
+acquire_acquire
+release_relaxed
+release_consume
+release_acquire
+acq_rel_relaxed
+acq_rel_consume
+acq_rel_acquire
+seq_cst_relaxed
+seq_cst_consume
+seq_cst_acquire
+seq_cst_seq_cst
+</pre></blockquote>
+
+<p>
+Again, the compiler supplies intrinsics only for the strongest orderings where
+it can make a difference.  The library takes care of calling the weakest
+supplied intrinsic that is as strong or stronger than the customer asked for.
+</p>
+
+</div>
+</body>
+</html>
diff --git a/final/www/content.css b/final/www/content.css
new file mode 100644
index 0000000..dca6a32
--- /dev/null
+++ b/final/www/content.css
@@ -0,0 +1,27 @@
+html { margin: 0px; } body { margin: 8px; }
+
+html, body {
+  padding:0px;
+  font-size:small; font-family:"Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, Helvetica, sans-serif; background-color: #fff; color: #222;
+  line-height:1.5;
+}
+
+h1, h2, h3, tt { color: #000 }
+
+h1 { padding-top:0px; margin-top:0px;}
+h2 { color:#333333; padding-top:0.5em; }
+h3 { padding-top: 0.5em; margin-bottom: -0.25em; color:#2d58b7}
+li { padding-bottom: 0.5em; }
+ul { padding-left:1.5em; }
+
+/* Slides */
+IMG.img_slide {
+    display: block;
+    margin-left: auto;
+    margin-right: auto
+}
+
+.itemTitle { color:#2d58b7 }
+
+/* Tables */
+tr { vertical-align:top }
diff --git a/final/www/cxx1y_status.html b/final/www/cxx1y_status.html
new file mode 100644
index 0000000..ce7f216
--- /dev/null
+++ b/final/www/cxx1y_status.html
@@ -0,0 +1,277 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>libc++ C++1Y Status</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>libc++ C++1Y Status</h1>
+  <!--*********************************************************************-->
+
+  <p>In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, known as "C++1Y" (probably to be C++14)</p>
+  <p>The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol)</p>
+  <p>This page shows the status of libc++; the status of clang's support of the language features is <a href="http://clang.llvm.org/cxx_status.html">here</a>.</p>
+
+  <p>The groups that have contributed papers:
+  <ul>
+    <li>CWG - Core Language Working group</li>
+    <li>LWG - Library working group</li>
+    <li>SG1 - Study group #1 (Concurrency working group)</li>
+  </ul>
+  </p>
+  
+  <h3>Paper Status</h3>
+  <table id="papers" border="1">
+	<tr><th>Paper #</th><th>Group</th><th>Paper Name</th><th>Meeting</th><th>Status</th><th>First released version</th></tr>
+
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3346.pdf">3346</a></td><td>LWG</td><td>Terminology for Container Element Requirements - Rev 1</td><td>Kona</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+
+<!-- 	<tr><td>3323</td><td>CWG</td><td>A Proposal to Tweak Certain C++ Contextual Conversions, v3</td><td>Portland</td><td></td><td></td></tr> -->
+	
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm">3421</a></td><td>LWG</td><td>Making Operator Functors greater&lt;&gt;</td><td>Portland</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3462.html">3462</a></td><td>LWG</td><td>std::result_of and SFINAE</td><td>Portland</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3469.html">3469</a></td><td>LWG</td><td>Constexpr Library Additions: chrono, v3</td><td>Portland</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3470.html">3470</a></td><td>LWG</td><td>Constexpr Library Additions: containers, v2</td><td>Portland</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3471.html">3471</a></td><td>LWG</td><td>Constexpr Library Additions: utilities, v3</td><td>Portland</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3302.html">3302</a></td><td>LWG</td><td>Constexpr Library Additions: complex, v2</td><td>Portland</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+
+<!-- 	<tr><td>3472</td><td>CWG</td><td>Binary Literals in the C++ Core Language</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3624</td><td>CWG</td><td>Core Issue 1512: Pointer comparison vs qualification conversions (revision 3)</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3639</td><td>CWG</td><td>Runtime-sized arrays with automatic storage duration (revision 5)</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3638</td><td>CWG</td><td>Return type deduction for normal functions</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3648</td><td>CWG</td><td>Wording Changes for Generalized Lambda-capture</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3653</td><td>CWG</td><td>Member initializers and aggregates</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3667</td><td>CWG</td><td>Drafting for Core 1402</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3652</td><td>CWG</td><td>Relaxing constraints on constexpr functions" and "constexpr member functions and implicit const</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3664</td><td>CWG</td><td>Clarifying Memory Allocation</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3651</td><td>CWG</td><td>Variable Templates (Revision 1)</td><td>Bristol</td><td></td><td></td></tr> -->
+<!-- 	<tr><td>3649</td><td>CWG</td><td>Generic (Polymorphic) Lambda Expressions (Revision 3)</td><td>Bristol</td><td></td><td></td></tr> -->
+	
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3545.pdf">3545</a></td><td>LWG</td><td>An Incremental Improvement to integral_constant</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3644.pdf">3644</a></td><td>LWG</td><td>Null Forward Iterators</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3668.html">3668</a></td><td>LWG</td><td>std::exchange()</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3658.html">3658</a></td><td>LWG</td><td>Compile-time integer sequences</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3670.html">3670</a></td><td>LWG</td><td>Addressing Tuples by Type</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3671.html">3671</a></td><td>LWG</td><td>Making non-modifying sequence operations more robust</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3656.htm">3656</a></td><td>LWG</td><td>make_unique</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3654.html">3654</a></td><td>LWG</td><td>Quoted Strings</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3642.pdf">3642</a></td><td>LWG</td><td>User-defined Literals</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3655.pdf">3655</a></td><td>LWG</td><td>TransformationTraits Redux (excluding part 4)</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3657.htm">3657</a></td><td>LWG</td><td>Adding heterogeneous comparison lookup to associative containers</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3672.html">3672</a></td><td>LWG</td><td>A proposal to add a utility class to represent optional objects</td><td>Bristol</td><td><I>Removed from Draft Standard</I></td><td>n/a</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3669.pdf">3669</a></td><td>LWG</td><td>Fixing constexpr member functions without const</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3662.html">3662</a></td><td>LWG</td><td>C++ Dynamic Arrays (dynarray)</td><td>Bristol</td><td><I>Removed from Draft Standard</I></td><td>n/a</td></tr>
+	
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3659.html">3659</a></td><td>SG1</td><td>Shared Locking in C++</td><td>Bristol</td><td>Complete</td><td>3.4</td></tr>
+
+ 	<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3779.pdf">3779</a></td><td>LWG</td><td>User-defined Literals for std::complex</td><td>Chicago</td><td>Complete</td><td>3.4</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3789.htm">3789</a></td><td>LWG</td><td>Constexpr Library Additions: functional</td><td>Chicago</td><td>Complete</td><td>3.4</td></tr>
+ 	<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>
+
+	<tr><td><a href="http://isocpp.org/files/papers/N3924.pdf">3924</a></td><td>LWG</td><td>Discouraging rand() in C++14</td><td>Issaquah</td><td>Complete</td><td>3.5</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3887">3887</a></td><td>LWG</td><td>Consistent Metafunction Aliases</td><td>Issaquah</td><td>Complete</td><td>3.5</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3891">3891</a></td><td>SG1</td><td>A proposal to rename shared_mutex to shared_timed_mutex</td><td>Issaquah</td><td>Complete</td><td>3.5</td></tr>
+
+<!--  	<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr> -->
+  </table>
+
+  <h3>Library Working group Issues Status</h3>
+<!--   <I>Note: "NAD" means that the issue was deemed "Not a defect"</I> -->
+  <table id="issues" border="1">
+	<tr><th>Issue #</th><th>Issue Name</th><th>Meeting</th><th>Status</th></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1214">1214</a></td><td>Insufficient/inconsistent key immutability requirements for associative containers</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2009">2009</a></td><td>Reporting out-of-bound values on numeric string conversions</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2010">2010</a></td><td>is_* traits for binding operations can't be meaningfully specialized</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2015">2015</a></td><td>Incorrect pre-conditions for some type traits</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2021">2021</a></td><td>Further incorrect usages of result_of</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2028">2028</a></td><td>messages_base::catalog overspecified</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2033">2033</a></td><td>Preconditions of reserve, shrink_to_fit, and resize functions</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2039">2039</a></td><td>Issues with std::reverse and std::copy_if</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2044">2044</a></td><td>No definition of "Stable" for copy algorithms</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2045">2045</a></td><td>forward_list::merge and forward_list::splice_after with unequal allocators</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2047">2047</a></td><td>Incorrect "mixed" move-assignment semantics of unique_ptr</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2050">2050</a></td><td>Unordered associative containers do not use allocator_traits to define member types</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2053">2053</a></td><td>Errors in regex bitmask types</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2061">2061</a></td><td>make_move_iterator and arrays</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2064">2064</a></td><td>More noexcept issues in basic_string</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2065">2065</a></td><td>Minimal allocator interface</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2067">2067</a></td><td>packaged_task should have deleted copy c'tor with const parameter</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2069">2069</a></td><td>Inconsistent exception spec for basic_string move constructor</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2096">2096</a></td><td>Incorrect constraints of future::get in regard to MoveAssignable</td><td>Kona</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2102">2102</a></td><td>Why is std::launch an implementation-defined type?</td><td>Kona</td><td>Complete</td></tr>
+  <tr><td></td><td></td><td></td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2071">2071</a></td><td>std::valarray move-assignment</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2074">2074</a></td><td>Off by one error in std::reverse_copy</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2081">2081</a></td><td>Allocator requirements should include CopyConstructible</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2083">2083</a></td><td>const-qualification on weak_ptr::owner_before</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2086">2086</a></td><td>Overly generic type support for math functions</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2099">2099</a></td><td>Unnecessary constraints of va_start() usage</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2103">2103</a></td><td>std::allocator_traits&lt;std::allocator&lt;T&gt;&gt;::propagate_on_container_move_assignment</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2105">2105</a></td><td>Inconsistent requirements on const_iterator's value_type</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2110">2110</a></td><td>remove can't swap but note says it might</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2123">2123</a></td><td>merge() allocator requirements for lists versus forward lists</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2005">2005</a></td><td>unordered_map::insert(T&&) protection should apply to map too</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2011">2011</a></td><td>Unexpected output required of strings</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2048">2048</a></td><td>Unnecessary mem_fn overloads</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2049">2049</a></td><td>is_destructible is underspecified</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2056">2056</a></td><td>future_errc enums start with value 0 (invalid value for broken_promise)</td><td>Portland</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2058">2058</a></td><td>valarray and begin/end</td><td>Portland</td><td>Complete</td></tr>
+  <tr><td></td><td></td><td></td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2091">2091</a></td><td>Misplaced effect in m.try_lock_for()</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2092">2092</a></td><td>Vague Wording for condition_variable_any</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2093">2093</a></td><td>Throws clause of condition_variable::wait with predicate</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2094">2094</a></td><td>duration conversion overflow shouldn't participate in overload resolution</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2122">2122</a></td><td>merge() stability for lists versus forward lists</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2128">2128</a></td><td>Absence of global functions cbegin/cend</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2145">2145</a></td><td>error_category default constructor</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2147">2147</a></td><td>Unclear hint type in Allocator's allocate function</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2148">2148</a></td><td>Hashing enums should be supported directly by std::hash</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2149">2149</a></td><td>Concerns about 20.8/5</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2162">2162</a></td><td>allocator_traits::max_size missing noexcept</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2163">2163</a></td><td>nth_element requires inconsistent post-conditions</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2169">2169</a></td><td>Missing reset() requirements in unique_ptr specialization</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2172">2172</a></td><td>Does atomic_compare_exchange_* accept v == nullptr arguments?</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2080">2080</a></td><td>Specify when once_flag becomes invalid</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2098">2098</a></td><td>promise throws clauses</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2109">2109</a></td><td>Incorrect requirements for hash specializations</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2130">2130</a></td><td>missing ordering constraints for fences</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2138">2138</a></td><td>atomic_flag::clear ordering constraints</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2140">2140</a></td><td>notify_all_at_thread_exit synchronization</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2144">2144</a></td><td>Missing noexcept specification in type_index</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2174">2174</a></td><td>wstring_convert::converted() should be noexcept</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2175">2175</a></td><td>string_convert and wbuffer_convert validity</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2176">2176</a></td><td>Special members for wstring_convert and wbuffer_convert</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2177">2177</a></td><td>Requirements on Copy/MoveInsertable</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2185">2185</a></td><td>Missing throws clause for future/shared_future::wait_for/wait_until</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2187">2187</a></td><td>vector&lt;bool&gt; is missing emplace and emplace_back member functions</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2190">2190</a></td><td>ordering of condition variable operations, reflects Posix discussion</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2196">2196</a></td><td>Specification of is_*[copy/move]_[constructible/assignable] unclear for non-referencable types</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2197">2197</a></td><td>Specification of is_[un]signed unclear for non-arithmetic types</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2200">2200</a></td><td>Data race avoidance for all containers, not only for sequences</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2203">2203</a></td><td>scoped_allocator_adaptor uses wrong argument types for piecewise construction</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2207">2207</a></td><td>basic_string::at should not have a Requires clause</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2209">2209</a></td><td>assign() overspecified for sequence containers</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2210">2210</a></td><td>Missing allocator-extended constructor for allocator-aware containers</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2211">2211</a></td><td>Replace ambiguous use of "Allocator" in container requirements</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2222">2222</a></td><td>Inconsistency in description of forward_list::splice_after single-element overload</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2225">2225</a></td><td>Unrealistic header inclusion checks required</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2229">2229</a></td><td>Standard code conversion facets underspecified</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2231">2231</a></td><td>DR 704 removes complexity guarantee for clear()</td><td>Bristol</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2235">2235</a></td><td>Undefined behavior without proper requirements on basic_string constructors</td><td>Bristol</td><td>Complete</td></tr>
+    <tr><td></td><td></td><td></td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2141">2141</a></td><td>common_type trait produces reference types</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2246">2246</a></td><td>unique_ptr assignment effects w.r.t. deleter</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2247">2247</a></td><td>Type traits and std::nullptr_t</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2085">2085</a></td><td>Wrong description of effect 1 of basic_istream::ignore</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2087">2087</a></td><td>iostream_category() and noexcept</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2143">2143</a></td><td>ios_base::xalloc should be thread-safe</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2150">2150</a></td><td>Unclear specification of find_end</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2180">2180</a></td><td>Exceptions from std::seed_seq operations</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2194">2194</a></td><td>Impossible container requirements for adaptor types</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2013">2013</a></td><td>Do library implementers have the freedom to add constexpr?</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2018">2018</a></td><td>regex_traits::isctype Returns clause is wrong</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2078">2078</a></td><td>Throw specification of async() incomplete</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2097">2097</a></td><td>packaged_task constructors should be constrained</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2100">2100</a></td><td>Timed waiting functions cannot timeout if launch::async policy used</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2120">2120</a></td><td>What should async do if neither 'async' nor 'deferred' is set in policy?</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2159">2159</a></td><td>atomic_flag initialization</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2275">2275</a></td><td>Why is forward_as_tuple not constexpr?</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2284">2284</a></td><td>Inconsistency in allocator_traits::max_size</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2298">2298</a></td><td>is_nothrow_constructible is always false because of create&lt;&gt;</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2300">2300</a></td><td>Redundant sections for map and multimap members should be removed</td><td>Chicago</td><td>Complete</td></tr>
+	<tr><td>NB comment: GB9</td>                                                                     <td>Remove gets from C++14</td><td>Chicago</td><td>Complete</td></tr>
+    <tr><td></td><td></td><td></td><td></td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2135">2135</a></td><td>Unclear requirement for exceptions thrown in condition_variable::wait()</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2291">2291</a></td><td>std::hash is vulnerable to collision DoS attack</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2142">2142</a></td><td>packaged_task::operator() synchronization too broad?</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2240">2240</a></td><td>Probable misuse of term "function scope" in [thread.condition]</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2252">2252</a></td><td>Strong guarantee on vector::push_back() still broken with C++11?</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2257">2257</a></td><td>Simplify container requirements with the new algorithms</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2268">2268</a></td><td>Setting a default argument in the declaration of a member function assign of std::basic_string</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2271">2271</a></td><td>regex_traits::lookup_classname specification unclear</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2272">2272</a></td><td>quoted should use char_traits::eq for character comparison</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2278">2278</a></td><td>User-defined literals for Standard Library types</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2280">2280</a></td><td>begin / end for arrays should be constexpr and noexcept</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2285">2285</a></td><td>make_reverse_iterator</td><td>Issaquah</td><td>Complete</td></tr>
+
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2299">2299</a></td><td>Effects of inaccessible key_compare::is_transparent type are not clear</td><td>Issaquah</td><td>Complete</td></tr>
+
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1450">1450</a></td><td>Contradiction in regex_constants</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2003">2003</a></td><td>String exception inconsistency in erase.</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2112">2112</a></td><td>User-defined classes that cannot be derived from</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2132">2132</a></td><td>std::function ambiguity</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2182">2182</a></td><td>Container::[const_]reference types are misleadingly specified</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2188">2188</a></td><td>Reverse iterator does not fully support targets that overload operator&</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2193">2193</a></td><td>Default constructors for standard library containers are explicit</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2205">2205</a></td><td>Problematic postconditions of regex_match and regex_search</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2213">2213</a></td><td>Return value of std::regex_replace</td><td>Issaquah</td><td>Complete</td></tr>
+
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2258">2258</a></td><td>a.erase(q1, q2) unable to directly return q2</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2263">2263</a></td><td>Comparing iterators and allocator pointers with different const-character</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2293">2293</a></td><td>Wrong facet used by num_put::do_put</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2301">2301</a></td><td>Why is std::tie not constexpr?</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2304">2304</a></td><td>Complexity of count in unordered associative containers</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2306">2306</a></td><td>match_results::reference should be value_type&, not const value_type&</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2308">2308</a></td><td>Clarify container destructor requirements w.r.t. std::array</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2313">2313</a></td><td>tuple_size should always derive from integral_constant<size_t, N></td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2314">2314</a></td><td>apply() should return decltype(auto) and use decay_t before tuple_size</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2315">2315</a></td><td>weak_ptr should be movable</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2316">2316</a></td><td>weak_ptr::lock() should be atomic</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2317">2317</a></td><td>The type property queries should be UnaryTypeTraits returning size_t</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2320">2320</a></td><td>select_on_container_copy_construction() takes allocators, not containers</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2322">2322</a></td><td>Associative(initializer_list, stuff) constructors are underspecified</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2323">2323</a></td><td>vector::resize(n, t)'s specification should be simplified</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2324">2324</a></td><td>Insert iterator constructors should use addressof()</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2329">2329</a></td><td>regex_match()/regex_search() with match_results should forbid temporary strings</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2330">2330</a></td><td>regex("meow", regex::icase) is technically forbidden but should be permitted</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2332">2332</a></td><td>regex_iterator/regex_token_iterator should forbid temporary regexes</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2339">2339</a></td><td>Wording issue in nth_element</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2341">2341</a></td><td>Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir)</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2344">2344</a></td><td>quoted()'s interaction with padding is unclear</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2346">2346</a></td><td>integral_constant's member functions should be marked noexcept</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2350">2350</a></td><td>min, max, and minmax should be constexpr</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2356">2356</a></td><td>Stability of erasure in unordered associative containers</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2357">2357</a></td><td>Remaining "Assignable" requirement</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2359">2359</a></td><td>How does regex_constants::nosubs affect basic_regex::mark_count()?</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360">2360</a></td><td>reverse_iterator::operator*() is unimplementable</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2104">2104</a></td><td>unique_lock move-assignment should not be noexcept</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2186">2186</a></td><td>Incomplete action on async/launch::deferred</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2075">2075</a></td><td>Progress guarantees, lock-free property, and scheduling assumptions</td><td>Issaquah</td><td>Complete</td></tr>
+	<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2288">2288</a></td><td>Inconsistent requirements for shared mutexes</td><td>Issaquah</td><td>Complete</td></tr>
+<!-- 	<tr><td></td><td></td><td></td><td></td></tr> -->
+  </table>
+
+  <p>Last Updated: 25-Mar-2014</p>
+</div>
+</body>
+</html>
diff --git a/final/www/debug_mode.html b/final/www/debug_mode.html
new file mode 100644
index 0000000..943c47d
--- /dev/null
+++ b/final/www/debug_mode.html
@@ -0,0 +1,162 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+        "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+	<title>libc++ debug mode status</title>
+</head>
+<body>
+
+<p>
+Work is beginning on a libc++ debug mode.  The purpose of this table is to
+record which parts of libc++ have debug mode support.
+</p>
+
+<p>
+Note: Debug mode is currently not functional. Defining _LIBCPP_DEBUG will result
+in fairly nasty compile errors.
+</p>
+
+<table border=1>
+<tr>
+<th>Section</th>
+<th>Completed ?</th>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>vector&lt;T&gt;, T != bool</code>
+</p>
+</td>
+<td align="center"> &#10003; </td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;list&gt;</code>
+</p>
+</td>
+<td align="center"> &#10003; </td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;unordered_set&gt;</code>
+</p>
+</td>
+<td align="center"> &#10003; </td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;unordered_map&gt;</code>
+</p>
+</td>
+<td align="center"> &#10003; </td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;string&gt;</code>
+</p>
+</td>
+<td align="center"> &#10003; </td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;set&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;map&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>vector&lt;bool&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;deque&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;forward_list&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;array&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;stack&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;queue&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+<tr>
+<td>
+<p>
+<code>&lt;algorithm&gt;</code>
+</p>
+</td>
+<td align="center"><!-- &#10003; --></td>
+</tr>
+
+
+</table>
+
+<p>
+At present the table is known to not be a complete list.  It is currently ordered
+in approximate priority order.
+</p>
+
+<p>Last Updated: 3-June-2014</p>
+
+</body>
+</html>
diff --git a/final/www/index.html b/final/www/index.html
new file mode 100644
index 0000000..ba3f259
--- /dev/null
+++ b/final/www/index.html
@@ -0,0 +1,377 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>"libc++" C++ Standard Library</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>"libc++" C++ Standard Library</h1>
+  <!--*********************************************************************-->
+
+  <p>libc++ is a new implementation of the C++ standard library, targeting
+     C++11.</p>
+
+  <p>All of the code in libc++ is <a
+     href="http://llvm.org/docs/DeveloperPolicy.html#license">dual licensed</a>
+     under the MIT license and the UIUC License (a BSD-like license).</p>
+
+  <!--=====================================================================-->
+  <h2 id="goals">Features and Goals</h2>
+  <!--=====================================================================-->
+
+    <ul>
+        <li>Correctness as defined by the C++11 standard.</li>
+        <li>Fast execution.</li>
+        <li>Minimal memory use.</li>
+        <li>Fast compile times.</li>
+        <li>ABI compatibility with gcc's libstdc++ for some low-level features
+            such as exception objects, rtti and memory allocation.</li>
+        <li>Extensive unit tests.</li>
+    </ul>
+
+  <!--=====================================================================-->
+  <h2 id="why">Why a new C++ Standard Library for C++11?</h2>
+  <!--=====================================================================-->
+
+  <p>After its initial introduction, many people have asked "why start a new
+     library instead of contributing to an existing library?" (like Apache's
+     libstdcxx, GNU's libstdc++, STLport, etc).  There are many contributing
+     reasons, but some of the major ones are:</p>
+
+  <ul>
+  <li><p>From years of experience (including having implemented the standard
+      library before), we've learned many things about implementing
+      the standard containers which require ABI breakage and fundamental changes
+      to how they are implemented.  For example, it is generally accepted that
+      building std::string using the "short string optimization" instead of
+      using Copy On Write (COW) is a superior approach for multicore
+      machines (particularly in C++11, which has rvalue references).  Breaking
+      ABI compatibility with old versions of the library was
+      determined to be critical to achieving the performance goals of
+      libc++.</p></li>
+
+  <li><p>Mainline libstdc++ has switched to GPL3, a license which the developers
+      of libc++ cannot use.  libstdc++ 4.2 (the last GPL2 version) could be
+      independently extended to support C++11, but this would be a fork of the
+      codebase (which is often seen as worse for a project than starting a new
+      independent one).  Another problem with libstdc++ is that it is tightly
+       integrated with G++ development, tending to be tied fairly closely to the
+       matching version of G++.</p>
+    </li>
+
+  <li><p>STLport and the Apache libstdcxx library are two other popular
+      candidates, but both lack C++11 support.  Our experience (and the
+      experience of libstdc++ developers) is that adding support for C++11 (in
+      particular rvalue references and move-only types) requires changes to
+      almost every class and function, essentially amounting to a rewrite.
+      Faced with a rewrite, we decided to start from scratch and evaluate every
+      design decision from first principles based on experience.</p>
+
+      <p>Further, both projects are apparently abandoned: STLport 5.2.1 was
+      released in Oct'08, and STDCXX 4.2.1 in May'08.</p>
+
+    </ul>
+
+  <!--=====================================================================-->
+  <h2 id="requirements">Platform Support</h2>
+  <!--=====================================================================-->
+
+   <p>libc++ is known to work on the following platforms, using g++-4.2 and
+      clang (lack of C++11 language support disables some functionality).</p>
+
+    <ul>
+     <li>Mac OS X i386</li>
+     <li>Mac OS X x86_64</li>
+    </ul>
+
+  <!--=====================================================================-->
+  <h2 id="dir-structure">Current Status</h2>
+  <!--=====================================================================-->
+
+   <p>libc++ is a 100% complete C++11 implementation on Apple's OS X. </p>
+   <p>LLVM and Clang can self host in C++ and C++11 mode with libc++ on Linux.</p>
+   <p>libc++ is also a 100% complete C++14 implementation. A list of new features and changes for 
+      C++14 can be found <a href="cxx1y_status.html">here</a>.</p>
+   <p>Implementation of the post-c++14 Technical Specifications is in progress. A list of features and
+      the current status of these features can be found <a href="ts1z_status.html">here</a>.</p>
+   <p>
+   Ports to other platforms are underway. Here are recent test
+   results for <a href="results.Windows.html">Windows</a>
+   and <a href="results.Linux.html">Linux</a>.
+   </p>
+
+  <!--=====================================================================-->
+  <h2>Get it and get involved!</h2>
+  <!--=====================================================================-->
+
+  <p>First please review our
+     <a href="http://llvm.org/docs/DeveloperPolicy.html">Developer's Policy</a>.
+
+  <p>To check out the code, use:</p>
+
+  <ul>
+  <li><code>svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx</code></li>
+  </ul>
+
+  <p>
+     On Mac OS 10.7 (Lion) and later, the easiest way to get this library is to install
+     Xcode 4.2 or later.  However if you want to install tip-of-trunk from here
+     (getting the bleeding edge), read on.  However, be warned that Mac OS
+     10.7 will not boot without a valid copy of <code>libc++.1.dylib</code> in
+     <code>/usr/lib</code>.
+  </p>
+
+  <p>
+     Next:
+  </p>
+  
+  <ul>
+    <li><code>cd libcxx/lib</code></li>
+    <li><code>export TRIPLE=-apple-</code></li>
+    <li><code>./buildit</code></li>
+    <li><code>ln -sf libc++.1.dylib libc++.dylib</code></li>
+  </ul>
+  
+  <p>
+     That should result in a libc++.1.dylib and libc++.dylib.  The safest thing
+     to do is to use it from where your libcxx is installed instead of replacing
+     these in your Mac OS.
+  </p>
+
+  <p>
+  To use your system-installed libc++ with clang you can:
+  </p>
+
+  <ul>
+    <li><code>clang++ -stdlib=libc++ test.cpp</code></li>
+    <li><code>clang++ -std=c++11 -stdlib=libc++ test.cpp</code></li>
+  </ul>
+
+  <p>
+  To use your tip-of-trunk libc++ on Mac OS with clang you can:
+  </p>
+
+  <ul>
+    <li><code>export DYLD_LIBRARY_PATH=&lt;path-to-libcxx&gt;/lib</code>
+    <li><code>clang++ -std=c++11 -stdlib=libc++ -nostdinc++
+         -I&lt;path-to-libcxx&gt;/include -L&lt;path-to-libcxx&gt;/lib
+         test.cpp</code></li>
+  </ul>
+
+  <p>To run the libc++ test suite (recommended):</p>
+
+  <ul>
+  <li><code>cd libcxx/test</code></li>
+  <li><code>./testit</code></li>
+     <ul>
+       <li>You can alter the command line options <code>testit</code> uses
+       with <code>export OPTIONS="whatever you need"</code></li>
+     </ul>
+  </ul>
+
+  <!--=====================================================================-->
+  <h3>Notes</h3>
+  <!--=====================================================================-->
+
+<p>
+Building libc++ with <code>-fno-rtti</code> is not supported.  However linking
+against it with <code>-fno-rtti</code> is supported.
+</p>
+
+  <p>Send discussions to the
+  (<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">clang mailing list</a>).</p>
+
+  <!--=====================================================================-->
+  <h2>Bug reports and patches</h2>
+  <!--=====================================================================-->
+
+<p>
+If you think you've found a bug in libc++, please report it using 
+the <a href="http://llvm.org/bugs">LLVM Bugzilla</a>. If you're not sure, you
+can post a message to the <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a> 
+mailing list or on IRC. Please include "libc++" in your subject.
+</p>
+
+<p>
+If you want to contribute a patch to libc++, the best place for that is the
+<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a> 
+mailing list. Please include "libc++" and "PATCH" in your subject.
+</p>
+
+  <!--=====================================================================-->
+  <h2>Build on Linux using CMake and libsupc++.</h2>
+  <!--=====================================================================-->
+
+  <p>
+     You will need libstdc++ in order to provide libsupc++.
+  </p>
+  
+  <p>
+     Figure out where the libsupc++ headers are on your system. On Ubuntu this
+     is <code>/usr/include/c++/&lt;version&gt;</code> and
+     <code>/usr/include/c++/&lt;version&gt;/&lt;target-triple&gt;</code>
+  </p>
+  
+  <p>
+     You can also figure this out by running
+     <pre>
+$ echo | g++ -Wp,-v -x c++ - -fsyntax-only
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include &lt;...&gt; search starts here:
+ /usr/include/c++/4.7
+ /usr/include/c++/4.7/x86_64-linux-gnu
+ /usr/include/c++/4.7/backward
+ /usr/lib/gcc/x86_64-linux-gnu/4.7/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+     </pre>
+
+      Note the first two entries happen to be what we are looking for. This
+      may not be correct on other platforms.
+  </p>
+  
+  <p>
+     We can now run CMake:
+     <ul>
+       <li><code>CC=clang CXX=clang++ cmake -G "Unix Makefiles"
+                -DLIBCXX_CXX_ABI=libstdc++
+                -DLIBCXX_LIBSUPCXX_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/"
+                -DCMAKE_BUILD_TYPE=Release
+                -DCMAKE_INSTALL_PREFIX=/usr
+                &lt;libc++-source-dir&gt;</code></li>
+       <li>You can also substitute <code>-DLIBCXX_CXX_ABI=libsupc++</code>
+       above, which will cause the library to be linked to libsupc++ instead
+       of libstdc++, but this is only recommended if you know that you will
+       never need to link against libstdc++ in the same executable as libc++.
+       GCC ships libsupc++ separately but only as a static library.  If a
+       program also needs to link against libstdc++, it will provide its
+       own copy of libsupc++ and this can lead to subtle problems.
+       <li><code>make</code></li>
+       <li><code>sudo make install</code></li>
+     </ul>
+     <p>
+        You can now run clang with -stdlib=libc++.
+     </p>
+  </p>
+
+  <!--=====================================================================-->
+  <h2>Build on Linux using CMake and libc++abi.</h2>
+  <!--=====================================================================-->
+
+  <p>
+     You will need to keep the source tree of <a href="http://libcxxabi.llvm.org">libc++abi</a>
+     available on your build machine and your copy of the libc++abi shared library must
+     be placed where your linker will find it.
+  </p>
+  
+  <p>
+     We can now run CMake:
+     <ul>
+       <li><code>CC=clang CXX=clang++ cmake -G "Unix Makefiles"
+                -DLIBCXX_CXX_ABI=libcxxabi
+                -DLIBCXX_LIBCXXABI_INCLUDE_PATHS="&lt;libc++abi-source-dir&gt;/include"
+                -DCMAKE_BUILD_TYPE=Release
+                -DCMAKE_INSTALL_PREFIX=/usr
+                &lt;libc++-source-dir&gt;</code></li>
+       <li><code>make</code></li>
+       <li><code>sudo make install</code></li>
+     </ul>
+     <p>
+        Unfortunately you can't simply run clang with "-stdlib=libc++" at this point, as
+        clang is set up to link for libc++ linked to libsupc++.  To get around this
+        you'll have to set up your linker yourself (or patch clang).  For example,
+        <ul>
+          <li><code>clang++ -stdlib=libc++ helloworld.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc</code></li>
+        </ul>
+        Alternately, you could just add libc++abi to your libraries list, which in most
+        situations will give the same result:
+        <ul>
+          <li><code>clang++ -stdlib=libc++ helloworld.cpp -lc++abi</code></li>
+        </ul>
+     </p>
+  </p>
+
+  <!--=====================================================================-->
+  <h2>Build on Linux using CMake and libcxxrt.</h2>
+  <!--=====================================================================-->
+
+  <p>
+     You will need to keep the source tree of
+     <a href="https://github.com/pathscale/libcxxrt/">libcxxrt</a> available
+     on your build machine and your copy of the libcxxrt shared library must
+     be placed where your linker will find it.
+  </p>
+ 
+  <p>
+     We can now run CMake:
+     <ul>
+       <li><code>CC=clang CXX=clang++ cmake -G "Unix Makefiles"
+                -DLIBCXX_CXX_ABI=libcxxrt
+                -DLIBCXX_LIBCXXRT_INCLUDE_PATHS="&lt;libcxxrt-source-dir&gt;/src"
+                -DCMAKE_BUILD_TYPE=Release
+                -DCMAKE_INSTALL_PREFIX=/usr
+                &lt;libc++-source-dir&gt;</code></li>
+       <li><code>make</code></li>
+       <li><code>sudo make install</code></li>
+     </ul>
+     <p>
+        Unfortunately you can't simply run clang with "-stdlib=libc++" at this point, as
+        clang is set up to link for libc++ linked to libsupc++.  To get around this
+        you'll have to set up your linker yourself (or patch clang).  For example,
+        <ul>
+          <li><code>clang++ -stdlib=libc++ helloworld.cpp -nodefaultlibs -lc++ -lcxxrt -lm -lc -lgcc_s -lgcc</code></li>
+        </ul>
+        Alternately, you could just add libcxxrt to your libraries list, which in most
+        situations will give the same result:
+        <ul>
+          <li><code>clang++ -stdlib=libc++ helloworld.cpp -lcxxrt</code></li>
+        </ul>
+     </p>
+  </p>
+
+  <!--=====================================================================-->
+  <h2>Design Documents</h2>
+  <!--=====================================================================-->
+
+<ul>
+<li><a href="atomic_design.html"><tt>&lt;atomic&gt;</tt></a></li>
+<li><a href="type_traits_design.html"><tt>&lt;type_traits&gt;</tt></a></li>
+<li><a href="http://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/">Excellent notes by Marshall Clow</a></li>
+<li><a href="debug_mode.html">Status of debug mode</a></li>
+</ul>
+
+</div>
+</body>
+</html>
diff --git a/final/www/menu.css b/final/www/menu.css
new file mode 100644
index 0000000..4a887b1
--- /dev/null
+++ b/final/www/menu.css
@@ -0,0 +1,39 @@
+/***************/
+/* page layout */
+/***************/
+
+[id=menu] {
+	position:fixed;
+	width:25ex;
+}
+[id=content] {
+	/* *****  EDIT THIS VALUE IF CONTENT OVERLAPS MENU ***** */
+	position:absolute;
+  left:29ex;
+	padding-right:4ex;
+}
+
+/**************/
+/* menu style */
+/**************/
+
+#menu .submenu {
+	padding-top:1em;
+	display:block;
+}
+
+#menu label {
+	display:block;
+	font-weight: bold;
+	text-align: center;
+	background-color: rgb(192,192,192);
+}
+#menu a {
+	padding:0 .2em;
+	display:block;
+	text-align: center;
+	background-color: rgb(235,235,235);
+}
+#menu a:visited {
+	color:rgb(100,50,100);
+}
diff --git a/final/www/results.Linux.html b/final/www/results.Linux.html
new file mode 100644
index 0000000..5e3eaf1
--- /dev/null
+++ b/final/www/results.Linux.html
@@ -0,0 +1,122 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>results.Linux</title>
+</head>
+<body>
+<pre>
+
+All failures in the libc++ test suite will be documented here. Last
+run was with Clang (pre-3.2) on Debian unstable x86_64 with eglibc
+2.13 and kernel 3.2.0-3-amd64. The ABI library used was libc++abi.
+
+depr/
+ depr.c.headers/
+  math_h.pass.cpp: Fails a static assert that the return type of
+   isnan(double) and isinf(double) is a bool.
+ uchar_h.pass.cpp:
+   My libc doesn't seem to provide uchar.h yet.
+ exception.unexpected/
+  set.unexpected/
+   get_unexpected.pass.cpp: This seems to be a problem with libc++abi:
+    its default unexpected handler does not call the terminate handler?
+   set_unexpected.pass.cpp: idem.
+diagnostics/
+ syserr/
+  syserr.errcat/
+   syserr.errcat.objects/
+    system_category.pass.cpp: Always maps back to generic category
+     when it should stay system category, because the implementation
+     dependson ELAST, which Linux lacks.
+input.output/
+ iostream.format/
+  ext.manip/
+   get_time.pass.cpp: Local representation is 'Sat 31 Dec 2061
+    11:55:59 PM EST' which does not match the expected result in the
+    test.
+   put_time.pass.cpp: idem.
+language.support/
+ support.start.term/
+  quick_exit.pass.cpp: Fails because it doesn't know about
+   std::at_quick_exit. Interestingly my libc does seem to know about
+   std::[at_]quick_exit, so this needs some investigation.
+localization/
+ locale.categories/
+  category.collate/
+   locale.collate.byname/
+    compare.pass.cpp: In the C local, sorting order seems OK, but not
+     in the &quot&quot and en UTF8 locals. Needs investigation.
+  category.ctype/
+   locale.codecvt/
+    locale.codecvt.members/
+     wchar_t_out.pass.cpp: Needs investigation.
+    widen_1.pass.cpp: Fails due to not converting some out of bounds
+     characters the same way as expected. Needs investigation.
+    widen_many.pass.cpp: idem.
+  category.monetary/
+   locale.money.get/
+    locale.money.get.members/
+     get_long_double_ru_RU.pass.cpp: Needs investigation.
+     get_long_double_zh_CN.pass.cpp: idem.
+    locale.money.put.members/
+     put_long_double_ru_RU.pass.cpp: idem.
+     put_long_double_zh_CN.pass.cpp: idem.
+   locale.moneypunct.byname/
+    decimal_point.pass.cpp: Expects ',' for RU, but gets '.'.
+    thousands_sep.pass.cpp: idem.
+  category.numeric/
+   locale.nm.put/
+    facet.num.put.members/
+     put_long_double.pass.cpp: Fails due to getting '+nan' rather
+      than just 'nan'.
+  category.time/
+   locale.time.get.byname/
+    get_date.pass.cpp: Needs investigation.
+    get_date_wide.pass.cpp: idem.
+    get_monthname.pass.cpp: idem.
+    get_monthname_wide.pass.cpp: idem.
+    get_one.pass.cpp: idem.
+    get_one_wide.pass.cpp: idem.
+    get_weekday.pass.cpp: idem.
+    get_weekday_wide.pass.cpp: idem.
+   locale.time.put.byname/
+    put1.pass.cpp: idem.
+   locale.time.put/
+    locale.time.put.members/
+     put2.pass.cpp: idem.
+  facet.numpunct/
+   locale.numpunct.byname/
+    grouping.pass.cpp: idem.
+    thousands_sep.pass.cpp: idem.
+numerics/
+ c.math/
+  cmath.pass.cpp: Fails for same reason as depr/depr.c.headers/math_h.pass.cpp
+re/
+ re.alg/
+  re.alg.match/
+   awk.pass.cpp: Needs investigation.
+   basic.pass.cpp: idem.
+   ecma.pass.cpp: idem.
+   extended.pass.cpp: idem.
+  re.alg.search/
+   awk.pass.cpp: idem.
+   basic.pass.cpp: idem.
+   ecma.pass.cpp: idem.
+   extended.pass.cpp: idem.
+ re.traits/
+  lookup_collatename.pass.cpp: idem.
+strings/
+ c.strings/
+  cuchar.pass.cpp: Can't find cuchar header
+  version_cuchar.pass.cpp: idem.
+utilities/
+ memory/
+  unique.ptr/
+   unique.ptr.runtime/
+    unique.ptr.runtime.ctor/
+     default02.pass.cpp:
+      test previously passed, recently started crashing clang. Needs investigation.
+     pointer02.pass.cpp: idem.
+</pre>
+</body>
+</html>
diff --git a/final/www/results.Windows.html b/final/www/results.Windows.html
new file mode 100644
index 0000000..a5ec121
--- /dev/null
+++ b/final/www/results.Windows.html
@@ -0,0 +1,487 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<title>results.Windows</title>
+</head>
+<body>
+<pre>
+All failures in the libc++ test suite will be documented here.
+
+Last run was with Clang (pre-3.1) and GCC 4.6.3 (with dw2 exception handling) and
+ mingw-w64 v2.0.3 on i686-w64-mingw32.
+
+The following line was added to ./lib/buildit to make a static libc++ library because a DLL requires "declspec(dllexport)" or a .def file:
+ar rcs libc++.a *.o
+I also deleted libc++.dll and libc++.dll.a to make sure libc++ was linked statically to prevent unrelated issues from contaminating the test results.
+The commands to build and test were (-nodefaultlibs does not work, lots of MinGW related stuff gets left out resulting in linker failures):
+TRIPLE=i686-w64-mingw32 ./buildit
+TRIPLE=i686-w64-mingw32 HEADER_INCLUDE="-I/home/Ruben/libcxx/include" LIBS="-L/home/ruben/libcxx/lib -lc++ -lpthread -lsupc++ -lmsvcr100 -Wl,--allow-multiple-definition" ./testit > test.log 2>&1
+
+Note: Some locale tests may "Need investigating", but I think most problems are
+      caused by wrong/unportable locale naming in the tests.
+Note: Some tests failed to link because "test.exe" was still running when ld.exe
+      tried to link the next test. I left these failures out of the list; they
+      account for about 10-30 failures, and are counted in the total scores below.
+      I reran some of these failures manually and they passed.
+Note: Some tests fail at runtime but pass when run manually. Usage of std::cout
+      segfaults so further investigation is difficult. These also contribute to
+      the failures total, but are left out of the failure list, as the cause is
+      probably not located in that part of libc++, not locatable due to the lack
+      of usable debug info generated by Clang at this time.
+
+TOTAL RESULTS:
+Section failures / total sections: 104 / 1064 = 9.8% failures
+Test failures / total number of tests: 292 / 4326 = 6.7% failures
+
+depr/
+ depr.c.headers/
+  inttypes_h.pass.cpp: missing macros for C++.
+  uchar_h.pass.cpp: bug in mingw-w64 headers for C++11 builtin char types.
+  wchar_h.pass.cpp: Windows does not have swprintf, should use _snwprintf.
+                    Suggest #define swprintf as _snwprintf for _WIN32.
+exception.unexpected/
+   set.unexpected/
+    get_unexpected.pass.cpp: Segmentation fault - needs investigation.
+    set_unexpected.pass.cpp: idem.
+diagnostics/
+ syserr/
+  syserr.errcat/
+   syserr.errcat.objects/
+    system_category.pass.cpp: Needs investigation.
+input.output/
+ file.streams/
+  c.files/
+   cinttypes.pass.cpp: missing macros for C++.
+  fstreams/
+   filebuf.assign/
+    member_swap.pass.cpp: Segmentation fault - needs investigation.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   filebuf.cons/
+    move.pass.cpp: idem.
+   filebuf.members/
+    open_pointers.pass.cpp: idem.
+   filebuf.virtuals/
+    overflow.pass.cpp: idem.
+    pbackfail.pass.cpp: idem.
+    seekoff.pass.cpp: idem.
+    underflow.pass.cpp: idem.
+   fstream.assign/
+    member_swap.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   fstream.cons/
+    move.pass.cpp: idem.
+    pointer.pass.cpp: idem.
+    string.pass.cpp: idem.
+   fstream.members/
+    open_pointer.pass.cpp: idem.
+    open_string.pass.cpp: idem.
+   ifstream.assign/
+    member_swap.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   ifstream.cons/
+    move.pass.cpp: idem.
+    pointer.pass.cpp: idem.
+    string.pass.cpp: idem.
+   ifstream.members/
+    open_pointer.pass.cpp: idem.
+    open_string.pass.cpp: idem.
+	  rdbuf.pass.cpp: idem.
+   ofstream.assign/
+    member_swap.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    nonmember_swap.pass.cpp: idem.
+   ofstream.cons/
+    move.pass.cpp: idem.
+    pointer.pass.cpp: idem.
+    string.pass.cpp: idem.
+   ofstream.members/
+    open_pointer.pass.cpp: idem.
+    open_string.pass.cpp: idem.
+	  rdbuf.pass.cpp: idem.
+ iostream.format/
+  ext.manip
+   get_money.pass.cpp: Windows locale names don't follow UNIX convention.
+   get_time.pass.cpp: idem.
+   put_money.pass.cpp: idem.
+   put_time.pass.cpp: idem.
+  output.streams/
+   ostream.formatted/
+    ostream.inserters.arithmetic/
+     long_double.pass.cpp: Segfault - needs investigation.
+     pointer.pass.cpp: idem.
+   ostream_sentry/
+    destruct.pass.cpp: idem.
+ iostream.objects/
+  narrow.stream.objects/
+   cerr.pass.cpp: idem.
+   cin.pass.cpp: idem.
+  wide.stream.objects/
+   wcerr.pass.cpp: idem.
+   wcin.pass.cpp: idem.
+ iostreams.base/
+  ios/
+   basic.ios.members/
+    copyfmt.pass.cpp: Windows locale names don't follow UNIX convention.
+    imbue.pass.cpp: idem.
+    move.pass.cpp: idem.
+    swap.pass.cpp: Windows locale names don't follow UNIX convention.
+  ios.base/
+   ios.base.callback/
+    register_callback.pass.cpp: Windows locale names don't follow UNIX convention.
+   ios.base.locales/
+    imbue.pass.cpp: Windows locale names don't follow UNIX convention.
+ stream.buffers/
+  streambuf/
+   streambuf.cons/
+    copy.pass.cpp: Windows locale names don't follow UNIX convention.
+    default.pass.cpp: idem.
+   streambuf.members/
+    streambuf.buffer/
+     locales.pass.cpp: Windows locale names don't follow UNIX convention.
+   streambuf.protected/
+    streambuf.assign/
+	   assign.pass.cpp: Windows locale names don't follow UNIX convention.
+     swap.pass.cpp: idem.
+language.support/
+ support.exception/
+  except.nested/
+   assign.pass.cpp: Needs investigation.
+   ctor_copy.pass.cpp: idem.
+   ctor_default.pass.cpp: idem.
+   rethrow_if_nested.pass.cpp: idem.
+   rethrow_nested.pass.cpp: idem.
+   throw_with_nested.pass.cpp: idem.
+  propagation/
+   current_exception.pass.cpp: Needs investigation.
+   exception_ptr.pass.cpp: idem.
+   make_exception_ptr.pass.cpp: idem.
+   rethrow_exception.pass.cpp: idem.
+  uncaught/
+   uncaught_exception.pass.cpp: Needs investigation.
+ support.limits/
+  limits/
+   numeric.limits.members/
+    digits.pass.cpp: Needs investigation (wrong assumptions?).
+    digits10.pass.cpp: idem.
+ support.runtime/
+  support.start.term/
+   quick_exit.pass.cpp: Not declared in libc++ headers. Is it from the ABI lib?
+ support.types/
+  max_align_t.pass.cpp: needs investigation (wrong assumptions?).
+localization/
+ locale.categories/
+  category.collate/
+   locale.collate.byname/
+    compare.pass.cpp: Windows locale names don't follow UNIX convention.
+    hash.pass.cpp: idem.
+    transform.pass.cpp: getenv should be replaced by putenv for portability.
+                        Windows locale names don't follow UNIX convention.
+    types.pass.cpp: Windows locale names don't follow UNIX convention.
+ locale.categories/
+  category.ctype/
+   locale.codecvt/
+    locale.codecvt.members/
+     wchar_t_in.pass.cpp: Most likely wchar_t is assumed 4 bytes.
+     wchar_t_length.pass.cpp: idem.
+     wchar_t_out.pass.cpp: idem.
+     wchar_t_unshift.pass.cpp: idem.
+   locale.codecvt.byname/
+    ctor_wchar_t.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale.ctype.byname/
+    is_1.pass.cpp: Windows locale names don't follow UNIX convention.
+    is_many.pass.cpp: idem.
+    narrow_1.pass.cpp: idem.
+    narrow_many.pass.cpp: idem.
+    scan_is.pass.cpp: idem.
+    scan_not.pass.cpp: idem.
+    tolower_1.pass.cpp: idem.
+    tolower_many.pass.cpp: idem.
+    toupper_1.pass.cpp: idem.
+    toupper_many.pass.cpp: idem.
+    types.pass.cpp: idem.
+    widen_1.pass.cpp: idem.
+    widen_many.pass.cpp: idem.
+  category.monetary/
+   locale.money.get/
+    locale.money.get.members/
+     get_long_double_en_US.pass.cpp: Windows locale names don't follow UNIX convention.
+     get_long_double_fr_FR.pass.cpp: idem.
+     get_long_double_ru_RU.pass.cpp: idem.
+     get_long_double_zh_CN.pass.cpp: idem.
+     get_string_en_US.pass.cpp: idem.
+   locale.money.put/
+    locale.money.put.members/
+	 put_long_double_en_US.pass.cpp: Windows locale names don't follow UNIX convention.
+     put_long_double_fr_FR.pass.cpp: idem.
+     put_long_double_ru_RU.pass.cpp: idem.
+     put_long_double_zh_CN.pass.cpp: idem.
+     put_string_en_US.pass.cpp: idem.
+   locale.moneypunct.byname/
+     curr_symbol.pass.cpp: Failed constructing from C locale. Needs investigation.
+     decimal_point.pass.cpp: idem.
+     frac_digits.pass.cpp: idem.
+     grouping.pass.cpp: idem.
+     neg_format.pass.cpp: idem.
+     negative_sign.pass.cpp: idem.
+     pos_format.pass.cpp: idem.
+     positive_sign.pass.cpp: idem.
+     thousands_sep.pass.cpp: idem.
+  category.numeric/
+   locale.nm.put/
+    facet.num.put.members/
+     put_double.pass.cpp: idem. (different floating point format?)
+     put_long_double.pass.cpp: idem.
+     put_pointer.pass.cpp: idem.
+   locale.num.get/
+    facet.num.get.members/
+     get_double.pass.cpp: Needs investigating.
+     get_float.pass.cpp: idem.
+     get_long_double.pass.cpp: idem.
+     get_pointer.pass.cpp: idem.
+  category.time/
+   locale.time.get/
+    locale.time.get.byname/
+     date_order.pass.cpp: Windows locale names don't follow UNIX convention.
+     date_order_wide.pass.cpp: idem.
+     get_date.pass.cpp: idem.
+     get_date_wide.pass.cpp: idem.
+     get_monthname.pass.cpp: idem.
+     get_monthname_wide.pass.cpp: idem.
+     get_one.pass.cpp: idem.
+     get_one_wide.pass.cpp: idem.
+     get_time.pass.cpp: idem.
+     get_time_wide.pass.cpp: idem.
+     get_weekday.pass.cpp: idem.
+     get_weekday_wide.pass.cpp: idem.
+     get_year.pass.cpp: idem.
+     get_year_wide.pass.cpp: idem.
+   locale.time.put/
+    locale.time.put.members/
+     put1.pass.cpp: Needs investigating.
+     put2.pass.cpp: idem.
+    locale.time.put.byname/
+     put1.pass.cpp: Windows locale names don't follow UNIX convention.
+   facet.numpunct/
+    locale.numpunct/
+     locale.numpunct.byname/
+      decimal_point.pass.cpp: Failed constructing from C locale. Needs investigation.
+      grouping.pass.cpp: idem.
+      thousands_sep.pass.cpp: idem.
+ locale.stdcvt/
+  codecvt_utf16_in.pass.cpp: 0x40003 does not fit in a 2-byte wchar_t.
+  codecvt_utf16_out.pass.cpp: idem.
+  codecvt_utf8_in.pass.cpp: idem.
+  codecvt_utf8_out.pass.cpp: idem.
+  codecvt_utf8_utf16_in.pass: idem.
+  codecvt_utf8_utf16_out.pass.cpp: idem.
+ locales/
+  locale/
+   locale.cons/
+    assign.pass.cpp: Windows locale names don't follow UNIX convention.
+    char_pointer.pass.cpp: idem.
+    copy.pass.cpp: idem.
+    default.pass.cpp: idem.
+    locale_char_pointer_cat.pass.cpp: idem.
+    locale_facetptr.pass.cpp: idem.
+    locale_locale_cat.pass.cpp: idem.
+    locale_string_cat.pass.cpp: idem.
+    string.pass.cpp: idem.
+   locale.members/
+    name.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale.operators/
+    eq.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale/locale.statics/
+    classic.pass.cpp: Failed constructing from C locale. Needs investigation.
+    global.pass.cpp: Windows locale names don't follow UNIX convention.
+   locale.convenience/
+    conversions/
+     conversions.buffer/
+      overflow.pass.cpp: Needs investigation.
+      pbackfail.pass.cpp: idem.
+      seekoff.pass.cpp: idem.
+      test.pass.cpp: idem.
+      underflow.pass.cpp: idem.
+     conversions.string/
+      converted.pass.cpp: out of range hex sequence due to 2-byte wchar_t.
+      from_bytes.pass.cpp: idem (This test passed while it probably shouldn't!).
+      to_bytes.pass.cpp: idem.
+numerics/
+ complex.number/
+  complex.value.ops/
+   abs.pass.cpp: Failed assertion.
+   arg.pass.cpp: idem.
+ rand/
+  rand.device/
+   ctor.pass.cpp: No such thing as /dev/urandom on Windows. Need alternative.
+   entropy.pass.cpp: idem.
+   eval.pass.cpp: idem.
+  rand.dis/
+   rand.dist.bern/
+    rand.dist.bern.bernoulli/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.bern.bin/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.bern.geo/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.bern.negbin/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.norm/
+	  rand.dist.norm.cauchy/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.chisq/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.norm.f/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.lognormal/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.normal/
+     io.pass.cpp: Needs investigation. (different output double format?)
+	  rand.dist.norm.t/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.pois/
+    rand.dist.pois.exp/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.extreme/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.gamma/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.poisson/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.pois.weibull/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.samp/
+    rand.dist.samp.discrete/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.samp.pconst/
+     io.pass.cpp: Needs investigation. (different output double format?)
+    rand.dist.samp.plinear/
+     io.pass.cpp: Needs investigation. (different output double format?)
+   rand.dist.uni/
+    rand.dist.uni.real/
+     io.pass.cpp: Needs investigation. (different output double format?)
+re/
+ re.alg/
+  re.alg.match/
+   awk.pass.cpp: Needs investigation.
+   basic.pass.cpp: idem.
+   ecma.pass.cpp: idem.
+   extended.pass.cpp: idem.
+  re.alg.search/
+   awk.pass.cpp: Needs investigation.
+   basic.pass.cpp: idem.
+   ecma.pass.cpp: idem.
+   extended.pass.cpp: idem.
+ re.regex/
+  re.regex.locale/
+   imbue.pass.cpp: Windows locale names don't follow UNIX convention.
+ re.traits/
+  default.pass.cpp: Windows locale names don't follow UNIX convention.
+  getloc.pass.cpp: idem.
+  imbue.pass.cpp: idem.
+  isctype.pass.cpp: Needs investigation.
+  lookup_classname.pass.cpp: idem.
+  lookup_collatename.pass.cpp: Windows locale names don't follow UNIX convention.
+  transform.pass.cpp: idem.
+  transform_primary.pass.cpp: idem
+  translate_nocase.pass.cpp: Needs investigation.
+strings/
+ c.strings/
+  cuchar.pass.cpp: see previous note about uchar.h.
+  cwchar.pass.cpp: I suggest including the win32 support header which defines
+                   (v)swprintf to the Windows equivalent.
+  version_cuchar.pass.cpp: see previous note about uchar.h.
+ string.conversions/
+  stod.pass.cpp: "no conversion". Needs investigation.
+  stof.pass.cpp: idem.
+  to_string.pass.cpp: Needs investigation.
+  to_wstring.pass.cpp: idem.
+thread/
+ futures/
+  futures.async/
+   async.pass.cpp: Needs investigation.
+  futures.promise/
+   alloc_ctor.pass.cpp: Needs investigation.
+   default.pass.cpp: idem.
+   dtor.pass.cpp: idem.
+   get_future.pass.cpp: idem.
+   move_assign.pass.cpp: idem.
+   move_ctor.pass.cpp: idem.
+   set_exception.pass.cpp: idem.
+   set_exception_at_thread_exit.pass.cpp: idem.
+   set_lvalue.pass.cpp: idem.
+   set_lvalue_at_thread_exit.pass.cpp: idem.
+   set_rvalue.pass.cpp: idem.
+   set_rvalue_at_thread_exit.pass.cpp: idem.
+   set_value_at_thread_exit_const.pass.cpp: idem.
+   set_value_at_thread_exit_void.pass.cpp: idem.
+   set_value_const.pass.cpp: idem.
+   set_value_void.pass.cpp: idem.
+   swap.pass.cpp: idem.
+  futures.shared_future/
+   copy_assign.pass.cpp: Needs investigation.
+   copy_ctor.pass.cpp: idem.
+   ctor_future.pass.cpp: idem.
+   dtor.pass.cpp: idem.
+   get.pass.cpp: idem.
+   move_assign.pass.cpp: idem.
+   move_ctor.pass.cpp: idem.
+   wait.pass.cpp: idem.
+   wait_for.pass.cpp: idem.
+   wait_until.pass.cpp: idem.
+  futures.tas/
+   futures.task.members/
+    assign_move.pass.cpp: Needs investigation.
+    ctor_func.pass.cpp: idem.
+    ctor_func_alloc.pass.cpp: idem.
+    ctor_move.pass.cpp: idem.
+    dtor.pass.cpp: idem.
+    get_future.pass.cpp: idem.
+    make_ready_at_thread_exit.pass.cpp: idem.
+    operator.pass.cpp: idem.
+    reset.pass.cpp: idem.
+    swap.pass.cpp: idem.
+   futures.task.nonmembers/
+    swap.pass.cpp: Needs investigation.
+   futures.unique_future/
+    dtor.pass.cpp: Needs investigation.
+    get.pass.cpp: idem.
+    move_assign.pass.cpp: idem.
+    move_ctor.pass.cpp: idem.
+    share.pass.cpp: idem.
+    wait.pass.cpp: idem.
+    wait_for.pass.cpp: idem.
+    wait_until.pass.cpp: idem.
+ thread.condition/
+  thread.condition.condvar/
+   wait_for.pass.cpp: Needs investigation.
+  thread.condition.condvarany/
+   wait_for.pass.cpp: Needs investigation.
+ thread.mutex/
+  thread.lock/
+   thread.lock.unique/
+    thread.lock.unique.cons/
+     mutex_try_to_lock.pass.cpp: Needs investigation.
+ thread.threads/
+  thread.thread.class/
+   thread.thread.constr/
+    move.pass.cpp: Needs investigation.
+   thread.thread.id/
+    join.pass.cpp: Needs investigation.
+   thread.thread.static/
+    hardware_concurrency.pass.cpp: Needs investigation.
+utilities/
+ meta/
+  meta.trans/
+   meta.trans.other/
+    aligned_storage.pass.cpp: Probably due to sizeof(long) != 8.
+   meta.trans.sign/
+    make_signed.pass.cpp: Probably due to sizeof(wchar_t) != 4.
+    make_unsigned.pass.cpp: idem.
+   meta.unary.prop.query/
+    alignment_of.pass.cpp: Probably a Clang problem on Windows.
+</pre>
+</body>
+</html>
diff --git a/final/www/ts1z_status.html b/final/www/ts1z_status.html
new file mode 100644
index 0000000..3a15770
--- /dev/null
+++ b/final/www/ts1z_status.html
@@ -0,0 +1,89 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>libc++ C++1Y Status</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>Post-C++14 TS Implementation Status</h1>
+  <!--*********************************************************************-->
+
+  <p>In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, known as "C++1Y" (probably to be C++14)</p>
+  <p>The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol)</p>
+  <p>This page shows the status of libc++; the status of clang's support of the language features is <a href="http://clang.llvm.org/cxx_status.html">here</a>.</p>
+
+  <h3>Technical Specifications</h3>
+  <table id="TS" border="1">
+	<tr><th>Paper Number</th><th>TS Title</th></tr>
+
+	<tr><td>4023</td><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4023.html">C++ Extensions for Library Fundamentals</a></td></tr>
+	<tr><td>3940</td><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3940.html">Technical Specification - File System</a></td></tr>
+	<tr><td></td><td></td></tr>
+  </table>
+
+  <h3>Features in Library Fundamentals</h3>
+  <table id="Features" border="1">
+	<tr><th>Feature Name</th><th>Status</th></tr>
+	<tr><td>Uses-allocator construction</td><td>Not started</td></tr>
+	<tr><td>Changes to std::shared_ptr and weak_ptr</td><td>Not started</td></tr>
+	<tr><td>Additions to std::function</td><td>Not started</td></tr>
+	<tr><td>Changes to std::common_type</td><td>Not started</td></tr>
+	<tr><td>Changes to std::iterator_traits</td><td>Not started</td></tr>
+	<tr><td>Additions to std::promise</td><td>Not started</td></tr>
+	<tr><td>Additions to std::packaged_task</td><td>Not started</td></tr>
+  <tr><td></td><td></td></tr>
+	<tr><td>Class erased_type</td><td>Initial implementation complete</td></tr>
+	<tr><td>Calling a function with a tuple of arguments</td><td>Not started</td></tr>
+	<tr><td>Other type transformations</td><td>Not started</td></tr>
+	<tr><td>Compile-time Rational Arithmetic</td><td>Not started</td></tr>
+	<tr><td>Time Utilities</td><td>Not started</td></tr>
+	<tr><td>System Error Support</td><td>Not started</td></tr>
+  <tr><td></td><td></td></tr>
+	<tr><td>Searchers</td><td>Not started</td></tr>
+	<tr><td>Optional Objects</td><td>Initial implementation complete</td></tr>
+	<tr><td>class any</td><td>Not started</td></tr>
+	<tr><td>string_view</td><td>Implementation in progress</td></tr>
+	<tr><td>memory</td><td>Not started</td></tr>
+	<tr><td>Algorithms library</td><td>Not started</td></tr>
+	<tr><td>Networking</td><td>Not started</td></tr>
+
+  </table>
+
+  <h3>Features in Filesystem</h3>
+  <table id="Features" border="1">
+	<tr><th>Feature Name</th><th>Status</th></tr>
+	<tr><td>All features</td><td>Not started</td></tr>
+
+  </table>
+
+  <p>Last Updated: 2-June-2014</p>
+</div>
+</body>
+</html>
diff --git a/final/www/type_traits_design.html b/final/www/type_traits_design.html
new file mode 100644
index 0000000..ea173a8
--- /dev/null
+++ b/final/www/type_traits_design.html
@@ -0,0 +1,286 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd">
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>type traits intrinsic design</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/">LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">cfe-commits</a>
+    <a href="http://llvm.org/bugs/">Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/">Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/">Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+  <!--*********************************************************************-->
+  <h1>Type traits intrinsic design</h1>
+  <!--*********************************************************************-->
+
+<p>
+This is a survey of the type traits intrinsics clang has, and those needed.
+The names and definitions of several of the needed type traits has recently
+changed.  Please see:
+<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3142.html">N3142</a>.
+</p>
+
+<blockquote>
+<table border="1">
+<caption>Legend</caption>
+
+<tr>
+<td>clang supplies it and it is absolutely necessary</td>
+<td bgcolor="#80FF80"><tt>some_trait(T)</tt></td>
+</tr>
+
+<tr>
+<td>clang supplies it and it is useful</td>
+<td bgcolor="#96B9FF"><tt>some_trait(T)</tt></td>
+</tr>
+
+<tr>
+<td>clang supplies it and it is not needed</td>
+<td><tt>some_trait(T)</tt></td>
+</tr>
+
+<tr>
+<td>clang does not supply it and it is not needed</td>
+<td></td>
+</tr>
+
+<tr>
+<td>clang does not supply it and it is absolutely necessary</td>
+<td bgcolor="#FF5965"><tt>some_trait(T)</tt></td>
+</tr>
+
+</table>
+
+<p></p>
+
+<table border="1">
+<caption>Needed type traits vs clang type traits</caption>
+
+<tr>
+<th>libc++ Needs</th>
+<th>clang Has</th>
+</tr>
+
+<tr>
+<td><tt>is_union&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_union(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_class&lt;T&gt;</tt></td>
+<td bgcolor="#96B9FF"><tt>__is_class(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_enum&lt;T&gt;</tt></td>
+<td bgcolor="#96B9FF"><tt>__is_enum(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_pod&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_pod(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>has_virtual_destructor&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__has_virtual_destructor(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_constructible&lt;T, Args...&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_default_constructible&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_copy_constructible&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_move_constructible&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_assignable&lt;T, U&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_copy_assignable&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_move_assignable&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_destructible&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_constructible&lt;T, Args...&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_trivially_constructible(T, U)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_default_constructible&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__has_trivial_constructor(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_copy_constructible&lt;T&gt;</tt></td>
+<td><tt>__has_trivial_copy(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_move_constructible&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_assignable&lt;T, U&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_trivially_assignable(T, U)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_copy_assignable&lt;T&gt;</tt></td>
+<td><tt>__has_trivial_assign(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_move_assignable&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_destructible&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__has_trivial_destructor(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_constructible&lt;T, Args...&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_default_constructible&lt;T&gt;</tt></td>
+<td><tt>__has_nothrow_constructor(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_copy_constructible&lt;T&gt;</tt></td>
+<td><tt>__has_nothrow_copy(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_move_constructible&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_assignable&lt;T, U&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_copy_assignable&lt;T&gt;</tt></td>
+<td><tt>__has_nothrow_assign(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_move_assignable&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_nothrow_destructible&lt;T&gt;</tt></td>
+<td></td>
+</tr>
+
+<tr>
+<td><tt>is_trivial&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_trivial(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_trivially_copyable&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_trivially_copyable(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_standard_layout&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_standard_layout(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_literal_type&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_literal_type(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_convertible&lt;T, U&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_convertible_to(T, U)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_base_of&lt;T, U&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__is_base_of(T, U)</tt></td>
+</tr>
+
+<tr>
+<td><tt>underlying_type&lt;T&gt;</tt></td>
+<td bgcolor="#80FF80"><tt>__underlying_type(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_polymorphic&lt;T&gt;</tt></td>
+<td><tt>__is_polymorphic(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_empty&lt;T&gt;</tt></td>
+<td><tt>__is_empty(T)</tt></td>
+</tr>
+
+<tr>
+<td><tt>is_abstract&lt;T&gt;</tt></td>
+<td><tt>__is_abstract(T)</tt></td>
+</tr>
+
+</table>
+</blockquote>
+
+</div>
+</body>
+</html>